Skip to content

Commit 001a17a

Browse files
authored
Add support for monorepo version bumps (#56)
* Add support for monorepo version bumps * Switch from jlpm to yarn * Run yarn install before bumping version
1 parent 589c4d9 commit 001a17a

File tree

3 files changed

+134
-63
lines changed

3 files changed

+134
-63
lines changed

package.json

Lines changed: 62 additions & 62 deletions
Original file line numberDiff line numberDiff line change
@@ -1,66 +1,66 @@
11
{
2-
"name": "@jupyter/root-ui-toolkit",
3-
"version": "0.10.1",
4-
"private": true,
5-
"description": "UI Toolkit for Jupyter",
6-
"keywords": [
7-
"jupyter"
2+
"name": "@jupyter/root-ui-toolkit",
3+
"version": "0.10.0",
4+
"private": true,
5+
"description": "UI Toolkit for Jupyter",
6+
"keywords": [
7+
"jupyter"
8+
],
9+
"homepage": "https://jupyterlab-contrib.github.io/jupyter-ui-toolkit/",
10+
"bugs": {
11+
"url": "https://github.com/jupyterlab-contrib/jupyter-ui-toolkit/issues"
12+
},
13+
"license": "BSD-3-Clause",
14+
"author": {
15+
"name": "Project Jupyter"
16+
},
17+
"repository": {
18+
"type": "git",
19+
"url": "https://github.com/jupyterlab-contrib/jupyter-ui-toolkit.git"
20+
},
21+
"workspaces": [
22+
"packages/*"
23+
],
24+
"scripts": {
25+
"build": "lerna run build",
26+
"build:prod": "lerna run --scope @jupyter/web-components --scope @jupyter/react-components build && lerna run --scope jupyter-ui-demo build:prod",
27+
"clean": "lerna run clean",
28+
"format": "yarn stylelint && prettier --write \"**/*{.ts,.tsx,.js,.jsx,.css,.json,.md}\"",
29+
"format:check": "yarn stylelint:check && prettier --list-different \"**/*{.ts,.tsx,.js,.jsx,.css,.json,.md}\"",
30+
"lint": "lerna run eslint",
31+
"lint:check": "lerna run eslint:check",
32+
"stylelint": "yarn stylelint:check --fix",
33+
"stylelint:check": "stylelint --cache \"packages/lab-example/style/**/*.css\""
34+
},
35+
"devDependencies": {
36+
"@typescript-eslint/eslint-plugin": "^5.55.0",
37+
"@typescript-eslint/parser": "^5.55.0",
38+
"eslint": "^8.36.0",
39+
"eslint-config-prettier": "^8.7.0",
40+
"eslint-plugin-prettier": "^4.2.1",
41+
"lerna": "^7.0.0",
42+
"prettier": "^2.8.8",
43+
"stylelint": "^14.9.1",
44+
"stylelint-config-prettier": "^9.0.4",
45+
"stylelint-config-recommended": "^8.0.0",
46+
"stylelint-config-standard": "^26.0.0",
47+
"stylelint-prettier": "^2.0.0"
48+
},
49+
"resolutions": {
50+
"file-system-cache": "<2.4.0 || >2.4.0"
51+
},
52+
"packageManager": "yarn@3.6.0",
53+
"stylelint": {
54+
"extends": [
55+
"stylelint-config-recommended",
56+
"stylelint-config-standard",
57+
"stylelint-prettier/recommended"
858
],
9-
"homepage": "https://jupyterlab-contrib.github.io/jupyter-ui-toolkit/",
10-
"bugs": {
11-
"url": "https://github.com/jupyterlab-contrib/jupyter-ui-toolkit/issues"
12-
},
13-
"license": "BSD-3-Clause",
14-
"author": {
15-
"name": "Project Jupyter"
16-
},
17-
"repository": {
18-
"type": "git",
19-
"url": "https://github.com/jupyterlab-contrib/jupyter-ui-toolkit.git"
20-
},
21-
"workspaces": [
22-
"packages/*"
23-
],
24-
"scripts": {
25-
"build": "lerna run build",
26-
"build:prod": "lerna run --scope @jupyter/web-components --scope @jupyter/react-components build && lerna run --scope jupyter-ui-demo build:prod",
27-
"clean": "lerna run clean",
28-
"format": "yarn stylelint && prettier --write \"**/*{.ts,.tsx,.js,.jsx,.css,.json,.md}\"",
29-
"format:check": "yarn stylelint:check && prettier --list-different \"**/*{.ts,.tsx,.js,.jsx,.css,.json,.md}\"",
30-
"lint": "lerna run eslint",
31-
"lint:check": "lerna run eslint:check",
32-
"stylelint": "yarn stylelint:check --fix",
33-
"stylelint:check": "stylelint --cache \"packages/lab-example/style/**/*.css\""
34-
},
35-
"devDependencies": {
36-
"@typescript-eslint/eslint-plugin": "^5.55.0",
37-
"@typescript-eslint/parser": "^5.55.0",
38-
"eslint": "^8.36.0",
39-
"eslint-config-prettier": "^8.7.0",
40-
"eslint-plugin-prettier": "^4.2.1",
41-
"lerna": "^7.0.0",
42-
"prettier": "^2.8.8",
43-
"stylelint": "^14.9.1",
44-
"stylelint-config-prettier": "^9.0.4",
45-
"stylelint-config-recommended": "^8.0.0",
46-
"stylelint-config-standard": "^26.0.0",
47-
"stylelint-prettier": "^2.0.0"
48-
},
49-
"resolutions": {
50-
"file-system-cache": "<2.4.0 || >2.4.0"
51-
},
52-
"packageManager": "yarn@3.6.0",
53-
"stylelint": {
54-
"extends": [
55-
"stylelint-config-recommended",
56-
"stylelint-config-standard",
57-
"stylelint-prettier/recommended"
58-
],
59-
"rules": {
60-
"property-no-vendor-prefix": null,
61-
"selector-class-pattern": null,
62-
"selector-no-vendor-prefix": null,
63-
"value-no-vendor-prefix": null
64-
}
59+
"rules": {
60+
"property-no-vendor-prefix": null,
61+
"selector-class-pattern": null,
62+
"selector-no-vendor-prefix": null,
63+
"value-no-vendor-prefix": null
6564
}
65+
}
6666
}

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ source_dir = "src"
6262
build_dir = "jupyter_ui_demo/labextension"
6363

6464
[tool.jupyter-releaser.options]
65-
version_cmd = "hatch version"
65+
version_cmd = "python scripts/bump_version.py --force"
6666

6767
[tool.jupyter-releaser.hooks]
6868
before-build-npm = [

scripts/bump_version.py

Lines changed: 71 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,71 @@
1+
# Copyright (c) Jupyter Development Team.
2+
# Distributed under the terms of the Modified BSD License.
3+
4+
import json
5+
from pathlib import Path
6+
from shutil import which
7+
8+
import click
9+
from jupyter_releaser.util import get_version, run
10+
from pkg_resources import parse_version # type: ignore
11+
12+
LERNA_CMD = "yarn run lerna version --no-push --force-publish --no-git-tag-version"
13+
14+
15+
@click.command()
16+
@click.option("--force", default=False, is_flag=True)
17+
@click.argument("spec", nargs=1)
18+
def bump(force, spec):
19+
status = run("git status --porcelain").strip()
20+
if len(status) > 0:
21+
raise Exception("Must be in a clean git state with no untracked files")
22+
23+
curr = parse_version(get_version())
24+
if spec == "next":
25+
spec = f"{curr.major}.{curr.minor}."
26+
if curr.pre:
27+
p, x = curr.pre
28+
spec += f"{curr.micro}{p}{x + 1}"
29+
else:
30+
spec += f"{curr.micro + 1}"
31+
32+
elif spec == "patch":
33+
spec = f"{curr.major}.{curr.minor}."
34+
if curr.pre:
35+
spec += f"{curr.micro}"
36+
else:
37+
spec += f"{curr.micro + 1}"
38+
39+
version = parse_version(spec)
40+
41+
# convert the Python version
42+
js_version = f"{version.major}.{version.minor}.{version.micro}"
43+
if version.pre:
44+
p, x = version.pre
45+
p = p.replace("a", "alpha").replace("b", "beta")
46+
js_version += f"-{p}.{x}"
47+
48+
# bump the JS packages
49+
run(f"{which('yarn')} install")
50+
lerna_cmd = f"{LERNA_CMD} {js_version}"
51+
if force:
52+
lerna_cmd += " --yes"
53+
run(lerna_cmd)
54+
55+
HERE = Path(__file__).parent.parent.resolve()
56+
path = HERE.joinpath("package.json")
57+
if path.exists():
58+
with path.open(mode="r") as f:
59+
data = json.load(f)
60+
61+
data["version"] = js_version
62+
63+
with path.open(mode="w") as f:
64+
json.dump(data, f, indent=2)
65+
66+
else:
67+
raise FileNotFoundError(f"Could not find package.json under dir {path!s}")
68+
69+
70+
if __name__ == "__main__":
71+
bump()

0 commit comments

Comments
 (0)