Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -133,6 +133,7 @@
"fix:python": "node scripts/lint_python.js --fix",
"fix": "npm-run-all --silent fix:*",
"toggle_puppeteer": "node scripts/toggle_puppeteer.js",
"version": "python3 python/perspective/scripts/write_version.py && git add python/perspective/perspective/core/_version.py"
"version": "python3 python/perspective/scripts/write_version.py && git add python/perspective/perspective/core/_version.py",
"jlab_link": "node scripts/jlab_link.js"
}
}
1 change: 1 addition & 0 deletions packages/perspective-jupyterlab/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@
"version": "yarn build"
},
"dependencies": {
"@finos/perspective": "^0.6.0",
"@finos/perspective-viewer": "^0.6.0",
"@finos/perspective-viewer-d3fc": "^0.6.0",
"@finos/perspective-viewer-datagrid": "^0.6.0",
Expand Down
1 change: 0 additions & 1 deletion packages/perspective/src/js/perspective.js
Original file line number Diff line number Diff line change
Expand Up @@ -1799,7 +1799,6 @@ export default function(Module) {
throw new Error("WebAssembly not supported");
} else {
console.log("Loading wasm");
console.log(msg.buffer.byteLength);
__MODULE__({
wasmBinary: msg.buffer,
wasmJSMethod: "native-wasm"
Expand Down
71 changes: 71 additions & 0 deletions scripts/jlab_link.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
/******************************************************************************
*
* Copyright (c) 2017, the Perspective Authors.
*
* This file is part of the Perspective library, distributed under the terms of
* the Apache License 2.0. The full license can be found in the LICENSE file.
*
*/
const path = require("path");
const {existsSync} = require("fs");
const {execute, execute_return} = require("./script_utils.js");

// Packages listed as dependencies & dev dependencies inside Jupyterlab plugin
const packages = ["perspective", "perspective-viewer", "perspective-viewer-datagrid", "perspective-viewer-d3fc", "perspective-test", "perspective-webpack-plugin"].map(pkg => `@finos/${pkg}`);

/**
* In order for Jupyterlab to pick up changes to @finos/perspective-* in the
* local working directory, we use `yarn link` to force Jupyterlab to look
* locally for all `perspective` packages, instead of pulling them from NPM
* during `jupyter lab install`. This script should be run whenever
* `jupyter lab clean` has been run, as cleaning the Jupyterlab dir will
* also break links.
*
* This allows us to distribute just the Jupyterlab plugin without inlining
* the rest of Perspective, but also allows for developers to see their local
* changes picked up in their current Jupyterlab installation.
*
* To set up your Jupyterlab environment with the local
* `perspective-jupyterlab` plugin, run
* `jupyter labextension install ./packages/perspective-jupyterlab` to link
* to the local plugin.
*/
(async function() {
try {
// check if @finos packages are already linked
const link_path = path.resolve(process.env.HOME, ".config/yarn/link", "@finos");

if (!existsSync(link_path)) {
throw Error(`No @finos links found in ${link_path} - run \`yarn link\` inside all Perspective packages first.`);
}

const paths = await execute_return("jupyter lab path");
const app_path = paths["stdout"]
.split("\n")[0]
.split(":")[1]
.trim();
const staging_path = path.resolve(app_path, "staging");

if (!existsSync(staging_path)) {
throw Error("Jupyterlab staging path does not exist - run `jupyter lab build` first.");
}

process.chdir(staging_path);

// Run yarn link inside jlab staging
for (const pkg of packages) {
execute(`yarn link ${pkg}`);
}

// Build from Perspective root
process.chdir(path.resolve(__dirname, ".."));
console.log("--------------------------");
execute("jupyter lab build");

console.log("--------------------------");
console.log("Jupyterlab should now have all changes from the current working directory. To pick up new changes, run `yarn build` and `jupyter lab build`.");
} catch (e) {
console.error(e);
process.exit(1);
}
})();
24 changes: 24 additions & 0 deletions scripts/script_utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@ const execSync = require("child_process").execSync;
const _path = require("path");
const fs = require("fs");
const rimraf = require("rimraf");
const {promisify} = require("util");

const isWin = process.platform === "win32";

/*******************************************************************************
Expand Down Expand Up @@ -70,6 +72,16 @@ const execute_throw = cmd => {
execSync(cmd, {stdio: "inherit"});
};

const execute_return = async cmd => {
if (process.argv.indexOf("--debug") > -1) {
console.log(`$ ${cmd}`);
}

const ex = promisify(require("child_process").exec);

return await ex(cmd);
}

/*******************************************************************************
*
* Public
Expand Down Expand Up @@ -186,6 +198,18 @@ exports.execute = (strings, ...args) => execute(Array.isArray(strings) ? bash(st
*/
exports.execute_throw = (strings, ...args) => execute_throw(Array.isArray(strings) ? bash(strings, ...args) : strings);

/**
* Just like `execute`, except it will return the output of the command
* it runs.
*
* @async
* @param {string} expression a bash command to be templated.
* @returns {string} A command with the missing argument's flags removed.
* @example
* execute`run -t${1} -u"${undefined}" task`;
*/
exports.execute_return = async (strings, ...args) => await execute_return(Array.isArray(strings) ? bash(strings, ...args) : strings);

/**
* Returns the value after this command-line flag, or `true` if it is the last
* arg. This makes it easy to null-pun for boolean flags, and capture the
Expand Down