@ezetgalaxy/titan 25.11.9 → 25.12.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/index.js +47 -23
- package/package.json +2 -2
package/index.js
CHANGED
|
@@ -108,32 +108,51 @@ async function devServer() {
|
|
|
108
108
|
let rustProcess = null;
|
|
109
109
|
|
|
110
110
|
function startRust() {
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
111
|
+
return new Promise((resolve) => {
|
|
112
|
+
// if server already running → kill it
|
|
113
|
+
if (rustProcess) {
|
|
114
|
+
console.log("[Titan] Killing old Rust server...");
|
|
115
|
+
|
|
116
|
+
if (process.platform === "win32") {
|
|
117
|
+
const killer = spawn("taskkill", ["/PID", rustProcess.pid, "/T", "/F"], {
|
|
118
|
+
stdio: "ignore",
|
|
119
|
+
shell: true,
|
|
120
|
+
});
|
|
121
|
+
|
|
122
|
+
killer.on("exit", () => {
|
|
123
|
+
rustProcess = launchRust(resolve);
|
|
124
|
+
});
|
|
125
|
+
} else {
|
|
126
|
+
rustProcess.kill();
|
|
127
|
+
rustProcess.on("close", () => {
|
|
128
|
+
rustProcess = launchRust(resolve);
|
|
129
|
+
});
|
|
130
|
+
}
|
|
120
131
|
} else {
|
|
121
|
-
rustProcess
|
|
132
|
+
rustProcess = launchRust(resolve);
|
|
122
133
|
}
|
|
123
|
-
}
|
|
134
|
+
});
|
|
135
|
+
}
|
|
124
136
|
|
|
125
|
-
|
|
126
|
-
|
|
137
|
+
function launchRust(done) {
|
|
138
|
+
const processHandle = spawn("cargo", ["run"], {
|
|
127
139
|
cwd: path.join(process.cwd(), "server"),
|
|
128
140
|
stdio: "inherit",
|
|
129
141
|
shell: true,
|
|
130
142
|
});
|
|
131
143
|
|
|
132
|
-
|
|
133
|
-
|
|
144
|
+
processHandle.on("spawn", () => {
|
|
145
|
+
setTimeout(done, 200); // wait for OS to release port
|
|
146
|
+
});
|
|
147
|
+
|
|
148
|
+
processHandle.on("close", (code) => {
|
|
149
|
+
console.log(`[Titan] Rust server exited: ${code}`);
|
|
134
150
|
});
|
|
151
|
+
|
|
152
|
+
return processHandle;
|
|
135
153
|
}
|
|
136
154
|
|
|
155
|
+
|
|
137
156
|
function rebuild() {
|
|
138
157
|
console.log(cyan("Titan: Regenerating routes..."));
|
|
139
158
|
execSync("node app/app.js", { stdio: "inherit" });
|
|
@@ -200,7 +219,8 @@ function startProd() {
|
|
|
200
219
|
// TITAN UPDATE — Upgrade titan/ runtime
|
|
201
220
|
// ------------------------------------------
|
|
202
221
|
function updateTitan() {
|
|
203
|
-
const
|
|
222
|
+
const projectRoot = process.cwd();
|
|
223
|
+
const projectTitan = path.join(projectRoot, "titan");
|
|
204
224
|
const cliTitan = path.join(__dirname, "templates", "titan");
|
|
205
225
|
|
|
206
226
|
if (!fs.existsSync(projectTitan)) {
|
|
@@ -211,26 +231,30 @@ function updateTitan() {
|
|
|
211
231
|
|
|
212
232
|
console.log(cyan("Titan: Updating runtime files..."));
|
|
213
233
|
|
|
214
|
-
|
|
215
|
-
const backupDir = path.join(process.cwd(), `titan_backup_${Date.now()}`);
|
|
234
|
+
const backupDir = path.join(projectRoot, `titan_backup_${Date.now()}`);
|
|
216
235
|
fs.renameSync(projectTitan, backupDir);
|
|
217
|
-
|
|
218
236
|
console.log(green(`✔ Backup created → ${backupDir}`));
|
|
219
237
|
|
|
220
238
|
copyDir(cliTitan, projectTitan);
|
|
221
239
|
|
|
240
|
+
const projectTemplateRoot = path.join(__dirname, "templates");
|
|
241
|
+
|
|
222
242
|
[".gitignore", ".dockerignore", "Dockerfile"].forEach((file) => {
|
|
223
|
-
const src = path.join(
|
|
224
|
-
const dest = path.join(
|
|
225
|
-
if (fs.existsSync(src)) fs.copyFileSync(src, dest);
|
|
226
|
-
});
|
|
243
|
+
const src = path.join(projectTemplateRoot, file);
|
|
244
|
+
const dest = path.join(projectRoot, file);
|
|
227
245
|
|
|
246
|
+
if (fs.existsSync(src)) {
|
|
247
|
+
fs.copyFileSync(src, dest);
|
|
248
|
+
console.log(green(`✔ Updated ${file}`));
|
|
249
|
+
}
|
|
250
|
+
});
|
|
228
251
|
|
|
229
252
|
console.log(green("✔ Titan runtime updated successfully!"));
|
|
230
253
|
console.log(cyan("Your project now has the latest Titan features."));
|
|
231
254
|
}
|
|
232
255
|
|
|
233
256
|
|
|
257
|
+
|
|
234
258
|
// ROUTER
|
|
235
259
|
switch (cmd) {
|
|
236
260
|
case "init":
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ezetgalaxy/titan",
|
|
3
|
-
"version": "25.
|
|
3
|
+
"version": "25.12.1",
|
|
4
4
|
"description": "JavaScript backend framework that compiles your JS into a Rust + Axum server.",
|
|
5
5
|
"license": "ISC",
|
|
6
6
|
"author": "ezetgalaxy",
|
|
@@ -49,4 +49,4 @@
|
|
|
49
49
|
"chokidar": "^5.0.0",
|
|
50
50
|
"esbuild": "^0.27.1"
|
|
51
51
|
}
|
|
52
|
-
}
|
|
52
|
+
}
|