dinou 7.0.0 → 7.2.0

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/cli.js CHANGED
@@ -1,224 +1,137 @@
1
- #!/usr/bin/env node
2
-
3
- const { program } = require("commander");
4
- const { execSync } = require("child_process");
5
- const path = require("path");
6
-
7
- const dinouPath = path.resolve(__dirname, "dinou");
8
- const projectRoot = process.cwd();
9
-
10
- const runCommand = (command, options = {}) => {
11
- try {
12
- execSync(command, { stdio: "inherit", cwd: projectRoot, ...options });
13
- } catch (error) {
14
- console.error(`Error executing "${command}":`, error.message);
15
- process.exit(1);
16
- }
17
- };
18
-
19
- // Helper paths
20
- const p = (rel) => path.join(dinouPath, rel);
21
-
22
- // --- DEV ---
23
-
24
- program
25
- .command("dev")
26
- .description("Start development server with Esbuild")
27
- .action(() => {
28
- runCommand(`cross-env DINOU_BUILD_TOOL=esbuild node ${p("node/dev.mjs")}`);
29
- });
30
-
31
- program
32
- .command("dev:esbuild")
33
- .description("Start development server with Esbuild")
34
- .action(() => {
35
- runCommand(`cross-env DINOU_BUILD_TOOL=esbuild node ${p("node/dev.mjs")}`);
36
- });
37
-
38
- program
39
- .command("dev:rollup")
40
- .description("Start development server with Rollup")
41
- .action(() => {
42
- runCommand(`cross-env DINOU_BUILD_TOOL=rollup node ${p("node/dev.mjs")}`);
43
- });
44
-
45
- program
46
- .command("dev:webpack")
47
- .description("Start development server with Webpack")
48
- .action(() => {
49
- runCommand(`cross-env DINOU_BUILD_TOOL=webpack node ${p("node/dev.mjs")}`);
50
- });
51
-
52
- // --- NODE (BUILD & START) ---
53
-
54
- program
55
- .command("build")
56
- .description("Build the app for Node.js production (using esbuild)")
57
- .action(() => {
58
- runCommand(`cross-env NODE_ENV=production node ${p("esbuild/build.mjs")} && node ${p("node/build.mjs")}`);
59
- });
60
-
61
- program
62
- .command("build:node")
63
- .description("Build the app for Node.js production (using esbuild)")
64
- .action(() => {
65
- runCommand(`cross-env NODE_ENV=production node ${p("esbuild/build.mjs")} && node ${p("node/build.mjs")}`);
66
- });
67
-
68
- program
69
- .command("build:node:esbuild")
70
- .description("Build the app for Node.js with Esbuild")
71
- .action(() => {
72
- runCommand(`cross-env NODE_ENV=production node ${p("esbuild/build.mjs")} && node ${p("node/build.mjs")}`);
73
- });
74
-
75
- program
76
- .command("build:node:rollup")
77
- .description("Build the app for Node.js with Rollup")
78
- .action(() => {
79
- runCommand(`cross-env NODE_ENV=production npx rollup -c ${p("rollup/rollup.config.js")} && node ${p("node/build.mjs")}`);
80
- });
81
-
82
- program
83
- .command("build:node:webpack")
84
- .description("Build the app for Node.js with Webpack")
85
- .action(() => {
86
- runCommand(`cross-env NODE_ENV=production npx webpack --config ${p("webpack/webpack.config.js")} && cross-env DINOU_BUILD_TOOL=webpack node ${p("node/build.mjs")}`);
87
- });
88
-
89
- program
90
- .command("start")
91
- .description("Start the app in production mode (Node.js)")
92
- .action(() => {
93
- runCommand(`cross-env NODE_ENV=production node ${p("adapters/node.mjs")}`);
94
- });
95
-
96
- program
97
- .command("start:node")
98
- .description("Start the app in production mode (Node.js)")
99
- .action(() => {
100
- runCommand(`cross-env NODE_ENV=production node ${p("adapters/node.mjs")}`);
101
- });
102
-
103
- program
104
- .command("start:node:esbuild")
105
- .description("Start the app in production mode (Esbuild build)")
106
- .action(() => {
107
- runCommand(`cross-env NODE_ENV=production node ${p("adapters/node.mjs")}`);
108
- });
109
-
110
- program
111
- .command("start:node:rollup")
112
- .description("Start the app in production mode (Rollup build)")
113
- .action(() => {
114
- runCommand(`cross-env NODE_ENV=production node ${p("adapters/node.mjs")}`);
115
- });
116
-
117
- program
118
- .command("start:node:webpack")
119
- .description("Start the app in production mode (Webpack build)")
120
- .action(() => {
121
- runCommand(`cross-env NODE_ENV=production DINOU_BUILD_TOOL=webpack node ${p("adapters/node.mjs")}`);
122
- });
123
-
124
- // --- CLOUDFLARE WORKERS ---
125
-
126
- program
127
- .command("build:cloudflare")
128
- .description("Build the app for Cloudflare Workers (using esbuild)")
129
- .action(() => {
130
- runCommand(`cross-env NODE_ENV=production node ${p("esbuild/build.mjs")} && node ${p("cloudflare/build.mjs")}`);
131
- });
132
-
133
- program
134
- .command("build:cloudflare:esbuild")
135
- .description("Build the app for Cloudflare Workers with Esbuild")
136
- .action(() => {
137
- runCommand(`cross-env NODE_ENV=production node ${p("esbuild/build.mjs")} && node ${p("cloudflare/build.mjs")}`);
138
- });
139
-
140
- program
141
- .command("build:cloudflare:rollup")
142
- .description("Build the app for Cloudflare Workers with Rollup")
143
- .action(() => {
144
- runCommand(`cross-env NODE_ENV=production npx rollup -c ${p("rollup/rollup.config.js")} && node ${p("cloudflare/build.mjs")}`);
145
- });
146
-
147
- program
148
- .command("build:cloudflare:webpack")
149
- .description("Build the app for Cloudflare Workers with Webpack")
150
- .action(() => {
151
- runCommand(`cross-env NODE_ENV=production npx webpack --config ${p("webpack/webpack.config.js")} && cross-env DINOU_BUILD_TOOL=webpack node ${p("cloudflare/build.mjs")}`);
152
- });
153
-
154
- // --- DENO DEPLOY / EDGE ---
155
-
156
- const runDenoBuild = (bundler) => {
157
- const bundlerCmd = bundler === "rollup"
158
- ? `cross-env NODE_ENV=production npx rollup -c ${p("rollup/rollup.config.js")}`
159
- : bundler === "webpack"
160
- ? `cross-env NODE_ENV=production npx webpack --config ${p("webpack/webpack.config.js")}`
161
- : `cross-env NODE_ENV=production node ${p("esbuild/build.mjs")}`;
162
-
163
- const envPrefix = bundler === "webpack" ? "cross-env DINOU_BUILD_TOOL=webpack " : "";
164
- return `${bundlerCmd} && ${envPrefix}node ${p("deno/build.mjs")} && deno run --unstable-kv --allow-net --allow-read --allow-write --allow-env ${p("deno/seed-kv.js")}`;
165
- };
166
-
167
- program
168
- .command("build:deno")
169
- .description("Build the app for Deno Deploy / Edge (using esbuild)")
170
- .action(() => { runCommand(runDenoBuild("esbuild")); });
171
-
172
- program
173
- .command("build:deno:esbuild")
174
- .description("Build the app for Deno Deploy with Esbuild")
175
- .action(() => { runCommand(runDenoBuild("esbuild")); });
176
-
177
- program
178
- .command("build:deno:rollup")
179
- .description("Build the app for Deno Deploy with Rollup")
180
- .action(() => { runCommand(runDenoBuild("rollup")); });
181
-
182
- program
183
- .command("build:deno:webpack")
184
- .description("Build the app for Deno Deploy with Webpack")
185
- .action(() => { runCommand(runDenoBuild("webpack")); });
186
-
187
- program
188
- .command("start:deno")
189
- .description("Start the app in production mode with Deno")
190
- .action(() => {
191
- runCommand(`deno run --unstable-kv --allow-net --allow-read --allow-write --allow-env --allow-sys ${p("adapters/deno.js")}`);
192
- });
193
-
194
- // Deno compile commands
195
- const denoTargets = [
196
- { name: "", flags: "", outfile: "dist/deno-server" },
197
- { name: ":linux", flags: "--target x86_64-unknown-linux-gnu ", outfile: "dist/deno-server-linux" },
198
- { name: ":linux_arm", flags: "--target aarch64-unknown-linux-gnu ", outfile: "dist/deno-server-linux-arm" },
199
- { name: ":mac", flags: "--target aarch64-apple-darwin ", outfile: "dist/deno-server-mac" },
200
- { name: ":win", flags: "--target x86_64-pc-windows-msvc ", outfile: "dist/deno-server-win" },
1
+ #!/usr/bin/env node
2
+
3
+ const { program } = require("commander");
4
+ const { execSync } = require("child_process");
5
+ const path = require("path");
6
+
7
+ const dinouPath = path.resolve(__dirname, "dinou");
8
+ const projectRoot = process.cwd();
9
+
10
+ const runCommand = (command, options = {}) => {
11
+ try {
12
+ execSync(command, { stdio: "inherit", cwd: projectRoot, ...options });
13
+ } catch (error) {
14
+ console.error(`Error executing "${command}":`, error.message);
15
+ process.exit(1);
16
+ }
17
+ };
18
+
19
+ // Helper paths
20
+ const p = (rel) => path.join(dinouPath, rel);
21
+
22
+ // --- DEV ---
23
+
24
+ program
25
+ .command("dev")
26
+ .description("Start development server with Esbuild")
27
+ .action(() => {
28
+ runCommand(`cross-env DINOU_BUILD_TOOL=esbuild node ${p("node/dev.mjs")}`);
29
+ });
30
+
31
+ program
32
+ .command("dev:esbuild")
33
+ .description("Start development server with Esbuild")
34
+ .action(() => {
35
+ runCommand(`cross-env DINOU_BUILD_TOOL=esbuild node ${p("node/dev.mjs")}`);
36
+ });
37
+
38
+ program
39
+ .command("dev:rollup")
40
+ .description("Start development server with Rollup")
41
+ .action(() => {
42
+ runCommand(`cross-env DINOU_BUILD_TOOL=rollup node ${p("node/dev.mjs")}`);
43
+ });
44
+
45
+ program
46
+ .command("dev:webpack")
47
+ .description("Start development server with Webpack")
48
+ .action(() => {
49
+ runCommand(`cross-env DINOU_BUILD_TOOL=webpack node ${p("node/dev.mjs")}`);
50
+ });
51
+
52
+ // --- NODE (BUILD & START) ---
53
+
54
+ program
55
+ .command("build")
56
+ .description("Build the app for Node.js production (using esbuild)")
57
+ .action(() => {
58
+ runCommand(`cross-env NODE_ENV=production node ${p("esbuild/build.mjs")} && node ${p("node/build.mjs")}`);
59
+ });
60
+
61
+ program
62
+ .command("build:node")
63
+ .description("Build the app for Node.js production (using esbuild)")
64
+ .action(() => {
65
+ runCommand(`cross-env NODE_ENV=production node ${p("esbuild/build.mjs")} && node ${p("node/build.mjs")}`);
66
+ });
67
+
68
+ program
69
+ .command("build:node:esbuild")
70
+ .description("Build the app for Node.js with Esbuild")
71
+ .action(() => {
72
+ runCommand(`cross-env NODE_ENV=production node ${p("esbuild/build.mjs")} && node ${p("node/build.mjs")}`);
73
+ });
74
+
75
+ program
76
+ .command("build:node:rollup")
77
+ .description("Build the app for Node.js with Rollup")
78
+ .action(() => {
79
+ runCommand(`cross-env NODE_ENV=production npx rollup -c ${p("rollup/rollup.config.js")} && node ${p("node/build.mjs")}`);
80
+ });
81
+
82
+ program
83
+ .command("build:node:webpack")
84
+ .description("Build the app for Node.js with Webpack")
85
+ .action(() => {
86
+ runCommand(`cross-env NODE_ENV=production npx webpack --config ${p("webpack/webpack.config.js")} && cross-env DINOU_BUILD_TOOL=webpack node ${p("node/build.mjs")}`);
87
+ });
88
+
89
+ program
90
+ .command("start")
91
+ .description("Start the app in production mode (Node.js)")
92
+ .action(() => {
93
+ runCommand(`cross-env NODE_ENV=production node ${p("adapters/node.mjs")}`);
94
+ });
95
+
96
+ program
97
+ .command("start:node")
98
+ .description("Start the app in production mode (Node.js)")
99
+ .action(() => {
100
+ runCommand(`cross-env NODE_ENV=production node ${p("adapters/node.mjs")}`);
101
+ });
102
+
103
+ program
104
+ .command("start:node:esbuild")
105
+ .description("Start the app in production mode (Esbuild build)")
106
+ .action(() => {
107
+ runCommand(`cross-env NODE_ENV=production node ${p("adapters/node.mjs")}`);
108
+ });
109
+
110
+ program
111
+ .command("start:node:rollup")
112
+ .description("Start the app in production mode (Rollup build)")
113
+ .action(() => {
114
+ runCommand(`cross-env NODE_ENV=production node ${p("adapters/node.mjs")}`);
115
+ });
116
+
117
+ program
118
+ .command("start:node:webpack")
119
+ .description("Start the app in production mode (Webpack build)")
120
+ .action(() => {
121
+ runCommand(`cross-env NODE_ENV=production DINOU_BUILD_TOOL=webpack node ${p("adapters/node.mjs")}`);
122
+ });
123
+
124
+ // --- NODE (COMPILE VIA BUN) ---
125
+
126
+ const nodeTargets = [
127
+ { name: "", flags: "", outfile: "dist/server" },
128
+ { name: ":linux", flags: "--target=bun-linux-x64 ", outfile: "dist/server-linux" },
129
+ { name: ":linux_arm", flags: "--target=bun-linux-arm64 ", outfile: "dist/server-linux-arm" },
130
+ { name: ":mac", flags: "--target=bun-darwin-arm64 ", outfile: "dist/server-mac" },
131
+ { name: ":win", flags: "--target=bun-windows-x64 ", outfile: "dist/server-win" },
201
132
  ];
202
133
 
203
- for (const t of denoTargets) {
204
- for (const b of ["esbuild", "rollup", "webpack"]) {
205
- const cmdNames = b === "esbuild"
206
- ? [`build:deno:compile${t.name}`, `build:deno:compile${t.name}:esbuild`]
207
- : [`build:deno:compile${t.name}:${b}`];
208
- for (const cmdName of cmdNames) {
209
- program
210
- .command(cmdName)
211
- .description(`Compile standalone Deno executable (${t.name || "host"}, ${b})`)
212
- .action(() => {
213
- runCommand(`${runDenoBuild(b)} && deno compile ${t.flags}--no-check --no-config --allow-net --allow-read --allow-write --allow-env --allow-sys --output ${t.outfile} .dinou/deno/main.js`);
214
- });
215
- }
216
- }
217
- }
218
-
219
- // --- BUN (STANDARD) ---
220
-
221
- const runBunBuild = (bundler) => {
134
+ const runNodeBuild = (bundler) => {
222
135
  const bundlerCmd = bundler === "rollup"
223
136
  ? `cross-env NODE_ENV=production npx rollup -c ${p("rollup/rollup.config.js")}`
224
137
  : bundler === "webpack"
@@ -226,167 +139,339 @@ const runBunBuild = (bundler) => {
226
139
  : `cross-env NODE_ENV=production node ${p("esbuild/build.mjs")}`;
227
140
 
228
141
  const envPrefix = bundler === "webpack" ? "cross-env DINOU_BUILD_TOOL=webpack " : "";
229
- return `${bundlerCmd} && ${envPrefix}node ${p("bun/build.mjs")}`;
142
+ return `${bundlerCmd} && ${envPrefix}node ${p("node/build.mjs")}`;
230
143
  };
231
144
 
232
- program
233
- .command("build:bun")
234
- .description("Build the app for Bun (using esbuild)")
235
- .action(() => { runCommand(runBunBuild("esbuild")); });
236
-
237
- program
238
- .command("build:bun:esbuild")
239
- .description("Build the app for Bun with Esbuild")
240
- .action(() => { runCommand(runBunBuild("esbuild")); });
241
-
242
- program
243
- .command("build:bun:rollup")
244
- .description("Build the app for Bun with Rollup")
245
- .action(() => { runCommand(runBunBuild("rollup")); });
246
-
247
- program
248
- .command("build:bun:webpack")
249
- .description("Build the app for Bun with Webpack")
250
- .action(() => { runCommand(runBunBuild("webpack")); });
251
-
252
- program
253
- .command("start:bun")
254
- .description("Start the app in production mode with Bun")
255
- .action(() => {
256
- runCommand(`cross-env NODE_ENV=production bun ${p("adapters/bun.js")}`);
257
- });
258
-
259
- program
260
- .command("start:bun:esbuild")
261
- .description("Start the app in production mode with Bun (Esbuild)")
262
- .action(() => {
263
- runCommand(`cross-env NODE_ENV=production bun ${p("adapters/bun.js")}`);
264
- });
265
-
266
- program
267
- .command("start:bun:rollup")
268
- .description("Start the app in production mode with Bun (Rollup)")
269
- .action(() => {
270
- runCommand(`cross-env NODE_ENV=production bun ${p("adapters/bun.js")}`);
271
- });
272
-
273
- program
274
- .command("start:bun:webpack")
275
- .description("Start the app in production mode with Bun (Webpack)")
276
- .action(() => {
277
- runCommand(`cross-env NODE_ENV=production DINOU_BUILD_TOOL=webpack bun ${p("adapters/bun.js")}`);
278
- });
279
-
280
- const bunTargets = [
281
- { name: "", flags: "", outfile: "dist/server" },
282
- { name: ":linux", flags: "--target=bun-linux-x64 ", outfile: "dist/server-linux" },
283
- { name: ":linux_arm", flags: "--target=bun-linux-arm64 ", outfile: "dist/server-linux-arm" },
284
- { name: ":mac", flags: "--target=bun-darwin-arm64 ", outfile: "dist/server-mac" },
285
- { name: ":win", flags: "--target=bun-windows-x64 ", outfile: "dist/server-win" },
286
- ];
287
-
288
- for (const t of bunTargets) {
145
+ for (const t of nodeTargets) {
289
146
  for (const b of ["esbuild", "rollup", "webpack"]) {
290
147
  const cmdNames = b === "esbuild"
291
- ? [`build:bun:compile${t.name}`, `build:bun:compile${t.name}:esbuild`]
292
- : [`build:bun:compile${t.name}:${b}`];
148
+ ? [`build:node:compile${t.name}`, `build:node:compile${t.name}:esbuild`]
149
+ : [`build:node:compile${t.name}:${b}`];
293
150
  for (const cmdName of cmdNames) {
294
151
  program
295
152
  .command(cmdName)
296
- .description(`Compile standalone Bun executable (${t.name || "host"}, ${b})`)
153
+ .description(`Compile standalone Node.js server executable with Bun (${t.name || "host"}, ${b})`)
297
154
  .action(() => {
298
- runCommand(`${runBunBuild(b)} && bun build --compile ${t.flags}.dinou/bun/server.js --outfile ${t.outfile}`);
155
+ runCommand(`${runNodeBuild(b)} && bun build --compile ${t.flags}.dinou/node/server.mjs --outfile ${t.outfile}`);
299
156
  });
300
157
  }
301
158
  }
302
159
  }
303
160
 
304
- // --- BUN (PURE) ---
161
+ // --- NODE (PURE BUN RUNNER COMPILE) ---
305
162
 
306
- const runBunPureBuild = (bundler) => {
163
+ const runNodePureBuild = (bundler) => {
307
164
  if (bundler === "rollup") {
308
- return `cross-env NODE_ENV=production npx rollup -c ${p("rollup/rollup.config.js")} && bun ${p("bun/build.mjs")}`;
165
+ return `cross-env NODE_ENV=production npx rollup -c ${p("rollup/rollup.config.js")} && bun ${p("node/build.mjs")}`;
309
166
  }
310
167
  if (bundler === "webpack") {
311
- return `cross-env NODE_ENV=production npx webpack --config ${p("webpack/webpack.config.js")} && cross-env DINOU_BUILD_TOOL=webpack bun ${p("bun/build.mjs")}`;
168
+ return `cross-env NODE_ENV=production npx webpack --config ${p("webpack/webpack.config.js")} && cross-env DINOU_BUILD_TOOL=webpack bun ${p("node/build.mjs")}`;
312
169
  }
313
- return `cross-env NODE_ENV=production bun ${p("esbuild/build.mjs")} && bun ${p("bun/build.mjs")}`;
170
+ return `cross-env NODE_ENV=production bun ${p("esbuild/build.mjs")} && bun ${p("node/build.mjs")}`;
314
171
  };
315
172
 
316
173
  program
317
- .command("build:bun:pure")
318
- .description("Build the app with 100% Bun (using esbuild)")
319
- .action(() => { runCommand(runBunPureBuild("esbuild")); });
174
+ .command("build:node:pure")
175
+ .description("Build the app for Node.js with 100% Bun (using esbuild)")
176
+ .action(() => { runCommand(runNodePureBuild("esbuild")); });
320
177
 
321
178
  program
322
- .command("build:bun:pure:esbuild")
323
- .description("Build the app with 100% Bun (Esbuild)")
324
- .action(() => { runCommand(runBunPureBuild("esbuild")); });
179
+ .command("build:node:pure:esbuild")
180
+ .description("Build the app for Node.js with 100% Bun (Esbuild)")
181
+ .action(() => { runCommand(runNodePureBuild("esbuild")); });
325
182
 
326
183
  program
327
- .command("build:bun:pure:rollup")
328
- .description("Build the app with 100% Bun (Rollup)")
329
- .action(() => { runCommand(runBunPureBuild("rollup")); });
184
+ .command("build:node:pure:rollup")
185
+ .description("Build the app for Node.js with 100% Bun (Rollup)")
186
+ .action(() => { runCommand(runNodePureBuild("rollup")); });
330
187
 
331
188
  program
332
- .command("build:bun:pure:webpack")
333
- .description("Build the app with 100% Bun (Webpack)")
334
- .action(() => { runCommand(runBunPureBuild("webpack")); });
189
+ .command("build:node:pure:webpack")
190
+ .description("Build the app for Node.js with 100% Bun (Webpack)")
191
+ .action(() => { runCommand(runNodePureBuild("webpack")); });
335
192
 
336
- for (const t of bunTargets) {
193
+ for (const t of nodeTargets) {
337
194
  for (const b of ["esbuild", "rollup", "webpack"]) {
338
195
  const cmdNames = b === "esbuild"
339
- ? [`build:bun:pure:compile${t.name}`, `build:bun:pure:compile${t.name}:esbuild`]
340
- : [`build:bun:pure:compile${t.name}:${b}`];
196
+ ? [`build:node:pure:compile${t.name}`, `build:node:pure:compile${t.name}:esbuild`]
197
+ : [`build:node:pure:compile${t.name}:${b}`];
341
198
  for (const cmdName of cmdNames) {
342
199
  program
343
200
  .command(cmdName)
344
- .description(`Compile standalone Bun Pure executable (${t.name || "host"}, ${b})`)
201
+ .description(`Compile standalone Node.js server executable with 100% Bun (${t.name || "host"}, ${b})`)
345
202
  .action(() => {
346
- runCommand(`${runBunPureBuild(b)} && bun build --compile ${t.flags}.dinou/bun/server.js --outfile ${t.outfile}`);
203
+ runCommand(`${runNodePureBuild(b)} && bun build --compile ${t.flags}.dinou/node/server.mjs --outfile ${t.outfile}`);
347
204
  });
348
205
  }
349
206
  }
350
207
  }
351
208
 
352
- // --- EXPORT STATIC ---
353
-
354
- program
355
- .command("export-static")
356
- .description("Export standalone static website (using esbuild)")
357
- .action(() => {
358
- runCommand(`cross-env NODE_ENV=production node ${p("esbuild/build.mjs")} && node ${p("core/export-static.mjs")}`);
359
- });
360
-
361
- program
362
- .command("export-static:esbuild")
363
- .description("Export standalone static website with Esbuild")
364
- .action(() => {
365
- runCommand(`cross-env NODE_ENV=production node ${p("esbuild/build.mjs")} && node ${p("core/export-static.mjs")}`);
366
- });
367
-
368
- program
369
- .command("export-static:rollup")
370
- .description("Export standalone static website with Rollup")
371
- .action(() => {
372
- runCommand(`cross-env NODE_ENV=production npx rollup -c ${p("rollup/rollup.config.js")} && node ${p("core/export-static.mjs")}`);
373
- });
374
-
375
- program
376
- .command("export-static:webpack")
377
- .description("Export standalone static website with Webpack")
378
- .action(() => {
379
- runCommand(`cross-env NODE_ENV=production npx webpack --config ${p("webpack/webpack.config.js")} && node ${p("core/export-static.mjs")}`);
380
- });
381
-
382
- // --- EJECT ---
383
-
384
- program
385
- .command("eject")
386
- .description("Copy the framework to the root of the project")
387
- .action(() => {
388
- console.log("Executing eject...");
389
- require("./eject");
390
- });
391
-
392
- program.parse(process.argv);
209
+ // --- CLOUDFLARE WORKERS ---
210
+
211
+ program
212
+ .command("build:cloudflare")
213
+ .description("Build the app for Cloudflare Workers (using esbuild)")
214
+ .action(() => {
215
+ runCommand(`cross-env NODE_ENV=production node ${p("esbuild/build.mjs")} && node ${p("cloudflare/build.mjs")}`);
216
+ });
217
+
218
+ program
219
+ .command("build:cloudflare:esbuild")
220
+ .description("Build the app for Cloudflare Workers with Esbuild")
221
+ .action(() => {
222
+ runCommand(`cross-env NODE_ENV=production node ${p("esbuild/build.mjs")} && node ${p("cloudflare/build.mjs")}`);
223
+ });
224
+
225
+ program
226
+ .command("build:cloudflare:rollup")
227
+ .description("Build the app for Cloudflare Workers with Rollup")
228
+ .action(() => {
229
+ runCommand(`cross-env NODE_ENV=production npx rollup -c ${p("rollup/rollup.config.js")} && node ${p("cloudflare/build.mjs")}`);
230
+ });
231
+
232
+ program
233
+ .command("build:cloudflare:webpack")
234
+ .description("Build the app for Cloudflare Workers with Webpack")
235
+ .action(() => {
236
+ runCommand(`cross-env NODE_ENV=production npx webpack --config ${p("webpack/webpack.config.js")} && cross-env DINOU_BUILD_TOOL=webpack node ${p("cloudflare/build.mjs")}`);
237
+ });
238
+
239
+ // --- DENO DEPLOY / EDGE ---
240
+
241
+ const runDenoBuild = (bundler) => {
242
+ const bundlerCmd = bundler === "rollup"
243
+ ? `cross-env NODE_ENV=production npx rollup -c ${p("rollup/rollup.config.js")}`
244
+ : bundler === "webpack"
245
+ ? `cross-env NODE_ENV=production npx webpack --config ${p("webpack/webpack.config.js")}`
246
+ : `cross-env NODE_ENV=production node ${p("esbuild/build.mjs")}`;
247
+
248
+ const envPrefix = bundler === "webpack" ? "cross-env DINOU_BUILD_TOOL=webpack " : "";
249
+ return `${bundlerCmd} && ${envPrefix}node ${p("deno/build.mjs")} && deno run --unstable-kv --allow-net --allow-read --allow-write --allow-env ${p("deno/seed-kv.js")}`;
250
+ };
251
+
252
+ program
253
+ .command("build:deno")
254
+ .description("Build the app for Deno Deploy / Edge (using esbuild)")
255
+ .action(() => { runCommand(runDenoBuild("esbuild")); });
256
+
257
+ program
258
+ .command("build:deno:esbuild")
259
+ .description("Build the app for Deno Deploy with Esbuild")
260
+ .action(() => { runCommand(runDenoBuild("esbuild")); });
261
+
262
+ program
263
+ .command("build:deno:rollup")
264
+ .description("Build the app for Deno Deploy with Rollup")
265
+ .action(() => { runCommand(runDenoBuild("rollup")); });
266
+
267
+ program
268
+ .command("build:deno:webpack")
269
+ .description("Build the app for Deno Deploy with Webpack")
270
+ .action(() => { runCommand(runDenoBuild("webpack")); });
271
+
272
+ program
273
+ .command("start:deno")
274
+ .description("Start the app in production mode with Deno")
275
+ .action(() => {
276
+ runCommand(`deno run --unstable-kv --allow-net --allow-read --allow-write --allow-env --allow-sys ${p("adapters/deno.js")}`);
277
+ });
278
+
279
+ // Deno compile commands
280
+ const denoTargets = [
281
+ { name: "", flags: "", outfile: "dist/deno-server" },
282
+ { name: ":linux", flags: "--target x86_64-unknown-linux-gnu ", outfile: "dist/deno-server-linux" },
283
+ { name: ":linux_arm", flags: "--target aarch64-unknown-linux-gnu ", outfile: "dist/deno-server-linux-arm" },
284
+ { name: ":mac", flags: "--target aarch64-apple-darwin ", outfile: "dist/deno-server-mac" },
285
+ { name: ":win", flags: "--target x86_64-pc-windows-msvc ", outfile: "dist/deno-server-win" },
286
+ ];
287
+
288
+ for (const t of denoTargets) {
289
+ for (const b of ["esbuild", "rollup", "webpack"]) {
290
+ const cmdNames = b === "esbuild"
291
+ ? [`build:deno:compile${t.name}`, `build:deno:compile${t.name}:esbuild`]
292
+ : [`build:deno:compile${t.name}:${b}`];
293
+ for (const cmdName of cmdNames) {
294
+ program
295
+ .command(cmdName)
296
+ .description(`Compile standalone Deno executable (${t.name || "host"}, ${b})`)
297
+ .action(() => {
298
+ runCommand(`${runDenoBuild(b)} && deno compile ${t.flags}--no-check --no-config --allow-net --allow-read --allow-write --allow-env --allow-sys --output ${t.outfile} .dinou/deno/main.js`);
299
+ });
300
+ }
301
+ }
302
+ }
303
+
304
+ // --- BUN (STANDARD) ---
305
+
306
+ const runBunBuild = (bundler) => {
307
+ const bundlerCmd = bundler === "rollup"
308
+ ? `cross-env NODE_ENV=production npx rollup -c ${p("rollup/rollup.config.js")}`
309
+ : bundler === "webpack"
310
+ ? `cross-env NODE_ENV=production npx webpack --config ${p("webpack/webpack.config.js")}`
311
+ : `cross-env NODE_ENV=production node ${p("esbuild/build.mjs")}`;
312
+
313
+ const envPrefix = bundler === "webpack" ? "cross-env DINOU_BUILD_TOOL=webpack " : "";
314
+ return `${bundlerCmd} && ${envPrefix}node ${p("bun/build.mjs")}`;
315
+ };
316
+
317
+ program
318
+ .command("build:bun")
319
+ .description("Build the app for Bun (using esbuild)")
320
+ .action(() => { runCommand(runBunBuild("esbuild")); });
321
+
322
+ program
323
+ .command("build:bun:esbuild")
324
+ .description("Build the app for Bun with Esbuild")
325
+ .action(() => { runCommand(runBunBuild("esbuild")); });
326
+
327
+ program
328
+ .command("build:bun:rollup")
329
+ .description("Build the app for Bun with Rollup")
330
+ .action(() => { runCommand(runBunBuild("rollup")); });
331
+
332
+ program
333
+ .command("build:bun:webpack")
334
+ .description("Build the app for Bun with Webpack")
335
+ .action(() => { runCommand(runBunBuild("webpack")); });
336
+
337
+ program
338
+ .command("start:bun")
339
+ .description("Start the app in production mode with Bun")
340
+ .action(() => {
341
+ runCommand(`cross-env NODE_ENV=production bun ${p("adapters/bun.js")}`);
342
+ });
343
+
344
+ program
345
+ .command("start:bun:esbuild")
346
+ .description("Start the app in production mode with Bun (Esbuild)")
347
+ .action(() => {
348
+ runCommand(`cross-env NODE_ENV=production bun ${p("adapters/bun.js")}`);
349
+ });
350
+
351
+ program
352
+ .command("start:bun:rollup")
353
+ .description("Start the app in production mode with Bun (Rollup)")
354
+ .action(() => {
355
+ runCommand(`cross-env NODE_ENV=production bun ${p("adapters/bun.js")}`);
356
+ });
357
+
358
+ program
359
+ .command("start:bun:webpack")
360
+ .description("Start the app in production mode with Bun (Webpack)")
361
+ .action(() => {
362
+ runCommand(`cross-env NODE_ENV=production DINOU_BUILD_TOOL=webpack bun ${p("adapters/bun.js")}`);
363
+ });
364
+
365
+ const bunTargets = [
366
+ { name: "", flags: "", outfile: "dist/server" },
367
+ { name: ":linux", flags: "--target=bun-linux-x64 ", outfile: "dist/server-linux" },
368
+ { name: ":linux_arm", flags: "--target=bun-linux-arm64 ", outfile: "dist/server-linux-arm" },
369
+ { name: ":mac", flags: "--target=bun-darwin-arm64 ", outfile: "dist/server-mac" },
370
+ { name: ":win", flags: "--target=bun-windows-x64 ", outfile: "dist/server-win" },
371
+ ];
372
+
373
+ for (const t of bunTargets) {
374
+ for (const b of ["esbuild", "rollup", "webpack"]) {
375
+ const cmdNames = b === "esbuild"
376
+ ? [`build:bun:compile${t.name}`, `build:bun:compile${t.name}:esbuild`]
377
+ : [`build:bun:compile${t.name}:${b}`];
378
+ for (const cmdName of cmdNames) {
379
+ program
380
+ .command(cmdName)
381
+ .description(`Compile standalone Bun executable (${t.name || "host"}, ${b})`)
382
+ .action(() => {
383
+ runCommand(`${runBunBuild(b)} && bun build --compile ${t.flags}.dinou/bun/server.js --outfile ${t.outfile}`);
384
+ });
385
+ }
386
+ }
387
+ }
388
+
389
+ // --- BUN (PURE) ---
390
+
391
+ const runBunPureBuild = (bundler) => {
392
+ if (bundler === "rollup") {
393
+ return `cross-env NODE_ENV=production npx rollup -c ${p("rollup/rollup.config.js")} && bun ${p("bun/build.mjs")}`;
394
+ }
395
+ if (bundler === "webpack") {
396
+ return `cross-env NODE_ENV=production npx webpack --config ${p("webpack/webpack.config.js")} && cross-env DINOU_BUILD_TOOL=webpack bun ${p("bun/build.mjs")}`;
397
+ }
398
+ return `cross-env NODE_ENV=production bun ${p("esbuild/build.mjs")} && bun ${p("bun/build.mjs")}`;
399
+ };
400
+
401
+ program
402
+ .command("build:bun:pure")
403
+ .description("Build the app with 100% Bun (using esbuild)")
404
+ .action(() => { runCommand(runBunPureBuild("esbuild")); });
405
+
406
+ program
407
+ .command("build:bun:pure:esbuild")
408
+ .description("Build the app with 100% Bun (Esbuild)")
409
+ .action(() => { runCommand(runBunPureBuild("esbuild")); });
410
+
411
+ program
412
+ .command("build:bun:pure:rollup")
413
+ .description("Build the app with 100% Bun (Rollup)")
414
+ .action(() => { runCommand(runBunPureBuild("rollup")); });
415
+
416
+ program
417
+ .command("build:bun:pure:webpack")
418
+ .description("Build the app with 100% Bun (Webpack)")
419
+ .action(() => { runCommand(runBunPureBuild("webpack")); });
420
+
421
+ for (const t of bunTargets) {
422
+ for (const b of ["esbuild", "rollup", "webpack"]) {
423
+ const cmdNames = b === "esbuild"
424
+ ? [`build:bun:pure:compile${t.name}`, `build:bun:pure:compile${t.name}:esbuild`]
425
+ : [`build:bun:pure:compile${t.name}:${b}`];
426
+ for (const cmdName of cmdNames) {
427
+ program
428
+ .command(cmdName)
429
+ .description(`Compile standalone Bun Pure executable (${t.name || "host"}, ${b})`)
430
+ .action(() => {
431
+ runCommand(`${runBunPureBuild(b)} && bun build --compile ${t.flags}.dinou/bun/server.js --outfile ${t.outfile}`);
432
+ });
433
+ }
434
+ }
435
+ }
436
+
437
+ // --- EXPORT STATIC ---
438
+
439
+ program
440
+ .command("export-static")
441
+ .description("Export standalone static website (using esbuild)")
442
+ .action(() => {
443
+ runCommand(`cross-env NODE_ENV=production node ${p("esbuild/build.mjs")} && node ${p("core/export-static.mjs")}`);
444
+ });
445
+
446
+ program
447
+ .command("export-static:esbuild")
448
+ .description("Export standalone static website with Esbuild")
449
+ .action(() => {
450
+ runCommand(`cross-env NODE_ENV=production node ${p("esbuild/build.mjs")} && node ${p("core/export-static.mjs")}`);
451
+ });
452
+
453
+ program
454
+ .command("export-static:rollup")
455
+ .description("Export standalone static website with Rollup")
456
+ .action(() => {
457
+ runCommand(`cross-env NODE_ENV=production npx rollup -c ${p("rollup/rollup.config.js")} && node ${p("core/export-static.mjs")}`);
458
+ });
459
+
460
+ program
461
+ .command("export-static:webpack")
462
+ .description("Export standalone static website with Webpack")
463
+ .action(() => {
464
+ runCommand(`cross-env NODE_ENV=production npx webpack --config ${p("webpack/webpack.config.js")} && node ${p("core/export-static.mjs")}`);
465
+ });
466
+
467
+ // --- EJECT ---
468
+
469
+ program
470
+ .command("eject")
471
+ .description("Copy the framework to the root of the project")
472
+ .action(() => {
473
+ console.log("Executing eject...");
474
+ require("./eject");
475
+ });
476
+
477
+ program.parse(process.argv);