From 8b774d7d18f166501d9770321c31dc79d3c40bd7 Mon Sep 17 00:00:00 2001 From: martinRenou Date: Fri, 13 Dec 2024 15:23:07 +0100 Subject: [PATCH] Fixing lerna setup (#136) * Try fixing lerna setup * Missing bump script * Update * Meh --- package.json | 8 +++++--- pyproject.toml | 5 +++-- scripts/bump_version.py | 30 ++++++++++++++++++++++++++++++ 3 files changed, 38 insertions(+), 5 deletions(-) create mode 100644 scripts/bump_version.py diff --git a/package.json b/package.json index d520952..f1b0362 100644 --- a/package.json +++ b/package.json @@ -14,9 +14,11 @@ }, "license": "BSD-3-Clause", "author": "JupyterLite Contributors", - "workspaces": [ - "packages/*" - ], + "workspaces": { + "packages": [ + "packages/*" + ] + }, "repository": { "type": "git", "url": "https://github.com/jupyterlite/xeus.git" diff --git a/pyproject.toml b/pyproject.toml index 40fdd0d..65c02ff 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -71,12 +71,13 @@ source_dir = "src" build_dir = "jupyterlite_xeus/labextension" [tool.jupyter-releaser.options] -version_cmd = "hatch version" +version_cmd = "python ./scripts/bump_version.py" [tool.jupyter-releaser.hooks] +before-bump-version = ["python -m pip install 'jupyterlab>=4.0.0,<5'", "jlpm"] before-build-npm = [ "python -m pip install 'jupyterlab>=4.0.0,<4.3'", - "jlpm", + "YARN_ENABLE_IMMUTABLE_INSTALLS=0 jlpm", "jlpm build:prod" ] before-build-python = ["jlpm clean:all"] diff --git a/scripts/bump_version.py b/scripts/bump_version.py new file mode 100644 index 0000000..099ebca --- /dev/null +++ b/scripts/bump_version.py @@ -0,0 +1,30 @@ +import argparse +import json +from pathlib import Path +from subprocess import run + +BUMP_VERSION_CMD = "npx lerna version --no-push --force-publish --no-git-tag-version --yes" + + +def main(): + parser = argparse.ArgumentParser() + parser.add_argument("version") + args = parser.parse_args() + version = args.version + + run(f"{BUMP_VERSION_CMD} {version}", shell=True, check=True) + + root = Path(__file__).parent.parent + version_file = root / "packages" / "xeus-extension" / "package.json" + package_file = root / "package.json" + + version_json = json.loads(version_file.read_text()) + version = version_json["version"].replace("-alpha.", "-a").replace("-beta.", "-b").replace("-rc.", "-rc") + + package_json = json.loads(package_file.read_text()) + package_json["version"] = version + package_file.write_text(json.dumps(package_json, indent=4)) + + +if __name__ == "__main__": + main()