You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: rfcs/code-generator.md
+64-64Lines changed: 64 additions & 64 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -36,7 +36,7 @@ Bingo offers several advantages:
36
36
37
37
## Integration Strategy: Dual-Mode Support
38
38
39
-
**Key Decision**: `vite gen` supports BOTH bingo templates AND any existing `create-*` template through intelligent migration:
39
+
**Key Decision**: `vite new` supports BOTH bingo templates AND any existing `create-*` template through intelligent migration:
40
40
41
41
### Two Ways to Write Generators
42
42
@@ -46,10 +46,10 @@ Best for creating **reusable local generators** within your monorepo:
46
46
47
47
```bash
48
48
# Run workspace-local bingo generator
49
-
vite gen @company/generator-ui-lib
49
+
vite new @company/generator-ui-lib
50
50
51
51
# Or any bingo template from npm
52
-
vite gen create-typescript-app
52
+
vite new create-typescript-app
53
53
```
54
54
55
55
**Why use bingo**:
@@ -66,9 +66,9 @@ Run **ANY** existing `create-*` template from the ecosystem:
66
66
67
67
```bash
68
68
# Run any existing template
69
-
vite gen create-vite
70
-
vite gen create-next-app
71
-
vite gen create-nuxt
69
+
vite new create-vite
70
+
vite new create-next-app
71
+
vite new create-nuxt
72
72
```
73
73
74
74
**Why use universal templates**:
@@ -113,7 +113,7 @@ Monorepo integration:
113
113
114
114
```
115
115
┌──────────────────────────┐
116
-
│ vite gen <name> │
116
+
│ vite new <name> │
117
117
└───────────┬──────────────┘
118
118
│
119
119
┌─────▼─────────┐
@@ -166,7 +166,7 @@ After any template runs, vite+ adds monorepo-specific features:
166
166
**Purpose**: Simplify dependency management by consolidating vite, vitest, oxlint, and oxfmt into a single vite-plus package.
167
167
168
168
```bash
169
-
$ vite gen create-vite --template react-ts
169
+
$ vite new create-vite --template react-ts
170
170
171
171
# create-vite runs normally...
172
172
✔ Project name: › my-app
@@ -239,10 +239,10 @@ This is a **dependency consolidation** feature, not a tool replacement feature.
239
239
240
240
### 2. Target Directory Selection (Monorepo)
241
241
242
-
When running `vite gen` in a monorepo workspace, vite+ prompts users to select which parent directory to create the new package in:
242
+
When running `vite new` in a monorepo workspace, vite+ prompts users to select which parent directory to create the new package in:
243
243
244
244
```bash
245
-
$ vite gen create-vite
245
+
$ vite new create-vite
246
246
247
247
◆ Where should we create the new package?
248
248
│ ○ apps/ (Applications)
@@ -273,14 +273,14 @@ $ vite gen create-vite
273
273
- Clear organization in monorepo
274
274
- Users don't need to remember directory structure
275
275
- Consistent with workspace organization
276
-
- Can be skipped with `--directory` flag: `vite gen create-vite --directory=packages`
276
+
- Can be skipped with `--directory` flag: `vite new create-vite --directory=packages`
277
277
278
278
### 3. Workspace Dependency Prompts
279
279
280
280
Inspired by [Turbo's generator](https://turborepo.com/docs/guides/generating-code), vite+ prompts users to select existing workspace packages as dependencies:
281
281
282
282
```bash
283
-
$ vite gen @company/generator-ui-lib --name=design-system
283
+
$ vite new @company/generator-ui-lib --name=design-system
@@ -950,7 +950,7 @@ vite+ acts as an intelligent wrapper that:
950
950
### Template Execution Flow
951
951
952
952
```
953
-
1. User runs: vite gen [template-name] [vite-options] -- [template-options]
953
+
1. User runs: vite new [template-name] [vite-options] -- [template-options]
954
954
↓
955
955
2. vite+ parses CLI arguments (split on -- separator)
956
956
↓
@@ -1024,7 +1024,7 @@ This approach is **simple and robust**:
1024
1024
When a template is not installed locally, vite+ automatically uses the appropriate package manager runner:
1025
1025
1026
1026
```bash
1027
-
$ vite gen create-vite -- --template react-ts
1027
+
$ vite new create-vite -- --template react-ts
1028
1028
1029
1029
┌ 🎨 Vite+ Code Generator
1030
1030
│
@@ -1116,7 +1116,7 @@ This example shows the full monorepo integration with workspace dependency selec
1116
1116
1117
1117
```bash
1118
1118
$ cd my-monorepo
1119
-
$ vite gen create-vite -- --template react-ts
1119
+
$ vite new create-vite -- --template react-ts
1120
1120
1121
1121
┌ 🎨 Vite+ Code Generator
1122
1122
│
@@ -1199,7 +1199,7 @@ Next steps:
1199
1199
Use the built-in `vite:generator` to quickly scaffold a new generator:
1200
1200
1201
1201
```bash
1202
-
$ vite gen vite:generator
1202
+
$ vite new vite:generator
1203
1203
1204
1204
┌ 🎨 Vite+ Code Generator
1205
1205
│
@@ -1253,7 +1253,7 @@ Summary:
1253
1253
Next steps:
1254
1254
cd tools/generators/ui-lib
1255
1255
# Edit src/template.ts to customize your generator
1256
-
# Then test it with: vite gen @company/generator-ui-lib
1256
+
# Then test it with: vite new @company/generator-ui-lib
1257
1257
```
1258
1258
1259
1259
The generated scaffold includes:
@@ -1269,7 +1269,7 @@ The generated scaffold includes:
1269
1269
Use the built-in `vite:application` generator for a vite+ optimized project:
1270
1270
1271
1271
```bash
1272
-
$ vite gen vite:application
1272
+
$ vite new vite:application
1273
1273
1274
1274
┌ 🎨 Vite+ Code Generator
1275
1275
│
@@ -1327,9 +1327,9 @@ The generated project includes:
1327
1327
1328
1328
```bash
1329
1329
# Use create-typescript-app (a popular bingo template)
1330
-
vite gen create-typescript-app
1330
+
vite new create-typescript-app
1331
1331
1332
-
┌ vite gen create-typescript-app
1332
+
┌ vite new create-typescript-app
1333
1333
│
1334
1334
# vite+ prompts for target directory first
1335
1335
◆ Where should we create the new package?
@@ -1398,7 +1398,7 @@ Use the official scaffold to quickly create a new generator:
1398
1398
1399
1399
```bash
1400
1400
# Create a new generator in your monorepo
1401
-
vite gen @vite-plus/create-generator
1401
+
vite new @vite-plus/create-generator
1402
1402
1403
1403
┌ @vite-plus/create-generator
1404
1404
│
@@ -1423,7 +1423,7 @@ vite gen @vite-plus/create-generator
1423
1423
Next steps:
1424
1424
1. cd tools/generators/ui-lib
1425
1425
2. Edit src/template.ts to define your generator logic
1426
-
3. Test with: vite gen @company/generator-ui-lib
1426
+
3. Test with: vite new @company/generator-ui-lib
1427
1427
```
1428
1428
1429
1429
#### Generated Structure
@@ -1746,13 +1746,13 @@ Generate new UI component libraries for our monorepo.
1746
1746
From monorepo root:
1747
1747
1748
1748
\`\`\`bash
1749
-
vite gen@company/generator-ui-lib
1749
+
vite new@company/generator-ui-lib
1750
1750
\`\`\`
1751
1751
1752
1752
With options:
1753
1753
1754
1754
\`\`\`bash
1755
-
vite gen@company/generator-ui-lib --name=design-system --framework=react
1755
+
vite new@company/generator-ui-lib --name=design-system --framework=react
1756
1756
\`\`\`
1757
1757
1758
1758
## Development
@@ -1765,7 +1765,7 @@ vite test
1765
1765
1766
1766
# Test the generator
1767
1767
1768
-
vite gen@company/generator-ui-lib
1768
+
vite new@company/generator-ui-lib
1769
1769
\`\`\`
1770
1770
1771
1771
## Customization
@@ -1781,7 +1781,7 @@ Edit `src/template.ts` to customize:
1781
1781
1782
1782
```bash
1783
1783
# Run from monorepo root
1784
-
vite gen @company/generator-ui-lib
1784
+
vite new @company/generator-ui-lib
1785
1785
1786
1786
# Bingo generator prompts
1787
1787
┌ @company/generator-ui-lib
@@ -1839,13 +1839,13 @@ Next steps:
1839
1839
5. npm run storybook (view docs)
1840
1840
1841
1841
# CLI options
1842
-
vite gen @company/generator-ui-lib --name=icons --no-migrate # Skip migrations
1843
-
vite gen @company/generator-ui-lib --name=hooks --deps=@company/utils # Pre-select deps
1842
+
vite new @company/generator-ui-lib --name=icons --no-migrate # Skip migrations
1843
+
vite new @company/generator-ui-lib --name=hooks --deps=@company/utils # Pre-select deps
1844
1844
```
1845
1845
1846
1846
**Key Point**: Even your own bingo generators benefit from auto-migration! You can generate code using standalone vite/vitest/oxlint, and vite+ will automatically consolidate them into vite-plus.
1847
1847
1848
-
**Tip**: Use `vite gen @vite-plus/create-generator` to quickly scaffold a new generator in your monorepo!
1848
+
**Tip**: Use `vite new @vite-plus/create-generator` to quickly scaffold a new generator in your monorepo!
1849
1849
1850
1850
**Testing the Generator:**
1851
1851
@@ -1894,7 +1894,7 @@ For monorepo-specific needs, vite+ can provide thin wrappers:
1894
1894
1895
1895
```bash
1896
1896
# Built-in generator that configures vite-task.json automatically
1897
-
vite gen vite:library --name=shared-utils
1897
+
vite new vite:library --name=shared-utils
1898
1898
1899
1899
# This could wrap an existing bingo template and add:
1900
1900
# - vite-task.json with build/test/lint tasks
@@ -2169,7 +2169,7 @@ A successful implementation should:
2169
2169
2170
2170
-[migration-command.md](./migration-command.md) - `vite migration` command for migrating existing projects
2171
2171
- Shares the same migration engine and rules
2172
-
-`vite gen` runs migrations after template generation
2172
+
-`vite new` runs migrations after template generation
2173
2173
-`vite migration` runs migrations on existing projects
0 commit comments