@ezetgalaxy/titan 25.14.2 → 25.14.4
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 +20 -44
- package/package.json +1 -1
- package/templates/server/src/main.rs +17 -7
package/index.js
CHANGED
|
@@ -187,66 +187,41 @@ function buildProd() {
|
|
|
187
187
|
|
|
188
188
|
const root = process.cwd();
|
|
189
189
|
const appJs = path.join(root, "app", "app.js");
|
|
190
|
-
const bundler = path.join(root, "titan", "bundle.js");
|
|
191
190
|
const serverDir = path.join(root, "server");
|
|
192
|
-
const
|
|
193
|
-
const actionsOut = builtActionsDir; // final output
|
|
191
|
+
const actionsOut = path.join(serverDir, "actions");
|
|
194
192
|
|
|
195
|
-
//
|
|
196
|
-
// 0) Basic validation
|
|
197
|
-
// --------------------------------------------
|
|
193
|
+
// BASIC CHECKS
|
|
198
194
|
if (!fs.existsSync(appJs)) {
|
|
199
195
|
console.log(red("ERROR: app/app.js not found."));
|
|
200
196
|
process.exit(1);
|
|
201
197
|
}
|
|
202
198
|
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
// --------------------------------------------
|
|
209
|
-
// 1) Generate routes + action_map via DSL
|
|
210
|
-
// --------------------------------------------
|
|
211
|
-
console.log(cyan("→ Generating Titan metadata..."));
|
|
199
|
+
// ----------------------------------------------------
|
|
200
|
+
// 1) BUILD METADATA + BUNDLE ACTIONS (ONE TIME ONLY)
|
|
201
|
+
// ----------------------------------------------------
|
|
202
|
+
console.log(cyan("→ Building Titan metadata + bundling actions..."));
|
|
212
203
|
execSync("node app/app.js --build", { stdio: "inherit" });
|
|
213
204
|
|
|
214
|
-
//
|
|
215
|
-
// 2) Bundle JS actions
|
|
216
|
-
// --------------------------------------------
|
|
217
|
-
console.log(cyan("→ Bundling Titan actions..."));
|
|
218
|
-
execSync("node titan/bundle.js", { stdio: "inherit" });
|
|
219
|
-
|
|
220
|
-
// --------------------------------------------
|
|
221
|
-
// 3) Ensure server/actions exists
|
|
222
|
-
// --------------------------------------------
|
|
205
|
+
// ensure actions directory exists
|
|
223
206
|
fs.mkdirSync(actionsOut, { recursive: true });
|
|
224
207
|
|
|
225
|
-
//
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
console.log(red("
|
|
230
|
-
console.log(red("This means titan/bundle.js output path is incorrect."));
|
|
208
|
+
// verify bundled actions exist
|
|
209
|
+
const bundles = fs.readdirSync(actionsOut).filter(f => f.endsWith(".jsbundle"));
|
|
210
|
+
if (bundles.length === 0) {
|
|
211
|
+
console.log(red("ERROR: No actions bundled."));
|
|
212
|
+
console.log(red("Make sure your DSL outputs to server/actions."));
|
|
231
213
|
process.exit(1);
|
|
232
214
|
}
|
|
233
215
|
|
|
234
|
-
|
|
235
|
-
.
|
|
236
|
-
|
|
237
|
-
if (bundles.length === 0) {
|
|
238
|
-
console.log(yellow("Warning: No actions bundled."));
|
|
239
|
-
} else {
|
|
240
|
-
for (const file of bundles) {
|
|
241
|
-
console.log(cyan(`→ Found bundle: ${file}`));
|
|
242
|
-
}
|
|
243
|
-
}
|
|
216
|
+
bundles.forEach(file => {
|
|
217
|
+
console.log(cyan(`→ Found action bundle: ${file}`));
|
|
218
|
+
});
|
|
244
219
|
|
|
245
|
-
console.log(green("✔ Actions
|
|
220
|
+
console.log(green("✔ Actions ready in server/actions"));
|
|
246
221
|
|
|
247
|
-
//
|
|
248
|
-
//
|
|
249
|
-
//
|
|
222
|
+
// ----------------------------------------------------
|
|
223
|
+
// 2) BUILD RUST BINARY
|
|
224
|
+
// ----------------------------------------------------
|
|
250
225
|
console.log(cyan("→ Building Rust release binary..."));
|
|
251
226
|
execSync("cargo build --release", {
|
|
252
227
|
cwd: serverDir,
|
|
@@ -257,6 +232,7 @@ function buildProd() {
|
|
|
257
232
|
}
|
|
258
233
|
|
|
259
234
|
|
|
235
|
+
|
|
260
236
|
/* START PRODUCTION BINARY */
|
|
261
237
|
function startProd() {
|
|
262
238
|
const isWin = process.platform === "win32";
|
package/package.json
CHANGED
|
@@ -130,20 +130,30 @@ fn detect_project_root() -> PathBuf {
|
|
|
130
130
|
}
|
|
131
131
|
|
|
132
132
|
|
|
133
|
-
fn resolve_actions_dir(
|
|
134
|
-
let exe = std::env::current_exe().
|
|
135
|
-
let exe_dir = exe.parent().
|
|
133
|
+
fn resolve_actions_dir() -> PathBuf {
|
|
134
|
+
let exe = std::env::current_exe().unwrap_or_else(|_| PathBuf::from("."));
|
|
135
|
+
let exe_dir = exe.parent().unwrap_or(Path::new("/app")).to_path_buf();
|
|
136
|
+
|
|
137
|
+
// Detect production if running from Docker binary location
|
|
136
138
|
let is_prod = exe_dir.to_string_lossy().contains("/app")
|
|
137
|
-
||
|
|
139
|
+
|| exe.file_name().unwrap_or_default() == "titan-server";
|
|
138
140
|
|
|
139
141
|
if is_prod {
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
project_root.join("server").join("actions")
|
|
142
|
+
// Final production directory
|
|
143
|
+
return PathBuf::from("/app/actions");
|
|
143
144
|
}
|
|
145
|
+
|
|
146
|
+
// DEV: exe = <root>/server/target/debug/server(.exe)
|
|
147
|
+
exe_dir
|
|
148
|
+
.parent() // target
|
|
149
|
+
.unwrap_or(Path::new("."))
|
|
150
|
+
.parent() // server
|
|
151
|
+
.unwrap_or(Path::new("."))
|
|
152
|
+
.join("actions")
|
|
144
153
|
}
|
|
145
154
|
|
|
146
155
|
|
|
156
|
+
|
|
147
157
|
async fn dynamic_handler(
|
|
148
158
|
State(state): State<AppState>,
|
|
149
159
|
req: Request<Body>,
|