@zappdev/cli 0.5.0-alpha.4 → 0.5.0-alpha.5
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/package.json +1 -1
- package/src/init.ts +9 -15
package/package.json
CHANGED
package/src/init.ts
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
// Does NOT modify the Vite template files — users add Zapp imports themselves.
|
|
4
4
|
|
|
5
5
|
import path from "node:path";
|
|
6
|
-
import { mkdir
|
|
6
|
+
import { mkdir } from "node:fs/promises";
|
|
7
7
|
import { existsSync } from "node:fs";
|
|
8
8
|
|
|
9
9
|
interface InitOptions {
|
|
@@ -21,26 +21,20 @@ export async function runInit(opts: InitOptions) {
|
|
|
21
21
|
process.exit(1);
|
|
22
22
|
}
|
|
23
23
|
|
|
24
|
-
// 1.
|
|
25
|
-
//
|
|
26
|
-
//
|
|
27
|
-
//
|
|
24
|
+
// 1. Scaffold Vite project files (no install, no dev server).
|
|
25
|
+
// create-vite has an --immediate flag that auto-installs + starts the dev
|
|
26
|
+
// server, and an interactive prompt that does the same if confirmed.
|
|
27
|
+
// --no-interactive skips the prompt and defaults to no install.
|
|
28
28
|
process.stdout.write(`[zapp] creating ${name} with template ${template}...\n`);
|
|
29
|
-
const viteProc = Bun.spawn(
|
|
30
|
-
|
|
31
|
-
stdout: "inherit",
|
|
32
|
-
|
|
33
|
-
});
|
|
29
|
+
const viteProc = Bun.spawn(
|
|
30
|
+
["bunx", "create-vite@latest", name, "--template", template, "--no-interactive"],
|
|
31
|
+
{ cwd: root, stdout: "inherit", stderr: "inherit" },
|
|
32
|
+
);
|
|
34
33
|
if ((await viteProc.exited) !== 0) {
|
|
35
34
|
process.stderr.write("[zapp] vite scaffold failed\n");
|
|
36
35
|
process.exit(1);
|
|
37
36
|
}
|
|
38
37
|
|
|
39
|
-
// Remove node_modules if create-vite auto-installed — we modify
|
|
40
|
-
// package.json (add zapp deps/scripts) before the user installs.
|
|
41
|
-
const autoModules = path.join(projectDir, "node_modules");
|
|
42
|
-
try { await rm(autoModules, { recursive: true }); } catch {}
|
|
43
|
-
|
|
44
38
|
// 2. Add zapp/ native code
|
|
45
39
|
const zappDir = path.join(projectDir, "zapp");
|
|
46
40
|
await mkdir(zappDir, { recursive: true });
|