From 315ff1d9804915f5d1b6d916eef655b2d46072c9 Mon Sep 17 00:00:00 2001 From: Donkie Date: Fri, 29 Dec 2023 00:14:26 +0100 Subject: [PATCH] Added node package bumping to bump script --- spoolman/bump.py | 19 +++++++++++++++++-- 1 file changed, 17 insertions(+), 2 deletions(-) diff --git a/spoolman/bump.py b/spoolman/bump.py index 91289bc..e9140d2 100644 --- a/spoolman/bump.py +++ b/spoolman/bump.py @@ -2,6 +2,7 @@ # ruff: noqa: PLR2004, T201, S603, S607 +import json import re import subprocess import sys @@ -39,8 +40,22 @@ def bump() -> None: sys.exit(1) new_version = new_version_match.group(1) - # Stage the pyproject.toml file - subprocess.run(["git", "add", "pyproject.toml"], cwd=project_root, check=True) + # Update the version number in the node project + with Path("client", "package.json").open("r") as f: + node_package = json.load(f) + node_package["version"] = new_version + with Path("client", "package.json").open("w") as f: + json.dump(node_package, f, indent=2) + + # Run npm install to update the lock file with new version + subprocess.run(["npm", "install"], cwd=project_root.joinpath("client"), check=True, shell=True) # noqa: S602 + + # Stage the changed files + subprocess.run( + ["git", "add", "pyproject.toml", "client/package.json", "client/package-lock.json"], + cwd=project_root, + check=True, + ) # Commit the changes subprocess.run(["git", "commit", "-m", f"Bump version to {new_version}"], cwd=project_root, check=True)