From 94c944c6d1685609683e814f932dedffdaebd0bb Mon Sep 17 00:00:00 2001 From: manufacturist <15235526+manufacturist@users.noreply.github.com> Date: Fri, 19 Jun 2026 15:48:09 +0300 Subject: [PATCH] fix: read version from package.json instead of hardcoded string The --version flag was always printing "1.0.0" because the version string in src/index.ts was never updated alongside package.json bumps. Replaced it with a runtime require("../package.json").version so future releases automatically reflect the correct version. Co-Authored-By: Claude --- .changeset/fix-version-flag.md | 5 +++++ src/index.ts | 4 +++- 2 files changed, 8 insertions(+), 1 deletion(-) create mode 100644 .changeset/fix-version-flag.md 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);