Single-source the version from package.json (closes #5)
check / check (push) Successful in 33s
check / check (push) Successful in 33s
src/index.ts imports package.json for VERSION and bin/quak.ts passes VERSION to commander, so package.json is the only place the version is written. tsc copies package.json to dist/package.json, so the import resolves from the built output; script/build runs the built CLI with --version to prove it. A test checks VERSION and quak --version against package.json. Model: opus-5-5
This commit is contained in:
@@ -45,10 +45,24 @@ for (const bin of bins) {
|
||||
'
|
||||
}
|
||||
|
||||
# src/index.ts imports ../package.json for the version, which tsc copies to
|
||||
# dist/package.json. Running the built CLI proves that import resolves from
|
||||
# dist/ and reports the version package.json declares.
|
||||
verify_version() {
|
||||
built="$(node dist/bin/quak.js --version)"
|
||||
declared="$(node -p 'require("./package.json").version')"
|
||||
if [ "$built" != "$declared" ]; then
|
||||
echo "build: dist/bin/quak.js reports $built, package.json declares $declared" >&2
|
||||
exit 1
|
||||
fi
|
||||
echo "build: dist/bin/quak.js reports version $built"
|
||||
}
|
||||
|
||||
main() {
|
||||
cd "$ROOT"
|
||||
yarn run tsc
|
||||
verify_entrypoints
|
||||
verify_version
|
||||
}
|
||||
|
||||
main "$@"
|
||||
|
||||
Reference in New Issue
Block a user