Skip to content

feat(init/npm): add --yes flag to bypass prompt#31499

Merged
dsherret merged 6 commits intodenoland:mainfrom
dsherret:feat_deno_init_yes
Dec 5, 2025
Merged

feat(init/npm): add --yes flag to bypass prompt#31499
dsherret merged 6 commits intodenoland:mainfrom
dsherret:feat_deno_init_yes

Conversation

@dsherret
Copy link
Copy Markdown
Contributor

@dsherret dsherret commented Dec 4, 2025

Closes #31498

@dsherret dsherret changed the title feat(init): add --yes flag feat(init): add --yes flag to bypass prompt Dec 4, 2025
@coderabbitai
Copy link
Copy Markdown

coderabbitai bot commented Dec 4, 2025

Warning

Rate limit exceeded

@dsherret has exceeded the limit for the number of commits or files that can be reviewed per hour. Please wait 11 minutes and 20 seconds before requesting another review.

⌛ How to resolve this issue?

After the wait time has elapsed, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

We recommend that you space out your commits to avoid hitting the rate limit.

🚦 How do rate limits work?

CodeRabbit enforces hourly rate limits for each developer per organization.

Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout.

Please see our FAQ for further information.

📥 Commits

Reviewing files that changed from the base of the PR and between 5c64679 and bb8ea50.

⛔ Files ignored due to path filters (2)
  • tests/specs/init/yes_flag/init.out is excluded by !**/*.out
  • tests/specs/init/yes_flag/missing.out is excluded by !**/*.out
📒 Files selected for processing (3)
  • cli/args/flags.rs (14 hunks)
  • cli/tools/init/mod.rs (3 hunks)
  • tests/specs/init/yes_flag/__test__.jsonc (1 hunks)

Walkthrough

This change introduces a --yes (or -y) CLI flag to the init subcommand. The flag is added to the argument parser in cli/args/flags.rs, stored in the InitFlags struct, and propagated through the init flow. In cli/tools/init/mod.rs, the init_npm function is refactored to accept an InitNpmOptions struct containing the yes flag. When the flag is set, interactive prompts are skipped. A new test specification validates this behavior by running init with --yes --lib and verifying test execution.

Pre-merge checks and finishing touches

✅ Passed checks (5 passed)
Check name Status Explanation
Description check ✅ Passed The description references issue #31498, which is the linked requirement for this PR.
Linked Issues check ✅ Passed The PR fully implements the requested feature from #31498: adds a --yes flag (-y) to deno init to bypass interactive prompts, enabling non-interactive CI environments.
Out of Scope Changes check ✅ Passed All changes are directly scoped to implementing the --yes flag feature: CLI arg parsing, InitFlags struct, init_npm refactoring, and test coverage.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Title check ✅ Passed The title accurately describes the main change: adding a --yes flag to bypass the interactive prompt in deno init.

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link
Copy Markdown

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 0

🧹 Nitpick comments (1)
cli/args/flags.rs (1)

12537-12705: Init tests updated appropriately; consider a couple more --yes combinations

The new expectations with yes: false and the added deno init --yes test align with the parsing changes. For future‑proofing/CI behavior, it could be useful (optional) to add tests for a few extra shapes, for example:

  • deno init --yes foo
  • deno init foo --yes
  • Potentially one --npm case (for whichever ordering you intend to support)

That would lock in the desired behavior around flag/arg ordering for non‑interactive use.

📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 557c580 and 5c64679.

⛔ Files ignored due to path filters (2)
  • tests/specs/init/yes_flag/init_lib.out is excluded by !**/*.out
  • tests/specs/init/yes_flag/lib_test.out is excluded by !**/*.out
📒 Files selected for processing (3)
  • cli/args/flags.rs (14 hunks)
  • cli/tools/init/mod.rs (4 hunks)
  • tests/specs/init/yes_flag/__test__.jsonc (1 hunks)
🧰 Additional context used
📓 Path-based instructions (5)
tests/specs/**/__test__.jsonc

📄 CodeRabbit inference engine (CLAUDE.md)

Spec tests should be created in tests/specs/ with a __test__.jsonc file describing test steps and input files

Files:

  • tests/specs/init/yes_flag/__test__.jsonc
tests/specs/**/{__test__.jsonc,*.out}

📄 CodeRabbit inference engine (CLAUDE.md)

Output assertions in spec tests should use __test__.jsonc inline fields or .out files with special matching syntax: [WILDCARD], [WILDLINE], [WILDCHAR], [WILDCHARS(n)], [UNORDERED_START]/[UNORDERED_END], and [# comment]

Files:

  • tests/specs/init/yes_flag/__test__.jsonc
cli/tools/**/*.rs

📄 CodeRabbit inference engine (CLAUDE.md)

CLI tools should be implemented in cli/tools/<tool> or cli/tools/<tool>/mod.rs

Files:

  • cli/tools/init/mod.rs
**/*.rs

📄 CodeRabbit inference engine (CLAUDE.md)

**/*.rs: For debugging Rust code, set breakpoints in IDE debuggers (VS Code with rust-analyzer, IntelliJ IDEA) or use lldb directly
Use eprintln!() or dbg!() macros for debug prints in Rust code

Files:

  • cli/tools/init/mod.rs
  • cli/args/flags.rs

⚙️ CodeRabbit configuration file

Don't worry about coverage of Rust docstrings. Don't be nitpicky about it. Leave it to the author's judgement if such a documentation is necessary.

Files:

  • cli/tools/init/mod.rs
  • cli/args/flags.rs
cli/args/flags.rs

📄 CodeRabbit inference engine (CLAUDE.md)

CLI flag parsing should be defined in cli/args/flags.rs

Files:

  • cli/args/flags.rs
🧠 Learnings (5)
📓 Common learnings
Learnt from: CR
Repo: denoland/deno PR: 0
File: CLAUDE.md:0-0
Timestamp: 2025-11-24T16:19:37.808Z
Learning: Applies to cli/args/flags.rs : CLI flag parsing should be defined in `cli/args/flags.rs`
📚 Learning: 2025-11-24T16:19:37.808Z
Learnt from: CR
Repo: denoland/deno PR: 0
File: CLAUDE.md:0-0
Timestamp: 2025-11-24T16:19:37.808Z
Learning: Applies to tests/specs/**/__test__.jsonc : Spec tests should be created in `tests/specs/` with a `__test__.jsonc` file describing test steps and input files

Applied to files:

  • tests/specs/init/yes_flag/__test__.jsonc
📚 Learning: 2025-11-24T16:19:37.808Z
Learnt from: CR
Repo: denoland/deno PR: 0
File: CLAUDE.md:0-0
Timestamp: 2025-11-24T16:19:37.808Z
Learning: Applies to tests/specs/**/{__test__.jsonc,*.out} : Output assertions in spec tests should use `__test__.jsonc` inline fields or `.out` files with special matching syntax: `[WILDCARD]`, `[WILDLINE]`, `[WILDCHAR]`, `[WILDCHARS(n)]`, `[UNORDERED_START]`/`[UNORDERED_END]`, and `[# comment]`

Applied to files:

  • tests/specs/init/yes_flag/__test__.jsonc
📚 Learning: 2025-11-24T16:19:37.808Z
Learnt from: CR
Repo: denoland/deno PR: 0
File: CLAUDE.md:0-0
Timestamp: 2025-11-24T16:19:37.808Z
Learning: Applies to cli/args/flags.rs : CLI flag parsing should be defined in `cli/args/flags.rs`

Applied to files:

  • cli/args/flags.rs
📚 Learning: 2025-11-24T16:19:37.808Z
Learnt from: CR
Repo: denoland/deno PR: 0
File: CLAUDE.md:0-0
Timestamp: 2025-11-24T16:19:37.808Z
Learning: Applies to cli/main.rs : Main CLI entry point is in `cli/main.rs` and should handle command routing

Applied to files:

  • cli/args/flags.rs
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (10)
  • GitHub Check: lint debug windows-x86_64
  • GitHub Check: test release linux-x86_64
  • GitHub Check: test debug macos-aarch64
  • GitHub Check: test debug linux-aarch64
  • GitHub Check: test debug windows-x86_64
  • GitHub Check: test debug linux-x86_64
  • GitHub Check: lint debug linux-x86_64
  • GitHub Check: test debug macos-x86_64
  • GitHub Check: lint debug macos-x86_64
  • GitHub Check: build libs
🔇 Additional comments (3)
cli/tools/init/mod.rs (1)

33-39: LGTM! Clean refactoring with correct yes-flag logic.

The introduction of InitNpmOptions properly groups related parameters, and the conditional prompting logic correctly bypasses interactive confirmation when yes is true while preserving the existing behavior otherwise.

Also applies to: 308-315, 329-353, 375-375

tests/specs/init/yes_flag/__test__.jsonc (1)

1-14: Ensure output assertion files exist.

The test spec references init_lib.out and lib_test.out for output assertions. Per spec test standards, these .out files must exist in the same directory and use the proper matching syntax ([WILDCARD], [WILDLINE], [WILDCHAR], [WILDCHARS(n)], [UNORDERED_START]/[UNORDERED_END]).

cli/args/flags.rs (1)

281-289: --yes flag plumbing for deno init looks correct; double‑check --npm ordering semantics

  • Adding yes: bool to InitFlags, defining -y/--yes on init_subcommand(), and reading it in init_parse (including the inner re‑parse for extra args) is consistent with the existing pattern for lib/serve and keeps the default false.
  • One subtle behavior to be aware of: because the positional args is used to forward flags to npm when --npm is set, calls like deno init --npm vite --yes will treat --yes as a package argument (not set InitFlags.yes), whereas deno init --yes --npm vite will set yes: true. That mirrors the current --npm vite --serve behavior, but it may be surprising unless documented.

If the intent is “only recognize --yes before the package name in --npm mode”, the current wiring is fine; otherwise you may want to adjust or document this explicitly.

Also applies to: 3114-3150, 5903-5941

@dsherret dsherret changed the title feat(init): add --yes flag to bypass prompt feat(init/npm): add --yes flag to bypass prompt Dec 4, 2025
@dsherret dsherret merged commit dd3a7d3 into denoland:main Dec 5, 2025
20 checks passed
@dsherret dsherret deleted the feat_deno_init_yes branch December 5, 2025 16:07
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.

Allow running deno init -A to support CI or non-prompt supporting envs

3 participants