diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 1680989a0..6b45e4fbf 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -24,8 +24,8 @@ conda activate retrolab # Install package in development mode pip install -e . -# Link the RetroLab JupyterLab extension -jupyter labextension develop . --overwrite +# Link the RetroLab JupyterLab extension and RetroLab schemas +jlpm develop # Enable the server extension jupyter server extension enable retrolab diff --git a/binder/postBuild b/binder/postBuild index 9fa663335..82203ae5c 100644 --- a/binder/postBuild +++ b/binder/postBuild @@ -1,4 +1,8 @@ #!/bin/bash set -euo pipefail -python -m pip install . \ No newline at end of file +jlpm && jlpm run build +python -m pip install -e . +jlpm run develop +jupyter server extension enable retrolab +jupyter serverextension enable retrolab \ No newline at end of file diff --git a/buildutils/src/develop.ts b/buildutils/src/develop.ts new file mode 100644 index 000000000..b464fea21 --- /dev/null +++ b/buildutils/src/develop.ts @@ -0,0 +1,51 @@ +/* ----------------------------------------------------------------------------- +| Copyright (c) Jupyter Development Team. +| Distributed under the terms of the Modified BSD License. +|----------------------------------------------------------------------------*/ + +import commander from 'commander'; + +import fs from 'fs-extra'; + +import path from 'path'; + +import process from 'process'; + +import { run } from '@jupyterlab/buildutils'; + +commander + .description('Setup the repository for develop mode') + .option('--overwrite', 'Force linking the RetroLab schemas') + .option('--source', 'The path to the retrolab package') + .action((options: any) => { + const { overwrite } = options; + const prefix = run( + 'python -c "import sys; print(sys.prefix)"', + { + stdio: 'pipe' + }, + true + ); + const source = path.resolve(options.source ?? process.cwd()); + const sourceDir = path.join(source, 'retrolab', 'schemas', '@retrolab'); + const destDir = path.join( + prefix, + 'share', + 'jupyter', + 'lab', + 'schemas', + '@retrolab' + ); + if (overwrite) { + try { + fs.unlinkSync(destDir); + console.log('Removed previous symlink:', destDir); + } catch (e) { + console.info('Skip unlinkink', destDir); + } + } + console.log('Symlinking:', sourceDir, destDir); + fs.symlinkSync(sourceDir, destDir, 'dir'); + }); + +commander.parse(process.argv); diff --git a/package.json b/package.json index d8c7a55ac..b77bd7ec1 100644 --- a/package.json +++ b/package.json @@ -26,6 +26,7 @@ "clean": "lerna run clean", "eslint": "eslint . --ext .ts,.tsx --fix", "eslint:check": "eslint . --ext .ts,.tsx", + "develop": "jupyter labextension develop . --overwrite && node ./buildutils/lib/develop.js --overwrite", "install": "lerna bootstrap", "integrity": "node buildutils/lib/ensure-repo.js", "prettier": "prettier --write \"**/*{.ts,.tsx,.js,.jsx,.css,.json,.md}\"",