Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 6 additions & 3 deletions packages/global/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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:*"
Expand Down
5 changes: 3 additions & 2 deletions packages/global/rolldown.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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',
Expand Down
96 changes: 96 additions & 0 deletions packages/global/snap-tests/gen-check/snap.txt
Original file line number Diff line number Diff line change
@@ -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 <template> to use any template
Run vite gen <template> -- <options> to pass options to the template

✨ Tip: You can use ANY npm template with vite gen!


[1]> vp gen --no-interactive # run in non-interactive mode without template name will show error

Template name is required when running in non-interactive mode

Usage: vite gen [TEMPLATE] [OPTIONS] [-- TEMPLATE_OPTIONS]

Example:
# Create a new application in non-interactive mode with a custom target directory
vite gen vite:application --no-interactive --directory=apps/my-app

Use `vite gen --list` to list all available templates, or run `vite gen --help` for more information.

7 changes: 7 additions & 0 deletions packages/global/snap-tests/gen-check/steps.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"commands": [
"vp gen --help # show help",
"vp gen --list # list templates",
"vp gen --no-interactive # run in non-interactive mode without template name will show error"
]
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
> vp gen vite:library --no-interactive --directory @my-scope/my-library # create vite library with scope name
> ls my-library/package.json # check package.json
my-library/package.json

> cat my-library/.npmrc # check .npmrc
//npm.pkg.github.com/:_authToken=${GITHUB_TOKEN}
@voidzero-dev:registry=https://npm.pkg.github.com/
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
{
"env": {
"VITE_DISABLE_AUTO_INSTALL": "1"
},
"commands": [
{
"command": "vp gen vite:library --no-interactive --directory @my-scope/my-library # create vite library with scope name",
"ignoreOutput": true
},
"ls my-library/package.json # check package.json",
"cat my-library/.npmrc # check .npmrc"
]
}
11 changes: 11 additions & 0 deletions packages/global/snap-tests/gen-create-tsdown/snap.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
> vp gen vite:library --no-interactive # create vite library with default values
> ls vite-plus-library/package.json # check package.json
vite-plus-library/package.json

> cat vite-plus-library/.npmrc # check .npmrc
//npm.pkg.github.com/:_authToken=${GITHUB_TOKEN}
@voidzero-dev:registry=https://npm.pkg.github.com/

> vp gen vite:library --no-interactive --directory my-vue -- --template vue # create vite library with custom template
> ls my-vue/package.json # check package.json
my-vue/package.json
18 changes: 18 additions & 0 deletions packages/global/snap-tests/gen-create-tsdown/steps.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
{
"env": {
"VITE_DISABLE_AUTO_INSTALL": "1"
},
"commands": [
{
"command": "vp gen vite:library --no-interactive # create vite library with default values",
"ignoreOutput": true
},
"ls vite-plus-library/package.json # check package.json",
"cat vite-plus-library/.npmrc # check .npmrc",
{
"command": "vp gen vite:library --no-interactive --directory my-vue -- --template vue # create vite library with custom template",
"ignoreOutput": true
},
"ls my-vue/package.json # check package.json"
]
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
> vp gen vite:application --no-interactive --directory @my-scope/my-vite-app -- --template vanilla-ts # create vite app with vanilla-ts template with scope name
> ls my-vite-app/package.json # check package.json
my-vite-app/package.json

> cat my-vite-app/.npmrc # check .npmrc
//npm.pkg.github.com/:_authToken=${GITHUB_TOKEN}
@voidzero-dev:registry=https://npm.pkg.github.com/
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
{
"env": {
"VITE_DISABLE_AUTO_INSTALL": "1"
},
"commands": [
{
"command": "vp gen vite:application --no-interactive --directory @my-scope/my-vite-app -- --template vanilla-ts # create vite app with vanilla-ts template with scope name",
"ignoreOutput": true
},
"ls my-vite-app/package.json # check package.json",
"cat my-vite-app/.npmrc # check .npmrc"
]
}
11 changes: 11 additions & 0 deletions packages/global/snap-tests/gen-create-vite/snap.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
> vp gen vite:application --no-interactive # create vite app with default values
> ls vite-plus-application/package.json # check package.json
vite-plus-application/package.json

> cat vite-plus-application/.npmrc # check .npmrc
//npm.pkg.github.com/:_authToken=${GITHUB_TOKEN}
@voidzero-dev:registry=https://npm.pkg.github.com/

> vp gen vite:application --no-interactive --directory my-react-ts -- --template react-ts # create vite app with react-ts template
> ls my-react-ts/package.json # check package.json
my-react-ts/package.json
18 changes: 18 additions & 0 deletions packages/global/snap-tests/gen-create-vite/steps.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
{
"env": {
"VITE_DISABLE_AUTO_INSTALL": "1"
},
"commands": [
{
"command": "vp gen vite:application --no-interactive # create vite app with default values",
"ignoreOutput": true
},
"ls vite-plus-application/package.json # check package.json",
"cat vite-plus-application/.npmrc # check .npmrc",
{
"command": "vp gen vite:application --no-interactive --directory my-react-ts -- --template react-ts # create vite app with react-ts template",
"ignoreOutput": true
},
"ls my-react-ts/package.json # check package.json"
]
}
Loading
Loading