@ezetgalaxy/titan 25.13.0 → 25.13.2
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 +52 -6
- package/package.json +1 -1
- package/templates/server/src/main.rs +17 -12
package/index.js
CHANGED
|
@@ -43,7 +43,7 @@ function copyDir(src, dest) {
|
|
|
43
43
|
/* HELP */
|
|
44
44
|
function help() {
|
|
45
45
|
console.log(`
|
|
46
|
-
${bold(cyan("Titan
|
|
46
|
+
${bold(cyan("Titan Planet"))} v${TITAN_VERSION}
|
|
47
47
|
|
|
48
48
|
${green("tit init <project>")} Create new Titan project
|
|
49
49
|
${green("tit dev")} Dev mode (hot reload)
|
|
@@ -240,20 +240,66 @@ function updateTitan() {
|
|
|
240
240
|
const root = process.cwd();
|
|
241
241
|
const projectTitan = path.join(root, "titan");
|
|
242
242
|
|
|
243
|
-
const
|
|
244
|
-
const
|
|
243
|
+
const templatesRoot = path.join(__dirname, "templates");
|
|
244
|
+
const templateTitan = path.join(templatesRoot, "titan");
|
|
245
|
+
|
|
246
|
+
const templateServer = path.join(templatesRoot, "server");
|
|
247
|
+
const templateCargo = path.join(templateServer, "Cargo.toml");
|
|
248
|
+
const templateMain = path.join(templateServer, "src", "main.rs");
|
|
245
249
|
|
|
246
250
|
if (!fs.existsSync(projectTitan)) {
|
|
247
|
-
console.log(red("Not a Titan project
|
|
251
|
+
console.log(red("Not a Titan project — titan/ folder missing."));
|
|
248
252
|
return;
|
|
249
253
|
}
|
|
250
254
|
|
|
255
|
+
console.log(cyan("Updating Titan runtime..."));
|
|
256
|
+
|
|
257
|
+
// ----------------------------------------------------------
|
|
258
|
+
// 1. Update titan/ runtime folder
|
|
259
|
+
// ----------------------------------------------------------
|
|
251
260
|
fs.rmSync(projectTitan, { recursive: true, force: true });
|
|
252
|
-
copyDir(
|
|
261
|
+
copyDir(templateTitan, projectTitan);
|
|
262
|
+
console.log(green("✔ Updated titan/ runtime"));
|
|
263
|
+
|
|
264
|
+
// ----------------------------------------------------------
|
|
265
|
+
// 2. Update server/Cargo.toml
|
|
266
|
+
// ----------------------------------------------------------
|
|
267
|
+
const destCargo = path.join(root, "server", "Cargo.toml");
|
|
268
|
+
if (fs.existsSync(templateCargo)) {
|
|
269
|
+
fs.copyFileSync(templateCargo, destCargo);
|
|
270
|
+
console.log(green("✔ Updated server/Cargo.toml"));
|
|
271
|
+
} else {
|
|
272
|
+
console.log(yellow("⚠ Missing Cargo.toml template in CLI."));
|
|
273
|
+
}
|
|
253
274
|
|
|
254
|
-
|
|
275
|
+
// ----------------------------------------------------------
|
|
276
|
+
// 3. Update server/src/main.rs
|
|
277
|
+
// ----------------------------------------------------------
|
|
278
|
+
const destMain = path.join(root, "server", "src", "main.rs");
|
|
279
|
+
if (fs.existsSync(templateMain)) {
|
|
280
|
+
fs.copyFileSync(templateMain, destMain);
|
|
281
|
+
console.log(green("✔ Updated server/src/main.rs"));
|
|
282
|
+
} else {
|
|
283
|
+
console.log(yellow("⚠ Missing server/src/main.rs in CLI."));
|
|
284
|
+
}
|
|
285
|
+
|
|
286
|
+
// ----------------------------------------------------------
|
|
287
|
+
// 4. Update project-level config files
|
|
288
|
+
// ----------------------------------------------------------
|
|
289
|
+
[".gitignore", ".dockerignore", "Dockerfile"].forEach((file) => {
|
|
290
|
+
const src = path.join(templatesRoot, file);
|
|
291
|
+
const dest = path.join(root, file);
|
|
292
|
+
|
|
293
|
+
if (fs.existsSync(src)) {
|
|
294
|
+
fs.copyFileSync(src, dest);
|
|
295
|
+
console.log(green(`✔ Updated ${file}`));
|
|
296
|
+
}
|
|
297
|
+
});
|
|
298
|
+
|
|
299
|
+
console.log(bold(green("✔ Titan update complete")));
|
|
255
300
|
}
|
|
256
301
|
|
|
302
|
+
|
|
257
303
|
/* ROUTER */
|
|
258
304
|
switch (cmd) {
|
|
259
305
|
case "init":
|
package/package.json
CHANGED
|
@@ -40,9 +40,7 @@ struct AppState {
|
|
|
40
40
|
project_root: PathBuf,
|
|
41
41
|
}
|
|
42
42
|
|
|
43
|
-
|
|
44
|
-
/// This `t.fetch` runs the blocking HTTP call inside `tokio::task::block_in_place`
|
|
45
|
-
/// so it is safe to call while inside an async Tokio context.
|
|
43
|
+
|
|
46
44
|
fn inject_t_fetch(ctx: &mut Context) {
|
|
47
45
|
// Create native Rust function (Boa v0.20)
|
|
48
46
|
let t_fetch_native = NativeFunction::from_fn_ptr(|_this, args, ctx| {
|
|
@@ -186,19 +184,26 @@ async fn dynamic_handler_inner(
|
|
|
186
184
|
.into_response();
|
|
187
185
|
}
|
|
188
186
|
|
|
189
|
-
let action_path = state.project_root
|
|
190
|
-
.join("actions")
|
|
191
|
-
.join(format!("{}.jsbundle", action_name));
|
|
192
187
|
|
|
188
|
+
let dev_actions_dir = state.project_root.join("server").join("actions");
|
|
189
|
+
let prod_actions_dir = state.project_root.join("actions");
|
|
193
190
|
|
|
191
|
+
let actions_dir = if dev_actions_dir.exists() {
|
|
192
|
+
dev_actions_dir
|
|
193
|
+
} else {
|
|
194
|
+
prod_actions_dir
|
|
195
|
+
};
|
|
194
196
|
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
197
|
+
let action_path = actions_dir.join(format!("{}.jsbundle", action_name));
|
|
198
|
+
|
|
199
|
+
if !action_path.exists() {
|
|
200
|
+
return (
|
|
201
|
+
StatusCode::NOT_FOUND,
|
|
202
|
+
format!("Action bundle not found: {:?}", action_path),
|
|
203
|
+
)
|
|
200
204
|
.into_response();
|
|
201
|
-
|
|
205
|
+
}
|
|
206
|
+
|
|
202
207
|
|
|
203
208
|
let js_code = match fs::read_to_string(action_path) {
|
|
204
209
|
Ok(v) => v,
|