@ezetgalaxy/titan 26.8.3 → 26.9.1

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 (106) hide show
  1. package/README.md +76 -17
  2. package/index.js +118 -29
  3. package/package.json +1 -2
  4. package/templates/extension/README.md +104 -104
  5. package/templates/extension/index.js +27 -27
  6. package/templates/extension/jsconfig.json +12 -12
  7. package/templates/extension/native/Cargo.toml +9 -9
  8. package/templates/extension/native/src/lib.rs +5 -5
  9. package/templates/extension/package.json +20 -20
  10. package/templates/extension/titan.json +17 -17
  11. package/templates/js/Dockerfile +66 -66
  12. package/templates/js/_dockerignore +3 -3
  13. package/templates/js/_gitignore +1 -0
  14. package/templates/js/app/actions/hello.js +5 -5
  15. package/templates/js/app/titan.d.ts +87 -87
  16. package/templates/js/jsconfig.json +18 -18
  17. package/templates/js/server/src/action_management.rs +131 -131
  18. package/templates/js/server/src/errors.rs +10 -10
  19. package/templates/js/server/src/extensions.rs +989 -989
  20. package/templates/js/server/src/utils.rs +33 -33
  21. package/templates/js/titan/bundle.js +78 -78
  22. package/templates/js/titan/dev.js +9 -1
  23. package/templates/js/titan/titan.js +122 -122
  24. package/templates/{rust → rust-js}/Dockerfile +66 -66
  25. package/templates/{rust → rust-js}/_dockerignore +3 -3
  26. package/templates/{rust → rust-js}/_gitignore +1 -0
  27. package/templates/{rust → rust-js}/app/actions/hello.js +5 -5
  28. package/templates/{rust → rust-js}/app/actions/rust_hello.rs +14 -14
  29. package/templates/{rust → rust-js}/app/titan.d.ts +101 -101
  30. package/templates/{rust → rust-js}/jsconfig.json +18 -18
  31. package/templates/{rust → rust-js}/package.json +1 -1
  32. package/templates/{rust → rust-js}/server/src/action_management.rs +131 -131
  33. package/templates/{rust → rust-js}/server/src/errors.rs +10 -10
  34. package/templates/{rust → rust-js}/server/src/extensions.rs +989 -989
  35. package/templates/{rust → rust-js}/server/src/utils.rs +33 -33
  36. package/templates/{rust → rust-js}/titan/dev.js +9 -1
  37. package/templates/rust-ts/Dockerfile +66 -0
  38. package/templates/rust-ts/_dockerignore +3 -0
  39. package/templates/rust-ts/_gitignore +38 -0
  40. package/templates/rust-ts/app/actions/hello.ts +11 -0
  41. package/templates/rust-ts/app/actions/rust_hello.rs +14 -0
  42. package/templates/rust-ts/app/app.ts +11 -0
  43. package/templates/rust-ts/package.json +14 -0
  44. package/templates/rust-ts/server/Cargo.lock +2869 -0
  45. package/templates/rust-ts/server/Cargo.toml +39 -0
  46. package/templates/rust-ts/server/src/action_management.rs +131 -0
  47. package/templates/rust-ts/server/src/errors.rs +51 -0
  48. package/templates/rust-ts/server/src/extensions.rs +989 -0
  49. package/templates/rust-ts/server/src/main.rs +468 -0
  50. package/templates/rust-ts/server/src/utils.rs +33 -0
  51. package/templates/rust-ts/titan/bundle.js +163 -0
  52. package/templates/rust-ts/titan/dev.js +402 -0
  53. package/templates/rust-ts/titan/titan.d.ts +117 -0
  54. package/templates/rust-ts/titan/titan.js +122 -0
  55. package/templates/rust-ts/tsconfig.json +21 -0
  56. package/templates/ts/Dockerfile +40 -0
  57. package/templates/ts/_dockerignore +3 -0
  58. package/templates/ts/_gitignore +38 -0
  59. package/templates/ts/app/actions/hello.ts +11 -0
  60. package/templates/ts/app/app.ts +10 -0
  61. package/templates/ts/package.json +26 -0
  62. package/templates/ts/server/Cargo.lock +2869 -0
  63. package/templates/ts/server/Cargo.toml +27 -0
  64. package/templates/ts/server/src/action_management.rs +131 -0
  65. package/templates/ts/server/src/errors.rs +51 -0
  66. package/templates/ts/server/src/extensions.rs +989 -0
  67. package/templates/ts/server/src/main.rs +437 -0
  68. package/templates/ts/server/src/utils.rs +33 -0
  69. package/templates/ts/titan/builder.js +121 -0
  70. package/templates/ts/titan/bundle.js +76 -0
  71. package/templates/ts/titan/dev.js +402 -0
  72. package/templates/ts/titan/runtime.js +1 -0
  73. package/templates/ts/titan/titan.d.ts +117 -0
  74. package/templates/ts/titan/titan.js +122 -0
  75. package/templates/ts/tsconfig.json +16 -0
  76. package/titanpl-sdk/README.md +109 -109
  77. package/titanpl-sdk/bin/run.js +251 -254
  78. package/titanpl-sdk/index.d.ts +46 -46
  79. package/titanpl-sdk/index.js +5 -5
  80. package/titanpl-sdk/package.json +32 -32
  81. package/titanpl-sdk/templates/.dockerignore +3 -3
  82. package/titanpl-sdk/templates/Dockerfile +53 -53
  83. package/titanpl-sdk/templates/app/actions/hello.js +5 -5
  84. package/titanpl-sdk/templates/app/titan.d.ts +87 -87
  85. package/titanpl-sdk/templates/jsconfig.json +18 -18
  86. package/titanpl-sdk/templates/server/src/action_management.rs +131 -131
  87. package/titanpl-sdk/templates/server/src/errors.rs +10 -10
  88. package/titanpl-sdk/templates/server/src/extensions.rs +640 -640
  89. package/titanpl-sdk/templates/server/src/utils.rs +33 -33
  90. package/titanpl-sdk/templates/titan/bundle.js +65 -65
  91. package/titanpl-sdk/templates/titan/dev.js +113 -113
  92. package/titanpl-sdk/templates/titan/titan.js +98 -98
  93. package/templates/js/server/action_map.json +0 -3
  94. package/templates/js/server/actions/hello.jsbundle +0 -48
  95. package/templates/js/server/routes.json +0 -16
  96. package/templates/rust/server/action_map.json +0 -3
  97. package/templates/rust/server/actions/hello.jsbundle +0 -47
  98. package/templates/rust/server/routes.json +0 -22
  99. package/templates/rust/server/src/actions_rust/mod.rs +0 -19
  100. package/templates/rust/server/src/actions_rust/rust_hello.rs +0 -14
  101. /package/templates/{rust → rust-js}/app/app.js +0 -0
  102. /package/templates/{rust → rust-js}/server/Cargo.lock +0 -0
  103. /package/templates/{rust → rust-js}/server/Cargo.toml +0 -0
  104. /package/templates/{rust → rust-js}/server/src/main.rs +0 -0
  105. /package/templates/{rust → rust-js}/titan/bundle.js +0 -0
  106. /package/templates/{rust → rust-js}/titan/titan.js +0 -0
@@ -1,254 +1,251 @@
1
- #!/usr/bin/env node
2
- import fs from "fs";
3
- import path from "path";
4
- import { execSync } from "child_process";
5
- import { fileURLToPath } from "url";
6
-
7
- const __filename = fileURLToPath(import.meta.url);
8
- const __dirname = path.dirname(__filename);
9
-
10
- // Helper for colors
11
- const cyan = (t) => `\x1b[36m${t}\x1b[0m`;
12
- const green = (t) => `\x1b[32m${t}\x1b[0m`;
13
- const red = (t) => `\x1b[31m${t}\x1b[0m`;
14
- const yellow = (t) => `\x1b[33m${t}\x1b[0m`;
15
-
16
- function copyDir(src, dest) {
17
- fs.mkdirSync(dest, { recursive: true });
18
- for (const file of fs.readdirSync(src)) {
19
- const srcPath = path.join(src, file);
20
- const destPath = path.join(dest, file);
21
- if (fs.lstatSync(srcPath).isDirectory()) {
22
- copyDir(srcPath, destPath);
23
- } else {
24
- fs.copyFileSync(srcPath, destPath);
25
- }
26
- }
27
- }
28
-
29
- function run() {
30
- console.log(cyan("Titan SDK: Test Runner"));
31
-
32
- // 1. Validate we are in an extension directory
33
- const cwd = process.cwd();
34
- const manifestPath = path.join(cwd, "titan.json");
35
- if (!fs.existsSync(manifestPath)) {
36
- console.log(red("Error: titan.json not found. Run this command inside your extension folder."));
37
- process.exit(1);
38
- }
39
-
40
- const manifest = JSON.parse(fs.readFileSync(manifestPath, "utf8"));
41
- const name = manifest.name;
42
- console.log(green(`Extension: ${name}`));
43
-
44
- // 2. Build Native Logic (if properly set up)
45
- const nativeDir = path.join(cwd, "native");
46
- if (fs.existsSync(nativeDir) && fs.existsSync(path.join(nativeDir, "Cargo.toml"))) {
47
- console.log(cyan("Building native Rust module..."));
48
- try {
49
- execSync("cargo build --release", { cwd: nativeDir, stdio: "inherit" });
50
- } catch (e) {
51
- console.log(red("Failed to build native module."));
52
- process.exit(1);
53
- }
54
- }
55
-
56
- // 3. Create a Test Harness (Mini Titan Project)
57
- const runDir = path.join(cwd, ".titan_test_run");
58
- if (fs.existsSync(runDir)) {
59
- try {
60
- fs.rmSync(runDir, {
61
- recursive: true,
62
- force: true,
63
- maxRetries: 10,
64
- retryDelay: 100
65
- });
66
- } catch (e) {
67
- console.log(yellow(`Warning: Could not fully clean ${runDir}. Proceeding anyway...`));
68
- }
69
- }
70
-
71
- // Ensure runDir exists (sometimes rmSync + mkdirSync fails on Windows due to locks)
72
- if (!fs.existsSync(runDir)) {
73
- fs.mkdirSync(runDir, { recursive: true });
74
- }
75
-
76
- // Create app structure
77
- const appDir = path.join(runDir, "app");
78
- fs.mkdirSync(appDir);
79
-
80
- // Create actions folder (required by Titan build)
81
- const actionsDir = path.join(appDir, "actions");
82
- fs.mkdirSync(actionsDir);
83
-
84
- // Copy titan/ and server/ from templates
85
- const templatesDir = path.join(__dirname, "..", "templates");
86
-
87
- const titanSrc = path.join(templatesDir, "titan");
88
- const titanDest = path.join(runDir, "titan");
89
- if (fs.existsSync(titanSrc)) {
90
- console.log(cyan("→ Setting up Titan runtime..."));
91
- copyDir(titanSrc, titanDest);
92
- // Double check titan.js exists
93
- if (!fs.existsSync(path.join(titanDest, "titan.js"))) {
94
- console.log(red(`Error: Failed to copy titan.js to ${titanDest}`));
95
- process.exit(1);
96
- }
97
- } else {
98
- console.log(red(`Error: Titan templates not found at ${titanSrc}`));
99
- process.exit(1);
100
- }
101
-
102
- const serverSrc = path.join(templatesDir, "server");
103
- const serverDest = path.join(runDir, "server");
104
- if (fs.existsSync(serverSrc)) {
105
- console.log(cyan("→ Setting up Titan server..."));
106
- copyDir(serverSrc, serverDest);
107
- } else {
108
- console.log(red(`Error: Server templates not found at ${serverSrc}`));
109
- process.exit(1);
110
- }
111
-
112
- // Create package.json for the test harness
113
- const pkgJson = {
114
- "type": "module"
115
- };
116
- fs.writeFileSync(path.join(runDir, "package.json"), JSON.stringify(pkgJson, null, 2));
117
-
118
- // Create 'node_modules' to link the extension
119
- const nmDir = path.join(runDir, "node_modules");
120
- fs.mkdirSync(nmDir);
121
-
122
- // Link current extension to node_modules/NAME
123
- // Use junction for Windows compat without admin rights
124
- const extDest = path.join(nmDir, name);
125
- try {
126
- fs.symlinkSync(cwd, extDest, "junction");
127
- } catch (e) {
128
- // Fallback to copy if link fails
129
- console.log(yellow("Linking failed, copying extension files..."));
130
- copyDir(cwd, extDest);
131
- }
132
-
133
- // Create a test action in app/actions/test.js
134
- const testAction = `export const test = (req) => {
135
- const ext = t["${name}"];
136
-
137
- const results = {
138
- extension: "${name}",
139
- loaded: !!ext,
140
- methods: ext ? Object.keys(ext) : [],
141
- timestamp: new Date().toISOString()
142
- };
143
-
144
- if (ext && ext.hello) {
145
- try {
146
- results.hello_test = ext.hello("World");
147
- } catch(e) {
148
- results.hello_error = String(e);
149
- }
150
- }
151
-
152
- if (ext && ext.calc) {
153
- try {
154
- results.calc_test = ext.calc(15, 25);
155
- } catch(e) {
156
- results.calc_error = String(e);
157
- }
158
- }
159
-
160
- return results;
161
- };
162
- `;
163
-
164
- fs.writeFileSync(path.join(actionsDir, "test.js"), testAction);
165
-
166
- // Create a simple test script in app/app.js
167
- // This script will be executed by Titan
168
- const testScript = `import t from "../titan/titan.js";
169
- import "${name}";
170
-
171
- // Extension test harness for: ${name}
172
- const ext = t["${name}"];
173
-
174
- console.log("---------------------------------------------------");
175
- console.log("Testing Extension: ${name}");
176
- console.log("---------------------------------------------------");
177
-
178
- if (!ext) {
179
- console.log("ERROR: Extension '${name}' not found in global 't'.");
180
- } else {
181
- console.log("✓ Extension loaded successfully!");
182
- console.log("✓ Available methods:", Object.keys(ext).join(", "));
183
-
184
- // Try 'hello' if it exists
185
- if (typeof ext.hello === 'function') {
186
- console.log("\\nTesting ext.hello('Titan')...");
187
- try {
188
- const res = ext.hello("Titan");
189
- console.log("✓ Result:", res);
190
- } catch(e) {
191
- console.log("✗ Error:", e.message);
192
- }
193
- }
194
-
195
- // Try 'calc' if it exists
196
- if (typeof ext.calc === 'function') {
197
- console.log("\\nTesting ext.calc(10, 20)...");
198
- try {
199
- const res = ext.calc(10, 20);
200
- console.log("✓ Result:", res);
201
- } catch(e) {
202
- console.log("✗ Error:", e.message);
203
- }
204
- }
205
- }
206
-
207
- console.log("---------------------------------------------------");
208
- console.log("✓ Test complete!");
209
- console.log("\\n📍 Routes:");
210
- console.log(" GET http://localhost:3000/ → Test harness info");
211
- console.log(" GET http://localhost:3000/test → Extension test results (JSON)");
212
- console.log("---------------------------------------------------\\n");
213
-
214
- // Create routes
215
- t.get("/test").action("test");
216
- t.get("/").reply("🚀 Extension Test Harness for ${name}\\n\\nVisit /test to see extension test results");
217
-
218
- await t.start(3000, "Titan Extension Test Running!");
219
- `;
220
-
221
- fs.writeFileSync(path.join(appDir, "app.js"), testScript);
222
-
223
- // Build the app (bundle actions)
224
- console.log(cyan("Building test app..."));
225
- try {
226
- // Ensure we are in runDir and the file exists
227
- const appJsPath = path.join(runDir, "app", "app.js");
228
- if (!fs.existsSync(appJsPath)) {
229
- throw new Error(`app/app.js missing at ${appJsPath}`);
230
- }
231
-
232
- execSync("node app/app.js --build", {
233
- cwd: runDir,
234
- stdio: "inherit",
235
- env: { ...process.env, NODE_OPTIONS: "--no-warnings" }
236
- });
237
- } catch (e) {
238
- console.log(red("Failed to build test app. This is expected if your extension has errors."));
239
- // Don't exit here, attempt to continue to show runtime errors if possible
240
- }
241
-
242
- // 4. Run Titan Server using cargo run (like dev mode)
243
- console.log(green("\x1b[1m\n>>> STARTING EXTENSION TEST >>>\n\x1b[0m"));
244
-
245
- const serverDir = path.join(runDir, "server");
246
-
247
- try {
248
- execSync("cargo run", { cwd: serverDir, stdio: "inherit" });
249
- } catch (e) {
250
- console.log(red("Runtime exited."));
251
- }
252
- }
253
-
254
- run();
1
+ #!/usr/bin/env node
2
+ import fs from "fs";
3
+ import path from "path";
4
+ import { execSync } from "child_process";
5
+ import { fileURLToPath } from "url";
6
+
7
+ const __filename = fileURLToPath(import.meta.url);
8
+ const __dirname = path.dirname(__filename);
9
+
10
+ // Helper for colors
11
+ const cyan = (t) => `\x1b[36m${t}\x1b[0m`;
12
+ const green = (t) => `\x1b[32m${t}\x1b[0m`;
13
+ const red = (t) => `\x1b[31m${t}\x1b[0m`;
14
+ const yellow = (t) => `\x1b[33m${t}\x1b[0m`;
15
+
16
+ function copyDir(src, dest) {
17
+ fs.mkdirSync(dest, { recursive: true });
18
+ for (const file of fs.readdirSync(src)) {
19
+ const srcPath = path.join(src, file);
20
+ const destPath = path.join(dest, file);
21
+ if (fs.lstatSync(srcPath).isDirectory()) {
22
+ copyDir(srcPath, destPath);
23
+ } else {
24
+ fs.copyFileSync(srcPath, destPath);
25
+ }
26
+ }
27
+ }
28
+
29
+ function run() {
30
+ console.log(cyan("Titan SDK: Test Runner"));
31
+
32
+ // 1. Validate we are in an extension directory
33
+ const cwd = process.cwd();
34
+ const manifestPath = path.join(cwd, "titan.json");
35
+ if (!fs.existsSync(manifestPath)) {
36
+ console.log(red("Error: titan.json not found. Run this command inside your extension folder."));
37
+ process.exit(1);
38
+ }
39
+
40
+ const manifest = JSON.parse(fs.readFileSync(manifestPath, "utf8"));
41
+ const name = manifest.name;
42
+ console.log(green(`Extension: ${name}`));
43
+
44
+ // 2. Build Native Logic (if properly set up)
45
+ const nativeDir = path.join(cwd, "native");
46
+ if (fs.existsSync(nativeDir) && fs.existsSync(path.join(nativeDir, "Cargo.toml"))) {
47
+ console.log(cyan("Building native Rust module..."));
48
+ try {
49
+ execSync("cargo build --release", { cwd: nativeDir, stdio: "inherit" });
50
+ } catch (e) {
51
+ console.log(red("Failed to build native module."));
52
+ process.exit(1);
53
+ }
54
+ }
55
+
56
+ // 3. Setup Test Harness (Mini Titan Project)
57
+ const runDir = path.join(cwd, ".titan_test_run");
58
+ const isFirstRun = !fs.existsSync(runDir);
59
+
60
+ if (isFirstRun) {
61
+ console.log(cyan("Initializing test environment..."));
62
+ fs.mkdirSync(runDir, { recursive: true });
63
+
64
+ // Create app structure
65
+ const appDir = path.join(runDir, "app");
66
+ fs.mkdirSync(appDir);
67
+
68
+ // Create actions folder (required by Titan build)
69
+ const actionsDir = path.join(appDir, "actions");
70
+ fs.mkdirSync(actionsDir);
71
+
72
+ // Copy titan/ and server/ from templates
73
+ const templatesDir = path.join(__dirname, "..", "templates");
74
+
75
+ const titanSrc = path.join(templatesDir, "titan");
76
+ const titanDest = path.join(runDir, "titan");
77
+ if (fs.existsSync(titanSrc)) {
78
+ copyDir(titanSrc, titanDest);
79
+ // Double check titan.js exists
80
+ if (!fs.existsSync(path.join(titanDest, "titan.js"))) {
81
+ console.log(red(`Error: Failed to copy titan.js to ${titanDest}`));
82
+ process.exit(1);
83
+ }
84
+ } else {
85
+ console.log(red(`Error: Titan templates not found at ${titanSrc}`));
86
+ process.exit(1);
87
+ }
88
+
89
+ const serverSrc = path.join(templatesDir, "server");
90
+ const serverDest = path.join(runDir, "server");
91
+ if (fs.existsSync(serverSrc)) {
92
+ copyDir(serverSrc, serverDest);
93
+ } else {
94
+ console.log(red(`Error: Server templates not found at ${serverSrc}`));
95
+ process.exit(1);
96
+ }
97
+
98
+ // Create package.json for the test harness
99
+ const pkgJson = {
100
+ "type": "module"
101
+ };
102
+ fs.writeFileSync(path.join(runDir, "package.json"), JSON.stringify(pkgJson, null, 2));
103
+
104
+ // Create 'node_modules'
105
+ fs.mkdirSync(path.join(runDir, "node_modules"));
106
+ } else {
107
+ console.log(cyan("Using existing test environment..."));
108
+ }
109
+
110
+ // Always Ensure Extension Link is Fresh
111
+ const nmDir = path.join(runDir, "node_modules");
112
+ if (!fs.existsSync(nmDir)) fs.mkdirSync(nmDir, { recursive: true });
113
+
114
+ const extDest = path.join(nmDir, name);
115
+
116
+ // Remove old link/folder if exists to ensure freshness
117
+ if (fs.existsSync(extDest)) {
118
+ try {
119
+ fs.rmSync(extDest, { recursive: true, force: true });
120
+ } catch (e) { }
121
+ }
122
+
123
+ // Link current extension to node_modules/NAME
124
+ try {
125
+ // Use junction for Windows compat without admin rights
126
+ fs.symlinkSync(cwd, extDest, "junction");
127
+ } catch (e) {
128
+ // Fallback to copy if link fails
129
+ // console.log(yellow("Linking failed, copying extension files..."));
130
+ copyDir(cwd, extDest);
131
+ }
132
+
133
+ // Create default test files ONLY if they don't exist
134
+ const actionsDir = path.join(runDir, "app", "actions");
135
+ const testActionPath = path.join(actionsDir, "test.js");
136
+
137
+ if (!fs.existsSync(testActionPath)) {
138
+ const testAction = `export const test = (req) => {
139
+ const ext = t["${name}"];
140
+
141
+ const results = {
142
+ extension: "${name}",
143
+ loaded: !!ext,
144
+ methods: ext ? Object.keys(ext) : [],
145
+ timestamp: new Date().toISOString()
146
+ };
147
+
148
+ if (ext && ext.hello) {
149
+ try {
150
+ results.hello_test = ext.hello("World");
151
+ } catch(e) {
152
+ results.hello_error = String(e);
153
+ }
154
+ }
155
+
156
+ if (ext && ext.calc) {
157
+ try {
158
+ results.calc_test = ext.calc(15, 25);
159
+ } catch(e) {
160
+ results.calc_error = String(e);
161
+ }
162
+ }
163
+
164
+ return results;
165
+ };
166
+ `;
167
+ fs.writeFileSync(testActionPath, testAction);
168
+ }
169
+
170
+ const appJsPath = path.join(runDir, "app", "app.js");
171
+ if (!fs.existsSync(appJsPath)) {
172
+ const testScript = `import t from "../titan/titan.js";
173
+ import "${name}";
174
+
175
+ // Extension test harness for: ${name}
176
+ const ext = t["${name}"];
177
+
178
+ console.log("---------------------------------------------------");
179
+ console.log("Testing Extension: ${name}");
180
+ console.log("---------------------------------------------------");
181
+
182
+ if (!ext) {
183
+ console.log("ERROR: Extension '${name}' not found in global 't'.");
184
+ } else {
185
+ console.log("✓ Extension loaded successfully!");
186
+ console.log(" Available methods:", Object.keys(ext).join(", "));
187
+
188
+ // Try 'hello' if it exists
189
+ if (typeof ext.hello === 'function') {
190
+ console.log("\\nTesting ext.hello('Titan')...");
191
+ try {
192
+ const res = ext.hello("Titan");
193
+ console.log("✓ Result:", res);
194
+ } catch(e) {
195
+ console.log("✗ Error:", e.message);
196
+ }
197
+ }
198
+
199
+ // Try 'calc' if it exists
200
+ if (typeof ext.calc === 'function') {
201
+ console.log("\\nTesting ext.calc(10, 20)...");
202
+ try {
203
+ const res = ext.calc(10, 20);
204
+ console.log("✓ Result:", res);
205
+ } catch(e) {
206
+ console.log("✗ Error:", e.message);
207
+ }
208
+ }
209
+ }
210
+
211
+ console.log("---------------------------------------------------");
212
+ console.log("✓ Test complete!");
213
+ console.log("\\n📍 Routes:");
214
+ console.log(" GET http://localhost:3000/ → Test harness info");
215
+ console.log(" GET http://localhost:3000/test → Extension test results (JSON)");
216
+ console.log("---------------------------------------------------\\n");
217
+
218
+ // Create routes
219
+ t.get("/test").action("test");
220
+ t.get("/").reply("🚀 Extension Test Harness for ${name}\\n\\nVisit /test to see extension test results");
221
+
222
+ await t.start(3000, "Titan Extension Test Running!");
223
+ `;
224
+ fs.writeFileSync(appJsPath, testScript);
225
+ }
226
+
227
+ // Build the app (bundle actions)
228
+ console.log(cyan("Building test app..."));
229
+ try {
230
+ execSync("node app/app.js --build", {
231
+ cwd: runDir,
232
+ stdio: "inherit",
233
+ env: { ...process.env, NODE_OPTIONS: "--no-warnings" }
234
+ });
235
+ } catch (e) {
236
+ console.log(red("Failed to build test app. checking for runtime errors..."));
237
+ }
238
+
239
+ // 4. Run Titan Server using cargo run
240
+ console.log(green("\\x1b[1m\\n>>> STARTING EXTENSION TEST >>>\\n\\x1b[0m"));
241
+
242
+ const serverDir = path.join(runDir, "server");
243
+
244
+ try {
245
+ execSync("cargo run", { cwd: serverDir, stdio: "inherit" });
246
+ } catch (e) {
247
+ // console.log(red("Runtime exited."));
248
+ }
249
+ }
250
+
251
+ run();
@@ -1,46 +1,46 @@
1
- export { };
2
-
3
- declare global {
4
- /**
5
- * Titan Runtime Global Object
6
- */
7
- const t: Titan.Runtime;
8
- }
9
-
10
- export namespace Titan {
11
- interface Runtime {
12
- /**
13
- * Log messages to the Titan console
14
- */
15
- log: LogInterface;
16
-
17
- /**
18
- * Read file content
19
- */
20
- read(path: string): string;
21
-
22
- /**
23
- * Fetch API wrapper
24
- */
25
- fetch(url: string, options?: any): Promise<any>;
26
-
27
- /**
28
- * Database operations
29
- */
30
- db: {
31
- query(sql: string, params?: any[]): Promise<any>;
32
- };
33
-
34
- /**
35
- * Titan Extensions
36
- */
37
- [key: string]: any;
38
- }
39
-
40
- interface LogInterface {
41
- (...args: any[]): void;
42
- info(...args: any[]): void;
43
- warn(...args: any[]): void;
44
- error(...args: any[]): void;
45
- }
46
- }
1
+ export { };
2
+
3
+ declare global {
4
+ /**
5
+ * Titan Runtime Global Object
6
+ */
7
+ const t: Titan.Runtime;
8
+ }
9
+
10
+ export namespace Titan {
11
+ interface Runtime {
12
+ /**
13
+ * Log messages to the Titan console
14
+ */
15
+ log: LogInterface;
16
+
17
+ /**
18
+ * Read file content
19
+ */
20
+ read(path: string): string;
21
+
22
+ /**
23
+ * Fetch API wrapper
24
+ */
25
+ fetch(url: string, options?: any): Promise<any>;
26
+
27
+ /**
28
+ * Database operations
29
+ */
30
+ db: {
31
+ query(sql: string, params?: any[]): Promise<any>;
32
+ };
33
+
34
+ /**
35
+ * Titan Extensions
36
+ */
37
+ [key: string]: any;
38
+ }
39
+
40
+ interface LogInterface {
41
+ (...args: any[]): void;
42
+ info(...args: any[]): void;
43
+ warn(...args: any[]): void;
44
+ error(...args: any[]): void;
45
+ }
46
+ }
@@ -1,5 +1,5 @@
1
- // Titan SDK
2
- // This package is primarily for type definitions and development tools.
3
- // The 't' object is injected globally by the Titan runtime.
4
-
5
- export const VERSION = "0.0.1";
1
+ // Titan SDK
2
+ // This package is primarily for type definitions and development tools.
3
+ // The 't' object is injected globally by the Titan runtime.
4
+
5
+ export const VERSION = "0.0.1";