Skip to content

Commit 7b09b5b

Browse files
fix: read version from package.json instead of hardcoded string (#18)
Co-authored-by: Claude <noreply@anthropic.com>
1 parent 32a2203 commit 7b09b5b

2 files changed

Lines changed: 8 additions & 1 deletion

File tree

.changeset/fix-version-flag.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"@codacy/codacy-cloud-cli": patch
3+
---
4+
5+
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.

src/index.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
#!/usr/bin/env node
22
import { Command } from "commander";
33
import { OpenAPI } from "./api/client/core/OpenAPI";
4+
// eslint-disable-next-line @typescript-eslint/no-require-imports
5+
const { version } = require("../package.json") as { version: string };
46
import { registerInfoCommand } from "./commands/info";
57
import { registerRepositoriesCommand } from "./commands/repositories";
68
import { registerRepositoryCommand } from "./commands/repository";
@@ -27,7 +29,7 @@ OpenAPI.HEADERS = {
2729
program
2830
.name("codacy-cloud-cli")
2931
.description("A CLI tool to interact with the Codacy API")
30-
.version("1.0.0")
32+
.version(version)
3133
.option("-o, --output <format>", "output format (table or json)", "table");
3234

3335
registerInfoCommand(program);

0 commit comments

Comments
 (0)