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 14, 2023
1 parent c528497 commit 6d69a51
Show file tree
Hide file tree
Showing 4 changed files with 15 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
5 changes: 3 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 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
9 changes: 9 additions & 0 deletions packages/cli/scripts/inline-version.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
import * as fs from 'node:fs/promises';
import { fileURLToPath } from 'node:url';
import { join } from 'node:path';

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

const { version } = JSON.parse(await fs.readFile(join(cwd, 'package.json'), 'utf8'));

await fs.writeFile(join(cwd, 'src/version.ts'), `export const VERSION = '${version}';\n`);

0 comments on commit 6d69a51

Please sign in to comment.