From 82f4229861724b704c80767be601d72386451a7b Mon Sep 17 00:00:00 2001 From: Yaacov Rydzinski Date: Fri, 27 Feb 2026 10:59:43 +0200 Subject: [PATCH] internal: remove version/preversion scripts --- package.json | 2 -- resources/checkgit.sh | 39 ------------------------------------ resources/release-prepare.ts | 24 +++++++++++++++++++++- 3 files changed, 23 insertions(+), 42 deletions(-) delete mode 100644 resources/checkgit.sh diff --git a/package.json b/package.json index 6d5f1d3009..71ecc29095 100644 --- a/package.json +++ b/package.json @@ -29,8 +29,6 @@ "node": "^20.0.0 || ^22.0.0 || ^24.0.0 || >=25.0.0" }, "scripts": { - "preversion": "bash -c '. ./resources/checkgit.sh && npm ci --ignore-scripts'", - "version": "node --import ./resources/register-ts-node.js resources/gen-version.ts && npm test && git add src/version.ts", "fuzzonly": "mocha --full-trace src/**/__tests__/**/*-fuzz.ts", "changelog": "node --import ./resources/register-ts-node.js resources/gen-changelog.ts", "release:prepare": "node --import ./resources/register-ts-node.js resources/release-prepare.ts", diff --git a/resources/checkgit.sh b/resources/checkgit.sh deleted file mode 100644 index e5e4c67cf2..0000000000 --- a/resources/checkgit.sh +++ /dev/null @@ -1,39 +0,0 @@ -# Exit immediately if any subcommand terminated -set -e -trap "exit 1" ERR - -# -# This script determines if current git state is the up to date main. If so -# it exits normally. If not it prompts for an explicit continue. This script -# intends to protect from versioning for NPM without first pushing changes -# and including any changes on main. -# - -# Check that local copy has no modifications -GIT_MODIFIED_FILES=$(git ls-files -dm 2> /dev/null); -GIT_STAGED_FILES=$(git diff --cached --name-only 2> /dev/null); -if [ "$GIT_MODIFIED_FILES" != "" -o "$GIT_STAGED_FILES" != "" ]; then - read -p "Git has local modifications. Continue? (y|N) " yn; - if [ "$yn" != "y" ]; then exit 1; fi; -fi; - -# First fetch to ensure git is up to date. Fail-fast if this fails. -git fetch; -if [[ $? -ne 0 ]]; then exit 1; fi; - -# Extract useful information. -GIT_BRANCH=$(git branch -v 2> /dev/null | sed '/^[^*]/d'); -GIT_BRANCH_NAME=$(echo "$GIT_BRANCH" | sed 's/* \([A-Za-z0-9_\-]*\).*/\1/'); -GIT_BRANCH_SYNC=$(echo "$GIT_BRANCH" | sed 's/* [^[]*.\([^]]*\).*/\1/'); - -# Check if main is checked out -if [ "$GIT_BRANCH_NAME" != "main" ]; then - read -p "Git not on main but $GIT_BRANCH_NAME. Continue? (y|N) " yn; - if [ "$yn" != "y" ]; then exit 1; fi; -fi; - -# Check if branch is synced with remote -if [ "$GIT_BRANCH_SYNC" != "" ]; then - read -p "Git not up to date but $GIT_BRANCH_SYNC. Continue? (y|N) " yn; - if [ "$yn" != "y" ]; then exit 1; fi; -fi; diff --git a/resources/release-prepare.ts b/resources/release-prepare.ts index a50b3be840..0acd63706b 100644 --- a/resources/release-prepare.ts +++ b/resources/release-prepare.ts @@ -9,9 +9,24 @@ try { process.exit(1); } -console.log('Running npm version without creating a tag...'); +console.log('Installing dependencies...'); +npm().ci('--ignore-scripts'); + +console.log('Bumping package version without creating a tag...'); npm().version(...args.npmVersionArgs, '--no-git-tag-version'); +console.log('Updating src/version.ts...'); +npm().exec( + '--', + 'node', + '--import', + './resources/register-ts-node.js', + 'resources/gen-version.ts', +); + +console.log('Running test suite...'); +npm().run('test'); + const { version } = readPackageJSON(); console.log(`Generating changelog for v${version}...`); const changelogArgs = ['--silent', 'changelog']; @@ -97,6 +112,13 @@ function validateBranchState(releaseBranch: string): void { 'Working directory must be clean before running release:prepare.', ); } + const branchStatus = git().status('--porcelain', '--branch'); + const branchSummary = branchStatus.split('\n')[0] ?? ''; + if (/\[[^\]]+\]/.test(branchSummary)) { + throw new Error( + `Current branch "${checkedBranch}" is not up to date with its upstream.`, + ); + } let releaseBranchHead: string; try {