@voltx/cli 0.3.4 → 0.3.5

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 (49) hide show
  1. package/README.md +54 -22
  2. package/dist/build.d.mts +4 -3
  3. package/dist/build.d.ts +4 -3
  4. package/dist/build.js +56 -27
  5. package/dist/build.mjs +1 -2
  6. package/dist/chunk-2LHDOMF2.mjs +680 -0
  7. package/dist/chunk-5DVBIJXU.mjs +84 -0
  8. package/dist/chunk-65PVXS4D.mjs +894 -0
  9. package/dist/chunk-7JVIEGSA.mjs +141 -0
  10. package/dist/chunk-A4NA4AJN.mjs +786 -0
  11. package/dist/chunk-AAAHANST.mjs +839 -0
  12. package/dist/chunk-AD3WMFZF.mjs +205 -0
  13. package/dist/chunk-CSSHLVYS.mjs +83 -0
  14. package/dist/chunk-CWOSNV5O.mjs +150 -0
  15. package/dist/chunk-EI6XBYKB.mjs +84 -0
  16. package/dist/chunk-FI2W4L4S.mjs +205 -0
  17. package/dist/chunk-G2INQCCJ.mjs +907 -0
  18. package/dist/chunk-H2DTIOEO.mjs +150 -0
  19. package/dist/chunk-IS2WTE3C.mjs +138 -0
  20. package/dist/chunk-JECCDBYI.mjs +730 -0
  21. package/dist/chunk-KX2MRJUO.mjs +795 -0
  22. package/dist/chunk-LTGMHAZS.mjs +147 -0
  23. package/dist/chunk-OPO6RUFP.mjs +698 -0
  24. package/dist/chunk-PWQSKYAM.mjs +682 -0
  25. package/dist/chunk-Q5XCFN7L.mjs +1026 -0
  26. package/dist/chunk-QSU6FZC7.mjs +497 -0
  27. package/dist/chunk-RYWRFHEC.mjs +83 -0
  28. package/dist/chunk-SU4Q3PTH.mjs +201 -0
  29. package/dist/chunk-UXI3QSDN.mjs +121 -0
  30. package/dist/chunk-VD3CNPNP.mjs +123 -0
  31. package/dist/chunk-X6VOAPRJ.mjs +756 -0
  32. package/dist/cli.js +932 -307
  33. package/dist/cli.mjs +7 -6
  34. package/dist/create.d.mts +1 -0
  35. package/dist/create.d.ts +1 -0
  36. package/dist/create.js +723 -191
  37. package/dist/create.mjs +1 -2
  38. package/dist/dev.d.mts +6 -4
  39. package/dist/dev.d.ts +6 -4
  40. package/dist/dev.js +119 -46
  41. package/dist/dev.mjs +1 -2
  42. package/dist/generate.js +13 -13
  43. package/dist/generate.mjs +1 -2
  44. package/dist/index.js +919 -295
  45. package/dist/index.mjs +5 -6
  46. package/dist/start.js +7 -17
  47. package/dist/start.mjs +1 -2
  48. package/dist/welcome.mjs +0 -1
  49. package/package.json +11 -3
@@ -0,0 +1,84 @@
1
+ // src/start.ts
2
+ import { spawn } from "child_process";
3
+ import { resolve, join } from "path";
4
+ import { existsSync } from "fs";
5
+ import { loadEnv } from "@voltx/core";
6
+ async function runStart(options = {}) {
7
+ const cwd = process.cwd();
8
+ const { port, outDir = "dist" } = options;
9
+ const distDir = resolve(cwd, outDir);
10
+ if (!existsSync(distDir)) {
11
+ console.error(`[voltx] Build output not found at ${outDir}/`);
12
+ console.error("[voltx] Run `voltx build` first to create a production build.");
13
+ process.exit(1);
14
+ }
15
+ const entry = options.entry ?? findDistEntry(distDir);
16
+ if (!entry) {
17
+ console.error(`[voltx] No entry file found in ${outDir}/`);
18
+ console.error("[voltx] Expected index.js, index.mjs, or main.js");
19
+ process.exit(1);
20
+ }
21
+ const entryPath = resolve(distDir, entry);
22
+ if (!existsSync(entryPath)) {
23
+ console.error(`[voltx] Entry file not found: ${outDir}/${entry}`);
24
+ process.exit(1);
25
+ }
26
+ loadEnv("production", cwd);
27
+ const env = {
28
+ ...process.env,
29
+ NODE_ENV: "production"
30
+ };
31
+ if (port) {
32
+ env.PORT = String(port);
33
+ }
34
+ const hasClientBuild = existsSync(resolve(distDir, "client"));
35
+ console.log("");
36
+ console.log(" \u26A1 VoltX Production Server");
37
+ console.log(" \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500");
38
+ console.log(` Entry: ${outDir}/${entry}`);
39
+ if (port) {
40
+ console.log(` Port: ${port}`);
41
+ }
42
+ console.log(` Mode: ${hasClientBuild ? "full-stack" : "API-only"}`);
43
+ console.log(" \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500");
44
+ console.log("");
45
+ const child = spawn("node", [entryPath], {
46
+ cwd,
47
+ env,
48
+ stdio: "inherit"
49
+ });
50
+ const signals = ["SIGINT", "SIGTERM"];
51
+ for (const signal of signals) {
52
+ process.on(signal, () => {
53
+ child.kill(signal);
54
+ });
55
+ }
56
+ child.on("error", (err) => {
57
+ console.error("[voltx] Failed to start production server:", err.message);
58
+ process.exit(1);
59
+ });
60
+ child.on("exit", (code) => {
61
+ process.exit(code ?? 0);
62
+ });
63
+ }
64
+ function findDistEntry(distDir) {
65
+ const candidates = [
66
+ "index.mjs",
67
+ "index.js",
68
+ "index.cjs",
69
+ "main.mjs",
70
+ "main.js",
71
+ "src/index.mjs",
72
+ "src/index.js"
73
+ ];
74
+ for (const candidate of candidates) {
75
+ if (existsSync(join(distDir, candidate))) {
76
+ return candidate;
77
+ }
78
+ }
79
+ return null;
80
+ }
81
+
82
+ export {
83
+ runStart
84
+ };