@zappdev/cli 0.5.0-alpha.7 → 0.5.0-alpha.9

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.
Files changed (2) hide show
  1. package/package.json +1 -1
  2. package/src/init.ts +15 -11
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@zappdev/cli",
3
- "version": "0.5.0-alpha.7",
3
+ "version": "0.5.0-alpha.9",
4
4
  "type": "module",
5
5
  "bin": {
6
6
  "zapp": "./src/zapp-cli.ts"
package/src/init.ts CHANGED
@@ -150,25 +150,28 @@ export default defineConfig({
150
150
  if (configPath) {
151
151
  let viteConfig = await Bun.file(configPath).text();
152
152
 
153
- // Add our import at the top (after existing imports)
154
- const importLine = `import { zappWorkers } from "@zappdev/vite";\n`;
155
- if (!viteConfig.includes("@zappdev/vite")) {
156
- // Insert after the last import statement
153
+ // Add our imports at the top (after existing imports)
154
+ const importLines = [
155
+ `import { zappWorkers } from "@zappdev/vite";`,
156
+ `import zappConfig from "./zapp.config";`,
157
+ ];
158
+ for (const importLine of importLines) {
159
+ const pkg = importLine.match(/from ["'](.+?)["']/)?.[1] ?? "";
160
+ if (viteConfig.includes(pkg)) continue;
157
161
  const lastImportIdx = viteConfig.lastIndexOf("\nimport ");
158
162
  if (lastImportIdx >= 0) {
159
163
  const endOfLine = viteConfig.indexOf("\n", lastImportIdx + 1);
160
- viteConfig = viteConfig.slice(0, endOfLine + 1) + importLine + viteConfig.slice(endOfLine + 1);
164
+ viteConfig = viteConfig.slice(0, endOfLine + 1) + importLine + "\n" + viteConfig.slice(endOfLine + 1);
161
165
  } else {
162
- viteConfig = importLine + viteConfig;
166
+ viteConfig = importLine + "\n" + viteConfig;
163
167
  }
164
168
  }
165
169
 
166
- // Append zappWorkers() to the plugins array
167
- if (!viteConfig.includes("zappWorkers()")) {
168
- // Match plugins: [...] and append inside the array
170
+ // Append zappWorkers() with config to the plugins array
171
+ if (!viteConfig.includes("zappWorkers(")) {
169
172
  viteConfig = viteConfig.replace(
170
173
  /plugins:\s*\[/,
171
- "plugins: [zappWorkers(), "
174
+ "plugins: [zappWorkers({ backend: zappConfig.backend }), "
172
175
  );
173
176
  }
174
177
 
@@ -177,9 +180,10 @@ export default defineConfig({
177
180
  // No vite.config found — create a minimal one
178
181
  await Bun.write(viteConfigPath, `import { defineConfig } from "vite";
179
182
  import { zappWorkers } from "@zappdev/vite";
183
+ import zappConfig from "./zapp.config";
180
184
 
181
185
  export default defineConfig({
182
- plugins: [zappWorkers()],
186
+ plugins: [zappWorkers({ backend: zappConfig.backend })],
183
187
  });
184
188
  `);
185
189
  }