dinou 7.0.0 → 7.1.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,392 +1,392 @@
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" },
201
- ];
202
-
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) => {
222
- const bundlerCmd = bundler === "rollup"
223
- ? `cross-env NODE_ENV=production npx rollup -c ${p("rollup/rollup.config.js")}`
224
- : bundler === "webpack"
225
- ? `cross-env NODE_ENV=production npx webpack --config ${p("webpack/webpack.config.js")}`
226
- : `cross-env NODE_ENV=production node ${p("esbuild/build.mjs")}`;
227
-
228
- const envPrefix = bundler === "webpack" ? "cross-env DINOU_BUILD_TOOL=webpack " : "";
229
- return `${bundlerCmd} && ${envPrefix}node ${p("bun/build.mjs")}`;
230
- };
231
-
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) {
289
- for (const b of ["esbuild", "rollup", "webpack"]) {
290
- const cmdNames = b === "esbuild"
291
- ? [`build:bun:compile${t.name}`, `build:bun:compile${t.name}:esbuild`]
292
- : [`build:bun:compile${t.name}:${b}`];
293
- for (const cmdName of cmdNames) {
294
- program
295
- .command(cmdName)
296
- .description(`Compile standalone Bun executable (${t.name || "host"}, ${b})`)
297
- .action(() => {
298
- runCommand(`${runBunBuild(b)} && bun build --compile ${t.flags}.dinou/bun/server.js --outfile ${t.outfile}`);
299
- });
300
- }
301
- }
302
- }
303
-
304
- // --- BUN (PURE) ---
305
-
306
- const runBunPureBuild = (bundler) => {
307
- if (bundler === "rollup") {
308
- return `cross-env NODE_ENV=production npx rollup -c ${p("rollup/rollup.config.js")} && bun ${p("bun/build.mjs")}`;
309
- }
310
- 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")}`;
312
- }
313
- return `cross-env NODE_ENV=production bun ${p("esbuild/build.mjs")} && bun ${p("bun/build.mjs")}`;
314
- };
315
-
316
- program
317
- .command("build:bun:pure")
318
- .description("Build the app with 100% Bun (using esbuild)")
319
- .action(() => { runCommand(runBunPureBuild("esbuild")); });
320
-
321
- program
322
- .command("build:bun:pure:esbuild")
323
- .description("Build the app with 100% Bun (Esbuild)")
324
- .action(() => { runCommand(runBunPureBuild("esbuild")); });
325
-
326
- program
327
- .command("build:bun:pure:rollup")
328
- .description("Build the app with 100% Bun (Rollup)")
329
- .action(() => { runCommand(runBunPureBuild("rollup")); });
330
-
331
- program
332
- .command("build:bun:pure:webpack")
333
- .description("Build the app with 100% Bun (Webpack)")
334
- .action(() => { runCommand(runBunPureBuild("webpack")); });
335
-
336
- for (const t of bunTargets) {
337
- for (const b of ["esbuild", "rollup", "webpack"]) {
338
- 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}`];
341
- for (const cmdName of cmdNames) {
342
- program
343
- .command(cmdName)
344
- .description(`Compile standalone Bun Pure executable (${t.name || "host"}, ${b})`)
345
- .action(() => {
346
- runCommand(`${runBunPureBuild(b)} && bun build --compile ${t.flags}.dinou/bun/server.js --outfile ${t.outfile}`);
347
- });
348
- }
349
- }
350
- }
351
-
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);
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" },
201
+ ];
202
+
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) => {
222
+ const bundlerCmd = bundler === "rollup"
223
+ ? `cross-env NODE_ENV=production npx rollup -c ${p("rollup/rollup.config.js")}`
224
+ : bundler === "webpack"
225
+ ? `cross-env NODE_ENV=production npx webpack --config ${p("webpack/webpack.config.js")}`
226
+ : `cross-env NODE_ENV=production node ${p("esbuild/build.mjs")}`;
227
+
228
+ const envPrefix = bundler === "webpack" ? "cross-env DINOU_BUILD_TOOL=webpack " : "";
229
+ return `${bundlerCmd} && ${envPrefix}node ${p("bun/build.mjs")}`;
230
+ };
231
+
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) {
289
+ for (const b of ["esbuild", "rollup", "webpack"]) {
290
+ const cmdNames = b === "esbuild"
291
+ ? [`build:bun:compile${t.name}`, `build:bun:compile${t.name}:esbuild`]
292
+ : [`build:bun:compile${t.name}:${b}`];
293
+ for (const cmdName of cmdNames) {
294
+ program
295
+ .command(cmdName)
296
+ .description(`Compile standalone Bun executable (${t.name || "host"}, ${b})`)
297
+ .action(() => {
298
+ runCommand(`${runBunBuild(b)} && bun build --compile ${t.flags}.dinou/bun/server.js --outfile ${t.outfile}`);
299
+ });
300
+ }
301
+ }
302
+ }
303
+
304
+ // --- BUN (PURE) ---
305
+
306
+ const runBunPureBuild = (bundler) => {
307
+ if (bundler === "rollup") {
308
+ return `cross-env NODE_ENV=production npx rollup -c ${p("rollup/rollup.config.js")} && bun ${p("bun/build.mjs")}`;
309
+ }
310
+ 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")}`;
312
+ }
313
+ return `cross-env NODE_ENV=production bun ${p("esbuild/build.mjs")} && bun ${p("bun/build.mjs")}`;
314
+ };
315
+
316
+ program
317
+ .command("build:bun:pure")
318
+ .description("Build the app with 100% Bun (using esbuild)")
319
+ .action(() => { runCommand(runBunPureBuild("esbuild")); });
320
+
321
+ program
322
+ .command("build:bun:pure:esbuild")
323
+ .description("Build the app with 100% Bun (Esbuild)")
324
+ .action(() => { runCommand(runBunPureBuild("esbuild")); });
325
+
326
+ program
327
+ .command("build:bun:pure:rollup")
328
+ .description("Build the app with 100% Bun (Rollup)")
329
+ .action(() => { runCommand(runBunPureBuild("rollup")); });
330
+
331
+ program
332
+ .command("build:bun:pure:webpack")
333
+ .description("Build the app with 100% Bun (Webpack)")
334
+ .action(() => { runCommand(runBunPureBuild("webpack")); });
335
+
336
+ for (const t of bunTargets) {
337
+ for (const b of ["esbuild", "rollup", "webpack"]) {
338
+ 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}`];
341
+ for (const cmdName of cmdNames) {
342
+ program
343
+ .command(cmdName)
344
+ .description(`Compile standalone Bun Pure executable (${t.name || "host"}, ${b})`)
345
+ .action(() => {
346
+ runCommand(`${runBunPureBuild(b)} && bun build --compile ${t.flags}.dinou/bun/server.js --outfile ${t.outfile}`);
347
+ });
348
+ }
349
+ }
350
+ }
351
+
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);