diff --git a/packages/global/package.json b/packages/global/package.json index 2fe8ace507..87e4aa673e 100644 --- a/packages/global/package.json +++ b/packages/global/package.json @@ -23,17 +23,20 @@ }, "dependencies": { "@voidzero-dev/vite-plus": "workspace:*", - "create-tsdown": "catalog:", - "create-vite": "catalog:", "cross-spawn": "catalog:", "oxlint": "catalog:", "oxlint-tsgolint": "catalog:", - "rolldown-vite": "workspace:*" + "rolldown-vite": "workspace:*", + "validate-npm-package-name": "catalog:" }, "devDependencies": { "@clack/prompts": "catalog:", + "@std/yaml": "catalog:", "@types/cross-spawn": "catalog:", + "@types/validate-npm-package-name": "catalog:", "@voidzero-dev/vite-plus-tools": "workspace:", + "glob": "catalog:", + "minimatch": "catalog:", "mri": "catalog:", "picocolors": "catalog:", "rolldown": "workspace:*" diff --git a/packages/global/rolldown.config.ts b/packages/global/rolldown.config.ts index 4d629d4d43..0d3d6f3b72 100644 --- a/packages/global/rolldown.config.ts +++ b/packages/global/rolldown.config.ts @@ -5,12 +5,13 @@ export default defineConfig({ external: [ /^node:/, '@voidzero-dev/vite-plus/bin', - 'create-vite', - 'create-tsdown', + '@voidzero-dev/vite-plus/binding', // FIXME: Calling `require` for "child_process" in an environment that doesn't expose the `require` function 'cross-spawn', // FIXME: will lost colors if not external 'picocolors', + // FIXME: Calling `require` for "module" in an environment that doesn't expose the `require` function + 'validate-npm-package-name', ], output: { format: 'esm', diff --git a/packages/global/snap-tests/gen-check/snap.txt b/packages/global/snap-tests/gen-check/snap.txt new file mode 100644 index 0000000000..b261ffc461 --- /dev/null +++ b/packages/global/snap-tests/gen-check/snap.txt @@ -0,0 +1,96 @@ +> vp gen --help # show help +Usage: vite gen [TEMPLATE] [OPTIONS] [-- TEMPLATE_OPTIONS] + +Run any template (builtin, remote, or local) with automatic vite+ integration. + +Arguments: + TEMPLATE Template name (optional; you will be prompted if omitted) + - Built-in: vite:monorepo, vite:application, vite:library, vite:generator + - Remote: create-vite, @tanstack/create-start, create-next-app, create-nuxt, + github:user/repo, https://github.com/user/template-repo + - Local: @company/generator-*, ./tools/create-ui-component + +Options (before --): + --directory DIR Target directory for the generated project. + Only works for built-in templates; auto-detected for remote templates. + --no-interactive Run in non-interactive mode (skip prompts and use defaults) + --list List all available templates + -h, --help Show this help message + +Template options (after --): + All arguments after -- are passed directly through to the template command. + +Examples: + # Interactive mode - choose template via prompt + vite gen + + # Run any existing template (npx / pnpm dlx / yarn dlx / bunx auto-detected) + vite gen create-vite + vite gen create-next-app + vite gen @tanstack/create-start + + # With template-specific options (after --) + vite gen create-vite -- --template react-ts + vite gen create-next-app -- --typescript --app + + # Create vite+ monorepo, application, library, or generator scaffolds + vite gen vite:monorepo + vite gen vite:application + vite gen vite:library + vite gen vite:generator + + # Monorepo: specify target directory + vite gen vite:application --directory=packages/my-app + + # Combine gen command options and template options + vite gen vite:application --directory=apps/my-app -- --template vue-ts + + # Run templates from GitHub (via degit) + vite gen github:user/repo + vite gen https://github.com/user/template-repo + +Note: Templates are executed via npx / pnpm dlx / yarn dlx / bunx, + based on the detected package manager. + No global installation required - always uses the latest version. + +Aliases: g, generate, new + + +> vp gen --list # list templates + +๐Ÿ“ฆ Available Templates + +Vite+ Built-in Templates: + โ€ข vite:monorepo - Create a new monorepo + โ€ข vite:application - Create a new application + โ€ข vite:library - Create a new library + โ€ข vite:generator - Scaffold a new code generator + +Popular Remote Templates: + โ€ข create-vite - Official Vite templates + โ€ข @tanstack/create-start - TanStack applications + โ€ข create-next-app - Next.js application + โ€ข create-nuxt - Nuxt application + โ€ข create-typescript-app - TypeScript application + โ€ข create-react-router - React Router application + โ€ข create-vue - Vue application + +Run vite gen for interactive mode +Run vite gen