fix(plugin): close the review's gaps in names, prompts and the generated test

The collision check scanned the whole file as text, so every scaffolded
app refused `core`, `tea` or `module` because they appear inside import
strings. It now reads identifiers from the parse tree.

Typing `npm` at the registry question silently produced a JSR-only
package. An answer that is not offered is now asked again.

The generated test only awaited boot(); it now checks the plugin's token
is in app.graph(), and fails if it is not. engines.node moves to
>=22.18, the first Node that runs `node --test` on .ts unflagged.

Signed-off-by: Diego Resendez <diego.resendez@zero-oneit.com>
This commit is contained in:
chrnx committed 2026-09-24 13:11:55 -05:00
1 parent e4a350fcbf
commit 4358091d07
6 files changed
+163 -29

No files matched your search

+8 -12
View File
@@ -96,7 +96,7 @@ fn in_app<R: BufRead, W: Write>(opts: Opts, ask: &mut Ask<R, W>, root: &Path) ->
let src = std::fs::read_to_string(&entry_path)?;
// A second binding of a name the entry already has is a SyntaxError, and it
// would break the app rather than only the new plugin.
if naming::used_in(&src, &fun) {
if wire::binds(&src, &fun) {
return Err(invalid(format!(
"{} already uses `{fun}`, so the plugin's factory would collide with it; pick another name",
entry_path.strip_prefix(root).unwrap_or(&entry_path).display()
@@ -193,17 +193,13 @@ fn package_mode<R: BufRead, W: Write>(
Some(r) => r,
None => {
ask.say(&format!("\n{}\n", plugin_files::JSR_BANNER))?;
match ask
.text(
"Publish to: (1) JSR only (2) JSR + npm",
Some("1"),
"--registry",
)?
.as_str()
{
"2" | "both" => "both".to_string(),
_ => "jsr".to_string(),
}
ask.choice(
"Publish to: (1) JSR only [default] (2) JSR + npm",
&[("1", "jsr"), ("2", "both")],
"jsr",
"--registry",
)?
.to_string()
}
};