Skip to content

fix(cli): read version from package.json instead of hardcoding it - #437

Open
angelraph wants to merge 1 commit into
Open-audit-foundation:mainfrom
angelraph:fix/cli-version-from-package-json
Open

fix(cli): read version from package.json instead of hardcoding it#437
angelraph wants to merge 1 commit into
Open-audit-foundation:mainfrom
angelraph:fix/cli-version-from-package-json

Conversation

@angelraph

Copy link
Copy Markdown
Contributor

Summary

cli/open-audit-cli.ts hardcoded .version("1.0.0") while package.json's version field is "0.1.0" — so open-audit-cli --version reported a release that doesn't exist.

Fix

Import the version directly from package.json (JSON module resolution is already enabled in the build:cli script) instead of hardcoding a string, so there's a single source of truth.

-import { readFileSync, existsSync } from "fs";
-import { resolve } from "path";
-import { parse as parseYaml } from "yaml";
+import { readFileSync, existsSync } from "fs";
+import { resolve } from "path";
+import { parse as parseYaml } from "yaml";
+import { version as packageVersion } from "../package.json";
 ...
 program
   .name("open-audit-cli")
-  .version("1.0.0")
+  .version(packageVersion)

Verification

  • npm run build:cli && node dist/cli/open-audit-cli.js --version0.1.0, matching package.json.
  • Bumped package.json's version locally, rebuilt, confirmed the CLI's reported version updated with zero code changes, then reverted.
  • Ran cli/test-cli.sh before and after the change — the version test passes; a pre-existing, unrelated failure (translation blueprint matching) reproduces identically on unmodified main.

Note

I see #430 is also open against this issue. Assigning maintainer's call on which lands — flagging for visibility since our diffs are both about the same line, just wanted to make sure my assignment on the issue was fulfilled.

Closes #426

cli/open-audit-cli.ts hardcoded .version("1.0.0") while package.json's
version field is "0.1.0", causing open-audit-cli --version to report a
release that doesn't exist.

Import the version field from package.json (resolveJsonModule is already
enabled in the build:cli script) so the CLI's reported version always
matches package.json, with no separate value to keep in sync.

Closes Open-audit-foundation#426
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Fix the CLI's hardcoded version string — it doesn't match package.json

1 participant