create-vanilla-vite 1.2.1 → 1.2.2
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 +15 -0
- package/README.md +129 -22
- package/bin/create-template.mjs +99 -15
- package/package.json +9 -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/CHANGELOG.md
CHANGED
|
@@ -1,8 +1,23 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## 1.2.2 - 2026-11-19
|
|
4
|
+
|
|
5
|
+
- Added `--install-mode=adD|plain|both` option and interactive prompt to choose dependency installation behavior.
|
|
6
|
+
- Added dependency synchronization when running `adD` with no package arguments.
|
|
7
|
+
- Fixed Express 5 server listen callback to prevent printing success message on startup errors.
|
|
8
|
+
- Fixed `--dry-run` in version manager to never write package files.
|
|
9
|
+
- Added full rollback on publish failure to restore original package files.
|
|
10
|
+
- Switched version manager command execution to cross-spawn for Windows compatibility and interactive 2FA/OTP publishing.
|
|
11
|
+
- Updated release workflow to derive dist-tag using version-manager and skip duplicate versions on npm.
|
|
12
|
+
- Added unit tests step to CI workflow.
|
|
13
|
+
- Mapped signal exit codes to 130 for SIGINT and 143 for SIGTERM in runner and dependency scripts.
|
|
14
|
+
- Guarded dev runner process signaling to avoid sending signals to terminated child processes.
|
|
15
|
+
- Excluded internal version-manager script from published package files.
|
|
16
|
+
|
|
3
17
|
## 1.2.1 - 2026-11-12
|
|
4
18
|
|
|
5
19
|
- Made the npm install-guard smoke check account for npm versions that skip the root preinstall lifecycle on direct package installs.
|
|
20
|
+
- Updated CI to install dependencies from the pnpm lockfile.
|
|
6
21
|
- Verified all 36 scaffold smoke-test scenarios pass on Linux and Windows.
|
|
7
22
|
|
|
8
23
|
## 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,138 @@ 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.
|
|
168
176
|
|
|
169
177
|
## Development
|
|
170
178
|
|
|
171
|
-
To test from
|
|
179
|
+
To test from source:
|
|
172
180
|
|
|
173
181
|
```bash
|
|
174
|
-
git clone https://github.com/Wasib-2005/
|
|
182
|
+
git clone https://github.com/Wasib-2005/vanilla-vite
|
|
183
|
+
cd vanilla-vite
|
|
184
|
+
pnpm install
|
|
185
|
+
```
|
|
186
|
+
|
|
187
|
+
Run the generator directly:
|
|
175
188
|
|
|
176
|
-
|
|
189
|
+
```bash
|
|
190
|
+
pnpm exec node bin/create-template.mjs my-app
|
|
177
191
|
# or
|
|
178
|
-
|
|
192
|
+
node bin/create-template.mjs my-app
|
|
179
193
|
```
|
|
180
194
|
|
|
181
195
|
Run the scaffold smoke matrix (npm and pnpm, JavaScript and TypeScript,
|
|
182
196
|
frontend-only/basic Node/Express backends, with and without Tailwind) with:
|
|
183
197
|
|
|
184
198
|
```bash
|
|
185
|
-
|
|
186
|
-
|
|
199
|
+
pnpm test:smoke
|
|
200
|
+
```
|
|
201
|
+
|
|
202
|
+
Use `pnpm test:smoke -- --quick` for a smaller publish-time check,
|
|
203
|
+
`SMOKE_FILTER=<text> pnpm test:smoke` to select matching cases, or
|
|
204
|
+
`SMOKE_KEEP=1 pnpm test:smoke` to keep generated test projects for inspection.
|
|
205
|
+
|
|
206
|
+
## Version management and publishing
|
|
207
|
+
|
|
208
|
+
Vanilla-Vite includes a version management CLI to safely bump versions and publish to the npm registry.
|
|
209
|
+
|
|
210
|
+
### With a specified version
|
|
211
|
+
|
|
212
|
+
```bash
|
|
213
|
+
pnpm vpublish 1.0.5
|
|
214
|
+
```
|
|
215
|
+
|
|
216
|
+
### Interactive prompt
|
|
217
|
+
|
|
218
|
+
If invoked without arguments, the version manager compares the latest npm version and the local package version, then prompts for the target version:
|
|
219
|
+
|
|
220
|
+
```bash
|
|
221
|
+
pnpm vpublish
|
|
222
|
+
```
|
|
223
|
+
|
|
224
|
+
Interactive example prompt:
|
|
225
|
+
|
|
226
|
+
```text
|
|
227
|
+
Vanilla-Vite Version Manager
|
|
228
|
+
|
|
229
|
+
Latest npm version: 1.2.1
|
|
230
|
+
Local repository version: 1.2.0
|
|
231
|
+
|
|
232
|
+
Enter the new version:
|
|
233
|
+
```
|
|
234
|
+
|
|
235
|
+
### Safety and validation checks
|
|
236
|
+
|
|
237
|
+
Before publishing, the version manager automatically performs the following safeguards:
|
|
238
|
+
|
|
239
|
+
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`.
|
|
240
|
+
2. **Repository verification**: Validates that the command runs from the root of `create-vanilla-vite`.
|
|
241
|
+
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.
|
|
242
|
+
4. **Duplicate publication prevention**: Checks the npm registry to verify the target version has not already been published.
|
|
243
|
+
5. **Downgrade prevention**: Rejects versions lower than the latest published npm version (override available with `--allow-downgrade`).
|
|
244
|
+
6. **Authentication check**: Verifies active npm registry credentials before running build and publish steps.
|
|
245
|
+
7. **Pre-publish test verification**: Automatically executes `pnpm test:smoke -- --quick` to guarantee all critical smoke tests pass before publishing.
|
|
246
|
+
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`.
|
|
247
|
+
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>"`).
|
|
248
|
+
10. **Confirmation prompt**: Displays a complete publication summary and requires explicit confirmation before modifying files or uploading packages.
|
|
249
|
+
|
|
250
|
+
### Non-interactive and CI usage
|
|
251
|
+
|
|
252
|
+
```bash
|
|
253
|
+
pnpm vpublish 1.2.2 --yes
|
|
254
|
+
```
|
|
255
|
+
|
|
256
|
+
To test the publishing process without modifying the registry:
|
|
257
|
+
|
|
258
|
+
```bash
|
|
259
|
+
pnpm vpublish 1.2.2 --dry-run
|
|
187
260
|
```
|
|
188
261
|
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
262
|
+
## Troubleshooting
|
|
263
|
+
|
|
264
|
+
### Installation guard blocks direct install
|
|
265
|
+
|
|
266
|
+
Direct installs in the root workspace are blocked in `adD only` mode to keep dependencies organized within individual client and server workspaces.
|
|
267
|
+
- Add dependencies using:
|
|
268
|
+
```bash
|
|
269
|
+
pnpm adD <package>
|
|
270
|
+
# or with npm:
|
|
271
|
+
npm run adD -- <package>
|
|
272
|
+
```
|
|
273
|
+
- To recover from an interrupted install or sync all workspace packages:
|
|
274
|
+
```bash
|
|
275
|
+
pnpm adD
|
|
276
|
+
# or with npm:
|
|
277
|
+
npm run adD
|
|
278
|
+
# or with the allow flag:
|
|
279
|
+
VANILLA_VITE_ALLOW_INSTALL=1 pnpm install
|
|
280
|
+
```
|
|
281
|
+
|
|
282
|
+
### Publishing via CLI or GitHub Release
|
|
283
|
+
|
|
284
|
+
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.
|
|
285
|
+
|
|
286
|
+
### Port conflicts
|
|
287
|
+
|
|
288
|
+
- 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.
|
|
289
|
+
- 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`.
|
|
290
|
+
|
|
291
|
+
### Root execution error on publish
|
|
292
|
+
|
|
293
|
+
If you see:
|
|
294
|
+
```text
|
|
295
|
+
Refusing to run publishing operations as root.
|
|
296
|
+
Publishing packages with root privileges is unsafe.
|
|
297
|
+
```
|
|
298
|
+
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
299
|
|
|
193
300
|
## License
|
|
194
301
|
|
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);
|
|
@@ -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,52 @@ 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
|
+
...(installMode !== "plain" ? ["add-dependency.mjs"] : []),
|
|
1686
|
+
];
|
|
1687
|
+
await Promise.all(scriptsToCopy.map(copyScript));
|
|
1619
1688
|
const rootPackage = {
|
|
1620
1689
|
name: projectName,
|
|
1621
1690
|
version: "1.0.0",
|
|
1622
1691
|
private: true,
|
|
1623
1692
|
engines: { node: ">=20.6" },
|
|
1624
1693
|
workspaces,
|
|
1694
|
+
vanillaVite: {
|
|
1695
|
+
installMode,
|
|
1696
|
+
},
|
|
1625
1697
|
scripts: {
|
|
1626
1698
|
preinstall: "node scripts/install-info.mjs",
|
|
1627
1699
|
postinstall: "node scripts/install-info.mjs --complete",
|
|
@@ -1635,8 +1707,12 @@ try {
|
|
|
1635
1707
|
? "pnpm -r --if-present run lint"
|
|
1636
1708
|
: "npm run lint --workspaces --if-present",
|
|
1637
1709
|
client: "node scripts/run-app.mjs client",
|
|
1638
|
-
|
|
1639
|
-
|
|
1710
|
+
...(installMode !== "plain"
|
|
1711
|
+
? {
|
|
1712
|
+
adD: "node scripts/add-dependency.mjs",
|
|
1713
|
+
"add-dependency": "node scripts/add-dependency.mjs",
|
|
1714
|
+
}
|
|
1715
|
+
: {}),
|
|
1640
1716
|
...(includeServer ? { server: "node scripts/run-app.mjs server" } : {}),
|
|
1641
1717
|
},
|
|
1642
1718
|
type: "module",
|
|
@@ -1756,9 +1832,17 @@ if (!creationCancelled && !noStart && !installFailed) {
|
|
|
1756
1832
|
root,
|
|
1757
1833
|
);
|
|
1758
1834
|
} catch (error) {
|
|
1759
|
-
|
|
1760
|
-
|
|
1761
|
-
|
|
1762
|
-
|
|
1835
|
+
if (
|
|
1836
|
+
!creationCancelled &&
|
|
1837
|
+
error?.message &&
|
|
1838
|
+
!error.message.includes("SIGINT") &&
|
|
1839
|
+
!error.message.includes("SIGTERM") &&
|
|
1840
|
+
!error.message.includes("code 130")
|
|
1841
|
+
) {
|
|
1842
|
+
console.error(
|
|
1843
|
+
`\nProject created successfully, but the development server could not be started: ${error.message}`,
|
|
1844
|
+
);
|
|
1845
|
+
process.exitCode = 1;
|
|
1846
|
+
}
|
|
1763
1847
|
}
|
|
1764
1848
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "create-vanilla-vite",
|
|
3
|
-
"version": "1.2.
|
|
3
|
+
"version": "1.2.2",
|
|
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,10 @@
|
|
|
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",
|
|
20
23
|
"CHANGELOG.md",
|
|
21
24
|
"README.md"
|
|
22
25
|
],
|
|
@@ -48,6 +51,9 @@
|
|
|
48
51
|
"cross-spawn": "^7.0.6"
|
|
49
52
|
},
|
|
50
53
|
"scripts": {
|
|
51
|
-
"test
|
|
54
|
+
"test": "node test/fixes.test.mjs && node test/version-manager.test.mjs && node test/smoke.mjs --quick",
|
|
55
|
+
"test:unit": "node test/fixes.test.mjs && node test/version-manager.test.mjs",
|
|
56
|
+
"test:smoke": "node test/smoke.mjs",
|
|
57
|
+
"vpublish": "node scripts/version-manager.mjs"
|
|
52
58
|
}
|
|
53
59
|
}
|
|
@@ -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
|
});
|
package/scripts/dev.mjs
CHANGED
|
@@ -6,7 +6,6 @@ import {
|
|
|
6
6
|
closeSync,
|
|
7
7
|
openSync,
|
|
8
8
|
readFileSync,
|
|
9
|
-
statSync,
|
|
10
9
|
unlinkSync,
|
|
11
10
|
writeFileSync,
|
|
12
11
|
} from "node:fs";
|
|
@@ -19,7 +18,9 @@ const logFile = join(root, ".dev.log");
|
|
|
19
18
|
const lockFile = join(root, ".dev.lock");
|
|
20
19
|
const maxLogLines = 2000;
|
|
21
20
|
const maxLogBytes = 1_000_000;
|
|
21
|
+
let currentLogBytes = 0;
|
|
22
22
|
const project = JSON.parse(await readFile(join(root, "package.json"), "utf8"));
|
|
23
|
+
const installMode = project.vanillaVite?.installMode ?? "adD";
|
|
23
24
|
const children = [];
|
|
24
25
|
let lockDescriptor;
|
|
25
26
|
|
|
@@ -139,13 +140,31 @@ async function updateEnvValue(path, key, value) {
|
|
|
139
140
|
if (error.code !== "ENOENT") throw error;
|
|
140
141
|
contents = "";
|
|
141
142
|
}
|
|
142
|
-
const
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
143
|
+
const lines = contents.split(/\r?\n/);
|
|
144
|
+
let found = false;
|
|
145
|
+
const newLines = [];
|
|
146
|
+
const keyPattern = new RegExp(`^\\s*${key}\\s*=`);
|
|
147
|
+
for (const line of lines) {
|
|
148
|
+
if (keyPattern.test(line)) {
|
|
149
|
+
if (!found) {
|
|
150
|
+
newLines.push(`${key}=${value}`);
|
|
151
|
+
found = true;
|
|
152
|
+
}
|
|
153
|
+
} else {
|
|
154
|
+
newLines.push(line);
|
|
155
|
+
}
|
|
156
|
+
}
|
|
157
|
+
if (!found) {
|
|
158
|
+
if (newLines.length > 0 && newLines[newLines.length - 1] === "") {
|
|
159
|
+
newLines[newLines.length - 1] = `${key}=${value}`;
|
|
160
|
+
newLines.push("");
|
|
161
|
+
} else {
|
|
162
|
+
newLines.push(`${key}=${value}`);
|
|
163
|
+
newLines.push("");
|
|
164
|
+
}
|
|
147
165
|
}
|
|
148
|
-
|
|
166
|
+
const result = newLines.join("\n");
|
|
167
|
+
await writeFile(path, result.endsWith("\n") ? result : `${result}\n`);
|
|
149
168
|
}
|
|
150
169
|
|
|
151
170
|
async function ensureEnvFiles() {
|
|
@@ -172,10 +191,29 @@ async function updateNetworkEnvironment(enabled, address) {
|
|
|
172
191
|
const server = apps.find((app) => app.name === "server");
|
|
173
192
|
if (!client) return;
|
|
174
193
|
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
194
|
+
let serverPort = "4000";
|
|
195
|
+
if (server) {
|
|
196
|
+
try {
|
|
197
|
+
const serverEnv = await readFile(join(root, server.workspace, ".env"), "utf8");
|
|
198
|
+
const match = serverEnv.match(/^\s*PORT\s*=\s*(.*)$/m);
|
|
199
|
+
if (match) {
|
|
200
|
+
const portCandidate = match[1].trim();
|
|
201
|
+
if (portCandidate !== "") {
|
|
202
|
+
const parsed = Number(portCandidate);
|
|
203
|
+
if (Number.isInteger(parsed) && parsed >= 1 && parsed <= 65535) {
|
|
204
|
+
serverPort = String(parsed);
|
|
205
|
+
} else {
|
|
206
|
+
log(
|
|
207
|
+
"dev",
|
|
208
|
+
`Warning: Invalid PORT "${portCandidate}" in ${server.workspace}/.env; using fallback 4000.`,
|
|
209
|
+
);
|
|
210
|
+
}
|
|
211
|
+
}
|
|
212
|
+
}
|
|
213
|
+
} catch (error) {
|
|
214
|
+
if (error.code !== "ENOENT") throw error;
|
|
215
|
+
}
|
|
216
|
+
}
|
|
179
217
|
await updateEnvValue(
|
|
180
218
|
join(root, client.workspace, ".env.local"),
|
|
181
219
|
"VITE_API_URL",
|
|
@@ -215,10 +253,15 @@ function formatLog(name, message) {
|
|
|
215
253
|
}
|
|
216
254
|
|
|
217
255
|
function showDependencyCommands() {
|
|
256
|
+
if (installMode === "plain") return;
|
|
218
257
|
const commands =
|
|
219
|
-
|
|
220
|
-
?
|
|
221
|
-
|
|
258
|
+
installMode === "both"
|
|
259
|
+
? packageManager === "pnpm"
|
|
260
|
+
? [" > pnpm adD <package> (choose workspace)", " > pnpm add <package> (or direct install)"]
|
|
261
|
+
: [" > npm run adD -- <package> (choose workspace)", " > npm install <package> (or direct install)"]
|
|
262
|
+
: packageManager === "pnpm"
|
|
263
|
+
? [" > pnpm adD <package>", " > pnpm add-dependency <package>"]
|
|
264
|
+
: [" > npm run adD -- <package>", " > npm run add-dependency -- <package>"];
|
|
222
265
|
const lines = [">>> ADD DEPENDENCIES LATER <<<", ...commands];
|
|
223
266
|
const width = Math.max(...lines.map((line) => line.length));
|
|
224
267
|
const border = "+".repeat(width);
|
|
@@ -358,8 +401,10 @@ function displayLog(name, message, write = console.log) {
|
|
|
358
401
|
.replace(/\x1B\[[0-?]*[ -/]*[JKH]/g, "");
|
|
359
402
|
const formatted = formatLog(name, cleanMessage);
|
|
360
403
|
const plain = formatted.replace(/\x1b\[[0-?]*[ -/]*[@-~]/g, "");
|
|
361
|
-
|
|
362
|
-
|
|
404
|
+
const lineBuffer = Buffer.from(`${plain}\n`);
|
|
405
|
+
appendFileSync(logFile, lineBuffer);
|
|
406
|
+
currentLogBytes += lineBuffer.length;
|
|
407
|
+
if (currentLogBytes > maxLogBytes - 1) {
|
|
363
408
|
const lines = readFileSync(logFile, "utf8")
|
|
364
409
|
.split(/\r?\n/)
|
|
365
410
|
.filter(Boolean)
|
|
@@ -379,7 +424,9 @@ function displayLog(name, message, write = console.log) {
|
|
|
379
424
|
content = bytes.subarray(-(maxLogBytes - 1)).toString("utf8");
|
|
380
425
|
}
|
|
381
426
|
}
|
|
382
|
-
|
|
427
|
+
const finalContent = content ? `${content}\n` : "";
|
|
428
|
+
writeFileSync(logFile, finalContent);
|
|
429
|
+
currentLogBytes = Buffer.byteLength(finalContent);
|
|
383
430
|
}
|
|
384
431
|
|
|
385
432
|
if (
|
|
@@ -420,6 +467,7 @@ function start({ name, workspace }) {
|
|
|
420
467
|
stdio: ["ignore", "pipe", "pipe"],
|
|
421
468
|
});
|
|
422
469
|
child.appName = name;
|
|
470
|
+
child.intentionallyStopped = false;
|
|
423
471
|
children.push(child);
|
|
424
472
|
for (const stream of [child.stdout, child.stderr]) {
|
|
425
473
|
stream.setEncoding("utf8");
|
|
@@ -441,11 +489,13 @@ function start({ name, workspace }) {
|
|
|
441
489
|
stream.once("end", () => displayChildLine(pending));
|
|
442
490
|
}
|
|
443
491
|
child.once("error", (error) => {
|
|
492
|
+
if (child.intentionallyStopped) return;
|
|
444
493
|
log(name, `Unable to start: ${error.message}`, console.error);
|
|
445
494
|
process.exitCode = 1;
|
|
446
495
|
void stop();
|
|
447
496
|
});
|
|
448
497
|
child.once("close", (code) => {
|
|
498
|
+
if (child.intentionallyStopped) return;
|
|
449
499
|
if (!stopping && !restarting) {
|
|
450
500
|
if (code !== 0) {
|
|
451
501
|
log(name, `Process exited with code ${code ?? "unknown"}.`, console.error);
|
|
@@ -457,10 +507,12 @@ function start({ name, workspace }) {
|
|
|
457
507
|
}
|
|
458
508
|
|
|
459
509
|
function signalChild(child, signal) {
|
|
510
|
+
child.intentionallyStopped = true;
|
|
511
|
+
if (child.exitCode !== null || child.signalCode !== null) return;
|
|
460
512
|
try {
|
|
461
513
|
if (child.pid) {
|
|
462
514
|
process.kill(-child.pid, signal);
|
|
463
|
-
} else
|
|
515
|
+
} else {
|
|
464
516
|
child.kill(signal);
|
|
465
517
|
}
|
|
466
518
|
} catch (error) {
|
|
@@ -471,20 +523,24 @@ function signalChild(child, signal) {
|
|
|
471
523
|
function waitForClose(child, timeout) {
|
|
472
524
|
if (child.exitCode !== null || child.signalCode !== null) return Promise.resolve();
|
|
473
525
|
return new Promise((resolve) => {
|
|
474
|
-
|
|
475
|
-
child.off("close", onClose);
|
|
476
|
-
resolve();
|
|
477
|
-
}, timeout);
|
|
526
|
+
let timer;
|
|
478
527
|
const onClose = () => {
|
|
479
528
|
clearTimeout(timer);
|
|
480
529
|
resolve();
|
|
481
530
|
};
|
|
531
|
+
timer = setTimeout(() => {
|
|
532
|
+
child.off("close", onClose);
|
|
533
|
+
resolve();
|
|
534
|
+
}, timeout);
|
|
482
535
|
child.once("close", onClose);
|
|
483
536
|
});
|
|
484
537
|
}
|
|
485
538
|
|
|
486
|
-
async function stopChildren(
|
|
487
|
-
const running = children
|
|
539
|
+
async function stopChildren() {
|
|
540
|
+
const running = [...children];
|
|
541
|
+
for (const child of running) {
|
|
542
|
+
child.intentionallyStopped = true;
|
|
543
|
+
}
|
|
488
544
|
if (process.platform === "win32") {
|
|
489
545
|
for (const child of running) {
|
|
490
546
|
if (!child.pid || child.exitCode !== null || child.signalCode !== null) continue;
|
|
@@ -519,6 +575,9 @@ async function stopChildren(name) {
|
|
|
519
575
|
async function stop() {
|
|
520
576
|
if (stopping) return;
|
|
521
577
|
stopping = true;
|
|
578
|
+
if (process.exitCode === undefined) {
|
|
579
|
+
process.exitCode = 0;
|
|
580
|
+
}
|
|
522
581
|
if (process.stdin.isTTY) process.stdin.setRawMode(false);
|
|
523
582
|
process.stdin.pause();
|
|
524
583
|
await stopChildren();
|
|
@@ -527,11 +586,14 @@ async function stop() {
|
|
|
527
586
|
async function restart() {
|
|
528
587
|
if (restarting || stopping) return;
|
|
529
588
|
restarting = true;
|
|
530
|
-
|
|
531
|
-
|
|
532
|
-
|
|
533
|
-
|
|
534
|
-
|
|
589
|
+
try {
|
|
590
|
+
displayRunnerLog("Restarting application processes...");
|
|
591
|
+
await stopChildren();
|
|
592
|
+
if (stopping) return;
|
|
593
|
+
for (const app of apps) start(app);
|
|
594
|
+
} finally {
|
|
595
|
+
restarting = false;
|
|
596
|
+
}
|
|
535
597
|
}
|
|
536
598
|
|
|
537
599
|
async function toggleHost() {
|
|
@@ -547,25 +609,27 @@ async function toggleHost() {
|
|
|
547
609
|
return;
|
|
548
610
|
}
|
|
549
611
|
restarting = true;
|
|
550
|
-
let serverPort;
|
|
551
612
|
try {
|
|
552
|
-
serverPort
|
|
553
|
-
|
|
613
|
+
let serverPort;
|
|
614
|
+
try {
|
|
615
|
+
serverPort = await updateNetworkEnvironment(nextHostEnabled, address);
|
|
616
|
+
} catch (error) {
|
|
617
|
+
log("dev", `Unable to update network environment: ${error.message}`, console.error);
|
|
618
|
+
return;
|
|
619
|
+
}
|
|
620
|
+
hostEnabled = nextHostEnabled;
|
|
621
|
+
await stopChildren();
|
|
622
|
+
if (stopping) return;
|
|
623
|
+
for (const app of apps) start(app);
|
|
624
|
+
log(
|
|
625
|
+
"dev",
|
|
626
|
+
hostEnabled
|
|
627
|
+
? `Frontend is available at http://${address}:5173; backend API is http://${address}:${serverPort}.`
|
|
628
|
+
: "Frontend and backend are using localhost.",
|
|
629
|
+
);
|
|
630
|
+
} finally {
|
|
554
631
|
restarting = false;
|
|
555
|
-
log("dev", `Unable to update network environment: ${error.message}`, console.error);
|
|
556
|
-
return;
|
|
557
632
|
}
|
|
558
|
-
hostEnabled = nextHostEnabled;
|
|
559
|
-
await stopChildren();
|
|
560
|
-
if (stopping) return;
|
|
561
|
-
for (const app of apps) start(app);
|
|
562
|
-
restarting = false;
|
|
563
|
-
log(
|
|
564
|
-
"dev",
|
|
565
|
-
hostEnabled
|
|
566
|
-
? `Frontend is available at http://${address}:5173; backend API is http://${address}:${serverPort}.`
|
|
567
|
-
: "Frontend and backend are using localhost.",
|
|
568
|
-
);
|
|
569
633
|
}
|
|
570
634
|
|
|
571
635
|
let environmentSetupFailed = false;
|
|
@@ -581,12 +645,14 @@ if (hostEnabled && !startupAddress) {
|
|
|
581
645
|
log("dev", "Unable to find a network IPv4 address; API URL remains on localhost.", console.error);
|
|
582
646
|
hostEnabled = false;
|
|
583
647
|
}
|
|
584
|
-
|
|
585
|
-
|
|
586
|
-
|
|
587
|
-
|
|
588
|
-
|
|
589
|
-
|
|
648
|
+
if (hostEnabled) {
|
|
649
|
+
try {
|
|
650
|
+
await updateNetworkEnvironment(true, startupAddress);
|
|
651
|
+
} catch (error) {
|
|
652
|
+
log("dev", `Unable to update network environment: ${error.message}`, console.error);
|
|
653
|
+
environmentSetupFailed = true;
|
|
654
|
+
process.exitCode = 1;
|
|
655
|
+
}
|
|
590
656
|
}
|
|
591
657
|
|
|
592
658
|
if (environmentSetupFailed) process.exit(1);
|
|
@@ -599,8 +665,8 @@ const signalExitCodes = { SIGINT: 130, SIGTERM: 143, SIGHUP: 129 };
|
|
|
599
665
|
for (const signal of ["SIGINT", "SIGTERM", "SIGHUP"]) {
|
|
600
666
|
process.on(signal, () => {
|
|
601
667
|
signalCount += 1;
|
|
668
|
+
process.exitCode = signalExitCodes[signal];
|
|
602
669
|
if (signalCount === 1) {
|
|
603
|
-
process.exitCode = signalExitCodes[signal];
|
|
604
670
|
void stop();
|
|
605
671
|
} else {
|
|
606
672
|
forceKillChildren();
|
|
@@ -613,12 +679,15 @@ if (process.stdin.isTTY) {
|
|
|
613
679
|
process.stdin.setRawMode(true);
|
|
614
680
|
process.stdin.resume();
|
|
615
681
|
process.stdin.on("data", (key) => {
|
|
616
|
-
if (key.includes("\u0003"))
|
|
617
|
-
|
|
682
|
+
if (key.includes("\u0003")) {
|
|
683
|
+
process.exitCode = 130;
|
|
684
|
+
void stop();
|
|
685
|
+
} else if (key.toString().toLowerCase() === "r") void restart();
|
|
618
686
|
else if (key.toString().toLowerCase() === "h") void toggleHost();
|
|
619
687
|
else if (key.toString().toLowerCase() === "g") cycleLogLayout();
|
|
620
688
|
else if (key.toString().toLowerCase() === "c") {
|
|
621
689
|
writeFileSync(logFile, "");
|
|
690
|
+
currentLogBytes = 0;
|
|
622
691
|
renderLogLayout();
|
|
623
692
|
}
|
|
624
693
|
});
|
package/scripts/install-info.mjs
CHANGED
|
@@ -37,26 +37,59 @@ try {
|
|
|
37
37
|
}
|
|
38
38
|
const freshInstall = installState === undefined && process.env.npm_command === "install";
|
|
39
39
|
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
40
|
+
const installMode = project.vanillaVite?.installMode ?? "adD";
|
|
41
|
+
|
|
42
|
+
if (installMode === "both") {
|
|
43
|
+
if (
|
|
44
|
+
process.env.VANILLA_VITE_ALLOW_INSTALL !== "1" &&
|
|
45
|
+
process.env.CI === undefined &&
|
|
46
|
+
process.env.npm_command !== "ci" &&
|
|
47
|
+
installState !== undefined
|
|
48
|
+
) {
|
|
49
|
+
const isPnpm = process.env.npm_config_user_agent?.startsWith("pnpm/");
|
|
50
|
+
console.log(
|
|
51
|
+
isPnpm
|
|
52
|
+
? "Tip: `pnpm adD <package>` lets you pick the workspace."
|
|
53
|
+
: "Tip: `npm run adD -- <package>` lets you pick the workspace.",
|
|
54
|
+
);
|
|
55
|
+
}
|
|
56
|
+
} else if (installMode === "adD") {
|
|
57
|
+
if (
|
|
58
|
+
process.env.VANILLA_VITE_ALLOW_INSTALL !== "1" &&
|
|
59
|
+
process.env.CI === undefined &&
|
|
60
|
+
process.env.npm_command !== "ci" &&
|
|
61
|
+
!freshInstall &&
|
|
62
|
+
(installState === "installing" || installState === "installed" || hasInstalledDependencies)
|
|
63
|
+
) {
|
|
64
|
+
const isPnpm = process.env.npm_config_user_agent?.startsWith("pnpm/");
|
|
65
|
+
const syncCmd = isPnpm ? "pnpm adD" : "npm run adD";
|
|
66
|
+
const allowCmd = isPnpm
|
|
67
|
+
? "VANILLA_VITE_ALLOW_INSTALL=1 pnpm install"
|
|
68
|
+
: "VANILLA_VITE_ALLOW_INSTALL=1 npm install";
|
|
69
|
+
const rerunCmd = isPnpm
|
|
70
|
+
? "rm -f .install-state && pnpm install"
|
|
71
|
+
: "rm -f .install-state && npm install";
|
|
72
|
+
console.error(
|
|
73
|
+
"\nDirect installs are disabled to keep dependencies in the intended workspace.\n" +
|
|
74
|
+
"Use `pnpm adD <package>` or `pnpm add-dependency <package>`; with npm, use `npm run adD -- <package>` or `npm run add-dependency -- <package>`.\n" +
|
|
75
|
+
"The adD commands are the supported way to add packages.\n\n" +
|
|
76
|
+
"Recovery instructions:\n" +
|
|
77
|
+
` - To install dependencies across all workspaces, run \`${syncCmd}\` with no arguments to sync dependencies\n` +
|
|
78
|
+
` (or ${allowCmd}).\n` +
|
|
79
|
+
" - If an installation was interrupted, remove .install-state and rerun:\n" +
|
|
80
|
+
` ${rerunCmd}\n`,
|
|
81
|
+
);
|
|
82
|
+
process.exit(1);
|
|
83
|
+
}
|
|
53
84
|
}
|
|
54
85
|
|
|
55
86
|
if (
|
|
56
87
|
process.env.VANILLA_VITE_ALLOW_INSTALL === "1" ||
|
|
57
88
|
process.env.CI !== undefined ||
|
|
58
89
|
process.env.npm_command === "ci" ||
|
|
59
|
-
freshInstall
|
|
90
|
+
freshInstall ||
|
|
91
|
+
installMode === "plain" ||
|
|
92
|
+
installMode === "both"
|
|
60
93
|
) {
|
|
61
94
|
await writeFile(installStatePath, "installing\n");
|
|
62
95
|
}
|
package/scripts/run-app.mjs
CHANGED
|
@@ -11,7 +11,7 @@ const { workspaces } = JSON.parse(
|
|
|
11
11
|
const workspace = workspaces.find((name) => name.endsWith(`-${app}`));
|
|
12
12
|
|
|
13
13
|
if (!workspace || !["client", "server"].includes(app)) {
|
|
14
|
-
console.error("Usage:
|
|
14
|
+
console.error("Usage: pnpm client|server [dev|-dev] | npm run client|server [dev|-dev]");
|
|
15
15
|
process.exit(1);
|
|
16
16
|
}
|
|
17
17
|
|
|
@@ -26,7 +26,11 @@ if (args.length === 0 || (args.length === 1 && ["dev", "-dev"].includes(args[0])
|
|
|
26
26
|
? ["--filter", workspace, "run", script]
|
|
27
27
|
: ["run", script, "--workspace", workspace];
|
|
28
28
|
} else {
|
|
29
|
-
console.error(
|
|
29
|
+
console.error(
|
|
30
|
+
packageManager === "pnpm"
|
|
31
|
+
? `Usage: pnpm ${app} [dev|-dev]`
|
|
32
|
+
: `Usage: npm run ${app} [dev|-dev]`,
|
|
33
|
+
);
|
|
30
34
|
process.exit(1);
|
|
31
35
|
}
|
|
32
36
|
|
|
@@ -36,5 +40,13 @@ child.once("error", (error) => {
|
|
|
36
40
|
process.exitCode = 1;
|
|
37
41
|
});
|
|
38
42
|
child.once("exit", (code, signal) => {
|
|
39
|
-
process.exitCode =
|
|
43
|
+
process.exitCode =
|
|
44
|
+
code ??
|
|
45
|
+
(signal === "SIGINT"
|
|
46
|
+
? 130
|
|
47
|
+
: signal === "SIGTERM"
|
|
48
|
+
? 143
|
|
49
|
+
: signal
|
|
50
|
+
? 1
|
|
51
|
+
: 0);
|
|
40
52
|
});
|