@ezetgalaxy/titan 25.13.4 → 25.13.6

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/index.js +37 -21
  2. package/package.json +1 -1
package/index.js CHANGED
@@ -1,4 +1,4 @@
1
- #!/usr/bin/env node
1
+ #!/usr/bin/env node
2
2
  import fs from "fs";
3
3
  import path from "path";
4
4
  import { execSync, spawn } from "child_process";
@@ -181,52 +181,68 @@ async function devServer() {
181
181
  }
182
182
 
183
183
  /* PRODUCTION BUILD */
184
+ // BUILD RELEASE — PRODUCTION READY
184
185
  function buildProd() {
186
+ console.log(cyan("Titan: Building production output..."));
187
+
185
188
  const root = process.cwd();
186
189
  const appJs = path.join(root, "app", "app.js");
190
+ const bundler = path.join(root, "titan", "bundle.js");
191
+ const serverDir = path.join(root, "server");
192
+ const builtActionsDir = path.join(root, "titan", "actions");
193
+ const actionsOut = path.join(serverDir, "actions"); // FIX: define early
187
194
 
188
- console.log(cyan("Titan: Building production output..."));
189
-
195
+ // Ensure app/app.js exists
190
196
  if (!fs.existsSync(appJs)) {
191
- console.log(red("ERROR: app/app.js missing."));
197
+ console.log(red("ERROR: app/app.js not found."));
192
198
  process.exit(1);
193
199
  }
194
200
 
195
- /* Generate routes */
196
- execSync(`node "${appJs}"`, { stdio: "inherit" });
201
+ // Ensure bundler exists
202
+ if (!fs.existsSync(bundler)) {
203
+ console.log(red("ERROR: titan/bundle.js not found."));
204
+ process.exit(1);
205
+ }
197
206
 
198
- /* Bundle actions */
199
- runBundler(root);
207
+ // 1) Generate routes.json and action_map.json
208
+ console.log(cyan("→ Generating Titan metadata..."));
209
+ execSync("node app/app.js --build", { stdio: "inherit" });
200
210
 
201
- /* Copy bundles server/actions */
202
- const outDir = path.join(root, "server", "actions");
203
- fs.mkdirSync(outDir, { recursive: true });
211
+ // 2) Bundle JS actions
212
+ console.log(cyan(" Bundling Titan actions..."));
213
+ execSync("node titan/bundle.js", { stdio: "inherit" });
204
214
 
205
- const builtActions = path.join(projectRoot, "server", "actions");
215
+ // 3) Ensure server/actions exists
216
+ fs.mkdirSync(actionsOut, { recursive: true }); // FIX: mandatory
206
217
 
207
- if (fs.existsSync(builtActions)) {
208
- for (const file of fs.readdirSync(builtActions)) {
218
+ // 4) Copy bundled actions to server/actions
219
+ if (fs.existsSync(builtActionsDir)) {
220
+ for (const file of fs.readdirSync(builtActionsDir)) {
209
221
  if (file.endsWith(".jsbundle")) {
222
+ console.log(cyan(`→ Copying ${file}`));
210
223
  fs.copyFileSync(
211
- path.join(builtActions, file),
224
+ path.join(builtActionsDir, file),
212
225
  path.join(actionsOut, file)
213
226
  );
214
227
  }
215
228
  }
229
+ } else {
230
+ console.log(yellow("Warning: No actions bundled."));
216
231
  }
217
232
 
218
-
219
233
  console.log(green("✔ Actions copied to server/actions"));
220
234
 
221
- /* Rust release build */
222
- execSync(`cargo build --release`, {
223
- cwd: path.join(root, "server"),
224
- stdio: "inherit",
235
+ // 5) Build Rust binary
236
+ console.log(cyan("→ Building Rust release binary..."));
237
+ execSync("cargo build --release", {
238
+ cwd: serverDir,
239
+ stdio: "inherit"
225
240
  });
226
241
 
227
- console.log(green("✔ Rust binary built successfully."));
242
+ console.log(green("✔ Titan production build complete!"));
228
243
  }
229
244
 
245
+
230
246
  /* START PRODUCTION BINARY */
231
247
  function startProd() {
232
248
  const isWin = process.platform === "win32";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ezetgalaxy/titan",
3
- "version": "25.13.4",
3
+ "version": "25.13.6",
4
4
  "description": "JavaScript backend framework that compiles your JS into a Rust + Axum server.",
5
5
  "license": "ISC",
6
6
  "author": "ezetgalaxy",