@ezetgalaxy/titan 25.12.6 → 25.12.8
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 +76 -11
- package/package.json +1 -1
- package/templates/Dockerfile +32 -13
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";
|
|
@@ -186,19 +186,84 @@ async function devServer() {
|
|
|
186
186
|
}
|
|
187
187
|
|
|
188
188
|
|
|
189
|
-
// BUILD RELEASE
|
|
189
|
+
// BUILD RELEASE — PRODUCTION READY
|
|
190
190
|
function buildProd() {
|
|
191
|
-
console.log(cyan("Titan:
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
191
|
+
console.log(cyan("Titan: Building production output..."));
|
|
192
|
+
|
|
193
|
+
const projectRoot = process.cwd();
|
|
194
|
+
|
|
195
|
+
const appJs = path.join(projectRoot, "app", "app.js");
|
|
196
|
+
const bundler = path.join(projectRoot, "titan", "bundle.js");
|
|
197
|
+
const serverDir = path.join(projectRoot, "server");
|
|
198
|
+
|
|
199
|
+
// 1) Ensure app/app.js exists
|
|
200
|
+
if (!fs.existsSync(appJs)) {
|
|
201
|
+
console.log(red("ERROR: app/app.js not found. Cannot build Titan project."));
|
|
202
|
+
process.exit(1);
|
|
203
|
+
}
|
|
204
|
+
|
|
205
|
+
// 2) Ensure bundler exists
|
|
206
|
+
if (!fs.existsSync(bundler)) {
|
|
207
|
+
console.log(red("ERROR: titan/bundle.js not found. Cannot bundle actions."));
|
|
208
|
+
process.exit(1);
|
|
209
|
+
}
|
|
210
|
+
|
|
211
|
+
// 3) Generate routes.json + action_map.json
|
|
212
|
+
console.log(cyan("→ Generating Titan metadata (routes + action_map)..."));
|
|
213
|
+
try {
|
|
214
|
+
execSync(`node app/app.js --build`, { stdio: "inherit" });
|
|
215
|
+
} catch (err) {
|
|
216
|
+
console.log(red("Failed to generate metadata via app/app.js"));
|
|
217
|
+
process.exit(1);
|
|
218
|
+
}
|
|
219
|
+
|
|
220
|
+
// 4) Bundle JS actions → .jsbundle files
|
|
221
|
+
console.log(cyan("→ Bundling Titan actions..."));
|
|
222
|
+
try {
|
|
223
|
+
execSync(`node titan/bundle.js`, { stdio: "inherit" });
|
|
224
|
+
} catch (err) {
|
|
225
|
+
console.log(red("Bundler failed. Check titan/bundle.js for errors."));
|
|
226
|
+
process.exit(1);
|
|
227
|
+
}
|
|
228
|
+
|
|
229
|
+
// 5) Ensure server/actions folder exists
|
|
230
|
+
const actionsOut = path.join(serverDir, "actions");
|
|
231
|
+
if (!fs.existsSync(actionsOut)) {
|
|
232
|
+
fs.mkdirSync(actionsOut, { recursive: true });
|
|
233
|
+
}
|
|
234
|
+
|
|
235
|
+
// 6) Copy generated bundles into server/actions
|
|
236
|
+
const builtActions = path.join(projectRoot, "titan", "actions");
|
|
237
|
+
if (fs.existsSync(builtActions)) {
|
|
238
|
+
for (const file of fs.readdirSync(builtActions)) {
|
|
239
|
+
if (file.endsWith(".jsbundle")) {
|
|
240
|
+
fs.copyFileSync(
|
|
241
|
+
path.join(builtActions, file),
|
|
242
|
+
path.join(actionsOut, file)
|
|
243
|
+
);
|
|
244
|
+
}
|
|
245
|
+
}
|
|
246
|
+
}
|
|
247
|
+
|
|
248
|
+
console.log(green("✔ Bundles copied to server/actions"));
|
|
249
|
+
|
|
250
|
+
// 7) Build Rust binary
|
|
251
|
+
console.log(cyan("→ Building Rust release binary..."));
|
|
252
|
+
try {
|
|
253
|
+
execSync(`cargo build --release`, {
|
|
254
|
+
cwd: serverDir,
|
|
255
|
+
stdio: "inherit",
|
|
256
|
+
});
|
|
257
|
+
} catch (err) {
|
|
258
|
+
console.log(red("Rust build failed."));
|
|
259
|
+
process.exit(1);
|
|
260
|
+
}
|
|
261
|
+
|
|
262
|
+
console.log(green("✔ Titan production build complete!"));
|
|
263
|
+
console.log(green("✔ Rust binary ready at server/target/release/"));
|
|
200
264
|
}
|
|
201
265
|
|
|
266
|
+
|
|
202
267
|
// START PRODUCTION
|
|
203
268
|
function startProd() {
|
|
204
269
|
const isWindows = process.platform === "win32";
|
package/package.json
CHANGED
package/templates/Dockerfile
CHANGED
|
@@ -1,40 +1,59 @@
|
|
|
1
|
-
#
|
|
1
|
+
# ================================================================
|
|
2
|
+
# STAGE 1 — Build Titan (JS → Rust)
|
|
3
|
+
# ================================================================
|
|
2
4
|
FROM rust:1.91.1 AS builder
|
|
3
5
|
|
|
4
|
-
# Install Node for Titan CLI
|
|
6
|
+
# Install Node for Titan CLI and bundler
|
|
5
7
|
RUN curl -fsSL https://deb.nodesource.com/setup_20.x | bash - \
|
|
6
8
|
&& apt-get install -y nodejs
|
|
7
9
|
|
|
8
|
-
# Install Titan CLI
|
|
10
|
+
# Install Titan CLI globally
|
|
9
11
|
RUN npm install -g @ezetgalaxy/titan
|
|
10
12
|
|
|
11
13
|
WORKDIR /app
|
|
12
14
|
|
|
13
|
-
# Copy project
|
|
15
|
+
# Copy project files into container
|
|
14
16
|
COPY . .
|
|
15
17
|
|
|
16
|
-
# Install
|
|
18
|
+
# Install JS dependencies (for bundler & DSL)
|
|
17
19
|
RUN npm install
|
|
18
20
|
|
|
19
|
-
# Build Titan metadata (routes +
|
|
21
|
+
# Build Titan metadata (routes.json + actions/*.jsbundle)
|
|
20
22
|
RUN tit build
|
|
21
23
|
|
|
22
|
-
# Build Rust release
|
|
24
|
+
# Build the Rust backend (release mode)
|
|
23
25
|
RUN cd server && cargo build --release
|
|
24
26
|
|
|
25
|
-
|
|
27
|
+
|
|
28
|
+
|
|
29
|
+
# ================================================================
|
|
30
|
+
# STAGE 2 — Runtime Image
|
|
31
|
+
# ================================================================
|
|
26
32
|
FROM debian:stable-slim
|
|
27
33
|
|
|
28
34
|
WORKDIR /app
|
|
29
35
|
|
|
30
|
-
#
|
|
36
|
+
# -------------------------------------------------------------
|
|
37
|
+
# Copy the Rust binary
|
|
38
|
+
# -------------------------------------------------------------
|
|
31
39
|
COPY --from=builder /app/server/target/release/server ./titan-server
|
|
32
40
|
|
|
33
|
-
#
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
COPY --from=builder /app/server/
|
|
41
|
+
# -------------------------------------------------------------
|
|
42
|
+
# Copy Titan routing metadata (REQUIRED)
|
|
43
|
+
# -------------------------------------------------------------
|
|
44
|
+
COPY --from=builder /app/server/routes.json ./routes.json
|
|
45
|
+
COPY --from=builder /app/server/action_map.json ./action_map.json
|
|
46
|
+
|
|
47
|
+
# -------------------------------------------------------------
|
|
48
|
+
# Copy Titan JS bundles directory (REQUIRED)
|
|
49
|
+
# -------------------------------------------------------------
|
|
50
|
+
RUN mkdir -p /app/actions
|
|
51
|
+
COPY --from=builder /app/server/actions /app/actions
|
|
52
|
+
|
|
37
53
|
|
|
54
|
+
# -------------------------------------------------------------
|
|
55
|
+
# Runtime configuration
|
|
56
|
+
# -------------------------------------------------------------
|
|
38
57
|
EXPOSE 3000
|
|
39
58
|
|
|
40
59
|
CMD ["./titan-server"]
|