@titanpl/cli 3.0.0 → 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 +12 -5
- package/templates/common/.env +1 -0
- package/templates/common/Dockerfile +98 -0
- package/templates/common/_dockerignore +35 -0
- package/templates/common/_gitignore +33 -0
- package/templates/common/app/t.native.d.ts +2043 -0
- package/templates/common/app/t.native.js +39 -0
- package/templates/extension/README.md +69 -0
- package/templates/extension/index.d.ts +27 -0
- package/templates/extension/index.js +17 -0
- package/templates/extension/jsconfig.json +14 -0
- package/templates/extension/native/Cargo.toml +9 -0
- package/templates/extension/native/src/lib.rs +5 -0
- package/templates/extension/package-lock.json +522 -0
- package/templates/extension/package.json +26 -0
- package/templates/extension/titan.json +18 -0
- package/templates/js/app/actions/getuser.js +9 -0
- package/templates/js/app/app.js +7 -0
- package/templates/js/eslint.config.js +5 -0
- package/templates/js/jsconfig.json +27 -0
- package/templates/js/package.json +32 -0
- package/templates/rust-js/app/actions/getuser.js +9 -0
- package/templates/rust-js/app/actions/rust_hello.rs +14 -0
- package/templates/rust-js/app/app.js +9 -0
- package/templates/rust-js/eslint.config.js +5 -0
- package/templates/rust-js/jsconfig.json +27 -0
- package/templates/rust-js/package.json +27 -0
- package/templates/rust-js/titan/bundle.js +157 -0
- package/templates/rust-js/titan/dev.js +323 -0
- package/templates/rust-js/titan/titan.js +126 -0
- package/templates/rust-ts/app/actions/getuser.ts +9 -0
- package/templates/rust-ts/app/actions/rust_hello.rs +14 -0
- package/templates/rust-ts/app/app.ts +9 -0
- package/templates/rust-ts/eslint.config.js +12 -0
- package/templates/rust-ts/package.json +29 -0
- package/templates/rust-ts/titan/bundle.js +163 -0
- package/templates/rust-ts/titan/dev.js +435 -0
- package/templates/rust-ts/titan/titan.d.ts +19 -0
- package/templates/rust-ts/titan/titan.js +124 -0
- package/templates/rust-ts/tsconfig.json +28 -0
- package/templates/ts/app/actions/getuser.ts +9 -0
- package/templates/ts/app/app.ts +7 -0
- package/templates/ts/eslint.config.js +12 -0
- package/templates/ts/package.json +35 -0
- package/templates/ts/tsconfig.json +28 -0
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@titanpl/cli",
|
|
3
|
-
"version": "
|
|
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,8 +12,16 @@
|
|
|
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",
|
|
@@ -22,8 +30,7 @@
|
|
|
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
|
|
@@ -0,0 +1,98 @@
|
|
|
1
|
+
# ================================================================
|
|
2
|
+
# STAGE 1 — Builder
|
|
3
|
+
# ================================================================
|
|
4
|
+
FROM node:20-slim AS builder
|
|
5
|
+
|
|
6
|
+
WORKDIR /app
|
|
7
|
+
|
|
8
|
+
# build-essential is required for native Titan extensions (C++ or Rust based)
|
|
9
|
+
RUN apt-get update && apt-get install -y --no-install-recommends \
|
|
10
|
+
build-essential pkg-config git ca-certificates \
|
|
11
|
+
&& rm -rf /var/lib/apt/lists/*
|
|
12
|
+
|
|
13
|
+
ENV NODE_ENV=production
|
|
14
|
+
|
|
15
|
+
COPY package.json package-lock.json* ./
|
|
16
|
+
|
|
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
|
+
|
|
38
|
+
COPY . .
|
|
39
|
+
|
|
40
|
+
# Run the Titan build step
|
|
41
|
+
RUN npx titan build
|
|
42
|
+
|
|
43
|
+
|
|
44
|
+
# ================================================================
|
|
45
|
+
# STAGE 2 — Runtime (Optimized Pure Engine)
|
|
46
|
+
# ================================================================
|
|
47
|
+
FROM ubuntu:24.04
|
|
48
|
+
|
|
49
|
+
# Use an unprivileged user for security
|
|
50
|
+
RUN groupadd -r titan && useradd -r -g titan titan
|
|
51
|
+
|
|
52
|
+
WORKDIR /app
|
|
53
|
+
|
|
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/
|
|
60
|
+
|
|
61
|
+
# titan extensions + engine
|
|
62
|
+
COPY --from=builder /app/.ext ./.ext
|
|
63
|
+
|
|
64
|
+
# runtime assets
|
|
65
|
+
COPY --from=builder /app/package.json ./package.json
|
|
66
|
+
|
|
67
|
+
# ---------------- OPTIONAL APP FOLDERS ----------------
|
|
68
|
+
# Static assets
|
|
69
|
+
# COPY --from=builder /app/app/static ./static
|
|
70
|
+
|
|
71
|
+
# Public assets
|
|
72
|
+
# COPY --from=builder /app/app/public ./public
|
|
73
|
+
|
|
74
|
+
# DB
|
|
75
|
+
# COPY --from=builder /app/app/db ./db
|
|
76
|
+
|
|
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
|
|
83
|
+
|
|
84
|
+
# Standard environment variables
|
|
85
|
+
ENV HOST=0.0.0.0
|
|
86
|
+
ENV PORT=5100
|
|
87
|
+
ENV TITAN_DEV=0
|
|
88
|
+
|
|
89
|
+
USER titan
|
|
90
|
+
EXPOSE 5100
|
|
91
|
+
|
|
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"]
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
node_modules
|
|
2
|
+
npm-debug.log
|
|
3
|
+
.git
|
|
4
|
+
.gitignore
|
|
5
|
+
|
|
6
|
+
package-lock.json
|
|
7
|
+
yarn.lock
|
|
8
|
+
|
|
9
|
+
# Titan Gravity Engine
|
|
10
|
+
dist/
|
|
11
|
+
.titan/
|
|
12
|
+
.ext/
|
|
13
|
+
|
|
14
|
+
deploy/
|
|
15
|
+
|
|
16
|
+
# Rust Build Artifacts
|
|
17
|
+
server/target/
|
|
18
|
+
Cargo.lock
|
|
19
|
+
|
|
20
|
+
# OS Files
|
|
21
|
+
.DS_Store
|
|
22
|
+
Thumbs.db
|
|
23
|
+
*.tmp
|
|
24
|
+
*.bak
|
|
25
|
+
|
|
26
|
+
# Environment & Secrets
|
|
27
|
+
.env
|
|
28
|
+
.env.local
|
|
29
|
+
.env.*.local
|
|
30
|
+
|
|
31
|
+
# IDEs
|
|
32
|
+
.vscode/
|
|
33
|
+
.idea/
|
|
34
|
+
*.swp
|
|
35
|
+
*.swo
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
# Node & Packages
|
|
2
|
+
node_modules/
|
|
3
|
+
npm-debug.log*
|
|
4
|
+
yarn-debug.log*
|
|
5
|
+
yarn-error.log*
|
|
6
|
+
package-lock.json
|
|
7
|
+
yarn.lock
|
|
8
|
+
|
|
9
|
+
# Titan Engine (Auto-generated - DO NOT COMMIT)
|
|
10
|
+
dist/
|
|
11
|
+
.titan/
|
|
12
|
+
.ext/
|
|
13
|
+
.env
|
|
14
|
+
|
|
15
|
+
# Rust Build Artifacts (If using Hybrid)
|
|
16
|
+
server/target/
|
|
17
|
+
Cargo.lock
|
|
18
|
+
|
|
19
|
+
# OS Files
|
|
20
|
+
.DS_Store
|
|
21
|
+
Thumbs.db
|
|
22
|
+
*.tmp
|
|
23
|
+
*.bak
|
|
24
|
+
|
|
25
|
+
# Environment & Secrets
|
|
26
|
+
.env.local
|
|
27
|
+
.env.*.local
|
|
28
|
+
|
|
29
|
+
# IDEs
|
|
30
|
+
.vscode/
|
|
31
|
+
.idea/
|
|
32
|
+
*.swp
|
|
33
|
+
*.swo
|