-
Notifications
You must be signed in to change notification settings - Fork 5.9k
feat: deno init --empty
#31516
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat: deno init --empty
#31516
Conversation
WalkthroughAdds a new Pre-merge checks and finishing touches❌ Failed checks (1 warning)
✅ Passed checks (2 passed)
✨ Finishing touches
🧪 Generate unit tests (beta)
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. Comment |
There was a problem hiding this 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
Caution
Some comments are outside the diff and can’t be posted inline due to platform limitations.
⚠️ Outside diff range comments (1)
cli/args/flags.rs (1)
283-292: InitFlags: newemptyfield will break existing struct initializers (tests) unless updatedAdding
pub empty: boolhere is fine, but every explicitInitFlags { ... }literal now must includeemptyor use struct update syntax. The tests in this module still constructInitFlagswithoutempty, which will fail to compile (missing field 'empty'). Please update those initializers (for example in theinittests near the bottom of this file) to setempty: falseexplicitly.
🧹 Nitpick comments (3)
cli/tools/init/mod.rs (1)
52-69: Empty init branch behavior looks correct; optional DRY-up with default pathThe empty-mode path creates the expected minimal scaffold (
main.tswith “Hello world!” and adeno.jsonwith only adevtask) and reuses the existing file helpers, so behavior and error handling are consistent with other modes. The only minor nit is that the"deno run --watch main.ts"task definition is now duplicated with the default path; if you expect that to evolve over time, consider extracting the common JSON snippet into a small helper to avoid drift, but this is non-blocking.tests/integration/init_tests.rs (1)
174-211: Strengthen--emptytest to assert deno.json has no std/assert or test configThe test does a good job covering the new empty mode (no
cd, nodeno testin guidance, onlymain.ts, correct output). Given the PR’s motivation—avoiding@std/assertand test scaffolding—it would be useful to assert thatdeno.jsonreflects that as well.For example, after checking that
deno.jsonexists, you could also verify it doesn’t reference@std/assert(or other test-related scaffolding):- assert!(cwd.join("deno.json").exists()); + let deno_json_path = cwd.join("deno.json"); + assert!(deno_json_path.exists()); + + let deno_json_content = deno_json_path.read_to_string(); + assert!(!deno_json_content.contains("@std/assert"));This makes the test guard precisely against the regression the flag is meant to prevent.
cli/args/flags.rs (1)
3162-3168:--emptyflag wiring looks consistent, but it probably should conflict with--npmThe new
emptyflag is correctly threaded:
- Defined on the
initsubcommand and mapped intoInitFlags.emptyviamatches.get_flag("empty")andinner_matches.get_flag("empty").- Propagated into
DenoSubcommand::Init(InitFlags { ..., empty, .. }).One concern:
Arg::new("empty")only conflicts withlibandserve, andArg::new("npm")only conflicts withlibandserve. That meansdeno init --npm <pkg> --emptyis currently accepted and producesInitFlags { package: Some(...), empty: true, ... }, even thoughemptyis only meaningful for the non‑npm scaffold path.Consider tightening the CLI contract so
--emptyand--npmare mutually exclusive, for example by addingemptyto thenpmarg’sconflicts_with_alllist or adding"npm"to theemptyarg’sconflicts_with_all.Also applies to: 5946-5981
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (3)
cli/args/flags.rs(5 hunks)cli/tools/init/mod.rs(2 hunks)tests/integration/init_tests.rs(1 hunks)
🧰 Additional context used
📓 Path-based instructions (3)
cli/tools/**/*.rs
📄 CodeRabbit inference engine (CLAUDE.md)
CLI tools should be implemented in
cli/tools/<tool>orcli/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 uselldbdirectly
Useeprintln!()ordbg!()macros for debug prints in Rust code
Files:
cli/tools/init/mod.rscli/args/flags.rstests/integration/init_tests.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.rscli/args/flags.rstests/integration/init_tests.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 (1)
📚 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
🧬 Code graph analysis (2)
cli/tools/init/mod.rs (1)
cli/util/fs.rs (1)
create_file(22-50)
tests/integration/init_tests.rs (1)
tests/util/server/src/builders.rs (1)
for_jsr(114-116)
⏰ 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: test debug 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 release linux-x86_64
- GitHub Check: test debug macos-x86_64
- GitHub Check: build libs
- GitHub Check: lint debug windows-x86_64
- GitHub Check: lint debug macos-x86_64
- GitHub Check: lint debug linux-x86_64
🔇 Additional comments (1)
cli/tools/init/mod.rs (1)
247-256: Init guidance for--emptyis consistent and avoids test hintsThe new logging branch for
init_flags.emptymatches the scaffold you create: it only mentions runningmain.tsand thedevtask, and correctly omits anydeno testhints since no tests are generated. This keeps the UX aligned with the “empty” intent.
…ot contain `@std/assert` when using
|
Please sign the CLA so we could land this PR |
deno init --empty commanddeno init --empty
I did right now. |
bartlomieju
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks
Hi dear Deno Team,
First of all, it's not connected to a issue, I'm a web developer that use Deno for years. All each project, each deno init, I firstly delete main_test.ts, after remove @std/assert imports in deno.json. Today, actually few minutes ago I said to myself
Is there no command that does an empty init?I couldn't find one. So yeah, here,deno init --emptycommand to a real empty project initialize.I can not tested cargo test because I can not fixed that error