@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.
- package/README.md +76 -17
- package/index.js +118 -29
- package/package.json +1 -2
- package/templates/extension/README.md +104 -104
- package/templates/extension/index.js +27 -27
- package/templates/extension/jsconfig.json +12 -12
- package/templates/extension/native/Cargo.toml +9 -9
- package/templates/extension/native/src/lib.rs +5 -5
- package/templates/extension/package.json +20 -20
- package/templates/extension/titan.json +17 -17
- package/templates/js/Dockerfile +66 -66
- package/templates/js/_dockerignore +3 -3
- package/templates/js/_gitignore +1 -0
- package/templates/js/app/actions/hello.js +5 -5
- package/templates/js/app/titan.d.ts +87 -87
- package/templates/js/jsconfig.json +18 -18
- package/templates/js/server/src/action_management.rs +131 -131
- package/templates/js/server/src/errors.rs +10 -10
- package/templates/js/server/src/extensions.rs +989 -989
- package/templates/js/server/src/utils.rs +33 -33
- package/templates/js/titan/bundle.js +78 -78
- package/templates/js/titan/dev.js +9 -1
- package/templates/js/titan/titan.js +122 -122
- package/templates/{rust → rust-js}/Dockerfile +66 -66
- package/templates/{rust → rust-js}/_dockerignore +3 -3
- package/templates/{rust → rust-js}/_gitignore +1 -0
- package/templates/{rust → rust-js}/app/actions/hello.js +5 -5
- package/templates/{rust → rust-js}/app/actions/rust_hello.rs +14 -14
- package/templates/{rust → rust-js}/app/titan.d.ts +101 -101
- package/templates/{rust → rust-js}/jsconfig.json +18 -18
- package/templates/{rust → rust-js}/package.json +1 -1
- package/templates/{rust → rust-js}/server/src/action_management.rs +131 -131
- package/templates/{rust → rust-js}/server/src/errors.rs +10 -10
- package/templates/{rust → rust-js}/server/src/extensions.rs +989 -989
- package/templates/{rust → rust-js}/server/src/utils.rs +33 -33
- package/templates/{rust → rust-js}/titan/dev.js +9 -1
- package/templates/rust-ts/Dockerfile +66 -0
- package/templates/rust-ts/_dockerignore +3 -0
- package/templates/rust-ts/_gitignore +38 -0
- package/templates/rust-ts/app/actions/hello.ts +11 -0
- package/templates/rust-ts/app/actions/rust_hello.rs +14 -0
- package/templates/rust-ts/app/app.ts +11 -0
- package/templates/rust-ts/package.json +14 -0
- package/templates/rust-ts/server/Cargo.lock +2869 -0
- package/templates/rust-ts/server/Cargo.toml +39 -0
- package/templates/rust-ts/server/src/action_management.rs +131 -0
- package/templates/rust-ts/server/src/errors.rs +51 -0
- package/templates/rust-ts/server/src/extensions.rs +989 -0
- package/templates/rust-ts/server/src/main.rs +468 -0
- package/templates/rust-ts/server/src/utils.rs +33 -0
- package/templates/rust-ts/titan/bundle.js +163 -0
- package/templates/rust-ts/titan/dev.js +402 -0
- package/templates/rust-ts/titan/titan.d.ts +117 -0
- package/templates/rust-ts/titan/titan.js +122 -0
- package/templates/rust-ts/tsconfig.json +21 -0
- package/templates/ts/Dockerfile +40 -0
- package/templates/ts/_dockerignore +3 -0
- package/templates/ts/_gitignore +38 -0
- package/templates/ts/app/actions/hello.ts +11 -0
- package/templates/ts/app/app.ts +10 -0
- package/templates/ts/package.json +26 -0
- package/templates/ts/server/Cargo.lock +2869 -0
- package/templates/ts/server/Cargo.toml +27 -0
- package/templates/ts/server/src/action_management.rs +131 -0
- package/templates/ts/server/src/errors.rs +51 -0
- package/templates/ts/server/src/extensions.rs +989 -0
- package/templates/ts/server/src/main.rs +437 -0
- package/templates/ts/server/src/utils.rs +33 -0
- package/templates/ts/titan/builder.js +121 -0
- package/templates/ts/titan/bundle.js +76 -0
- package/templates/ts/titan/dev.js +402 -0
- package/templates/ts/titan/runtime.js +1 -0
- package/templates/ts/titan/titan.d.ts +117 -0
- package/templates/ts/titan/titan.js +122 -0
- package/templates/ts/tsconfig.json +16 -0
- package/titanpl-sdk/README.md +109 -109
- package/titanpl-sdk/bin/run.js +251 -254
- package/titanpl-sdk/index.d.ts +46 -46
- package/titanpl-sdk/index.js +5 -5
- package/titanpl-sdk/package.json +32 -32
- package/titanpl-sdk/templates/.dockerignore +3 -3
- package/titanpl-sdk/templates/Dockerfile +53 -53
- package/titanpl-sdk/templates/app/actions/hello.js +5 -5
- package/titanpl-sdk/templates/app/titan.d.ts +87 -87
- package/titanpl-sdk/templates/jsconfig.json +18 -18
- package/titanpl-sdk/templates/server/src/action_management.rs +131 -131
- package/titanpl-sdk/templates/server/src/errors.rs +10 -10
- package/titanpl-sdk/templates/server/src/extensions.rs +640 -640
- package/titanpl-sdk/templates/server/src/utils.rs +33 -33
- package/titanpl-sdk/templates/titan/bundle.js +65 -65
- package/titanpl-sdk/templates/titan/dev.js +113 -113
- package/titanpl-sdk/templates/titan/titan.js +98 -98
- package/templates/js/server/action_map.json +0 -3
- package/templates/js/server/actions/hello.jsbundle +0 -48
- package/templates/js/server/routes.json +0 -16
- package/templates/rust/server/action_map.json +0 -3
- package/templates/rust/server/actions/hello.jsbundle +0 -47
- package/templates/rust/server/routes.json +0 -22
- package/templates/rust/server/src/actions_rust/mod.rs +0 -19
- package/templates/rust/server/src/actions_rust/rust_hello.rs +0 -14
- /package/templates/{rust → rust-js}/app/app.js +0 -0
- /package/templates/{rust → rust-js}/server/Cargo.lock +0 -0
- /package/templates/{rust → rust-js}/server/Cargo.toml +0 -0
- /package/templates/{rust → rust-js}/server/src/main.rs +0 -0
- /package/templates/{rust → rust-js}/titan/bundle.js +0 -0
- /package/templates/{rust → rust-js}/titan/titan.js +0 -0
package/titanpl-sdk/bin/run.js
CHANGED
|
@@ -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.
|
|
57
|
-
const runDir = path.join(cwd, ".titan_test_run");
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
console.log(red(`Error:
|
|
95
|
-
process.exit(1);
|
|
96
|
-
}
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
//
|
|
124
|
-
|
|
125
|
-
|
|
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
|
|
134
|
-
const
|
|
135
|
-
const
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
}
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
const
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
}
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
console.log("
|
|
212
|
-
console.log("
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
}
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
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();
|
package/titanpl-sdk/index.d.ts
CHANGED
|
@@ -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
|
+
}
|
package/titanpl-sdk/index.js
CHANGED
|
@@ -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";
|