@titanpl/cli 2.0.4 → 4.0.0

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@titanpl/cli",
3
- "version": "2.0.4",
3
+ "version": "4.0.0",
4
4
  "description": "The unified CLI for Titan Planet. Use it to create, manage, build, and deploy high-performance backend projects.",
5
5
  "keywords": [
6
6
  "titanpl",
@@ -12,18 +12,25 @@
12
12
  "author": "ezetgalaxy",
13
13
  "type": "module",
14
14
  "main": "index.js",
15
+ "files": [
16
+ "index.js",
17
+ "src/",
18
+ "templates/",
19
+ "README.md"
20
+ ],
15
21
  "scripts": {
16
- "test": "echo \"Error: no test specified\" && exit 1"
22
+ "test": "echo \"Error: no test specified\" && exit 1",
23
+ "prepack": "node -e \"const fs=require('fs');const p=require('path');const src=p.resolve(__dirname,'..','..','templates');const dest=p.resolve(__dirname,'templates');if(fs.existsSync(src)&&!fs.existsSync(dest)){const cp=(s,d)=>{fs.mkdirSync(d,{recursive:true});for(const f of fs.readdirSync(s)){const sp=p.join(s,f),dp=p.join(d,f);fs.lstatSync(sp).isDirectory()?cp(sp,dp):fs.copyFileSync(sp,dp)}};cp(src,dest);console.log('Copied templates for packaging')}\"",
24
+ "postpack": "node -e \"const fs=require('fs');const p=require('path');const d=p.resolve(__dirname,'templates');if(fs.existsSync(d)){fs.rmSync(d,{recursive:true,force:true});console.log('Cleaned up templates after packaging')}\""
17
25
  },
18
26
  "bin": {
19
27
  "titan": "./index.js",
20
- "titanpl": "./index.js",
28
+ "t8n": "./index.js",
21
29
  "tit": "./index.js"
22
30
  },
23
31
  "optionalDependencies": {
24
32
  "@titanpl/engine-win32-x64": "2.0.4",
25
- "@titanpl/engine-linux-x64": "2.0.4",
26
- "@titanpl/engine-darwin-arm64": "2.0.4"
33
+ "@titanpl/engine-linux-x64": "2.0.4"
27
34
  },
28
35
  "dependencies": {
29
36
  "@titanpl/packet": "2.0.4",
@@ -31,4 +38,4 @@
31
38
  "commander": "^11.0.0",
32
39
  "chalk": "^4.1.2"
33
40
  }
34
- }
41
+ }
@@ -0,0 +1 @@
1
+ TITAN_DEV=1
@@ -1,45 +1,68 @@
1
1
  # ================================================================
2
- # STAGE 1 — Build TitanPl
2
+ # STAGE 1 — Builder
3
3
  # ================================================================
4
- FROM node:20.20.0-slim AS builder
4
+ FROM node:20-slim AS builder
5
5
 
6
6
  WORKDIR /app
7
7
 
8
- # Install native dependencies in case of native modules or hybrids
8
+ # build-essential is required for native Titan extensions (C++ or Rust based)
9
9
  RUN apt-get update && apt-get install -y --no-install-recommends \
10
- curl ca-certificates build-essential pkg-config libssl-dev git bash \
10
+ build-essential pkg-config git ca-certificates \
11
11
  && rm -rf /var/lib/apt/lists/*
12
12
 
13
13
  ENV NODE_ENV=production
14
14
 
15
- # ---------- Node Dependencies ----------
16
15
  COPY package.json package-lock.json* ./
17
- RUN npm install
18
16
 
19
- # ---------- Copy Project ----------
17
+ # Install with optional dependencies so it grabs the correct engine for the Linux builder
18
+ RUN npm install --include=optional
19
+
20
+ # ------------------------------------------------
21
+ # Extract Titan Extensions (packages with titan.json)
22
+ # ------------------------------------------------
23
+ RUN mkdir -p /app/.ext && \
24
+ find node_modules -mindepth 2 -maxdepth 3 -type f -name "titan.json" | while read file; do \
25
+ pkg_dir=$(dirname "$file"); \
26
+ pkg_name=$(basename "$pkg_dir"); \
27
+ echo "Extracting Titan extension: $pkg_name"; \
28
+ cp -a "$pkg_dir" "/app/.ext/$pkg_name"; \
29
+ rm -rf "/app/.ext/$pkg_name/node_modules"; \
30
+ done
31
+
32
+ # ------------------------------------------------
33
+ # Copy ANY installed Titan Engine (Architecture agnostic)
34
+ # ------------------------------------------------
35
+ RUN mkdir -p /app/.ext/@titanpl && \
36
+ cp -r node_modules/@titanpl/engine-linux-* /app/.ext/@titanpl/
37
+
20
38
  COPY . .
21
39
 
22
- # Run the Titan build command (compiles dist/)
40
+ # Run the Titan build step
23
41
  RUN npx titan build
24
42
 
43
+
25
44
  # ================================================================
26
- # STAGE 2 — Gravity Engine (Production Ready)
45
+ # STAGE 2 — Runtime (Optimized Pure Engine)
27
46
  # ================================================================
28
- FROM node:20.20.0-slim
47
+ FROM ubuntu:24.04
48
+
49
+ # Use an unprivileged user for security
50
+ RUN groupadd -r titan && useradd -r -g titan titan
29
51
 
30
52
  WORKDIR /app
31
53
 
32
- # Ensure we have required OS-level certs if doing network fetching
33
- RUN apt-get update && \
34
- apt-get install -y --no-install-recommends ca-certificates curl && \
35
- rm -rf /var/lib/apt/lists/*
54
+ RUN apt-get update && apt-get install -y --no-install-recommends \
55
+ ca-certificates curl \
56
+ && rm -rf /var/lib/apt/lists/*
57
+
58
+ # copy dist contents into /app/dist
59
+ COPY --from=builder /app/dist/ ./dist/
36
60
 
37
- # ---- Copy Production package.json and install ONLY dependencies ----
38
- COPY package.json package-lock.json* ./
39
- RUN npm ci --omit=dev
61
+ # titan extensions + engine
62
+ COPY --from=builder /app/.ext ./.ext
40
63
 
41
- # ---- Copy Dist Build from Builder ----
42
- COPY --from=builder /app/dist ./dist
64
+ # runtime assets
65
+ COPY --from=builder /app/package.json ./package.json
43
66
 
44
67
  # ---------------- OPTIONAL APP FOLDERS ----------------
45
68
  # Static assets
@@ -51,16 +74,25 @@ COPY --from=builder /app/dist ./dist
51
74
  # DB
52
75
  # COPY --from=builder /app/app/db ./db
53
76
 
54
- # ---- Create User After Copy ----
55
- RUN useradd -m titan && chown -R titan:titan /app
56
- USER titan
77
+ # CRITICAL SYSTEM SETUP:
78
+ # 1. Mandatory .env file (Engine requires it for config parsing)
79
+ # 2. Node modules symlink for extension JS dependency resolution
80
+ RUN echo "TITAN_DEV=0" > .env && \
81
+ ln -s /app/.ext /app/node_modules && \
82
+ chown -R titan:titan /app
57
83
 
58
- # ---- Platform Defaults ----
84
+ # Standard environment variables
59
85
  ENV HOST=0.0.0.0
60
86
  ENV PORT=5100
61
87
  ENV TITAN_DEV=0
62
88
 
89
+ USER titan
63
90
  EXPOSE 5100
64
91
 
65
- # ---- Force Foreground Process via Titan CLI ----
66
- CMD ["npx", "titan", "start"]
92
+ # Health check to ensure the server is alive
93
+ HEALTHCHECK --interval=30s --timeout=5s --start-period=5s --retries=3 \
94
+ CMD curl -f http://localhost:5100/ || exit 1
95
+
96
+ # DYNAMIC ENTRYPOINT: Finds the correct architecture binary and starts it
97
+ # This allows the SAME image to work on x64 vs ARM64 servers.
98
+ CMD ["/bin/sh", "-c", "exec $(find .ext/@titanpl/engine-linux-* -name titan-server -type f | head -n 1) run dist"]
@@ -13,6 +13,10 @@
13
13
  "@titanpl/node": "latest",
14
14
  "@titanpl/packet": "2.0.4"
15
15
  },
16
+ "optionalDependencies": {
17
+ "@titanpl/engine-linux-x64": "2.0.5",
18
+ "@titanpl/engine-win32-x64": "2.0.3"
19
+ },
16
20
  "scripts": {
17
21
  "build": "titan build",
18
22
  "dev": "titan dev",
@@ -25,4 +29,4 @@
25
29
  "eslint-plugin-titanpl": "latest"
26
30
  },
27
31
  "version": "2.0.4"
28
- }
32
+ }
@@ -14,6 +14,11 @@
14
14
  "@titanpl/packet": "2.0.4",
15
15
  "typescript": "^5.0.0"
16
16
  },
17
+ "optionalDependencies": {
18
+ "@titanpl/engine-linux-arm64": "2.0.5",
19
+ "@titanpl/engine-linux-x64": "2.0.5",
20
+ "@titanpl/engine-win32-x64": "2.0.3"
21
+ },
17
22
  "scripts": {
18
23
  "build": "titan build",
19
24
  "dev": "titan dev",
@@ -27,4 +32,4 @@
27
32
  "@typescript-eslint/parser": "^8.54.0"
28
33
  },
29
34
  "version": "2.0.4"
30
- }
35
+ }