fix(cli): make local Bingo generators work in vp create#1777
Conversation
✅ Deploy Preview for viteplus-preview canceled.
|
|
✅ Staging deployment successful! Preview: https://viteplus-staging.void.app/ |
|
@cursor review |
|
@codex review |
There was a problem hiding this comment.
✅ Bugbot reviewed your changes and found no new issues!
Comment @cursor review or bugbot run to trigger another review on this PR
Reviewed by Cursor Bugbot for commit 676352f. Configure here.
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 676352fd0e
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
Workspace packages scaffolded by `vp create vite:generator` carry the `bingo-template` keyword and are flagged as template packages during workspace detection, but the interactive `vp create` picker only listed built-in templates, so local generators were never offered. `getInitialTemplateOptions` now accepts the workspace packages and appends an option per template package (after the built-ins, monorepo only), with the package name as value and its description as hint. Selecting one flows into the existing `discoverTemplate` local-package path, which already runs bingo templates via their bin entry with `--skip-requests`.
Add a Code Generators section to the create guide covering how to scaffold a generator with `vp create vite:generator`, run it from the interactive picker or by package name, and customize the template.
…project Explain how the global vp resolves the project-local vite-plus first, how to link a checkout into a test project with pnpm link, and when pnpm bootstrap-cli is needed for Rust global CLI changes.
The generator template scaffolded by `vp create vite:generator` crashed with ERR_MODULE_NOT_FOUND whenever the generator was run: its bin imported '../src/template.js' (a tsc-style specifier), but vp create executes the template directly with `node bin/index.ts`, where Node type stripping does not remap .js specifiers to .ts files. - import '../src/template.ts' directly and cast for runTemplateCLI, whose parameter type is wider than createTemplate's return under TS 6 - update bingo to 0.9.3 (latest) in the catalog and the template - align the catalog zod with bingo, which depends on zod 3 and introspects schemas via zod 3 internals; the generator template is the only zod consumer in the repo - move bingo/zod to vite-plus devDependencies: they are the generator template's dependencies and snap tests resolve modules from the CLI package's node_modules - bump the template engines to >=22.18.0, the first Node version that runs .ts files without the --experimental-strip-types flag - add a unit test that runs the template bin directly with node
The only generator snap test covered the error path outside a monorepo. The new create-generator-monorepo case scaffolds a generator inside a monorepo with vite:generator, locks the template package.json contract into the snapshot, runs the generator through `vp create my-generator` (the path that crashed before the template fix), and verifies the generated files.
pnpm 11 records the link as a vite-plus link: override in pnpm-workspace.yaml (or pnpm.overrides in package.json), so it survives later installs instead of being restored by them.
The bingo-template keyword / bingo dependency check was duplicated between discoverWorkspacePackages and discoverTemplate. Both now use a single isBingoTemplate helper so the detection criteria live in one place. Also drop the unreachable '' fallback for the picker hint, the package path is always set.
Spinner frames such as '◒ Preparing local Git repository...' appear in snap output intermittently depending on timing, while the final '◇'/'◆' state line is stable. Normalize them away in replaceUnstableOutput and regenerate the create-generator-monorepo snapshot without the transient frame.
The case scaffolds a generator and prints its package.json, which now carries bingo ^0.9.3 and engines >=22.18.0.
A workspace package carrying the vite-plus-template keyword but no bin field was offered by the create picker, then discoverTemplate silently fell through to expandCreateShorthand and would install and run the unrelated npm package create-<name>. The fallthrough predates the picker, but the picker made it reachable interactively. - extract isTemplatePackage() so the picker and discovery share the template classification - discoverTemplate now throws a clear error for a template package without a bin entry instead of falling through to npm - use || for the picker hint so an empty description falls back to the package path - strip clack spinner frames at end-of-output without a trailing newline - document why the catalog pins zod to v3 (bingo introspects schemas via zod 3 internals)
Running a local generator in a monorepo with multiple parent dirs (e.g. apps/* and tools/*) placed the generated package under apps/ because inferParentDir only recognized the literal vite:generator builtin and fell back to the default app rule for a local generator's package name. inferParentDir now resolves a local template package to its own parent directory, so a generator under tools/ scaffolds its output into tools/ rather than apps/. The create-generator-monorepo snap fixture gains an apps/* parent so it actually exercises the multi-parent case the tools-only fixture missed. Closes review comment on #1777.
676352f to
0080cda
Compare
Extract findLocalPackage so discoverTemplate and inferParentDir resolve a template specifier to a workspace package the same way. Also tighten the inferParentDir test to exercise the isTemplatePackage guard with a non-template package instead of re-checking the default rule.
…nd harden multi-bin resolution Two robustness fixes for local template packages now that they are directly selectable from the create picker: - isTemplatePackage (picker visibility) now requires the vite-plus-template or bingo-template keyword. A plain `bingo` dependency no longer surfaces a normal workspace package as a template; it remains an execution hint in isBingoTemplate (controls --skip-requests), separating 'is this offered' from 'how is it run'. - discoverTemplate resolves a package's bin via resolveLocalBinPath: a single bin (string or one-entry object) is used directly, a multi-bin package prefers the entry named after the package (scoped or unscoped), and an ambiguous multi-bin package with no matching entry throws a clear error instead of silently picking the first key.
This comment was marked as resolved.
This comment was marked as resolved.
This comment was marked as resolved.
This comment was marked as resolved.
…ep ones inferParentDir only co-located output for keyword-marked packages, but discoverTemplate runs a workspace package as a Bingo template when it only has a bingo dependency. Such a package, invoked by name, scaffolded under the default apps parent instead of next to the generator. Place output next to any matched local package so placement matches execution.
|
Review the following changes in direct dependencies. Learn more about Socket for GitHub.
|
|
@cursor review |
|
@codex review |
There was a problem hiding this comment.
✅ Bugbot reviewed your changes and found no new issues!
Comment @cursor review or bugbot run to trigger another review on this PR
Reviewed by Cursor Bugbot for commit aa6b1be. Configure here.
|
Codex Review: Didn't find any major issues. Bravo. ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
If Codex has suggestions, it will comment; otherwise it will react with 👍. Codex can also answer questions or update the PR. Try commenting "@codex address that feedback". |
`sync-remote` rewrote pnpm-workspace.yaml by parsing it to a plain object and re-stringifying, which dropped every comment. PR #1777 adds a comment to the catalog (the zod-v3 pin rationale), so the next sync would silently delete it. Add `mergeWorkspaceYaml`, a comment-preserving parse+merge+serialize seam: parse the main workspace as a yaml Document (which retains comments), merge the upstream rolldown/vite workspaces via the unchanged mergePnpmWorkspaces, then reconcile the merged data back into the document so surviving keys keep their comments. syncRemote now uses this instead of parse/stringify.
Problem
Local generator packages (scaffolded by
vp create vite:generator) were broken in two ways:vp createpicker never offered them. Workspace detection already flags template packages (bingo-templatekeyword or abingodependency), but the picker only listed built-in templates.ERR_MODULE_NOT_FOUND. The template's bin imported'../src/template.js', butvp createruns the template directly withnode bin/index.ts, where Node type stripping does not remap.jsspecifiers to.tsfiles.Changes
Picker:
getInitialTemplateOptionsnow appends local template packages (monorepo only). Selection flows into the existing local-package path indiscoverTemplate, so no execution changes were needed.Template: import
'../src/template.ts'directly, update bingo to 0.9.3, align the catalog zod with bingo (which requires zod 3), and bump engines to>=22.18.0(first Node version that runs.tsunflagged). bingo/zod move from the root package.json to vite-plus devDependencies.Tests: unit tests for the picker and the template bin (both failed before the fixes), plus a new
create-generator-monoreposnap test covering scaffold and execution end to end.Docs: Code Generators section in the create guide, and local validation testing notes in CONTRIBUTING.md.
Verified in a real monorepo: the generator appears in the picker and
vp create million-finding -- --name demo-pkg --directory demo-pkggenerates the package correctly.Note
Medium Risk
Touches template discovery, monorepo placement, and dependency versions for
vp create, but behavior is heavily covered by new unit and snap tests rather than security-critical paths.Overview
Fixes local Bingo generator workflows in monorepos: interactive
vp createnow lists workspace packages marked withbingo-template/vite-plus-template, and running them uses clearer local bin resolution (including multi-bin packages), Bingo execution with auto--skip-requests, and output placement next to the generator undertools/instead of defaulting toapps/. Packages that only depend onbingostill run as generators by name but no longer appear in the picker; marker-keyword template packages without abinentry error instead of falling through to npmcreate-*.The
vite:generatorscaffold is updated for directnode bin/index.tsexecution (.tsimports, bingo 0.9.3, zod v3 aligned with bingo, Node >=22.18.0);bingo/zodmove from the repo root intovite-plusdevDependencies. Coverage adds unit tests, acreate-generator-monoreposnap test, spinner-frame normalization for stable snaps, and docs (Code Generators guide + CONTRIBUTING local validation viapnpm link).Reviewed by Cursor Bugbot for commit aa6b1be. Configure here.