@zappdev/cli 0.5.0-alpha.4 → 0.5.0-alpha.6
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 +4 -1
- package/src/init.ts +14 -18
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 });
|
|
@@ -108,13 +102,15 @@ fn main() -> int {
|
|
|
108
102
|
}
|
|
109
103
|
`);
|
|
110
104
|
|
|
111
|
-
// 3. Add zapp.config.ts
|
|
105
|
+
// 3. Add zapp.config.ts — typed via defineConfig for autocomplete
|
|
112
106
|
const identifier = `com.zapp.${name.toLowerCase().replace(/[^a-z0-9]/g, "")}`;
|
|
113
|
-
await Bun.write(path.join(projectDir, "zapp.config.ts"), `
|
|
107
|
+
await Bun.write(path.join(projectDir, "zapp.config.ts"), `import { defineConfig } from "@zappdev/cli/config";
|
|
108
|
+
|
|
109
|
+
export default defineConfig({
|
|
114
110
|
name: "${name}",
|
|
115
111
|
identifier: "${identifier}",
|
|
116
112
|
version: "0.1.0",
|
|
117
|
-
};
|
|
113
|
+
});
|
|
118
114
|
`);
|
|
119
115
|
|
|
120
116
|
// 4. Update package.json — add deps and scripts
|