create-vanilla-vite 1.2.1 → 1.2.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +26 -0
- package/README.md +160 -22
- package/bin/create-template.mjs +109 -18
- package/package.json +21 -3
- package/scripts/add-dependency.mjs +35 -8
- package/scripts/dev.mjs +123 -54
- package/scripts/install-info.mjs +47 -14
- package/scripts/run-app.mjs +15 -3
- package/scripts/toggle-feature.mjs +407 -0
package/CHANGELOG.md
CHANGED
|
@@ -1,8 +1,34 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## 1.2.3 - 2026-11-19
|
|
4
|
+
|
|
5
|
+
- Added feature toggle commands (`turn-on`, `trun-on`, `tN` and `turn-off`, `trun-off`, `tO`) to switch features like `adD` / install guard on and off dynamically.
|
|
6
|
+
- Added modular feature manager `scripts/toggle-feature.mjs` with alias resolution (`adD`, `add-dependency`, `install`, `i`, `add`, `guard`, `install-mode`) and status reporting.
|
|
7
|
+
- Fixed CLI update relaunch to target the exact new version instead of `@latest`, preventing pnpm and npm dlx/exec cache reuse of stale versions.
|
|
8
|
+
- Added a pre-publish changelog check in `pnpm vpublish` to verify an entry exists for the target version or prompt for changelog items.
|
|
9
|
+
- Extended `vpublish` to support passing changelog items non-interactively via `--changelog="<entry>"`.
|
|
10
|
+
- Raised pre-publish smoke validation timeout in version manager to 20 minutes with `VPUBLISH_TEST_TIMEOUT_MS` override.
|
|
11
|
+
- Replaced root node_modules symlinking in test suite with isolated fake binaries and minimal stubs.
|
|
12
|
+
- Fixed ReferenceError for file extensions in Express smoke tests.
|
|
13
|
+
|
|
14
|
+
## 1.2.2 - 2026-11-19
|
|
15
|
+
|
|
16
|
+
- Added `--install-mode=adD|plain|both` option and interactive prompt to choose dependency installation behavior.
|
|
17
|
+
- Added dependency synchronization when running `adD` with no package arguments.
|
|
18
|
+
- Fixed Express 5 server listen callback to prevent printing success message on startup errors.
|
|
19
|
+
- Fixed `--dry-run` in version manager to never write package files.
|
|
20
|
+
- Added full rollback on publish failure to restore original package files.
|
|
21
|
+
- Switched version manager command execution to cross-spawn for Windows compatibility and interactive 2FA/OTP publishing.
|
|
22
|
+
- Updated release workflow to derive dist-tag using version-manager and skip duplicate versions on npm.
|
|
23
|
+
- Added unit tests step to CI workflow.
|
|
24
|
+
- Mapped signal exit codes to 130 for SIGINT and 143 for SIGTERM in runner and dependency scripts.
|
|
25
|
+
- Guarded dev runner process signaling to avoid sending signals to terminated child processes.
|
|
26
|
+
- Excluded internal version-manager script from published package files.
|
|
27
|
+
|
|
3
28
|
## 1.2.1 - 2026-11-12
|
|
4
29
|
|
|
5
30
|
- Made the npm install-guard smoke check account for npm versions that skip the root preinstall lifecycle on direct package installs.
|
|
31
|
+
- Updated CI to install dependencies from the pnpm lockfile.
|
|
6
32
|
- Verified all 36 scaffold smoke-test scenarios pass on Linux and Windows.
|
|
7
33
|
|
|
8
34
|
## 1.2.0 - 2026-11-11
|
package/README.md
CHANGED
|
@@ -4,9 +4,9 @@ Create a Vite app with the official interactive setup. Choose React or any other
|
|
|
4
4
|
|
|
5
5
|
[](https://www.npmjs.com/package/create-vanilla-vite)
|
|
6
6
|
[](https://www.npmjs.com/package/create-vanilla-vite)
|
|
7
|
-
[](https://github.com/Wasib-2005/vanilla-vite)
|
|
8
8
|
|
|
9
|
-
**Links:** [npm package](https://www.npmjs.com/package/create-vanilla-vite) · [GitHub repository](https://github.com/Wasib-2005/
|
|
9
|
+
**Links:** [npm package](https://www.npmjs.com/package/create-vanilla-vite) · [GitHub repository](https://github.com/Wasib-2005/vanilla-vite) · [Report an issue](https://github.com/Wasib-2005/vanilla-vite/issues)
|
|
10
10
|
|
|
11
11
|
## Requirements
|
|
12
12
|
|
|
@@ -55,7 +55,9 @@ Available options are `--tailwind`, `--axios`, `--no-axios`, `--router`,
|
|
|
55
55
|
`--no-router`, and `--icons=react-icons|animateicons|none`;
|
|
56
56
|
`--backend=none|basic|express`; `--ts` or `--js` (these language flags apply
|
|
57
57
|
to the optional backend only);
|
|
58
|
-
`--structure=simple|module`;
|
|
58
|
+
`--structure=simple|module`; `--pm=npm|pnpm`; and
|
|
59
|
+
`--install-mode=adD|plain|both` (controls dependency install tooling; adD is default).
|
|
60
|
+
`--no-tailwind` opts out of
|
|
59
61
|
Tailwind when using `--yes`. `--template=vanilla` passes a template directly to
|
|
60
62
|
create-vite. `--no-start` creates the project without starting its dev server.
|
|
61
63
|
The generator offers to initialize Git and make an initial commit; use
|
|
@@ -147,9 +149,13 @@ npm run lint
|
|
|
147
149
|
|
|
148
150
|
## Add dependencies
|
|
149
151
|
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
152
|
+
During scaffolding, you can select how dependencies should be installed:
|
|
153
|
+
|
|
154
|
+
1. **adD only (default)**: All packages should be added using `pnpm adD <package>` or `npm run adD -- <package>`. Direct root installs are blocked by the workspace install guard to prevent placing packages in the wrong location.
|
|
155
|
+
2. **Plain install only**: Dependencies are installed using standard `pnpm add <package>` or `npm install <package>`. No guard is enabled and `adD` is not scaffolded.
|
|
156
|
+
3. **Both**: Provides the `adD` interactive workspace picker, but also allows direct `pnpm add` / `npm install` without blocking.
|
|
157
|
+
|
|
158
|
+
When using `adD` (in `adD only` or `both` mode), the prompt lets you choose the project root, client, or server (if you created one); the client is selected by default, including when you press Esc:
|
|
153
159
|
|
|
154
160
|
```bash
|
|
155
161
|
pnpm adD <package>
|
|
@@ -158,37 +164,169 @@ npm run adD -- <package>
|
|
|
158
164
|
npm run add-dependency -- <package>
|
|
159
165
|
```
|
|
160
166
|
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
167
|
+
To sync or install all workspace dependencies across the monorepo, run `adD` with no package arguments:
|
|
168
|
+
|
|
169
|
+
```bash
|
|
170
|
+
pnpm adD
|
|
171
|
+
# or with npm:
|
|
172
|
+
npm run adD
|
|
173
|
+
```
|
|
174
|
+
|
|
175
|
+
In `adD only` mode, do not use `npm install <package>`, `npm add <package>`, or `pnpm add <package>` directly to add packages. They bypass the location prompt and are blocked by the workspace install guard. A failed or aborted install can leave `node_modules` behind; running `pnpm adD` with no arguments safely syncs dependencies.
|
|
176
|
+
|
|
177
|
+
### Toggle features on and off
|
|
178
|
+
|
|
179
|
+
You can dynamically toggle monorepo features on and off at any time.
|
|
180
|
+
|
|
181
|
+
To turn off `adD` / install guard (switches to plain install mode and hides the dev banner):
|
|
182
|
+
```bash
|
|
183
|
+
pnpm turn-off adD
|
|
184
|
+
# or using shortcuts:
|
|
185
|
+
pnpm tO adD
|
|
186
|
+
pnpm tO
|
|
187
|
+
# with npm:
|
|
188
|
+
npm run tO -- adD
|
|
189
|
+
```
|
|
190
|
+
|
|
191
|
+
To turn `adD` / install guard back on:
|
|
192
|
+
```bash
|
|
193
|
+
pnpm turn-on adD
|
|
194
|
+
# or using shortcuts:
|
|
195
|
+
pnpm tN adD
|
|
196
|
+
pnpm tN
|
|
197
|
+
# with npm:
|
|
198
|
+
npm run tN -- adD
|
|
199
|
+
```
|
|
200
|
+
|
|
201
|
+
Aliases supported for the `adD` feature: `adD`, `add-dependency`, `install`, `i`, `add`, `guard`, `install-mode`. When run without an argument, `tN` and `tO` target `adD` by default.
|
|
202
|
+
|
|
203
|
+
To inspect current features and their status:
|
|
204
|
+
```bash
|
|
205
|
+
node scripts/toggle-feature.mjs status
|
|
206
|
+
```
|
|
168
207
|
|
|
169
208
|
## Development
|
|
170
209
|
|
|
171
|
-
To test from
|
|
210
|
+
To test from source:
|
|
172
211
|
|
|
173
212
|
```bash
|
|
174
|
-
git clone https://github.com/Wasib-2005/
|
|
213
|
+
git clone https://github.com/Wasib-2005/vanilla-vite
|
|
214
|
+
cd vanilla-vite
|
|
215
|
+
pnpm install
|
|
216
|
+
```
|
|
175
217
|
|
|
176
|
-
|
|
218
|
+
Run the generator directly:
|
|
219
|
+
|
|
220
|
+
```bash
|
|
221
|
+
pnpm exec node bin/create-template.mjs my-app
|
|
177
222
|
# or
|
|
178
|
-
|
|
223
|
+
node bin/create-template.mjs my-app
|
|
179
224
|
```
|
|
180
225
|
|
|
181
226
|
Run the scaffold smoke matrix (npm and pnpm, JavaScript and TypeScript,
|
|
182
227
|
frontend-only/basic Node/Express backends, with and without Tailwind) with:
|
|
183
228
|
|
|
184
229
|
```bash
|
|
185
|
-
|
|
186
|
-
|
|
230
|
+
pnpm test:smoke
|
|
231
|
+
```
|
|
232
|
+
|
|
233
|
+
Use `pnpm test:smoke -- --quick` for a smaller publish-time check,
|
|
234
|
+
`SMOKE_FILTER=<text> pnpm test:smoke` to select matching cases, or
|
|
235
|
+
`SMOKE_KEEP=1 pnpm test:smoke` to keep generated test projects for inspection.
|
|
236
|
+
|
|
237
|
+
## Version management and publishing
|
|
238
|
+
|
|
239
|
+
Vanilla-Vite includes a version management CLI to safely bump versions and publish to the npm registry.
|
|
240
|
+
|
|
241
|
+
### With a specified version
|
|
242
|
+
|
|
243
|
+
```bash
|
|
244
|
+
pnpm vpublish 1.0.5
|
|
245
|
+
```
|
|
246
|
+
|
|
247
|
+
### Interactive prompt
|
|
248
|
+
|
|
249
|
+
If invoked without arguments, the version manager compares the latest npm version and the local package version, then prompts for the target version:
|
|
250
|
+
|
|
251
|
+
```bash
|
|
252
|
+
pnpm vpublish
|
|
253
|
+
```
|
|
254
|
+
|
|
255
|
+
Interactive example prompt:
|
|
256
|
+
|
|
257
|
+
```text
|
|
258
|
+
Vanilla-Vite Version Manager
|
|
259
|
+
|
|
260
|
+
Latest npm version: 1.2.1
|
|
261
|
+
Local repository version: 1.2.0
|
|
262
|
+
|
|
263
|
+
Enter the new version:
|
|
264
|
+
```
|
|
265
|
+
|
|
266
|
+
### Safety and validation checks
|
|
267
|
+
|
|
268
|
+
Before publishing, the version manager automatically performs the following safeguards:
|
|
269
|
+
|
|
270
|
+
1. **Root execution restriction**: The CLI refuses to publish when run as root on Linux or macOS to prevent accidental privilege escalation and file permission issues. To override in automated environments, set `ALLOW_ROOT_PUBLISH=1` or pass `--allow-root`.
|
|
271
|
+
2. **Repository verification**: Validates that the command runs from the root of `create-vanilla-vite`.
|
|
272
|
+
3. **SemVer validation**: Enforces strict semantic versioning (e.g. `1.0.5`, `1.1.0-beta.1`). Invalid versions such as `1.0` or `hello` are rejected.
|
|
273
|
+
4. **Duplicate publication prevention**: Checks the npm registry to verify the target version has not already been published.
|
|
274
|
+
5. **Downgrade prevention**: Rejects versions lower than the latest published npm version (override available with `--allow-downgrade`).
|
|
275
|
+
6. **Authentication check**: Verifies active npm registry credentials before running build and publish steps.
|
|
276
|
+
7. **Pre-publish test verification**: Automatically executes `pnpm test:smoke -- --quick` to guarantee all critical smoke tests pass before publishing.
|
|
277
|
+
8. **Prerelease tag routing**: Prerelease versions (such as `1.1.0-beta.1`, `1.1.0-rc.1`) are published with their corresponding distribution tag (`beta`, `rc`, etc.) rather than `latest`. Stable versions publish under `latest`.
|
|
278
|
+
9. **Changelog verification**: Checks `CHANGELOG.md` for an entry corresponding to the target version. If an entry already exists, publishing continues automatically. If no entry exists, the CLI prompts for what to add to the changelog (or accepts `--changelog="<entry>"`).
|
|
279
|
+
10. **Confirmation prompt**: Displays a complete publication summary and requires explicit confirmation before modifying files or uploading packages.
|
|
280
|
+
|
|
281
|
+
### Non-interactive and CI usage
|
|
282
|
+
|
|
283
|
+
```bash
|
|
284
|
+
pnpm vpublish 1.2.2 --yes
|
|
285
|
+
```
|
|
286
|
+
|
|
287
|
+
To test the publishing process without modifying the registry:
|
|
288
|
+
|
|
289
|
+
```bash
|
|
290
|
+
pnpm vpublish 1.2.2 --dry-run
|
|
187
291
|
```
|
|
188
292
|
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
293
|
+
## Troubleshooting
|
|
294
|
+
|
|
295
|
+
### Installation guard blocks direct install
|
|
296
|
+
|
|
297
|
+
Direct installs in the root workspace are blocked in `adD only` mode to keep dependencies organized within individual client and server workspaces.
|
|
298
|
+
- Add dependencies using:
|
|
299
|
+
```bash
|
|
300
|
+
pnpm adD <package>
|
|
301
|
+
# or with npm:
|
|
302
|
+
npm run adD -- <package>
|
|
303
|
+
```
|
|
304
|
+
- To recover from an interrupted install or sync all workspace packages:
|
|
305
|
+
```bash
|
|
306
|
+
pnpm adD
|
|
307
|
+
# or with npm:
|
|
308
|
+
npm run adD
|
|
309
|
+
# or with the allow flag:
|
|
310
|
+
VANILLA_VITE_ALLOW_INSTALL=1 pnpm install
|
|
311
|
+
```
|
|
312
|
+
|
|
313
|
+
### Publishing via CLI or GitHub Release
|
|
314
|
+
|
|
315
|
+
Package publishing is intended to be performed EITHER via the local CLI `pnpm vpublish` OR via a GitHub release, not both. The GitHub Actions release workflow automatically checks whether the version has already been published to the npm registry and skips the publish step if it already exists.
|
|
316
|
+
|
|
317
|
+
### Port conflicts
|
|
318
|
+
|
|
319
|
+
- If port 5173 is in use, Vite stops with a port error due to `strictPort: true`. Free port 5173 or modify `vite.config` to use another port.
|
|
320
|
+
- If backend port 4000 is in use, Express logs `Port 4000 is already in use.` and exits cleanly with non-zero exit code. Change `PORT` in `[server-folder]/.env`.
|
|
321
|
+
|
|
322
|
+
### Root execution error on publish
|
|
323
|
+
|
|
324
|
+
If you see:
|
|
325
|
+
```text
|
|
326
|
+
Refusing to run publishing operations as root.
|
|
327
|
+
Publishing packages with root privileges is unsafe.
|
|
328
|
+
```
|
|
329
|
+
Run `pnpm vpublish` as your regular user. In automated container environments that run as root, set `ALLOW_ROOT_PUBLISH=1` or pass `--allow-root`.
|
|
192
330
|
|
|
193
331
|
## License
|
|
194
332
|
|
package/bin/create-template.mjs
CHANGED
|
@@ -30,8 +30,16 @@ const allowedOptions = [
|
|
|
30
30
|
"--no-start",
|
|
31
31
|
"--no-update-check",
|
|
32
32
|
"--no-git",
|
|
33
|
+
"--install-mode",
|
|
33
34
|
];
|
|
34
|
-
const valueOptions = new Set([
|
|
35
|
+
const valueOptions = new Set([
|
|
36
|
+
"--icons",
|
|
37
|
+
"--backend",
|
|
38
|
+
"--structure",
|
|
39
|
+
"--pm",
|
|
40
|
+
"--template",
|
|
41
|
+
"--install-mode",
|
|
42
|
+
]);
|
|
35
43
|
const optionNames = new Set(allowedOptions);
|
|
36
44
|
const positionalArgs = [];
|
|
37
45
|
const optionErrors = [];
|
|
@@ -78,6 +86,13 @@ const structureOption = readOption("structure");
|
|
|
78
86
|
const requestedPackageManager = readOption("pm");
|
|
79
87
|
const templateOption = readOption("template");
|
|
80
88
|
const iconsOption = readOption("icons");
|
|
89
|
+
const installModeOption = readOption("install-mode");
|
|
90
|
+
if (
|
|
91
|
+
installModeOption !== undefined &&
|
|
92
|
+
!["adD", "plain", "both"].includes(installModeOption)
|
|
93
|
+
) {
|
|
94
|
+
optionErrors.push("--install-mode must be adD, plain, or both");
|
|
95
|
+
}
|
|
81
96
|
if (backendOption !== undefined && !["none", "basic", "express"].includes(backendOption)) {
|
|
82
97
|
optionErrors.push("--backend must be none, basic, or express");
|
|
83
98
|
}
|
|
@@ -193,6 +208,9 @@ const handleCreationSignal = async () => {
|
|
|
193
208
|
process.exit(130);
|
|
194
209
|
};
|
|
195
210
|
|
|
211
|
+
process.on("SIGINT", handleCreationSignal);
|
|
212
|
+
process.on("SIGTERM", handleCreationSignal);
|
|
213
|
+
|
|
196
214
|
function parseSemver(version) {
|
|
197
215
|
const match =
|
|
198
216
|
/^(0|[1-9]\d*)\.(0|[1-9]\d*)\.(0|[1-9]\d*)(?:-((?:0|[1-9]\d*|\d*[A-Za-z-][0-9A-Za-z-]*)(?:\.(?:0|[1-9]\d*|\d*[A-Za-z-][0-9A-Za-z-]*))*))?(?:\+[0-9A-Za-z-]+(?:\.[0-9A-Za-z-]+)*)?$/.exec(version);
|
|
@@ -269,7 +287,7 @@ async function updateIfOutdated() {
|
|
|
269
287
|
}
|
|
270
288
|
if (!stdin.isTTY) {
|
|
271
289
|
console.warn(
|
|
272
|
-
`\nA newer version of create-vanilla-vite is available (${latestVersion}; current: ${installedVersion}). Run ${packageManager} create vanilla-vite
|
|
290
|
+
`\nA newer version of create-vanilla-vite is available (${latestVersion}; current: ${installedVersion}). Run ${packageManager} create vanilla-vite@${latestVersion} to use it.`,
|
|
273
291
|
);
|
|
274
292
|
return;
|
|
275
293
|
}
|
|
@@ -290,11 +308,11 @@ async function updateIfOutdated() {
|
|
|
290
308
|
];
|
|
291
309
|
const updateArgs =
|
|
292
310
|
packageManager === "pnpm"
|
|
293
|
-
? ["dlx",
|
|
311
|
+
? ["dlx", `create-vanilla-vite@${latestVersion}`, ...relaunchArgs]
|
|
294
312
|
: [
|
|
295
313
|
"exec",
|
|
296
314
|
"--yes",
|
|
297
|
-
|
|
315
|
+
`--package=create-vanilla-vite@${latestVersion}`,
|
|
298
316
|
"--",
|
|
299
317
|
"create-vanilla-vite",
|
|
300
318
|
...relaunchArgs,
|
|
@@ -996,7 +1014,7 @@ a {
|
|
|
996
1014
|
`,
|
|
997
1015
|
),
|
|
998
1016
|
]
|
|
999
|
-
: []),
|
|
1017
|
+
: [rm(join(sourceRoot, "App.css"), { force: true })]),
|
|
1000
1018
|
writeFile(
|
|
1001
1019
|
entryPath,
|
|
1002
1020
|
`import { StrictMode } from "react";
|
|
@@ -1346,15 +1364,35 @@ export function createApp() {
|
|
|
1346
1364
|
}
|
|
1347
1365
|
`
|
|
1348
1366
|
: null;
|
|
1367
|
+
const listenErrorParam = language === "ts" ? "error?: Error" : "error";
|
|
1349
1368
|
const server = `import "dotenv/config";
|
|
1350
1369
|
import { createApp } from "./app.${extension}";
|
|
1351
1370
|
|
|
1352
|
-
|
|
1371
|
+
function parsePort(value${language === "ts" ? ": string | undefined" : ""})${typeAnnotation} {
|
|
1372
|
+
if (!value || value.trim() === "") return 4000;
|
|
1373
|
+
const parsed = Number(value);
|
|
1374
|
+
if (!Number.isInteger(parsed) || parsed < 1 || parsed > 65535) {
|
|
1375
|
+
console.warn(\`Invalid PORT "\${value}"; falling back to 4000.\`);
|
|
1376
|
+
return 4000;
|
|
1377
|
+
}
|
|
1378
|
+
return parsed;
|
|
1379
|
+
}
|
|
1380
|
+
|
|
1381
|
+
const port${typeAnnotation} = parsePort(process.env.PORT);
|
|
1353
1382
|
const host = process.env.HOST ?? "localhost";
|
|
1354
1383
|
const app = createApp();
|
|
1355
|
-
const server = app.listen(port, host, () => {
|
|
1384
|
+
const server = app.listen(port, host, (${listenErrorParam}) => {
|
|
1385
|
+
if (error) return;
|
|
1356
1386
|
console.log(\`Backend listening at http://\${host}:\${port}\`);
|
|
1357
1387
|
});
|
|
1388
|
+
server.on("error", (error${language === "ts" ? ": NodeJS.ErrnoException" : ""}) => {
|
|
1389
|
+
if (error.code === "EADDRINUSE") {
|
|
1390
|
+
console.error(\`Port \${port} is already in use.\`);
|
|
1391
|
+
} else {
|
|
1392
|
+
console.error("Backend failed to start:", error.message || error);
|
|
1393
|
+
}
|
|
1394
|
+
process.exit(1);
|
|
1395
|
+
});
|
|
1358
1396
|
for (const signal of ["SIGINT", "SIGTERM"]) {
|
|
1359
1397
|
process.once(signal, () => {
|
|
1360
1398
|
server.close((error) => {
|
|
@@ -1541,8 +1579,6 @@ await updateIfOutdated();
|
|
|
1541
1579
|
try {
|
|
1542
1580
|
await mkdir(root);
|
|
1543
1581
|
rootCreated = true;
|
|
1544
|
-
process.on("SIGINT", handleCreationSignal);
|
|
1545
|
-
process.on("SIGTERM", handleCreationSignal);
|
|
1546
1582
|
} catch (error) {
|
|
1547
1583
|
if (error.code === "EEXIST") console.error(`The destination already exists: ${root}`);
|
|
1548
1584
|
else console.error(`Unable to create project directory: ${error.message}`);
|
|
@@ -1612,16 +1648,53 @@ try {
|
|
|
1612
1648
|
workspaces.push(serverFolder);
|
|
1613
1649
|
}
|
|
1614
1650
|
|
|
1651
|
+
const installMode =
|
|
1652
|
+
installModeOption !== undefined
|
|
1653
|
+
? installModeOption
|
|
1654
|
+
: await chooseOption(
|
|
1655
|
+
"How do you want to install dependencies later?",
|
|
1656
|
+
[
|
|
1657
|
+
{
|
|
1658
|
+
label:
|
|
1659
|
+
packageManager === "pnpm"
|
|
1660
|
+
? "adD only — use `pnpm adD <pkg>` to choose workspaces (default)"
|
|
1661
|
+
: "adD only — use `npm run adD -- <pkg>` to choose workspaces (default)",
|
|
1662
|
+
value: "adD",
|
|
1663
|
+
},
|
|
1664
|
+
{
|
|
1665
|
+
label:
|
|
1666
|
+
packageManager === "pnpm"
|
|
1667
|
+
? "Plain install only — use standard `pnpm add <pkg>`"
|
|
1668
|
+
: "Plain install only — use standard `npm install <pkg>`",
|
|
1669
|
+
value: "plain",
|
|
1670
|
+
},
|
|
1671
|
+
{
|
|
1672
|
+
label: "Both — allow plain installs and provide adD for choosing workspaces",
|
|
1673
|
+
value: "both",
|
|
1674
|
+
},
|
|
1675
|
+
],
|
|
1676
|
+
0,
|
|
1677
|
+
"yellow",
|
|
1678
|
+
);
|
|
1679
|
+
|
|
1615
1680
|
await mkdir(join(root, "scripts"), { recursive: true });
|
|
1616
|
-
|
|
1617
|
-
|
|
1618
|
-
|
|
1681
|
+
const scriptsToCopy = [
|
|
1682
|
+
"dev.mjs",
|
|
1683
|
+
"run-app.mjs",
|
|
1684
|
+
"install-info.mjs",
|
|
1685
|
+
"toggle-feature.mjs",
|
|
1686
|
+
...(installMode !== "plain" ? ["add-dependency.mjs"] : []),
|
|
1687
|
+
];
|
|
1688
|
+
await Promise.all(scriptsToCopy.map(copyScript));
|
|
1619
1689
|
const rootPackage = {
|
|
1620
1690
|
name: projectName,
|
|
1621
1691
|
version: "1.0.0",
|
|
1622
1692
|
private: true,
|
|
1623
1693
|
engines: { node: ">=20.6" },
|
|
1624
1694
|
workspaces,
|
|
1695
|
+
vanillaVite: {
|
|
1696
|
+
installMode,
|
|
1697
|
+
},
|
|
1625
1698
|
scripts: {
|
|
1626
1699
|
preinstall: "node scripts/install-info.mjs",
|
|
1627
1700
|
postinstall: "node scripts/install-info.mjs --complete",
|
|
@@ -1635,9 +1708,19 @@ try {
|
|
|
1635
1708
|
? "pnpm -r --if-present run lint"
|
|
1636
1709
|
: "npm run lint --workspaces --if-present",
|
|
1637
1710
|
client: "node scripts/run-app.mjs client",
|
|
1638
|
-
|
|
1639
|
-
|
|
1711
|
+
...(installMode !== "plain"
|
|
1712
|
+
? {
|
|
1713
|
+
adD: "node scripts/add-dependency.mjs",
|
|
1714
|
+
"add-dependency": "node scripts/add-dependency.mjs",
|
|
1715
|
+
}
|
|
1716
|
+
: {}),
|
|
1640
1717
|
...(includeServer ? { server: "node scripts/run-app.mjs server" } : {}),
|
|
1718
|
+
"turn-on": "node scripts/toggle-feature.mjs on",
|
|
1719
|
+
"trun-on": "node scripts/toggle-feature.mjs on",
|
|
1720
|
+
tN: "node scripts/toggle-feature.mjs on",
|
|
1721
|
+
"turn-off": "node scripts/toggle-feature.mjs off",
|
|
1722
|
+
"trun-off": "node scripts/toggle-feature.mjs off",
|
|
1723
|
+
tO: "node scripts/toggle-feature.mjs off",
|
|
1641
1724
|
},
|
|
1642
1725
|
type: "module",
|
|
1643
1726
|
dependencies: {
|
|
@@ -1756,9 +1839,17 @@ if (!creationCancelled && !noStart && !installFailed) {
|
|
|
1756
1839
|
root,
|
|
1757
1840
|
);
|
|
1758
1841
|
} catch (error) {
|
|
1759
|
-
|
|
1760
|
-
|
|
1761
|
-
|
|
1762
|
-
|
|
1842
|
+
if (
|
|
1843
|
+
!creationCancelled &&
|
|
1844
|
+
error?.message &&
|
|
1845
|
+
!error.message.includes("SIGINT") &&
|
|
1846
|
+
!error.message.includes("SIGTERM") &&
|
|
1847
|
+
!error.message.includes("code 130")
|
|
1848
|
+
) {
|
|
1849
|
+
console.error(
|
|
1850
|
+
`\nProject created successfully, but the development server could not be started: ${error.message}`,
|
|
1851
|
+
);
|
|
1852
|
+
process.exitCode = 1;
|
|
1853
|
+
}
|
|
1763
1854
|
}
|
|
1764
1855
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "create-vanilla-vite",
|
|
3
|
-
"version": "1.2.
|
|
3
|
+
"version": "1.2.3",
|
|
4
4
|
"description": "Scaffold a React or Vite app with an optional Node.js or Express backend",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"repository": {
|
|
@@ -16,7 +16,11 @@
|
|
|
16
16
|
},
|
|
17
17
|
"files": [
|
|
18
18
|
"bin/",
|
|
19
|
-
"scripts/",
|
|
19
|
+
"scripts/dev.mjs",
|
|
20
|
+
"scripts/run-app.mjs",
|
|
21
|
+
"scripts/install-info.mjs",
|
|
22
|
+
"scripts/add-dependency.mjs",
|
|
23
|
+
"scripts/toggle-feature.mjs",
|
|
20
24
|
"CHANGELOG.md",
|
|
21
25
|
"README.md"
|
|
22
26
|
],
|
|
@@ -47,7 +51,21 @@
|
|
|
47
51
|
"dependencies": {
|
|
48
52
|
"cross-spawn": "^7.0.6"
|
|
49
53
|
},
|
|
54
|
+
"vanillaVite": {
|
|
55
|
+
"installMode": "adD"
|
|
56
|
+
},
|
|
50
57
|
"scripts": {
|
|
51
|
-
"test
|
|
58
|
+
"test": "node test/fixes.test.mjs && node test/version-manager.test.mjs && node test/smoke.mjs --quick",
|
|
59
|
+
"test:unit": "node test/fixes.test.mjs && node test/version-manager.test.mjs",
|
|
60
|
+
"test:smoke": "node test/smoke.mjs",
|
|
61
|
+
"vpublish": "node scripts/version-manager.mjs",
|
|
62
|
+
"turn-on": "node scripts/toggle-feature.mjs on",
|
|
63
|
+
"trun-on": "node scripts/toggle-feature.mjs on",
|
|
64
|
+
"tN": "node scripts/toggle-feature.mjs on",
|
|
65
|
+
"turn-off": "node scripts/toggle-feature.mjs off",
|
|
66
|
+
"trun-off": "node scripts/toggle-feature.mjs off",
|
|
67
|
+
"tO": "node scripts/toggle-feature.mjs off",
|
|
68
|
+
"adD": "node scripts/add-dependency.mjs",
|
|
69
|
+
"add-dependency": "node scripts/add-dependency.mjs"
|
|
52
70
|
}
|
|
53
71
|
}
|
|
@@ -8,12 +8,34 @@ import spawn from "cross-spawn";
|
|
|
8
8
|
const root = fileURLToPath(new URL("../", import.meta.url));
|
|
9
9
|
const project = JSON.parse(await readFile(join(root, "package.json"), "utf8"));
|
|
10
10
|
const packages = process.argv.slice(2);
|
|
11
|
+
const packageManager = process.env.npm_config_user_agent?.startsWith("pnpm/")
|
|
12
|
+
? "pnpm"
|
|
13
|
+
: "npm";
|
|
11
14
|
|
|
12
15
|
if (packages.length === 0) {
|
|
13
|
-
console.
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
16
|
+
console.log(`Syncing workspace dependencies with ${packageManager} install...`);
|
|
17
|
+
const child = spawn(packageManager, ["install"], {
|
|
18
|
+
cwd: root,
|
|
19
|
+
stdio: "inherit",
|
|
20
|
+
env: { ...process.env, VANILLA_VITE_ALLOW_INSTALL: "1" },
|
|
21
|
+
});
|
|
22
|
+
child.once("error", (error) => {
|
|
23
|
+
console.error(`Unable to run ${packageManager}: ${error.message}`);
|
|
24
|
+
process.exitCode = 1;
|
|
25
|
+
});
|
|
26
|
+
child.once("exit", (code, signal) => {
|
|
27
|
+
process.exitCode =
|
|
28
|
+
code ??
|
|
29
|
+
(signal === "SIGINT"
|
|
30
|
+
? 130
|
|
31
|
+
: signal === "SIGTERM"
|
|
32
|
+
? 143
|
|
33
|
+
: signal
|
|
34
|
+
? 1
|
|
35
|
+
: 0);
|
|
36
|
+
});
|
|
37
|
+
await new Promise((resolve) => child.once("close", resolve));
|
|
38
|
+
process.exit(process.exitCode ?? 0);
|
|
17
39
|
}
|
|
18
40
|
|
|
19
41
|
if (!stdin.isTTY) {
|
|
@@ -85,9 +107,6 @@ if (!selectedTarget) {
|
|
|
85
107
|
process.exit(130);
|
|
86
108
|
}
|
|
87
109
|
|
|
88
|
-
const packageManager = process.env.npm_config_user_agent?.startsWith("pnpm/")
|
|
89
|
-
? "pnpm"
|
|
90
|
-
: "npm";
|
|
91
110
|
const { workspace } = selectedTarget;
|
|
92
111
|
const commandArgs =
|
|
93
112
|
packageManager === "pnpm"
|
|
@@ -108,5 +127,13 @@ child.once("error", (error) => {
|
|
|
108
127
|
process.exitCode = 1;
|
|
109
128
|
});
|
|
110
129
|
child.once("exit", (code, signal) => {
|
|
111
|
-
process.exitCode =
|
|
130
|
+
process.exitCode =
|
|
131
|
+
code ??
|
|
132
|
+
(signal === "SIGINT"
|
|
133
|
+
? 130
|
|
134
|
+
: signal === "SIGTERM"
|
|
135
|
+
? 143
|
|
136
|
+
: signal
|
|
137
|
+
? 1
|
|
138
|
+
: 0);
|
|
112
139
|
});
|