Added publishing workflows and instructions for creating packages.#6
Added publishing workflows and instructions for creating packages.#6richardgaunt wants to merge 1 commit into
Conversation
This commit adds GitHub Actions workflows for automated testing and package publishing. The main improvements include: - Added publish-on-tag.yml workflow that publishes to GitHub Packages when a new tag is pushed - Added CHANGELOG.md for tracking release history - Updated package.json with version management scripts and prepublish hooks - Added detailed publishing documentation in PUBLISHING.md - Renamed package to cli-maker for consistency - Updated README with GitHub Packages installation instructions These changes allow for a simplified release process: 1. Update CHANGELOG.md with your changes 2. Run npm version commands (patch/minor/major) 3. Push tags to trigger automatic publishing wq
WalkthroughThis update introduces automated publishing workflows for GitHub Packages, including new GitHub Actions for publishing on tag and release events. The project is renamed from "Create CLI Template" to "CLI Maker" throughout documentation and configuration. New CLI entry points, changelog, publishing instructions, and version management scripts are added. Console logs are removed from test files. Changes
Sequence Diagram(s)sequenceDiagram
participant Developer
participant GitHub
participant GitHub Actions
participant NPM Registry
Developer->>GitHub: Push tag (vX.Y.Z) or create release
GitHub->>GitHub Actions: Trigger workflow (publish-on-tag.yml or publish.yml)
GitHub Actions->>GitHub Actions: Checkout code, setup Node.js, install dependencies, lint, test
GitHub Actions->>GitHub Actions: Extract version from tag/release, verify with package.json
GitHub Actions->>NPM Registry: Publish package to GitHub Packages (npm publish)
GitHub Actions->>GitHub: Create GitHub Release (with changelog and instructions)
Poem
Tip ⚡️ Faster reviews with caching
Enjoy the performance boost—your workflow just got faster. ✨ Finishing Touches
🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
SupportNeed help? Create a ticket on our support page for assistance with any issues or questions. Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. CodeRabbit Commands (Invoked using PR comments)
Other keywords and placeholders
CodeRabbit Configuration File (
|
There was a problem hiding this comment.
Actionable comments posted: 3
🧹 Nitpick comments (17)
test/scaffolded-cli-features.test.mjs (1)
122-122: Remove redundant comment.
The standalone comment// Creating a CLI application for feature testing.is a leftover from debug logging and doesn’t add actionable context. Consider removing it for clarity..github/workflows/publish.yml (2)
1-21: Add newline at end of file.
YAMLlint reports a missing newline at EOF. Please append a blank line to satisfy the linter.🧰 Tools
🪛 YAMLlint (1.35.1)
[error] 21-21: no new line character at the end of file
(new-line-at-end-of-file)
17-19: Consider caching npm dependencies.
To speed upnpm ciin CI runs, you can add a cache step:- uses: actions/cache@v3 with: path: ~/.npm key: ${{ runner.os }}-node-${{ hashFiles('**/package-lock.json') }} restore-keys: | ${{ runner.os }}-node-CHANGELOG.md (1)
8-8: Replace placeholder release date.
Update theYYYY-MM-DDin the## [1.0.0] - YYYY-MM-DDheader with the actual release date per the Keep a Changelog format.bin/cli.mjs (2)
3-4: Ensure compatibility with ESM async commands
IfcreateCommandreturns a Promise, consider usingprogram.parseAsync()instead ofprogram.parse()to properly await async handlers and capture errors.- program.parse(); + await program.parseAsync();You may need to wrap it in an async IIFE:
#!/usr/bin/env node ;(async () => { const program = new Command(); // ... configure program await program.parseAsync(); })();[safety]
9-11: Avoid hardcoding the version string
Duplicating the version in bothbin/cli.mjsandpackage.jsoncan drift out of sync. Consider importing the version frompackage.json:import { version } from '../package.json' assert { type: 'json' }; program.version(version);package.json (1)
2-61: Consider defining supported Node engines
Since CI uses Node.js 20.x, add an"engines"field to communicate compatibility and prevent installs on unsupported versions:"type": "module", + "engines": { + "node": ">=16" + }, "bin": {.github/workflows/publish-on-tag.yml (1)
51-52: Updatesoftprops/action-gh-releaseto latest stable
actionlint flags thatsoftprops/action-gh-release@v1is outdated. Upgrade to the latest version (e.g.,@v1.18.0or@v1tag with latest patch):- uses: softprops/action-gh-release@v1 + uses: softprops/action-gh-release@v1.18.0🧰 Tools
🪛 actionlint (1.7.4)
52-52: the runner of "softprops/action-gh-release@v1" action is too old to run on GitHub Actions. update the action's version to fix this issue
(action)
PUBLISHING.md (7)
5-9: Clarify authentication for automated workflows vs manual publishing
Consider explicitly mentioning that the GitHub Actions workflow uses the built-inGITHUB_TOKENsecret, so users only need a personal access token when performing manual publishes. This will help avoid confusion between automated and manual steps.
10-13: Link to workflow file for quick access
To improve navigability, make the workflow path clickable by using a Markdown link, e.g.:[`.github/workflows/publish-on-tag.yml`](.github/workflows/publish-on-tag.yml)
14-33: Enhance version bump step with script references
In the “Bump Version” section, it may be helpful to reference the actual npm scripts inpackage.json(e.g.,"version:patch","version:minor","version:major") and note that they update bothpackage.jsonandCHANGELOG.md. This gives users clearer context on what those commands do under the hood.
43-74: Consider adding caching to the CI workflow
To speed up installs, you could introduceactions/cachefor~/.npmor the project’s node_modules. For example:- uses: actions/cache@v3 with: path: ~/.npm key: ${{ runner.os }}-npm-${{ hashFiles('package-lock.json') }} restore-keys: ${{ runner.os }}-npm-
76-106: Expand on publishing workflow steps or remove placeholder
The snippet ends with# Additional steps.... Please either flesh out the actual steps (e.g.,npm publish, changelog validation, release notes generation) or replace the placeholder with a note linking to the full workflow file.
122-137: Local testing: mention cleanup of previous links
Consider adding a note about runningnpm unlink(or removing previously linked globals) beforenpm link, to avoid conflicts if the package was already linked.
138-151: Add reference to GitHub docs for PAT scopes
For manual publishing, linking to the GitHub documentation on creating a personal access token and the required scopes can help users ensure they set up their tokens correctly.test/cli-stdin-timing.test.mjs (2)
246-264: Cover exit code for invalid command scenario
Great addition of the invalid-command test to ensure error handling. To make this more robust, consider also asserting the process exit code (e.g., non-zero) and/or checkingstderrto verify where the error is reported.
282-306: Assert exit code and stderr for help command
The help command test is thorough in matching usage patterns, but you may want to assert thathelpCommandResult.code === 0and thatstderris empty to guarantee the command succeeded cleanly and without warnings.
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (11)
.github/workflows/publish-on-tag.yml(1 hunks).github/workflows/publish.yml(1 hunks)CHANGELOG.md(1 hunks)PR_DESCRIPTION.md(1 hunks)PUBLISHING.md(1 hunks)README.md(4 hunks)bin/cli.mjs(1 hunks)package.json(2 hunks)test/cli-error-handling.test.mjs(1 hunks)test/cli-stdin-timing.test.mjs(2 hunks)test/scaffolded-cli-features.test.mjs(1 hunks)
🧰 Additional context used
🪛 YAMLlint (1.35.1)
.github/workflows/publish.yml
[error] 21-21: no new line character at the end of file
(new-line-at-end-of-file)
.github/workflows/publish-on-tag.yml
[error] 57-57: trailing spaces
(trailing-spaces)
[error] 59-59: trailing spaces
(trailing-spaces)
[error] 61-61: trailing spaces
(trailing-spaces)
[error] 65-65: trailing spaces
(trailing-spaces)
🪛 actionlint (1.7.4)
.github/workflows/publish-on-tag.yml
52-52: the runner of "softprops/action-gh-release@v1" action is too old to run on GitHub Actions. update the action's version to fix this issue
(action)
🔇 Additional comments (5)
test/cli-error-handling.test.mjs (1)
142-142: Removed unnecessary debug output for cleaner tests.
The inline comment was updated to remove the oldconsole.logdebug statement, reducing noise during CI runs without affecting the assertion logic.PR_DESCRIPTION.md (1)
1-52: Overall summary alignment
ThePR_DESCRIPTION.mdaccurately reflects the additions of CI workflows, documentation, and versioning scripts. No inconsistencies detected.PUBLISHING.md (3)
1-4: Clear and descriptive header
The title and introductory lines concisely convey the purpose of this document.
34-42: Steps for pushing and monitoring are clear
The instructions for pushing tags, monitoring the workflow, and verifying the published package are straightforward and actionable.
108-120: Usage instructions are accurate
The commands for installing via npm and invoking withnpxcorrectly reflect the published package name and usage patterns.
| A starter kit generator for CLI applications. This tool helps you quickly scaffold a new command-line interface application with all the necessary configurations. | ||
|
|
||
| [](https://github.com/richardgaunt/cli-starter/actions/workflows/tests.yml) | ||
| [](https://github.com/richardgaunt/cli-maker/actions/workflows/tests.yml) |
There was a problem hiding this comment.
Fix broken Actions badge path
The badge references tests.yml but the workflow file is named test.yml. Update the URL to point to the correct workflow:
-[]
+[]Committable suggestion skipped: line range outside the PR's diff.
| "name": "cli-maker", | ||
| "version": "1.0.0", |
There was a problem hiding this comment.
Verify and update commander version
The PR merges a previous upgrade to commander@13.1.0 but package.json still pins "commander": "^11.1.0". Please confirm the intended version and update accordingly to avoid mismatches:
- "dependencies": {
- "commander": "^11.1.0",
+ "dependencies": {
+ "commander": "^13.1.0",Also applies to: 47-48
| body: | | ||
| ## Changes in this Release | ||
|
|
||
| - See the [CHANGELOG.md](./CHANGELOG.md) for details | ||
|
|
||
| ## Installation | ||
|
|
||
| ```bash | ||
| # Install from GitHub Packages | ||
| npm install -g @richardgaunt/cli-maker | ||
|
|
||
| # Or use with npx | ||
| npx @richardgaunt/cli-maker my-cli-app | ||
| ``` | ||
| draft: false |
There was a problem hiding this comment.
Remove trailing spaces to satisfy YAMLlint
YAMLlint errors are reported for trailing spaces in the release body. Here's a diff to strip them:
- body: |
- ## Changes in this Release
-
- - See the [CHANGELOG.md](./CHANGELOG.md) for details
-
- ## Installation
-
- ```bash
- # Install from GitHub Packages
- npm install -g @richardgaunt/cli-maker
-
- # Or use with npx
- npx @richardgaunt/cli-maker my-cli-app
- ```
+ body: |
+ ## Changes in this Release
+
+ - See the [CHANGELOG.md](./CHANGELOG.md) for details
+
+ ## Installation
+
+ ```bash
+ # Install from GitHub Packages
+ npm install -g @richardgaunt/cli-maker
+
+ # Or use with npx
+ npx @richardgaunt/cli-maker my-cli-app
+ ```🧰 Tools
🪛 YAMLlint (1.35.1)
[error] 57-57: trailing spaces
(trailing-spaces)
[error] 59-59: trailing spaces
(trailing-spaces)
[error] 61-61: trailing spaces
(trailing-spaces)
[error] 65-65: trailing spaces
(trailing-spaces)
Checklist before requesting a review
Changed
This commit adds GitHub Actions workflows for automated testing and package
publishing. The main improvements include:
These changes allow for a simplified release process:
Summary by CodeRabbit
New Features
Documentation
Style