@zappdev/cli 0.5.0-alpha.3 → 0.5.0-alpha.4
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 +13 -5
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 } from "node:fs/promises";
|
|
6
|
+
import { mkdir, rm } from "node:fs/promises";
|
|
7
7
|
import { existsSync } from "node:fs";
|
|
8
8
|
|
|
9
9
|
interface InitOptions {
|
|
@@ -22,8 +22,11 @@ export async function runInit(opts: InitOptions) {
|
|
|
22
22
|
}
|
|
23
23
|
|
|
24
24
|
// 1. Create Vite project
|
|
25
|
+
// Use bunx create-vite (not `bun create vite`) to avoid auto-installing
|
|
26
|
+
// deps and triggering template postinstall scripts that can start a dev
|
|
27
|
+
// server. The user runs `bun install` themselves after init.
|
|
25
28
|
process.stdout.write(`[zapp] creating ${name} with template ${template}...\n`);
|
|
26
|
-
const viteProc = Bun.spawn(["
|
|
29
|
+
const viteProc = Bun.spawn(["bunx", "create-vite", name, "--template", template], {
|
|
27
30
|
cwd: root,
|
|
28
31
|
stdout: "inherit",
|
|
29
32
|
stderr: "inherit",
|
|
@@ -33,6 +36,11 @@ export async function runInit(opts: InitOptions) {
|
|
|
33
36
|
process.exit(1);
|
|
34
37
|
}
|
|
35
38
|
|
|
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
|
+
|
|
36
44
|
// 2. Add zapp/ native code
|
|
37
45
|
const zappDir = path.join(projectDir, "zapp");
|
|
38
46
|
await mkdir(zappDir, { recursive: true });
|
|
@@ -123,12 +131,12 @@ fn main() -> int {
|
|
|
123
131
|
|
|
124
132
|
pkgObj.dependencies = {
|
|
125
133
|
...(pkgObj.dependencies ?? {}),
|
|
126
|
-
"@zappdev/runtime": "^0.5.0",
|
|
134
|
+
"@zappdev/runtime": "^0.5.0-alpha.0",
|
|
127
135
|
};
|
|
128
136
|
pkgObj.devDependencies = {
|
|
129
137
|
...(pkgObj.devDependencies ?? {}),
|
|
130
|
-
"@zappdev/cli": "^0.5.0",
|
|
131
|
-
"@zappdev/vite": "^0.5.0",
|
|
138
|
+
"@zappdev/cli": "^0.5.0-alpha.0",
|
|
139
|
+
"@zappdev/vite": "^0.5.0-alpha.0",
|
|
132
140
|
};
|
|
133
141
|
|
|
134
142
|
await Bun.write(pkgPath, JSON.stringify(pkgObj, null, 2));
|