Skip to content

Commit d229bee

Browse files
committed
Added script to bump package versions and commit, npm/pnpm fall short.
1 parent 835b987 commit d229bee

File tree

4 files changed

+49
-3
lines changed

4 files changed

+49
-3
lines changed

.github/workflows/version.yml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,8 +26,10 @@ jobs:
2626
node-version: "22"
2727
cache: "pnpm"
2828

29+
- name: Install dependencies
30+
run: pnpm install --frozen-lockfile
31+
2932
- name: Bump version
30-
if: ${{ github.event_name }} == "workflow_dispatch" && ${{ github.ref_name }} == "main"
3133
run: pnpm run version -- ${{ inputs.version }}
3234

3335
- name: Create PR with new versions

package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
"name": "eslint-plugin-solid-monorepo",
33
"private": true,
44
"license": "MIT",
5+
"type": "module",
56
"workspaces": [
67
"packages/*"
78
],
@@ -16,7 +17,7 @@
1617
"turbo:docs": "cp packages/eslint-plugin-solid/README.md README.md",
1718
"turbo:lint": "eslint --max-warnings=0",
1819
"turbo:tsc": "tsc",
19-
"version": "sh -c 'npm version --workspace=packages/eslint-plugin-solid --workspace=packages/eslint-solid-standalone --workspaces-update=false ${0} && git add packages/*/package.json'"
20+
"version": "node scripts/version.js"
2021
},
2122
"lint-staged": {
2223
"*.{js,jsx,ts,tsx}": [

scripts/version.js

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
import fs from "node:fs/promises";
2+
import path from "node:path";
3+
import inc from "semver/functions/inc";
4+
import { exec } from "node:child_process";
5+
6+
const pluginPackageJsonPath = path.resolve("packages", "eslint-plugin-solid", "package.json");
7+
const standalonePackageJsonPath = path.resolve(
8+
"packages",
9+
"eslint-solid-standalone",
10+
"package.json"
11+
);
12+
13+
const pluginPackageJson = JSON.parse(await fs.readFile(pluginPackageJsonPath, "utf-8"));
14+
const standalonePackageJson = JSON.parse(await fs.readFile(standalonePackageJsonPath, "utf-8"));
15+
16+
const version = pluginPackageJson.version;
17+
const increment = process.argv[2];
18+
const newVersion = inc(version, increment);
19+
20+
if (newVersion == null || !/^\d+\.\d+\.\d+$/.test(newVersion)) {
21+
console.error("Usage: node scripts/version.js [increment]");
22+
process.exit(1);
23+
}
24+
25+
pluginPackageJson.version = newVersion;
26+
standalonePackageJson.version = newVersion;
27+
28+
await Promise.all([
29+
fs.writeFile(pluginPackageJsonPath, JSON.stringify(pluginPackageJson, null, 2), "utf-8"),
30+
fs.writeFile(standalonePackageJsonPath, JSON.stringify(standalonePackageJson, null, 2), "utf-8"),
31+
]);
32+
await new Promise((resolve, reject) => {
33+
exec(
34+
`git commit --all --message="v${newVersion}"; git tag "v${newVersion}";`,
35+
(error, stdout) => {
36+
if (error) {
37+
reject(error);
38+
} else {
39+
resolve(stdout);
40+
}
41+
}
42+
);
43+
});

tsconfig.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,6 @@
88
"resolveJsonModule": true,
99
"allowImportingTsExtensions": true
1010
},
11-
"include": ["packages/eslint-plugin-solid", "packages/eslint-solid-standalone", "test"],
11+
"include": ["packages/eslint-plugin-solid", "packages/eslint-solid-standalone", "test", "scripts"],
1212
"exclude": ["**/dist", "**/dist.*"]
1313
}

0 commit comments

Comments
 (0)