feat: prompt for a new package name in the wizard#2
Merged
Conversation
…check) When the wizard finds no package.json, or when run as a bare `fledgling --new` with no names, prompt for a name to claim instead of bailing. The name is format-validated as you type (npm rules) and its availability is checked on submit via a fast HTTP HEAD to the registry, so a taken name re-prompts rather than failing later at claim time. Adds validatePackageName() and isNameAvailable() to npm.ts.
bebc37c to
d961663
Compare
|
The changes in this PR will be included in the next version bump.
|
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
Lets the interactive wizard create a brand-new package when there's no local one to work from.
Previously, running
fledglingin a directory with nopackage.jsondropped to a bare text prompt, andfledgling --newwith no names just errored. Now both route into a proper "new name" flow.Changes
fledgling --new(no names given).validatePackageName()enforces npm's rules (lowercase, ≤214 chars, valid scope, no leading dot/underscore, url-safe chars).isNameAvailable()does a fast HTTPHEADto the registry (nonpm viewsubprocess). A taken name re-prompts (red,❌) instead of failing downstream at claim time. If the registry is unreachable, it says so and continues — the authoritative check still runs before the claim.isNew: true, so it flows into the existing taken-name handling and the "also set up trusted publishing?" opt-in.Notes
--newwith no name still errors as before — we can't prompt without a TTY.Test plan
npm run typecheckpassesnpm run buildpassesHEADreturns 404 for available names / 200 for taken, including scoped names (@scope/name→%2fencoding)fledglingin an empty dir → prompts for a namefledgling --newin a repo → prompts for a name