fix: read version from package.json, add CI workflow, gitignore package-lock#14
fix: read version from package.json, add CI workflow, gitignore package-lock#14
Conversation
Summary of ChangesHello, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed! This pull request focuses on enhancing the project's development workflow and consistency. It introduces dynamic version management for the CLI, sets up a continuous integration pipeline to validate builds, and refines the Highlights
Changelog
Ignored Files
Activity
Using Gemini Code AssistThe full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips. Invoking Gemini You can request assistance from Gemini at any point by creating a comment using either
Customization To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a Limitations & Feedback Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for GitHub and other Google products, sign up here. You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension. Footnotes
|
There was a problem hiding this comment.
Code Review
This pull request updates the CLI to read its version from package.json and modifies the .gitignore file. My review focuses on these changes. I've suggested an improvement for how the version is imported in index.ts to use modern TypeScript features and correct a potentially incorrect file path. I've also raised a concern about ignoring package-lock.json, as this can affect build reproducibility, which is crucial for a CLI application. The changes are a good step towards automation and consistency, and my suggestions aim to further improve maintainability and reliability.
| @@ -1,2 +1,3 @@ | |||
| node_modules/ | |||
| dist/ | |||
| packages/cli/package-lock.json | |||
There was a problem hiding this comment.
It is generally recommended to commit package-lock.json for applications, including CLI tools. This ensures reproducible builds for all developers and in CI environments by locking down the exact versions of all dependencies.
Ignoring the lock file can lead to different developers or environments using different dependency versions, which may introduce hard-to-debug issues. For a CLI tool, which is an application, committing the lock file is standard practice. I would recommend removing this line and committing the package-lock.json file to ensure dependency consistency.
| // eslint-disable-next-line @typescript-eslint/no-require-imports | ||
| const { version } = require('../../package.json'); |
There was a problem hiding this comment.
The path to package.json seems incorrect, and there's a cleaner way to import JSON files in TypeScript.
-
Path Issue: The path
'../../package.json'appears to point to apackage.jsonfile at the project root, not the CLI's ownpackage.jsonlocated atpackages/cli/package.json. To read the version of the CLI package itself, the path should likely be'../package.json'. -
Import Style: Instead of using
requireand disabling the ESLint rule, you can enable"resolveJsonModule": truein yourtsconfig.jsonand use an ES moduleimportstatement. This is the modern and recommended approach for handling JSON files in TypeScript.
Here is a suggested change that addresses both points:
| // eslint-disable-next-line @typescript-eslint/no-require-imports | |
| const { version } = require('../../package.json'); | |
| import { version } from '../package.json'; |
Closes #10, #11, #12.
Changes
index.tsnow reads version frompackage.jsonviarequire()instead of hardcoding'0.1.0'.github/workflows/ci.yml: runsnpm install+npm run build(tsc) on every PR targetingmain, using the self-hosted runnerpackages/cli/package-lock.jsonto.gitignorefrom CC