Skip to content

refactor: integrate @doist/cli-core 0.7.1 (update command)#321

Merged
scottlovegrove merged 3 commits into
mainfrom
scottl/update-core
May 9, 2026
Merged

refactor: integrate @doist/cli-core 0.7.1 (update command)#321
scottlovegrove merged 3 commits into
mainfrom
scottl/update-core

Conversation

@scottlovegrove
Copy link
Copy Markdown
Collaborator

@scottlovegrove scottlovegrove commented May 9, 2026

Summary

  • Bump @doist/cli-core to 0.7.1 and replace the local td update / td update switch implementation with registerUpdateCommand from @doist/cli-core/commands (cli-core#9)
  • Drop ~190 lines of local action/switch logic and the 490-line test file — behaviour is now covered by 34 cli-core tests
  • src/lib/update.ts shrinks to a thin re-export of cli-core's semver helpers plus a tolerant getConfiguredUpdateChannel for td doctor (so an invalid update_channel surfaces as a config-validation warning rather than a hard error)
  • packageName now comes from package.json instead of being hard-coded

Behaviour change

Production td update is now stricter:

  • Invalid update_channel in config raises INVALID_UPDATE_CHANNEL instead of being silently passed through
  • Errors emit canonical CliError codes (INVALID_FLAGS, UPDATE_CHECK_FAILED, UPDATE_INSTALL_FAILED)
  • Both subcommands accept --json / --ndjson envelopes

Test plan

  • npm run check clean
  • npm run type-check clean
  • npm test — 1556 tests pass
  • Smoke: td update --check, td update --check --json, td update --channel, td update switch --pre-release, td update switch --stable
  • Smoke: td doctor with valid + invalid update_channel in config

🤖 Generated with Claude Code

Replace the local `td update` / `td update switch` implementation with
`registerUpdateCommand` from `@doist/cli-core/commands`. The shared command
brings strict channel validation (`INVALID_UPDATE_CHANNEL`), canonical
`CliError` codes (`INVALID_FLAGS`, `UPDATE_CHECK_FAILED`,
`UPDATE_INSTALL_FAILED`), and `--json` / `--ndjson` envelopes — behaviour
already covered by 34 cli-core tests, so the local action/switch/test
files are dropped.

`src/lib/update.ts` keeps a tolerant `getConfiguredUpdateChannel` for
`td doctor` (so an invalid `update_channel` surfaces as a config-validation
warning rather than a hard error) and re-exports the semver helpers from
cli-core.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@doistbot doistbot requested a review from pauloslund May 9, 2026 12:19
Copy link
Copy Markdown
Member

@doistbot doistbot left a comment

Choose a reason for hiding this comment

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

This PR nicely integrates @doist/cli-core 0.7.0 by delegating the update command logic to the core library, successfully dropping a substantial amount of custom code. Leveraging the shared command improves maintainability while introducing stricter validation and helpful new JSON output options. A couple of minor details to address include updating SKILL_CONTENT to document the new JSON flags and retaining a lightweight local test to verify the repo-specific command wiring.

Share FeedbackReview Logs

Comment thread src/commands/update/index.ts
Comment thread src/commands/update/index.ts
Picks up the dist-tag fetch fix (Doist/cli-core#10) — `td update` was
failing with `UPDATE_CHECK_FAILED: HTTP 406` because cli-core 0.7.0 sent
the abbreviated-metadata `Accept` header on a dist-tag URL, which the
npm registry rejects.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@scottlovegrove scottlovegrove changed the title refactor: integrate @doist/cli-core 0.7.0 (update command) refactor: integrate @doist/cli-core 0.7.1 (update command) May 9, 2026
@scottlovegrove scottlovegrove self-assigned this May 9, 2026
@scottlovegrove scottlovegrove added the 👀 Show PR PR must be reviewed before or after merging label May 9, 2026
- Document `td update --check --json` and `td update switch --pre-release --json`
  in SKILL_CONTENT (per AGENTS.md: any new flag must reach the agent skill).
- Add a thin wrapper test covering what cli-core's tests can't see — that
  `registerUpdateCommand` forwards the right `packageName`, `currentVersion`,
  `configPath`, `changelogCommandName`, and `withSpinner` to cli-core, plus
  one parse-level smoke that drives `td update --check` end-to-end against
  a stubbed `fetch` and asserts the resolved registry URL matches
  `package.json#name`.

Addresses review on #321.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@scottlovegrove scottlovegrove merged commit 5a09425 into main May 9, 2026
4 checks passed
@scottlovegrove scottlovegrove deleted the scottl/update-core branch May 9, 2026 12:43
@doist-release-bot
Copy link
Copy Markdown
Contributor

🎉 This PR is included in version 1.62.2 🎉

The release is available on:

Your semantic-release bot 📦🚀

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

Labels

released 👀 Show PR PR must be reviewed before or after merging

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants