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