Skip to content

Commit

Permalink
chore(cli): inline version
Browse files Browse the repository at this point in the history
  • Loading branch information
P0lip committed Sep 15, 2023
1 parent c528497 commit 2089270
Show file tree
Hide file tree
Showing 5 changed files with 41 additions and 2 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ node_modules

packages/formatters/src/html/templates.ts
packages/cli/binaries
packages/cli/src/version.ts
/test-harness/tmp/
/test-harness/tests/
packages/*/dist
Expand Down
12 changes: 10 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,8 @@
"scripts": {
"clean": "rimraf .cache packages/*/{dist,.cache}",
"prebuild": "yarn workspaces foreach run prebuild",
"build": "yarn prebuild && tsc --build ./tsconfig.build.json",
"build": "yarn prebuild && tsc --build ./tsconfig.build.json && yarn postbuild",
"postbuild": "yarn workspaces foreach run postbuild",
"prelint": "yarn workspaces foreach run prelint",
"lint": "yarn prelint && yarn lint.prettier && yarn lint.eslint",
"lint.fix": "yarn lint.prettier --write && yarn lint.eslint --fix",
Expand All @@ -37,7 +38,7 @@
"test.harness": "yarn pretest.harness && jest -c test-harness/jest.config.mjs",
"test.jest": "jest --silent --cacheDirectory=.cache/.jest",
"test.karma": "karma start",
"prepare": "husky install",
"prepare": "husky install && yarn workspaces foreach run prepare",
"prerelease": "patch-package",
"release": "yarn prerelease && multi-semantic-release --deps.bump=satisfy",
"jest": "jest"
Expand All @@ -58,6 +59,12 @@
"@semantic-release/commit-analyzer",
"@semantic-release/release-notes-generator",
"@semantic-release/changelog",
[
"@semantic-release/exec",
{
"publishCmd": "node scripts/inline-version.mjs ${nextRelease.version}"
}
],
"@semantic-release/npm",
[
"@semantic-release/github",
Expand All @@ -73,6 +80,7 @@
"@commitlint/config-conventional": "^12.1.4",
"@octokit/core": "^3.5.1",
"@semantic-release/changelog": "^6.0.3",
"@semantic-release/exec": "^6.0.3",
"@semantic-release/git": "^10.0.1",
"@semantic-release/github": "^8.1.0",
"@semantic-release/npm": "^9.0.2",
Expand Down
2 changes: 2 additions & 0 deletions packages/cli/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@
"url": "https://github.com/stoplightio/spectral.git"
},
"scripts": {
"prepare": "node scripts/inline-version.mjs",
"postbuild": "node scripts/inline-version.mjs",
"build.binary": "pkg . --output ./binaries/spectral",
"build.windows": "pkg . --targets windows --out-path ./binaries",
"build.nix": "pkg . --targets linux-x64,linux-arm64,macos-x64,macos-arm64,alpine-x64,alpine-arm64 --out-path ./binaries",
Expand Down
11 changes: 11 additions & 0 deletions packages/cli/scripts/inline-version.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
import * as fs from 'node:fs';
import process from 'node:process';
import { fileURLToPath } from 'node:url';
import { join } from 'node:path';

const cwd = join(fileURLToPath(import.meta.url), '../..');

const version =
process.argv.length === 3 ? process.argv[2] : JSON.parse(fs.readFileSync(join(cwd, 'package.json'), 'utf8')).version;

fs.writeFileSync(join(cwd, 'src/version.ts'), `export const VERSION = '${version}';\n`);
17 changes: 17 additions & 0 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -2453,6 +2453,22 @@ __metadata:
languageName: node
linkType: hard

"@semantic-release/exec@npm:^6.0.3":
version: 6.0.3
resolution: "@semantic-release/exec@npm:6.0.3"
dependencies:
"@semantic-release/error": ^3.0.0
aggregate-error: ^3.0.0
debug: ^4.0.0
execa: ^5.0.0
lodash: ^4.17.4
parse-json: ^5.0.0
peerDependencies:
semantic-release: ">=18.0.0"
checksum: c6ad2f02ff01a4709c4914f560d0343efea9afe993c733ff971da8bf89604a1460d87b26a1a2ace5992c5ace8e8d384cf314504e0c4b623fc8433e8e8d9e2fe0
languageName: node
linkType: hard

"@semantic-release/git@npm:^10.0.1":
version: 10.0.1
resolution: "@semantic-release/git@npm:10.0.1"
Expand Down Expand Up @@ -11469,6 +11485,7 @@ __metadata:
"@commitlint/config-conventional": ^12.1.4
"@octokit/core": ^3.5.1
"@semantic-release/changelog": ^6.0.3
"@semantic-release/exec": ^6.0.3
"@semantic-release/git": ^10.0.1
"@semantic-release/github": ^8.1.0
"@semantic-release/npm": ^9.0.2
Expand Down

0 comments on commit 2089270

Please sign in to comment.