Skip to content

Added publishing workflows and instructions for creating packages.#6

Open
richardgaunt wants to merge 1 commit into
mainfrom
feature/add-publishing
Open

Added publishing workflows and instructions for creating packages.#6
richardgaunt wants to merge 1 commit into
mainfrom
feature/add-publishing

Conversation

@richardgaunt

@richardgaunt richardgaunt commented May 12, 2025

Copy link
Copy Markdown
Owner

Checklist before requesting a review

  • This PR does not have an associated ticket
  • I have provided information in section about WHY something was done if this was not a normal implementation
  • I have performed a self-review of my code
  • I have commented my code, particularly in hard-to-understand areas
  • I have added tests that prove my fix is effective or that my feature works
  • I have run new and existing relevant tests locally with my changes, and they passed
  • I have provided screenshots, where applicable

Changed

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

Summary by CodeRabbit

  • New Features

    • Introduced a command-line tool, "cli-maker", for generating new CLI applications with customizable options.
    • Added automated publishing workflows to GitHub Packages, triggered by version tags or releases.
    • Included semantic version management scripts for streamlined version bumping.
  • Documentation

    • Added comprehensive guides for publishing, changelog tracking, and updated all references to the new project name.
    • Expanded README with installation and usage instructions for "cli-maker".
  • Style

    • Removed debug logging from test suites for cleaner test output.

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
@coderabbitai

coderabbitai Bot commented May 12, 2025

Copy link
Copy Markdown

Walkthrough

This 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

File(s) Change Summary
.github/workflows/publish-on-tag.yml, .github/workflows/publish.yml Added GitHub Actions workflows for automated package publishing: one triggered by version tags and another by release creation, both handling checkout, Node.js setup, dependency installation, testing, and publishing to GitHub Packages.
CHANGELOG.md, PUBLISHING.md, PR_DESCRIPTION.md, README.md Added or updated documentation: changelog using Keep a Changelog format, publishing instructions, PR description with workflow/testing details, and README reflecting the new project name ("CLI Maker"), usage, and installation from GitHub Packages.
bin/cli.mjs Introduced a new CLI entry script using Commander.js, defining the cli-maker command with options for skipping prompts, git initialization, and dependency installation, and linking to the main create command.
package.json Renamed package to "cli-maker", updated bin entry, added version management and pre-publish scripts, updated metadata, and configured publish settings for GitHub Packages.
test/cli-error-handling.test.mjs, test/cli-stdin-timing.test.mjs, test/scaffolded-cli-features.test.mjs Removed all console.log debug statements from test files to clean up test output; no changes to logic, assertions, or control flow.

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)
Loading

Poem

In the warren of code, a new name we cheer,
"CLI Maker" hops forward, its purpose is clear!
With workflows that publish at the twitch of a tag,
And changelogs that sparkle—no detail will lag.
Console logs vanish, the tests run with grace,
As rabbits of progress, we bound into place!
🐇✨

Tip

⚡️ Faster reviews with caching
  • CodeRabbit now supports caching for code and dependencies, helping speed up reviews. This means quicker feedback, reduced wait times, and a smoother review experience overall. Cached data is encrypted and stored securely. This feature will be automatically enabled for all accounts on May 16th. To opt out, configure Review - Disable Cache at either the organization or repository level. If you prefer to disable all data retention across your organization, simply turn off the Data Retention setting under your Organization Settings.

Enjoy the performance boost—your workflow just got faster.

✨ Finishing Touches
  • 📝 Generate Docstrings

🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Generate unit testing code for this file.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai generate unit testing code for this file.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and generate unit testing code.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Support

Need 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)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings to generate docstrings for this PR.
  • @coderabbitai generate sequence diagram to generate a sequence diagram of the changes in this PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 up npm ci in 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 the YYYY-MM-DD in the ## [1.0.0] - YYYY-MM-DD header with the actual release date per the Keep a Changelog format.

bin/cli.mjs (2)

3-4: Ensure compatibility with ESM async commands
If createCommand returns a Promise, consider using program.parseAsync() instead of program.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 both bin/cli.mjs and package.json can drift out of sync. Consider importing the version from package.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: Update softprops/action-gh-release to latest stable
actionlint flags that softprops/action-gh-release@v1 is outdated. Upgrade to the latest version (e.g., @v1.18.0 or @v1 tag 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-in GITHUB_TOKEN secret, 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 in package.json (e.g., "version:patch", "version:minor", "version:major") and note that they update both package.json and CHANGELOG.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 introduce actions/cache for ~/.npm or 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 running npm unlink (or removing previously linked globals) before npm 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 checking stderr to 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 that helpCommandResult.code === 0 and that stderr is empty to guarantee the command succeeded cleanly and without warnings.

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 74e2ac2 and da4db69.

📒 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 old console.log debug statement, reducing noise during CI runs without affecting the assertion logic.

PR_DESCRIPTION.md (1)

1-52: Overall summary alignment
The PR_DESCRIPTION.md accurately 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 with npx correctly reflect the published package name and usage patterns.

Comment thread README.md
A starter kit generator for CLI applications. This tool helps you quickly scaffold a new command-line interface application with all the necessary configurations.

[![Tests](https://github.com/richardgaunt/cli-starter/actions/workflows/tests.yml/badge.svg)](https://github.com/richardgaunt/cli-starter/actions/workflows/tests.yml)
[![Tests](https://github.com/richardgaunt/cli-maker/actions/workflows/tests.yml/badge.svg)](https://github.com/richardgaunt/cli-maker/actions/workflows/tests.yml)

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue

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:

-[![Tests](https://github.com/richardgaunt/cli-maker/actions/workflows/tests.yml/badge.svg)]
+[![Tests](https://github.com/richardgaunt/cli-maker/actions/workflows/test.yml/badge.svg)]

Committable suggestion skipped: line range outside the PR's diff.

Comment thread package.json
Comment on lines +2 to 3
"name": "cli-maker",
"version": "1.0.0",

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue

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

Comment on lines +55 to +69
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

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue

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)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant