@ezetgalaxy/titan 25.12.7 → 25.12.8
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/index.js +76 -11
- 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";
|
|
@@ -186,19 +186,84 @@ async function devServer() {
|
|
|
186
186
|
}
|
|
187
187
|
|
|
188
188
|
|
|
189
|
-
// BUILD RELEASE
|
|
189
|
+
// BUILD RELEASE — PRODUCTION READY
|
|
190
190
|
function buildProd() {
|
|
191
|
-
console.log(cyan("Titan:
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
191
|
+
console.log(cyan("Titan: Building production output..."));
|
|
192
|
+
|
|
193
|
+
const projectRoot = process.cwd();
|
|
194
|
+
|
|
195
|
+
const appJs = path.join(projectRoot, "app", "app.js");
|
|
196
|
+
const bundler = path.join(projectRoot, "titan", "bundle.js");
|
|
197
|
+
const serverDir = path.join(projectRoot, "server");
|
|
198
|
+
|
|
199
|
+
// 1) Ensure app/app.js exists
|
|
200
|
+
if (!fs.existsSync(appJs)) {
|
|
201
|
+
console.log(red("ERROR: app/app.js not found. Cannot build Titan project."));
|
|
202
|
+
process.exit(1);
|
|
203
|
+
}
|
|
204
|
+
|
|
205
|
+
// 2) Ensure bundler exists
|
|
206
|
+
if (!fs.existsSync(bundler)) {
|
|
207
|
+
console.log(red("ERROR: titan/bundle.js not found. Cannot bundle actions."));
|
|
208
|
+
process.exit(1);
|
|
209
|
+
}
|
|
210
|
+
|
|
211
|
+
// 3) Generate routes.json + action_map.json
|
|
212
|
+
console.log(cyan("→ Generating Titan metadata (routes + action_map)..."));
|
|
213
|
+
try {
|
|
214
|
+
execSync(`node app/app.js --build`, { stdio: "inherit" });
|
|
215
|
+
} catch (err) {
|
|
216
|
+
console.log(red("Failed to generate metadata via app/app.js"));
|
|
217
|
+
process.exit(1);
|
|
218
|
+
}
|
|
219
|
+
|
|
220
|
+
// 4) Bundle JS actions → .jsbundle files
|
|
221
|
+
console.log(cyan("→ Bundling Titan actions..."));
|
|
222
|
+
try {
|
|
223
|
+
execSync(`node titan/bundle.js`, { stdio: "inherit" });
|
|
224
|
+
} catch (err) {
|
|
225
|
+
console.log(red("Bundler failed. Check titan/bundle.js for errors."));
|
|
226
|
+
process.exit(1);
|
|
227
|
+
}
|
|
228
|
+
|
|
229
|
+
// 5) Ensure server/actions folder exists
|
|
230
|
+
const actionsOut = path.join(serverDir, "actions");
|
|
231
|
+
if (!fs.existsSync(actionsOut)) {
|
|
232
|
+
fs.mkdirSync(actionsOut, { recursive: true });
|
|
233
|
+
}
|
|
234
|
+
|
|
235
|
+
// 6) Copy generated bundles into server/actions
|
|
236
|
+
const builtActions = path.join(projectRoot, "titan", "actions");
|
|
237
|
+
if (fs.existsSync(builtActions)) {
|
|
238
|
+
for (const file of fs.readdirSync(builtActions)) {
|
|
239
|
+
if (file.endsWith(".jsbundle")) {
|
|
240
|
+
fs.copyFileSync(
|
|
241
|
+
path.join(builtActions, file),
|
|
242
|
+
path.join(actionsOut, file)
|
|
243
|
+
);
|
|
244
|
+
}
|
|
245
|
+
}
|
|
246
|
+
}
|
|
247
|
+
|
|
248
|
+
console.log(green("✔ Bundles copied to server/actions"));
|
|
249
|
+
|
|
250
|
+
// 7) Build Rust binary
|
|
251
|
+
console.log(cyan("→ Building Rust release binary..."));
|
|
252
|
+
try {
|
|
253
|
+
execSync(`cargo build --release`, {
|
|
254
|
+
cwd: serverDir,
|
|
255
|
+
stdio: "inherit",
|
|
256
|
+
});
|
|
257
|
+
} catch (err) {
|
|
258
|
+
console.log(red("Rust build failed."));
|
|
259
|
+
process.exit(1);
|
|
260
|
+
}
|
|
261
|
+
|
|
262
|
+
console.log(green("✔ Titan production build complete!"));
|
|
263
|
+
console.log(green("✔ Rust binary ready at server/target/release/"));
|
|
200
264
|
}
|
|
201
265
|
|
|
266
|
+
|
|
202
267
|
// START PRODUCTION
|
|
203
268
|
function startProd() {
|
|
204
269
|
const isWindows = process.platform === "win32";
|