@ezetgalaxy/titan 26.6.1 → 26.6.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 +13 -98
- package/package.json +1 -1
- package/templates/titan/titan.js +37 -26
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";
|
|
@@ -464,107 +464,22 @@ Next steps:
|
|
|
464
464
|
}
|
|
465
465
|
|
|
466
466
|
function runExtension() {
|
|
467
|
-
const
|
|
468
|
-
|
|
469
|
-
|
|
470
|
-
|
|
471
|
-
console.log(red("Error: titan.json not found. Are you in an extension folder?"));
|
|
472
|
-
return;
|
|
473
|
-
}
|
|
474
|
-
|
|
475
|
-
const manifest = JSON.parse(fs.readFileSync(manifestPath, "utf8"));
|
|
476
|
-
const name = manifest.name;
|
|
477
|
-
console.log(cyan(`Preparing to run extension: ${name}`));
|
|
478
|
-
|
|
479
|
-
// 1. Build Native if exists
|
|
480
|
-
const nativeDir = path.join(cwd, "native");
|
|
481
|
-
if (fs.existsSync(nativeDir)) {
|
|
482
|
-
console.log(cyan("Building native module..."));
|
|
467
|
+
const localSdk = path.join(__dirname, "titan-sdk", "bin", "run.js");
|
|
468
|
+
|
|
469
|
+
if (fs.existsSync(localSdk)) {
|
|
470
|
+
console.log(cyan("[Titan] Using local SDK runner..."));
|
|
483
471
|
try {
|
|
484
|
-
execSync(
|
|
472
|
+
execSync(`node "${localSdk}"`, { stdio: "inherit" });
|
|
485
473
|
} catch (e) {
|
|
486
|
-
|
|
487
|
-
return;
|
|
488
|
-
}
|
|
489
|
-
}
|
|
490
|
-
|
|
491
|
-
// 2. Setup Temporary Runner
|
|
492
|
-
const runnerDir = path.join(cwd, ".titan_runner");
|
|
493
|
-
if (fs.existsSync(runnerDir)) {
|
|
494
|
-
fs.rmSync(runnerDir, { recursive: true, force: true });
|
|
495
|
-
}
|
|
496
|
-
|
|
497
|
-
// We need to create a project environment.
|
|
498
|
-
// We can use the templates stored in __dirname
|
|
499
|
-
const templateDir = path.join(__dirname, "templates");
|
|
500
|
-
|
|
501
|
-
console.log(cyan("Setting up test harness..."));
|
|
502
|
-
fs.mkdirSync(runnerDir);
|
|
503
|
-
|
|
504
|
-
// Copy templates/app -> runner/app
|
|
505
|
-
const runnerApp = path.join(runnerDir, "app");
|
|
506
|
-
copyDir(path.join(templateDir, "app"), runnerApp);
|
|
507
|
-
|
|
508
|
-
// Copy templates/server -> runner/server
|
|
509
|
-
const runnerServer = path.join(runnerDir, "server");
|
|
510
|
-
copyDir(path.join(templateDir, "server"), runnerServer);
|
|
511
|
-
|
|
512
|
-
// Create a dummy app.js that uses the extension
|
|
513
|
-
const appJsContent = `
|
|
514
|
-
const extensionName = "${name}";
|
|
515
|
-
t.log("TestRunner", "Loading extension: " + extensionName);
|
|
516
|
-
|
|
517
|
-
// Access the extension
|
|
518
|
-
if (t[extensionName]) {
|
|
519
|
-
t.log("TestRunner", "Extension found on 't'!");
|
|
520
|
-
if (t[extensionName].hello) {
|
|
521
|
-
t[extensionName].hello("Titan User");
|
|
522
|
-
}
|
|
523
|
-
if (t[extensionName].calc) {
|
|
524
|
-
const res = t[extensionName].calc(10, 50);
|
|
525
|
-
t.log("TestRunner", "Calc Result (10+50): " + res);
|
|
474
|
+
// SDK runner handles its own errors
|
|
526
475
|
}
|
|
527
476
|
} else {
|
|
528
|
-
|
|
529
|
-
|
|
530
|
-
|
|
531
|
-
|
|
532
|
-
|
|
533
|
-
|
|
534
|
-
// We need to simulate 'node_modules/extension_name'
|
|
535
|
-
const runnerNodeModules = path.join(runnerDir, "node_modules");
|
|
536
|
-
fs.mkdirSync(runnerNodeModules, { recursive: true });
|
|
537
|
-
|
|
538
|
-
const extLinkPath = path.join(runnerNodeModules, name);
|
|
539
|
-
// On Windows, symlinks require special permissions, usually.
|
|
540
|
-
// Junctions are safer for directories.
|
|
541
|
-
try {
|
|
542
|
-
fs.symlinkSync(cwd, extLinkPath, "junction");
|
|
543
|
-
} catch (e) {
|
|
544
|
-
// Fallback to copy if symlink fails
|
|
545
|
-
console.log(yellow("Symlink failed, copying extension..."));
|
|
546
|
-
copyDir(cwd, extLinkPath);
|
|
547
|
-
}
|
|
548
|
-
|
|
549
|
-
console.log(cyan("Building test harness server... (this may take a minute)"));
|
|
550
|
-
try {
|
|
551
|
-
execSync("cargo build --release", { cwd: runnerServer, stdio: "inherit" });
|
|
552
|
-
} catch (e) {
|
|
553
|
-
console.log(red("Failed to build test server."));
|
|
554
|
-
return;
|
|
555
|
-
}
|
|
556
|
-
|
|
557
|
-
// 5. Run it
|
|
558
|
-
const isWin = process.platform === "win32";
|
|
559
|
-
const bin = isWin ? "titan-server.exe" : "titan-server";
|
|
560
|
-
const exe = path.join(runnerServer, "target", "release", bin);
|
|
561
|
-
|
|
562
|
-
console.log(bold(green("\n>>> STARTING EXTENSION TEST >>>\n")));
|
|
563
|
-
try {
|
|
564
|
-
// Run inside the runner directory so it finds app/, server/, etc.
|
|
565
|
-
execSync(`"${exe}"`, { cwd: runnerDir, stdio: "inherit" });
|
|
566
|
-
} catch (e) {
|
|
567
|
-
console.log(red("\nTest ended with error or was stopped."));
|
|
477
|
+
console.log(cyan("[Titan] SDK not found locally, falling back to npx..."));
|
|
478
|
+
try {
|
|
479
|
+
execSync("npx -y titan-sdk", { stdio: "inherit" });
|
|
480
|
+
} catch (e) {
|
|
481
|
+
// SDK runner handles its own errors
|
|
482
|
+
}
|
|
568
483
|
}
|
|
569
484
|
}
|
|
570
485
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ezetgalaxy/titan",
|
|
3
|
-
"version": "26.6.
|
|
3
|
+
"version": "26.6.2",
|
|
4
4
|
"description": "Titan Planet is a JavaScript-first backend framework that embeds JS actions into a Rust + Axum server and ships as a single native binary. Routes are compiled to static metadata; only actions run in the embedded JS runtime. No Node.js. No event loop in production.",
|
|
5
5
|
"license": "ISC",
|
|
6
6
|
"author": "ezetgalaxy",
|
package/templates/titan/titan.js
CHANGED
|
@@ -50,32 +50,43 @@ const t = {
|
|
|
50
50
|
},
|
|
51
51
|
|
|
52
52
|
async start(port = 3000, msg = "") {
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
53
|
+
try {
|
|
54
|
+
console.log(cyan("[Titan] Preparing runtime..."));
|
|
55
|
+
await bundle();
|
|
56
|
+
|
|
57
|
+
const base = path.join(process.cwd(), "server");
|
|
58
|
+
if (!fs.existsSync(base)) {
|
|
59
|
+
fs.mkdirSync(base, { recursive: true });
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
const routesPath = path.join(base, "routes.json");
|
|
63
|
+
const actionMapPath = path.join(base, "action_map.json");
|
|
64
|
+
|
|
65
|
+
fs.writeFileSync(
|
|
66
|
+
routesPath,
|
|
67
|
+
JSON.stringify(
|
|
68
|
+
{
|
|
69
|
+
__config: { port },
|
|
70
|
+
routes,
|
|
71
|
+
__dynamic_routes: Object.values(dynamicRoutes).flat()
|
|
72
|
+
},
|
|
73
|
+
null,
|
|
74
|
+
2
|
|
75
|
+
)
|
|
76
|
+
);
|
|
77
|
+
|
|
78
|
+
fs.writeFileSync(
|
|
79
|
+
actionMapPath,
|
|
80
|
+
JSON.stringify(actionMap, null, 2)
|
|
81
|
+
);
|
|
82
|
+
|
|
83
|
+
console.log(green("✔ Titan metadata written successfully"));
|
|
84
|
+
if (msg) console.log(cyan(msg));
|
|
85
|
+
|
|
86
|
+
} catch (e) {
|
|
87
|
+
console.error(`\x1b[31m[Titan] Build Error: ${e.message}\x1b[0m`);
|
|
88
|
+
process.exit(1);
|
|
89
|
+
}
|
|
79
90
|
}
|
|
80
91
|
};
|
|
81
92
|
|