feat: framework-agnostic runSelfUpdate helper#2
Merged
Conversation
Adds runSelfUpdate({ packageName, currentVersion, header?, registry?, check? })
so any npm-distributed consuming CLI can offer an update/install-latest command
without re-implementing the registry query, version compare, and global install.
No oclif dependency -- callable from a plain dispatcher (e.g. quoin) as readily
as from a BaseCommand. Renders via ix-ui-cli and returns { updated, latest }.
Registry defaults to the ambient npm config (mirrors however the caller was
installed); a registry override is applied as the scope-specific
--<scope>:registry= flag for scoped packages, because a plain --registry is
silently ignored for a scoped package when an npmrc pins a @scope:registry.
Adds FR-023 + tests.md traceability.
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
Adds a reusable `runSelfUpdate` helper so any npm-distributed IX CLI can offer an `update`/install-latest command without re-implementing the registry query, version comparison, and global install.
```ts
runSelfUpdate({ packageName, currentVersion, header?, registry?, check? }): Promise<{ updated, latest }>
```
Registry resolution
Defaults to the ambient npm config — i.e. however the caller was installed (its `@scope:registry`, or the npm default) — rather than a hardcoded registry. When a `registry` override is supplied it is applied as the scope-specific `--:registry=` flag for a scoped package, because a plain `--registry` is silently ignored for a scoped package when an npmrc pins a `@scope:registry`. Unscoped packages use a plain `--registry`.
Spec
Tests
`tests/self-update.test.ts` (vitest): up-to-date, `--check` update-available, install-when-out-of-date, scoped vs unscoped registry override, ambient default (no flag), and registry-unreachable rejection. Mocks only the external edges (`node:child_process`, `@agent-ix/ix-ui-cli`). `make lint`/`make test`/`make build` green.
Consumer
`@agent-ix/quoin`'s `update` command consumes this (separate PR). Note: quoin must relock to the release that includes this export before its `update` works at runtime.
🤖 Generated with Claude Code