diff --git a/.changeset/fix-version-flag.md b/.changeset/fix-version-flag.md new file mode 100644 index 0000000..24e8cd5 --- /dev/null +++ b/.changeset/fix-version-flag.md @@ -0,0 +1,5 @@ +--- +"@codacy/codacy-cloud-cli": patch +--- + +Fix `--version` flag reporting hardcoded `1.0.0` instead of the actual package version. The CLI now reads the version dynamically from `package.json` at runtime via `require`, so the reported version stays in sync with every release automatically. diff --git a/src/index.ts b/src/index.ts index 02e4c95..d024fba 100644 --- a/src/index.ts +++ b/src/index.ts @@ -1,6 +1,8 @@ #!/usr/bin/env node import { Command } from "commander"; import { OpenAPI } from "./api/client/core/OpenAPI"; +// eslint-disable-next-line @typescript-eslint/no-require-imports +const { version } = require("../package.json") as { version: string }; import { registerInfoCommand } from "./commands/info"; import { registerRepositoriesCommand } from "./commands/repositories"; import { registerRepositoryCommand } from "./commands/repository"; @@ -27,7 +29,7 @@ OpenAPI.HEADERS = { program .name("codacy-cloud-cli") .description("A CLI tool to interact with the Codacy API") - .version("1.0.0") + .version(version) .option("-o, --output ", "output format (table or json)", "table"); registerInfoCommand(program);