-
Notifications
You must be signed in to change notification settings - Fork 0
fix: read version from package.json instead of hardcoded string #18
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -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. |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -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 }; | ||
|
Comment on lines
+4
to
+5
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🟡 MEDIUM RISK Suggestion: Mixing A more modern and type-safe approach is to use TypeScript's native
|
||
| 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 <format>", "output format (table or json)", "table"); | ||
|
|
||
| registerInfoCommand(program); | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Mixing
requirestatements with ESimportstatements violates standard import ordering practices (such as the ESLintimport/firstrule).In TypeScript/JavaScript,
importstatements are hoisted to the top of the module scope during compilation, whereasrequireis executed at runtime in the order it appears. This means theimportstatements below this line will actually execute before thisrequirestatement.To maintain clean code structure and avoid potential linting or formatting issues, please move this
requirestatement below all theimportstatements (after the import ofregisterLogoutCommandon line 19).