Skip to content

Commit

Permalink
Align with copier template (#310)
Browse files Browse the repository at this point in the history
* Backport PR #308: Manual release: add clean-up instructions (pre-build)

* Align with copier template

* Add recommendation to use the copier template

* Align Jest configuration

---------

Co-authored-by: Benoit Bovy <[email protected]>
Co-authored-by: Frédéric Collonval <[email protected]>
  • Loading branch information
3 people authored May 22, 2023
1 parent 3853e17 commit 0ba10b8
Show file tree
Hide file tree
Showing 12 changed files with 53 additions and 32 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/check-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ jobs:
uses: jupyterlab/maintainer-tools/.github/actions/base-setup@v1

- name: Install dependencies
run: python -m pip install -U cookiecutter "jupyterlab>=4.0.0b0,<5"
run: python -m pip install -U cookiecutter "jupyterlab>=4.0.0,<5"

- name: Create the extension
run: |
Expand Down
18 changes: 9 additions & 9 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ jobs:
# Trick to use custom parameters
python -c "from cookiecutter.main import cookiecutter; import json, os; f=open('cookiecutter.json'); d=json.load(f); f.close(); d['kind']=d['kind'][0]; d['labextension_name']=os.getenv('NAME'); cookiecutter('.', extra_context=d, no_input=True)"
pushd ${PYNAME}
python -m pip install "jupyterlab>=4.0.0b0,<5"
python -m pip install "jupyterlab>=4.0.0,<5"
jlpm
jlpm stylelint-config-prettier-check
jlpm lint:check
Expand Down Expand Up @@ -81,7 +81,7 @@ jobs:
# Trick to use custom parameters
python -c "from cookiecutter.main import cookiecutter; import json; f=open('cookiecutter.json'); d=json.load(f); f.close(); d['kind']=d['kind'][0]; d['test']='n'; cookiecutter('.', extra_context=d, no_input=True)"
pushd myextension
pip install "jupyterlab>=4.0.0b0,<5"
pip install "jupyterlab>=4.0.0,<5"
jlpm
jlpm lint:check
pip install -e .
Expand Down Expand Up @@ -120,7 +120,7 @@ jobs:
# Trick to use custom parameters
python -c "from cookiecutter.main import cookiecutter; import json; f=open('cookiecutter.json'); d=json.load(f); f.close(); d['kind']=d['kind'][0]; d['has_settings']='y'; cookiecutter('.', extra_context=d, no_input=True)"
pushd myextension
pip install "jupyterlab>=4.0.0b0,<5"
pip install "jupyterlab>=4.0.0,<5"
jlpm
# It is not easily possible to get this version compatible with linter rules
jlpm lint
Expand Down Expand Up @@ -164,7 +164,7 @@ jobs:
cd myextension
cat pyproject.toml
pip install .
pip install "jupyterlab>=4.0.0b0,<5"
pip install "jupyterlab>=4.0.0,<5"
jlpm
jlpm lint:check
Expand All @@ -189,7 +189,7 @@ jobs:
python -c "from cookiecutter.main import cookiecutter; import json; f=open('cookiecutter.json'); d=json.load(f); f.close(); d['kind']='server'; cookiecutter('.', extra_context=d, no_input=True)"
cd myextension
python -m pip install -e .[test]
python -m pip install "jupyterlab>=4.0.0b0,<5"
python -m pip install "jupyterlab>=4.0.0,<5"
jupyter labextension develop . --overwrite
jupyter server extension enable myextension
Expand Down Expand Up @@ -223,7 +223,7 @@ jobs:
# Trick to use custom parameters
python -c "from cookiecutter.main import cookiecutter; import json; f=open('cookiecutter.json'); d=json.load(f); f.close(); d['kind']='server'; cookiecutter('.', extra_context=d, no_input=True)"
cd myextension
python -m pip install "jupyterlab>=4.0.0b0,<5"
python -m pip install "jupyterlab>=4.0.0,<5"
jupyter lab clean --all
python -m build
cd dist
Expand Down Expand Up @@ -289,7 +289,7 @@ jobs:
sudo rm -rf $(which node)
python -m pip install myextension.tar.gz
python -m pip install "jupyterlab>=4.0.0b0,<5"
python -m pip install "jupyterlab>=4.0.0,<5"
jupyter labextension list 2>&1 | grep -ie "myextension.*OK"
jupyter server extension list
jupyter server extension list 2>&1 | grep -ie "myextension.*OK"
Expand Down Expand Up @@ -319,7 +319,7 @@ jobs:
# Trick to use custom parameters
python -c "from cookiecutter.main import cookiecutter; import json; f=open('cookiecutter.json'); d=json.load(f); f.close(); d['kind']='theme'; cookiecutter('.', extra_context=d, no_input=True)"
pushd mytheme
python -m pip install "jupyterlab>=4.0.0b0,<5"
python -m pip install "jupyterlab>=4.0.0,<5"
jlpm
jlpm lint:check
python -m pip install -e .
Expand Down Expand Up @@ -360,7 +360,7 @@ jobs:
python -c "from cookiecutter.main import cookiecutter; import json, os; f=open('cookiecutter.json'); d=json.load(f); f.close(); d['kind']=os.getenv('KIND'); d['labextension_name']='myextension'; cookiecutter('.', extra_context=d, no_input=True)"
pushd myextension
sed -i 's/^\(nodeLinker:\s\).*$/\1pnpm/' .yarnrc.yml
python -m pip install "jupyterlab>=4.0.0b0,<5"
python -m pip install "jupyterlab>=4.0.0,<5"
jlpm
if [ ! -d node_modules/.store ] ; then echo 'nodes_module directory should contain a .store directory when using pnpm nodeLinker'; exit 1; fi;
jlpm build
Expand Down
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@

[![Github Actions Status](https://github.com/jupyterlab/extension-cookiecutter-ts/workflows/CI/badge.svg)](https://github.com/jupyterlab/extension-cookiecutter-ts/actions/workflows/main.yml)

⚠️ **We strongly advice to use the template next generation: https://github.com/jupyterlab/extension-template**

A [cookiecutter](https://github.com/audreyr/cookiecutter) template for creating
a JupyterLab extension. Three kinds of extension are supported:
- _frontend_: Pure frontend extension written in TypeScript.
Expand Down
6 changes: 3 additions & 3 deletions {{cookiecutter.python_name}}/.github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ jobs:
uses: jupyterlab/maintainer-tools/.github/actions/base-setup@v1

- name: Install dependencies
run: python -m pip install -U "jupyterlab>=4.0.0b0,<5"
run: python -m pip install -U "jupyterlab>=4.0.0,<5"

- name: Lint the extension
run: |
Expand Down Expand Up @@ -81,7 +81,7 @@ jobs:
sudo rm -rf $(which node)
sudo rm -rf $(which node)
pip install "jupyterlab>=4.0.0b0,<5" {{ cookiecutter.python_name }}*.whl
pip install "jupyterlab>=4.0.0,<5" {{ cookiecutter.python_name }}*.whl
{% if cookiecutter.kind.lower() == 'server' %}
jupyter server extension list
Expand Down Expand Up @@ -114,7 +114,7 @@ jobs:
- name: Install the extension
run: |
set -eux
python -m pip install "jupyterlab>=4.0.0b0,<5" {{ cookiecutter.python_name }}*.whl
python -m pip install "jupyterlab>=4.0.0,<5" {{ cookiecutter.python_name }}*.whl
- name: Install dependencies
working-directory: ui-tests
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ jobs:{# Escape double curly brace #}{% raw %}
uses: jupyterlab/maintainer-tools/.github/actions/base-setup@v1

- name: Install dependencies
run: python -m pip install -U "jupyterlab>=4.0.0b0,<5"
run: python -m pip install -U "jupyterlab>=4.0.0,<5"

- name: Install extension
run: |
Expand Down
2 changes: 1 addition & 1 deletion {{cookiecutter.python_name}}/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ for the frontend extension.
{% endif %}
## Requirements

- JupyterLab >= 4.0.0b0
- JupyterLab >= 4.0.0

## Install

Expand Down
12 changes: 12 additions & 0 deletions {{cookiecutter.python_name}}/RELEASE.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,18 @@ See the docs on [hatch-nodejs-version](https://github.com/agoose77/hatch-nodejs-
hatch version <new-version>
```

Make sure to clean up all the development files before building the package:

```bash
jlpm clean:all
```

You could also clean up the local git repository:

```bash
git clean -dfX
```

To create a Python source package (`.tar.gz`) and the binary package (`.whl`) in the `dist/` directory, do:

```bash
Expand Down
2 changes: 1 addition & 1 deletion {{cookiecutter.python_name}}/binder/environment.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ channels:
dependencies:
# runtime dependencies
- python >=3.10,<3.11.0a0
- jupyterlab >=4.0.0b0,<5
- jupyterlab >=4.0.0,<5
# labextension build dependencies
- nodejs >=18,<19
- pip
Expand Down
17 changes: 12 additions & 5 deletions {{cookiecutter.python_name}}/jest.config.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,16 @@
const jestJupyterLab = require('@jupyterlab/testutils/lib/jest-config');

const esModules = ['@jupyterlab/'].join('|');
const esModules = [
'@codemirror',
'@jupyter/ydoc',
'@jupyterlab/',
'lib0',
'nanoid',
'vscode-ws-jsonrpc',
'y-protocols',
'y-websocket',
'yjs'
].join('|');

const baseConfig = jestJupyterLab(__dirname);

Expand All @@ -14,8 +24,5 @@ module.exports = {
],
coverageReporters: ['lcov', 'text'],
testRegex: 'src/.*/.*.spec.ts[x]?$',
transformIgnorePatterns: [
...baseConfig.transformIgnorePatterns,
`/node_modules/(?!${esModules}).+`
]
transformIgnorePatterns: [`/node_modules/(?!${esModules}).+`]
};
16 changes: 8 additions & 8 deletions {{cookiecutter.python_name}}/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -55,19 +55,19 @@
"stylelint:check": "stylelint --cache \"style/**/*.css\"",{% if cookiecutter.test.lower().startswith('y') %}
"test": "jest --coverage",{% endif %}
"watch": "run-p watch:src watch:labextension",
"watch:src": "tsc -w",
"watch:src": "tsc -w --sourceMap",
"watch:labextension": "jupyter labextension watch ."
},
"dependencies": {
"@jupyterlab/application": "^4.0.0-beta.0"{% if cookiecutter.kind.lower() == 'theme' %},
"@jupyterlab/apputils": "^4.0.0-beta.0"{% endif %}{% if cookiecutter.has_settings.lower().startswith('y') %},
"@jupyterlab/settingregistry": "^4.0.0-beta.0"{% endif %}{% if cookiecutter.kind.lower() == 'server' %},
"@jupyterlab/coreutils": "^6.0.0-beta.0",
"@jupyterlab/services": "^7.0.0-beta.0"{% endif %}
"@jupyterlab/application": "^4.0.0"{% if cookiecutter.kind.lower() == 'theme' %},
"@jupyterlab/apputils": "^4.0.0"{% endif %}{% if cookiecutter.has_settings.lower().startswith('y') %},
"@jupyterlab/settingregistry": "^4.0.0"{% endif %}{% if cookiecutter.kind.lower() == 'server' %},
"@jupyterlab/coreutils": "^6.0.0",
"@jupyterlab/services": "^7.0.0"{% endif %}
},
"devDependencies": {
"@jupyterlab/builder": "^4.0.0-beta.0",{% if cookiecutter.test.lower().startswith('y') %}
"@jupyterlab/testutils": "^4.0.0-beta.0",
"@jupyterlab/builder": "^4.0.0",{% if cookiecutter.test.lower().startswith('y') %}
"@jupyterlab/testutils": "^4.0.0",
"@types/jest": "^29.2.0",{% endif %}
"@types/json-schema": "^7.0.11",
"@types/react": "^18.0.26",
Expand Down
4 changes: 2 additions & 2 deletions {{cookiecutter.python_name}}/pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
[build-system]
requires = ["hatchling>=1.5.0", "jupyterlab>=4.0.0b0,<5", "hatch-nodejs-version"]
requires = ["hatchling>=1.5.0", "jupyterlab>=4.0.0,<5", "hatch-nodejs-version"]
build-backend = "hatchling.build"

[project]
Expand Down Expand Up @@ -78,7 +78,7 @@ version_cmd = "hatch version"

[tool.jupyter-releaser.hooks]
before-build-npm = [
"python -m pip install 'jupyterlab>=4.0.0b0,<5'",
"python -m pip install 'jupyterlab>=4.0.0,<5'",
"jlpm",
"jlpm build:prod"
]
Expand Down
2 changes: 1 addition & 1 deletion {{cookiecutter.python_name}}/ui-tests/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
"test:update": "jlpm playwright test --update-snapshots"
},
"devDependencies": {
"@jupyterlab/galata": "^5.0.0-beta.0",
"@jupyterlab/galata": "^5.0.0",
"@playwright/test": "^1.32.0"
}
}

0 comments on commit 0ba10b8

Please sign in to comment.