Skip to content

feat: prompt for a new package name in the wizard#2

Merged
theoephraim merged 2 commits into
mainfrom
feat/new-name-wizard
Jun 18, 2026
Merged

feat: prompt for a new package name in the wizard#2
theoephraim merged 2 commits into
mainfrom
feat/new-name-wizard

Conversation

@theoephraim

Copy link
Copy Markdown
Member

What

Lets the interactive wizard create a brand-new package when there's no local one to work from.

Previously, running fledgling in a directory with no package.json dropped to a bare text prompt, and fledgling --new with no names just errored. Now both route into a proper "new name" flow.

Changes

  • New-name prompt in the wizard, triggered when there are no discovered packages or the user runs a bare fledgling --new (no names given).
  • Format validation as you typevalidatePackageName() enforces npm's rules (lowercase, ≤214 chars, valid scope, no leading dot/underscore, url-safe chars).
  • Availability check on submitisNameAvailable() does a fast HTTP HEAD to the registry (no npm view subprocess). 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.
  • The new target is marked isNew: true, so it flows into the existing taken-name handling and the "also set up trusted publishing?" opt-in.

Notes

  • Single name per run (matches the prompt UX); the downstream code already handles arrays, so multi-name entry is an easy follow-up.
  • Non-TTY --new with no name still errors as before — we can't prompt without a TTY.

Test plan

  • npm run typecheck passes
  • npm run build passes
  • Verified registry HEAD returns 404 for available names / 200 for taken, including scoped names (@scope/name%2f encoding)
  • Manual: fledgling in an empty dir → prompts for a name
  • Manual: fledgling --new in a repo → prompts for a name

…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.
@theoephraim theoephraim force-pushed the feat/new-name-wizard branch from bebc37c to d961663 Compare June 18, 2026 23:09
@github-actions

github-actions Bot commented Jun 18, 2026

Copy link
Copy Markdown

bumpy-frog

The changes in this PR will be included in the next version bump.

minor Minor releases

  • fledgling 1.0.0 → 1.1.0

Bump files in this PR

Click here if you want to add another bump file to this PR


This comment is maintained by bumpy.

@theoephraim theoephraim merged commit 9c4fe2d into main Jun 18, 2026
1 check 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