feat(cli): prompt to run npm init when package.json is missing#72
Merged
feat(cli): prompt to run npm init when package.json is missing#72
Conversation
Instead of failing immediately when no package.json is found, the init command now asks the user if they'd like to run npm init first. If they accept, npm init runs interactively and we continue scaffolding. If they decline, the command exits cleanly with a short message. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
The flag auto-accepts the npm init confirmation prompt and passes -y through to npm init itself, making the command suitable for scripts and CI. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Pairing `shell: true` with an args array triggers Node's DEP0190 deprecation warning because the args aren't escaped. Switch to spawning the platform-correct npm binary directly (`npm.cmd` on Windows, `npm` elsewhere) so we don't need shell mode. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
- Short-circuit promptYesNo to false when stdin is not a TTY, so piped/CI invocations without --yes don't hang on a closed stream - Move the prompt's readline output from stderr to stdout for parity with typical CLI prompt conventions - Make the "without yes" spawn assertion platform-agnostic - Add a comment at the runNpmInit call site noting npm init is responsible for creating package.json before the read below Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
mpfilbin
approved these changes
May 7, 2026
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.
Summary
we initnow detects a missingpackage.jsonand asks the user if they'd like to runnpm initinstead of failing immediatelynpm initruns interactively andwe initcontinues scaffolding once it completes--yes/-yflag that bypasses the confirmation prompt and passes-ythrough tonpm initfor non-interactive use--yesto opt inshell: truefrom thenpm install/npm initspawn calls to silence Node's DEP0190 deprecation; usesnpm.cmdon Windows where the.cmdshim is requiredCloses NW-18265
Replaces #71 (closed when branch was renamed)
Test Plan
we initin a directory with nopackage.json— verify prompt appearsnpm initruns interactively, then scaffolding continueswe init -yin a directory with nopackage.json— verify no prompt andnpm init -yis usedwe initwith stdin piped from/dev/null— verify clean exit with redirect message (no hang)we initin a directory that already haspackage.json— verify existing behavior unchangedjust test)🤖 Generated with Claude Code