Skip to content

Commit 2089270

Browse files
committed
chore(cli): inline version
1 parent c528497 commit 2089270

File tree

5 files changed

+41
-2
lines changed

5 files changed

+41
-2
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ node_modules
1212

1313
packages/formatters/src/html/templates.ts
1414
packages/cli/binaries
15+
packages/cli/src/version.ts
1516
/test-harness/tmp/
1617
/test-harness/tests/
1718
packages/*/dist

package.json

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,8 @@
2525
"scripts": {
2626
"clean": "rimraf .cache packages/*/{dist,.cache}",
2727
"prebuild": "yarn workspaces foreach run prebuild",
28-
"build": "yarn prebuild && tsc --build ./tsconfig.build.json",
28+
"build": "yarn prebuild && tsc --build ./tsconfig.build.json && yarn postbuild",
29+
"postbuild": "yarn workspaces foreach run postbuild",
2930
"prelint": "yarn workspaces foreach run prelint",
3031
"lint": "yarn prelint && yarn lint.prettier && yarn lint.eslint",
3132
"lint.fix": "yarn lint.prettier --write && yarn lint.eslint --fix",
@@ -37,7 +38,7 @@
3738
"test.harness": "yarn pretest.harness && jest -c test-harness/jest.config.mjs",
3839
"test.jest": "jest --silent --cacheDirectory=.cache/.jest",
3940
"test.karma": "karma start",
40-
"prepare": "husky install",
41+
"prepare": "husky install && yarn workspaces foreach run prepare",
4142
"prerelease": "patch-package",
4243
"release": "yarn prerelease && multi-semantic-release --deps.bump=satisfy",
4344
"jest": "jest"
@@ -58,6 +59,12 @@
5859
"@semantic-release/commit-analyzer",
5960
"@semantic-release/release-notes-generator",
6061
"@semantic-release/changelog",
62+
[
63+
"@semantic-release/exec",
64+
{
65+
"publishCmd": "node scripts/inline-version.mjs ${nextRelease.version}"
66+
}
67+
],
6168
"@semantic-release/npm",
6269
[
6370
"@semantic-release/github",
@@ -73,6 +80,7 @@
7380
"@commitlint/config-conventional": "^12.1.4",
7481
"@octokit/core": "^3.5.1",
7582
"@semantic-release/changelog": "^6.0.3",
83+
"@semantic-release/exec": "^6.0.3",
7684
"@semantic-release/git": "^10.0.1",
7785
"@semantic-release/github": "^8.1.0",
7886
"@semantic-release/npm": "^9.0.2",

packages/cli/package.json

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,8 @@
2424
"url": "https://github.com/stoplightio/spectral.git"
2525
},
2626
"scripts": {
27+
"prepare": "node scripts/inline-version.mjs",
28+
"postbuild": "node scripts/inline-version.mjs",
2729
"build.binary": "pkg . --output ./binaries/spectral",
2830
"build.windows": "pkg . --targets windows --out-path ./binaries",
2931
"build.nix": "pkg . --targets linux-x64,linux-arm64,macos-x64,macos-arm64,alpine-x64,alpine-arm64 --out-path ./binaries",
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
import * as fs from 'node:fs';
2+
import process from 'node:process';
3+
import { fileURLToPath } from 'node:url';
4+
import { join } from 'node:path';
5+
6+
const cwd = join(fileURLToPath(import.meta.url), '../..');
7+
8+
const version =
9+
process.argv.length === 3 ? process.argv[2] : JSON.parse(fs.readFileSync(join(cwd, 'package.json'), 'utf8')).version;
10+
11+
fs.writeFileSync(join(cwd, 'src/version.ts'), `export const VERSION = '${version}';\n`);

yarn.lock

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2453,6 +2453,22 @@ __metadata:
24532453
languageName: node
24542454
linkType: hard
24552455

2456+
"@semantic-release/exec@npm:^6.0.3":
2457+
version: 6.0.3
2458+
resolution: "@semantic-release/exec@npm:6.0.3"
2459+
dependencies:
2460+
"@semantic-release/error": ^3.0.0
2461+
aggregate-error: ^3.0.0
2462+
debug: ^4.0.0
2463+
execa: ^5.0.0
2464+
lodash: ^4.17.4
2465+
parse-json: ^5.0.0
2466+
peerDependencies:
2467+
semantic-release: ">=18.0.0"
2468+
checksum: c6ad2f02ff01a4709c4914f560d0343efea9afe993c733ff971da8bf89604a1460d87b26a1a2ace5992c5ace8e8d384cf314504e0c4b623fc8433e8e8d9e2fe0
2469+
languageName: node
2470+
linkType: hard
2471+
24562472
"@semantic-release/git@npm:^10.0.1":
24572473
version: 10.0.1
24582474
resolution: "@semantic-release/git@npm:10.0.1"
@@ -11469,6 +11485,7 @@ __metadata:
1146911485
"@commitlint/config-conventional": ^12.1.4
1147011486
"@octokit/core": ^3.5.1
1147111487
"@semantic-release/changelog": ^6.0.3
11488+
"@semantic-release/exec": ^6.0.3
1147211489
"@semantic-release/git": ^10.0.1
1147311490
"@semantic-release/github": ^8.1.0
1147411491
"@semantic-release/npm": ^9.0.2

0 commit comments

Comments
 (0)