Skip to content

Commit b846504

Browse files
committed
chore(build): write also new version to package-lock.json at bump
1 parent a87a02c commit b846504

File tree

1 file changed

+26
-7
lines changed

1 file changed

+26
-7
lines changed

scripts/update_git_versions.py

Lines changed: 26 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,9 @@
11
import contextlib
22
import re
3+
import subprocess
34
import sys
45
from pathlib import Path
6+
from typing import Any
57

68
if __name__ == "__main__" and not __package__:
79
file = Path(__file__).resolve()
@@ -25,6 +27,16 @@ def replace_in_file(filename: Path, pattern: "re.Pattern[str]", to: str) -> None
2527
filename.write_text(new)
2628

2729

30+
def run(title: str, *args: Any, **kwargs: Any) -> None:
31+
try:
32+
print(f"running {title}")
33+
subprocess.run(*args, **kwargs)
34+
except (SystemExit, KeyboardInterrupt):
35+
raise
36+
except BaseException as e:
37+
print(f"{title} failed: {e}", file=sys.stderr)
38+
39+
2840
def main() -> None:
2941
version = get_version()
3042
version_files = list(Path("packages").rglob("__version__.py"))
@@ -36,13 +48,20 @@ def main() -> None:
3648
rf"\g<1>{version or ''}\g<3>",
3749
)
3850

39-
replace_in_file(
40-
Path("package.json"),
41-
re.compile(
42-
r"""(\"version\"\s*:\s*['"])([0-9]+\.[0-9]+\.[0-9]+.*)(['"])""",
43-
re.MULTILINE,
44-
),
45-
rf"\g<1>{version or ''}\g<3>",
51+
# replace_in_file(
52+
# Path("package.json"),
53+
# re.compile(
54+
# r"""(\"version\"\s*:\s*['"])([0-9]+\.[0-9]+\.[0-9]+.*)(['"])""",
55+
# re.MULTILINE,
56+
# ),
57+
# rf"\g<1>{version or ''}\g<3>",
58+
# )
59+
60+
run(
61+
"npm version",
62+
f"npm --no-git-tag-version version {version}",
63+
shell=True,
64+
timeout=600,
4665
)
4766

4867
pyproject_files = list(Path("packages").rglob("pyproject.toml"))

0 commit comments

Comments
 (0)