From aa2811407ca2d65f55818899ee8925c5effea231 Mon Sep 17 00:00:00 2001 From: Jeremy Tuloup Date: Tue, 11 May 2021 13:44:40 +0200 Subject: [PATCH 01/11] Update all examples Update eslint-plugin-jsdoc Update jupyter_packaging on CI Update .eslintrc.js Lint and align prettier versions Update author --- .github/workflows/main.yml | 6 +- command-palette/.eslintrc.js | 28 ++++--- command-palette/package.json | 36 +++++---- command-palette/pyproject.toml | 18 ++++- command-palette/setup.py | 81 ++++++++----------- command-palette/src/index.ts | 6 +- commands/.eslintrc.js | 28 ++++--- commands/README.md | 6 +- commands/package.json | 36 +++++---- commands/pyproject.toml | 18 ++++- commands/setup.py | 81 ++++++++----------- commands/src/index.ts | 8 +- context-menu/.eslintrc.js | 28 ++++--- context-menu/package.json | 42 +++++----- context-menu/pyproject.toml | 18 ++++- context-menu/setup.py | 81 ++++++++----------- context-menu/src/index.ts | 14 ++-- custom-log-console/.eslintrc.js | 28 ++++--- custom-log-console/README.md | 2 +- custom-log-console/package.json | 50 +++++++----- custom-log-console/pyproject.toml | 18 ++++- custom-log-console/setup.py | 81 ++++++++----------- custom-log-console/src/index.ts | 52 ++++++------ custom-log-console/src/logLevelSwitcher.tsx | 10 +-- datagrid/.eslintrc.js | 28 ++++--- datagrid/package.json | 40 +++++---- datagrid/pyproject.toml | 18 ++++- datagrid/setup.py | 81 ++++++++----------- datagrid/src/index.ts | 8 +- hello-world/.eslintrc.js | 28 ++++--- hello-world/README.md | 2 +- hello-world/package.json | 36 +++++---- hello-world/pyproject.toml | 18 ++++- hello-world/setup.py | 81 ++++++++----------- hello-world/src/index.ts | 4 +- kernel-messaging/.eslintrc.js | 28 ++++--- kernel-messaging/README.md | 12 +-- kernel-messaging/package.json | 44 +++++----- kernel-messaging/pyproject.toml | 18 ++++- kernel-messaging/setup.py | 81 ++++++++----------- kernel-messaging/src/index.ts | 8 +- kernel-messaging/src/model.ts | 2 +- kernel-messaging/src/panel.ts | 10 +-- kernel-output/.eslintrc.js | 28 ++++--- kernel-output/README.md | 10 +-- kernel-output/package.json | 44 +++++----- kernel-output/pyproject.toml | 18 ++++- kernel-output/setup.py | 81 ++++++++----------- kernel-output/src/index.ts | 14 ++-- kernel-output/src/panel.ts | 14 ++-- launcher/.eslintrc.js | 28 ++++--- launcher/README.md | 14 ++-- launcher/package.json | 42 +++++----- launcher/pyproject.toml | 18 ++++- launcher/setup.py | 81 ++++++++----------- launcher/src/index.ts | 22 ++--- log-messages/.eslintrc.js | 28 ++++--- log-messages/package.json | 52 ++++++------ log-messages/pyproject.toml | 18 ++++- log-messages/setup.py | 81 ++++++++----------- log-messages/src/index.ts | 8 +- main-menu/.eslintrc.js | 28 ++++--- main-menu/README.md | 6 +- main-menu/package.json | 38 +++++---- main-menu/pyproject.toml | 18 ++++- main-menu/setup.py | 81 ++++++++----------- main-menu/src/index.ts | 8 +- package.json | 2 +- react-widget/.eslintrc.js | 28 ++++--- react-widget/package.json | 40 +++++---- react-widget/pyproject.toml | 18 ++++- react-widget/setup.py | 81 ++++++++----------- react-widget/src/index.ts | 10 +-- server-extension/.eslintrc.js | 28 ++++--- .../jupyter-config/jlab_ext_example.json | 7 ++ server-extension/package.json | 42 +++++----- server-extension/pyproject.toml | 18 ++++- server-extension/setup.py | 54 +++++-------- server-extension/src/index.ts | 10 +-- settings/.eslintrc.js | 28 ++++--- settings/package.json | 40 +++++---- settings/pyproject.toml | 18 ++++- settings/setup.py | 81 ++++++++----------- settings/src/index.ts | 14 ++-- signals/.eslintrc.js | 28 ++++--- signals/package.json | 47 ++++++----- signals/pyproject.toml | 18 ++++- signals/setup.py | 81 ++++++++----------- signals/src/button.ts | 2 +- signals/src/index.ts | 8 +- signals/src/panel.ts | 2 +- state/.eslintrc.js | 28 ++++--- state/README.md | 12 +-- state/package.json | 40 +++++---- state/pyproject.toml | 18 ++++- state/setup.py | 81 ++++++++----------- state/src/index.ts | 12 +-- widgets/.eslintrc.js | 28 ++++--- widgets/package.json | 38 +++++---- widgets/pyproject.toml | 18 ++++- widgets/setup.py | 81 ++++++++----------- widgets/src/index.ts | 6 +- 102 files changed, 1699 insertions(+), 1471 deletions(-) create mode 100644 server-extension/jupyter-config/jlab_ext_example.json diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index fa53c16e..f9f79428 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -89,7 +89,7 @@ jobs: - name: Install the Python dependencies if: steps.filter.outputs.extension == 'true' run: | - python -m pip install --upgrade pip jupyter_packaging~=0.7.9 jupyterlab~=3.0 + python -m pip install --upgrade pip jupyter_packaging~=0.10 jupyterlab~=3.0 - name: Install the NPM dependencies if: steps.filter.outputs.extension == 'true' run: | @@ -179,7 +179,7 @@ jobs: - name: Install the Python dependencies if: steps.filter.outputs.extension == 'true' run: | - python -m pip install --upgrade pip jupyter_packaging~=0.7.9 jupyterlab~=3.0 + python -m pip install --upgrade pip jupyter_packaging~=0.10 jupyterlab~=3.0 - name: Install the NPM dependencies if: steps.filter.outputs.extension == 'true' run: | @@ -262,7 +262,7 @@ jobs: restore-keys: | ${{ runner.os }}-pip- - name: Install the Python dependencies - run: python -m pip install jupyter_packaging~=0.7.9 jupyterlab~=3.0 pytest pytest-check-links + run: python -m pip install jupyter_packaging~=0.10 jupyterlab~=3.0 pytest pytest-check-links - name: Bootstrap the jlpm deps run: jlpm - name: Build all the extensions diff --git a/command-palette/.eslintrc.js b/command-palette/.eslintrc.js index 652320e0..c2375786 100644 --- a/command-palette/.eslintrc.js +++ b/command-palette/.eslintrc.js @@ -5,28 +5,34 @@ module.exports = { 'plugin:@typescript-eslint/recommended', 'plugin:jsdoc/recommended', 'plugin:prettier/recommended', - 'plugin:react/recommended' + 'plugin:react/recommended', ], parser: '@typescript-eslint/parser', parserOptions: { project: 'tsconfig.json', - sourceType: 'module' + sourceType: 'module', }, plugins: ['@typescript-eslint', 'jsdoc'], rules: { - '@typescript-eslint/interface-name-prefix': [ + '@typescript-eslint/naming-convention': [ 'error', - { prefixWithI: 'always' } + { + selector: 'interface', + format: ['PascalCase'], + custom: { + regex: '^I[A-Z]', + match: true, + }, + }, ], '@typescript-eslint/no-unused-vars': ['warn', { args: 'none' }], '@typescript-eslint/no-explicit-any': 'off', - '@typescript-eslint/camelcase': 'warn', '@typescript-eslint/no-namespace': 'off', '@typescript-eslint/no-use-before-define': 'off', '@typescript-eslint/quotes': [ 'error', 'single', - { avoidEscape: true, allowTemplateLiterals: false } + { avoidEscape: true, allowTemplateLiterals: false }, ], curly: ['error', 'all'], eqeqeq: 'error', @@ -34,14 +40,14 @@ module.exports = { 'jsdoc/require-property-type': 'off', 'jsdoc/require-returns-type': 'off', 'jsdoc/no-types': 'warn', - 'prefer-arrow-callback': 'error' + 'prefer-arrow-callback': 'error', }, settings: { jsdoc: { - mode: 'typescript' + mode: 'typescript', }, react: { - version: 'detect' - } - } + version: 'detect', + }, + }, }; diff --git a/command-palette/package.json b/command-palette/package.json index 3572bcad..ad568540 100644 --- a/command-palette/package.json +++ b/command-palette/package.json @@ -12,10 +12,14 @@ "url": "https://github.com/jupyterlab/extension-examples/issues" }, "license": "BSD-3-Clause", - "author": "Project Jupyter Contributors", + "author": { + "name": "Project Jupyter Contributors", + "email": "" + }, "files": [ "lib/**/*.{d.ts,eot,gif,html,jpg,js,js.map,json,png,svg,woff2,ttf}", - "style/**/*.{css,eot,gif,html,jpg,json,png,svg,woff2,ttf}" + "style/**/*.{css,eot,gif,html,jpg,json,png,svg,woff2,ttf}", + "style/index.js" ], "main": "lib/index.js", "types": "lib/index.d.ts", @@ -30,41 +34,43 @@ "build:labextension": "jupyter labextension build .", "build:labextension:dev": "jupyter labextension build --development True .", "build:lib": "tsc", - "build:prod": "jlpm run build:lib && jlpm run build:labextension", + "build:prod": "jlpm run clean && jlpm run build:lib && jlpm run build:labextension", "clean": "jlpm run clean:lib", "clean:all": "jlpm run clean:lib && jlpm run clean:labextension", "clean:labextension": "rimraf jupyterlab_examples_command_palette/labextension", "clean:lib": "rimraf lib tsconfig.tsbuildinfo", "eslint": "eslint . --ext .ts,.tsx --fix", "eslint:check": "eslint . --ext .ts,.tsx", - "install:extension": "jupyter labextension develop --overwrite .", + "install:extension": "jlpm run build", "prepare": "jlpm run clean && jlpm run build:prod", "watch": "run-p watch:src watch:labextension", "watch:labextension": "jupyter labextension watch .", "watch:src": "tsc -w" }, "dependencies": { - "@jupyterlab/application": "^3.0.0-rc.15" + "@jupyterlab/application": "^3.0.10" }, "devDependencies": { - "@jupyterlab/builder": "^3.0.0-rc.15", - "@typescript-eslint/eslint-plugin": "^2.27.0", - "@typescript-eslint/parser": "^2.27.0", - "eslint": "^7.5.0", - "eslint-config-prettier": "^6.10.1", - "eslint-plugin-jsdoc": "^22.0.0", - "eslint-plugin-prettier": "^3.1.2", + "@jupyterlab/builder": "^3.0.0", + "@typescript-eslint/eslint-plugin": "^4.8.1", + "@typescript-eslint/parser": "^4.8.1", + "eslint": "^7.14.0", + "eslint-config-prettier": "^6.15.0", + "eslint-plugin-jsdoc": "^34.0.0", + "eslint-plugin-prettier": "^3.1.4", "eslint-plugin-react": "^7.18.3", "npm-run-all": "^4.1.5", - "prettier": "^1.19.0", + "prettier": "^2.1.1", "rimraf": "^3.0.2", "typescript": "~4.1.3" }, "sideEffects": [ - "style/*.css" + "style/*.css", + "style/index.js" ], "jupyterlab": { "extension": true, "outputDir": "jupyterlab_examples_command_palette/labextension" - } + }, + "styleModule": "style/index.js" } \ No newline at end of file diff --git a/command-palette/pyproject.toml b/command-palette/pyproject.toml index c40f3629..3079f611 100644 --- a/command-palette/pyproject.toml +++ b/command-palette/pyproject.toml @@ -1,3 +1,17 @@ [build-system] -requires = ["jupyter_packaging~=0.7.9", "jupyterlab>=3.0.0rc15,==3.*", "setuptools>=40.8.0", "wheel"] -build-backend = "setuptools.build_meta" +requires = ["jupyter_packaging~=0.10,<2", "jupyterlab~=3.0"] +build-backend = "jupyter_packaging.build_api" + +[tool.jupyter-packaging.options] +skip-if-exists = ["jupyterlab_examples_command_palette/labextension/static/style.js"] +ensured-targets = ["jupyterlab_examples_command_palette/labextension/static/style.js", "jupyterlab_examples_command_palette/labextension/package.json"] + +[tool.jupyter-packaging.builder] +factory = "jupyter_packaging.npm_builder" + +[tool.jupyter-packaging.build-args] +build_cmd = "build:prod" +npm = ["jlpm"] + +[tool.check-manifest] +ignore = ["jupyterlab_examples_command_palette/labextension/**", "yarn.lock", ".*", "package-lock.json"] diff --git a/command-palette/setup.py b/command-palette/setup.py index fe413975..1f9895cd 100644 --- a/command-palette/setup.py +++ b/command-palette/setup.py @@ -2,79 +2,52 @@ jupyterlab_examples_command_palette setup """ import json -import os +from pathlib import Path -from jupyter_packaging import ( - create_cmdclass, install_npm, ensure_targets, - combine_commands, skip_if_exists -) import setuptools -HERE = os.path.abspath(os.path.dirname(__file__)) +HERE = Path(__file__).parent.resolve() # The name of the project -name="jupyterlab_examples_command_palette" - -# Get our version -with open(os.path.join(HERE, 'package.json')) as f: - version = json.load(f)['version'] +name = "jupyterlab_examples_command_palette" -lab_path = os.path.join(HERE, name, "labextension") +lab_path = (HERE / name / "labextension") # Representative files that should exist after a successful build -jstargets = [ - os.path.join(lab_path, "package.json"), +ensured_targets = [ + str(lab_path / "package.json"), + str(lab_path / "static/style.js") ] -package_data_spec = { - name: [ - "*" - ] -} - labext_name = "@jupyterlab-examples/command-palette" data_files_spec = [ - ("share/jupyter/labextensions/%s" % labext_name, lab_path, "**"), - ("share/jupyter/labextensions/%s" % labext_name, HERE, "install.json"), + ("share/jupyter/labextensions/%s" % labext_name, str(lab_path), "**"), + ("share/jupyter/labextensions/%s" % labext_name, str(HERE), "install.json"), ] -cmdclass = create_cmdclass("jsdeps", - package_data_spec=package_data_spec, - data_files_spec=data_files_spec -) - -js_command = combine_commands( - install_npm(HERE, build_cmd="build:prod", npm=["jlpm"]), - ensure_targets(jstargets), -) - -is_repo = os.path.exists(os.path.join(HERE, ".git")) -if is_repo: - cmdclass["jsdeps"] = js_command -else: - cmdclass["jsdeps"] = skip_if_exists(jstargets, js_command) +long_description = (HERE / "README.md").read_text() -with open("README.md", "r") as fh: - long_description = fh.read() +# Get the package info from package.json +pkg_json = json.loads((HERE / "package.json").read_bytes()) setup_args = dict( name=name, - version=version, - url="https://github.com/jupyterlab/extension-examples.git", - author="Project Jupyter Contributors", - description="Minimal JupyterLab example adding a new command to the palette.", - long_description= long_description, + version=pkg_json["version"], + url=pkg_json["homepage"], + author=pkg_json["author"]["name"], + author_email=pkg_json["author"]["email"], + description=pkg_json["description"], + license=pkg_json["license"], + long_description=long_description, long_description_content_type="text/markdown", - cmdclass= cmdclass, packages=setuptools.find_packages(), install_requires=[ - "jupyterlab>=3.0.0rc15,==3.*", + "jupyter_server>=1.6,<2" ], zip_safe=False, include_package_data=True, python_requires=">=3.6", - license="BSD-3-Clause", platforms="Linux, Mac OS X, Windows", keywords=["Jupyter", "JupyterLab", "JupyterLab3"], classifiers=[ @@ -84,10 +57,24 @@ "Programming Language :: Python :: 3.6", "Programming Language :: Python :: 3.7", "Programming Language :: Python :: 3.8", + "Programming Language :: Python :: 3.9", "Framework :: Jupyter", ], ) +try: + from jupyter_packaging import ( + wrap_installers, + npm_builder, + get_data_files + ) + post_develop = npm_builder( + build_cmd="install:extension", source_dir="src", build_dir=lab_path + ) + setup_args['cmdclass'] = wrap_installers(post_develop=post_develop, ensured_targets=ensured_targets) + setup_args['data_files'] = get_data_files(data_files_spec) +except ImportError as e: + pass if __name__ == "__main__": setuptools.setup(**setup_args) diff --git a/command-palette/src/index.ts b/command-palette/src/index.ts index 2dfdd692..a8f8eb88 100644 --- a/command-palette/src/index.ts +++ b/command-palette/src/index.ts @@ -1,6 +1,6 @@ import { JupyterFrontEnd, - JupyterFrontEndPlugin + JupyterFrontEndPlugin, } from '@jupyterlab/application'; import { ICommandPalette } from '@jupyterlab/apputils'; @@ -25,13 +25,13 @@ const extension: JupyterFrontEndPlugin = { console.log( `jlab-examples:command-palette has been called ${args['origin']}.` ); - } + }, }); // Add the command to the command palette const category = 'Extension Examples'; palette.addItem({ command, category, args: { origin: 'from palette' } }); - } + }, }; export default extension; diff --git a/commands/.eslintrc.js b/commands/.eslintrc.js index 652320e0..c2375786 100644 --- a/commands/.eslintrc.js +++ b/commands/.eslintrc.js @@ -5,28 +5,34 @@ module.exports = { 'plugin:@typescript-eslint/recommended', 'plugin:jsdoc/recommended', 'plugin:prettier/recommended', - 'plugin:react/recommended' + 'plugin:react/recommended', ], parser: '@typescript-eslint/parser', parserOptions: { project: 'tsconfig.json', - sourceType: 'module' + sourceType: 'module', }, plugins: ['@typescript-eslint', 'jsdoc'], rules: { - '@typescript-eslint/interface-name-prefix': [ + '@typescript-eslint/naming-convention': [ 'error', - { prefixWithI: 'always' } + { + selector: 'interface', + format: ['PascalCase'], + custom: { + regex: '^I[A-Z]', + match: true, + }, + }, ], '@typescript-eslint/no-unused-vars': ['warn', { args: 'none' }], '@typescript-eslint/no-explicit-any': 'off', - '@typescript-eslint/camelcase': 'warn', '@typescript-eslint/no-namespace': 'off', '@typescript-eslint/no-use-before-define': 'off', '@typescript-eslint/quotes': [ 'error', 'single', - { avoidEscape: true, allowTemplateLiterals: false } + { avoidEscape: true, allowTemplateLiterals: false }, ], curly: ['error', 'all'], eqeqeq: 'error', @@ -34,14 +40,14 @@ module.exports = { 'jsdoc/require-property-type': 'off', 'jsdoc/require-returns-type': 'off', 'jsdoc/no-types': 'warn', - 'prefer-arrow-callback': 'error' + 'prefer-arrow-callback': 'error', }, settings: { jsdoc: { - mode: 'typescript' + mode: 'typescript', }, react: { - version: 'detect' - } - } + version: 'detect', + }, + }, }; diff --git a/commands/README.md b/commands/README.md index 7c94a21a..fdea886f 100644 --- a/commands/README.md +++ b/commands/README.md @@ -40,16 +40,16 @@ const extension: JupyterFrontEndPlugin = { if (orig !== 'init') { window.alert(`jlab-examples:command has been called from ${orig}.`); } - } + }, }); // Call the command execution - commands.execute(command, { origin: 'init' }).catch(reason => { + commands.execute(command, { origin: 'init' }).catch((reason) => { console.error( `An error occurred during the execution of jlab-examples:command.\n${reason}` ); }); - } + }, }; ``` diff --git a/commands/package.json b/commands/package.json index 5fdddfe9..0451f480 100644 --- a/commands/package.json +++ b/commands/package.json @@ -12,10 +12,14 @@ "url": "https://github.com/jupyterlab/extension-examples/issues" }, "license": "BSD-3-Clause", - "author": "Project Jupyter Contributors", + "author": { + "name": "Project Jupyter Contributors", + "email": "" + }, "files": [ "lib/**/*.{d.ts,eot,gif,html,jpg,js,js.map,json,png,svg,woff2,ttf}", - "style/**/*.{css,eot,gif,html,jpg,json,png,svg,woff2,ttf}" + "style/**/*.{css,eot,gif,html,jpg,json,png,svg,woff2,ttf}", + "style/index.js" ], "main": "lib/index.js", "types": "lib/index.d.ts", @@ -30,41 +34,43 @@ "build:labextension": "jupyter labextension build .", "build:labextension:dev": "jupyter labextension build --development True .", "build:lib": "tsc", - "build:prod": "jlpm run build:lib && jlpm run build:labextension", + "build:prod": "jlpm run clean && jlpm run build:lib && jlpm run build:labextension", "clean": "jlpm run clean:lib", "clean:all": "jlpm run clean:lib && jlpm run clean:labextension", "clean:labextension": "rimraf jupyterlab_examples_commands/labextension", "clean:lib": "rimraf lib tsconfig.tsbuildinfo", "eslint": "eslint . --ext .ts,.tsx --fix", "eslint:check": "eslint . --ext .ts,.tsx", - "install:extension": "jupyter labextension develop --overwrite .", + "install:extension": "jlpm run build", "prepare": "jlpm run clean && jlpm run build:prod", "watch": "run-p watch:src watch:labextension", "watch:labextension": "jupyter labextension watch .", "watch:src": "tsc -w" }, "dependencies": { - "@jupyterlab/application": "^3.0.0-rc.15" + "@jupyterlab/application": "^3.0.10" }, "devDependencies": { - "@jupyterlab/builder": "^3.0.0-rc.15", - "@typescript-eslint/eslint-plugin": "^2.27.0", - "@typescript-eslint/parser": "^2.27.0", - "eslint": "^7.5.0", - "eslint-config-prettier": "^6.10.1", - "eslint-plugin-jsdoc": "^22.0.0", - "eslint-plugin-prettier": "^3.1.2", + "@jupyterlab/builder": "^3.0.0", + "@typescript-eslint/eslint-plugin": "^4.8.1", + "@typescript-eslint/parser": "^4.8.1", + "eslint": "^7.14.0", + "eslint-config-prettier": "^6.15.0", + "eslint-plugin-jsdoc": "^34.0.0", + "eslint-plugin-prettier": "^3.1.4", "eslint-plugin-react": "^7.18.3", "npm-run-all": "^4.1.5", - "prettier": "^1.19.0", + "prettier": "^2.1.1", "rimraf": "^3.0.2", "typescript": "~4.1.3" }, "sideEffects": [ - "style/*.css" + "style/*.css", + "style/index.js" ], "jupyterlab": { "extension": true, "outputDir": "jupyterlab_examples_commands/labextension" - } + }, + "styleModule": "style/index.js" } \ No newline at end of file diff --git a/commands/pyproject.toml b/commands/pyproject.toml index c40f3629..d2804842 100644 --- a/commands/pyproject.toml +++ b/commands/pyproject.toml @@ -1,3 +1,17 @@ [build-system] -requires = ["jupyter_packaging~=0.7.9", "jupyterlab>=3.0.0rc15,==3.*", "setuptools>=40.8.0", "wheel"] -build-backend = "setuptools.build_meta" +requires = ["jupyter_packaging~=0.10,<2", "jupyterlab~=3.0"] +build-backend = "jupyter_packaging.build_api" + +[tool.jupyter-packaging.options] +skip-if-exists = ["jupyterlab_examples_commands/labextension/static/style.js"] +ensured-targets = ["jupyterlab_examples_commands/labextension/static/style.js", "jupyterlab_examples_commands/labextension/package.json"] + +[tool.jupyter-packaging.builder] +factory = "jupyter_packaging.npm_builder" + +[tool.jupyter-packaging.build-args] +build_cmd = "build:prod" +npm = ["jlpm"] + +[tool.check-manifest] +ignore = ["jupyterlab_examples_commands/labextension/**", "yarn.lock", ".*", "package-lock.json"] diff --git a/commands/setup.py b/commands/setup.py index 1448ae43..0cc57823 100644 --- a/commands/setup.py +++ b/commands/setup.py @@ -2,79 +2,52 @@ jupyterlab_examples_commands setup """ import json -import os +from pathlib import Path -from jupyter_packaging import ( - create_cmdclass, install_npm, ensure_targets, - combine_commands, skip_if_exists -) import setuptools -HERE = os.path.abspath(os.path.dirname(__file__)) +HERE = Path(__file__).parent.resolve() # The name of the project -name="jupyterlab_examples_commands" - -# Get our version -with open(os.path.join(HERE, 'package.json')) as f: - version = json.load(f)['version'] +name = "jupyterlab_examples_commands" -lab_path = os.path.join(HERE, name, "labextension") +lab_path = (HERE / name / "labextension") # Representative files that should exist after a successful build -jstargets = [ - os.path.join(lab_path, "package.json"), +ensured_targets = [ + str(lab_path / "package.json"), + str(lab_path / "static/style.js") ] -package_data_spec = { - name: [ - "*" - ] -} - labext_name = "@jupyterlab-examples/commands" data_files_spec = [ - ("share/jupyter/labextensions/%s" % labext_name, lab_path, "**"), - ("share/jupyter/labextensions/%s" % labext_name, HERE, "install.json"), + ("share/jupyter/labextensions/%s" % labext_name, str(lab_path), "**"), + ("share/jupyter/labextensions/%s" % labext_name, str(HERE), "install.json"), ] -cmdclass = create_cmdclass("jsdeps", - package_data_spec=package_data_spec, - data_files_spec=data_files_spec -) - -js_command = combine_commands( - install_npm(HERE, build_cmd="build:prod", npm=["jlpm"]), - ensure_targets(jstargets), -) - -is_repo = os.path.exists(os.path.join(HERE, ".git")) -if is_repo: - cmdclass["jsdeps"] = js_command -else: - cmdclass["jsdeps"] = skip_if_exists(jstargets, js_command) +long_description = (HERE / "README.md").read_text() -with open("README.md", "r") as fh: - long_description = fh.read() +# Get the package info from package.json +pkg_json = json.loads((HERE / "package.json").read_bytes()) setup_args = dict( name=name, - version=version, - url="https://github.com/jupyterlab/extension-examples.git", - author="Project Jupyter Contributors", - description="Minimal JupyterLab example creating a new command.", - long_description= long_description, + version=pkg_json["version"], + url=pkg_json["homepage"], + author=pkg_json["author"]["name"], + author_email=pkg_json["author"]["email"], + description=pkg_json["description"], + license=pkg_json["license"], + long_description=long_description, long_description_content_type="text/markdown", - cmdclass= cmdclass, packages=setuptools.find_packages(), install_requires=[ - "jupyterlab>=3.0.0rc15,==3.*", + "jupyter_server>=1.6,<2" ], zip_safe=False, include_package_data=True, python_requires=">=3.6", - license="BSD-3-Clause", platforms="Linux, Mac OS X, Windows", keywords=["Jupyter", "JupyterLab", "JupyterLab3"], classifiers=[ @@ -84,10 +57,24 @@ "Programming Language :: Python :: 3.6", "Programming Language :: Python :: 3.7", "Programming Language :: Python :: 3.8", + "Programming Language :: Python :: 3.9", "Framework :: Jupyter", ], ) +try: + from jupyter_packaging import ( + wrap_installers, + npm_builder, + get_data_files + ) + post_develop = npm_builder( + build_cmd="install:extension", source_dir="src", build_dir=lab_path + ) + setup_args['cmdclass'] = wrap_installers(post_develop=post_develop, ensured_targets=ensured_targets) + setup_args['data_files'] = get_data_files(data_files_spec) +except ImportError as e: + pass if __name__ == "__main__": setuptools.setup(**setup_args) diff --git a/commands/src/index.ts b/commands/src/index.ts index 610e9a0b..df8b5b1e 100644 --- a/commands/src/index.ts +++ b/commands/src/index.ts @@ -1,6 +1,6 @@ import { JupyterFrontEnd, - JupyterFrontEndPlugin + JupyterFrontEndPlugin, } from '@jupyterlab/application'; /** @@ -24,16 +24,16 @@ const extension: JupyterFrontEndPlugin = { if (orig !== 'init') { window.alert(`jlab-examples:command has been called from ${orig}.`); } - } + }, }); // Call the command execution - commands.execute(command, { origin: 'init' }).catch(reason => { + commands.execute(command, { origin: 'init' }).catch((reason) => { console.error( `An error occurred during the execution of jlab-examples:command.\n${reason}` ); }); - } + }, }; export default extension; diff --git a/context-menu/.eslintrc.js b/context-menu/.eslintrc.js index 652320e0..c2375786 100644 --- a/context-menu/.eslintrc.js +++ b/context-menu/.eslintrc.js @@ -5,28 +5,34 @@ module.exports = { 'plugin:@typescript-eslint/recommended', 'plugin:jsdoc/recommended', 'plugin:prettier/recommended', - 'plugin:react/recommended' + 'plugin:react/recommended', ], parser: '@typescript-eslint/parser', parserOptions: { project: 'tsconfig.json', - sourceType: 'module' + sourceType: 'module', }, plugins: ['@typescript-eslint', 'jsdoc'], rules: { - '@typescript-eslint/interface-name-prefix': [ + '@typescript-eslint/naming-convention': [ 'error', - { prefixWithI: 'always' } + { + selector: 'interface', + format: ['PascalCase'], + custom: { + regex: '^I[A-Z]', + match: true, + }, + }, ], '@typescript-eslint/no-unused-vars': ['warn', { args: 'none' }], '@typescript-eslint/no-explicit-any': 'off', - '@typescript-eslint/camelcase': 'warn', '@typescript-eslint/no-namespace': 'off', '@typescript-eslint/no-use-before-define': 'off', '@typescript-eslint/quotes': [ 'error', 'single', - { avoidEscape: true, allowTemplateLiterals: false } + { avoidEscape: true, allowTemplateLiterals: false }, ], curly: ['error', 'all'], eqeqeq: 'error', @@ -34,14 +40,14 @@ module.exports = { 'jsdoc/require-property-type': 'off', 'jsdoc/require-returns-type': 'off', 'jsdoc/no-types': 'warn', - 'prefer-arrow-callback': 'error' + 'prefer-arrow-callback': 'error', }, settings: { jsdoc: { - mode: 'typescript' + mode: 'typescript', }, react: { - version: 'detect' - } - } + version: 'detect', + }, + }, }; diff --git a/context-menu/package.json b/context-menu/package.json index 7d7e8d78..d5d84755 100644 --- a/context-menu/package.json +++ b/context-menu/package.json @@ -12,10 +12,14 @@ "url": "https://github.com/jupyterlab/extension-examples/issues" }, "license": "BSD-3-Clause", - "author": "Project Jupyter Contributors", + "author": { + "name": "Project Jupyter Contributors", + "email": "" + }, "files": [ "lib/**/*.{d.ts,eot,gif,html,jpg,js,js.map,json,png,svg,woff2,ttf}", - "style/**/*.{css,eot,gif,html,jpg,json,png,svg,woff2,ttf}" + "style/**/*.{css,eot,gif,html,jpg,json,png,svg,woff2,ttf}", + "style/index.js" ], "main": "lib/index.js", "types": "lib/index.d.ts", @@ -30,44 +34,46 @@ "build:labextension": "jupyter labextension build .", "build:labextension:dev": "jupyter labextension build --development True .", "build:lib": "tsc", - "build:prod": "jlpm run build:lib && jlpm run build:labextension", + "build:prod": "jlpm run clean && jlpm run build:lib && jlpm run build:labextension", "clean": "jlpm run clean:lib", "clean:all": "jlpm run clean:lib && jlpm run clean:labextension", "clean:labextension": "rimraf jupyterlab_examples_context_menu/labextension", "clean:lib": "rimraf lib tsconfig.tsbuildinfo", "eslint": "eslint . --ext .ts,.tsx --fix", "eslint:check": "eslint . --ext .ts,.tsx", - "install:extension": "jupyter labextension develop --overwrite .", + "install:extension": "jlpm run build", "prepare": "jlpm run clean && jlpm run build:prod", "watch": "run-p watch:src watch:labextension", "watch:labextension": "jupyter labextension watch .", "watch:src": "tsc -w" }, "dependencies": { - "@jupyterlab/application": "^3.0.0-rc.15", - "@jupyterlab/apputils": "^3.0.0-rc.15", - "@jupyterlab/filebrowser": "^3.0.0-rc.15", - "@jupyterlab/ui-components": "^3.0.0-rc.15" + "@jupyterlab/application": "^3.0.10", + "@jupyterlab/apputils": "^3.0.8", + "@jupyterlab/filebrowser": "^3.0.10", + "@jupyterlab/ui-components": "^3.0.7" }, "devDependencies": { - "@jupyterlab/builder": "^3.0.0-rc.15", - "@typescript-eslint/eslint-plugin": "^2.27.0", - "@typescript-eslint/parser": "^2.27.0", - "eslint": "^7.5.0", - "eslint-config-prettier": "^6.10.1", - "eslint-plugin-jsdoc": "^22.0.0", - "eslint-plugin-prettier": "^3.1.2", + "@jupyterlab/builder": "^3.0.0", + "@typescript-eslint/eslint-plugin": "^4.8.1", + "@typescript-eslint/parser": "^4.8.1", + "eslint": "^7.14.0", + "eslint-config-prettier": "^6.15.0", + "eslint-plugin-jsdoc": "^34.0.0", + "eslint-plugin-prettier": "^3.1.4", "eslint-plugin-react": "^7.18.3", "npm-run-all": "^4.1.5", - "prettier": "^1.19.0", + "prettier": "^2.1.1", "rimraf": "^3.0.2", "typescript": "~4.1.3" }, "sideEffects": [ - "style/*.css" + "style/*.css", + "style/index.js" ], "jupyterlab": { "extension": true, "outputDir": "jupyterlab_examples_context_menu/labextension" - } + }, + "styleModule": "style/index.js" } \ No newline at end of file diff --git a/context-menu/pyproject.toml b/context-menu/pyproject.toml index c40f3629..14436ae7 100644 --- a/context-menu/pyproject.toml +++ b/context-menu/pyproject.toml @@ -1,3 +1,17 @@ [build-system] -requires = ["jupyter_packaging~=0.7.9", "jupyterlab>=3.0.0rc15,==3.*", "setuptools>=40.8.0", "wheel"] -build-backend = "setuptools.build_meta" +requires = ["jupyter_packaging~=0.10,<2", "jupyterlab~=3.0"] +build-backend = "jupyter_packaging.build_api" + +[tool.jupyter-packaging.options] +skip-if-exists = ["jupyterlab_examples_context_menu/labextension/static/style.js"] +ensured-targets = ["jupyterlab_examples_context_menu/labextension/static/style.js", "jupyterlab_examples_context_menu/labextension/package.json"] + +[tool.jupyter-packaging.builder] +factory = "jupyter_packaging.npm_builder" + +[tool.jupyter-packaging.build-args] +build_cmd = "build:prod" +npm = ["jlpm"] + +[tool.check-manifest] +ignore = ["jupyterlab_examples_context_menu/labextension/**", "yarn.lock", ".*", "package-lock.json"] diff --git a/context-menu/setup.py b/context-menu/setup.py index ce0832aa..ec1c0d3b 100644 --- a/context-menu/setup.py +++ b/context-menu/setup.py @@ -2,79 +2,52 @@ jupyterlab_examples_context_menu setup """ import json -import os +from pathlib import Path -from jupyter_packaging import ( - create_cmdclass, install_npm, ensure_targets, - combine_commands, skip_if_exists -) import setuptools -HERE = os.path.abspath(os.path.dirname(__file__)) +HERE = Path(__file__).parent.resolve() # The name of the project -name="jupyterlab_examples_context_menu" - -# Get our version -with open(os.path.join(HERE, 'package.json')) as f: - version = json.load(f)['version'] +name = "jupyterlab_examples_context_menu" -lab_path = os.path.join(HERE, name, "labextension") +lab_path = (HERE / name / "labextension") # Representative files that should exist after a successful build -jstargets = [ - os.path.join(lab_path, "package.json"), +ensured_targets = [ + str(lab_path / "package.json"), + str(lab_path / "static/style.js") ] -package_data_spec = { - name: [ - "*" - ] -} - labext_name = "@jupyterlab-examples/context-menu" data_files_spec = [ - ("share/jupyter/labextensions/%s" % labext_name, lab_path, "**"), - ("share/jupyter/labextensions/%s" % labext_name, HERE, "install.json"), + ("share/jupyter/labextensions/%s" % labext_name, str(lab_path), "**"), + ("share/jupyter/labextensions/%s" % labext_name, str(HERE), "install.json"), ] -cmdclass = create_cmdclass("jsdeps", - package_data_spec=package_data_spec, - data_files_spec=data_files_spec -) - -js_command = combine_commands( - install_npm(HERE, build_cmd="build:prod", npm=["jlpm"]), - ensure_targets(jstargets), -) - -is_repo = os.path.exists(os.path.join(HERE, ".git")) -if is_repo: - cmdclass["jsdeps"] = js_command -else: - cmdclass["jsdeps"] = skip_if_exists(jstargets, js_command) +long_description = (HERE / "README.md").read_text() -with open("README.md", "r") as fh: - long_description = fh.read() +# Get the package info from package.json +pkg_json = json.loads((HERE / "package.json").read_bytes()) setup_args = dict( name=name, - version=version, - url="https://github.com/jupyterlab/extension-examples.git", - author="Project Jupyter Contributors", - description="A minimal JupyterLab example to develop a context-menu.", - long_description= long_description, + version=pkg_json["version"], + url=pkg_json["homepage"], + author=pkg_json["author"]["name"], + author_email=pkg_json["author"]["email"], + description=pkg_json["description"], + license=pkg_json["license"], + long_description=long_description, long_description_content_type="text/markdown", - cmdclass= cmdclass, packages=setuptools.find_packages(), install_requires=[ - "jupyterlab>=3.0.0rc15,==3.*", + "jupyter_server>=1.6,<2" ], zip_safe=False, include_package_data=True, python_requires=">=3.6", - license="BSD-3-Clause", platforms="Linux, Mac OS X, Windows", keywords=["Jupyter", "JupyterLab", "JupyterLab3"], classifiers=[ @@ -84,10 +57,24 @@ "Programming Language :: Python :: 3.6", "Programming Language :: Python :: 3.7", "Programming Language :: Python :: 3.8", + "Programming Language :: Python :: 3.9", "Framework :: Jupyter", ], ) +try: + from jupyter_packaging import ( + wrap_installers, + npm_builder, + get_data_files + ) + post_develop = npm_builder( + build_cmd="install:extension", source_dir="src", build_dir=lab_path + ) + setup_args['cmdclass'] = wrap_installers(post_develop=post_develop, ensured_targets=ensured_targets) + setup_args['data_files'] = get_data_files(data_files_spec) +except ImportError as e: + pass if __name__ == "__main__": setuptools.setup(**setup_args) diff --git a/context-menu/src/index.ts b/context-menu/src/index.ts index a197cff6..8b9da3e9 100644 --- a/context-menu/src/index.ts +++ b/context-menu/src/index.ts @@ -1,6 +1,6 @@ import { JupyterFrontEnd, - JupyterFrontEndPlugin + JupyterFrontEndPlugin, } from '@jupyterlab/application'; import { IFileBrowserFactory } from '@jupyterlab/filebrowser'; import { showDialog, Dialog } from '@jupyterlab/apputils'; @@ -19,7 +19,7 @@ const extension: JupyterFrontEndPlugin = { extensions: ['.example'], fileFormat: 'text', contentType: 'file', - mimeTypes: ['text/plain'] + mimeTypes: ['text/plain'], }); app.commands.addCommand('jlab-examples/context-menu:open', { @@ -32,17 +32,17 @@ const extension: JupyterFrontEndPlugin = { showDialog({ title: file.name, body: 'Path: ' + file.path, - buttons: [Dialog.okButton()] - }).catch(e => console.log(e)); - } + buttons: [Dialog.okButton()], + }).catch((e) => console.log(e)); + }, }); app.contextMenu.addItem({ command: 'jlab-examples/context-menu:open', selector: '.jp-DirListing-item[data-file-type="example"]', - rank: 0 + rank: 0, }); - } + }, }; export default extension; diff --git a/custom-log-console/.eslintrc.js b/custom-log-console/.eslintrc.js index 652320e0..c2375786 100644 --- a/custom-log-console/.eslintrc.js +++ b/custom-log-console/.eslintrc.js @@ -5,28 +5,34 @@ module.exports = { 'plugin:@typescript-eslint/recommended', 'plugin:jsdoc/recommended', 'plugin:prettier/recommended', - 'plugin:react/recommended' + 'plugin:react/recommended', ], parser: '@typescript-eslint/parser', parserOptions: { project: 'tsconfig.json', - sourceType: 'module' + sourceType: 'module', }, plugins: ['@typescript-eslint', 'jsdoc'], rules: { - '@typescript-eslint/interface-name-prefix': [ + '@typescript-eslint/naming-convention': [ 'error', - { prefixWithI: 'always' } + { + selector: 'interface', + format: ['PascalCase'], + custom: { + regex: '^I[A-Z]', + match: true, + }, + }, ], '@typescript-eslint/no-unused-vars': ['warn', { args: 'none' }], '@typescript-eslint/no-explicit-any': 'off', - '@typescript-eslint/camelcase': 'warn', '@typescript-eslint/no-namespace': 'off', '@typescript-eslint/no-use-before-define': 'off', '@typescript-eslint/quotes': [ 'error', 'single', - { avoidEscape: true, allowTemplateLiterals: false } + { avoidEscape: true, allowTemplateLiterals: false }, ], curly: ['error', 'all'], eqeqeq: 'error', @@ -34,14 +40,14 @@ module.exports = { 'jsdoc/require-property-type': 'off', 'jsdoc/require-returns-type': 'off', 'jsdoc/no-types': 'warn', - 'prefer-arrow-callback': 'error' + 'prefer-arrow-callback': 'error', }, settings: { jsdoc: { - mode: 'typescript' + mode: 'typescript', }, react: { - version: 'detect' - } - } + version: 'detect', + }, + }, }; diff --git a/custom-log-console/README.md b/custom-log-console/README.md index aaa26402..98e24113 100644 --- a/custom-log-console/README.md +++ b/custom-log-console/README.md @@ -163,7 +163,7 @@ logConsolePanel?.logger?.log(msg); const msg: ITextLog = { type: 'text', level: 'info', - data: 'Hello world text!!' + data: 'Hello world text!!', }; logConsolePanel?.logger?.log(msg); diff --git a/custom-log-console/package.json b/custom-log-console/package.json index 4cb4c733..0a4bc619 100644 --- a/custom-log-console/package.json +++ b/custom-log-console/package.json @@ -12,10 +12,14 @@ "url": "https://github.com/jupyterlab/extension-examples/issues" }, "license": "BSD-3-Clause", - "author": "Project Jupyter Contributors", + "author": { + "name": "Project Jupyter Contributors", + "email": "" + }, "files": [ "lib/**/*.{d.ts,eot,gif,html,jpg,js,js.map,json,png,svg,woff2,ttf}", - "style/**/*.{css,eot,gif,html,jpg,json,png,svg,woff2,ttf}" + "style/**/*.{css,eot,gif,html,jpg,json,png,svg,woff2,ttf}", + "style/index.js" ], "main": "lib/index.js", "types": "lib/index.d.ts", @@ -30,50 +34,52 @@ "build:labextension": "jupyter labextension build .", "build:labextension:dev": "jupyter labextension build --development True .", "build:lib": "tsc", - "build:prod": "jlpm run build:lib && jlpm run build:labextension", + "build:prod": "jlpm run clean && jlpm run build:lib && jlpm run build:labextension", "clean": "jlpm run clean:lib", "clean:all": "jlpm run clean:lib && jlpm run clean:labextension", "clean:labextension": "rimraf jupyterlab_examples_custom_log_console/labextension", "clean:lib": "rimraf lib tsconfig.tsbuildinfo", "eslint": "eslint . --ext .ts,.tsx --fix", "eslint:check": "eslint . --ext .ts,.tsx", - "install:extension": "jupyter labextension develop --overwrite .", + "install:extension": "jlpm run build", "prepare": "jlpm run clean && jlpm run build:prod", "watch": "run-p watch:src watch:labextension", "watch:labextension": "jupyter labextension watch .", "watch:src": "tsc -w" }, "dependencies": { - "@jupyterlab/application": "^3.0.0-rc.15", - "@jupyterlab/apputils": "^3.0.0-rc.15", - "@jupyterlab/coreutils": "^5.0.0-rc.15", - "@jupyterlab/logconsole": "^3.0.0-rc.15", - "@jupyterlab/mainmenu": "^3.0.0-rc.15", - "@jupyterlab/nbformat": "^3.0.0-rc.15", - "@jupyterlab/rendermime": "^3.0.0-rc.15", - "@jupyterlab/ui-components": "^3.0.0-rc.15", + "@jupyterlab/application": "^3.0.10", + "@jupyterlab/apputils": "^3.0.8", + "@jupyterlab/coreutils": "^5.0.6", + "@jupyterlab/logconsole": "^3.0.9", + "@jupyterlab/mainmenu": "^3.0.8", + "@jupyterlab/nbformat": "^3.0.5", + "@jupyterlab/rendermime": "^3.0.9", + "@jupyterlab/ui-components": "^3.0.7", "@lumino/coreutils": "^1.5.3", "@lumino/widgets": "^1.16.1" }, "devDependencies": { - "@jupyterlab/builder": "^3.0.0-rc.15", - "@typescript-eslint/eslint-plugin": "^2.27.0", - "@typescript-eslint/parser": "^2.27.0", - "eslint": "^7.5.0", - "eslint-config-prettier": "^6.10.1", - "eslint-plugin-jsdoc": "^22.0.0", - "eslint-plugin-prettier": "^3.1.2", + "@jupyterlab/builder": "^3.0.0", + "@typescript-eslint/eslint-plugin": "^4.8.1", + "@typescript-eslint/parser": "^4.8.1", + "eslint": "^7.14.0", + "eslint-config-prettier": "^6.15.0", + "eslint-plugin-jsdoc": "^34.0.0", + "eslint-plugin-prettier": "^3.1.4", "eslint-plugin-react": "^7.18.3", "npm-run-all": "^4.1.5", - "prettier": "^1.19.0", + "prettier": "^2.1.1", "rimraf": "^3.0.2", "typescript": "~4.1.3" }, "sideEffects": [ - "style/*.css" + "style/*.css", + "style/index.js" ], "jupyterlab": { "extension": true, "outputDir": "jupyterlab_examples_custom_log_console/labextension" - } + }, + "styleModule": "style/index.js" } \ No newline at end of file diff --git a/custom-log-console/pyproject.toml b/custom-log-console/pyproject.toml index c40f3629..e1b62381 100644 --- a/custom-log-console/pyproject.toml +++ b/custom-log-console/pyproject.toml @@ -1,3 +1,17 @@ [build-system] -requires = ["jupyter_packaging~=0.7.9", "jupyterlab>=3.0.0rc15,==3.*", "setuptools>=40.8.0", "wheel"] -build-backend = "setuptools.build_meta" +requires = ["jupyter_packaging~=0.10,<2", "jupyterlab~=3.0"] +build-backend = "jupyter_packaging.build_api" + +[tool.jupyter-packaging.options] +skip-if-exists = ["jupyterlab_examples_custom_log_console/labextension/static/style.js"] +ensured-targets = ["jupyterlab_examples_custom_log_console/labextension/static/style.js", "jupyterlab_examples_custom_log_console/labextension/package.json"] + +[tool.jupyter-packaging.builder] +factory = "jupyter_packaging.npm_builder" + +[tool.jupyter-packaging.build-args] +build_cmd = "build:prod" +npm = ["jlpm"] + +[tool.check-manifest] +ignore = ["jupyterlab_examples_custom_log_console/labextension/**", "yarn.lock", ".*", "package-lock.json"] diff --git a/custom-log-console/setup.py b/custom-log-console/setup.py index bc188912..99e141dd 100644 --- a/custom-log-console/setup.py +++ b/custom-log-console/setup.py @@ -2,79 +2,52 @@ jupyterlab_examples_custom_log_console setup """ import json -import os +from pathlib import Path -from jupyter_packaging import ( - create_cmdclass, install_npm, ensure_targets, - combine_commands, skip_if_exists -) import setuptools -HERE = os.path.abspath(os.path.dirname(__file__)) +HERE = Path(__file__).parent.resolve() # The name of the project -name="jupyterlab_examples_custom_log_console" - -# Get our version -with open(os.path.join(HERE, 'package.json')) as f: - version = json.load(f)['version'] +name = "jupyterlab_examples_custom_log_console" -lab_path = os.path.join(HERE, name, "labextension") +lab_path = (HERE / name / "labextension") # Representative files that should exist after a successful build -jstargets = [ - os.path.join(lab_path, "package.json"), +ensured_targets = [ + str(lab_path / "package.json"), + str(lab_path / "static/style.js") ] -package_data_spec = { - name: [ - "*" - ] -} - labext_name = "@jupyterlab-examples/custom-log-console" data_files_spec = [ - ("share/jupyter/labextensions/%s" % labext_name, lab_path, "**"), - ("share/jupyter/labextensions/%s" % labext_name, HERE, "install.json"), + ("share/jupyter/labextensions/%s" % labext_name, str(lab_path), "**"), + ("share/jupyter/labextensions/%s" % labext_name, str(HERE), "install.json"), ] -cmdclass = create_cmdclass("jsdeps", - package_data_spec=package_data_spec, - data_files_spec=data_files_spec -) - -js_command = combine_commands( - install_npm(HERE, build_cmd="build:prod", npm=["jlpm"]), - ensure_targets(jstargets), -) - -is_repo = os.path.exists(os.path.join(HERE, ".git")) -if is_repo: - cmdclass["jsdeps"] = js_command -else: - cmdclass["jsdeps"] = skip_if_exists(jstargets, js_command) +long_description = (HERE / "README.md").read_text() -with open("README.md", "r") as fh: - long_description = fh.read() +# Get the package info from package.json +pkg_json = json.loads((HERE / "package.json").read_bytes()) setup_args = dict( name=name, - version=version, - url="https://github.com/jupyterlab/extension-examples.git", - author="Project Jupyter Contributors", - description="A minimal JupyterLab example to develop a custom log console.", - long_description= long_description, + version=pkg_json["version"], + url=pkg_json["homepage"], + author=pkg_json["author"]["name"], + author_email=pkg_json["author"]["email"], + description=pkg_json["description"], + license=pkg_json["license"], + long_description=long_description, long_description_content_type="text/markdown", - cmdclass= cmdclass, packages=setuptools.find_packages(), install_requires=[ - "jupyterlab>=3.0.0rc15,==3.*", + "jupyter_server>=1.6,<2" ], zip_safe=False, include_package_data=True, python_requires=">=3.6", - license="BSD-3-Clause", platforms="Linux, Mac OS X, Windows", keywords=["Jupyter", "JupyterLab", "JupyterLab3"], classifiers=[ @@ -84,10 +57,24 @@ "Programming Language :: Python :: 3.6", "Programming Language :: Python :: 3.7", "Programming Language :: Python :: 3.8", + "Programming Language :: Python :: 3.9", "Framework :: Jupyter", ], ) +try: + from jupyter_packaging import ( + wrap_installers, + npm_builder, + get_data_files + ) + post_develop = npm_builder( + build_cmd="install:extension", source_dir="src", build_dir=lab_path + ) + setup_args['cmdclass'] = wrap_installers(post_develop=post_develop, ensured_targets=ensured_targets) + setup_args['data_files'] = get_data_files(data_files_spec) +except ImportError as e: + pass if __name__ == "__main__": setuptools.setup(**setup_args) diff --git a/custom-log-console/src/index.ts b/custom-log-console/src/index.ts index 7a639737..d964a816 100644 --- a/custom-log-console/src/index.ts +++ b/custom-log-console/src/index.ts @@ -1,20 +1,20 @@ import { JupyterFrontEnd, JupyterFrontEndPlugin, - ILayoutRestorer + ILayoutRestorer, } from '@jupyterlab/application'; import { ICommandPalette, MainAreaWidget, WidgetTracker, - CommandToolbarButton + CommandToolbarButton, } from '@jupyterlab/apputils'; import { LoggerRegistry, LogConsolePanel, IHtmlLog, ITextLog, - IOutputLog + IOutputLog, } from '@jupyterlab/logconsole'; import { addIcon, clearIcon, listIcon } from '@jupyterlab/ui-components'; import { IRenderMimeRegistry } from '@jupyterlab/rendermime'; @@ -43,25 +43,25 @@ const extension: JupyterFrontEndPlugin = { let logConsoleWidget: MainAreaWidget = null; const tracker = new WidgetTracker>({ - namespace: 'example-custom-log-console' + namespace: 'example-custom-log-console', }); restorer.restore(tracker, { command: 'jlab-examples/custom-log-console:open', - name: () => 'example-custom-log-console' + name: () => 'example-custom-log-console', }); commands.addCommand('jlab-examples/custom-log-console:checkpoint', { execute: () => logConsolePanel?.logger?.checkpoint(), icon: addIcon, isEnabled: () => !!logConsolePanel && logConsolePanel.source !== null, - label: 'Add Checkpoint' + label: 'Add Checkpoint', }); commands.addCommand('jlab-examples/custom-log-console:clear', { execute: () => logConsolePanel?.logger?.clear(), icon: clearIcon, isEnabled: () => !!logConsolePanel && logConsolePanel.source !== null, - label: 'Clear Log' + label: 'Clear Log', }); commands.addCommand('jlab-examples/custom-log-console:level', { execute: (args: any) => { @@ -70,21 +70,21 @@ const extension: JupyterFrontEndPlugin = { } }, isEnabled: () => !!logConsolePanel && logConsolePanel.source !== null, - label: args => `Set Log Level to ${args.level as string}` + label: (args) => `Set Log Level to ${args.level as string}`, }); const createLogConsoleWidget = (): void => { logConsolePanel = new LogConsolePanel( new LoggerRegistry({ defaultRendermime: rendermime, - maxLength: 1000 + maxLength: 1000, }) ); logConsolePanel.source = 'custom-log-console'; logConsoleWidget = new MainAreaWidget({ - content: logConsolePanel + content: logConsolePanel, }); logConsoleWidget.addClass('jp-LogConsole'); logConsoleWidget.title.label = 'Custom Log console'; @@ -94,14 +94,14 @@ const extension: JupyterFrontEndPlugin = { 'checkpoint', new CommandToolbarButton({ commands: app.commands, - id: 'jlab-examples/custom-log-console:checkpoint' + id: 'jlab-examples/custom-log-console:checkpoint', }) ); logConsoleWidget.toolbar.addItem( 'clear', new CommandToolbarButton({ commands: app.commands, - id: 'jlab-examples/custom-log-console:clear' + id: 'jlab-examples/custom-log-console:clear', }) ); logConsoleWidget.toolbar.addItem( @@ -132,12 +132,12 @@ const extension: JupyterFrontEndPlugin = { } else { createLogConsoleWidget(); } - } + }, }); palette.addItem({ command: 'jlab-examples/custom-log-console:open', - category: 'Examples' + category: 'Examples', }); commands.addCommand('jlab-examples/custom-log-console:logHTMLMessage', { @@ -147,11 +147,11 @@ const extension: JupyterFrontEndPlugin = { const msg: IHtmlLog = { type: 'html', level: 'debug', - data: '
Hello world HTML!!
' + data: '
Hello world HTML!!
', }; logConsolePanel?.logger?.log(msg); - } + }, }); commands.addCommand('jlab-examples/custom-log-console:logTextMessage', { @@ -161,11 +161,11 @@ const extension: JupyterFrontEndPlugin = { const msg: ITextLog = { type: 'text', level: 'info', - data: 'Hello world text!!' + data: 'Hello world text!!', }; logConsolePanel?.logger?.log(msg); - } + }, }); commands.addCommand('jlab-examples/custom-log-console:logOutputMessage', { @@ -175,18 +175,18 @@ const extension: JupyterFrontEndPlugin = { const data: nbformat.IOutput = { output_type: 'display_data', data: { - 'text/plain': 'Hello world nbformat!!' - } + 'text/plain': 'Hello world nbformat!!', + }, }; const msg: IOutputLog = { type: 'output', level: 'warning', - data + data, }; logConsolePanel?.logger?.log(msg); - } + }, }); // Create a new menu @@ -200,15 +200,15 @@ const extension: JupyterFrontEndPlugin = { // Buttons for the different examples menu.addItem({ - command: 'jlab-examples/custom-log-console:logHTMLMessage' + command: 'jlab-examples/custom-log-console:logHTMLMessage', }); menu.addItem({ - command: 'jlab-examples/custom-log-console:logTextMessage' + command: 'jlab-examples/custom-log-console:logTextMessage', }); menu.addItem({ - command: 'jlab-examples/custom-log-console:logOutputMessage' + command: 'jlab-examples/custom-log-console:logOutputMessage', }); - } + }, }; export default extension; diff --git a/custom-log-console/src/logLevelSwitcher.tsx b/custom-log-console/src/logLevelSwitcher.tsx index 42597be2..7549e9c9 100644 --- a/custom-log-console/src/logLevelSwitcher.tsx +++ b/custom-log-console/src/logLevelSwitcher.tsx @@ -90,13 +90,9 @@ export default class LogLevelSwitcher extends ReactWidget { options={ logger === null ? [] - : [ - 'Critical', - 'Error', - 'Warning', - 'Info', - 'Debug' - ].map(label => ({ label, value: label.toLowerCase() })) + : ['Critical', 'Error', 'Warning', 'Info', 'Debug'].map( + (label) => ({ label, value: label.toLowerCase() }) + ) } /> diff --git a/datagrid/.eslintrc.js b/datagrid/.eslintrc.js index 652320e0..c2375786 100644 --- a/datagrid/.eslintrc.js +++ b/datagrid/.eslintrc.js @@ -5,28 +5,34 @@ module.exports = { 'plugin:@typescript-eslint/recommended', 'plugin:jsdoc/recommended', 'plugin:prettier/recommended', - 'plugin:react/recommended' + 'plugin:react/recommended', ], parser: '@typescript-eslint/parser', parserOptions: { project: 'tsconfig.json', - sourceType: 'module' + sourceType: 'module', }, plugins: ['@typescript-eslint', 'jsdoc'], rules: { - '@typescript-eslint/interface-name-prefix': [ + '@typescript-eslint/naming-convention': [ 'error', - { prefixWithI: 'always' } + { + selector: 'interface', + format: ['PascalCase'], + custom: { + regex: '^I[A-Z]', + match: true, + }, + }, ], '@typescript-eslint/no-unused-vars': ['warn', { args: 'none' }], '@typescript-eslint/no-explicit-any': 'off', - '@typescript-eslint/camelcase': 'warn', '@typescript-eslint/no-namespace': 'off', '@typescript-eslint/no-use-before-define': 'off', '@typescript-eslint/quotes': [ 'error', 'single', - { avoidEscape: true, allowTemplateLiterals: false } + { avoidEscape: true, allowTemplateLiterals: false }, ], curly: ['error', 'all'], eqeqeq: 'error', @@ -34,14 +40,14 @@ module.exports = { 'jsdoc/require-property-type': 'off', 'jsdoc/require-returns-type': 'off', 'jsdoc/no-types': 'warn', - 'prefer-arrow-callback': 'error' + 'prefer-arrow-callback': 'error', }, settings: { jsdoc: { - mode: 'typescript' + mode: 'typescript', }, react: { - version: 'detect' - } - } + version: 'detect', + }, + }, }; diff --git a/datagrid/package.json b/datagrid/package.json index 4f5a236d..76ad0fc3 100644 --- a/datagrid/package.json +++ b/datagrid/package.json @@ -12,10 +12,14 @@ "url": "https://github.com/jupyterlab/extension-examples/issues" }, "license": "BSD-3-Clause", - "author": "Project Jupyter Contributors", + "author": { + "name": "Project Jupyter Contributors", + "email": "" + }, "files": [ "lib/**/*.{d.ts,eot,gif,html,jpg,js,js.map,json,png,svg,woff2,ttf}", - "style/**/*.{css,eot,gif,html,jpg,json,png,svg,woff2,ttf}" + "style/**/*.{css,eot,gif,html,jpg,json,png,svg,woff2,ttf}", + "style/index.js" ], "main": "lib/index.js", "types": "lib/index.d.ts", @@ -30,47 +34,49 @@ "build:labextension": "jupyter labextension build .", "build:labextension:dev": "jupyter labextension build --development True .", "build:lib": "tsc", - "build:prod": "jlpm run build:lib && jlpm run build:labextension", + "build:prod": "jlpm run clean && jlpm run build:lib && jlpm run build:labextension", "clean": "jlpm run clean:lib", "clean:all": "jlpm run clean:lib && jlpm run clean:labextension", "clean:labextension": "rimraf jupyterlab_examples_datagrid/labextension", "clean:lib": "rimraf lib tsconfig.tsbuildinfo", "eslint": "eslint . --ext .ts,.tsx --fix", "eslint:check": "eslint . --ext .ts,.tsx", - "install:extension": "jupyter labextension develop --overwrite .", + "install:extension": "jlpm run build", "prepare": "jlpm run clean && jlpm run build:prod", "watch": "run-p watch:src watch:labextension", "watch:labextension": "jupyter labextension watch .", "watch:src": "tsc -w" }, "dependencies": { - "@jupyterlab/application": "^3.0.0-rc.15", - "@jupyterlab/mainmenu": "^3.0.0-rc.15", - "@jupyterlab/translation": "^3.0.0-rc.15", + "@jupyterlab/application": "^3.0.10", + "@jupyterlab/mainmenu": "^3.0.8", + "@jupyterlab/translation": "^3.0.8", "@lumino/algorithm": "^1.3.3", "@lumino/coreutils": "^1.5.3", "@lumino/datagrid": "^0.14.1", "@lumino/disposable": "^1.4.3" }, "devDependencies": { - "@jupyterlab/builder": "^3.0.0-rc.15", - "@typescript-eslint/eslint-plugin": "^2.27.0", - "@typescript-eslint/parser": "^2.27.0", - "eslint": "^7.5.0", - "eslint-config-prettier": "^6.10.1", - "eslint-plugin-jsdoc": "^22.0.0", - "eslint-plugin-prettier": "^3.1.2", + "@jupyterlab/builder": "^3.0.0", + "@typescript-eslint/eslint-plugin": "^4.8.1", + "@typescript-eslint/parser": "^4.8.1", + "eslint": "^7.14.0", + "eslint-config-prettier": "^6.15.0", + "eslint-plugin-jsdoc": "^34.0.0", + "eslint-plugin-prettier": "^3.1.4", "eslint-plugin-react": "^7.18.3", "npm-run-all": "^4.1.5", - "prettier": "^1.19.0", + "prettier": "^2.1.1", "rimraf": "^3.0.2", "typescript": "~4.1.3" }, "sideEffects": [ - "style/*.css" + "style/*.css", + "style/index.js" ], "jupyterlab": { "extension": true, "outputDir": "jupyterlab_examples_datagrid/labextension" - } + }, + "styleModule": "style/index.js" } \ No newline at end of file diff --git a/datagrid/pyproject.toml b/datagrid/pyproject.toml index c40f3629..e32ff612 100644 --- a/datagrid/pyproject.toml +++ b/datagrid/pyproject.toml @@ -1,3 +1,17 @@ [build-system] -requires = ["jupyter_packaging~=0.7.9", "jupyterlab>=3.0.0rc15,==3.*", "setuptools>=40.8.0", "wheel"] -build-backend = "setuptools.build_meta" +requires = ["jupyter_packaging~=0.10,<2", "jupyterlab~=3.0"] +build-backend = "jupyter_packaging.build_api" + +[tool.jupyter-packaging.options] +skip-if-exists = ["jupyterlab_examples_datagrid/labextension/static/style.js"] +ensured-targets = ["jupyterlab_examples_datagrid/labextension/static/style.js", "jupyterlab_examples_datagrid/labextension/package.json"] + +[tool.jupyter-packaging.builder] +factory = "jupyter_packaging.npm_builder" + +[tool.jupyter-packaging.build-args] +build_cmd = "build:prod" +npm = ["jlpm"] + +[tool.check-manifest] +ignore = ["jupyterlab_examples_datagrid/labextension/**", "yarn.lock", ".*", "package-lock.json"] diff --git a/datagrid/setup.py b/datagrid/setup.py index 47b028ff..54505d75 100644 --- a/datagrid/setup.py +++ b/datagrid/setup.py @@ -2,79 +2,52 @@ jupyterlab_examples_datagrid setup """ import json -import os +from pathlib import Path -from jupyter_packaging import ( - create_cmdclass, install_npm, ensure_targets, - combine_commands, skip_if_exists -) import setuptools -HERE = os.path.abspath(os.path.dirname(__file__)) +HERE = Path(__file__).parent.resolve() # The name of the project -name="jupyterlab_examples_datagrid" - -# Get our version -with open(os.path.join(HERE, 'package.json')) as f: - version = json.load(f)['version'] +name = "jupyterlab_examples_datagrid" -lab_path = os.path.join(HERE, name, "labextension") +lab_path = (HERE / name / "labextension") # Representative files that should exist after a successful build -jstargets = [ - os.path.join(lab_path, "package.json"), +ensured_targets = [ + str(lab_path / "package.json"), + str(lab_path / "static/style.js") ] -package_data_spec = { - name: [ - "*" - ] -} - labext_name = "@jupyterlab-examples/datagrid" data_files_spec = [ - ("share/jupyter/labextensions/%s" % labext_name, lab_path, "**"), - ("share/jupyter/labextensions/%s" % labext_name, HERE, "install.json"), + ("share/jupyter/labextensions/%s" % labext_name, str(lab_path), "**"), + ("share/jupyter/labextensions/%s" % labext_name, str(HERE), "install.json"), ] -cmdclass = create_cmdclass("jsdeps", - package_data_spec=package_data_spec, - data_files_spec=data_files_spec -) - -js_command = combine_commands( - install_npm(HERE, build_cmd="build:prod", npm=["jlpm"]), - ensure_targets(jstargets), -) - -is_repo = os.path.exists(os.path.join(HERE, ".git")) -if is_repo: - cmdclass["jsdeps"] = js_command -else: - cmdclass["jsdeps"] = skip_if_exists(jstargets, js_command) +long_description = (HERE / "README.md").read_text() -with open("README.md", "r") as fh: - long_description = fh.read() +# Get the package info from package.json +pkg_json = json.loads((HERE / "package.json").read_bytes()) setup_args = dict( name=name, - version=version, - url="https://github.com/jupyterlab/extension-examples.git", - author="Project Jupyter Contributors", - description="minimal lab example", - long_description= long_description, + version=pkg_json["version"], + url=pkg_json["homepage"], + author=pkg_json["author"]["name"], + author_email=pkg_json["author"]["email"], + description=pkg_json["description"], + license=pkg_json["license"], + long_description=long_description, long_description_content_type="text/markdown", - cmdclass= cmdclass, packages=setuptools.find_packages(), install_requires=[ - "jupyterlab>=3.0.0rc15,==3.*", + "jupyter_server>=1.6,<2" ], zip_safe=False, include_package_data=True, python_requires=">=3.6", - license="BSD-3-Clause", platforms="Linux, Mac OS X, Windows", keywords=["Jupyter", "JupyterLab", "JupyterLab3"], classifiers=[ @@ -84,10 +57,24 @@ "Programming Language :: Python :: 3.6", "Programming Language :: Python :: 3.7", "Programming Language :: Python :: 3.8", + "Programming Language :: Python :: 3.9", "Framework :: Jupyter", ], ) +try: + from jupyter_packaging import ( + wrap_installers, + npm_builder, + get_data_files + ) + post_develop = npm_builder( + build_cmd="install:extension", source_dir="src", build_dir=lab_path + ) + setup_args['cmdclass'] = wrap_installers(post_develop=post_develop, ensured_targets=ensured_targets) + setup_args['data_files'] = get_data_files(data_files_spec) +except ImportError as e: + pass if __name__ == "__main__": setuptools.setup(**setup_args) diff --git a/datagrid/src/index.ts b/datagrid/src/index.ts index c78e7837..4f2e0234 100644 --- a/datagrid/src/index.ts +++ b/datagrid/src/index.ts @@ -1,6 +1,6 @@ import { JupyterFrontEnd, - JupyterFrontEndPlugin + JupyterFrontEndPlugin, } from '@jupyterlab/application'; import { ICommandPalette } from '@jupyterlab/apputils'; @@ -10,7 +10,7 @@ import { IMainMenu } from '@jupyterlab/mainmenu'; import { ITranslator, nullTranslator, - TranslationBundle + TranslationBundle, } from '@jupyterlab/translation'; import { DataGrid, DataModel } from '@lumino/datagrid'; @@ -40,7 +40,7 @@ const extension: JupyterFrontEndPlugin = { execute: () => { const widget = new DataGridPanel(); shell.add(widget, 'main'); - } + }, }); palette.addItem({ command, category: 'Extension Examples' }); @@ -49,7 +49,7 @@ const extension: JupyterFrontEndPlugin = { exampleMenu.title.label = trans.__('DataGrid Example'); mainMenu.addMenu(exampleMenu, { rank: 80 }); exampleMenu.addItem({ command }); - } + }, }; export default extension; diff --git a/hello-world/.eslintrc.js b/hello-world/.eslintrc.js index 652320e0..c2375786 100644 --- a/hello-world/.eslintrc.js +++ b/hello-world/.eslintrc.js @@ -5,28 +5,34 @@ module.exports = { 'plugin:@typescript-eslint/recommended', 'plugin:jsdoc/recommended', 'plugin:prettier/recommended', - 'plugin:react/recommended' + 'plugin:react/recommended', ], parser: '@typescript-eslint/parser', parserOptions: { project: 'tsconfig.json', - sourceType: 'module' + sourceType: 'module', }, plugins: ['@typescript-eslint', 'jsdoc'], rules: { - '@typescript-eslint/interface-name-prefix': [ + '@typescript-eslint/naming-convention': [ 'error', - { prefixWithI: 'always' } + { + selector: 'interface', + format: ['PascalCase'], + custom: { + regex: '^I[A-Z]', + match: true, + }, + }, ], '@typescript-eslint/no-unused-vars': ['warn', { args: 'none' }], '@typescript-eslint/no-explicit-any': 'off', - '@typescript-eslint/camelcase': 'warn', '@typescript-eslint/no-namespace': 'off', '@typescript-eslint/no-use-before-define': 'off', '@typescript-eslint/quotes': [ 'error', 'single', - { avoidEscape: true, allowTemplateLiterals: false } + { avoidEscape: true, allowTemplateLiterals: false }, ], curly: ['error', 'all'], eqeqeq: 'error', @@ -34,14 +40,14 @@ module.exports = { 'jsdoc/require-property-type': 'off', 'jsdoc/require-returns-type': 'off', 'jsdoc/no-types': 'warn', - 'prefer-arrow-callback': 'error' + 'prefer-arrow-callback': 'error', }, settings: { jsdoc: { - mode: 'typescript' + mode: 'typescript', }, react: { - version: 'detect' - } - } + version: 'detect', + }, + }, }; diff --git a/hello-world/README.md b/hello-world/README.md index 0e9b0b78..f7451817 100644 --- a/hello-world/README.md +++ b/hello-world/README.md @@ -105,7 +105,7 @@ logic of the extension. It begins with the following import section: import { JupyterFrontEnd, - JupyterFrontEndPlugin + JupyterFrontEndPlugin, } from '@jupyterlab/application'; ``` diff --git a/hello-world/package.json b/hello-world/package.json index 7a77b038..a238f347 100644 --- a/hello-world/package.json +++ b/hello-world/package.json @@ -12,10 +12,14 @@ "url": "https://github.com/jupyterlab/extension-examples/issues" }, "license": "BSD-3-Clause", - "author": "Project Jupyter Contributors", + "author": { + "name": "Project Jupyter Contributors", + "email": "" + }, "files": [ "lib/**/*.{d.ts,eot,gif,html,jpg,js,js.map,json,png,svg,woff2,ttf}", - "style/**/*.{css,eot,gif,html,jpg,json,png,svg,woff2,ttf}" + "style/**/*.{css,eot,gif,html,jpg,json,png,svg,woff2,ttf}", + "style/index.js" ], "main": "lib/index.js", "types": "lib/index.d.ts", @@ -30,41 +34,43 @@ "build:labextension": "jupyter labextension build .", "build:labextension:dev": "jupyter labextension build --development True .", "build:lib": "tsc", - "build:prod": "jlpm run build:lib && jlpm run build:labextension", + "build:prod": "jlpm run clean && jlpm run build:lib && jlpm run build:labextension", "clean": "jlpm run clean:lib", "clean:all": "jlpm run clean:lib && jlpm run clean:labextension", "clean:labextension": "rimraf jupyterlab_examples_hello_world/labextension", "clean:lib": "rimraf lib tsconfig.tsbuildinfo", "eslint": "eslint . --ext .ts,.tsx --fix", "eslint:check": "eslint . --ext .ts,.tsx", - "install:extension": "jupyter labextension develop --overwrite .", + "install:extension": "jlpm run build", "prepare": "jlpm run clean && jlpm run build:prod", "watch": "run-p watch:src watch:labextension", "watch:labextension": "jupyter labextension watch .", "watch:src": "tsc -w" }, "dependencies": { - "@jupyterlab/application": "^3.0.0" + "@jupyterlab/application": "^3.0.10" }, "devDependencies": { - "@jupyterlab/builder": "^3.0.0-rc.15", - "@typescript-eslint/eslint-plugin": "^2.27.0", - "@typescript-eslint/parser": "^2.27.0", - "eslint": "^7.5.0", - "eslint-config-prettier": "^6.10.1", - "eslint-plugin-jsdoc": "^22.0.0", - "eslint-plugin-prettier": "^3.1.2", + "@jupyterlab/builder": "^3.0.0", + "@typescript-eslint/eslint-plugin": "^4.8.1", + "@typescript-eslint/parser": "^4.8.1", + "eslint": "^7.14.0", + "eslint-config-prettier": "^6.15.0", + "eslint-plugin-jsdoc": "^34.0.0", + "eslint-plugin-prettier": "^3.1.4", "eslint-plugin-react": "^7.18.3", "npm-run-all": "^4.1.5", - "prettier": "^1.19.0", + "prettier": "^2.1.1", "rimraf": "^3.0.2", "typescript": "~4.1.3" }, "sideEffects": [ - "style/*.css" + "style/*.css", + "style/index.js" ], "jupyterlab": { "extension": true, "outputDir": "jupyterlab_examples_hello_world/labextension" - } + }, + "styleModule": "style/index.js" } \ No newline at end of file diff --git a/hello-world/pyproject.toml b/hello-world/pyproject.toml index c40f3629..e3a4da2a 100644 --- a/hello-world/pyproject.toml +++ b/hello-world/pyproject.toml @@ -1,3 +1,17 @@ [build-system] -requires = ["jupyter_packaging~=0.7.9", "jupyterlab>=3.0.0rc15,==3.*", "setuptools>=40.8.0", "wheel"] -build-backend = "setuptools.build_meta" +requires = ["jupyter_packaging~=0.10,<2", "jupyterlab~=3.0"] +build-backend = "jupyter_packaging.build_api" + +[tool.jupyter-packaging.options] +skip-if-exists = ["jupyterlab_examples_hello_world/labextension/static/style.js"] +ensured-targets = ["jupyterlab_examples_hello_world/labextension/static/style.js", "jupyterlab_examples_hello_world/labextension/package.json"] + +[tool.jupyter-packaging.builder] +factory = "jupyter_packaging.npm_builder" + +[tool.jupyter-packaging.build-args] +build_cmd = "build:prod" +npm = ["jlpm"] + +[tool.check-manifest] +ignore = ["jupyterlab_examples_hello_world/labextension/**", "yarn.lock", ".*", "package-lock.json"] diff --git a/hello-world/setup.py b/hello-world/setup.py index c257f4eb..785d3ef2 100644 --- a/hello-world/setup.py +++ b/hello-world/setup.py @@ -2,79 +2,52 @@ jupyterlab_examples_hello_world setup """ import json -import os +from pathlib import Path -from jupyter_packaging import ( - create_cmdclass, install_npm, ensure_targets, - combine_commands, skip_if_exists -) import setuptools -HERE = os.path.abspath(os.path.dirname(__file__)) +HERE = Path(__file__).parent.resolve() # The name of the project -name="jupyterlab_examples_hello_world" - -# Get our version -with open(os.path.join(HERE, 'package.json')) as f: - version = json.load(f)['version'] +name = "jupyterlab_examples_hello_world" -lab_path = os.path.join(HERE, name, "labextension") +lab_path = (HERE / name / "labextension") # Representative files that should exist after a successful build -jstargets = [ - os.path.join(lab_path, "package.json"), +ensured_targets = [ + str(lab_path / "package.json"), + str(lab_path / "static/style.js") ] -package_data_spec = { - name: [ - "*" - ] -} - labext_name = "@jupyterlab-examples/hello-world" data_files_spec = [ - ("share/jupyter/labextensions/%s" % labext_name, lab_path, "**"), - ("share/jupyter/labextensions/%s" % labext_name, HERE, "install.json"), + ("share/jupyter/labextensions/%s" % labext_name, str(lab_path), "**"), + ("share/jupyter/labextensions/%s" % labext_name, str(HERE), "install.json"), ] -cmdclass = create_cmdclass("jsdeps", - package_data_spec=package_data_spec, - data_files_spec=data_files_spec -) - -js_command = combine_commands( - install_npm(HERE, build_cmd="build:prod", npm=["jlpm"]), - ensure_targets(jstargets), -) - -is_repo = os.path.exists(os.path.join(HERE, ".git")) -if is_repo: - cmdclass["jsdeps"] = js_command -else: - cmdclass["jsdeps"] = skip_if_exists(jstargets, js_command) +long_description = (HERE / "README.md").read_text() -with open("README.md", "r") as fh: - long_description = fh.read() +# Get the package info from package.json +pkg_json = json.loads((HERE / "package.json").read_bytes()) setup_args = dict( name=name, - version=version, - url="https://github.com/jupyterlab/extension-examples.git", - author="Project Jupyter Contributors", - description="minimal lab example", - long_description= long_description, + version=pkg_json["version"], + url=pkg_json["homepage"], + author=pkg_json["author"]["name"], + author_email=pkg_json["author"]["email"], + description=pkg_json["description"], + license=pkg_json["license"], + long_description=long_description, long_description_content_type="text/markdown", - cmdclass= cmdclass, packages=setuptools.find_packages(), install_requires=[ - "jupyterlab>=3.0.0rc15,==3.*", + "jupyter_server>=1.6,<2" ], zip_safe=False, include_package_data=True, python_requires=">=3.6", - license="BSD-3-Clause", platforms="Linux, Mac OS X, Windows", keywords=["Jupyter", "JupyterLab", "JupyterLab3"], classifiers=[ @@ -84,10 +57,24 @@ "Programming Language :: Python :: 3.6", "Programming Language :: Python :: 3.7", "Programming Language :: Python :: 3.8", + "Programming Language :: Python :: 3.9", "Framework :: Jupyter", ], ) +try: + from jupyter_packaging import ( + wrap_installers, + npm_builder, + get_data_files + ) + post_develop = npm_builder( + build_cmd="install:extension", source_dir="src", build_dir=lab_path + ) + setup_args['cmdclass'] = wrap_installers(post_develop=post_develop, ensured_targets=ensured_targets) + setup_args['data_files'] = get_data_files(data_files_spec) +except ImportError as e: + pass if __name__ == "__main__": setuptools.setup(**setup_args) diff --git a/hello-world/src/index.ts b/hello-world/src/index.ts index d02f06c6..b4fd166c 100644 --- a/hello-world/src/index.ts +++ b/hello-world/src/index.ts @@ -1,6 +1,6 @@ import { JupyterFrontEnd, - JupyterFrontEndPlugin + JupyterFrontEndPlugin, } from '@jupyterlab/application'; /** @@ -11,7 +11,7 @@ const plugin: JupyterFrontEndPlugin = { autoStart: true, activate: (app: JupyterFrontEnd) => { console.log('the JupyterLab main application:', app); - } + }, }; export default plugin; diff --git a/kernel-messaging/.eslintrc.js b/kernel-messaging/.eslintrc.js index 652320e0..c2375786 100644 --- a/kernel-messaging/.eslintrc.js +++ b/kernel-messaging/.eslintrc.js @@ -5,28 +5,34 @@ module.exports = { 'plugin:@typescript-eslint/recommended', 'plugin:jsdoc/recommended', 'plugin:prettier/recommended', - 'plugin:react/recommended' + 'plugin:react/recommended', ], parser: '@typescript-eslint/parser', parserOptions: { project: 'tsconfig.json', - sourceType: 'module' + sourceType: 'module', }, plugins: ['@typescript-eslint', 'jsdoc'], rules: { - '@typescript-eslint/interface-name-prefix': [ + '@typescript-eslint/naming-convention': [ 'error', - { prefixWithI: 'always' } + { + selector: 'interface', + format: ['PascalCase'], + custom: { + regex: '^I[A-Z]', + match: true, + }, + }, ], '@typescript-eslint/no-unused-vars': ['warn', { args: 'none' }], '@typescript-eslint/no-explicit-any': 'off', - '@typescript-eslint/camelcase': 'warn', '@typescript-eslint/no-namespace': 'off', '@typescript-eslint/no-use-before-define': 'off', '@typescript-eslint/quotes': [ 'error', 'single', - { avoidEscape: true, allowTemplateLiterals: false } + { avoidEscape: true, allowTemplateLiterals: false }, ], curly: ['error', 'all'], eqeqeq: 'error', @@ -34,14 +40,14 @@ module.exports = { 'jsdoc/require-property-type': 'off', 'jsdoc/require-returns-type': 'off', 'jsdoc/no-types': 'warn', - 'prefer-arrow-callback': 'error' + 'prefer-arrow-callback': 'error', }, settings: { jsdoc: { - mode: 'typescript' + mode: 'typescript', }, react: { - version: 'detect' - } - } + version: 'detect', + }, + }, }; diff --git a/kernel-messaging/README.md b/kernel-messaging/README.md index 08dc8141..67486e15 100644 --- a/kernel-messaging/README.md +++ b/kernel-messaging/README.md @@ -41,7 +41,7 @@ that manages a single kernel session. Here is the code to initialize such sessio this._sessionContext = new SessionContext({ sessionManager: manager.sessions, specsManager: manager.kernelspecs, - name: 'Extension Examples' + name: 'Extension Examples', }); ``` @@ -96,7 +96,7 @@ export class ExamplePanel extends StackedPanel { this._sessionContext = new SessionContext({ sessionManager: manager.sessions, specsManager: manager.kernelspecs, - name: 'Extension Examples' + name: 'Extension Examples', }); this._model = new KernelModel(this._sessionContext); @@ -105,12 +105,12 @@ export class ExamplePanel extends StackedPanel { this.addWidget(this._example); void this._sessionContext .initialize() - .then(async value => { + .then(async (value) => { if (value) { await sessionContextDialogs.selectKernel(this._sessionContext); } }) - .catch(reason => { + .catch((reason) => { console.error( `Failed to initialize the session in ExamplePanel.\n${reason}` ); @@ -148,7 +148,7 @@ Once a kernel is initialized and ready, code can be executed with the following // src/model.ts#L46-L48 this.future = this._sessionContext.session?.kernel?.requestExecute({ - code + code, }); ``` @@ -205,7 +205,7 @@ export class KernelModel { return; } this.future = this._sessionContext.session?.kernel?.requestExecute({ - code + code, }); } diff --git a/kernel-messaging/package.json b/kernel-messaging/package.json index 6f10debc..198d0745 100644 --- a/kernel-messaging/package.json +++ b/kernel-messaging/package.json @@ -12,10 +12,14 @@ "url": "https://github.com/jupyterlab/extension-examples/issues" }, "license": "BSD-3-Clause", - "author": "Project Jupyter Contributors", + "author": { + "name": "Project Jupyter Contributors", + "email": "" + }, "files": [ "lib/**/*.{d.ts,eot,gif,html,jpg,js,js.map,json,png,svg,woff2,ttf}", - "style/**/*.{css,eot,gif,html,jpg,json,png,svg,woff2,ttf}" + "style/**/*.{css,eot,gif,html,jpg,json,png,svg,woff2,ttf}", + "style/index.js" ], "main": "lib/index.js", "types": "lib/index.d.ts", @@ -30,25 +34,25 @@ "build:labextension": "jupyter labextension build .", "build:labextension:dev": "jupyter labextension build --development True .", "build:lib": "tsc", - "build:prod": "jlpm run build:lib && jlpm run build:labextension", + "build:prod": "jlpm run clean && jlpm run build:lib && jlpm run build:labextension", "clean": "jlpm run clean:lib", "clean:all": "jlpm run clean:lib && jlpm run clean:labextension", "clean:labextension": "rimraf jupyterlab_examples_kernel_messaging/labextension", "clean:lib": "rimraf lib tsconfig.tsbuildinfo", "eslint": "eslint . --ext .ts,.tsx --fix", "eslint:check": "eslint . --ext .ts,.tsx", - "install:extension": "jupyter labextension develop --overwrite .", + "install:extension": "jlpm run build", "prepare": "jlpm run clean && jlpm run build:prod", "watch": "run-p watch:src watch:labextension", "watch:labextension": "jupyter labextension watch .", "watch:src": "tsc -w" }, "dependencies": { - "@jupyterlab/application": "^3.0.0-rc.15", - "@jupyterlab/launcher": "^3.0.0-rc.15", - "@jupyterlab/mainmenu": "^3.0.0-rc.15", - "@jupyterlab/nbformat": "^3.0.0-rc.15", - "@jupyterlab/translation": "^3.0.0-rc.15", + "@jupyterlab/application": "^3.0.10", + "@jupyterlab/launcher": "^3.0.8", + "@jupyterlab/mainmenu": "^3.0.8", + "@jupyterlab/nbformat": "^3.0.5", + "@jupyterlab/translation": "^3.0.8", "@lumino/algorithm": "^1.3.3", "@lumino/coreutils": "^1.5.3", "@lumino/datagrid": "^0.5.2", @@ -56,24 +60,26 @@ "@lumino/widgets": "^1.16.1" }, "devDependencies": { - "@jupyterlab/builder": "^3.0.0-rc.15", - "@typescript-eslint/eslint-plugin": "^2.27.0", - "@typescript-eslint/parser": "^2.27.0", - "eslint": "^7.5.0", - "eslint-config-prettier": "^6.10.1", - "eslint-plugin-jsdoc": "^22.0.0", - "eslint-plugin-prettier": "^3.1.2", + "@jupyterlab/builder": "^3.0.0", + "@typescript-eslint/eslint-plugin": "^4.8.1", + "@typescript-eslint/parser": "^4.8.1", + "eslint": "^7.14.0", + "eslint-config-prettier": "^6.15.0", + "eslint-plugin-jsdoc": "^34.0.0", + "eslint-plugin-prettier": "^3.1.4", "eslint-plugin-react": "^7.18.3", "npm-run-all": "^4.1.5", - "prettier": "^1.19.0", + "prettier": "^2.1.1", "rimraf": "^3.0.2", "typescript": "~4.1.3" }, "sideEffects": [ - "style/*.css" + "style/*.css", + "style/index.js" ], "jupyterlab": { "extension": true, "outputDir": "jupyterlab_examples_kernel_messaging/labextension" - } + }, + "styleModule": "style/index.js" } \ No newline at end of file diff --git a/kernel-messaging/pyproject.toml b/kernel-messaging/pyproject.toml index c40f3629..bdd35499 100644 --- a/kernel-messaging/pyproject.toml +++ b/kernel-messaging/pyproject.toml @@ -1,3 +1,17 @@ [build-system] -requires = ["jupyter_packaging~=0.7.9", "jupyterlab>=3.0.0rc15,==3.*", "setuptools>=40.8.0", "wheel"] -build-backend = "setuptools.build_meta" +requires = ["jupyter_packaging~=0.10,<2", "jupyterlab~=3.0"] +build-backend = "jupyter_packaging.build_api" + +[tool.jupyter-packaging.options] +skip-if-exists = ["jupyterlab_examples_kernel_messaging/labextension/static/style.js"] +ensured-targets = ["jupyterlab_examples_kernel_messaging/labextension/static/style.js", "jupyterlab_examples_kernel_messaging/labextension/package.json"] + +[tool.jupyter-packaging.builder] +factory = "jupyter_packaging.npm_builder" + +[tool.jupyter-packaging.build-args] +build_cmd = "build:prod" +npm = ["jlpm"] + +[tool.check-manifest] +ignore = ["jupyterlab_examples_kernel_messaging/labextension/**", "yarn.lock", ".*", "package-lock.json"] diff --git a/kernel-messaging/setup.py b/kernel-messaging/setup.py index 6592ff5d..94f092e7 100644 --- a/kernel-messaging/setup.py +++ b/kernel-messaging/setup.py @@ -2,79 +2,52 @@ jupyterlab_examples_kernel_messaging setup """ import json -import os +from pathlib import Path -from jupyter_packaging import ( - create_cmdclass, install_npm, ensure_targets, - combine_commands, skip_if_exists -) import setuptools -HERE = os.path.abspath(os.path.dirname(__file__)) +HERE = Path(__file__).parent.resolve() # The name of the project -name="jupyterlab_examples_kernel_messaging" - -# Get our version -with open(os.path.join(HERE, 'package.json')) as f: - version = json.load(f)['version'] +name = "jupyterlab_examples_kernel_messaging" -lab_path = os.path.join(HERE, name, "labextension") +lab_path = (HERE / name / "labextension") # Representative files that should exist after a successful build -jstargets = [ - os.path.join(lab_path, "package.json"), +ensured_targets = [ + str(lab_path / "package.json"), + str(lab_path / "static/style.js") ] -package_data_spec = { - name: [ - "*" - ] -} - labext_name = "@jupyterlab-examples/kernel-messaging" data_files_spec = [ - ("share/jupyter/labextensions/%s" % labext_name, lab_path, "**"), - ("share/jupyter/labextensions/%s" % labext_name, HERE, "install.json"), + ("share/jupyter/labextensions/%s" % labext_name, str(lab_path), "**"), + ("share/jupyter/labextensions/%s" % labext_name, str(HERE), "install.json"), ] -cmdclass = create_cmdclass("jsdeps", - package_data_spec=package_data_spec, - data_files_spec=data_files_spec -) - -js_command = combine_commands( - install_npm(HERE, build_cmd="build:prod", npm=["jlpm"]), - ensure_targets(jstargets), -) - -is_repo = os.path.exists(os.path.join(HERE, ".git")) -if is_repo: - cmdclass["jsdeps"] = js_command -else: - cmdclass["jsdeps"] = skip_if_exists(jstargets, js_command) +long_description = (HERE / "README.md").read_text() -with open("README.md", "r") as fh: - long_description = fh.read() +# Get the package info from package.json +pkg_json = json.loads((HERE / "package.json").read_bytes()) setup_args = dict( name=name, - version=version, - url="https://github.com/jupyterlab/extension-examples.git", - author="Project Jupyter Contributors", - description="minimal lab example", - long_description= long_description, + version=pkg_json["version"], + url=pkg_json["homepage"], + author=pkg_json["author"]["name"], + author_email=pkg_json["author"]["email"], + description=pkg_json["description"], + license=pkg_json["license"], + long_description=long_description, long_description_content_type="text/markdown", - cmdclass= cmdclass, packages=setuptools.find_packages(), install_requires=[ - "jupyterlab>=3.0.0rc15,==3.*", + "jupyter_server>=1.6,<2" ], zip_safe=False, include_package_data=True, python_requires=">=3.6", - license="BSD-3-Clause", platforms="Linux, Mac OS X, Windows", keywords=["Jupyter", "JupyterLab", "JupyterLab3"], classifiers=[ @@ -84,10 +57,24 @@ "Programming Language :: Python :: 3.6", "Programming Language :: Python :: 3.7", "Programming Language :: Python :: 3.8", + "Programming Language :: Python :: 3.9", "Framework :: Jupyter", ], ) +try: + from jupyter_packaging import ( + wrap_installers, + npm_builder, + get_data_files + ) + post_develop = npm_builder( + build_cmd="install:extension", source_dir="src", build_dir=lab_path + ) + setup_args['cmdclass'] = wrap_installers(post_develop=post_develop, ensured_targets=ensured_targets) + setup_args['data_files'] = get_data_files(data_files_spec) +except ImportError as e: + pass if __name__ == "__main__": setuptools.setup(**setup_args) diff --git a/kernel-messaging/src/index.ts b/kernel-messaging/src/index.ts index fc6a9945..dc205393 100644 --- a/kernel-messaging/src/index.ts +++ b/kernel-messaging/src/index.ts @@ -1,6 +1,6 @@ import { JupyterFrontEnd, - JupyterFrontEndPlugin + JupyterFrontEndPlugin, } from '@jupyterlab/application'; import { ICommandPalette } from '@jupyterlab/apputils'; @@ -30,7 +30,7 @@ const extension: JupyterFrontEndPlugin = { autoStart: true, optional: [ILauncher], requires: [ICommandPalette, IMainMenu, ITranslator], - activate: activate + activate: activate, }; /** @@ -58,7 +58,7 @@ function activate( if (launcher) { launcher.add({ command: CommandIDs.create, - category: category + category: category, }); } @@ -82,7 +82,7 @@ function activate( commands.addCommand(CommandIDs.create, { label: trans.__('Open the Kernel Messaging Panel'), caption: trans.__('Open the Kernel Messaging Panel'), - execute: createPanel + execute: createPanel, }); // add items in command palette and menu diff --git a/kernel-messaging/src/model.ts b/kernel-messaging/src/model.ts index d9a233f7..928e9cbf 100644 --- a/kernel-messaging/src/model.ts +++ b/kernel-messaging/src/model.ts @@ -44,7 +44,7 @@ export class KernelModel { return; } this.future = this._sessionContext.session?.kernel?.requestExecute({ - code + code, }); } diff --git a/kernel-messaging/src/panel.ts b/kernel-messaging/src/panel.ts index 988dd2ca..466ddab9 100644 --- a/kernel-messaging/src/panel.ts +++ b/kernel-messaging/src/panel.ts @@ -1,13 +1,13 @@ import { SessionContext, ISessionContext, - sessionContextDialogs + sessionContextDialogs, } from '@jupyterlab/apputils'; import { ITranslator, nullTranslator, - TranslationBundle + TranslationBundle, } from '@jupyterlab/translation'; import { ServiceManager } from '@jupyterlab/services'; @@ -41,7 +41,7 @@ export class ExamplePanel extends StackedPanel { this._sessionContext = new SessionContext({ sessionManager: manager.sessions, specsManager: manager.kernelspecs, - name: 'Extension Examples' + name: 'Extension Examples', }); this._model = new KernelModel(this._sessionContext); @@ -50,12 +50,12 @@ export class ExamplePanel extends StackedPanel { this.addWidget(this._example); void this._sessionContext .initialize() - .then(async value => { + .then(async (value) => { if (value) { await sessionContextDialogs.selectKernel(this._sessionContext); } }) - .catch(reason => { + .catch((reason) => { console.error( `Failed to initialize the session in ExamplePanel.\n${reason}` ); diff --git a/kernel-output/.eslintrc.js b/kernel-output/.eslintrc.js index 652320e0..c2375786 100644 --- a/kernel-output/.eslintrc.js +++ b/kernel-output/.eslintrc.js @@ -5,28 +5,34 @@ module.exports = { 'plugin:@typescript-eslint/recommended', 'plugin:jsdoc/recommended', 'plugin:prettier/recommended', - 'plugin:react/recommended' + 'plugin:react/recommended', ], parser: '@typescript-eslint/parser', parserOptions: { project: 'tsconfig.json', - sourceType: 'module' + sourceType: 'module', }, plugins: ['@typescript-eslint', 'jsdoc'], rules: { - '@typescript-eslint/interface-name-prefix': [ + '@typescript-eslint/naming-convention': [ 'error', - { prefixWithI: 'always' } + { + selector: 'interface', + format: ['PascalCase'], + custom: { + regex: '^I[A-Z]', + match: true, + }, + }, ], '@typescript-eslint/no-unused-vars': ['warn', { args: 'none' }], '@typescript-eslint/no-explicit-any': 'off', - '@typescript-eslint/camelcase': 'warn', '@typescript-eslint/no-namespace': 'off', '@typescript-eslint/no-use-before-define': 'off', '@typescript-eslint/quotes': [ 'error', 'single', - { avoidEscape: true, allowTemplateLiterals: false } + { avoidEscape: true, allowTemplateLiterals: false }, ], curly: ['error', 'all'], eqeqeq: 'error', @@ -34,14 +40,14 @@ module.exports = { 'jsdoc/require-property-type': 'off', 'jsdoc/require-returns-type': 'off', 'jsdoc/no-types': 'warn', - 'prefer-arrow-callback': 'error' + 'prefer-arrow-callback': 'error', }, settings: { jsdoc: { - mode: 'typescript' + mode: 'typescript', }, react: { - version: 'detect' - } - } + version: 'detect', + }, + }, }; diff --git a/kernel-output/README.md b/kernel-output/README.md index 267bbd19..e723f84c 100644 --- a/kernel-output/README.md +++ b/kernel-output/README.md @@ -55,7 +55,7 @@ the kernel) is started with these lines: this._sessionContext = new SessionContext({ sessionManager: manager.sessions, specsManager: manager.kernelspecs, - name: 'Kernel Output' + name: 'Kernel Output', }); ``` @@ -129,7 +129,7 @@ the data to show: this._outputareamodel = new OutputAreaModel(); this._outputarea = new SimplifiedOutputArea({ model: this._outputareamodel, - rendermime: rendermime + rendermime: rendermime, }); ``` @@ -188,7 +188,7 @@ on a list: // src/index.ts#L110-L114 // add items in command palette and menu -[CommandIDs.create, CommandIDs.execute].forEach(command => { +[CommandIDs.create, CommandIDs.execute].forEach((command) => { palette.addItem({ command, category }); exampleMenu.addItem({ command }); }); @@ -245,14 +245,14 @@ commands.addCommand(CommandIDs.execute, { const input = await InputDialog.getText({ title: trans.__('Code to execute'), okLabel: trans.__('Execute'), - placeholder: trans.__('Statement to execute') + placeholder: trans.__('Statement to execute'), }); // Execute the statement if (input.button.accept) { const code = input.value; panel.execute(code); } - } + }, }); ``` diff --git a/kernel-output/package.json b/kernel-output/package.json index 73e6f93a..dddaca93 100644 --- a/kernel-output/package.json +++ b/kernel-output/package.json @@ -12,10 +12,14 @@ "url": "https://github.com/jupyterlab/extension-examples/issues" }, "license": "BSD-3-Clause", - "author": "Project Jupyter Contributors", + "author": { + "name": "Project Jupyter Contributors", + "email": "" + }, "files": [ "lib/**/*.{d.ts,eot,gif,html,jpg,js,js.map,json,png,svg,woff2,ttf}", - "style/**/*.{css,eot,gif,html,jpg,json,png,svg,woff2,ttf}" + "style/**/*.{css,eot,gif,html,jpg,json,png,svg,woff2,ttf}", + "style/index.js" ], "main": "lib/index.js", "types": "lib/index.d.ts", @@ -30,49 +34,51 @@ "build:labextension": "jupyter labextension build .", "build:labextension:dev": "jupyter labextension build --development True .", "build:lib": "tsc", - "build:prod": "jlpm run build:lib && jlpm run build:labextension", + "build:prod": "jlpm run clean && jlpm run build:lib && jlpm run build:labextension", "clean": "jlpm run clean:lib", "clean:all": "jlpm run clean:lib && jlpm run clean:labextension", "clean:labextension": "rimraf jupyterlab_examples_kernel_output/labextension", "clean:lib": "rimraf lib tsconfig.tsbuildinfo", "eslint": "eslint . --ext .ts,.tsx --fix", "eslint:check": "eslint . --ext .ts,.tsx", - "install:extension": "jupyter labextension develop --overwrite .", + "install:extension": "jlpm run build", "prepare": "jlpm run clean && jlpm run build:prod", "watch": "run-p watch:src watch:labextension", "watch:labextension": "jupyter labextension watch .", "watch:src": "tsc -w" }, "dependencies": { - "@jupyterlab/application": "^3.0.0-rc.15", - "@jupyterlab/launcher": "^3.0.0-rc.15", - "@jupyterlab/mainmenu": "^3.0.0-rc.15", - "@jupyterlab/outputarea": "^3.0.0-rc.15", - "@jupyterlab/translation": "^3.0.0-rc.15", + "@jupyterlab/application": "^3.0.10", + "@jupyterlab/launcher": "^3.0.8", + "@jupyterlab/mainmenu": "^3.0.8", + "@jupyterlab/outputarea": "^3.0.9", + "@jupyterlab/translation": "^3.0.8", "@lumino/algorithm": "^1.3.3", "@lumino/coreutils": "^1.5.3", "@lumino/datagrid": "^0.3.1", "@lumino/disposable": "^1.4.3" }, "devDependencies": { - "@jupyterlab/builder": "^3.0.0-rc.15", - "@typescript-eslint/eslint-plugin": "^2.27.0", - "@typescript-eslint/parser": "^2.27.0", - "eslint": "^7.5.0", - "eslint-config-prettier": "^6.10.1", - "eslint-plugin-jsdoc": "^22.0.0", - "eslint-plugin-prettier": "^3.1.2", + "@jupyterlab/builder": "^3.0.0", + "@typescript-eslint/eslint-plugin": "^4.8.1", + "@typescript-eslint/parser": "^4.8.1", + "eslint": "^7.14.0", + "eslint-config-prettier": "^6.15.0", + "eslint-plugin-jsdoc": "^34.0.0", + "eslint-plugin-prettier": "^3.1.4", "eslint-plugin-react": "^7.18.3", "npm-run-all": "^4.1.5", - "prettier": "^1.19.0", + "prettier": "^2.1.1", "rimraf": "^3.0.2", "typescript": "~4.1.3" }, "sideEffects": [ - "style/*.css" + "style/*.css", + "style/index.js" ], "jupyterlab": { "extension": true, "outputDir": "jupyterlab_examples_kernel_output/labextension" - } + }, + "styleModule": "style/index.js" } \ No newline at end of file diff --git a/kernel-output/pyproject.toml b/kernel-output/pyproject.toml index c40f3629..4bb2820e 100644 --- a/kernel-output/pyproject.toml +++ b/kernel-output/pyproject.toml @@ -1,3 +1,17 @@ [build-system] -requires = ["jupyter_packaging~=0.7.9", "jupyterlab>=3.0.0rc15,==3.*", "setuptools>=40.8.0", "wheel"] -build-backend = "setuptools.build_meta" +requires = ["jupyter_packaging~=0.10,<2", "jupyterlab~=3.0"] +build-backend = "jupyter_packaging.build_api" + +[tool.jupyter-packaging.options] +skip-if-exists = ["jupyterlab_examples_kernel_output/labextension/static/style.js"] +ensured-targets = ["jupyterlab_examples_kernel_output/labextension/static/style.js", "jupyterlab_examples_kernel_output/labextension/package.json"] + +[tool.jupyter-packaging.builder] +factory = "jupyter_packaging.npm_builder" + +[tool.jupyter-packaging.build-args] +build_cmd = "build:prod" +npm = ["jlpm"] + +[tool.check-manifest] +ignore = ["jupyterlab_examples_kernel_output/labextension/**", "yarn.lock", ".*", "package-lock.json"] diff --git a/kernel-output/setup.py b/kernel-output/setup.py index 4fb31193..abfa9d23 100644 --- a/kernel-output/setup.py +++ b/kernel-output/setup.py @@ -2,79 +2,52 @@ jupyterlab_examples_kernel_output setup """ import json -import os +from pathlib import Path -from jupyter_packaging import ( - create_cmdclass, install_npm, ensure_targets, - combine_commands, skip_if_exists -) import setuptools -HERE = os.path.abspath(os.path.dirname(__file__)) +HERE = Path(__file__).parent.resolve() # The name of the project -name="jupyterlab_examples_kernel_output" - -# Get our version -with open(os.path.join(HERE, 'package.json')) as f: - version = json.load(f)['version'] +name = "jupyterlab_examples_kernel_output" -lab_path = os.path.join(HERE, name, "labextension") +lab_path = (HERE / name / "labextension") # Representative files that should exist after a successful build -jstargets = [ - os.path.join(lab_path, "package.json"), +ensured_targets = [ + str(lab_path / "package.json"), + str(lab_path / "static/style.js") ] -package_data_spec = { - name: [ - "*" - ] -} - labext_name = "@jupyterlab-examples/kernel-output" data_files_spec = [ - ("share/jupyter/labextensions/%s" % labext_name, lab_path, "**"), - ("share/jupyter/labextensions/%s" % labext_name, HERE, "install.json"), + ("share/jupyter/labextensions/%s" % labext_name, str(lab_path), "**"), + ("share/jupyter/labextensions/%s" % labext_name, str(HERE), "install.json"), ] -cmdclass = create_cmdclass("jsdeps", - package_data_spec=package_data_spec, - data_files_spec=data_files_spec -) - -js_command = combine_commands( - install_npm(HERE, build_cmd="build:prod", npm=["jlpm"]), - ensure_targets(jstargets), -) - -is_repo = os.path.exists(os.path.join(HERE, ".git")) -if is_repo: - cmdclass["jsdeps"] = js_command -else: - cmdclass["jsdeps"] = skip_if_exists(jstargets, js_command) +long_description = (HERE / "README.md").read_text() -with open("README.md", "r") as fh: - long_description = fh.read() +# Get the package info from package.json +pkg_json = json.loads((HERE / "package.json").read_bytes()) setup_args = dict( name=name, - version=version, - url="https://github.com/jupyterlab/extension-examples.git", - author="Project Jupyter Contributors", - description="minimal lab example", - long_description= long_description, + version=pkg_json["version"], + url=pkg_json["homepage"], + author=pkg_json["author"]["name"], + author_email=pkg_json["author"]["email"], + description=pkg_json["description"], + license=pkg_json["license"], + long_description=long_description, long_description_content_type="text/markdown", - cmdclass= cmdclass, packages=setuptools.find_packages(), install_requires=[ - "jupyterlab>=3.0.0rc15,==3.*", + "jupyter_server>=1.6,<2" ], zip_safe=False, include_package_data=True, python_requires=">=3.6", - license="BSD-3-Clause", platforms="Linux, Mac OS X, Windows", keywords=["Jupyter", "JupyterLab", "JupyterLab3"], classifiers=[ @@ -84,10 +57,24 @@ "Programming Language :: Python :: 3.6", "Programming Language :: Python :: 3.7", "Programming Language :: Python :: 3.8", + "Programming Language :: Python :: 3.9", "Framework :: Jupyter", ], ) +try: + from jupyter_packaging import ( + wrap_installers, + npm_builder, + get_data_files + ) + post_develop = npm_builder( + build_cmd="install:extension", source_dir="src", build_dir=lab_path + ) + setup_args['cmdclass'] = wrap_installers(post_develop=post_develop, ensured_targets=ensured_targets) + setup_args['data_files'] = get_data_files(data_files_spec) +except ImportError as e: + pass if __name__ == "__main__": setuptools.setup(**setup_args) diff --git a/kernel-output/src/index.ts b/kernel-output/src/index.ts index f4966306..45b25bec 100644 --- a/kernel-output/src/index.ts +++ b/kernel-output/src/index.ts @@ -1,6 +1,6 @@ import { JupyterFrontEnd, - JupyterFrontEndPlugin + JupyterFrontEndPlugin, } from '@jupyterlab/application'; import { ICommandPalette, InputDialog } from '@jupyterlab/apputils'; @@ -34,7 +34,7 @@ const extension: JupyterFrontEndPlugin = { autoStart: true, optional: [ILauncher], requires: [ICommandPalette, IMainMenu, IRenderMimeRegistry, ITranslator], - activate: activate + activate: activate, }; /** @@ -82,7 +82,7 @@ function activate( commands.addCommand(CommandIDs.create, { label: trans.__('Open the Kernel Output Panel'), caption: trans.__('Open the Kernel Output Panel'), - execute: createPanel + execute: createPanel, }); commands.addCommand(CommandIDs.execute, { @@ -97,18 +97,18 @@ function activate( const input = await InputDialog.getText({ title: trans.__('Code to execute'), okLabel: trans.__('Execute'), - placeholder: trans.__('Statement to execute') + placeholder: trans.__('Statement to execute'), }); // Execute the statement if (input.button.accept) { const code = input.value; panel.execute(code); } - } + }, }); // add items in command palette and menu - [CommandIDs.create, CommandIDs.execute].forEach(command => { + [CommandIDs.create, CommandIDs.execute].forEach((command) => { palette.addItem({ command, category }); exampleMenu.addItem({ command }); }); @@ -117,7 +117,7 @@ function activate( if (launcher) { launcher.add({ command: CommandIDs.create, - category: category + category: category, }); } } diff --git a/kernel-output/src/panel.ts b/kernel-output/src/panel.ts index ded4f69c..2c0d6d84 100644 --- a/kernel-output/src/panel.ts +++ b/kernel-output/src/panel.ts @@ -1,7 +1,7 @@ import { ISessionContext, SessionContext, - sessionContextDialogs + sessionContextDialogs, } from '@jupyterlab/apputils'; import { OutputAreaModel, SimplifiedOutputArea } from '@jupyterlab/outputarea'; @@ -13,7 +13,7 @@ import { KernelMessage, ServiceManager } from '@jupyterlab/services'; import { ITranslator, nullTranslator, - TranslationBundle + TranslationBundle, } from '@jupyterlab/translation'; import { Message } from '@lumino/messaging'; @@ -45,25 +45,25 @@ export class ExamplePanel extends StackedPanel { this._sessionContext = new SessionContext({ sessionManager: manager.sessions, specsManager: manager.kernelspecs, - name: 'Kernel Output' + name: 'Kernel Output', }); this._outputareamodel = new OutputAreaModel(); this._outputarea = new SimplifiedOutputArea({ model: this._outputareamodel, - rendermime: rendermime + rendermime: rendermime, }); this.addWidget(this._outputarea); void this._sessionContext .initialize() - .then(async value => { + .then(async (value) => { if (value) { await sessionContextDialogs.selectKernel(this._sessionContext); } }) - .catch(reason => { + .catch((reason) => { console.error( `Failed to initialize the session in ExamplePanel.\n${reason}` ); @@ -84,7 +84,7 @@ export class ExamplePanel extends StackedPanel { .then((msg: KernelMessage.IExecuteReplyMsg) => { console.log(msg); }) - .catch(reason => console.error(reason)); + .catch((reason) => console.error(reason)); } protected onCloseRequest(msg: Message): void { diff --git a/launcher/.eslintrc.js b/launcher/.eslintrc.js index 652320e0..c2375786 100644 --- a/launcher/.eslintrc.js +++ b/launcher/.eslintrc.js @@ -5,28 +5,34 @@ module.exports = { 'plugin:@typescript-eslint/recommended', 'plugin:jsdoc/recommended', 'plugin:prettier/recommended', - 'plugin:react/recommended' + 'plugin:react/recommended', ], parser: '@typescript-eslint/parser', parserOptions: { project: 'tsconfig.json', - sourceType: 'module' + sourceType: 'module', }, plugins: ['@typescript-eslint', 'jsdoc'], rules: { - '@typescript-eslint/interface-name-prefix': [ + '@typescript-eslint/naming-convention': [ 'error', - { prefixWithI: 'always' } + { + selector: 'interface', + format: ['PascalCase'], + custom: { + regex: '^I[A-Z]', + match: true, + }, + }, ], '@typescript-eslint/no-unused-vars': ['warn', { args: 'none' }], '@typescript-eslint/no-explicit-any': 'off', - '@typescript-eslint/camelcase': 'warn', '@typescript-eslint/no-namespace': 'off', '@typescript-eslint/no-use-before-define': 'off', '@typescript-eslint/quotes': [ 'error', 'single', - { avoidEscape: true, allowTemplateLiterals: false } + { avoidEscape: true, allowTemplateLiterals: false }, ], curly: ['error', 'all'], eqeqeq: 'error', @@ -34,14 +40,14 @@ module.exports = { 'jsdoc/require-property-type': 'off', 'jsdoc/require-returns-type': 'off', 'jsdoc/no-types': 'warn', - 'prefer-arrow-callback': 'error' + 'prefer-arrow-callback': 'error', }, settings: { jsdoc: { - mode: 'typescript' + mode: 'typescript', }, react: { - version: 'detect' - } - } + version: 'detect', + }, + }, }; diff --git a/launcher/README.md b/launcher/README.md index a114aa5c..e64ec417 100644 --- a/launcher/README.md +++ b/launcher/README.md @@ -21,10 +21,10 @@ The command will create a new Python file and then open it: // src/index.ts#L44-L66 commands.addCommand(command, { - label: args => (args['isPalette'] ? 'New Python File' : 'Python File'), + label: (args) => (args['isPalette'] ? 'New Python File' : 'Python File'), caption: 'Create a new Python file', - icon: args => (args['isPalette'] ? null : icon), - execute: async args => { + icon: (args) => (args['isPalette'] ? null : icon), + execute: async (args) => { // Get the directory in which the Python file must be created; // otherwise take the current filebrowser directory const cwd = args['cwd'] || browserFactory.defaultBrowser.model.path; @@ -33,15 +33,15 @@ commands.addCommand(command, { const model = await commands.execute('docmanager:new-untitled', { path: cwd, type: 'file', - ext: 'py' + ext: 'py', }); // Open the newly created file with the 'Editor' return commands.execute('docmanager:open', { path: model.path, - factory: FACTORY + factory: FACTORY, }); - } + }, }); ``` @@ -97,7 +97,7 @@ if (launcher) { launcher.add({ command, category: 'Extension Examples', - rank: 1 + rank: 1, }); } ``` diff --git a/launcher/package.json b/launcher/package.json index 1c6b2f15..b1aeee64 100644 --- a/launcher/package.json +++ b/launcher/package.json @@ -12,10 +12,14 @@ "url": "https://github.com/jupyterlab/extension-examples/issues" }, "license": "BSD-3-Clause", - "author": "Project Jupyter Contributors", + "author": { + "name": "Project Jupyter Contributors", + "email": "" + }, "files": [ "lib/**/*.{d.ts,eot,gif,html,jpg,js,js.map,json,png,svg,woff2,ttf}", - "style/**/*.{css,eot,gif,html,jpg,json,png,svg,woff2,ttf}" + "style/**/*.{css,eot,gif,html,jpg,json,png,svg,woff2,ttf}", + "style/index.js" ], "main": "lib/index.js", "types": "lib/index.d.ts", @@ -30,45 +34,47 @@ "build:labextension": "jupyter labextension build .", "build:labextension:dev": "jupyter labextension build --development True .", "build:lib": "tsc", - "build:prod": "jlpm run build:lib && jlpm run build:labextension", + "build:prod": "jlpm run clean && jlpm run build:lib && jlpm run build:labextension", "clean": "jlpm run clean:lib", "clean:all": "jlpm run clean:lib && jlpm run clean:labextension", "clean:labextension": "rimraf jupyterlab_examples_launcher/labextension", "clean:lib": "rimraf lib tsconfig.tsbuildinfo", "eslint": "eslint . --ext .ts,.tsx --fix", "eslint:check": "eslint . --ext .ts,.tsx", - "install:extension": "jupyter labextension develop --overwrite .", + "install:extension": "jlpm run build", "prepare": "jlpm run clean && jlpm run build:prod", "watch": "run-p watch:src watch:labextension", "watch:labextension": "jupyter labextension watch .", "watch:src": "tsc -w" }, "dependencies": { - "@jupyterlab/application": "^3.0.0-rc.15", - "@jupyterlab/filebrowser": "^3.0.0-rc.15", - "@jupyterlab/launcher": "^3.0.0-rc.15", - "@jupyterlab/mainmenu": "^3.0.0-rc.15" + "@jupyterlab/application": "^3.0.10", + "@jupyterlab/filebrowser": "^3.0.10", + "@jupyterlab/launcher": "^3.0.8", + "@jupyterlab/mainmenu": "^3.0.8" }, "devDependencies": { - "@jupyterlab/builder": "^3.0.0-rc.15", - "@typescript-eslint/eslint-plugin": "^2.27.0", - "@typescript-eslint/parser": "^2.27.0", - "eslint": "^7.5.0", - "eslint-config-prettier": "^6.10.1", - "eslint-plugin-jsdoc": "^22.0.0", - "eslint-plugin-prettier": "^3.1.2", + "@jupyterlab/builder": "^3.0.0", + "@typescript-eslint/eslint-plugin": "^4.8.1", + "@typescript-eslint/parser": "^4.8.1", + "eslint": "^7.14.0", + "eslint-config-prettier": "^6.15.0", + "eslint-plugin-jsdoc": "^34.0.0", + "eslint-plugin-prettier": "^3.1.4", "eslint-plugin-react": "^7.18.3", "npm-run-all": "^4.1.5", - "prettier": "^1.19.0", + "prettier": "^2.1.1", "rimraf": "^3.0.2", "typescript": "~4.1.3" }, "sideEffects": [ "style/*.css", - "style/*.svg" + "style/*.svg", + "style/index.js" ], "jupyterlab": { "extension": true, "outputDir": "jupyterlab_examples_launcher/labextension" - } + }, + "styleModule": "style/index.js" } \ No newline at end of file diff --git a/launcher/pyproject.toml b/launcher/pyproject.toml index c40f3629..29e548f0 100644 --- a/launcher/pyproject.toml +++ b/launcher/pyproject.toml @@ -1,3 +1,17 @@ [build-system] -requires = ["jupyter_packaging~=0.7.9", "jupyterlab>=3.0.0rc15,==3.*", "setuptools>=40.8.0", "wheel"] -build-backend = "setuptools.build_meta" +requires = ["jupyter_packaging~=0.10,<2", "jupyterlab~=3.0"] +build-backend = "jupyter_packaging.build_api" + +[tool.jupyter-packaging.options] +skip-if-exists = ["jupyterlab_examples_launcher/labextension/static/style.js"] +ensured-targets = ["jupyterlab_examples_launcher/labextension/static/style.js", "jupyterlab_examples_launcher/labextension/package.json"] + +[tool.jupyter-packaging.builder] +factory = "jupyter_packaging.npm_builder" + +[tool.jupyter-packaging.build-args] +build_cmd = "build:prod" +npm = ["jlpm"] + +[tool.check-manifest] +ignore = ["jupyterlab_examples_launcher/labextension/**", "yarn.lock", ".*", "package-lock.json"] diff --git a/launcher/setup.py b/launcher/setup.py index 1dd4ea27..cf70e22c 100644 --- a/launcher/setup.py +++ b/launcher/setup.py @@ -2,79 +2,52 @@ jupyterlab_examples_launcher setup """ import json -import os +from pathlib import Path -from jupyter_packaging import ( - create_cmdclass, install_npm, ensure_targets, - combine_commands, skip_if_exists -) import setuptools -HERE = os.path.abspath(os.path.dirname(__file__)) +HERE = Path(__file__).parent.resolve() # The name of the project -name="jupyterlab_examples_launcher" - -# Get our version -with open(os.path.join(HERE, 'package.json')) as f: - version = json.load(f)['version'] +name = "jupyterlab_examples_launcher" -lab_path = os.path.join(HERE, name, "labextension") +lab_path = (HERE / name / "labextension") # Representative files that should exist after a successful build -jstargets = [ - os.path.join(lab_path, "package.json"), +ensured_targets = [ + str(lab_path / "package.json"), + str(lab_path / "static/style.js") ] -package_data_spec = { - name: [ - "*" - ] -} - labext_name = "@jupyterlab-examples/launcher" data_files_spec = [ - ("share/jupyter/labextensions/%s" % labext_name, lab_path, "**"), - ("share/jupyter/labextensions/%s" % labext_name, HERE, "install.json"), + ("share/jupyter/labextensions/%s" % labext_name, str(lab_path), "**"), + ("share/jupyter/labextensions/%s" % labext_name, str(HERE), "install.json"), ] -cmdclass = create_cmdclass("jsdeps", - package_data_spec=package_data_spec, - data_files_spec=data_files_spec -) - -js_command = combine_commands( - install_npm(HERE, build_cmd="build:prod", npm=["jlpm"]), - ensure_targets(jstargets), -) - -is_repo = os.path.exists(os.path.join(HERE, ".git")) -if is_repo: - cmdclass["jsdeps"] = js_command -else: - cmdclass["jsdeps"] = skip_if_exists(jstargets, js_command) +long_description = (HERE / "README.md").read_text() -with open("README.md", "r") as fh: - long_description = fh.read() +# Get the package info from package.json +pkg_json = json.loads((HERE / "package.json").read_bytes()) setup_args = dict( name=name, - version=version, - url="https://github.com/jupyterlab/extension-examples.git", - author="Project Jupyter Contributors", - description="A minimal JupyterLab example using the launcher.", - long_description= long_description, + version=pkg_json["version"], + url=pkg_json["homepage"], + author=pkg_json["author"]["name"], + author_email=pkg_json["author"]["email"], + description=pkg_json["description"], + license=pkg_json["license"], + long_description=long_description, long_description_content_type="text/markdown", - cmdclass= cmdclass, packages=setuptools.find_packages(), install_requires=[ - "jupyterlab>=3.0.0rc15,==3.*", + "jupyter_server>=1.6,<2" ], zip_safe=False, include_package_data=True, python_requires=">=3.6", - license="BSD-3-Clause", platforms="Linux, Mac OS X, Windows", keywords=["Jupyter", "JupyterLab", "JupyterLab3"], classifiers=[ @@ -84,10 +57,24 @@ "Programming Language :: Python :: 3.6", "Programming Language :: Python :: 3.7", "Programming Language :: Python :: 3.8", + "Programming Language :: Python :: 3.9", "Framework :: Jupyter", ], ) +try: + from jupyter_packaging import ( + wrap_installers, + npm_builder, + get_data_files + ) + post_develop = npm_builder( + build_cmd="install:extension", source_dir="src", build_dir=lab_path + ) + setup_args['cmdclass'] = wrap_installers(post_develop=post_develop, ensured_targets=ensured_targets) + setup_args['data_files'] = get_data_files(data_files_spec) +except ImportError as e: + pass if __name__ == "__main__": setuptools.setup(**setup_args) diff --git a/launcher/src/index.ts b/launcher/src/index.ts index dd8de230..c7ad3b03 100644 --- a/launcher/src/index.ts +++ b/launcher/src/index.ts @@ -1,6 +1,6 @@ import { JupyterFrontEnd, - JupyterFrontEndPlugin + JupyterFrontEndPlugin, } from '@jupyterlab/application'; import { ICommandPalette } from '@jupyterlab/apputils'; @@ -38,14 +38,14 @@ const extension: JupyterFrontEndPlugin = { const command = CommandIDs.createNew; const icon = new LabIcon({ name: 'launcher:python-icon', - svgstr: pythonIconStr + svgstr: pythonIconStr, }); commands.addCommand(command, { - label: args => (args['isPalette'] ? 'New Python File' : 'Python File'), + label: (args) => (args['isPalette'] ? 'New Python File' : 'Python File'), caption: 'Create a new Python file', - icon: args => (args['isPalette'] ? null : icon), - execute: async args => { + icon: (args) => (args['isPalette'] ? null : icon), + execute: async (args) => { // Get the directory in which the Python file must be created; // otherwise take the current filebrowser directory const cwd = args['cwd'] || browserFactory.defaultBrowser.model.path; @@ -54,15 +54,15 @@ const extension: JupyterFrontEndPlugin = { const model = await commands.execute('docmanager:new-untitled', { path: cwd, type: 'file', - ext: 'py' + ext: 'py', }); // Open the newly created file with the 'Editor' return commands.execute('docmanager:open', { path: model.path, - factory: FACTORY + factory: FACTORY, }); - } + }, }); // Add the command to the launcher @@ -70,7 +70,7 @@ const extension: JupyterFrontEndPlugin = { launcher.add({ command, category: 'Extension Examples', - rank: 1 + rank: 1, }); } @@ -79,7 +79,7 @@ const extension: JupyterFrontEndPlugin = { palette.addItem({ command, args: { isPalette: true }, - category: PALETTE_CATEGORY + category: PALETTE_CATEGORY, }); } @@ -87,7 +87,7 @@ const extension: JupyterFrontEndPlugin = { if (menu) { menu.fileMenu.newMenu.addGroup([{ command }], 30); } - } + }, }; export default extension; diff --git a/log-messages/.eslintrc.js b/log-messages/.eslintrc.js index 652320e0..c2375786 100644 --- a/log-messages/.eslintrc.js +++ b/log-messages/.eslintrc.js @@ -5,28 +5,34 @@ module.exports = { 'plugin:@typescript-eslint/recommended', 'plugin:jsdoc/recommended', 'plugin:prettier/recommended', - 'plugin:react/recommended' + 'plugin:react/recommended', ], parser: '@typescript-eslint/parser', parserOptions: { project: 'tsconfig.json', - sourceType: 'module' + sourceType: 'module', }, plugins: ['@typescript-eslint', 'jsdoc'], rules: { - '@typescript-eslint/interface-name-prefix': [ + '@typescript-eslint/naming-convention': [ 'error', - { prefixWithI: 'always' } + { + selector: 'interface', + format: ['PascalCase'], + custom: { + regex: '^I[A-Z]', + match: true, + }, + }, ], '@typescript-eslint/no-unused-vars': ['warn', { args: 'none' }], '@typescript-eslint/no-explicit-any': 'off', - '@typescript-eslint/camelcase': 'warn', '@typescript-eslint/no-namespace': 'off', '@typescript-eslint/no-use-before-define': 'off', '@typescript-eslint/quotes': [ 'error', 'single', - { avoidEscape: true, allowTemplateLiterals: false } + { avoidEscape: true, allowTemplateLiterals: false }, ], curly: ['error', 'all'], eqeqeq: 'error', @@ -34,14 +40,14 @@ module.exports = { 'jsdoc/require-property-type': 'off', 'jsdoc/require-returns-type': 'off', 'jsdoc/no-types': 'warn', - 'prefer-arrow-callback': 'error' + 'prefer-arrow-callback': 'error', }, settings: { jsdoc: { - mode: 'typescript' + mode: 'typescript', }, react: { - version: 'detect' - } - } + version: 'detect', + }, + }, }; diff --git a/log-messages/package.json b/log-messages/package.json index dcd83e8d..769def56 100644 --- a/log-messages/package.json +++ b/log-messages/package.json @@ -12,10 +12,14 @@ "url": "https://github.com/jupyterlab/extension-examples/issues" }, "license": "BSD-3-Clause", - "author": "Project Jupyter Contributors", + "author": { + "name": "Project Jupyter Contributors", + "email": "" + }, "files": [ "lib/**/*.{d.ts,eot,gif,html,jpg,js,js.map,json,png,svg,woff2,ttf}", - "style/**/*.{css,eot,gif,html,jpg,json,png,svg,woff2,ttf}" + "style/**/*.{css,eot,gif,html,jpg,json,png,svg,woff2,ttf}", + "style/index.js" ], "main": "lib/index.js", "types": "lib/index.d.ts", @@ -30,51 +34,53 @@ "build:labextension": "jupyter labextension build .", "build:labextension:dev": "jupyter labextension build --development True .", "build:lib": "tsc", - "build:prod": "jlpm run build:lib && jlpm run build:labextension", + "build:prod": "jlpm run clean && jlpm run build:lib && jlpm run build:labextension", "clean": "jlpm run clean:lib", "clean:all": "jlpm run clean:lib && jlpm run clean:labextension", "clean:labextension": "rimraf jupyterlab_examples_log_messages/labextension", "clean:lib": "rimraf lib tsconfig.tsbuildinfo", "eslint": "eslint . --ext .ts,.tsx --fix", "eslint:check": "eslint . --ext .ts,.tsx", - "install:extension": "jupyter labextension develop --overwrite .", + "install:extension": "jlpm run build", "prepare": "jlpm run clean && jlpm run build:prod", "watch": "run-p watch:src watch:labextension", "watch:labextension": "jupyter labextension watch .", "watch:src": "tsc -w" }, "dependencies": { - "@jupyterlab/application": "^3.0.0-rc.15", - "@jupyterlab/apputils": "^3.0.0-rc.15", - "@jupyterlab/coreutils": "^5.0.0-rc.15", - "@jupyterlab/logconsole": "^3.0.0-rc.15", - "@jupyterlab/mainmenu": "^3.0.0-rc.15", - "@jupyterlab/nbformat": "^3.0.0-rc.15", - "@jupyterlab/notebook": "^3.0.0-rc.15", - "@jupyterlab/rendermime": "^3.0.0-rc.15", - "@jupyterlab/ui-components": "^3.0.0-rc.15", + "@jupyterlab/application": "^3.0.10", + "@jupyterlab/apputils": "^3.0.8", + "@jupyterlab/coreutils": "^5.0.6", + "@jupyterlab/logconsole": "^3.0.9", + "@jupyterlab/mainmenu": "^3.0.8", + "@jupyterlab/nbformat": "^3.0.5", + "@jupyterlab/notebook": "^3.0.10", + "@jupyterlab/rendermime": "^3.0.9", + "@jupyterlab/ui-components": "^3.0.7", "@lumino/coreutils": "^1.5.3", "@lumino/widgets": "^1.16.1" }, "devDependencies": { - "@jupyterlab/builder": "^3.0.0-rc.15", - "@typescript-eslint/eslint-plugin": "^2.27.0", - "@typescript-eslint/parser": "^2.27.0", - "eslint": "^7.5.0", - "eslint-config-prettier": "^6.10.1", - "eslint-plugin-jsdoc": "^22.0.0", - "eslint-plugin-prettier": "^3.1.2", + "@jupyterlab/builder": "^3.0.0", + "@typescript-eslint/eslint-plugin": "^4.8.1", + "@typescript-eslint/parser": "^4.8.1", + "eslint": "^7.14.0", + "eslint-config-prettier": "^6.15.0", + "eslint-plugin-jsdoc": "^34.0.0", + "eslint-plugin-prettier": "^3.1.4", "eslint-plugin-react": "^7.18.3", "npm-run-all": "^4.1.5", - "prettier": "^1.19.0", + "prettier": "^2.1.1", "rimraf": "^3.0.2", "typescript": "~4.1.3" }, "sideEffects": [ - "style/*.css" + "style/*.css", + "style/index.js" ], "jupyterlab": { "extension": true, "outputDir": "jupyterlab_examples_log_messages/labextension" - } + }, + "styleModule": "style/index.js" } \ No newline at end of file diff --git a/log-messages/pyproject.toml b/log-messages/pyproject.toml index c40f3629..dfbeca8d 100644 --- a/log-messages/pyproject.toml +++ b/log-messages/pyproject.toml @@ -1,3 +1,17 @@ [build-system] -requires = ["jupyter_packaging~=0.7.9", "jupyterlab>=3.0.0rc15,==3.*", "setuptools>=40.8.0", "wheel"] -build-backend = "setuptools.build_meta" +requires = ["jupyter_packaging~=0.10,<2", "jupyterlab~=3.0"] +build-backend = "jupyter_packaging.build_api" + +[tool.jupyter-packaging.options] +skip-if-exists = ["jupyterlab_examples_log_messages/labextension/static/style.js"] +ensured-targets = ["jupyterlab_examples_log_messages/labextension/static/style.js", "jupyterlab_examples_log_messages/labextension/package.json"] + +[tool.jupyter-packaging.builder] +factory = "jupyter_packaging.npm_builder" + +[tool.jupyter-packaging.build-args] +build_cmd = "build:prod" +npm = ["jlpm"] + +[tool.check-manifest] +ignore = ["jupyterlab_examples_log_messages/labextension/**", "yarn.lock", ".*", "package-lock.json"] diff --git a/log-messages/setup.py b/log-messages/setup.py index 0b2b0356..cbb8a72b 100644 --- a/log-messages/setup.py +++ b/log-messages/setup.py @@ -2,79 +2,52 @@ jupyterlab_examples_log_messages setup """ import json -import os +from pathlib import Path -from jupyter_packaging import ( - create_cmdclass, install_npm, ensure_targets, - combine_commands, skip_if_exists -) import setuptools -HERE = os.path.abspath(os.path.dirname(__file__)) +HERE = Path(__file__).parent.resolve() # The name of the project -name="jupyterlab_examples_log_messages" - -# Get our version -with open(os.path.join(HERE, 'package.json')) as f: - version = json.load(f)['version'] +name = "jupyterlab_examples_log_messages" -lab_path = os.path.join(HERE, name, "labextension") +lab_path = (HERE / name / "labextension") # Representative files that should exist after a successful build -jstargets = [ - os.path.join(lab_path, "package.json"), +ensured_targets = [ + str(lab_path / "package.json"), + str(lab_path / "static/style.js") ] -package_data_spec = { - name: [ - "*" - ] -} - labext_name = "@jupyterlab-examples/log-messages" data_files_spec = [ - ("share/jupyter/labextensions/%s" % labext_name, lab_path, "**"), - ("share/jupyter/labextensions/%s" % labext_name, HERE, "install.json"), + ("share/jupyter/labextensions/%s" % labext_name, str(lab_path), "**"), + ("share/jupyter/labextensions/%s" % labext_name, str(HERE), "install.json"), ] -cmdclass = create_cmdclass("jsdeps", - package_data_spec=package_data_spec, - data_files_spec=data_files_spec -) - -js_command = combine_commands( - install_npm(HERE, build_cmd="build:prod", npm=["jlpm"]), - ensure_targets(jstargets), -) - -is_repo = os.path.exists(os.path.join(HERE, ".git")) -if is_repo: - cmdclass["jsdeps"] = js_command -else: - cmdclass["jsdeps"] = skip_if_exists(jstargets, js_command) +long_description = (HERE / "README.md").read_text() -with open("README.md", "r") as fh: - long_description = fh.read() +# Get the package info from package.json +pkg_json = json.loads((HERE / "package.json").read_bytes()) setup_args = dict( name=name, - version=version, - url="https://github.com/jupyterlab/extension-examples.git", - author="Project Jupyter Contributors", - description="A minimal JupyterLab example to develop a custom log-messages.", - long_description= long_description, + version=pkg_json["version"], + url=pkg_json["homepage"], + author=pkg_json["author"]["name"], + author_email=pkg_json["author"]["email"], + description=pkg_json["description"], + license=pkg_json["license"], + long_description=long_description, long_description_content_type="text/markdown", - cmdclass= cmdclass, packages=setuptools.find_packages(), install_requires=[ - "jupyterlab>=3.0.0rc15,==3.*", + "jupyter_server>=1.6,<2" ], zip_safe=False, include_package_data=True, python_requires=">=3.6", - license="BSD-3-Clause", platforms="Linux, Mac OS X, Windows", keywords=["Jupyter", "JupyterLab", "JupyterLab3"], classifiers=[ @@ -84,10 +57,24 @@ "Programming Language :: Python :: 3.6", "Programming Language :: Python :: 3.7", "Programming Language :: Python :: 3.8", + "Programming Language :: Python :: 3.9", "Framework :: Jupyter", ], ) +try: + from jupyter_packaging import ( + wrap_installers, + npm_builder, + get_data_files + ) + post_develop = npm_builder( + build_cmd="install:extension", source_dir="src", build_dir=lab_path + ) + setup_args['cmdclass'] = wrap_installers(post_develop=post_develop, ensured_targets=ensured_targets) + setup_args['data_files'] = get_data_files(data_files_spec) +except ImportError as e: + pass if __name__ == "__main__": setuptools.setup(**setup_args) diff --git a/log-messages/src/index.ts b/log-messages/src/index.ts index a02474d0..a54add54 100644 --- a/log-messages/src/index.ts +++ b/log-messages/src/index.ts @@ -1,6 +1,6 @@ import { JupyterFrontEnd, - JupyterFrontEndPlugin + JupyterFrontEndPlugin, } from '@jupyterlab/application'; import { ILoggerRegistry, ITextLog } from '@jupyterlab/logconsole'; import { INotebookTracker } from '@jupyterlab/notebook'; @@ -32,11 +32,11 @@ const extension: JupyterFrontEndPlugin = { const msg: ITextLog = { type: 'text', level: 'info', - data: 'Hello world text!!' + data: 'Hello world text!!', }; logger?.log(msg); - } + }, }); // Create a new menu @@ -46,7 +46,7 @@ const extension: JupyterFrontEndPlugin = { mainMenu.addMenu(menu, { rank: 80 }); menu.addItem({ command: 'jlab-examples/log-messages:logTextMessage' }); - } + }, }; export default extension; diff --git a/main-menu/.eslintrc.js b/main-menu/.eslintrc.js index 652320e0..c2375786 100644 --- a/main-menu/.eslintrc.js +++ b/main-menu/.eslintrc.js @@ -5,28 +5,34 @@ module.exports = { 'plugin:@typescript-eslint/recommended', 'plugin:jsdoc/recommended', 'plugin:prettier/recommended', - 'plugin:react/recommended' + 'plugin:react/recommended', ], parser: '@typescript-eslint/parser', parserOptions: { project: 'tsconfig.json', - sourceType: 'module' + sourceType: 'module', }, plugins: ['@typescript-eslint', 'jsdoc'], rules: { - '@typescript-eslint/interface-name-prefix': [ + '@typescript-eslint/naming-convention': [ 'error', - { prefixWithI: 'always' } + { + selector: 'interface', + format: ['PascalCase'], + custom: { + regex: '^I[A-Z]', + match: true, + }, + }, ], '@typescript-eslint/no-unused-vars': ['warn', { args: 'none' }], '@typescript-eslint/no-explicit-any': 'off', - '@typescript-eslint/camelcase': 'warn', '@typescript-eslint/no-namespace': 'off', '@typescript-eslint/no-use-before-define': 'off', '@typescript-eslint/quotes': [ 'error', 'single', - { avoidEscape: true, allowTemplateLiterals: false } + { avoidEscape: true, allowTemplateLiterals: false }, ], curly: ['error', 'all'], eqeqeq: 'error', @@ -34,14 +40,14 @@ module.exports = { 'jsdoc/require-property-type': 'off', 'jsdoc/require-returns-type': 'off', 'jsdoc/no-types': 'warn', - 'prefer-arrow-callback': 'error' + 'prefer-arrow-callback': 'error', }, settings: { jsdoc: { - mode: 'typescript' + mode: 'typescript', }, react: { - version: 'detect' - } - } + version: 'detect', + }, + }, }; diff --git a/main-menu/README.md b/main-menu/README.md index fb84f2e6..44249f9a 100644 --- a/main-menu/README.md +++ b/main-menu/README.md @@ -51,7 +51,7 @@ const extension: JupyterFrontEndPlugin = { window.alert( `jlab-examples:main-menu has been called ${args['origin']}.` ); - } + }, }); // Add the command to the command palette @@ -59,7 +59,7 @@ const extension: JupyterFrontEndPlugin = { palette.addItem({ command, category, - args: { origin: 'from the palette' } + args: { origin: 'from the palette' }, }); // Create a menu @@ -69,7 +69,7 @@ const extension: JupyterFrontEndPlugin = { // Add the command to the menu tutorialMenu.addItem({ command, args: { origin: 'from the menu' } }); - } + }, }; ``` diff --git a/main-menu/package.json b/main-menu/package.json index 30004a35..92319a4a 100644 --- a/main-menu/package.json +++ b/main-menu/package.json @@ -12,10 +12,14 @@ "url": "https://github.com/jupyterlab/extension-examples/issues" }, "license": "BSD-3-Clause", - "author": "Project Jupyter Contributors", + "author": { + "name": "Project Jupyter Contributors", + "email": "" + }, "files": [ "lib/**/*.{d.ts,eot,gif,html,jpg,js,js.map,json,png,svg,woff2,ttf}", - "style/**/*.{css,eot,gif,html,jpg,json,png,svg,woff2,ttf}" + "style/**/*.{css,eot,gif,html,jpg,json,png,svg,woff2,ttf}", + "style/index.js" ], "main": "lib/index.js", "types": "lib/index.d.ts", @@ -30,43 +34,45 @@ "build:labextension": "jupyter labextension build .", "build:labextension:dev": "jupyter labextension build --development True .", "build:lib": "tsc", - "build:prod": "jlpm run build:lib && jlpm run build:labextension", + "build:prod": "jlpm run clean && jlpm run build:lib && jlpm run build:labextension", "clean": "jlpm run clean:lib", "clean:all": "jlpm run clean:lib && jlpm run clean:labextension", "clean:labextension": "rimraf jupyterlab_examples_main_menu/labextension", "clean:lib": "rimraf lib tsconfig.tsbuildinfo", "eslint": "eslint . --ext .ts,.tsx --fix", "eslint:check": "eslint . --ext .ts,.tsx", - "install:extension": "jupyter labextension develop --overwrite .", + "install:extension": "jlpm run build", "prepare": "jlpm run clean && jlpm run build:prod", "watch": "run-p watch:src watch:labextension", "watch:labextension": "jupyter labextension watch .", "watch:src": "tsc -w" }, "dependencies": { - "@jupyterlab/application": "^3.0.0-rc.15", - "@jupyterlab/mainmenu": "^3.0.0-rc.15", + "@jupyterlab/application": "^3.0.10", + "@jupyterlab/mainmenu": "^3.0.8", "@lumino/widgets": "^1.16.1" }, "devDependencies": { - "@jupyterlab/builder": "^3.0.0-rc.15", - "@typescript-eslint/eslint-plugin": "^2.27.0", - "@typescript-eslint/parser": "^2.27.0", - "eslint": "^7.5.0", - "eslint-config-prettier": "^6.10.1", - "eslint-plugin-jsdoc": "^22.0.0", - "eslint-plugin-prettier": "^3.1.2", + "@jupyterlab/builder": "^3.0.0", + "@typescript-eslint/eslint-plugin": "^4.8.1", + "@typescript-eslint/parser": "^4.8.1", + "eslint": "^7.14.0", + "eslint-config-prettier": "^6.15.0", + "eslint-plugin-jsdoc": "^34.0.0", + "eslint-plugin-prettier": "^3.1.4", "eslint-plugin-react": "^7.18.3", "npm-run-all": "^4.1.5", - "prettier": "^1.19.0", + "prettier": "^2.1.1", "rimraf": "^3.0.2", "typescript": "~4.1.3" }, "sideEffects": [ - "style/*.css" + "style/*.css", + "style/index.js" ], "jupyterlab": { "extension": true, "outputDir": "jupyterlab_examples_main_menu/labextension" - } + }, + "styleModule": "style/index.js" } \ No newline at end of file diff --git a/main-menu/pyproject.toml b/main-menu/pyproject.toml index c40f3629..305e1f7c 100644 --- a/main-menu/pyproject.toml +++ b/main-menu/pyproject.toml @@ -1,3 +1,17 @@ [build-system] -requires = ["jupyter_packaging~=0.7.9", "jupyterlab>=3.0.0rc15,==3.*", "setuptools>=40.8.0", "wheel"] -build-backend = "setuptools.build_meta" +requires = ["jupyter_packaging~=0.10,<2", "jupyterlab~=3.0"] +build-backend = "jupyter_packaging.build_api" + +[tool.jupyter-packaging.options] +skip-if-exists = ["jupyterlab_examples_main_menu/labextension/static/style.js"] +ensured-targets = ["jupyterlab_examples_main_menu/labextension/static/style.js", "jupyterlab_examples_main_menu/labextension/package.json"] + +[tool.jupyter-packaging.builder] +factory = "jupyter_packaging.npm_builder" + +[tool.jupyter-packaging.build-args] +build_cmd = "build:prod" +npm = ["jlpm"] + +[tool.check-manifest] +ignore = ["jupyterlab_examples_main_menu/labextension/**", "yarn.lock", ".*", "package-lock.json"] diff --git a/main-menu/setup.py b/main-menu/setup.py index 67f3b592..b52750b0 100644 --- a/main-menu/setup.py +++ b/main-menu/setup.py @@ -2,79 +2,52 @@ jupyterlab_examples_main_menu setup """ import json -import os +from pathlib import Path -from jupyter_packaging import ( - create_cmdclass, install_npm, ensure_targets, - combine_commands, skip_if_exists -) import setuptools -HERE = os.path.abspath(os.path.dirname(__file__)) +HERE = Path(__file__).parent.resolve() # The name of the project -name="jupyterlab_examples_main_menu" - -# Get our version -with open(os.path.join(HERE, 'package.json')) as f: - version = json.load(f)['version'] +name = "jupyterlab_examples_main_menu" -lab_path = os.path.join(HERE, name, "labextension") +lab_path = (HERE / name / "labextension") # Representative files that should exist after a successful build -jstargets = [ - os.path.join(lab_path, "package.json"), +ensured_targets = [ + str(lab_path / "package.json"), + str(lab_path / "static/style.js") ] -package_data_spec = { - name: [ - "*" - ] -} - labext_name = "@jupyterlab-examples/main-menu" data_files_spec = [ - ("share/jupyter/labextensions/%s" % labext_name, lab_path, "**"), - ("share/jupyter/labextensions/%s" % labext_name, HERE, "install.json"), + ("share/jupyter/labextensions/%s" % labext_name, str(lab_path), "**"), + ("share/jupyter/labextensions/%s" % labext_name, str(HERE), "install.json"), ] -cmdclass = create_cmdclass("jsdeps", - package_data_spec=package_data_spec, - data_files_spec=data_files_spec -) - -js_command = combine_commands( - install_npm(HERE, build_cmd="build:prod", npm=["jlpm"]), - ensure_targets(jstargets), -) - -is_repo = os.path.exists(os.path.join(HERE, ".git")) -if is_repo: - cmdclass["jsdeps"] = js_command -else: - cmdclass["jsdeps"] = skip_if_exists(jstargets, js_command) +long_description = (HERE / "README.md").read_text() -with open("README.md", "r") as fh: - long_description = fh.read() +# Get the package info from package.json +pkg_json = json.loads((HERE / "package.json").read_bytes()) setup_args = dict( name=name, - version=version, - url="https://github.com/jupyterlab/extension-examples.git", - author="Project Jupyter Contributors", - description="Minimal JupyterLab example adding a menu.", - long_description= long_description, + version=pkg_json["version"], + url=pkg_json["homepage"], + author=pkg_json["author"]["name"], + author_email=pkg_json["author"]["email"], + description=pkg_json["description"], + license=pkg_json["license"], + long_description=long_description, long_description_content_type="text/markdown", - cmdclass= cmdclass, packages=setuptools.find_packages(), install_requires=[ - "jupyterlab>=3.0.0rc15,==3.*", + "jupyter_server>=1.6,<2" ], zip_safe=False, include_package_data=True, python_requires=">=3.6", - license="BSD-3-Clause", platforms="Linux, Mac OS X, Windows", keywords=["Jupyter", "JupyterLab", "JupyterLab3"], classifiers=[ @@ -84,10 +57,24 @@ "Programming Language :: Python :: 3.6", "Programming Language :: Python :: 3.7", "Programming Language :: Python :: 3.8", + "Programming Language :: Python :: 3.9", "Framework :: Jupyter", ], ) +try: + from jupyter_packaging import ( + wrap_installers, + npm_builder, + get_data_files + ) + post_develop = npm_builder( + build_cmd="install:extension", source_dir="src", build_dir=lab_path + ) + setup_args['cmdclass'] = wrap_installers(post_develop=post_develop, ensured_targets=ensured_targets) + setup_args['data_files'] = get_data_files(data_files_spec) +except ImportError as e: + pass if __name__ == "__main__": setuptools.setup(**setup_args) diff --git a/main-menu/src/index.ts b/main-menu/src/index.ts index 9ede346e..d9f27c60 100644 --- a/main-menu/src/index.ts +++ b/main-menu/src/index.ts @@ -1,6 +1,6 @@ import { JupyterFrontEnd, - JupyterFrontEndPlugin + JupyterFrontEndPlugin, } from '@jupyterlab/application'; import { IMainMenu } from '@jupyterlab/mainmenu'; @@ -35,7 +35,7 @@ const extension: JupyterFrontEndPlugin = { window.alert( `jlab-examples:main-menu has been called ${args['origin']}.` ); - } + }, }); // Add the command to the command palette @@ -43,7 +43,7 @@ const extension: JupyterFrontEndPlugin = { palette.addItem({ command, category, - args: { origin: 'from the palette' } + args: { origin: 'from the palette' }, }); // Create a menu @@ -53,7 +53,7 @@ const extension: JupyterFrontEndPlugin = { // Add the command to the menu tutorialMenu.addItem({ command, args: { origin: 'from the menu' } }); - } + }, }; export default extension; diff --git a/package.json b/package.json index d983cef7..4bcf9009 100644 --- a/package.json +++ b/package.json @@ -45,6 +45,6 @@ "husky": "^3.0.9", "lerna": "^3.18.4", "lint-staged": "^9.4.3", - "prettier": "^1.19.1" + "prettier": "^2.1.1" } } diff --git a/react-widget/.eslintrc.js b/react-widget/.eslintrc.js index 652320e0..c2375786 100644 --- a/react-widget/.eslintrc.js +++ b/react-widget/.eslintrc.js @@ -5,28 +5,34 @@ module.exports = { 'plugin:@typescript-eslint/recommended', 'plugin:jsdoc/recommended', 'plugin:prettier/recommended', - 'plugin:react/recommended' + 'plugin:react/recommended', ], parser: '@typescript-eslint/parser', parserOptions: { project: 'tsconfig.json', - sourceType: 'module' + sourceType: 'module', }, plugins: ['@typescript-eslint', 'jsdoc'], rules: { - '@typescript-eslint/interface-name-prefix': [ + '@typescript-eslint/naming-convention': [ 'error', - { prefixWithI: 'always' } + { + selector: 'interface', + format: ['PascalCase'], + custom: { + regex: '^I[A-Z]', + match: true, + }, + }, ], '@typescript-eslint/no-unused-vars': ['warn', { args: 'none' }], '@typescript-eslint/no-explicit-any': 'off', - '@typescript-eslint/camelcase': 'warn', '@typescript-eslint/no-namespace': 'off', '@typescript-eslint/no-use-before-define': 'off', '@typescript-eslint/quotes': [ 'error', 'single', - { avoidEscape: true, allowTemplateLiterals: false } + { avoidEscape: true, allowTemplateLiterals: false }, ], curly: ['error', 'all'], eqeqeq: 'error', @@ -34,14 +40,14 @@ module.exports = { 'jsdoc/require-property-type': 'off', 'jsdoc/require-returns-type': 'off', 'jsdoc/no-types': 'warn', - 'prefer-arrow-callback': 'error' + 'prefer-arrow-callback': 'error', }, settings: { jsdoc: { - mode: 'typescript' + mode: 'typescript', }, react: { - version: 'detect' - } - } + version: 'detect', + }, + }, }; diff --git a/react-widget/package.json b/react-widget/package.json index 482f68e2..a4a3aac2 100644 --- a/react-widget/package.json +++ b/react-widget/package.json @@ -12,10 +12,14 @@ "url": "https://github.com/jupyterlab/extension-examples/issues" }, "license": "BSD-3-Clause", - "author": "Project Jupyter Contributors", + "author": { + "name": "Project Jupyter Contributors", + "email": "" + }, "files": [ "lib/**/*.{d.ts,eot,gif,html,jpg,js,js.map,json,png,svg,woff2,ttf}", - "style/**/*.{css,eot,gif,html,jpg,json,png,svg,woff2,ttf}" + "style/**/*.{css,eot,gif,html,jpg,json,png,svg,woff2,ttf}", + "style/index.js" ], "main": "lib/index.js", "types": "lib/index.d.ts", @@ -30,43 +34,45 @@ "build:labextension": "jupyter labextension build .", "build:labextension:dev": "jupyter labextension build --development True .", "build:lib": "tsc", - "build:prod": "jlpm run build:lib && jlpm run build:labextension", + "build:prod": "jlpm run clean && jlpm run build:lib && jlpm run build:labextension", "clean": "jlpm run clean:lib", "clean:all": "jlpm run clean:lib && jlpm run clean:labextension", "clean:labextension": "rimraf jupyterlab_examples_react_widget/labextension", "clean:lib": "rimraf lib tsconfig.tsbuildinfo", "eslint": "eslint . --ext .ts,.tsx --fix", "eslint:check": "eslint . --ext .ts,.tsx", - "install:extension": "jupyter labextension develop --overwrite .", + "install:extension": "jlpm run build", "prepare": "jlpm run clean && jlpm run build:prod", "watch": "run-p watch:src watch:labextension", "watch:labextension": "jupyter labextension watch .", "watch:src": "tsc -w" }, "dependencies": { - "@jupyterlab/application": "^3.0.0-rc.15", - "@jupyterlab/launcher": "^3.0.0-rc.15", - "@jupyterlab/ui-components": "^3.0.0-rc.15" + "@jupyterlab/application": "^3.0.10", + "@jupyterlab/launcher": "^3.0.8", + "@jupyterlab/ui-components": "^3.0.7" }, "devDependencies": { - "@jupyterlab/builder": "^3.0.0-rc.15", - "@typescript-eslint/eslint-plugin": "^2.27.0", - "@typescript-eslint/parser": "^2.27.0", - "eslint": "^7.5.0", - "eslint-config-prettier": "^6.10.1", - "eslint-plugin-jsdoc": "^22.0.0", - "eslint-plugin-prettier": "^3.1.2", + "@jupyterlab/builder": "^3.0.0", + "@typescript-eslint/eslint-plugin": "^4.8.1", + "@typescript-eslint/parser": "^4.8.1", + "eslint": "^7.14.0", + "eslint-config-prettier": "^6.15.0", + "eslint-plugin-jsdoc": "^34.0.0", + "eslint-plugin-prettier": "^3.1.4", "eslint-plugin-react": "^7.18.3", "npm-run-all": "^4.1.5", - "prettier": "^1.19.0", + "prettier": "^2.1.1", "rimraf": "^3.0.2", "typescript": "~4.1.3" }, "sideEffects": [ - "style/*.css" + "style/*.css", + "style/index.js" ], "jupyterlab": { "extension": true, "outputDir": "jupyterlab_examples_react_widget/labextension" - } + }, + "styleModule": "style/index.js" } \ No newline at end of file diff --git a/react-widget/pyproject.toml b/react-widget/pyproject.toml index c40f3629..18f17a59 100644 --- a/react-widget/pyproject.toml +++ b/react-widget/pyproject.toml @@ -1,3 +1,17 @@ [build-system] -requires = ["jupyter_packaging~=0.7.9", "jupyterlab>=3.0.0rc15,==3.*", "setuptools>=40.8.0", "wheel"] -build-backend = "setuptools.build_meta" +requires = ["jupyter_packaging~=0.10,<2", "jupyterlab~=3.0"] +build-backend = "jupyter_packaging.build_api" + +[tool.jupyter-packaging.options] +skip-if-exists = ["jupyterlab_examples_react_widget/labextension/static/style.js"] +ensured-targets = ["jupyterlab_examples_react_widget/labextension/static/style.js", "jupyterlab_examples_react_widget/labextension/package.json"] + +[tool.jupyter-packaging.builder] +factory = "jupyter_packaging.npm_builder" + +[tool.jupyter-packaging.build-args] +build_cmd = "build:prod" +npm = ["jlpm"] + +[tool.check-manifest] +ignore = ["jupyterlab_examples_react_widget/labextension/**", "yarn.lock", ".*", "package-lock.json"] diff --git a/react-widget/setup.py b/react-widget/setup.py index 931251aa..cf4a915d 100644 --- a/react-widget/setup.py +++ b/react-widget/setup.py @@ -2,79 +2,52 @@ jupyterlab_examples_react_widget setup """ import json -import os +from pathlib import Path -from jupyter_packaging import ( - create_cmdclass, install_npm, ensure_targets, - combine_commands, skip_if_exists -) import setuptools -HERE = os.path.abspath(os.path.dirname(__file__)) +HERE = Path(__file__).parent.resolve() # The name of the project -name="jupyterlab_examples_react_widget" - -# Get our version -with open(os.path.join(HERE, 'package.json')) as f: - version = json.load(f)['version'] +name = "jupyterlab_examples_react_widget" -lab_path = os.path.join(HERE, name, "labextension") +lab_path = (HERE / name / "labextension") # Representative files that should exist after a successful build -jstargets = [ - os.path.join(lab_path, "package.json"), +ensured_targets = [ + str(lab_path / "package.json"), + str(lab_path / "static/style.js") ] -package_data_spec = { - name: [ - "*" - ] -} - labext_name = "@jupyterlab-examples/react-widget" data_files_spec = [ - ("share/jupyter/labextensions/%s" % labext_name, lab_path, "**"), - ("share/jupyter/labextensions/%s" % labext_name, HERE, "install.json"), + ("share/jupyter/labextensions/%s" % labext_name, str(lab_path), "**"), + ("share/jupyter/labextensions/%s" % labext_name, str(HERE), "install.json"), ] -cmdclass = create_cmdclass("jsdeps", - package_data_spec=package_data_spec, - data_files_spec=data_files_spec -) - -js_command = combine_commands( - install_npm(HERE, build_cmd="build:prod", npm=["jlpm"]), - ensure_targets(jstargets), -) - -is_repo = os.path.exists(os.path.join(HERE, ".git")) -if is_repo: - cmdclass["jsdeps"] = js_command -else: - cmdclass["jsdeps"] = skip_if_exists(jstargets, js_command) +long_description = (HERE / "README.md").read_text() -with open("README.md", "r") as fh: - long_description = fh.read() +# Get the package info from package.json +pkg_json = json.loads((HERE / "package.json").read_bytes()) setup_args = dict( name=name, - version=version, - url="https://github.com/jupyterlab/extension-examples.git", - author="Project Jupyter Contributors", - description="Example of using a React Widget in a Jupyterlab extension", - long_description= long_description, + version=pkg_json["version"], + url=pkg_json["homepage"], + author=pkg_json["author"]["name"], + author_email=pkg_json["author"]["email"], + description=pkg_json["description"], + license=pkg_json["license"], + long_description=long_description, long_description_content_type="text/markdown", - cmdclass= cmdclass, packages=setuptools.find_packages(), install_requires=[ - "jupyterlab>=3.0.0rc15,==3.*", + "jupyter_server>=1.6,<2" ], zip_safe=False, include_package_data=True, python_requires=">=3.6", - license="BSD-3-Clause", platforms="Linux, Mac OS X, Windows", keywords=["Jupyter", "JupyterLab", "JupyterLab3"], classifiers=[ @@ -84,10 +57,24 @@ "Programming Language :: Python :: 3.6", "Programming Language :: Python :: 3.7", "Programming Language :: Python :: 3.8", + "Programming Language :: Python :: 3.9", "Framework :: Jupyter", ], ) +try: + from jupyter_packaging import ( + wrap_installers, + npm_builder, + get_data_files + ) + post_develop = npm_builder( + build_cmd="install:extension", source_dir="src", build_dir=lab_path + ) + setup_args['cmdclass'] = wrap_installers(post_develop=post_develop, ensured_targets=ensured_targets) + setup_args['data_files'] = get_data_files(data_files_spec) +except ImportError as e: + pass if __name__ == "__main__": setuptools.setup(**setup_args) diff --git a/react-widget/src/index.ts b/react-widget/src/index.ts index efe11cee..606fdfe2 100644 --- a/react-widget/src/index.ts +++ b/react-widget/src/index.ts @@ -1,6 +1,6 @@ import { JupyterFrontEnd, - JupyterFrontEndPlugin + JupyterFrontEndPlugin, } from '@jupyterlab/application'; import { MainAreaWidget } from '@jupyterlab/apputils'; @@ -32,22 +32,22 @@ const extension: JupyterFrontEndPlugin = { commands.addCommand(command, { caption: 'Create a new React Widget', label: 'React Widget', - icon: args => (args['isPalette'] ? null : reactIcon), + icon: (args) => (args['isPalette'] ? null : reactIcon), execute: () => { const content = new CounterWidget(); const widget = new MainAreaWidget({ content }); widget.title.label = 'React Widget'; widget.title.icon = reactIcon; app.shell.add(widget, 'main'); - } + }, }); if (launcher) { launcher.add({ - command + command, }); } - } + }, }; export default extension; diff --git a/server-extension/.eslintrc.js b/server-extension/.eslintrc.js index 652320e0..c2375786 100644 --- a/server-extension/.eslintrc.js +++ b/server-extension/.eslintrc.js @@ -5,28 +5,34 @@ module.exports = { 'plugin:@typescript-eslint/recommended', 'plugin:jsdoc/recommended', 'plugin:prettier/recommended', - 'plugin:react/recommended' + 'plugin:react/recommended', ], parser: '@typescript-eslint/parser', parserOptions: { project: 'tsconfig.json', - sourceType: 'module' + sourceType: 'module', }, plugins: ['@typescript-eslint', 'jsdoc'], rules: { - '@typescript-eslint/interface-name-prefix': [ + '@typescript-eslint/naming-convention': [ 'error', - { prefixWithI: 'always' } + { + selector: 'interface', + format: ['PascalCase'], + custom: { + regex: '^I[A-Z]', + match: true, + }, + }, ], '@typescript-eslint/no-unused-vars': ['warn', { args: 'none' }], '@typescript-eslint/no-explicit-any': 'off', - '@typescript-eslint/camelcase': 'warn', '@typescript-eslint/no-namespace': 'off', '@typescript-eslint/no-use-before-define': 'off', '@typescript-eslint/quotes': [ 'error', 'single', - { avoidEscape: true, allowTemplateLiterals: false } + { avoidEscape: true, allowTemplateLiterals: false }, ], curly: ['error', 'all'], eqeqeq: 'error', @@ -34,14 +40,14 @@ module.exports = { 'jsdoc/require-property-type': 'off', 'jsdoc/require-returns-type': 'off', 'jsdoc/no-types': 'warn', - 'prefer-arrow-callback': 'error' + 'prefer-arrow-callback': 'error', }, settings: { jsdoc: { - mode: 'typescript' + mode: 'typescript', }, react: { - version: 'detect' - } - } + version: 'detect', + }, + }, }; diff --git a/server-extension/jupyter-config/jlab_ext_example.json b/server-extension/jupyter-config/jlab_ext_example.json new file mode 100644 index 00000000..03f6eef1 --- /dev/null +++ b/server-extension/jupyter-config/jlab_ext_example.json @@ -0,0 +1,7 @@ +{ + "ServerApp": { + "jpserver_extensions": { + "jlab_ext_example": true + } + } +} diff --git a/server-extension/package.json b/server-extension/package.json index 776ec173..a52b9b3d 100644 --- a/server-extension/package.json +++ b/server-extension/package.json @@ -12,10 +12,14 @@ "url": "https://github.com/jupyterlab/extension-examples/issues" }, "license": "BSD-3-Clause", - "author": "Project Jupyter Contributors", + "author": { + "name": "Project Jupyter Contributors", + "email": "" + }, "files": [ "lib/**/*.{d.ts,eot,gif,html,jpg,js,js.map,json,png,svg,woff2,ttf}", - "style/**/*.{css,eot,gif,html,jpg,json,png,svg,woff2,ttf}" + "style/**/*.{css,eot,gif,html,jpg,json,png,svg,woff2,ttf}", + "style/index.js" ], "main": "lib/index.js", "types": "lib/index.d.ts", @@ -30,42 +34,43 @@ "build:labextension": "jupyter labextension build .", "build:labextension:dev": "jupyter labextension build --development True .", "build:lib": "tsc", - "build:prod": "jlpm run build:lib && jlpm run build:labextension", + "build:prod": "jlpm run clean && jlpm run build:lib && jlpm run build:labextension", "clean": "jlpm run clean:lib", "clean:all": "jlpm run clean:lib && jlpm run clean:labextension", "clean:labextension": "rimraf jlab_ext_example/labextension", "clean:lib": "rimraf lib tsconfig.tsbuildinfo", "eslint": "eslint . --ext .ts,.tsx --fix", "eslint:check": "eslint . --ext .ts,.tsx", - "install:extension": "jupyter labextension develop --overwrite .", + "install:extension": "jlpm run build", "prepare": "jlpm run clean && jlpm run build:prod", "watch": "run-p watch:src watch:labextension", "watch:labextension": "jupyter labextension watch .", "watch:src": "tsc -w" }, "dependencies": { - "@jupyterlab/application": "^3.0.0-rc.15", - "@jupyterlab/coreutils": "^5.0.0-rc.15", - "@jupyterlab/launcher": "^3.0.0-rc.15", - "@jupyterlab/services": "^6.0.0-rc.15" + "@jupyterlab/application": "^3.0.10", + "@jupyterlab/coreutils": "^5.0.6", + "@jupyterlab/launcher": "^3.0.8", + "@jupyterlab/services": "^6.0.8" }, "devDependencies": { - "@jupyterlab/builder": "^3.0.0-rc.15", - "@typescript-eslint/eslint-plugin": "^2.27.0", - "@typescript-eslint/parser": "^2.27.0", - "eslint": "^7.5.0", - "eslint-config-prettier": "^6.10.1", - "eslint-plugin-jsdoc": "^22.0.0", - "eslint-plugin-prettier": "^3.1.2", + "@jupyterlab/builder": "^3.0.0", + "@typescript-eslint/eslint-plugin": "^4.8.1", + "@typescript-eslint/parser": "^4.8.1", + "eslint": "^7.14.0", + "eslint-config-prettier": "^6.15.0", + "eslint-plugin-jsdoc": "^34.0.0", + "eslint-plugin-prettier": "^3.1.4", "eslint-plugin-react": "^7.18.3", "mkdirp": "^1.0.3", "npm-run-all": "^4.1.5", - "prettier": "^1.19.0", + "prettier": "^2.1.1", "rimraf": "^3.0.2", "typescript": "~4.1.3" }, "sideEffects": [ - "style/*.css" + "style/*.css", + "style/index.js" ], "jupyterlab": { "discovery": { @@ -80,5 +85,6 @@ }, "extension": true, "outputDir": "jlab_ext_example/labextension" - } + }, + "styleModule": "style/index.js" } \ No newline at end of file diff --git a/server-extension/pyproject.toml b/server-extension/pyproject.toml index c40f3629..7ee29bfe 100644 --- a/server-extension/pyproject.toml +++ b/server-extension/pyproject.toml @@ -1,3 +1,17 @@ [build-system] -requires = ["jupyter_packaging~=0.7.9", "jupyterlab>=3.0.0rc15,==3.*", "setuptools>=40.8.0", "wheel"] -build-backend = "setuptools.build_meta" +requires = ["jupyter_packaging~=0.10,<2", "jupyterlab~=3.0"] +build-backend = "jupyter_packaging.build_api" + +[tool.jupyter-packaging.options] +skip-if-exists = ["jlab_ext_example/labextension/static/style.js"] +ensured-targets = ["jlab_ext_example/labextension/static/style.js", "jlab_ext_example/labextension/package.json"] + +[tool.jupyter-packaging.builder] +factory = "jupyter_packaging.npm_builder" + +[tool.jupyter-packaging.build-args] +build_cmd = "build:prod" +npm = ["jlpm"] + +[tool.check-manifest] +ignore = ["jlab_ext_example/labextension/**", "yarn.lock", ".*", "package-lock.json"] diff --git a/server-extension/setup.py b/server-extension/setup.py index 7dff67e0..180f7ab2 100644 --- a/server-extension/setup.py +++ b/server-extension/setup.py @@ -4,13 +4,6 @@ import json from pathlib import Path -from jupyter_packaging import ( - create_cmdclass, - install_npm, - ensure_targets, - combine_commands, - skip_if_exists, -) import setuptools HERE = Path(__file__).parent.resolve() @@ -18,39 +11,23 @@ # The name of the project name = "jlab_ext_example" -lab_path = HERE / name / "labextension" +lab_path = (HERE / name / "labextension") # Representative files that should exist after a successful build -jstargets = [ +ensured_targets = [ str(lab_path / "package.json"), + str(lab_path / "static/style.js") ] -package_data_spec = {name: ["*"]} - labext_name = "@jupyterlab-examples/server-extension" data_files_spec = [ ("share/jupyter/labextensions/%s" % labext_name, str(lab_path), "**"), - ("share/jupyter/labextensions/%s" % labext_name, str(HERE), "install.json"), - ("etc/jupyter/jupyter_notebook_config.d", "jupyter-config/jupyter_notebook_config.d", "jlab_ext_example.json"), - ("etc/jupyter/jupyter_server_config.d", "jupyter-config/jupyter_server_config.d", "jlab_ext_example.json"), + ("share/jupyter/labextensions/%s" % labext_name, str(HERE), "install.json"),("etc/jupyter/jupyter_server_config.d", + "jupyter-config", "jlab_ext_example.json"), + ] -cmdclass = create_cmdclass( - "jsdeps", package_data_spec=package_data_spec, data_files_spec=data_files_spec -) - -js_command = combine_commands( - install_npm(HERE, build_cmd="build:prod", npm=["jlpm"]), - ensure_targets(jstargets), -) - -is_repo = (HERE / ".git").exists() -if is_repo: - cmdclass["jsdeps"] = js_command -else: - cmdclass["jsdeps"] = skip_if_exists(jstargets, js_command) - long_description = (HERE / "README.md").read_text() # Get the package info from package.json @@ -60,15 +37,15 @@ name=name, version=pkg_json["version"], url=pkg_json["homepage"], - author=pkg_json["author"], + author=pkg_json["author"]["name"], + author_email=pkg_json["author"]["email"], description=pkg_json["description"], license=pkg_json["license"], long_description=long_description, long_description_content_type="text/markdown", - cmdclass=cmdclass, packages=setuptools.find_packages(), install_requires=[ - "jupyterlab~=3.0", + "jupyter_server>=1.6,<2" ], zip_safe=False, include_package_data=True, @@ -87,6 +64,19 @@ ], ) +try: + from jupyter_packaging import ( + wrap_installers, + npm_builder, + get_data_files + ) + post_develop = npm_builder( + build_cmd="install:extension", source_dir="src", build_dir=lab_path + ) + setup_args['cmdclass'] = wrap_installers(post_develop=post_develop, ensured_targets=ensured_targets) + setup_args['data_files'] = get_data_files(data_files_spec) +except ImportError as e: + pass if __name__ == "__main__": setuptools.setup(**setup_args) diff --git a/server-extension/src/index.ts b/server-extension/src/index.ts index 5883e09d..6552ee9a 100644 --- a/server-extension/src/index.ts +++ b/server-extension/src/index.ts @@ -1,6 +1,6 @@ import { JupyterFrontEnd, - JupyterFrontEndPlugin + JupyterFrontEndPlugin, } from '@jupyterlab/application'; import { ICommandPalette, IFrame } from '@jupyterlab/apputils'; @@ -46,7 +46,7 @@ const extension: JupyterFrontEndPlugin = { try { const reply = await requestAPI('hello', { body: JSON.stringify(dataToSend), - method: 'POST' + method: 'POST', }); console.log(reply); } catch (reason) { @@ -65,7 +65,7 @@ const extension: JupyterFrontEndPlugin = { execute: () => { const widget = new IFrameWidget(); shell.add(widget, 'main'); - } + }, }); palette.addItem({ command, category: category }); @@ -74,10 +74,10 @@ const extension: JupyterFrontEndPlugin = { // Add launcher launcher.add({ command: command, - category: category + category: category, }); } - } + }, }; export default extension; diff --git a/settings/.eslintrc.js b/settings/.eslintrc.js index 652320e0..c2375786 100644 --- a/settings/.eslintrc.js +++ b/settings/.eslintrc.js @@ -5,28 +5,34 @@ module.exports = { 'plugin:@typescript-eslint/recommended', 'plugin:jsdoc/recommended', 'plugin:prettier/recommended', - 'plugin:react/recommended' + 'plugin:react/recommended', ], parser: '@typescript-eslint/parser', parserOptions: { project: 'tsconfig.json', - sourceType: 'module' + sourceType: 'module', }, plugins: ['@typescript-eslint', 'jsdoc'], rules: { - '@typescript-eslint/interface-name-prefix': [ + '@typescript-eslint/naming-convention': [ 'error', - { prefixWithI: 'always' } + { + selector: 'interface', + format: ['PascalCase'], + custom: { + regex: '^I[A-Z]', + match: true, + }, + }, ], '@typescript-eslint/no-unused-vars': ['warn', { args: 'none' }], '@typescript-eslint/no-explicit-any': 'off', - '@typescript-eslint/camelcase': 'warn', '@typescript-eslint/no-namespace': 'off', '@typescript-eslint/no-use-before-define': 'off', '@typescript-eslint/quotes': [ 'error', 'single', - { avoidEscape: true, allowTemplateLiterals: false } + { avoidEscape: true, allowTemplateLiterals: false }, ], curly: ['error', 'all'], eqeqeq: 'error', @@ -34,14 +40,14 @@ module.exports = { 'jsdoc/require-property-type': 'off', 'jsdoc/require-returns-type': 'off', 'jsdoc/no-types': 'warn', - 'prefer-arrow-callback': 'error' + 'prefer-arrow-callback': 'error', }, settings: { jsdoc: { - mode: 'typescript' + mode: 'typescript', }, react: { - version: 'detect' - } - } + version: 'detect', + }, + }, }; diff --git a/settings/package.json b/settings/package.json index cdbb7c96..77336923 100644 --- a/settings/package.json +++ b/settings/package.json @@ -12,11 +12,15 @@ "url": "https://github.com/jupyterlab/extension-examples/issues" }, "license": "BSD-3-Clause", - "author": "Project Jupyter Contributors", + "author": { + "name": "Project Jupyter Contributors", + "email": "" + }, "files": [ "lib/**/*.{d.ts,eot,gif,html,jpg,js,js.map,json,png,svg,woff2,ttf}", "schema/**/*.json", - "style/**/*.{css,eot,gif,html,jpg,json,png,svg,woff2,ttf}" + "style/**/*.{css,eot,gif,html,jpg,json,png,svg,woff2,ttf}", + "style/index.js" ], "main": "lib/index.js", "types": "lib/index.d.ts", @@ -31,45 +35,47 @@ "build:labextension": "jupyter labextension build .", "build:labextension:dev": "jupyter labextension build --development True .", "build:lib": "tsc", - "build:prod": "jlpm run build:lib && jlpm run build:labextension", + "build:prod": "jlpm run clean && jlpm run build:lib && jlpm run build:labextension", "clean": "jlpm run clean:lib", "clean:all": "jlpm run clean:lib && jlpm run clean:labextension", "clean:labextension": "rimraf jupyterlab_examples_settings/labextension", "clean:lib": "rimraf lib tsconfig.tsbuildinfo", "eslint": "eslint . --ext .ts,.tsx --fix", "eslint:check": "eslint . --ext .ts,.tsx", - "install:extension": "jupyter labextension develop --overwrite .", + "install:extension": "jlpm run build", "prepare": "jlpm run clean && jlpm run build:prod", "watch": "run-p watch:src watch:labextension", "watch:labextension": "jupyter labextension watch .", "watch:src": "tsc -w" }, "dependencies": { - "@jupyterlab/application": "^3.0.0-rc.15", - "@jupyterlab/mainmenu": "^3.0.0-rc.15", - "@jupyterlab/settingregistry": "^3.0.0-rc.15", + "@jupyterlab/application": "^3.0.10", + "@jupyterlab/mainmenu": "^3.0.8", + "@jupyterlab/settingregistry": "^3.0.5", "@lumino/widgets": "^1.16.1" }, "devDependencies": { - "@jupyterlab/builder": "^3.0.0-rc.15", - "@typescript-eslint/eslint-plugin": "^2.27.0", - "@typescript-eslint/parser": "^2.27.0", - "eslint": "^7.5.0", - "eslint-config-prettier": "^6.10.1", - "eslint-plugin-jsdoc": "^22.0.0", - "eslint-plugin-prettier": "^3.1.2", + "@jupyterlab/builder": "^3.0.0", + "@typescript-eslint/eslint-plugin": "^4.8.1", + "@typescript-eslint/parser": "^4.8.1", + "eslint": "^7.14.0", + "eslint-config-prettier": "^6.15.0", + "eslint-plugin-jsdoc": "^34.0.0", + "eslint-plugin-prettier": "^3.1.4", "eslint-plugin-react": "^7.18.3", "npm-run-all": "^4.1.5", - "prettier": "^1.19.0", + "prettier": "^2.1.1", "rimraf": "^3.0.2", "typescript": "~4.1.3" }, "sideEffects": [ - "style/*.css" + "style/*.css", + "style/index.js" ], "jupyterlab": { "extension": true, "schemaDir": "schema", "outputDir": "jupyterlab_examples_settings/labextension" - } + }, + "styleModule": "style/index.js" } \ No newline at end of file diff --git a/settings/pyproject.toml b/settings/pyproject.toml index c40f3629..9ddbf0b3 100644 --- a/settings/pyproject.toml +++ b/settings/pyproject.toml @@ -1,3 +1,17 @@ [build-system] -requires = ["jupyter_packaging~=0.7.9", "jupyterlab>=3.0.0rc15,==3.*", "setuptools>=40.8.0", "wheel"] -build-backend = "setuptools.build_meta" +requires = ["jupyter_packaging~=0.10,<2", "jupyterlab~=3.0"] +build-backend = "jupyter_packaging.build_api" + +[tool.jupyter-packaging.options] +skip-if-exists = ["jupyterlab_examples_settings/labextension/static/style.js"] +ensured-targets = ["jupyterlab_examples_settings/labextension/static/style.js", "jupyterlab_examples_settings/labextension/package.json"] + +[tool.jupyter-packaging.builder] +factory = "jupyter_packaging.npm_builder" + +[tool.jupyter-packaging.build-args] +build_cmd = "build:prod" +npm = ["jlpm"] + +[tool.check-manifest] +ignore = ["jupyterlab_examples_settings/labextension/**", "yarn.lock", ".*", "package-lock.json"] diff --git a/settings/setup.py b/settings/setup.py index a3ed2a73..c0bdfeb4 100644 --- a/settings/setup.py +++ b/settings/setup.py @@ -2,79 +2,52 @@ jupyterlab_examples_settings setup """ import json -import os +from pathlib import Path -from jupyter_packaging import ( - create_cmdclass, install_npm, ensure_targets, - combine_commands, skip_if_exists -) import setuptools -HERE = os.path.abspath(os.path.dirname(__file__)) +HERE = Path(__file__).parent.resolve() # The name of the project -name="jupyterlab_examples_settings" - -# Get our version -with open(os.path.join(HERE, 'package.json')) as f: - version = json.load(f)['version'] +name = "jupyterlab_examples_settings" -lab_path = os.path.join(HERE, name, "labextension") +lab_path = (HERE / name / "labextension") # Representative files that should exist after a successful build -jstargets = [ - os.path.join(lab_path, "package.json"), +ensured_targets = [ + str(lab_path / "package.json"), + str(lab_path / "static/style.js") ] -package_data_spec = { - name: [ - "*" - ] -} - labext_name = "@jupyterlab-examples/settings" data_files_spec = [ - ("share/jupyter/labextensions/%s" % labext_name, lab_path, "**"), - ("share/jupyter/labextensions/%s" % labext_name, HERE, "install.json"), + ("share/jupyter/labextensions/%s" % labext_name, str(lab_path), "**"), + ("share/jupyter/labextensions/%s" % labext_name, str(HERE), "install.json"), ] -cmdclass = create_cmdclass("jsdeps", - package_data_spec=package_data_spec, - data_files_spec=data_files_spec -) - -js_command = combine_commands( - install_npm(HERE, build_cmd="build:prod", npm=["jlpm"]), - ensure_targets(jstargets), -) - -is_repo = os.path.exists(os.path.join(HERE, ".git")) -if is_repo: - cmdclass["jsdeps"] = js_command -else: - cmdclass["jsdeps"] = skip_if_exists(jstargets, js_command) +long_description = (HERE / "README.md").read_text() -with open("README.md", "r") as fh: - long_description = fh.read() +# Get the package info from package.json +pkg_json = json.loads((HERE / "package.json").read_bytes()) setup_args = dict( name=name, - version=version, - url="https://github.com/jupyterlab/extension-examples.git", - author="Project Jupyter Contributors", - description="A JupyterLab minimal example using settings.", - long_description= long_description, + version=pkg_json["version"], + url=pkg_json["homepage"], + author=pkg_json["author"]["name"], + author_email=pkg_json["author"]["email"], + description=pkg_json["description"], + license=pkg_json["license"], + long_description=long_description, long_description_content_type="text/markdown", - cmdclass= cmdclass, packages=setuptools.find_packages(), install_requires=[ - "jupyterlab>=3.0.0rc15,==3.*", + "jupyter_server>=1.6,<2" ], zip_safe=False, include_package_data=True, python_requires=">=3.6", - license="BSD-3-Clause", platforms="Linux, Mac OS X, Windows", keywords=["Jupyter", "JupyterLab", "JupyterLab3"], classifiers=[ @@ -84,10 +57,24 @@ "Programming Language :: Python :: 3.6", "Programming Language :: Python :: 3.7", "Programming Language :: Python :: 3.8", + "Programming Language :: Python :: 3.9", "Framework :: Jupyter", ], ) +try: + from jupyter_packaging import ( + wrap_installers, + npm_builder, + get_data_files + ) + post_develop = npm_builder( + build_cmd="install:extension", source_dir="src", build_dir=lab_path + ) + setup_args['cmdclass'] = wrap_installers(post_develop=post_develop, ensured_targets=ensured_targets) + setup_args['data_files'] = get_data_files(data_files_spec) +except ImportError as e: + pass if __name__ == "__main__": setuptools.setup(**setup_args) diff --git a/settings/src/index.ts b/settings/src/index.ts index 12fff8f0..41d83854 100644 --- a/settings/src/index.ts +++ b/settings/src/index.ts @@ -1,6 +1,6 @@ import { JupyterFrontEnd, - JupyterFrontEndPlugin + JupyterFrontEndPlugin, } from '@jupyterlab/application'; import { ISettingRegistry } from '@jupyterlab/settingregistry'; @@ -61,7 +61,7 @@ const extension: JupyterFrontEndPlugin = { // Programmatically change a setting Promise.all([ setting.set('flag', !flag), - setting.set('limit', limit + 1) + setting.set('limit', limit + 1), ]) .then(() => { const newLimit = setting.get('limit').composite as number; @@ -70,12 +70,12 @@ const extension: JupyterFrontEndPlugin = { `Settings Example extension: Limit is set to '${newLimit}' and flag to '${newFlag}'` ); }) - .catch(reason => { + .catch((reason) => { console.error( `Something went wrong when changing the settings.\n${reason}` ); }); - } + }, }); // Create a menu @@ -85,15 +85,15 @@ const extension: JupyterFrontEndPlugin = { // Add the command to the menu settingsMenu.addItem({ - command: COMMAND_ID + command: COMMAND_ID, }); }) - .catch(reason => { + .catch((reason) => { console.error( `Something went wrong when reading the settings.\n${reason}` ); }); - } + }, }; export default extension; diff --git a/signals/.eslintrc.js b/signals/.eslintrc.js index 652320e0..c2375786 100644 --- a/signals/.eslintrc.js +++ b/signals/.eslintrc.js @@ -5,28 +5,34 @@ module.exports = { 'plugin:@typescript-eslint/recommended', 'plugin:jsdoc/recommended', 'plugin:prettier/recommended', - 'plugin:react/recommended' + 'plugin:react/recommended', ], parser: '@typescript-eslint/parser', parserOptions: { project: 'tsconfig.json', - sourceType: 'module' + sourceType: 'module', }, plugins: ['@typescript-eslint', 'jsdoc'], rules: { - '@typescript-eslint/interface-name-prefix': [ + '@typescript-eslint/naming-convention': [ 'error', - { prefixWithI: 'always' } + { + selector: 'interface', + format: ['PascalCase'], + custom: { + regex: '^I[A-Z]', + match: true, + }, + }, ], '@typescript-eslint/no-unused-vars': ['warn', { args: 'none' }], '@typescript-eslint/no-explicit-any': 'off', - '@typescript-eslint/camelcase': 'warn', '@typescript-eslint/no-namespace': 'off', '@typescript-eslint/no-use-before-define': 'off', '@typescript-eslint/quotes': [ 'error', 'single', - { avoidEscape: true, allowTemplateLiterals: false } + { avoidEscape: true, allowTemplateLiterals: false }, ], curly: ['error', 'all'], eqeqeq: 'error', @@ -34,14 +40,14 @@ module.exports = { 'jsdoc/require-property-type': 'off', 'jsdoc/require-returns-type': 'off', 'jsdoc/no-types': 'warn', - 'prefer-arrow-callback': 'error' + 'prefer-arrow-callback': 'error', }, settings: { jsdoc: { - mode: 'typescript' + mode: 'typescript', }, react: { - version: 'detect' - } - } + version: 'detect', + }, + }, }; diff --git a/signals/package.json b/signals/package.json index f5d9361a..fe3c9abc 100644 --- a/signals/package.json +++ b/signals/package.json @@ -12,10 +12,14 @@ "url": "https://github.com/jupyterlab/extension-examples/issues" }, "license": "BSD-3-Clause", - "author": "Project Jupyter Contributors", + "author": { + "name": "Project Jupyter Contributors", + "email": "" + }, "files": [ "lib/**/*.{d.ts,eot,gif,html,jpg,js,js.map,json,png,svg,woff2,ttf}", - "style/**/*.{css,eot,gif,html,jpg,json,png,svg,woff2,ttf}" + "style/**/*.{css,eot,gif,html,jpg,json,png,svg,woff2,ttf}", + "style/index.js" ], "main": "lib/index.js", "types": "lib/index.d.ts", @@ -30,50 +34,53 @@ "build:labextension": "jupyter labextension build .", "build:labextension:dev": "jupyter labextension build --development True .", "build:lib": "tsc", - "build:prod": "jlpm run build:lib && jlpm run build:labextension", + "build:prod": "jlpm run clean && jlpm run build:lib && jlpm run build:labextension", "clean": "jlpm run clean:lib", "clean:all": "jlpm run clean:lib && jlpm run clean:labextension", "clean:labextension": "rimraf jupyterlab_examples_signals/labextension", "clean:lib": "rimraf lib tsconfig.tsbuildinfo", "eslint": "eslint . --ext .ts,.tsx --fix", "eslint:check": "eslint . --ext .ts,.tsx", - "install:extension": "jupyter labextension develop --overwrite .", + "install:extension": "jlpm run build", "prepare": "jlpm run clean && jlpm run build:prod", "watch": "run-p watch:src watch:labextension", "watch:labextension": "jupyter labextension watch .", "watch:src": "tsc -w" }, "dependencies": { - "@jupyterlab/application": "^3.0.3", - "@jupyterlab/apputils": "^3.0.3", - "@jupyterlab/launcher": "^3.0.3", - "@jupyterlab/mainmenu": "^3.0.3", - "@jupyterlab/translation": "^3.0.3", + "@jupyterlab/application": "^3.0.10", + "@jupyterlab/apputils": "^3.0.8", + "@jupyterlab/launcher": "^3.0.8", + "@jupyterlab/mainmenu": "^3.0.8", + "@jupyterlab/translation": "^3.0.8", "@lumino/algorithm": "^1.3.3", "@lumino/coreutils": "^1.5.3", "@lumino/datagrid": "^0.3.1", "@lumino/disposable": "^1.4.3", - "@lumino/signaling": "^1.3.3", + "@lumino/signaling": "^1.4.3", "@lumino/widgets": "^1.16.1" }, "devDependencies": { - "@jupyterlab/builder": "^3.0.0-rc.15", - "@typescript-eslint/eslint-plugin": "^2.27.0", - "@typescript-eslint/parser": "^2.27.0", - "eslint": "^7.5.0", - "eslint-config-prettier": "^6.10.1", - "eslint-plugin-jsdoc": "^22.0.0", - "eslint-plugin-prettier": "^3.1.2", + "@jupyterlab/builder": "^3.0.0", + "@typescript-eslint/eslint-plugin": "^4.8.1", + "@typescript-eslint/parser": "^4.8.1", + "eslint": "^7.14.0", + "eslint-config-prettier": "^6.15.0", + "eslint-plugin-jsdoc": "^34.0.0", + "eslint-plugin-prettier": "^3.1.4", "eslint-plugin-react": "^7.18.3", "npm-run-all": "^4.1.5", + "prettier": "^2.1.1", "rimraf": "^3.0.2", "typescript": "~4.1.3" }, "sideEffects": [ - "style/*.css" + "style/*.css", + "style/index.js" ], "jupyterlab": { "extension": true, "outputDir": "jupyterlab_examples_signals/labextension" - } -} + }, + "styleModule": "style/index.js" +} \ No newline at end of file diff --git a/signals/pyproject.toml b/signals/pyproject.toml index c40f3629..02924314 100644 --- a/signals/pyproject.toml +++ b/signals/pyproject.toml @@ -1,3 +1,17 @@ [build-system] -requires = ["jupyter_packaging~=0.7.9", "jupyterlab>=3.0.0rc15,==3.*", "setuptools>=40.8.0", "wheel"] -build-backend = "setuptools.build_meta" +requires = ["jupyter_packaging~=0.10,<2", "jupyterlab~=3.0"] +build-backend = "jupyter_packaging.build_api" + +[tool.jupyter-packaging.options] +skip-if-exists = ["jupyterlab_examples_signals/labextension/static/style.js"] +ensured-targets = ["jupyterlab_examples_signals/labextension/static/style.js", "jupyterlab_examples_signals/labextension/package.json"] + +[tool.jupyter-packaging.builder] +factory = "jupyter_packaging.npm_builder" + +[tool.jupyter-packaging.build-args] +build_cmd = "build:prod" +npm = ["jlpm"] + +[tool.check-manifest] +ignore = ["jupyterlab_examples_signals/labextension/**", "yarn.lock", ".*", "package-lock.json"] diff --git a/signals/setup.py b/signals/setup.py index d7381cf3..b159c8eb 100644 --- a/signals/setup.py +++ b/signals/setup.py @@ -2,79 +2,52 @@ jupyterlab_examples_signals setup """ import json -import os +from pathlib import Path -from jupyter_packaging import ( - create_cmdclass, install_npm, ensure_targets, - combine_commands, skip_if_exists -) import setuptools -HERE = os.path.abspath(os.path.dirname(__file__)) +HERE = Path(__file__).parent.resolve() # The name of the project -name="jupyterlab_examples_signals" - -# Get our version -with open(os.path.join(HERE, 'package.json')) as f: - version = json.load(f)['version'] +name = "jupyterlab_examples_signals" -lab_path = os.path.join(HERE, name, "labextension") +lab_path = (HERE / name / "labextension") # Representative files that should exist after a successful build -jstargets = [ - os.path.join(lab_path, "package.json"), +ensured_targets = [ + str(lab_path / "package.json"), + str(lab_path / "static/style.js") ] -package_data_spec = { - name: [ - "*" - ] -} - labext_name = "@jupyterlab-examples/signals" data_files_spec = [ - ("share/jupyter/labextensions/%s" % labext_name, lab_path, "**"), - ("share/jupyter/labextensions/%s" % labext_name, HERE, "install.json"), + ("share/jupyter/labextensions/%s" % labext_name, str(lab_path), "**"), + ("share/jupyter/labextensions/%s" % labext_name, str(HERE), "install.json"), ] -cmdclass = create_cmdclass("jsdeps", - package_data_spec=package_data_spec, - data_files_spec=data_files_spec -) - -js_command = combine_commands( - install_npm(HERE, build_cmd="build:prod", npm=["jlpm"]), - ensure_targets(jstargets), -) - -is_repo = os.path.exists(os.path.join(HERE, ".git")) -if is_repo: - cmdclass["jsdeps"] = js_command -else: - cmdclass["jsdeps"] = skip_if_exists(jstargets, js_command) +long_description = (HERE / "README.md").read_text() -with open("README.md", "r") as fh: - long_description = fh.read() +# Get the package info from package.json +pkg_json = json.loads((HERE / "package.json").read_bytes()) setup_args = dict( name=name, - version=version, - url="https://github.com/jupyterlab/extension-examples.git", - author="Project Jupyter Contributors", - description="minimal lab example", - long_description= long_description, + version=pkg_json["version"], + url=pkg_json["homepage"], + author=pkg_json["author"]["name"], + author_email=pkg_json["author"]["email"], + description=pkg_json["description"], + license=pkg_json["license"], + long_description=long_description, long_description_content_type="text/markdown", - cmdclass= cmdclass, packages=setuptools.find_packages(), install_requires=[ - "jupyterlab>=3.0.0rc15,==3.*", + "jupyter_server>=1.6,<2" ], zip_safe=False, include_package_data=True, python_requires=">=3.6", - license="BSD-3-Clause", platforms="Linux, Mac OS X, Windows", keywords=["Jupyter", "JupyterLab", "JupyterLab3"], classifiers=[ @@ -84,10 +57,24 @@ "Programming Language :: Python :: 3.6", "Programming Language :: Python :: 3.7", "Programming Language :: Python :: 3.8", + "Programming Language :: Python :: 3.9", "Framework :: Jupyter", ], ) +try: + from jupyter_packaging import ( + wrap_installers, + npm_builder, + get_data_files + ) + post_develop = npm_builder( + build_cmd="install:extension", source_dir="src", build_dir=lab_path + ) + setup_args['cmdclass'] = wrap_installers(post_develop=post_develop, ensured_targets=ensured_targets) + setup_args['data_files'] = get_data_files(data_files_spec) +except ImportError as e: + pass if __name__ == "__main__": setuptools.setup(**setup_args) diff --git a/signals/src/button.ts b/signals/src/button.ts index addb47cf..f19ab1ab 100644 --- a/signals/src/button.ts +++ b/signals/src/button.ts @@ -26,7 +26,7 @@ export class ButtonWidget extends Widget { } private _count: ICount = { - clickCount: 0 + clickCount: 0, }; private _stateChanged = new Signal(this); diff --git a/signals/src/index.ts b/signals/src/index.ts index 2ff2dd17..20ebc6de 100644 --- a/signals/src/index.ts +++ b/signals/src/index.ts @@ -1,6 +1,6 @@ import { JupyterFrontEnd, - JupyterFrontEndPlugin + JupyterFrontEndPlugin, } from '@jupyterlab/application'; import { ICommandPalette } from '@jupyterlab/apputils'; @@ -30,7 +30,7 @@ const extension: JupyterFrontEndPlugin = { autoStart: true, optional: [ILauncher], requires: [ICommandPalette, IMainMenu, ITranslator], - activate + activate, }; /** @@ -58,7 +58,7 @@ function activate( if (launcher) { launcher.add({ command: CommandIDs.create, - category: category + category: category, }); } @@ -85,7 +85,7 @@ function activate( commands.addCommand(CommandIDs.create, { label: trans.__('Open the Signal Example Panel'), caption: trans.__('Open the Signal Example Panel'), - execute: createPanel + execute: createPanel, }); // Add items in command palette and menu diff --git a/signals/src/panel.ts b/signals/src/panel.ts index c38d361f..b9fd669a 100644 --- a/signals/src/panel.ts +++ b/signals/src/panel.ts @@ -1,7 +1,7 @@ import { ITranslator, nullTranslator, - TranslationBundle + TranslationBundle, } from '@jupyterlab/translation'; import { Panel } from '@lumino/widgets'; diff --git a/state/.eslintrc.js b/state/.eslintrc.js index 652320e0..c2375786 100644 --- a/state/.eslintrc.js +++ b/state/.eslintrc.js @@ -5,28 +5,34 @@ module.exports = { 'plugin:@typescript-eslint/recommended', 'plugin:jsdoc/recommended', 'plugin:prettier/recommended', - 'plugin:react/recommended' + 'plugin:react/recommended', ], parser: '@typescript-eslint/parser', parserOptions: { project: 'tsconfig.json', - sourceType: 'module' + sourceType: 'module', }, plugins: ['@typescript-eslint', 'jsdoc'], rules: { - '@typescript-eslint/interface-name-prefix': [ + '@typescript-eslint/naming-convention': [ 'error', - { prefixWithI: 'always' } + { + selector: 'interface', + format: ['PascalCase'], + custom: { + regex: '^I[A-Z]', + match: true, + }, + }, ], '@typescript-eslint/no-unused-vars': ['warn', { args: 'none' }], '@typescript-eslint/no-explicit-any': 'off', - '@typescript-eslint/camelcase': 'warn', '@typescript-eslint/no-namespace': 'off', '@typescript-eslint/no-use-before-define': 'off', '@typescript-eslint/quotes': [ 'error', 'single', - { avoidEscape: true, allowTemplateLiterals: false } + { avoidEscape: true, allowTemplateLiterals: false }, ], curly: ['error', 'all'], eqeqeq: 'error', @@ -34,14 +40,14 @@ module.exports = { 'jsdoc/require-property-type': 'off', 'jsdoc/require-returns-type': 'off', 'jsdoc/no-types': 'warn', - 'prefer-arrow-callback': 'error' + 'prefer-arrow-callback': 'error', }, settings: { jsdoc: { - mode: 'typescript' + mode: 'typescript', }, react: { - version: 'detect' - } - } + version: 'detect', + }, + }, }; diff --git a/state/README.md b/state/README.md index 579c3f65..def70247 100644 --- a/state/README.md +++ b/state/README.md @@ -40,7 +40,7 @@ const extension: JupyterFrontEndPlugin = { app.restored // Get the state object .then(() => state.fetch(PLUGIN_ID)) - .then(value => { + .then((value) => { // Get the option attribute if (value) { option = (value as ReadonlyJSONObject)['option'] as string; @@ -51,10 +51,10 @@ const extension: JupyterFrontEndPlugin = { return InputDialog.getItem({ title: 'Pick an option to persist by the State Example extension', items: options, - current: Math.max(0, options.indexOf(option)) + current: Math.max(0, options.indexOf(option)), }); }) - .then(result => { + .then((result) => { // If the user click on the accept button of the dialog if (result.button.accept) { // Get the user option @@ -63,12 +63,12 @@ const extension: JupyterFrontEndPlugin = { return state.save(PLUGIN_ID, { option }); } }) - .catch(reason => { + .catch((reason) => { console.error( `Something went wrong when reading the state for ${PLUGIN_ID}.\n${reason}` ); }); - } + }, }; ``` @@ -121,7 +121,7 @@ an item list with the default option being stored as a state variable. return InputDialog.getItem({ title: 'Pick an option to persist by the State Example extension', items: options, - current: Math.max(0, options.indexOf(option)) + current: Math.max(0, options.indexOf(option)), }); ``` diff --git a/state/package.json b/state/package.json index 924260ca..1352a3a3 100644 --- a/state/package.json +++ b/state/package.json @@ -12,10 +12,14 @@ "url": "https://github.com/jupyterlab/extension-examples/issues" }, "license": "BSD-3-Clause", - "author": "Project Jupyter Contributors", + "author": { + "name": "Project Jupyter Contributors", + "email": "" + }, "files": [ "lib/**/*.{d.ts,eot,gif,html,jpg,js,js.map,json,png,svg,woff2,ttf}", - "style/**/*.{css,eot,gif,html,jpg,json,png,svg,woff2,ttf}" + "style/**/*.{css,eot,gif,html,jpg,json,png,svg,woff2,ttf}", + "style/index.js" ], "main": "lib/index.js", "types": "lib/index.d.ts", @@ -30,44 +34,46 @@ "build:labextension": "jupyter labextension build .", "build:labextension:dev": "jupyter labextension build --development True .", "build:lib": "tsc", - "build:prod": "jlpm run build:lib && jlpm run build:labextension", + "build:prod": "jlpm run clean && jlpm run build:lib && jlpm run build:labextension", "clean": "jlpm run clean:lib", "clean:all": "jlpm run clean:lib && jlpm run clean:labextension", "clean:labextension": "rimraf jupyterlab_examples_state/labextension", "clean:lib": "rimraf lib tsconfig.tsbuildinfo", "eslint": "eslint . --ext .ts,.tsx --fix", "eslint:check": "eslint . --ext .ts,.tsx", - "install:extension": "jupyter labextension develop --overwrite .", + "install:extension": "jlpm run build", "prepare": "jlpm run clean && jlpm run build:prod", "watch": "run-p watch:src watch:labextension", "watch:labextension": "jupyter labextension watch .", "watch:src": "tsc -w" }, "dependencies": { - "@jupyterlab/application": "^3.0.0-rc.15", - "@jupyterlab/apputils": "^3.0.0-rc.15", - "@jupyterlab/statedb": "^3.0.0-rc.15", + "@jupyterlab/application": "^3.0.10", + "@jupyterlab/apputils": "^3.0.8", + "@jupyterlab/statedb": "^3.0.5", "@lumino/coreutils": "^1.5.3" }, "devDependencies": { - "@jupyterlab/builder": "^3.0.0-rc.15", - "@typescript-eslint/eslint-plugin": "^2.27.0", - "@typescript-eslint/parser": "^2.27.0", - "eslint": "^7.5.0", - "eslint-config-prettier": "^6.10.1", - "eslint-plugin-jsdoc": "^22.0.0", - "eslint-plugin-prettier": "^3.1.2", + "@jupyterlab/builder": "^3.0.0", + "@typescript-eslint/eslint-plugin": "^4.8.1", + "@typescript-eslint/parser": "^4.8.1", + "eslint": "^7.14.0", + "eslint-config-prettier": "^6.15.0", + "eslint-plugin-jsdoc": "^34.0.0", + "eslint-plugin-prettier": "^3.1.4", "eslint-plugin-react": "^7.18.3", "npm-run-all": "^4.1.5", - "prettier": "^1.19.0", + "prettier": "^2.1.1", "rimraf": "^3.0.2", "typescript": "~4.1.3" }, "sideEffects": [ - "style/*.css" + "style/*.css", + "style/index.js" ], "jupyterlab": { "extension": true, "outputDir": "jupyterlab_examples_state/labextension" - } + }, + "styleModule": "style/index.js" } \ No newline at end of file diff --git a/state/pyproject.toml b/state/pyproject.toml index c40f3629..e147eb99 100644 --- a/state/pyproject.toml +++ b/state/pyproject.toml @@ -1,3 +1,17 @@ [build-system] -requires = ["jupyter_packaging~=0.7.9", "jupyterlab>=3.0.0rc15,==3.*", "setuptools>=40.8.0", "wheel"] -build-backend = "setuptools.build_meta" +requires = ["jupyter_packaging~=0.10,<2", "jupyterlab~=3.0"] +build-backend = "jupyter_packaging.build_api" + +[tool.jupyter-packaging.options] +skip-if-exists = ["jupyterlab_examples_state/labextension/static/style.js"] +ensured-targets = ["jupyterlab_examples_state/labextension/static/style.js", "jupyterlab_examples_state/labextension/package.json"] + +[tool.jupyter-packaging.builder] +factory = "jupyter_packaging.npm_builder" + +[tool.jupyter-packaging.build-args] +build_cmd = "build:prod" +npm = ["jlpm"] + +[tool.check-manifest] +ignore = ["jupyterlab_examples_state/labextension/**", "yarn.lock", ".*", "package-lock.json"] diff --git a/state/setup.py b/state/setup.py index 7a010652..92e1ee29 100644 --- a/state/setup.py +++ b/state/setup.py @@ -2,79 +2,52 @@ jupyterlab_examples_state setup """ import json -import os +from pathlib import Path -from jupyter_packaging import ( - create_cmdclass, install_npm, ensure_targets, - combine_commands, skip_if_exists -) import setuptools -HERE = os.path.abspath(os.path.dirname(__file__)) +HERE = Path(__file__).parent.resolve() # The name of the project -name="jupyterlab_examples_state" - -# Get our version -with open(os.path.join(HERE, 'package.json')) as f: - version = json.load(f)['version'] +name = "jupyterlab_examples_state" -lab_path = os.path.join(HERE, name, "labextension") +lab_path = (HERE / name / "labextension") # Representative files that should exist after a successful build -jstargets = [ - os.path.join(lab_path, "package.json"), +ensured_targets = [ + str(lab_path / "package.json"), + str(lab_path / "static/style.js") ] -package_data_spec = { - name: [ - "*" - ] -} - labext_name = "@jupyterlab-examples/state" data_files_spec = [ - ("share/jupyter/labextensions/%s" % labext_name, lab_path, "**"), - ("share/jupyter/labextensions/%s" % labext_name, HERE, "install.json"), + ("share/jupyter/labextensions/%s" % labext_name, str(lab_path), "**"), + ("share/jupyter/labextensions/%s" % labext_name, str(HERE), "install.json"), ] -cmdclass = create_cmdclass("jsdeps", - package_data_spec=package_data_spec, - data_files_spec=data_files_spec -) - -js_command = combine_commands( - install_npm(HERE, build_cmd="build:prod", npm=["jlpm"]), - ensure_targets(jstargets), -) - -is_repo = os.path.exists(os.path.join(HERE, ".git")) -if is_repo: - cmdclass["jsdeps"] = js_command -else: - cmdclass["jsdeps"] = skip_if_exists(jstargets, js_command) +long_description = (HERE / "README.md").read_text() -with open("README.md", "r") as fh: - long_description = fh.read() +# Get the package info from package.json +pkg_json = json.loads((HERE / "package.json").read_bytes()) setup_args = dict( name=name, - version=version, - url="https://github.com/jupyterlab/extension-examples.git", - author="Project Jupyter Contributors", - description="A minimal JupyterLab example using state database (DB).", - long_description= long_description, + version=pkg_json["version"], + url=pkg_json["homepage"], + author=pkg_json["author"]["name"], + author_email=pkg_json["author"]["email"], + description=pkg_json["description"], + license=pkg_json["license"], + long_description=long_description, long_description_content_type="text/markdown", - cmdclass= cmdclass, packages=setuptools.find_packages(), install_requires=[ - "jupyterlab>=3.0.0rc15,==3.*", + "jupyter_server>=1.6,<2" ], zip_safe=False, include_package_data=True, python_requires=">=3.6", - license="BSD-3-Clause", platforms="Linux, Mac OS X, Windows", keywords=["Jupyter", "JupyterLab", "JupyterLab3"], classifiers=[ @@ -84,10 +57,24 @@ "Programming Language :: Python :: 3.6", "Programming Language :: Python :: 3.7", "Programming Language :: Python :: 3.8", + "Programming Language :: Python :: 3.9", "Framework :: Jupyter", ], ) +try: + from jupyter_packaging import ( + wrap_installers, + npm_builder, + get_data_files + ) + post_develop = npm_builder( + build_cmd="install:extension", source_dir="src", build_dir=lab_path + ) + setup_args['cmdclass'] = wrap_installers(post_develop=post_develop, ensured_targets=ensured_targets) + setup_args['data_files'] = get_data_files(data_files_spec) +except ImportError as e: + pass if __name__ == "__main__": setuptools.setup(**setup_args) diff --git a/state/src/index.ts b/state/src/index.ts index a713b5d7..de5ab8e1 100644 --- a/state/src/index.ts +++ b/state/src/index.ts @@ -1,6 +1,6 @@ import { JupyterFrontEnd, - JupyterFrontEndPlugin + JupyterFrontEndPlugin, } from '@jupyterlab/application'; import { InputDialog } from '@jupyterlab/apputils'; @@ -25,7 +25,7 @@ const extension: JupyterFrontEndPlugin = { app.restored // Get the state object .then(() => state.fetch(PLUGIN_ID)) - .then(value => { + .then((value) => { // Get the option attribute if (value) { option = (value as ReadonlyJSONObject)['option'] as string; @@ -36,10 +36,10 @@ const extension: JupyterFrontEndPlugin = { return InputDialog.getItem({ title: 'Pick an option to persist by the State Example extension', items: options, - current: Math.max(0, options.indexOf(option)) + current: Math.max(0, options.indexOf(option)), }); }) - .then(result => { + .then((result) => { // If the user click on the accept button of the dialog if (result.button.accept) { // Get the user option @@ -48,12 +48,12 @@ const extension: JupyterFrontEndPlugin = { return state.save(PLUGIN_ID, { option }); } }) - .catch(reason => { + .catch((reason) => { console.error( `Something went wrong when reading the state for ${PLUGIN_ID}.\n${reason}` ); }); - } + }, }; export default extension; diff --git a/widgets/.eslintrc.js b/widgets/.eslintrc.js index 652320e0..c2375786 100644 --- a/widgets/.eslintrc.js +++ b/widgets/.eslintrc.js @@ -5,28 +5,34 @@ module.exports = { 'plugin:@typescript-eslint/recommended', 'plugin:jsdoc/recommended', 'plugin:prettier/recommended', - 'plugin:react/recommended' + 'plugin:react/recommended', ], parser: '@typescript-eslint/parser', parserOptions: { project: 'tsconfig.json', - sourceType: 'module' + sourceType: 'module', }, plugins: ['@typescript-eslint', 'jsdoc'], rules: { - '@typescript-eslint/interface-name-prefix': [ + '@typescript-eslint/naming-convention': [ 'error', - { prefixWithI: 'always' } + { + selector: 'interface', + format: ['PascalCase'], + custom: { + regex: '^I[A-Z]', + match: true, + }, + }, ], '@typescript-eslint/no-unused-vars': ['warn', { args: 'none' }], '@typescript-eslint/no-explicit-any': 'off', - '@typescript-eslint/camelcase': 'warn', '@typescript-eslint/no-namespace': 'off', '@typescript-eslint/no-use-before-define': 'off', '@typescript-eslint/quotes': [ 'error', 'single', - { avoidEscape: true, allowTemplateLiterals: false } + { avoidEscape: true, allowTemplateLiterals: false }, ], curly: ['error', 'all'], eqeqeq: 'error', @@ -34,14 +40,14 @@ module.exports = { 'jsdoc/require-property-type': 'off', 'jsdoc/require-returns-type': 'off', 'jsdoc/no-types': 'warn', - 'prefer-arrow-callback': 'error' + 'prefer-arrow-callback': 'error', }, settings: { jsdoc: { - mode: 'typescript' + mode: 'typescript', }, react: { - version: 'detect' - } - } + version: 'detect', + }, + }, }; diff --git a/widgets/package.json b/widgets/package.json index 918c4a01..0fbcedfa 100644 --- a/widgets/package.json +++ b/widgets/package.json @@ -12,10 +12,14 @@ "url": "https://github.com/jupyterlab/extension-examples/issues" }, "license": "BSD-3-Clause", - "author": "Project Jupyter Contributors", + "author": { + "name": "Project Jupyter Contributors", + "email": "" + }, "files": [ "lib/**/*.{d.ts,eot,gif,html,jpg,js,js.map,json,png,svg,woff2,ttf}", - "style/**/*.{css,eot,gif,html,jpg,json,png,svg,woff2,ttf}" + "style/**/*.{css,eot,gif,html,jpg,json,png,svg,woff2,ttf}", + "style/index.js" ], "main": "lib/index.js", "types": "lib/index.d.ts", @@ -30,45 +34,47 @@ "build:labextension": "jupyter labextension build .", "build:labextension:dev": "jupyter labextension build --development True .", "build:lib": "tsc", - "build:prod": "jlpm run build:lib && jlpm run build:labextension", + "build:prod": "jlpm run clean && jlpm run build:lib && jlpm run build:labextension", "clean": "jlpm run clean:lib", "clean:all": "jlpm run clean:lib && jlpm run clean:labextension", "clean:labextension": "rimraf jupyterlab_examples_widgets/labextension", "clean:lib": "rimraf lib tsconfig.tsbuildinfo", "eslint": "eslint . --ext .ts,.tsx --fix", "eslint:check": "eslint . --ext .ts,.tsx", - "install:extension": "jupyter labextension develop --overwrite .", + "install:extension": "jlpm run build", "prepare": "jlpm run clean && jlpm run build:prod", "watch": "run-p watch:src watch:labextension", "watch:labextension": "jupyter labextension watch .", "watch:src": "tsc -w" }, "dependencies": { - "@jupyterlab/application": "^3.0.0-rc.15", - "@jupyterlab/mainmenu": "^3.0.0-rc.15", + "@jupyterlab/application": "^3.0.10", + "@jupyterlab/mainmenu": "^3.0.8", "@lumino/algorithm": "^1.3.3", "@lumino/coreutils": "^1.5.3", "@lumino/disposable": "^1.4.3" }, "devDependencies": { - "@jupyterlab/builder": "^3.0.0-rc.15", - "@typescript-eslint/eslint-plugin": "^2.27.0", - "@typescript-eslint/parser": "^2.27.0", - "eslint": "^7.5.0", - "eslint-config-prettier": "^6.10.1", - "eslint-plugin-jsdoc": "^22.0.0", - "eslint-plugin-prettier": "^3.1.2", + "@jupyterlab/builder": "^3.0.0", + "@typescript-eslint/eslint-plugin": "^4.8.1", + "@typescript-eslint/parser": "^4.8.1", + "eslint": "^7.14.0", + "eslint-config-prettier": "^6.15.0", + "eslint-plugin-jsdoc": "^34.0.0", + "eslint-plugin-prettier": "^3.1.4", "eslint-plugin-react": "^7.18.3", "npm-run-all": "^4.1.5", - "prettier": "^1.19.0", + "prettier": "^2.1.1", "rimraf": "^3.0.2", "typescript": "~4.1.3" }, "sideEffects": [ - "style/*.css" + "style/*.css", + "style/index.js" ], "jupyterlab": { "extension": true, "outputDir": "jupyterlab_examples_widgets/labextension" - } + }, + "styleModule": "style/index.js" } \ No newline at end of file diff --git a/widgets/pyproject.toml b/widgets/pyproject.toml index c40f3629..d1659ee8 100644 --- a/widgets/pyproject.toml +++ b/widgets/pyproject.toml @@ -1,3 +1,17 @@ [build-system] -requires = ["jupyter_packaging~=0.7.9", "jupyterlab>=3.0.0rc15,==3.*", "setuptools>=40.8.0", "wheel"] -build-backend = "setuptools.build_meta" +requires = ["jupyter_packaging~=0.10,<2", "jupyterlab~=3.0"] +build-backend = "jupyter_packaging.build_api" + +[tool.jupyter-packaging.options] +skip-if-exists = ["jupyterlab_examples_widgets/labextension/static/style.js"] +ensured-targets = ["jupyterlab_examples_widgets/labextension/static/style.js", "jupyterlab_examples_widgets/labextension/package.json"] + +[tool.jupyter-packaging.builder] +factory = "jupyter_packaging.npm_builder" + +[tool.jupyter-packaging.build-args] +build_cmd = "build:prod" +npm = ["jlpm"] + +[tool.check-manifest] +ignore = ["jupyterlab_examples_widgets/labextension/**", "yarn.lock", ".*", "package-lock.json"] diff --git a/widgets/setup.py b/widgets/setup.py index 73c2c1e1..e78994bb 100644 --- a/widgets/setup.py +++ b/widgets/setup.py @@ -2,79 +2,52 @@ jupyterlab_examples_widgets setup """ import json -import os +from pathlib import Path -from jupyter_packaging import ( - create_cmdclass, install_npm, ensure_targets, - combine_commands, skip_if_exists -) import setuptools -HERE = os.path.abspath(os.path.dirname(__file__)) +HERE = Path(__file__).parent.resolve() # The name of the project -name="jupyterlab_examples_widgets" - -# Get our version -with open(os.path.join(HERE, 'package.json')) as f: - version = json.load(f)['version'] +name = "jupyterlab_examples_widgets" -lab_path = os.path.join(HERE, name, "labextension") +lab_path = (HERE / name / "labextension") # Representative files that should exist after a successful build -jstargets = [ - os.path.join(lab_path, "package.json"), +ensured_targets = [ + str(lab_path / "package.json"), + str(lab_path / "static/style.js") ] -package_data_spec = { - name: [ - "*" - ] -} - labext_name = "@jupyterlab-examples/widgets" data_files_spec = [ - ("share/jupyter/labextensions/%s" % labext_name, lab_path, "**"), - ("share/jupyter/labextensions/%s" % labext_name, HERE, "install.json"), + ("share/jupyter/labextensions/%s" % labext_name, str(lab_path), "**"), + ("share/jupyter/labextensions/%s" % labext_name, str(HERE), "install.json"), ] -cmdclass = create_cmdclass("jsdeps", - package_data_spec=package_data_spec, - data_files_spec=data_files_spec -) - -js_command = combine_commands( - install_npm(HERE, build_cmd="build:prod", npm=["jlpm"]), - ensure_targets(jstargets), -) - -is_repo = os.path.exists(os.path.join(HERE, ".git")) -if is_repo: - cmdclass["jsdeps"] = js_command -else: - cmdclass["jsdeps"] = skip_if_exists(jstargets, js_command) +long_description = (HERE / "README.md").read_text() -with open("README.md", "r") as fh: - long_description = fh.read() +# Get the package info from package.json +pkg_json = json.loads((HERE / "package.json").read_bytes()) setup_args = dict( name=name, - version=version, - url="https://github.com/jupyterlab/extension-examples.git", - author="Project Jupyter Contributors", - description="minimal lab example", - long_description= long_description, + version=pkg_json["version"], + url=pkg_json["homepage"], + author=pkg_json["author"]["name"], + author_email=pkg_json["author"]["email"], + description=pkg_json["description"], + license=pkg_json["license"], + long_description=long_description, long_description_content_type="text/markdown", - cmdclass= cmdclass, packages=setuptools.find_packages(), install_requires=[ - "jupyterlab>=3.0.0rc15,==3.*", + "jupyter_server>=1.6,<2" ], zip_safe=False, include_package_data=True, python_requires=">=3.6", - license="BSD-3-Clause", platforms="Linux, Mac OS X, Windows", keywords=["Jupyter", "JupyterLab", "JupyterLab3"], classifiers=[ @@ -84,10 +57,24 @@ "Programming Language :: Python :: 3.6", "Programming Language :: Python :: 3.7", "Programming Language :: Python :: 3.8", + "Programming Language :: Python :: 3.9", "Framework :: Jupyter", ], ) +try: + from jupyter_packaging import ( + wrap_installers, + npm_builder, + get_data_files + ) + post_develop = npm_builder( + build_cmd="install:extension", source_dir="src", build_dir=lab_path + ) + setup_args['cmdclass'] = wrap_installers(post_develop=post_develop, ensured_targets=ensured_targets) + setup_args['data_files'] = get_data_files(data_files_spec) +except ImportError as e: + pass if __name__ == "__main__": setuptools.setup(**setup_args) diff --git a/widgets/src/index.ts b/widgets/src/index.ts index 41513d5f..b2d7b1d6 100644 --- a/widgets/src/index.ts +++ b/widgets/src/index.ts @@ -1,6 +1,6 @@ import { JupyterFrontEnd, - JupyterFrontEndPlugin + JupyterFrontEndPlugin, } from '@jupyterlab/application'; import { ICommandPalette } from '@jupyterlab/apputils'; @@ -30,7 +30,7 @@ const extension: JupyterFrontEndPlugin = { execute: () => { const widget = new ExampleWidget(); shell.add(widget, 'main'); - } + }, }); palette.addItem({ command, category: 'Extension Examples' }); @@ -39,7 +39,7 @@ const extension: JupyterFrontEndPlugin = { exampleMenu.title.label = 'Widget Example'; mainMenu.addMenu(exampleMenu, { rank: 80 }); exampleMenu.addItem({ command }); - } + }, }; export default extension; From 3d131a4bf3e3e904906df19f2c07ac8cb84c85ab Mon Sep 17 00:00:00 2001 From: Jeremy Tuloup Date: Tue, 11 May 2021 18:57:58 +0200 Subject: [PATCH 02/11] pip install . --- .github/workflows/main.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index f9f79428..495c6101 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -110,7 +110,7 @@ jobs: if: steps.filter.outputs.extension == 'true' run: | cd ${EXAMPLE_FOLDER} - pip install -e . + pip install . jupyter labextension list 2>&1 | grep -ie "@jupyterlab-examples/*.*OK" python -m jupyterlab.browser_check pip uninstall -y $(python setup.py --name) @@ -214,7 +214,7 @@ jobs: if: steps.filter.outputs.extension == 'true' run: | cd server-extension - pip install -e . + pip install . - name: Check extension as dev if: steps.filter.outputs.extension == 'true' && ( startsWith(runner.os, 'Linux') || startsWith(runner.os, 'macOS') ) run: | From 94ecaebf195451ff39f905c682e624471f654a45 Mon Sep 17 00:00:00 2001 From: Carlos Herrero Date: Mon, 21 Jun 2021 11:31:37 +0200 Subject: [PATCH 03/11] Add .gitattributes file for line endings Remove all files to add again and restore line endings Normalize all the line endings Make prettier happy --- .gitattributes | 8 ++++++++ 1 file changed, 8 insertions(+) create mode 100644 .gitattributes diff --git a/.gitattributes b/.gitattributes new file mode 100644 index 00000000..a853f895 --- /dev/null +++ b/.gitattributes @@ -0,0 +1,8 @@ + +# Set the default behavior, in case people don't have core.autocrlf set. +* text=auto + +# Explicitly declare text files you want to always be normalized and converted +# to native line endings on checkout. +*.ts text eol=lf +*.tsx text eol=lf From 96998d02c15ec27777d9a189a229293538a3b517 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20Collonval?= Date: Wed, 7 Jul 2021 12:14:35 +0200 Subject: [PATCH 04/11] Push fix on hello-world Fix setup.py --- .github/workflows/main.yml | 51 +++++++--------- command-palette/setup.py | 4 +- commands/setup.py | 4 +- context-menu/setup.py | 4 +- custom-log-console/setup.py | 4 +- datagrid/setup.py | 4 +- hello-world/setup.py | 4 +- kernel-messaging/setup.py | 4 +- kernel-output/setup.py | 4 +- launcher/setup.py | 4 +- log-messages/setup.py | 4 +- main-menu/setup.py | 4 +- react-widget/setup.py | 4 +- server-extension/README.md | 61 ++++++++----------- .../jupyter-config/jlab_ext_example.json | 7 --- server-extension/setup.py | 7 ++- settings/setup.py | 4 +- signals/setup.py | 4 +- state/setup.py | 4 +- widgets/setup.py | 4 +- 20 files changed, 85 insertions(+), 105 deletions(-) delete mode 100644 server-extension/jupyter-config/jlab_ext_example.json diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 495c6101..933c01a2 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -9,6 +9,7 @@ on: jobs: build_extensions: runs-on: ${{ matrix.os }} + strategy: fail-fast: false matrix: @@ -31,6 +32,11 @@ jobs: - toolbar-button - widgets os: [ubuntu-latest, macos-latest, windows-latest] + + defaults: + run: + working-directory: ${{ matrix.example }} + steps: - name: Checkout uses: actions/checkout@v2 @@ -54,12 +60,10 @@ jobs: - name: Check config files if: steps.filter.outputs.extension == 'true' run: | - diff hello-world/tsconfig.json ${EXAMPLE_FOLDER}/tsconfig.json - diff hello-world/.eslintignore ${EXAMPLE_FOLDER}/.eslintignore - diff hello-world/.eslintrc.js ${EXAMPLE_FOLDER}/.eslintrc.js - diff hello-world/.gitignore ${EXAMPLE_FOLDER}/.gitignore - env: - EXAMPLE_FOLDER: ${{ matrix.example }} + diff ../hello-world/tsconfig.json tsconfig.json + diff ../hello-world/.eslintignore .eslintignore + diff ../hello-world/.eslintrc.js .eslintrc.js + diff ../hello-world/.gitignore .gitignore shell: bash - name: Install node if: steps.filter.outputs.extension == 'true' @@ -92,30 +96,17 @@ jobs: python -m pip install --upgrade pip jupyter_packaging~=0.10 jupyterlab~=3.0 - name: Install the NPM dependencies if: steps.filter.outputs.extension == 'true' - run: | - cd ${EXAMPLE_FOLDER} - jlpm - env: - EXAMPLE_FOLDER: ${{ matrix.example }} - shell: bash + run: jlpm - name: Lint the files if: steps.filter.outputs.extension == 'true' - run: | - cd ${EXAMPLE_FOLDER} - jlpm run eslint:check - env: - EXAMPLE_FOLDER: ${{ matrix.example }} - shell: bash + run: jlpm run eslint:check - name: Build and check by extension - if: steps.filter.outputs.extension == 'true' run: | - cd ${EXAMPLE_FOLDER} - pip install . - jupyter labextension list 2>&1 | grep -ie "@jupyterlab-examples/*.*OK" + pip install . -vvv + jupyter labextension list 2>&1 | tee labextension.list + cat labextension.list | grep -ie "@jupyterlab-examples/*.*OK" python -m jupyterlab.browser_check pip uninstall -y $(python setup.py --name) - env: - EXAMPLE_FOLDER: ${{ matrix.example }} shell: bash build_serverextension: @@ -201,8 +192,10 @@ jobs: - name: Check extension as dev if: steps.filter.outputs.extension == 'true' && ( startsWith(runner.os, 'Linux') || startsWith(runner.os, 'macOS') ) run: | - jupyter server extension list 2>&1 | grep -ie "jlab_ext_example.*OK" - jupyter labextension list 2>&1 | grep -ie "@jupyterlab-examples/server-extension.*OK" + jupyter server extension list 2>&1 | tee serverextension.list + cat serverextension.list | grep -ie "jlab_ext_example.*OK" + jupyter labextension list 2>&1 | tee labextension.list + cat labextension.list | grep -ie "@jupyterlab-examples/server-extension.*OK" - name: Clean extension installation if: steps.filter.outputs.extension == 'true' run: | @@ -218,8 +211,10 @@ jobs: - name: Check extension as dev if: steps.filter.outputs.extension == 'true' && ( startsWith(runner.os, 'Linux') || startsWith(runner.os, 'macOS') ) run: | - jupyter server extension list 2>&1 | grep -ie "jlab_ext_example.*OK" - jupyter labextension list 2>&1 | grep -ie "@jupyterlab-examples/server-extension.*OK" + jupyter server extension list 2>&1 | tee serverextension.list + cat serverextension.list | grep -ie "jlab_ext_example.*OK" + jupyter labextension list 2>&1 | tee labextension.list + cat labextension.list | grep -ie "@jupyterlab-examples/server-extension.*OK" python -m jupyterlab.browser_check build_all: diff --git a/command-palette/setup.py b/command-palette/setup.py index 1f9895cd..fe4dbff7 100644 --- a/command-palette/setup.py +++ b/command-palette/setup.py @@ -22,8 +22,8 @@ labext_name = "@jupyterlab-examples/command-palette" data_files_spec = [ - ("share/jupyter/labextensions/%s" % labext_name, str(lab_path), "**"), - ("share/jupyter/labextensions/%s" % labext_name, str(HERE), "install.json"), + ("share/jupyter/labextensions/%s" % labext_name, str(lab_path.relative_to(HERE)), "**"), + ("share/jupyter/labextensions/%s" % labext_name, str('.'), "install.json"), ] long_description = (HERE / "README.md").read_text() diff --git a/commands/setup.py b/commands/setup.py index 0cc57823..4ec26537 100644 --- a/commands/setup.py +++ b/commands/setup.py @@ -22,8 +22,8 @@ labext_name = "@jupyterlab-examples/commands" data_files_spec = [ - ("share/jupyter/labextensions/%s" % labext_name, str(lab_path), "**"), - ("share/jupyter/labextensions/%s" % labext_name, str(HERE), "install.json"), + ("share/jupyter/labextensions/%s" % labext_name, str(lab_path.relative_to(HERE)), "**"), + ("share/jupyter/labextensions/%s" % labext_name, str('.'), "install.json"), ] long_description = (HERE / "README.md").read_text() diff --git a/context-menu/setup.py b/context-menu/setup.py index ec1c0d3b..cef40453 100644 --- a/context-menu/setup.py +++ b/context-menu/setup.py @@ -22,8 +22,8 @@ labext_name = "@jupyterlab-examples/context-menu" data_files_spec = [ - ("share/jupyter/labextensions/%s" % labext_name, str(lab_path), "**"), - ("share/jupyter/labextensions/%s" % labext_name, str(HERE), "install.json"), + ("share/jupyter/labextensions/%s" % labext_name, str(lab_path.relative_to(HERE)), "**"), + ("share/jupyter/labextensions/%s" % labext_name, str('.'), "install.json"), ] long_description = (HERE / "README.md").read_text() diff --git a/custom-log-console/setup.py b/custom-log-console/setup.py index 99e141dd..277528f0 100644 --- a/custom-log-console/setup.py +++ b/custom-log-console/setup.py @@ -22,8 +22,8 @@ labext_name = "@jupyterlab-examples/custom-log-console" data_files_spec = [ - ("share/jupyter/labextensions/%s" % labext_name, str(lab_path), "**"), - ("share/jupyter/labextensions/%s" % labext_name, str(HERE), "install.json"), + ("share/jupyter/labextensions/%s" % labext_name, str(lab_path.relative_to(HERE)), "**"), + ("share/jupyter/labextensions/%s" % labext_name, str('.'), "install.json"), ] long_description = (HERE / "README.md").read_text() diff --git a/datagrid/setup.py b/datagrid/setup.py index 54505d75..3a604541 100644 --- a/datagrid/setup.py +++ b/datagrid/setup.py @@ -22,8 +22,8 @@ labext_name = "@jupyterlab-examples/datagrid" data_files_spec = [ - ("share/jupyter/labextensions/%s" % labext_name, str(lab_path), "**"), - ("share/jupyter/labextensions/%s" % labext_name, str(HERE), "install.json"), + ("share/jupyter/labextensions/%s" % labext_name, str(lab_path.relative_to(HERE)), "**"), + ("share/jupyter/labextensions/%s" % labext_name, str('.'), "install.json"), ] long_description = (HERE / "README.md").read_text() diff --git a/hello-world/setup.py b/hello-world/setup.py index 785d3ef2..445380ae 100644 --- a/hello-world/setup.py +++ b/hello-world/setup.py @@ -22,8 +22,8 @@ labext_name = "@jupyterlab-examples/hello-world" data_files_spec = [ - ("share/jupyter/labextensions/%s" % labext_name, str(lab_path), "**"), - ("share/jupyter/labextensions/%s" % labext_name, str(HERE), "install.json"), + ("share/jupyter/labextensions/%s" % labext_name, str(lab_path.relative_to(HERE)), "**"), + ("share/jupyter/labextensions/%s" % labext_name, str('.'), "install.json"), ] long_description = (HERE / "README.md").read_text() diff --git a/kernel-messaging/setup.py b/kernel-messaging/setup.py index 94f092e7..0313f347 100644 --- a/kernel-messaging/setup.py +++ b/kernel-messaging/setup.py @@ -22,8 +22,8 @@ labext_name = "@jupyterlab-examples/kernel-messaging" data_files_spec = [ - ("share/jupyter/labextensions/%s" % labext_name, str(lab_path), "**"), - ("share/jupyter/labextensions/%s" % labext_name, str(HERE), "install.json"), + ("share/jupyter/labextensions/%s" % labext_name, str(lab_path.relative_to(HERE)), "**"), + ("share/jupyter/labextensions/%s" % labext_name, str('.'), "install.json"), ] long_description = (HERE / "README.md").read_text() diff --git a/kernel-output/setup.py b/kernel-output/setup.py index abfa9d23..1300a605 100644 --- a/kernel-output/setup.py +++ b/kernel-output/setup.py @@ -22,8 +22,8 @@ labext_name = "@jupyterlab-examples/kernel-output" data_files_spec = [ - ("share/jupyter/labextensions/%s" % labext_name, str(lab_path), "**"), - ("share/jupyter/labextensions/%s" % labext_name, str(HERE), "install.json"), + ("share/jupyter/labextensions/%s" % labext_name, str(lab_path.relative_to(HERE)), "**"), + ("share/jupyter/labextensions/%s" % labext_name, str('.'), "install.json"), ] long_description = (HERE / "README.md").read_text() diff --git a/launcher/setup.py b/launcher/setup.py index cf70e22c..32969989 100644 --- a/launcher/setup.py +++ b/launcher/setup.py @@ -22,8 +22,8 @@ labext_name = "@jupyterlab-examples/launcher" data_files_spec = [ - ("share/jupyter/labextensions/%s" % labext_name, str(lab_path), "**"), - ("share/jupyter/labextensions/%s" % labext_name, str(HERE), "install.json"), + ("share/jupyter/labextensions/%s" % labext_name, str(lab_path.relative_to(HERE)), "**"), + ("share/jupyter/labextensions/%s" % labext_name, str('.'), "install.json"), ] long_description = (HERE / "README.md").read_text() diff --git a/log-messages/setup.py b/log-messages/setup.py index cbb8a72b..e8c00456 100644 --- a/log-messages/setup.py +++ b/log-messages/setup.py @@ -22,8 +22,8 @@ labext_name = "@jupyterlab-examples/log-messages" data_files_spec = [ - ("share/jupyter/labextensions/%s" % labext_name, str(lab_path), "**"), - ("share/jupyter/labextensions/%s" % labext_name, str(HERE), "install.json"), + ("share/jupyter/labextensions/%s" % labext_name, str(lab_path.relative_to(HERE)), "**"), + ("share/jupyter/labextensions/%s" % labext_name, str('.'), "install.json"), ] long_description = (HERE / "README.md").read_text() diff --git a/main-menu/setup.py b/main-menu/setup.py index b52750b0..f750dc4a 100644 --- a/main-menu/setup.py +++ b/main-menu/setup.py @@ -22,8 +22,8 @@ labext_name = "@jupyterlab-examples/main-menu" data_files_spec = [ - ("share/jupyter/labextensions/%s" % labext_name, str(lab_path), "**"), - ("share/jupyter/labextensions/%s" % labext_name, str(HERE), "install.json"), + ("share/jupyter/labextensions/%s" % labext_name, str(lab_path.relative_to(HERE)), "**"), + ("share/jupyter/labextensions/%s" % labext_name, str('.'), "install.json"), ] long_description = (HERE / "README.md").read_text() diff --git a/react-widget/setup.py b/react-widget/setup.py index cf4a915d..dcc1410f 100644 --- a/react-widget/setup.py +++ b/react-widget/setup.py @@ -22,8 +22,8 @@ labext_name = "@jupyterlab-examples/react-widget" data_files_spec = [ - ("share/jupyter/labextensions/%s" % labext_name, str(lab_path), "**"), - ("share/jupyter/labextensions/%s" % labext_name, str(HERE), "install.json"), + ("share/jupyter/labextensions/%s" % labext_name, str(lab_path.relative_to(HERE)), "**"), + ("share/jupyter/labextensions/%s" % labext_name, str('.'), "install.json"), ] long_description = (HERE / "README.md").read_text() diff --git a/server-extension/README.md b/server-extension/README.md index bff59c37..b5da2dd6 100644 --- a/server-extension/README.md +++ b/server-extension/README.md @@ -498,13 +498,6 @@ jlab_ext_example setup import json from pathlib import Path -from jupyter_packaging import ( - create_cmdclass, - install_npm, - ensure_targets, - combine_commands, - skip_if_exists, -) import setuptools HERE = Path(__file__).parent.resolve() @@ -512,39 +505,24 @@ HERE = Path(__file__).parent.resolve() # The name of the project name = "jlab_ext_example" -lab_path = HERE / name / "labextension" +lab_path = (HERE / name / "labextension") # Representative files that should exist after a successful build -jstargets = [ +ensured_targets = [ str(lab_path / "package.json"), + str(lab_path / "static/style.js") ] -package_data_spec = {name: ["*"]} - labext_name = "@jupyterlab-examples/server-extension" data_files_spec = [ - ("share/jupyter/labextensions/%s" % labext_name, str(lab_path), "**"), - ("share/jupyter/labextensions/%s" % labext_name, str(HERE), "install.json"), + ("share/jupyter/labextensions/%s" % labext_name, str(lab_path.relative_to(HERE)), "**"), + ("share/jupyter/labextensions/%s" % labext_name, str('.'), "install.json"), ("etc/jupyter/jupyter_notebook_config.d", "jupyter-config/jupyter_notebook_config.d", "jlab_ext_example.json"), ("etc/jupyter/jupyter_server_config.d", "jupyter-config/jupyter_server_config.d", "jlab_ext_example.json"), + ] -cmdclass = create_cmdclass( - "jsdeps", package_data_spec=package_data_spec, data_files_spec=data_files_spec -) - -js_command = combine_commands( - install_npm(HERE, build_cmd="build:prod", npm=["jlpm"]), - ensure_targets(jstargets), -) - -is_repo = (HERE / ".git").exists() -if is_repo: - cmdclass["jsdeps"] = js_command -else: - cmdclass["jsdeps"] = skip_if_exists(jstargets, js_command) - long_description = (HERE / "README.md").read_text() # Get the package info from package.json @@ -554,15 +532,15 @@ setup_args = dict( name=name, version=pkg_json["version"], url=pkg_json["homepage"], - author=pkg_json["author"], + author=pkg_json["author"]["name"], + author_email=pkg_json["author"]["email"], description=pkg_json["description"], license=pkg_json["license"], long_description=long_description, long_description_content_type="text/markdown", - cmdclass=cmdclass, packages=setuptools.find_packages(), install_requires=[ - "jupyterlab~=3.0", + "jupyter_server>=1.6,<2" ], zip_safe=False, include_package_data=True, @@ -581,6 +559,19 @@ setup_args = dict( ], ) +try: + from jupyter_packaging import ( + wrap_installers, + npm_builder, + get_data_files + ) + post_develop = npm_builder( + build_cmd="install:extension", source_dir="src", build_dir=lab_path + ) + setup_args['cmdclass'] = wrap_installers(post_develop=post_develop, ensured_targets=ensured_targets) + setup_args['data_files'] = get_data_files(data_files_spec) +except ImportError as e: + pass if __name__ == "__main__": setuptools.setup(**setup_args) @@ -628,9 +619,9 @@ It will copy the NPM package in the Python package and force it to be copied in JupyterLab is looking for frontend extensions when the Python package is installed: ```py -# setup.py#L33-L33 +# setup.py#L25-L25 -("share/jupyter/labextensions/%s" % labext_name, str(lab_path), "**"), + ("share/jupyter/labextensions/%s" % labext_name, str(lab_path.relative_to(HERE)), "**"), ``` The last piece of configuration needed is the enabling of the server extension. This is @@ -652,7 +643,7 @@ done by copying the following JSON file: in the appropriate jupyter folder (`etc/jupyter/jupyter_server_config.d`): ```py -# setup.py#L36-L36 +# setup.py#L28-L28 ("etc/jupyter/jupyter_server_config.d", "jupyter-config/jupyter_server_config.d", "jlab_ext_example.json"), ``` @@ -661,7 +652,7 @@ For backward compatibility with the classical notebook, the old version of that (`etc/jupyter/jupyter_notebook_config.d`): ```py -# setup.py#L35-L35 +# setup.py#L27-L27 ("etc/jupyter/jupyter_notebook_config.d", "jupyter-config/jupyter_notebook_config.d", "jlab_ext_example.json"), ``` diff --git a/server-extension/jupyter-config/jlab_ext_example.json b/server-extension/jupyter-config/jlab_ext_example.json deleted file mode 100644 index 03f6eef1..00000000 --- a/server-extension/jupyter-config/jlab_ext_example.json +++ /dev/null @@ -1,7 +0,0 @@ -{ - "ServerApp": { - "jpserver_extensions": { - "jlab_ext_example": true - } - } -} diff --git a/server-extension/setup.py b/server-extension/setup.py index 180f7ab2..87296a1c 100644 --- a/server-extension/setup.py +++ b/server-extension/setup.py @@ -22,9 +22,10 @@ labext_name = "@jupyterlab-examples/server-extension" data_files_spec = [ - ("share/jupyter/labextensions/%s" % labext_name, str(lab_path), "**"), - ("share/jupyter/labextensions/%s" % labext_name, str(HERE), "install.json"),("etc/jupyter/jupyter_server_config.d", - "jupyter-config", "jlab_ext_example.json"), + ("share/jupyter/labextensions/%s" % labext_name, str(lab_path.relative_to(HERE)), "**"), + ("share/jupyter/labextensions/%s" % labext_name, str('.'), "install.json"), + ("etc/jupyter/jupyter_notebook_config.d", "jupyter-config/jupyter_notebook_config.d", "jlab_ext_example.json"), + ("etc/jupyter/jupyter_server_config.d", "jupyter-config/jupyter_server_config.d", "jlab_ext_example.json"), ] diff --git a/settings/setup.py b/settings/setup.py index c0bdfeb4..f6ced7ed 100644 --- a/settings/setup.py +++ b/settings/setup.py @@ -22,8 +22,8 @@ labext_name = "@jupyterlab-examples/settings" data_files_spec = [ - ("share/jupyter/labextensions/%s" % labext_name, str(lab_path), "**"), - ("share/jupyter/labextensions/%s" % labext_name, str(HERE), "install.json"), + ("share/jupyter/labextensions/%s" % labext_name, str(lab_path.relative_to(HERE)), "**"), + ("share/jupyter/labextensions/%s" % labext_name, str('.'), "install.json"), ] long_description = (HERE / "README.md").read_text() diff --git a/signals/setup.py b/signals/setup.py index b159c8eb..4b629a67 100644 --- a/signals/setup.py +++ b/signals/setup.py @@ -22,8 +22,8 @@ labext_name = "@jupyterlab-examples/signals" data_files_spec = [ - ("share/jupyter/labextensions/%s" % labext_name, str(lab_path), "**"), - ("share/jupyter/labextensions/%s" % labext_name, str(HERE), "install.json"), + ("share/jupyter/labextensions/%s" % labext_name, str(lab_path.relative_to(HERE)), "**"), + ("share/jupyter/labextensions/%s" % labext_name, str('.'), "install.json"), ] long_description = (HERE / "README.md").read_text() diff --git a/state/setup.py b/state/setup.py index 92e1ee29..e1f2e7e5 100644 --- a/state/setup.py +++ b/state/setup.py @@ -22,8 +22,8 @@ labext_name = "@jupyterlab-examples/state" data_files_spec = [ - ("share/jupyter/labextensions/%s" % labext_name, str(lab_path), "**"), - ("share/jupyter/labextensions/%s" % labext_name, str(HERE), "install.json"), + ("share/jupyter/labextensions/%s" % labext_name, str(lab_path.relative_to(HERE)), "**"), + ("share/jupyter/labextensions/%s" % labext_name, str('.'), "install.json"), ] long_description = (HERE / "README.md").read_text() diff --git a/widgets/setup.py b/widgets/setup.py index e78994bb..d3c04548 100644 --- a/widgets/setup.py +++ b/widgets/setup.py @@ -22,8 +22,8 @@ labext_name = "@jupyterlab-examples/widgets" data_files_spec = [ - ("share/jupyter/labextensions/%s" % labext_name, str(lab_path), "**"), - ("share/jupyter/labextensions/%s" % labext_name, str(HERE), "install.json"), + ("share/jupyter/labextensions/%s" % labext_name, str(lab_path.relative_to(HERE)), "**"), + ("share/jupyter/labextensions/%s" % labext_name, str('.'), "install.json"), ] long_description = (HERE / "README.md").read_text() From fccf4a48d0a2733239856c89c195ca9f6240b67a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20Collonval?= Date: Wed, 7 Jul 2021 16:26:34 +0200 Subject: [PATCH 05/11] Update READMEs Lint server-extension --- command-palette/README.md | 4 +- commands/README.md | 4 +- context-menu/README.md | 10 ++-- custom-log-console/README.md | 14 +++--- hello-world/README.md | 10 ++-- kernel-messaging/README.md | 4 +- kernel-output/README.md | 6 +-- log-messages/README.md | 2 +- main-menu/README.md | 10 ++-- server-extension/README.md | 95 ++++++++++++++++++++++++------------ server-extension/setup.py | 1 - settings/README.md | 39 +++++++++------ signals/README.md | 2 +- widgets/README.md | 2 +- 14 files changed, 126 insertions(+), 77 deletions(-) diff --git a/command-palette/README.md b/command-palette/README.md index ae091337..a1459cd4 100644 --- a/command-palette/README.md +++ b/command-palette/README.md @@ -42,13 +42,13 @@ const extension: JupyterFrontEndPlugin = { console.log( `jlab-examples:command-palette has been called ${args['origin']}.` ); - } + }, }); // Add the command to the command palette const category = 'Extension Examples'; palette.addItem({ command, category, args: { origin: 'from palette' } }); - } + }, ``` The `ICommandPalette` diff --git a/commands/README.md b/commands/README.md index fdea886f..6f66f052 100644 --- a/commands/README.md +++ b/commands/README.md @@ -71,12 +71,12 @@ with the unique command id and optionally the arguments. ```ts // src/index.ts#L31-L36 - commands.execute(command, { origin: 'init' }).catch(reason => { + commands.execute(command, { origin: 'init' }).catch((reason) => { console.error( `An error occurred during the execution of jlab-examples:command.\n${reason}` ); }); -} +}, ``` When running JupyterLab with this extension, the following message should diff --git a/context-menu/README.md b/context-menu/README.md index cd7d9775..863360a7 100644 --- a/context-menu/README.md +++ b/context-menu/README.md @@ -52,7 +52,7 @@ app.docRegistry.addFileType({ extensions: ['.example'], fileFormat: 'text', contentType: 'file', - mimeTypes: ['text/plain'] + mimeTypes: ['text/plain'], }); ``` @@ -73,9 +73,9 @@ app.commands.addCommand('jlab-examples/context-menu:open', { showDialog({ title: file.name, body: 'Path: ' + file.path, - buttons: [Dialog.okButton()] - }).catch(e => console.log(e)); - } + buttons: [Dialog.okButton()], + }).catch((e) => console.log(e)); + }, }); ``` @@ -93,7 +93,7 @@ Finally, you can add the command to a context menu using the `addItem()` method app.contextMenu.addItem({ command: 'jlab-examples/context-menu:open', selector: '.jp-DirListing-item[data-file-type="example"]', - rank: 0 + rank: 0, }); ``` diff --git a/custom-log-console/README.md b/custom-log-console/README.md index 98e24113..86a2a359 100644 --- a/custom-log-console/README.md +++ b/custom-log-console/README.md @@ -74,7 +74,7 @@ To initialize a new `LogConsoleWidget` you have to create a `LogConsolePanel` to logConsolePanel = new LogConsolePanel( new LoggerRegistry({ defaultRendermime: rendermime, - maxLength: 1000 + maxLength: 1000, }) ); ``` @@ -97,7 +97,7 @@ Now you are ready to initialize a new `MainAreaWidget` passing the `logConsolePa // src/index.ts#L86-L88 logConsoleWidget = new MainAreaWidget({ - content: logConsolePanel + content: logConsolePanel, }); ``` @@ -133,7 +133,7 @@ commands.addCommand('jlab-examples/custom-log-console:open', { } else { createLogConsoleWidget(); } - } + }, }); ``` @@ -147,7 +147,7 @@ Finally, you can send log messages calling `log` method present on the `logger` const msg: IHtmlLog = { type: 'html', level: 'debug', - data: '
Hello world HTML!!
' + data: '
Hello world HTML!!
', }; logConsolePanel?.logger?.log(msg); @@ -180,14 +180,14 @@ logConsolePanel?.logger?.log(msg); const data: nbformat.IOutput = { output_type: 'display_data', data: { - 'text/plain': 'Hello world nbformat!!' - } + 'text/plain': 'Hello world nbformat!!', + }, }; const msg: IOutputLog = { type: 'output', level: 'warning', - data + data, }; logConsolePanel?.logger?.log(msg); diff --git a/hello-world/README.md b/hello-world/README.md index f7451817..7cf02b4b 100644 --- a/hello-world/README.md +++ b/hello-world/README.md @@ -100,6 +100,7 @@ The following sections will walk you through the extension code files. Start with the file `src/index.ts`. This typescript file contains the main logic of the extension. It begins with the following import section: + ```ts // src/index.ts#L1-L4 @@ -108,6 +109,7 @@ import { JupyterFrontEndPlugin, } from '@jupyterlab/application'; ``` + `JupyterFrontEnd` is the main Jupyterlab application class. It allows you to access and modify some of its main components. `JupyterFrontEndPlugin` is the class @@ -116,10 +118,10 @@ called `@jupyterlab/application`. The dependency of your extension on this package is declared in the file `package.json`: ```json5 -// package.json#L46-L48 +// package.json#L50-L52 "dependencies": { - "@jupyterlab/application": "^3.0.0" + "@jupyterlab/application": "^3.0.10" }, ``` @@ -143,7 +145,7 @@ const plugin: JupyterFrontEndPlugin = { ```ts // src/index.ts#L14-L17 - } + }, }; export default plugin; @@ -230,7 +232,7 @@ a bit. Simply replace the `activate` function with the following lines: activate: (app: JupyterFrontEnd) => { console.log('the JupyterLab main application:', app); -} +}, ``` diff --git a/kernel-messaging/README.md b/kernel-messaging/README.md index 67486e15..7589b590 100644 --- a/kernel-messaging/README.md +++ b/kernel-messaging/README.md @@ -51,12 +51,12 @@ this._sessionContext = new SessionContext({ ```ts void this._sessionContext .initialize() - .then(async value => { + .then(async (value) => { if (value) { await sessionContextDialogs.selectKernel(this._sessionContext); } }) - .catch(reason => { + .catch((reason) => { console.error( `Failed to initialize the session in ExamplePanel.\n${reason}` ); diff --git a/kernel-output/README.md b/kernel-output/README.md index e723f84c..85288482 100644 --- a/kernel-output/README.md +++ b/kernel-output/README.md @@ -79,12 +79,12 @@ with this line: void this._sessionContext .initialize() - .then(async value => { + .then(async (value) => { if (value) { await sessionContextDialogs.selectKernel(this._sessionContext); } }) - .catch(reason => { + .catch((reason) => { console.error( `Failed to initialize the session in ExamplePanel.\n${reason}` ); @@ -145,7 +145,7 @@ execute(code: string): void { .then((msg: KernelMessage.IExecuteReplyMsg) => { console.log(msg); }) - .catch(reason => console.error(reason)); + .catch((reason) => console.error(reason)); } ``` diff --git a/log-messages/README.md b/log-messages/README.md index e2f5ab68..c97c17ad 100644 --- a/log-messages/README.md +++ b/log-messages/README.md @@ -62,7 +62,7 @@ Finally, you can send log messages by calling the `log` method of the `logger` o const msg: ITextLog = { type: 'text', level: 'info', - data: 'Hello world text!!' + data: 'Hello world text!!', }; logger?.log(msg); diff --git a/main-menu/README.md b/main-menu/README.md index 44249f9a..1b8e0457 100644 --- a/main-menu/README.md +++ b/main-menu/README.md @@ -14,6 +14,7 @@ The `IMainMenu` interface can be requested as a new argument to the `activate` function, but first it has to be imported. And the class `Menu` to create new menu needs also to be imported but from the Lumino library: + ```ts // src/index.ts#L6-L8 @@ -21,10 +22,12 @@ import { IMainMenu } from '@jupyterlab/mainmenu'; import { Menu } from '@lumino/widgets'; ``` + You can add the `IMainMenu` in the `requires:` property such that it is injected into the `activate` function. The extension looks like: + ```ts // src/index.ts#L15-L57 @@ -72,6 +75,7 @@ const extension: JupyterFrontEndPlugin = { }, }; ``` + In this extension, you have the dependencies to _@jupyterlab/mainmenu_ and _@lumino/widgets_. Before it builds, this dependencies have to be added to the @@ -85,11 +89,11 @@ After the execution of that command, `package.json` should list them in the `dependencies`: ```json5 -// package.json#L46-L50 +// package.json#L50-L54 "dependencies": { - "@jupyterlab/application": "^3.0.0-rc.15", - "@jupyterlab/mainmenu": "^3.0.0-rc.15", + "@jupyterlab/application": "^3.0.10", + "@jupyterlab/mainmenu": "^3.0.8", "@lumino/widgets": "^1.16.1" }, ``` diff --git a/server-extension/README.md b/server-extension/README.md index b5da2dd6..b28eb95a 100644 --- a/server-extension/README.md +++ b/server-extension/README.md @@ -18,13 +18,12 @@ example before diving into this one. Writing a JupyterLab extension usually starts from a configurable template. It can be downloaded with the [`cookiecutter`](https://cookiecutter.readthedocs.io/en/latest/) tool and the following command for an extension with a server part: - ```bash cookiecutter https://github.com/jupyterlab/extension-cookiecutter-ts ``` `cookiecutter` asks for some basic information that could for example be setup -like this (be careful to set _has\_server\_extension_ to _y_): +like this (be careful to set _has_server_extension_ to _y_): ```bash author_name []: my_name @@ -103,16 +102,19 @@ The entry point for the frontend extension is `src/index.ts`. The communication with the server extension is contained in another file `src/handler.ts`. So you need to import it: + ```ts // src/index.ts#L12-L12 import { requestAPI } from './handler'; ``` + In the `activate` function, the server extension is first called through a GET request on the endpoint _/jlab-ext-example/hello_. The response from the server is printed in the web browser console: + ```ts // src/index.ts#L36-L42 @@ -124,19 +126,23 @@ try { console.error(`Error on GET /jlab-ext-example/hello.\n${reason}`); } ``` + As the server response is not instantaneous, the request is done asynchronously using the `await` keyword: + ```ts // src/index.ts#L38-L38 const data = await requestAPI('hello'); ``` + To use that `await` keyword, the function must be declared as asynchronous using the `async` keyword: + ```ts // src/index.ts#L29-L33 @@ -146,11 +152,13 @@ activate: async ( launcher: ILauncher | null ) => { ``` + A GET request cannot carry data from the frontend to the server. To achieve that, you will need to execute a POST request. In this example, a POST request is sent to the _/jlab-ext-example/hello_ endpoint with the data `{name: 'George'}`: + ```ts // src/index.ts#L45-L56 @@ -158,7 +166,7 @@ const dataToSend = { name: 'George' }; try { const reply = await requestAPI('hello', { body: JSON.stringify(dataToSend), - method: 'POST' + method: 'POST', }); console.log(reply); } catch (reason) { @@ -167,6 +175,7 @@ try { ); } ``` + The difference with the GET request is the use of the `body` option to send data and the `method` option to set the appropriate HTTP method. @@ -178,6 +187,7 @@ the server, it needs to be stringified to be carried over by the request. The communication logic with the server is hidden in the `requestAPI` function. Its definition is : + ```ts // src/handler.ts#L12-L37 @@ -208,14 +218,17 @@ export async function requestAPI( return data; ``` + First the server settings are obtained from: + ```ts // src/handler.ts#L17-L17 const settings = ServerConnection.makeSettings(); ``` + This requires to add `@jupyterlab/services` to the package dependencies: @@ -225,14 +238,17 @@ jlpm add @jupyterlab/services Then the class `ServerConnection` can be imported: + ```ts // src/handler.ts#L3-L3 import { ServerConnection } from '@jupyterlab/services'; ``` + The next step is to build the full request URL: + ```ts // src/handler.ts#L18-L21 @@ -241,14 +257,17 @@ const requestUrl = URLExt.join( 'jlab-ext-example', endPoint ``` + To concatenate the various parts, the `URLExt` utility is imported: + ```ts // src/handler.ts#L1-L1 import { URLExt } from '@jupyterlab/coreutils'; ``` + This requires to add another dependency to the package: @@ -258,15 +277,18 @@ jlpm add @jupyterlab/coreutils You now have all the elements to make the request: + ```ts // src/handler.ts#L26-L26 response = await ServerConnection.makeRequest(requestUrl, init, settings); ``` + Finally, once the server response is obtained, its body is interpreted as JSON. And the resulting data is returned. + ```ts // src/handler.ts#L31-L37 @@ -278,9 +300,11 @@ if (!response.ok) { return data; ``` + This example also showcases how you can serve static files from the server extension. + ```ts // src/index.ts#L58-L79 @@ -294,7 +318,7 @@ commands.addCommand(command, { execute: () => { const widget = new IFrameWidget(); shell.add(widget, 'main'); - } + }, }); palette.addItem({ command, category: category }); @@ -303,10 +327,11 @@ if (launcher) { // Add launcher launcher.add({ command: command, - category: category + category: category, }); } ``` + Invoking the command (via the command palette or the launcher) will open a new tab with an `IFrame` that will display static content fetched from the server extension. @@ -520,7 +545,6 @@ data_files_spec = [ ("share/jupyter/labextensions/%s" % labext_name, str('.'), "install.json"), ("etc/jupyter/jupyter_notebook_config.d", "jupyter-config/jupyter_notebook_config.d", "jlab_ext_example.json"), ("etc/jupyter/jupyter_server_config.d", "jupyter-config/jupyter_server_config.d", "jlab_ext_example.json"), - ] long_description = (HERE / "README.md").read_text() @@ -581,38 +605,50 @@ if __name__ == "__main__": But in this case, it is a bit more complicated to build the frontend extension and ship it directly with the Python package. To deploy simultaneously the frontend and the backend, the frontend NPM package needs to be built and inserted in the Python package. This is -done using a special `cmdclass`: +done using a special a dedicated builder following [PEP 517](https://www.python.org/dev/peps/pep-0517) from package [jupyter-packaging](https://github.com/jupyter/jupyter-packaging). Its configuration is done in `pyproject.toml`: ```py -# setup.py#L39-L46 +# pyproject.toml -cmdclass = create_cmdclass( - "jsdeps", package_data_spec=package_data_spec, data_files_spec=data_files_spec -) +[build-system] +requires = ["jupyter_packaging~=0.10,<2", "jupyterlab~=3.0"] +build-backend = "jupyter_packaging.build_api" + +[tool.jupyter-packaging.options] +skip-if-exists = ["jlab_ext_example/labextension/static/style.js"] +ensured-targets = ["jlab_ext_example/labextension/static/style.js", "jlab_ext_example/labextension/package.json"] + +[tool.jupyter-packaging.builder] +factory = "jupyter_packaging.npm_builder" + +[tool.jupyter-packaging.build-args] +build_cmd = "build:prod" +npm = ["jlpm"] + +[tool.check-manifest] +ignore = ["jlab_ext_example/labextension/**", "yarn.lock", ".*", "package-lock.json"] -js_command = combine_commands( - install_npm(HERE, build_cmd="build:prod", npm=["jlpm"]), - ensure_targets(jstargets), -) ``` -Basically it will build the frontend NPM package: +It will build the frontend NPM package through its _factory_: ```py -# setup.py#L44-L44 +# pyproject.toml#L9-L14 + +[tool.jupyter-packaging.builder] +factory = "jupyter_packaging.npm_builder" -install_npm(HERE, build_cmd="build:prod", npm=["jlpm"]), +[tool.jupyter-packaging.build-args] +build_cmd = "build:prod" +npm = ["jlpm"] ``` It will ensure one of the generated files is `jlab_ext_example/labextension/package.json`: ```py -# setup.py#L23-L26 +# pyproject.toml#L7-L7 -# Representative files that should exist after a successful build -jstargets = [ - str(lab_path / "package.json"), -] +ensured-targets = ["jlab_ext_example/labextension/static/style.js", "jlab_ext_example/labextension/package.json"] ``` It will copy the NPM package in the Python package and force it to be copied in a place @@ -621,14 +657,14 @@ JupyterLab is looking for frontend extensions when the Python package is install ```py # setup.py#L25-L25 - ("share/jupyter/labextensions/%s" % labext_name, str(lab_path.relative_to(HERE)), "**"), +("share/jupyter/labextensions/%s" % labext_name, str(lab_path.relative_to(HERE)), "**"), ``` The last piece of configuration needed is the enabling of the server extension. This is done by copying the following JSON file: ```json5 -// jupyter-config/jlab_ext_example.json +// jupyter-config/jupyter_server_config.d/jlab_ext_example.json { "ServerApp": { @@ -649,7 +685,7 @@ in the appropriate jupyter folder (`etc/jupyter/jupyter_server_config.d`): ``` For backward compatibility with the classical notebook, the old version of that file is copied in - (`etc/jupyter/jupyter_notebook_config.d`): +(`etc/jupyter/jupyter_notebook_config.d`): ```py # setup.py#L27-L27 @@ -666,7 +702,7 @@ user about that dependency by adding the `discovery` metadata to your `package.j file: ```json5 -// package.json#L70-L80 +// package.json#L75-L85 "jupyterlab": { "discovery": { @@ -684,7 +720,7 @@ file: In this example, the extension requires a `server` extension: ```json5 -// package.json#L71-L71 +// package.json#L76-L76 "discovery": { ``` @@ -692,7 +728,7 @@ In this example, the extension requires a `server` extension: And that server extension is available through `pip`: ```json5 -// package.json#L72-L74 +// package.json#L77-L79 "server": { "managers": [ @@ -723,4 +759,3 @@ jupyter labextension develop . --overwrite # Rebuild extension Typescript source after making changes jlpm run build ``` - diff --git a/server-extension/setup.py b/server-extension/setup.py index 87296a1c..3d907acc 100644 --- a/server-extension/setup.py +++ b/server-extension/setup.py @@ -26,7 +26,6 @@ ("share/jupyter/labextensions/%s" % labext_name, str('.'), "install.json"), ("etc/jupyter/jupyter_notebook_config.d", "jupyter-config/jupyter_notebook_config.d", "jlab_ext_example.json"), ("etc/jupyter/jupyter_server_config.d", "jupyter-config/jupyter_server_config.d", "jlab_ext_example.json"), - ] long_description = (HERE / "README.md").read_text() diff --git a/settings/README.md b/settings/README.md index c2335066..b67e5fba 100644 --- a/settings/README.md +++ b/settings/README.md @@ -17,11 +17,13 @@ jlpm add @jupyterlab/settingregistry Once this is done, you can import the interface in your code. + ```ts // src/index.ts#L6-L6 import { ISettingRegistry } from '@jupyterlab/settingregistry'; ``` + To see how you can access the settings, let's have a look at `src/index.ts`. @@ -96,11 +98,13 @@ settings, your extension name must be structured as _package name_**:**_settings and the extension id is: + ```ts // src/index.ts#L12-L12 const PLUGIN_ID = '@jupyterlab-examples/settings:settings-example'; ``` + Therefore the settings file must be named `settings-example.json`. @@ -109,25 +113,26 @@ the `package.json` file in the `jupyterlab` section (here `schema`): ```json5 -// package.json#L70-L74 +// package.json#L75-L79 "jupyterlab": { "extension": true, "schemaDir": "schema", "outputDir": "jupyterlab_examples_settings/labextension" -} +}, ``` And you should not forget to add it to the files of the package: ```json5 -// package.json#L16-L20 +// package.json#L19-L24 "files": [ "lib/**/*.{d.ts,eot,gif,html,jpg,js,js.map,json,png,svg,woff2,ttf}", "schema/**/*.json", - "style/**/*.{css,eot,gif,html,jpg,json,png,svg,woff2,ttf}" + "style/**/*.{css,eot,gif,html,jpg,json,png,svg,woff2,ttf}", + "style/index.js" ], ``` @@ -183,7 +188,7 @@ const extension: JupyterFrontEndPlugin = { // Programmatically change a setting Promise.all([ setting.set('flag', !flag), - setting.set('limit', limit + 1) + setting.set('limit', limit + 1), ]) .then(() => { const newLimit = setting.get('limit').composite as number; @@ -192,12 +197,12 @@ const extension: JupyterFrontEndPlugin = { `Settings Example extension: Limit is set to '${newLimit}' and flag to '${newFlag}'` ); }) - .catch(reason => { + .catch((reason) => { console.error( `Something went wrong when changing the settings.\n${reason}` ); }); - } + }, }); // Create a menu @@ -207,15 +212,15 @@ const extension: JupyterFrontEndPlugin = { // Add the command to the menu settingsMenu.addItem({ - command: COMMAND_ID + command: COMMAND_ID, }); }) - .catch(reason => { + .catch((reason) => { console.error( `Something went wrong when reading the settings.\n${reason}` ); }); - } + }, }; ``` @@ -238,6 +243,7 @@ JSON file). After getting the setting, you need to access the `composite` attribute to get its value and specify the type explicitly. + ```ts // src/index.ts#L37-L45 @@ -251,6 +257,7 @@ function loadSetting(setting: ISettingRegistry.ISettings): void { ); } ``` + > `composite` means the setting value is the composition of the default > and the user values. @@ -259,11 +266,13 @@ To react at a setting change by the user, you should use the signal `changed`. In this case, when that signal is emitted the function `loadSetting` is called with the new settings. + ```ts // src/index.ts#L55-L55 setting.changed.connect(loadSetting); ``` + Finally, to demonstrate the programmatic change of a setting, a command to toggle the `flag` and increment the `limit` settings is implemented. @@ -276,7 +285,7 @@ execute: () => { // Programmatically change a setting Promise.all([ setting.set('flag', !flag), - setting.set('limit', limit + 1) + setting.set('limit', limit + 1), ]) .then(() => { const newLimit = setting.get('limit').composite as number; @@ -285,12 +294,12 @@ execute: () => { `Settings Example extension: Limit is set to '${newLimit}' and flag to '${newFlag}'` ); }) - .catch(reason => { + .catch((reason) => { console.error( `Something went wrong when changing the settings.\n${reason}` ); }); -} +}, ``` @@ -302,7 +311,7 @@ new value. // src/index.ts#L63-L64 setting.set('flag', !flag), -setting.set('limit', limit + 1) +setting.set('limit', limit + 1), ``` @@ -319,7 +328,7 @@ mainMenu.addMenu(settingsMenu, { rank: 80 }); // Add the command to the menu settingsMenu.addItem({ - command: COMMAND_ID + command: COMMAND_ID, }); ``` diff --git a/signals/README.md b/signals/README.md index 0b7f7f78..4f1b0ce9 100644 --- a/signals/README.md +++ b/signals/README.md @@ -81,7 +81,7 @@ constructor(options = { node: document.createElement('button') }) { // src/button.ts#L28-L30 private _count: ICount = { - clickCount: 0 + clickCount: 0, }; ``` diff --git a/widgets/README.md b/widgets/README.md index 9238d8e1..cc3d7b4f 100644 --- a/widgets/README.md +++ b/widgets/README.md @@ -49,7 +49,7 @@ in this example: execute: () => { const widget = new ExampleWidget(); shell.add(widget, 'main'); -} +}, ``` From 78c941061a159248e0ff0a1861bc1036eaff8405 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20Collonval?= Date: Wed, 7 Jul 2021 17:18:41 +0200 Subject: [PATCH 06/11] Apply upgrade script --- command-palette/package.json | 2 +- command-palette/setup.py | 2 +- commands/package.json | 2 +- commands/setup.py | 2 +- context-menu/package.json | 6 +- context-menu/setup.py | 2 +- custom-log-console/package.json | 12 +-- custom-log-console/setup.py | 2 +- datagrid/package.json | 6 +- datagrid/setup.py | 2 +- hello-world/README.md | 2 +- hello-world/package.json | 2 +- hello-world/setup.py | 2 +- kernel-messaging/package.json | 10 +-- kernel-messaging/setup.py | 2 +- kernel-output/package.json | 10 +-- kernel-output/setup.py | 2 +- launcher/package.json | 8 +- launcher/setup.py | 2 +- log-messages/package.json | 14 ++-- log-messages/setup.py | 2 +- main-menu/README.md | 4 +- main-menu/package.json | 4 +- main-menu/setup.py | 2 +- react-widget/package.json | 4 +- react-widget/setup.py | 2 +- server-extension/README.md | 17 ++-- .../jlab_ext_example.json | 0 .../jlab_ext_example.json | 0 server-extension/package.json | 6 +- server-extension/setup.py | 7 +- settings/package.json | 6 +- settings/setup.py | 2 +- signals/package.json | 10 +-- signals/setup.py | 2 +- state/package.json | 6 +- state/setup.py | 2 +- toolbar-button/.prettierrc | 5 -- toolbar-button/package.json | 29 +++---- toolbar-button/pyproject.toml | 18 ++++- toolbar-button/setup.py | 81 ++++++++----------- widgets/package.json | 4 +- widgets/setup.py | 2 +- 43 files changed, 153 insertions(+), 154 deletions(-) rename server-extension/jupyter-config/{jupyter_notebook_config.d => nb-config}/jlab_ext_example.json (100%) rename server-extension/jupyter-config/{jupyter_server_config.d => server-config}/jlab_ext_example.json (100%) delete mode 100644 toolbar-button/.prettierrc diff --git a/command-palette/package.json b/command-palette/package.json index ad568540..9bfee2e9 100644 --- a/command-palette/package.json +++ b/command-palette/package.json @@ -48,7 +48,7 @@ "watch:src": "tsc -w" }, "dependencies": { - "@jupyterlab/application": "^3.0.10" + "@jupyterlab/application": "^3.0.11" }, "devDependencies": { "@jupyterlab/builder": "^3.0.0", diff --git a/command-palette/setup.py b/command-palette/setup.py index fe4dbff7..42985fda 100644 --- a/command-palette/setup.py +++ b/command-palette/setup.py @@ -11,7 +11,7 @@ # The name of the project name = "jupyterlab_examples_command_palette" -lab_path = (HERE / name / "labextension") +lab_path = (HERE / name.replace("-", "_") / "labextension") # Representative files that should exist after a successful build ensured_targets = [ diff --git a/commands/package.json b/commands/package.json index 0451f480..98b15e7a 100644 --- a/commands/package.json +++ b/commands/package.json @@ -48,7 +48,7 @@ "watch:src": "tsc -w" }, "dependencies": { - "@jupyterlab/application": "^3.0.10" + "@jupyterlab/application": "^3.0.11" }, "devDependencies": { "@jupyterlab/builder": "^3.0.0", diff --git a/commands/setup.py b/commands/setup.py index 4ec26537..7611a951 100644 --- a/commands/setup.py +++ b/commands/setup.py @@ -11,7 +11,7 @@ # The name of the project name = "jupyterlab_examples_commands" -lab_path = (HERE / name / "labextension") +lab_path = (HERE / name.replace("-", "_") / "labextension") # Representative files that should exist after a successful build ensured_targets = [ diff --git a/context-menu/package.json b/context-menu/package.json index d5d84755..dff27042 100644 --- a/context-menu/package.json +++ b/context-menu/package.json @@ -48,9 +48,9 @@ "watch:src": "tsc -w" }, "dependencies": { - "@jupyterlab/application": "^3.0.10", - "@jupyterlab/apputils": "^3.0.8", - "@jupyterlab/filebrowser": "^3.0.10", + "@jupyterlab/application": "^3.0.11", + "@jupyterlab/apputils": "^3.0.9", + "@jupyterlab/filebrowser": "^3.0.11", "@jupyterlab/ui-components": "^3.0.7" }, "devDependencies": { diff --git a/context-menu/setup.py b/context-menu/setup.py index cef40453..e881185b 100644 --- a/context-menu/setup.py +++ b/context-menu/setup.py @@ -11,7 +11,7 @@ # The name of the project name = "jupyterlab_examples_context_menu" -lab_path = (HERE / name / "labextension") +lab_path = (HERE / name.replace("-", "_") / "labextension") # Representative files that should exist after a successful build ensured_targets = [ diff --git a/custom-log-console/package.json b/custom-log-console/package.json index 0a4bc619..9b9f6dd8 100644 --- a/custom-log-console/package.json +++ b/custom-log-console/package.json @@ -48,13 +48,13 @@ "watch:src": "tsc -w" }, "dependencies": { - "@jupyterlab/application": "^3.0.10", - "@jupyterlab/apputils": "^3.0.8", + "@jupyterlab/application": "^3.0.11", + "@jupyterlab/apputils": "^3.0.9", "@jupyterlab/coreutils": "^5.0.6", - "@jupyterlab/logconsole": "^3.0.9", - "@jupyterlab/mainmenu": "^3.0.8", - "@jupyterlab/nbformat": "^3.0.5", - "@jupyterlab/rendermime": "^3.0.9", + "@jupyterlab/logconsole": "^3.0.10", + "@jupyterlab/mainmenu": "^3.0.9", + "@jupyterlab/nbformat": "^3.0.6", + "@jupyterlab/rendermime": "^3.0.10", "@jupyterlab/ui-components": "^3.0.7", "@lumino/coreutils": "^1.5.3", "@lumino/widgets": "^1.16.1" diff --git a/custom-log-console/setup.py b/custom-log-console/setup.py index 277528f0..4f66adf8 100644 --- a/custom-log-console/setup.py +++ b/custom-log-console/setup.py @@ -11,7 +11,7 @@ # The name of the project name = "jupyterlab_examples_custom_log_console" -lab_path = (HERE / name / "labextension") +lab_path = (HERE / name.replace("-", "_") / "labextension") # Representative files that should exist after a successful build ensured_targets = [ diff --git a/datagrid/package.json b/datagrid/package.json index 76ad0fc3..83d1745e 100644 --- a/datagrid/package.json +++ b/datagrid/package.json @@ -48,9 +48,9 @@ "watch:src": "tsc -w" }, "dependencies": { - "@jupyterlab/application": "^3.0.10", - "@jupyterlab/mainmenu": "^3.0.8", - "@jupyterlab/translation": "^3.0.8", + "@jupyterlab/application": "^3.0.11", + "@jupyterlab/mainmenu": "^3.0.9", + "@jupyterlab/translation": "^3.0.9", "@lumino/algorithm": "^1.3.3", "@lumino/coreutils": "^1.5.3", "@lumino/datagrid": "^0.14.1", diff --git a/datagrid/setup.py b/datagrid/setup.py index 3a604541..03037738 100644 --- a/datagrid/setup.py +++ b/datagrid/setup.py @@ -11,7 +11,7 @@ # The name of the project name = "jupyterlab_examples_datagrid" -lab_path = (HERE / name / "labextension") +lab_path = (HERE / name.replace("-", "_") / "labextension") # Representative files that should exist after a successful build ensured_targets = [ diff --git a/hello-world/README.md b/hello-world/README.md index 7cf02b4b..bfbae171 100644 --- a/hello-world/README.md +++ b/hello-world/README.md @@ -121,7 +121,7 @@ package is declared in the file `package.json`: // package.json#L50-L52 "dependencies": { - "@jupyterlab/application": "^3.0.10" + "@jupyterlab/application": "^3.0.11" }, ``` diff --git a/hello-world/package.json b/hello-world/package.json index a238f347..612a817f 100644 --- a/hello-world/package.json +++ b/hello-world/package.json @@ -48,7 +48,7 @@ "watch:src": "tsc -w" }, "dependencies": { - "@jupyterlab/application": "^3.0.10" + "@jupyterlab/application": "^3.0.11" }, "devDependencies": { "@jupyterlab/builder": "^3.0.0", diff --git a/hello-world/setup.py b/hello-world/setup.py index 445380ae..6edac4aa 100644 --- a/hello-world/setup.py +++ b/hello-world/setup.py @@ -11,7 +11,7 @@ # The name of the project name = "jupyterlab_examples_hello_world" -lab_path = (HERE / name / "labextension") +lab_path = (HERE / name.replace("-", "_") / "labextension") # Representative files that should exist after a successful build ensured_targets = [ diff --git a/kernel-messaging/package.json b/kernel-messaging/package.json index 198d0745..68a813e8 100644 --- a/kernel-messaging/package.json +++ b/kernel-messaging/package.json @@ -48,11 +48,11 @@ "watch:src": "tsc -w" }, "dependencies": { - "@jupyterlab/application": "^3.0.10", - "@jupyterlab/launcher": "^3.0.8", - "@jupyterlab/mainmenu": "^3.0.8", - "@jupyterlab/nbformat": "^3.0.5", - "@jupyterlab/translation": "^3.0.8", + "@jupyterlab/application": "^3.0.11", + "@jupyterlab/launcher": "^3.0.9", + "@jupyterlab/mainmenu": "^3.0.9", + "@jupyterlab/nbformat": "^3.0.6", + "@jupyterlab/translation": "^3.0.9", "@lumino/algorithm": "^1.3.3", "@lumino/coreutils": "^1.5.3", "@lumino/datagrid": "^0.5.2", diff --git a/kernel-messaging/setup.py b/kernel-messaging/setup.py index 0313f347..afb363b4 100644 --- a/kernel-messaging/setup.py +++ b/kernel-messaging/setup.py @@ -11,7 +11,7 @@ # The name of the project name = "jupyterlab_examples_kernel_messaging" -lab_path = (HERE / name / "labextension") +lab_path = (HERE / name.replace("-", "_") / "labextension") # Representative files that should exist after a successful build ensured_targets = [ diff --git a/kernel-output/package.json b/kernel-output/package.json index dddaca93..8b6de541 100644 --- a/kernel-output/package.json +++ b/kernel-output/package.json @@ -48,11 +48,11 @@ "watch:src": "tsc -w" }, "dependencies": { - "@jupyterlab/application": "^3.0.10", - "@jupyterlab/launcher": "^3.0.8", - "@jupyterlab/mainmenu": "^3.0.8", - "@jupyterlab/outputarea": "^3.0.9", - "@jupyterlab/translation": "^3.0.8", + "@jupyterlab/application": "^3.0.11", + "@jupyterlab/launcher": "^3.0.9", + "@jupyterlab/mainmenu": "^3.0.9", + "@jupyterlab/outputarea": "^3.0.10", + "@jupyterlab/translation": "^3.0.9", "@lumino/algorithm": "^1.3.3", "@lumino/coreutils": "^1.5.3", "@lumino/datagrid": "^0.3.1", diff --git a/kernel-output/setup.py b/kernel-output/setup.py index 1300a605..68187838 100644 --- a/kernel-output/setup.py +++ b/kernel-output/setup.py @@ -11,7 +11,7 @@ # The name of the project name = "jupyterlab_examples_kernel_output" -lab_path = (HERE / name / "labextension") +lab_path = (HERE / name.replace("-", "_") / "labextension") # Representative files that should exist after a successful build ensured_targets = [ diff --git a/launcher/package.json b/launcher/package.json index b1aeee64..d14bdeb6 100644 --- a/launcher/package.json +++ b/launcher/package.json @@ -48,10 +48,10 @@ "watch:src": "tsc -w" }, "dependencies": { - "@jupyterlab/application": "^3.0.10", - "@jupyterlab/filebrowser": "^3.0.10", - "@jupyterlab/launcher": "^3.0.8", - "@jupyterlab/mainmenu": "^3.0.8" + "@jupyterlab/application": "^3.0.11", + "@jupyterlab/filebrowser": "^3.0.11", + "@jupyterlab/launcher": "^3.0.9", + "@jupyterlab/mainmenu": "^3.0.9" }, "devDependencies": { "@jupyterlab/builder": "^3.0.0", diff --git a/launcher/setup.py b/launcher/setup.py index 32969989..3afcea9e 100644 --- a/launcher/setup.py +++ b/launcher/setup.py @@ -11,7 +11,7 @@ # The name of the project name = "jupyterlab_examples_launcher" -lab_path = (HERE / name / "labextension") +lab_path = (HERE / name.replace("-", "_") / "labextension") # Representative files that should exist after a successful build ensured_targets = [ diff --git a/log-messages/package.json b/log-messages/package.json index 769def56..1029a261 100644 --- a/log-messages/package.json +++ b/log-messages/package.json @@ -48,14 +48,14 @@ "watch:src": "tsc -w" }, "dependencies": { - "@jupyterlab/application": "^3.0.10", - "@jupyterlab/apputils": "^3.0.8", + "@jupyterlab/application": "^3.0.11", + "@jupyterlab/apputils": "^3.0.9", "@jupyterlab/coreutils": "^5.0.6", - "@jupyterlab/logconsole": "^3.0.9", - "@jupyterlab/mainmenu": "^3.0.8", - "@jupyterlab/nbformat": "^3.0.5", - "@jupyterlab/notebook": "^3.0.10", - "@jupyterlab/rendermime": "^3.0.9", + "@jupyterlab/logconsole": "^3.0.10", + "@jupyterlab/mainmenu": "^3.0.9", + "@jupyterlab/nbformat": "^3.0.6", + "@jupyterlab/notebook": "^3.0.11", + "@jupyterlab/rendermime": "^3.0.10", "@jupyterlab/ui-components": "^3.0.7", "@lumino/coreutils": "^1.5.3", "@lumino/widgets": "^1.16.1" diff --git a/log-messages/setup.py b/log-messages/setup.py index e8c00456..30b673be 100644 --- a/log-messages/setup.py +++ b/log-messages/setup.py @@ -11,7 +11,7 @@ # The name of the project name = "jupyterlab_examples_log_messages" -lab_path = (HERE / name / "labextension") +lab_path = (HERE / name.replace("-", "_") / "labextension") # Representative files that should exist after a successful build ensured_targets = [ diff --git a/main-menu/README.md b/main-menu/README.md index 1b8e0457..1b7b368c 100644 --- a/main-menu/README.md +++ b/main-menu/README.md @@ -92,8 +92,8 @@ After the execution of that command, `package.json` should list them in the // package.json#L50-L54 "dependencies": { - "@jupyterlab/application": "^3.0.10", - "@jupyterlab/mainmenu": "^3.0.8", + "@jupyterlab/application": "^3.0.11", + "@jupyterlab/mainmenu": "^3.0.9", "@lumino/widgets": "^1.16.1" }, ``` diff --git a/main-menu/package.json b/main-menu/package.json index 92319a4a..b4475861 100644 --- a/main-menu/package.json +++ b/main-menu/package.json @@ -48,8 +48,8 @@ "watch:src": "tsc -w" }, "dependencies": { - "@jupyterlab/application": "^3.0.10", - "@jupyterlab/mainmenu": "^3.0.8", + "@jupyterlab/application": "^3.0.11", + "@jupyterlab/mainmenu": "^3.0.9", "@lumino/widgets": "^1.16.1" }, "devDependencies": { diff --git a/main-menu/setup.py b/main-menu/setup.py index f750dc4a..bdc4fd92 100644 --- a/main-menu/setup.py +++ b/main-menu/setup.py @@ -11,7 +11,7 @@ # The name of the project name = "jupyterlab_examples_main_menu" -lab_path = (HERE / name / "labextension") +lab_path = (HERE / name.replace("-", "_") / "labextension") # Representative files that should exist after a successful build ensured_targets = [ diff --git a/react-widget/package.json b/react-widget/package.json index a4a3aac2..0dd59487 100644 --- a/react-widget/package.json +++ b/react-widget/package.json @@ -48,8 +48,8 @@ "watch:src": "tsc -w" }, "dependencies": { - "@jupyterlab/application": "^3.0.10", - "@jupyterlab/launcher": "^3.0.8", + "@jupyterlab/application": "^3.0.11", + "@jupyterlab/launcher": "^3.0.9", "@jupyterlab/ui-components": "^3.0.7" }, "devDependencies": { diff --git a/react-widget/setup.py b/react-widget/setup.py index dcc1410f..7f9a5bc8 100644 --- a/react-widget/setup.py +++ b/react-widget/setup.py @@ -11,7 +11,7 @@ # The name of the project name = "jupyterlab_examples_react_widget" -lab_path = (HERE / name / "labextension") +lab_path = (HERE / name.replace("-", "_") / "labextension") # Representative files that should exist after a successful build ensured_targets = [ diff --git a/server-extension/README.md b/server-extension/README.md index b28eb95a..9a9c493d 100644 --- a/server-extension/README.md +++ b/server-extension/README.md @@ -530,7 +530,7 @@ HERE = Path(__file__).parent.resolve() # The name of the project name = "jlab_ext_example" -lab_path = (HERE / name / "labextension") +lab_path = (HERE / name.replace("-", "_") / "labextension") # Representative files that should exist after a successful build ensured_targets = [ @@ -543,8 +543,9 @@ labext_name = "@jupyterlab-examples/server-extension" data_files_spec = [ ("share/jupyter/labextensions/%s" % labext_name, str(lab_path.relative_to(HERE)), "**"), ("share/jupyter/labextensions/%s" % labext_name, str('.'), "install.json"), - ("etc/jupyter/jupyter_notebook_config.d", "jupyter-config/jupyter_notebook_config.d", "jlab_ext_example.json"), - ("etc/jupyter/jupyter_server_config.d", "jupyter-config/jupyter_server_config.d", "jlab_ext_example.json"), + ("etc/jupyter/jupyter_server_config.d", "jupyter-config/server-config", "jlab_ext_example.json"), + # For backward compatibility with notebook server + ("etc/jupyter/jupyter_notebook_config.d", "jupyter-config/nb-config", "jlab_ext_example.json"), ] long_description = (HERE / "README.md").read_text() @@ -664,7 +665,7 @@ The last piece of configuration needed is the enabling of the server extension. done by copying the following JSON file: ```json5 -// jupyter-config/jupyter_server_config.d/jlab_ext_example.json +// jupyter-config/server-config/jlab_ext_example.json { "ServerApp": { @@ -679,18 +680,18 @@ done by copying the following JSON file: in the appropriate jupyter folder (`etc/jupyter/jupyter_server_config.d`): ```py -# setup.py#L28-L28 +# setup.py#L27-L27 -("etc/jupyter/jupyter_server_config.d", "jupyter-config/jupyter_server_config.d", "jlab_ext_example.json"), +("etc/jupyter/jupyter_server_config.d", "jupyter-config/server-config", "jlab_ext_example.json"), ``` For backward compatibility with the classical notebook, the old version of that file is copied in (`etc/jupyter/jupyter_notebook_config.d`): ```py -# setup.py#L27-L27 +# setup.py#L29-L29 -("etc/jupyter/jupyter_notebook_config.d", "jupyter-config/jupyter_notebook_config.d", "jlab_ext_example.json"), +("etc/jupyter/jupyter_notebook_config.d", "jupyter-config/nb-config", "jlab_ext_example.json"), ``` ### JupyterLab Extension Manager diff --git a/server-extension/jupyter-config/jupyter_notebook_config.d/jlab_ext_example.json b/server-extension/jupyter-config/nb-config/jlab_ext_example.json similarity index 100% rename from server-extension/jupyter-config/jupyter_notebook_config.d/jlab_ext_example.json rename to server-extension/jupyter-config/nb-config/jlab_ext_example.json diff --git a/server-extension/jupyter-config/jupyter_server_config.d/jlab_ext_example.json b/server-extension/jupyter-config/server-config/jlab_ext_example.json similarity index 100% rename from server-extension/jupyter-config/jupyter_server_config.d/jlab_ext_example.json rename to server-extension/jupyter-config/server-config/jlab_ext_example.json diff --git a/server-extension/package.json b/server-extension/package.json index a52b9b3d..2ce0dbf7 100644 --- a/server-extension/package.json +++ b/server-extension/package.json @@ -48,10 +48,10 @@ "watch:src": "tsc -w" }, "dependencies": { - "@jupyterlab/application": "^3.0.10", + "@jupyterlab/application": "^3.0.11", "@jupyterlab/coreutils": "^5.0.6", - "@jupyterlab/launcher": "^3.0.8", - "@jupyterlab/services": "^6.0.8" + "@jupyterlab/launcher": "^3.0.9", + "@jupyterlab/services": "^6.0.9" }, "devDependencies": { "@jupyterlab/builder": "^3.0.0", diff --git a/server-extension/setup.py b/server-extension/setup.py index 3d907acc..187e4c8b 100644 --- a/server-extension/setup.py +++ b/server-extension/setup.py @@ -11,7 +11,7 @@ # The name of the project name = "jlab_ext_example" -lab_path = (HERE / name / "labextension") +lab_path = (HERE / name.replace("-", "_") / "labextension") # Representative files that should exist after a successful build ensured_targets = [ @@ -24,8 +24,9 @@ data_files_spec = [ ("share/jupyter/labextensions/%s" % labext_name, str(lab_path.relative_to(HERE)), "**"), ("share/jupyter/labextensions/%s" % labext_name, str('.'), "install.json"), - ("etc/jupyter/jupyter_notebook_config.d", "jupyter-config/jupyter_notebook_config.d", "jlab_ext_example.json"), - ("etc/jupyter/jupyter_server_config.d", "jupyter-config/jupyter_server_config.d", "jlab_ext_example.json"), + ("etc/jupyter/jupyter_server_config.d", "jupyter-config/server-config", "jlab_ext_example.json"), + # For backward compatibility with notebook server + ("etc/jupyter/jupyter_notebook_config.d", "jupyter-config/nb-config", "jlab_ext_example.json"), ] long_description = (HERE / "README.md").read_text() diff --git a/settings/package.json b/settings/package.json index 77336923..56938118 100644 --- a/settings/package.json +++ b/settings/package.json @@ -49,9 +49,9 @@ "watch:src": "tsc -w" }, "dependencies": { - "@jupyterlab/application": "^3.0.10", - "@jupyterlab/mainmenu": "^3.0.8", - "@jupyterlab/settingregistry": "^3.0.5", + "@jupyterlab/application": "^3.0.11", + "@jupyterlab/mainmenu": "^3.0.9", + "@jupyterlab/settingregistry": "^3.0.6", "@lumino/widgets": "^1.16.1" }, "devDependencies": { diff --git a/settings/setup.py b/settings/setup.py index f6ced7ed..db7f9389 100644 --- a/settings/setup.py +++ b/settings/setup.py @@ -11,7 +11,7 @@ # The name of the project name = "jupyterlab_examples_settings" -lab_path = (HERE / name / "labextension") +lab_path = (HERE / name.replace("-", "_") / "labextension") # Representative files that should exist after a successful build ensured_targets = [ diff --git a/signals/package.json b/signals/package.json index fe3c9abc..7bab35cd 100644 --- a/signals/package.json +++ b/signals/package.json @@ -48,11 +48,11 @@ "watch:src": "tsc -w" }, "dependencies": { - "@jupyterlab/application": "^3.0.10", - "@jupyterlab/apputils": "^3.0.8", - "@jupyterlab/launcher": "^3.0.8", - "@jupyterlab/mainmenu": "^3.0.8", - "@jupyterlab/translation": "^3.0.8", + "@jupyterlab/application": "^3.0.11", + "@jupyterlab/apputils": "^3.0.9", + "@jupyterlab/launcher": "^3.0.9", + "@jupyterlab/mainmenu": "^3.0.9", + "@jupyterlab/translation": "^3.0.9", "@lumino/algorithm": "^1.3.3", "@lumino/coreutils": "^1.5.3", "@lumino/datagrid": "^0.3.1", diff --git a/signals/setup.py b/signals/setup.py index 4b629a67..412d2a3a 100644 --- a/signals/setup.py +++ b/signals/setup.py @@ -11,7 +11,7 @@ # The name of the project name = "jupyterlab_examples_signals" -lab_path = (HERE / name / "labextension") +lab_path = (HERE / name.replace("-", "_") / "labextension") # Representative files that should exist after a successful build ensured_targets = [ diff --git a/state/package.json b/state/package.json index 1352a3a3..a4e1d4fd 100644 --- a/state/package.json +++ b/state/package.json @@ -48,9 +48,9 @@ "watch:src": "tsc -w" }, "dependencies": { - "@jupyterlab/application": "^3.0.10", - "@jupyterlab/apputils": "^3.0.8", - "@jupyterlab/statedb": "^3.0.5", + "@jupyterlab/application": "^3.0.11", + "@jupyterlab/apputils": "^3.0.9", + "@jupyterlab/statedb": "^3.0.6", "@lumino/coreutils": "^1.5.3" }, "devDependencies": { diff --git a/state/setup.py b/state/setup.py index e1f2e7e5..0fc384fb 100644 --- a/state/setup.py +++ b/state/setup.py @@ -11,7 +11,7 @@ # The name of the project name = "jupyterlab_examples_state" -lab_path = (HERE / name / "labextension") +lab_path = (HERE / name.replace("-", "_") / "labextension") # Representative files that should exist after a successful build ensured_targets = [ diff --git a/toolbar-button/.prettierrc b/toolbar-button/.prettierrc deleted file mode 100644 index b0a179d4..00000000 --- a/toolbar-button/.prettierrc +++ /dev/null @@ -1,5 +0,0 @@ -{ - "singleQuote": true, - "trailingComma": "none", - "arrowParens": "avoid" -} diff --git a/toolbar-button/package.json b/toolbar-button/package.json index 5f438f3e..cef7c8da 100644 --- a/toolbar-button/package.json +++ b/toolbar-button/package.json @@ -18,7 +18,8 @@ }, "files": [ "lib/**/*.{d.ts,eot,gif,html,jpg,js,js.map,json,png,svg,woff2,ttf}", - "style/**/*.{css,.js,eot,gif,html,jpg,json,png,svg,woff2,ttf}" + "style/**/*.{css,.js,eot,gif,html,jpg,json,png,svg,woff2,ttf}", + "style/index.js" ], "main": "lib/index.js", "types": "lib/index.d.ts", @@ -29,35 +30,35 @@ }, "scripts": { "build": "jlpm run build:lib && jlpm run build:labextension:dev", - "build:prod": "jlpm run clean && jlpm run build:lib && jlpm run build:labextension", "build:labextension": "jupyter labextension build .", "build:labextension:dev": "jupyter labextension build --development True .", "build:lib": "tsc", + "build:prod": "jlpm run clean && jlpm run build:lib && jlpm run build:labextension", "clean": "jlpm run clean:lib", - "clean:lib": "rimraf lib tsconfig.tsbuildinfo", - "clean:labextension": "rimraf jupyterlab_examples_toolbar_button/labextension", "clean:all": "jlpm run clean:lib && jlpm run clean:labextension", + "clean:labextension": "rimraf jupyterlab_examples_toolbar_button/labextension", + "clean:lib": "rimraf lib tsconfig.tsbuildinfo", "eslint": "eslint . --ext .ts,.tsx --fix", "eslint:check": "eslint . --ext .ts,.tsx", "install:extension": "jlpm run build", "watch": "run-p watch:src watch:labextension", - "watch:src": "tsc -w", - "watch:labextension": "jupyter labextension watch ." + "watch:labextension": "jupyter labextension watch .", + "watch:src": "tsc -w" }, "dependencies": { - "@jupyterlab/application": "^3.0.0" + "@jupyterlab/application": "^3.0.11" }, "devDependencies": { "@jupyterlab/builder": "^3.0.0", - "@typescript-eslint/eslint-plugin": "^2.27.0", - "@typescript-eslint/parser": "^2.27.0", - "eslint": "^7.5.0", - "eslint-config-prettier": "^6.10.1", + "@typescript-eslint/eslint-plugin": "^4.8.1", + "@typescript-eslint/parser": "^4.8.1", + "eslint": "^7.14.0", + "eslint-config-prettier": "^6.15.0", "eslint-plugin-jsdoc": "^22.0.0", - "eslint-plugin-prettier": "^3.1.2", + "eslint-plugin-prettier": "^3.1.4", "eslint-plugin-react": "^7.18.3", "npm-run-all": "^4.1.5", - "prettier": "^1.19.0", + "prettier": "^2.1.1", "rimraf": "^3.0.2", "typescript": "~4.1.3" }, @@ -70,4 +71,4 @@ "extension": true, "outputDir": "jupyterlab_examples_toolbar_button/labextension" } -} +} \ No newline at end of file diff --git a/toolbar-button/pyproject.toml b/toolbar-button/pyproject.toml index ba04c53f..fb6a5057 100644 --- a/toolbar-button/pyproject.toml +++ b/toolbar-button/pyproject.toml @@ -1,3 +1,17 @@ [build-system] -requires = ["jupyter_packaging~=0.7.9", "jupyterlab~=3.0", "setuptools>=40.8.0", "wheel"] -build-backend = "setuptools.build_meta" +requires = ["jupyter_packaging~=0.10,<2", "jupyterlab~=3.0"] +build-backend = "jupyter_packaging.build_api" + +[tool.jupyter-packaging.options] +skip-if-exists = ["jupyterlab_examples_toolbar_button/labextension/static/style.js"] +ensured-targets = ["jupyterlab_examples_toolbar_button/labextension/static/style.js", "jupyterlab_examples_toolbar_button/labextension/package.json"] + +[tool.jupyter-packaging.builder] +factory = "jupyter_packaging.npm_builder" + +[tool.jupyter-packaging.build-args] +build_cmd = "build:prod" +npm = ["jlpm"] + +[tool.check-manifest] +ignore = ["jupyterlab_examples_toolbar_button/labextension/**", "yarn.lock", ".*", "package-lock.json"] diff --git a/toolbar-button/setup.py b/toolbar-button/setup.py index b6b95355..7e15f7b1 100644 --- a/toolbar-button/setup.py +++ b/toolbar-button/setup.py @@ -2,79 +2,52 @@ jupyterlab_examples_toolbar_button setup """ import json -import os +from pathlib import Path -from jupyter_packaging import ( - create_cmdclass, install_npm, ensure_targets, - combine_commands, skip_if_exists -) import setuptools -HERE = os.path.abspath(os.path.dirname(__file__)) +HERE = Path(__file__).parent.resolve() # The name of the project -name="jupyterlab_examples_toolbar_button" - -# Get our version -with open(os.path.join(HERE, 'package.json')) as f: - version = json.load(f)['version'] +name = "jupyterlab_examples_toolbar_button" -lab_path = os.path.join(HERE, name, "labextension") +lab_path = (HERE / name.replace("-", "_") / "labextension") # Representative files that should exist after a successful build -jstargets = [ - os.path.join(lab_path, "package.json"), +ensured_targets = [ + str(lab_path / "package.json"), + str(lab_path / "static/style.js") ] -package_data_spec = { - name: [ - "*" - ] -} - labext_name = "@jupyterlab-examples/toolbar-button" data_files_spec = [ - ("share/jupyter/labextensions/%s" % labext_name, lab_path, "**"), - ("share/jupyter/labextensions/%s" % labext_name, HERE, "install.json"), + ("share/jupyter/labextensions/%s" % labext_name, str(lab_path.relative_to(HERE)), "**"), + ("share/jupyter/labextensions/%s" % labext_name, str('.'), "install.json"), ] -cmdclass = create_cmdclass("jsdeps", - package_data_spec=package_data_spec, - data_files_spec=data_files_spec -) - -js_command = combine_commands( - install_npm(HERE, build_cmd="build:prod", npm=["jlpm"]), - ensure_targets(jstargets), -) - -is_repo = os.path.exists(os.path.join(HERE, ".git")) -if is_repo: - cmdclass["jsdeps"] = js_command -else: - cmdclass["jsdeps"] = skip_if_exists(jstargets, js_command) +long_description = (HERE / "README.md").read_text() -with open("README.md", "r") as fh: - long_description = fh.read() +# Get the package info from package.json +pkg_json = json.loads((HERE / "package.json").read_bytes()) setup_args = dict( name=name, - version=version, - url="https://github.com/jupyterlab/extension-examples.git", - author="Project Jupyter Contributors", - description="minimal lab example", - long_description= long_description, + version=pkg_json["version"], + url=pkg_json["homepage"], + author=pkg_json["author"]["name"], + author_email=pkg_json["author"]["email"], + description=pkg_json["description"], + license=pkg_json["license"], + long_description=long_description, long_description_content_type="text/markdown", - cmdclass= cmdclass, packages=setuptools.find_packages(), install_requires=[ - "jupyterlab~=3.0", + "jupyter_server>=1.6,<2" ], zip_safe=False, include_package_data=True, python_requires=">=3.6", - license="BSD-3-Clause", platforms="Linux, Mac OS X, Windows", keywords=["Jupyter", "JupyterLab", "JupyterLab3"], classifiers=[ @@ -84,10 +57,24 @@ "Programming Language :: Python :: 3.6", "Programming Language :: Python :: 3.7", "Programming Language :: Python :: 3.8", + "Programming Language :: Python :: 3.9", "Framework :: Jupyter", ], ) +try: + from jupyter_packaging import ( + wrap_installers, + npm_builder, + get_data_files + ) + post_develop = npm_builder( + build_cmd="install:extension", source_dir="src", build_dir=lab_path + ) + setup_args['cmdclass'] = wrap_installers(post_develop=post_develop, ensured_targets=ensured_targets) + setup_args['data_files'] = get_data_files(data_files_spec) +except ImportError as e: + pass if __name__ == "__main__": setuptools.setup(**setup_args) diff --git a/widgets/package.json b/widgets/package.json index 0fbcedfa..b3b5a298 100644 --- a/widgets/package.json +++ b/widgets/package.json @@ -48,8 +48,8 @@ "watch:src": "tsc -w" }, "dependencies": { - "@jupyterlab/application": "^3.0.10", - "@jupyterlab/mainmenu": "^3.0.8", + "@jupyterlab/application": "^3.0.11", + "@jupyterlab/mainmenu": "^3.0.9", "@lumino/algorithm": "^1.3.3", "@lumino/coreutils": "^1.5.3", "@lumino/disposable": "^1.4.3" diff --git a/widgets/setup.py b/widgets/setup.py index d3c04548..638198b2 100644 --- a/widgets/setup.py +++ b/widgets/setup.py @@ -11,7 +11,7 @@ # The name of the project name = "jupyterlab_examples_widgets" -lab_path = (HERE / name / "labextension") +lab_path = (HERE / name.replace("-", "_") / "labextension") # Representative files that should exist after a successful build ensured_targets = [ From 08c9c5db58452277d796bdd5daae836b4e139c77 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20Collonval?= Date: Wed, 7 Jul 2021 19:21:58 +0200 Subject: [PATCH 07/11] Lint example --- server-extension/README.md | 2 ++ toolbar-button/.eslintrc.js | 18 +++++++++--------- toolbar-button/README.md | 14 +++++++------- toolbar-button/src/index.ts | 11 ++++++----- 4 files changed, 24 insertions(+), 21 deletions(-) diff --git a/server-extension/README.md b/server-extension/README.md index 9a9c493d..90d7b864 100644 --- a/server-extension/README.md +++ b/server-extension/README.md @@ -664,6 +664,7 @@ JupyterLab is looking for frontend extensions when the Python package is install The last piece of configuration needed is the enabling of the server extension. This is done by copying the following JSON file: + ```json5 // jupyter-config/server-config/jlab_ext_example.json @@ -676,6 +677,7 @@ done by copying the following JSON file: } ``` + in the appropriate jupyter folder (`etc/jupyter/jupyter_server_config.d`): diff --git a/toolbar-button/.eslintrc.js b/toolbar-button/.eslintrc.js index 652320e0..82c4e1c2 100644 --- a/toolbar-button/.eslintrc.js +++ b/toolbar-button/.eslintrc.js @@ -5,18 +5,18 @@ module.exports = { 'plugin:@typescript-eslint/recommended', 'plugin:jsdoc/recommended', 'plugin:prettier/recommended', - 'plugin:react/recommended' + 'plugin:react/recommended', ], parser: '@typescript-eslint/parser', parserOptions: { project: 'tsconfig.json', - sourceType: 'module' + sourceType: 'module', }, plugins: ['@typescript-eslint', 'jsdoc'], rules: { '@typescript-eslint/interface-name-prefix': [ 'error', - { prefixWithI: 'always' } + { prefixWithI: 'always' }, ], '@typescript-eslint/no-unused-vars': ['warn', { args: 'none' }], '@typescript-eslint/no-explicit-any': 'off', @@ -26,7 +26,7 @@ module.exports = { '@typescript-eslint/quotes': [ 'error', 'single', - { avoidEscape: true, allowTemplateLiterals: false } + { avoidEscape: true, allowTemplateLiterals: false }, ], curly: ['error', 'all'], eqeqeq: 'error', @@ -34,14 +34,14 @@ module.exports = { 'jsdoc/require-property-type': 'off', 'jsdoc/require-returns-type': 'off', 'jsdoc/no-types': 'warn', - 'prefer-arrow-callback': 'error' + 'prefer-arrow-callback': 'error', }, settings: { jsdoc: { - mode: 'typescript' + mode: 'typescript', }, react: { - version: 'detect' - } - } + version: 'detect', + }, + }, }; diff --git a/toolbar-button/README.md b/toolbar-button/README.md index 862bbfc9..e36b3f46 100644 --- a/toolbar-button/README.md +++ b/toolbar-button/README.md @@ -15,7 +15,7 @@ import { IDisposable, DisposableDelegate } from '@lumino/disposable'; import { JupyterFrontEnd, - JupyterFrontEndPlugin + JupyterFrontEndPlugin, } from '@jupyterlab/application'; import { ToolbarButton } from '@jupyterlab/apputils'; @@ -25,7 +25,7 @@ import { DocumentRegistry } from '@jupyterlab/docregistry'; import { NotebookActions, NotebookPanel, - INotebookModel + INotebookModel, } from '@jupyterlab/notebook'; ``` @@ -37,7 +37,7 @@ Firstly you have to register the plugin information. For that you have to pass a const plugin: JupyterFrontEndPlugin = { activate, id: 'toolbar-button', - autoStart: true + autoStart: true, }; ``` @@ -48,7 +48,8 @@ document widget; in this case a notebook panel. // src/index.ts#L30-L54 export class ButtonExtension - implements DocumentRegistry.IWidgetExtension { + implements DocumentRegistry.IWidgetExtension +{ /** * Create a new extension for the notebook panel widget. */ @@ -63,7 +64,7 @@ export class ButtonExtension className: 'clear-output-button', label: 'Clear All Outputs', onClick: clearOutput, - tooltip: 'Clear All Outputs' + tooltip: 'Clear All Outputs', }); panel.toolbar.insertItem(10, 'clearOutputs', button); @@ -71,7 +72,6 @@ export class ButtonExtension button.dispose(); }); } -} ``` Finally you need to tell the document registry about your widget extension: @@ -79,9 +79,9 @@ Finally you need to tell the document registry about your widget extension: ```ts // src/index.ts#L59-L61 + */ function activate(app: JupyterFrontEnd) { app.docRegistry.addWidgetExtension('Notebook', new ButtonExtension()); -} ``` ## Where to Go Next diff --git a/toolbar-button/src/index.ts b/toolbar-button/src/index.ts index aa500b37..4417fb53 100644 --- a/toolbar-button/src/index.ts +++ b/toolbar-button/src/index.ts @@ -2,7 +2,7 @@ import { IDisposable, DisposableDelegate } from '@lumino/disposable'; import { JupyterFrontEnd, - JupyterFrontEndPlugin + JupyterFrontEndPlugin, } from '@jupyterlab/application'; import { ToolbarButton } from '@jupyterlab/apputils'; @@ -12,7 +12,7 @@ import { DocumentRegistry } from '@jupyterlab/docregistry'; import { NotebookActions, NotebookPanel, - INotebookModel + INotebookModel, } from '@jupyterlab/notebook'; /** @@ -21,14 +21,15 @@ import { const plugin: JupyterFrontEndPlugin = { activate, id: 'toolbar-button', - autoStart: true + autoStart: true, }; /** * A notebook widget extension that adds a button to the toolbar. */ export class ButtonExtension - implements DocumentRegistry.IWidgetExtension { + implements DocumentRegistry.IWidgetExtension +{ /** * Create a new extension for the notebook panel widget. */ @@ -43,7 +44,7 @@ export class ButtonExtension className: 'clear-output-button', label: 'Clear All Outputs', onClick: clearOutput, - tooltip: 'Clear All Outputs' + tooltip: 'Clear All Outputs', }); panel.toolbar.insertItem(10, 'clearOutputs', button); From 7ce4e6128751674bfb6f05f9575a9ff941142f79 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20Collonval?= Date: Thu, 8 Jul 2021 13:01:58 +0200 Subject: [PATCH 08/11] Fix CI --- server-extension/README.md | 2 +- toolbar-button/.eslintrc.js | 12 +++++++++--- 2 files changed, 10 insertions(+), 4 deletions(-) diff --git a/server-extension/README.md b/server-extension/README.md index 90d7b864..8f7e481a 100644 --- a/server-extension/README.md +++ b/server-extension/README.md @@ -349,7 +349,7 @@ an `IFrame` that will display static content fetched from the server extension. The server part of the extension is going to be presented in this section. -JupyterLab server is built on top of the [Tornado](https://tornadoweb.org/en/stable/guide.html) Python package. To extend the server, +JupyterLab server is built on top of the [Tornado](https://www.tornadoweb.org/en/stable/guide.html) Python package. To extend the server, your extension needs to be defined as a proper Python package with some hook functions: ```py diff --git a/toolbar-button/.eslintrc.js b/toolbar-button/.eslintrc.js index 82c4e1c2..c2375786 100644 --- a/toolbar-button/.eslintrc.js +++ b/toolbar-button/.eslintrc.js @@ -14,13 +14,19 @@ module.exports = { }, plugins: ['@typescript-eslint', 'jsdoc'], rules: { - '@typescript-eslint/interface-name-prefix': [ + '@typescript-eslint/naming-convention': [ 'error', - { prefixWithI: 'always' }, + { + selector: 'interface', + format: ['PascalCase'], + custom: { + regex: '^I[A-Z]', + match: true, + }, + }, ], '@typescript-eslint/no-unused-vars': ['warn', { args: 'none' }], '@typescript-eslint/no-explicit-any': 'off', - '@typescript-eslint/camelcase': 'warn', '@typescript-eslint/no-namespace': 'off', '@typescript-eslint/no-use-before-define': 'off', '@typescript-eslint/quotes': [ From a7e4b2f604e001d54607597069c565160191ebce Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20Collonval?= Date: Thu, 8 Jul 2021 13:29:51 +0200 Subject: [PATCH 09/11] Update eslint jsdoc for toolbar button example --- toolbar-button/package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/toolbar-button/package.json b/toolbar-button/package.json index cef7c8da..3d48db06 100644 --- a/toolbar-button/package.json +++ b/toolbar-button/package.json @@ -54,7 +54,7 @@ "@typescript-eslint/parser": "^4.8.1", "eslint": "^7.14.0", "eslint-config-prettier": "^6.15.0", - "eslint-plugin-jsdoc": "^22.0.0", + "eslint-plugin-jsdoc": "^34.0.0", "eslint-plugin-prettier": "^3.1.4", "eslint-plugin-react": "^7.18.3", "npm-run-all": "^4.1.5", From 07ea78225c99068bedfc3f48d4b1fce8622b335f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20Collonval?= Date: Thu, 8 Jul 2021 14:05:21 +0200 Subject: [PATCH 10/11] Add missing toolbar-button package from workspace --- lerna.json | 1 + package.json | 1 + 2 files changed, 2 insertions(+) diff --git a/lerna.json b/lerna.json index dc64933b..cde8c923 100644 --- a/lerna.json +++ b/lerna.json @@ -16,6 +16,7 @@ "settings", "signals", "state", + "toolbar-button", "widgets" ], "npmClient": "jlpm", diff --git a/package.json b/package.json index 4bcf9009..52b6f819 100644 --- a/package.json +++ b/package.json @@ -37,6 +37,7 @@ "settings", "signals", "state", + "toolbar-button", "widgets" ] }, From 40f3ee310081a34c6ff53c9480eed06f38f0e789 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20Collonval?= Date: Sun, 11 Jul 2021 10:31:14 +0200 Subject: [PATCH 11/11] Fix missing dependencies --- toolbar-button/package.json | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/toolbar-button/package.json b/toolbar-button/package.json index 3d48db06..1a3e21a0 100644 --- a/toolbar-button/package.json +++ b/toolbar-button/package.json @@ -46,7 +46,11 @@ "watch:src": "tsc -w" }, "dependencies": { - "@jupyterlab/application": "^3.0.11" + "@jupyterlab/application": "^3.0.11", + "@jupyterlab/apputils": "^3.0.9", + "@jupyterlab/docregistry": "^3.0.11", + "@jupyterlab/notebook": "^3.0.11", + "@lumino/disposable": "^1.7.0" }, "devDependencies": { "@jupyterlab/builder": "^3.0.0", @@ -71,4 +75,4 @@ "extension": true, "outputDir": "jupyterlab_examples_toolbar_button/labextension" } -} \ No newline at end of file +}