@voltx/cli 0.3.3 → 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 (58) hide show
  1. package/README.md +68 -14
  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-4T26KROZ.mjs +456 -0
  8. package/dist/chunk-5DVBIJXU.mjs +84 -0
  9. package/dist/chunk-5RN2FYST.mjs +494 -0
  10. package/dist/chunk-65PVXS4D.mjs +894 -0
  11. package/dist/chunk-7JVIEGSA.mjs +141 -0
  12. package/dist/chunk-A4NA4AJN.mjs +786 -0
  13. package/dist/chunk-AAAHANST.mjs +839 -0
  14. package/dist/chunk-AD3WMFZF.mjs +205 -0
  15. package/dist/chunk-CFWXMM7Q.mjs +450 -0
  16. package/dist/chunk-CSSHLVYS.mjs +83 -0
  17. package/dist/chunk-CWOSNV5O.mjs +150 -0
  18. package/dist/chunk-EI6XBYKB.mjs +84 -0
  19. package/dist/chunk-EXMRIKIX.mjs +404 -0
  20. package/dist/chunk-FI2W4L4S.mjs +205 -0
  21. package/dist/chunk-FN7KZJ6H.mjs +363 -0
  22. package/dist/chunk-G2INQCCJ.mjs +907 -0
  23. package/dist/chunk-H2DTIOEO.mjs +150 -0
  24. package/dist/chunk-IS2WTE3C.mjs +138 -0
  25. package/dist/chunk-JECCDBYI.mjs +730 -0
  26. package/dist/chunk-KX2MRJUO.mjs +795 -0
  27. package/dist/chunk-LTGMHAZS.mjs +147 -0
  28. package/dist/chunk-OPO6RUFP.mjs +698 -0
  29. package/dist/chunk-P5FSO2UH.mjs +497 -0
  30. package/dist/chunk-PWQSKYAM.mjs +682 -0
  31. package/dist/chunk-Q5XCFN7L.mjs +1026 -0
  32. package/dist/chunk-QSU6FZC7.mjs +497 -0
  33. package/dist/chunk-RYWRFHEC.mjs +83 -0
  34. package/dist/chunk-SU4Q3PTH.mjs +201 -0
  35. package/dist/chunk-UO43CY7Y.mjs +497 -0
  36. package/dist/chunk-UXI3QSDN.mjs +121 -0
  37. package/dist/chunk-VD3CNPNP.mjs +123 -0
  38. package/dist/chunk-X6VOAPRJ.mjs +756 -0
  39. package/dist/cli.js +1023 -306
  40. package/dist/cli.mjs +7 -6
  41. package/dist/create.d.mts +1 -0
  42. package/dist/create.d.ts +1 -0
  43. package/dist/create.js +813 -189
  44. package/dist/create.mjs +1 -2
  45. package/dist/dev.d.mts +6 -4
  46. package/dist/dev.d.ts +6 -4
  47. package/dist/dev.js +119 -46
  48. package/dist/dev.mjs +1 -2
  49. package/dist/generate.js +13 -13
  50. package/dist/generate.mjs +1 -2
  51. package/dist/index.d.mts +1 -1
  52. package/dist/index.d.ts +1 -1
  53. package/dist/index.js +1010 -294
  54. package/dist/index.mjs +6 -7
  55. package/dist/start.js +7 -17
  56. package/dist/start.mjs +1 -2
  57. package/dist/welcome.mjs +0 -1
  58. package/package.json +11 -3
package/README.md CHANGED
@@ -11,39 +11,91 @@
11
11
 
12
12
  ---
13
13
 
14
- Command-line tools for the [VoltX](https://github.com/codewithshail/voltx) framework. Scaffold new projects, run the dev server, and build for production.
14
+ Command-line tools for the [VoltX](https://github.com/codewithshail/voltx) framework. Full-stack dev server (Vite + Hono), production build with SSR, code generation, and project scaffolding.
15
15
 
16
16
  ## Installation
17
17
 
18
18
  ```bash
19
- npm install -g @voltx/cli
19
+ npm install @voltx/cli
20
20
  ```
21
21
 
22
- Or use directly with npx:
22
+ ## Commands
23
+
24
+ ### Development
23
25
 
24
26
  ```bash
25
- npx @voltx/cli create my-app
27
+ voltx dev # Start Vite dev server with HMR + backend
28
+ voltx build # Build for production (client + SSR + server)
29
+ voltx start # Start production server
26
30
  ```
27
31
 
28
- ## Commands
32
+ `voltx dev` starts a single process that serves both the React frontend and Hono API backend with hot module replacement. No separate frontend/backend servers needed.
29
33
 
30
34
  ### Create a New Project
31
35
 
32
36
  ```bash
33
37
  voltx create my-app
34
38
  voltx create my-app --template chatbot
35
- voltx create my-app --template rag-app
36
- voltx create my-app --template agent-app
39
+ voltx create my-app --template agent-app --shadcn
40
+ voltx create my-app --template rag-app --auth jwt
41
+ ```
42
+
43
+ > For the full interactive experience with tool selection, RAG toggle, shadcn/ui, and API key management, use `npx create-voltx-app` instead.
44
+
45
+ ### Code Generation
46
+
47
+ ```bash
48
+ voltx generate route api/users # New API route
49
+ voltx generate agent assistant # New agent definition
50
+ voltx generate tool search # New tool for agents
51
+ ```
52
+
53
+ ## Build Pipeline
54
+
55
+ `voltx build` runs a 3-phase build when SSR is detected:
56
+
57
+ 1. **Client build** — Vite builds `src/entry-client.tsx` → `dist/client/`
58
+ 2. **SSR build** — Vite builds `src/entry-server.tsx` → `dist/server/`
59
+ 3. **Server build** — tsup bundles `server.ts` → `dist/index.js`
60
+
61
+ Falls back to a 2-phase build (client + server) if no `src/entry-server.tsx` exists.
62
+
63
+ ## Project Structure
64
+
65
+ All templates generate a full-stack project:
66
+
67
+ ```
68
+ my-app/
69
+ ├── api/ # Backend API routes (file-based routing)
70
+ │ ├── index.ts # GET /api — health check
71
+ │ ├── chat.ts # POST /api/chat (chatbot/agent-app)
72
+ │ └── agent.ts # POST /api/agent (agent-app)
73
+ ├── src/ # Frontend (React + Vite)
74
+ │ ├── app.tsx # Root component
75
+ │ ├── layout.tsx # Layout wrapper
76
+ │ ├── globals.css # Tailwind CSS v4
77
+ │ ├── entry-client.tsx # Client hydration
78
+ │ ├── entry-server.tsx # SSR rendering
79
+ │ ├── components/ # React components
80
+ │ ├── hooks/ # Custom hooks
81
+ │ └── lib/ # Utilities (cn() if shadcn enabled)
82
+ ├── agents/ # AI agents (agent-app)
83
+ ├── tools/ # Agent tools (agent-app)
84
+ ├── public/ # Static assets (favicon, robots.txt, manifest)
85
+ ├── server.ts # Hono app entry
86
+ ├── vite.config.ts # Vite + Tailwind + dev server
87
+ ├── components.json # shadcn/ui config (if enabled)
88
+ ├── voltx.config.ts # VoltX config
89
+ └── tsconfig.json # TypeScript (with @/* path alias)
37
90
  ```
38
91
 
39
- ### Available Templates
92
+ ## What's Included
40
93
 
41
- | Template | Description |
42
- |----------|-------------|
43
- | `blank` | Minimal server with file-based routing |
44
- | `chatbot` | Streaming chat with AI + conversation memory |
45
- | `rag-app` | Document Q&A with embeddings + vector search |
46
- | `agent-app` | Autonomous agent with tools + memory |
94
+ - **Tailwind CSS v4** — native Vite plugin, no PostCSS config needed
95
+ - **Path aliases** — `@/*` maps to `src/*` in both TypeScript and Vite
96
+ - **shadcn/ui** (optional) `--shadcn` flag pre-configures `components.json`, `cn()` utility, and CSS variables
97
+ - **React SSR** streaming server-side rendering via `@voltx/server`
98
+ - **Auto .env loading** `@voltx/core` loads `.env` files automatically
47
99
 
48
100
  ## Programmatic Usage
49
101
 
@@ -53,6 +105,8 @@ import { createProject } from "@voltx/cli";
53
105
  await createProject({
54
106
  name: "my-app",
55
107
  template: "chatbot",
108
+ auth: "jwt",
109
+ shadcn: true,
56
110
  });
57
111
  ```
58
112
 
package/dist/build.d.mts CHANGED
@@ -1,5 +1,5 @@
1
1
  interface BuildOptions {
2
- /** Entry file (default: src/index.ts) */
2
+ /** Entry file (default: server.ts or src/index.ts) */
3
3
  entry?: string;
4
4
  /** Output directory (default: dist) */
5
5
  outDir?: string;
@@ -11,8 +11,9 @@ interface BuildOptions {
11
11
  /**
12
12
  * Build the VoltX app for production.
13
13
  *
14
- * Uses tsup to bundle the server-side TypeScript into a single optimized JS file.
15
- * If a frontend directory exists (src/frontend), also builds it with Vite.
14
+ * Detects whether the project is full-stack (has vite.config.ts or server.ts).
15
+ * - Full-stack: builds client bundle, SSR bundle, and server bundle
16
+ * - API-only: builds server bundle only (existing behavior)
16
17
  */
17
18
  declare function runBuild(options?: BuildOptions): Promise<void>;
18
19
 
package/dist/build.d.ts CHANGED
@@ -1,5 +1,5 @@
1
1
  interface BuildOptions {
2
- /** Entry file (default: src/index.ts) */
2
+ /** Entry file (default: server.ts or src/index.ts) */
3
3
  entry?: string;
4
4
  /** Output directory (default: dist) */
5
5
  outDir?: string;
@@ -11,8 +11,9 @@ interface BuildOptions {
11
11
  /**
12
12
  * Build the VoltX app for production.
13
13
  *
14
- * Uses tsup to bundle the server-side TypeScript into a single optimized JS file.
15
- * If a frontend directory exists (src/frontend), also builds it with Vite.
14
+ * Detects whether the project is full-stack (has vite.config.ts or server.ts).
15
+ * - Full-stack: builds client bundle, SSR bundle, and server bundle
16
+ * - API-only: builds server bundle only (existing behavior)
16
17
  */
17
18
  declare function runBuild(options?: BuildOptions): Promise<void>;
18
19
 
package/dist/build.js CHANGED
@@ -26,6 +26,7 @@ module.exports = __toCommonJS(build_exports);
26
26
  var import_node_child_process = require("child_process");
27
27
  var import_node_path = require("path");
28
28
  var import_node_fs = require("fs");
29
+ var import_core = require("@voltx/core");
29
30
  async function runBuild(options = {}) {
30
31
  const cwd = process.cwd();
31
32
  const {
@@ -35,7 +36,7 @@ async function runBuild(options = {}) {
35
36
  sourcemap = false
36
37
  } = options;
37
38
  if (!entry) {
38
- console.error("[voltx] Could not find entry point. Expected src/index.ts");
39
+ console.error("[voltx] Could not find entry point. Expected server.ts or src/index.ts");
39
40
  process.exit(1);
40
41
  }
41
42
  const entryPath = (0, import_node_path.resolve)(cwd, entry);
@@ -43,59 +44,87 @@ async function runBuild(options = {}) {
43
44
  console.error(`[voltx] Entry file not found: ${entry}`);
44
45
  process.exit(1);
45
46
  }
47
+ (0, import_core.loadEnv)("production", cwd);
48
+ const hasViteConfig = (0, import_node_fs.existsSync)((0, import_node_path.resolve)(cwd, "vite.config.ts"));
49
+ const hasServerEntry = (0, import_node_fs.existsSync)((0, import_node_path.resolve)(cwd, "server.ts"));
50
+ const isFullStack = hasViteConfig || hasServerEntry;
46
51
  console.log("");
47
52
  console.log(" \u26A1 VoltX Build");
48
53
  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");
49
54
  console.log(` Entry: ${entry}`);
50
55
  console.log(` Output: ${outDir}/`);
56
+ console.log(` Mode: ${isFullStack ? "full-stack" : "API-only"}`);
51
57
  console.log(` Minify: ${minify}`);
52
58
  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");
53
59
  console.log("");
54
60
  (0, import_node_fs.mkdirSync)((0, import_node_path.resolve)(cwd, outDir), { recursive: true });
55
- console.log(" [1/2] Building server...");
61
+ if (isFullStack) {
62
+ await buildFullStack(cwd, entry, outDir, minify, sourcemap);
63
+ } else {
64
+ await buildApiOnly(cwd, entry, outDir, minify, sourcemap);
65
+ }
66
+ console.log("");
67
+ console.log(" \u26A1 Build complete!");
68
+ console.log(` Run \`voltx start\` to start the production server.`);
69
+ console.log("");
70
+ }
71
+ async function buildFullStack(cwd, entry, outDir, minify, sourcemap) {
72
+ const ssrEntry = (0, import_node_fs.existsSync)((0, import_node_path.join)(cwd, "src", "entry-server.tsx")) ? "src/entry-server.tsx" : null;
73
+ const totalSteps = ssrEntry ? 3 : 2;
74
+ console.log(` [1/${totalSteps}] Building client...`);
75
+ const viteBin = findBin(cwd, "vite");
76
+ const clientOutDir = (0, import_node_path.join)(outDir, "client");
77
+ await runCommand(
78
+ viteBin ?? "npx",
79
+ viteBin ? ["build", "--outDir", clientOutDir] : ["vite", "build", "--outDir", clientOutDir],
80
+ cwd
81
+ );
82
+ console.log(" \u2713 Client built");
83
+ if (ssrEntry) {
84
+ console.log(` [2/${totalSteps}] Building SSR bundle...`);
85
+ const serverOutDir = (0, import_node_path.join)(outDir, "server");
86
+ await runCommand(
87
+ viteBin ?? "npx",
88
+ viteBin ? ["build", "--ssr", ssrEntry, "--outDir", serverOutDir] : ["vite", "build", "--ssr", ssrEntry, "--outDir", serverOutDir],
89
+ cwd
90
+ );
91
+ console.log(" \u2713 SSR bundle built");
92
+ }
93
+ const serverStep = ssrEntry ? 3 : 2;
94
+ console.log(` [${serverStep}/${totalSteps}] Building server...`);
95
+ await buildServer(cwd, entry, outDir, minify, sourcemap, false);
96
+ console.log(" \u2713 Server built");
97
+ }
98
+ async function buildApiOnly(cwd, entry, outDir, minify, sourcemap) {
99
+ console.log(" [1/1] Building server...");
100
+ await buildServer(cwd, entry, outDir, minify, sourcemap);
101
+ console.log(" \u2713 Server built");
102
+ }
103
+ async function buildServer(cwd, entry, outDir, minify, sourcemap, clean = true) {
104
+ const tsupBin = findBin(cwd, "tsup");
56
105
  const tsupArgs = [
57
106
  entry,
58
107
  "--format",
59
108
  "esm",
60
109
  "--out-dir",
61
110
  outDir,
62
- "--clean",
63
111
  "--target",
64
- "node20"
112
+ "node20",
113
+ "--no-splitting"
65
114
  ];
115
+ if (clean) tsupArgs.push("--clean");
66
116
  if (minify) tsupArgs.push("--minify");
67
117
  if (sourcemap) tsupArgs.push("--sourcemap");
68
- tsupArgs.push("--no-splitting");
69
- const tsupBin = findBin(cwd, "tsup");
70
118
  await runCommand(
71
119
  tsupBin ?? "npx",
72
120
  tsupBin ? tsupArgs : ["tsup", ...tsupArgs],
73
121
  cwd
74
122
  );
75
- console.log(" \u2713 Server built successfully");
76
- const frontendDir = (0, import_node_path.resolve)(cwd, "src", "frontend");
77
- const viteConfig = (0, import_node_path.resolve)(cwd, "vite.config.ts");
78
- const hasFrontend = (0, import_node_fs.existsSync)(frontendDir) || (0, import_node_fs.existsSync)(viteConfig);
79
- if (hasFrontend) {
80
- console.log(" [2/2] Building frontend...");
81
- const viteBin = findBin(cwd, "vite");
82
- const viteArgs = ["build", "--outDir", (0, import_node_path.join)(outDir, "public")];
83
- await runCommand(
84
- viteBin ?? "npx",
85
- viteBin ? viteArgs : ["vite", ...viteArgs],
86
- cwd
87
- );
88
- console.log(" \u2713 Frontend built successfully");
89
- } else {
90
- console.log(" [2/2] No frontend found, skipping...");
91
- }
92
- console.log("");
93
- console.log(" \u26A1 Build complete!");
94
- console.log(` Run \`voltx start\` to start the production server.`);
95
- console.log("");
96
123
  }
97
124
  function findEntryPoint(cwd) {
98
125
  const candidates = [
126
+ "server.ts",
127
+ "server.js",
99
128
  "src/index.ts",
100
129
  "src/index.js",
101
130
  "src/index.mts",
package/dist/build.mjs CHANGED
@@ -1,7 +1,6 @@
1
1
  import {
2
2
  runBuild
3
- } from "./chunk-ZB2F3WTS.mjs";
4
- import "./chunk-Y6FXYEAI.mjs";
3
+ } from "./chunk-H2DTIOEO.mjs";
5
4
  export {
6
5
  runBuild
7
6
  };