Skip to content

Notify users of new versions and add commit update - #22

Merged
rafaeelricco merged 8 commits into
mainfrom
adding-new-version-banner
Apr 26, 2026
Merged

Notify users of new versions and add commit update#22
rafaeelricco merged 8 commits into
mainfrom
adding-new-version-banner

Conversation

@rafaeelricco

Copy link
Copy Markdown
Owner

Motivation

An essential feature to notify users about updates and help them always run the latest version of the tool. Enjoy!

What's New

Version Check Infrastructure

  • checkForUpdate in src/infra/version-check.ts queries registry.npmjs.org for the latest published version
  • 24h TTL cache stored at version-check.json under CONFIG_DIR to avoid hitting the registry on every run
  • Background refresh via detached node -e child process so the CLI never waits on network I/O
  • compareVersions helper for semver-style numeric comparison (major.minor.patch, ignores pre-release suffix)

Update Banner

  • renderUpdateBanner in src/infra/ui/update-banner.ts renders a @clack/prompts note showing current → latest
  • checkUpdate in src/cli/show-update-banner.ts wires the check into CLI startup
  • Suppressed when NO_UPDATE_NOTIFIER=true, when CI is set, or when stdout is not a TTY
  • Banner is rendered only when the cached latest version is greater than the local one

commit update Command

  • New Update command in src/cli/update.ts runs the global install for the detected package manager
  • detectPackageManager inspects process.argv[1] to pick pnpm add -g, yarn global add, or npm install -g
  • execBinInteractive in src/infra/shell.ts spawns with stdio: "inherit" so install progress streams to the user's terminal
  • exitCodeError helper extracted and reused by both execBin and execBinInteractive

CLI Parser & Help

  • update registered in CliCommand union and cliCommandDecoder
  • Default command switched from generate to -h so running commit with no args shows help
  • showVersion simplified to print just the version string
  • index.ts switched to absurd for exhaustive command checks and dropped the duplicate showHelp call on parse failure

Commit Error Logging

  • src/cli/commit.ts always logs the failure message via p.log.error, removing the prior instanceof Error guard that silently swallowed non-Error rejections

Testing & Feedback

  • Run the CLI on a machine where the local version is older than the latest npm release and confirm the banner renders once per 24h window
  • Verify the banner is suppressed under CI=true, NO_UPDATE_NOTIFIER=true, and when piping stdout
  • Run commit update under each package manager (pnpm, yarn, npm) and confirm the correct global install command is invoked with live output
  • Confirm commit with no arguments now prints help instead of running generate
  • Confirm commit --version / -v prints just the version string

If you find any bugs or have recommendations for improvements, please open an issue and assign it to me.

- Add `commit update` to install the latest package version with the detected package manager.
- Check cached npm registry metadata on startup and show an update banner when a newer version is available.
- Suppress update checks in CI, non-interactive output, or when `NO_UPDATE_NOTIFIER=true`.
- Add interactive shell execution for update installs and simplify `--version` output.
@rafaeelricco rafaeelricco self-assigned this Apr 25, 2026

@chatgpt-codex-connector chatgpt-codex-connector 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.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 8c20dadd22

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread src/infra/version-check.ts Outdated
Comment thread src/cli/update.ts Outdated
- Check the Yarn major version before selecting the Yarn global update command.
- Allow Yarn 1 global installs and reject modern Yarn with npm or pnpm install guidance.
- Preserve pnpm and npm update commands and existing interactive execution flow.
@rafaeelricco

Copy link
Copy Markdown
Owner Author

@codex review

@chatgpt-codex-connector chatgpt-codex-connector 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.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 4b07b19e71

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread index.ts Outdated
Comment thread src/cli/update.ts Outdated
@rafaeelricco
rafaeelricco merged commit 4863402 into main Apr 26, 2026
4 checks passed
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