fix(cli): accept source prefixes in the wizard package prompt - #86
Closed
mrrobertkent wants to merge 1 commit into
Closed
fix(cli): accept source prefixes in the wizard package prompt#86mrrobertkent wants to merge 1 commit into
mrrobertkent wants to merge 1 commit into
Conversation
The wizard passed manually-entered packages through untouched, so the `npm:`
prefix documented for `skilld add` crashed instead of resolving:
Enter package names > npm:unlighthouse
Error: Invalid package name: npm:unlighthouse
at getCacheDir (core/prepare.ts)
at getShippedSkills
`add` normalizes with `parseSkillInput`; the wizard did not. Do the same there,
and reject non-npm sources with a message pointing at `skilld add`.
Also stop `resolvePkgDir` propagating the validation error. It probes for an
optional cache hit, so a malformed name is a miss. The guard still rejects
traversal, it just no longer aborts the whole sync from a read path.
Contributor
Author
|
Closing in favour of a clean branch. |
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.
Problem
The interactive wizard rejects the source prefixes documented for
skilld add, with a stack trace rather than a message:addnormalizes its inputs:The wizard does not:
So
npm:unlighthousetravels as a literal package name untilgetCacheDirrejects it, and the throw takes down the whole run.Change
Normalize the same way
adddoes, at both manual-entry prompts.npm:prefixed and bare names resolve; other sources report where they belong instead of failing later:Second,
resolvePkgDirno longer lets the validation error escape. It probes for an optional cache hit, so a malformed name is a miss. Traversal is still rejected, it just no longer aborts a sync from a read path.getShippedSkillsis the only caller that could reach it with unvalidated input, and it already treats "not found" as empty.Testing
test/unit/pkg-dir-probe.test.tscovers the probe returning null fornpm:vue,gh:owner/repo, and../escaperather than throwing, andgetShippedSkillsreporting none.Normalization verified against the wizard's own splitting:
pnpm typecheckclean.Docs
README notes that the same prefixes work in the wizard prompt, and the placeholder now shows one (
vue npm:nuxt pinia).Out of scope
resolvePkgDir('', cwd, v)returns<cwd>/node_modules, becausejoin(cwd, 'node_modules', '')exists. No caller passes an empty name, so I left it alone rather than widen this PR.