titanpl 1.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/LICENSE +15 -0
- package/README.md +254 -0
- package/index.js +24 -0
- package/package.json +83 -0
- package/packages/cli/index.js +141 -0
- package/templates/common/.env +1 -0
- package/templates/common/Dockerfile +66 -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 +65 -0
- package/templates/extension/index.d.ts +27 -0
- package/templates/extension/index.js +28 -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 +27 -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 +29 -0
- package/templates/ts/tsconfig.json +28 -0
- package/titanpl-sdk/LICENSE +15 -0
- package/titanpl-sdk/README.md +109 -0
- package/titanpl-sdk/assets/titanpl-sdk.png +0 -0
- package/titanpl-sdk/bin/run.js +274 -0
- package/titanpl-sdk/index.js +5 -0
- package/titanpl-sdk/package-lock.json +28 -0
- package/titanpl-sdk/package.json +40 -0
- package/titanpl-sdk/templates/app/actions/hello.js +5 -0
- package/titanpl-sdk/templates/app/app.js +7 -0
- package/titanpl-sdk/templates/jsconfig.json +19 -0
- package/titanpl-sdk/templates/server/Cargo.toml +52 -0
- package/titanpl-sdk/templates/server/src/action_management.rs +175 -0
- package/titanpl-sdk/templates/server/src/errors.rs +12 -0
- package/titanpl-sdk/templates/server/src/extensions/builtin.rs +1038 -0
- package/titanpl-sdk/templates/server/src/extensions/external.rs +338 -0
- package/titanpl-sdk/templates/server/src/extensions/mod.rs +580 -0
- package/titanpl-sdk/templates/server/src/extensions/titan_core.js +249 -0
- package/titanpl-sdk/templates/server/src/fast_path.rs +719 -0
- package/titanpl-sdk/templates/server/src/main.rs +607 -0
- package/titanpl-sdk/templates/server/src/runtime.rs +284 -0
- package/titanpl-sdk/templates/server/src/utils.rs +33 -0
- package/titanpl-sdk/templates/titan/bundle.js +259 -0
- package/titanpl-sdk/templates/titan/dev.js +390 -0
- package/titanpl-sdk/templates/titan/error-box.js +277 -0
- package/titanpl-sdk/templates/titan/titan.js +129 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
ISC License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2025, Ezet Galaxy
|
|
4
|
+
|
|
5
|
+
Permission to use, copy, modify, and/or distribute this software for any
|
|
6
|
+
purpose with or without fee is hereby granted, provided that the above
|
|
7
|
+
copyright notice and this permission notice appear in all copies.
|
|
8
|
+
|
|
9
|
+
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
|
|
10
|
+
WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
|
|
11
|
+
MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
|
|
12
|
+
ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
|
|
13
|
+
WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
|
|
14
|
+
ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
|
|
15
|
+
OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,254 @@
|
|
|
1
|
+
<p align="center">
|
|
2
|
+
<a href="https://titan-docs-ez.vercel.app/" target="_blank">
|
|
3
|
+
<img src="https://i.ibb.co/VpBsTg6m/tpl-Logo.png" width="120" alt="TitanPl Logo" />
|
|
4
|
+
</a>
|
|
5
|
+
</p>
|
|
6
|
+
|
|
7
|
+
<p align="center">
|
|
8
|
+
You write zero Rust. TitanPl handles routing, bundling, runtime execution, hot reload, and deployment — <br> all powered by <a href="https://rust-lang.org/">Rust</a> under the hood.
|
|
9
|
+
</p>
|
|
10
|
+
|
|
11
|
+
<p align="center">
|
|
12
|
+
<a href="https://www.npmjs.com/package/@ezetgalaxy/titan">
|
|
13
|
+
<img src="https://img.shields.io/npm/v/@ezetgalaxy/titan?style=for-the-badge&logo=npm&logoColor=white" />
|
|
14
|
+
</a>
|
|
15
|
+
|
|
16
|
+
<img src="https://img.shields.io/badge/Runtime-Gravity(V8)%20%26%20Rust%20Tokio-1f2937?style=for-the-badge" />
|
|
17
|
+
|
|
18
|
+
<img src="https://img.shields.io/badge/Powered%20By%20Rust%20Axum-DEA584?style=for-the-badge&logo=rust&logoColor=black" />
|
|
19
|
+
|
|
20
|
+
<a href="https://discord.gg/mPDaTRtP">
|
|
21
|
+
<img src="https://img.shields.io/badge/Join-5865F2?style=for-the-badge&logo=discord&logoColor=white" />
|
|
22
|
+
</a>
|
|
23
|
+
|
|
24
|
+
<a href="https://x.com/TitanPl">
|
|
25
|
+
<img src="https://img.shields.io/badge/Follow-000000?style=for-the-badge&logo=x&logoColor=white" />
|
|
26
|
+
</a>
|
|
27
|
+
|
|
28
|
+
</p>
|
|
29
|
+
|
|
30
|
+
|
|
31
|
+
|
|
32
|
+
|
|
33
|
+
<h1> Description
|
|
34
|
+
</h1>
|
|
35
|
+
|
|
36
|
+
Titan Planet is a JavaScript/TypeScript-first Backend Framework that compiles your application into a single, high-performance native binary. It embeds it's own Gravity (V8) JavaScript runtime directly into a specialized Rust + Axum server.
|
|
37
|
+
|
|
38
|
+
**TypeScript Precision. JavaScript Simplicity. Native Rust Power. Zero Configuration.**
|
|
39
|
+
|
|
40
|
+
<p>
|
|
41
|
+
|
|
42
|
+
<img src="https://img.shields.io/badge/TypeScript-3178C6?style=for-the-badge&logo=typescript&logoColor=white" />
|
|
43
|
+
<img src="https://img.shields.io/badge/JavaScript-F7DF1E?style=for-the-badge&logo=javascript&logoColor=black" />
|
|
44
|
+
<img src="https://img.shields.io/badge/Rust-DEA584?style=for-the-badge&logo=rust&logoColor=black" />
|
|
45
|
+
</p>
|
|
46
|
+
|
|
47
|
+
|
|
48
|
+
## Why Titan?
|
|
49
|
+
|
|
50
|
+
Titan Planet compiles your JavaScript or TypeScript application into a **single native Rust binary**.
|
|
51
|
+
|
|
52
|
+
It embeds a V8 runtime inside a Rust + Axum server — giving you:
|
|
53
|
+
|
|
54
|
+
- ⚡ Native-level performance
|
|
55
|
+
- 📦 Single binary deployment
|
|
56
|
+
- 🧠 Strict TypeScript enforcement
|
|
57
|
+
- 🛡 Zero type errors before runtime
|
|
58
|
+
- 🚀 No DevOps configuration required
|
|
59
|
+
|
|
60
|
+
Start with pure TypeScript.
|
|
61
|
+
Drop into Rust when you need extreme performance.
|
|
62
|
+
Titan handles the integration automatically.
|
|
63
|
+
|
|
64
|
+
<p>
|
|
65
|
+
<a href="https://titan-docs-ez.vercel.app/docs" target="_blank">
|
|
66
|
+
<img src="https://i.ibb.co/VpBsTg6m/tpl-Logo.png" width="28" style="vertical-align:middle;" />
|
|
67
|
+
<strong style="vertical-align:middle;"> Documentation</strong>
|
|
68
|
+
</p>
|
|
69
|
+
<p>
|
|
70
|
+
<a href="https://titan-docs-ez.vercel.app/docs/runtime-architecture" target="_blank">
|
|
71
|
+
<strong style="vertical-align:middle;">Gravity Runtime</strong>
|
|
72
|
+
</a>
|
|
73
|
+
</p>
|
|
74
|
+
|
|
75
|
+
<p>
|
|
76
|
+
<a href="https://titan-docs-ez.vercel.app/docs/14-drift" target="_blank">
|
|
77
|
+
<strong style="vertical-align:middle;">Drift</strong>
|
|
78
|
+
</a>
|
|
79
|
+
</p>
|
|
80
|
+
|
|
81
|
+
# 🚀 Quick Start
|
|
82
|
+
### 1. Prerequisites
|
|
83
|
+
* **Rust** (latest stable): [Install Rust](https://rust-lang.org/tools/install/)
|
|
84
|
+
* **Node.js** (v18+): Required for CLI and JS tooling.
|
|
85
|
+
|
|
86
|
+
### 2. Install CLI
|
|
87
|
+
```bash
|
|
88
|
+
npm install -g @ezetgalaxy/titan
|
|
89
|
+
```
|
|
90
|
+
|
|
91
|
+
### 3. Initialize & Run
|
|
92
|
+
Titan guides you through selecting the perfect architecture for your needs.
|
|
93
|
+
|
|
94
|
+
```bash
|
|
95
|
+
titan init my-app
|
|
96
|
+
```
|
|
97
|
+
|
|
98
|
+
**Select your language:**
|
|
99
|
+
1. `JavaScript` (Fast, lightweight)
|
|
100
|
+
2. `TypeScript` (Strict, typed)
|
|
101
|
+
|
|
102
|
+
**Select your architecture:**
|
|
103
|
+
1. `Standard` (Pure JS/TS)
|
|
104
|
+
2. `Rust + JS/TS (Hybrid)` (High-performance native actions)
|
|
105
|
+
|
|
106
|
+
This creates one of four isolated environments:
|
|
107
|
+
* **Standard JS:** Lightweight server, zero Rust overhead.
|
|
108
|
+
* **Standard TS:** Strict server, zero Rust overhead.
|
|
109
|
+
* **Hybrid JS:** Full Rust integration + JS flexibility.
|
|
110
|
+
* **Hybrid TS:** Full Rust integration + TS strictness.
|
|
111
|
+
|
|
112
|
+
Inside your project:
|
|
113
|
+
```bash
|
|
114
|
+
cd my-app
|
|
115
|
+
titan dev
|
|
116
|
+
```
|
|
117
|
+
|
|
118
|
+
You'll see the Titan Dev Server spin up:
|
|
119
|
+
```
|
|
120
|
+
Titan Planet v26.16.0 [ Dev Mode ]
|
|
121
|
+
|
|
122
|
+
Type: Rust + TS Actions
|
|
123
|
+
Hot Reload: Enabled
|
|
124
|
+
Strict Mode: Active 🛡️
|
|
125
|
+
|
|
126
|
+
• Preparing runtime... Done
|
|
127
|
+
• A new orbit is ready for your app in 0.9s
|
|
128
|
+
• Your app is now orbiting Titan Planet
|
|
129
|
+
```
|
|
130
|
+
|
|
131
|
+
|
|
132
|
+
# ⚡ Hybrid Action System
|
|
133
|
+
|
|
134
|
+
Titan is unique because it allows you to write endpoints in **JavaScript, TypeScript, and Rust** within the same project.
|
|
135
|
+
|
|
136
|
+
| Feature | Status | Notes |
|
|
137
|
+
| :--- | :--- | :--- |
|
|
138
|
+
| **Standard JavaScript** | ✅ Stable | Production Ready |
|
|
139
|
+
| **Standard TypeScript** | 🚧 Beta | **Ready for Dev**, Production Under Testing |
|
|
140
|
+
| **Rust + JS (Hybrid)** | 🧪 Experimental | **Dev Only**, Production Under Testing |
|
|
141
|
+
| **Rust + TS (Hybrid)** | 🧪 Experimental | **Dev Only**, Production Under Testing |
|
|
142
|
+
|
|
143
|
+
### 🔵 TypeScript Actions (`app/actions/hello.ts`)
|
|
144
|
+
Fully typed, strict, and auto-compiled.
|
|
145
|
+
|
|
146
|
+
```typescript
|
|
147
|
+
import { defineAction } from "../../titan/titan";
|
|
148
|
+
|
|
149
|
+
interface HelloResponse {
|
|
150
|
+
message: string;
|
|
151
|
+
user_name: string;
|
|
152
|
+
}
|
|
153
|
+
|
|
154
|
+
// "defineAction" provides automatic type inference for "req"
|
|
155
|
+
export const hello = defineAction((req): HelloResponse => {
|
|
156
|
+
t.log("Handling request with strict types...");
|
|
157
|
+
|
|
158
|
+
return {
|
|
159
|
+
message: "Hello from TypeScript!",
|
|
160
|
+
user_name: req.body.name || "Guest"
|
|
161
|
+
};
|
|
162
|
+
});
|
|
163
|
+
```
|
|
164
|
+
|
|
165
|
+
### 🟡 JavaScript Actions (`app/actions/hello.js`)
|
|
166
|
+
Perfect for business logic, rapid prototyping, and IO-bound tasks.
|
|
167
|
+
```javascript
|
|
168
|
+
export const hello = defineAction((req) => {
|
|
169
|
+
t.log("Handling user request...");
|
|
170
|
+
return {
|
|
171
|
+
message: "Hello from JavaScript!",
|
|
172
|
+
user_id: req.params.id
|
|
173
|
+
};
|
|
174
|
+
});
|
|
175
|
+
```
|
|
176
|
+
|
|
177
|
+
### 🔴 Rust Actions (Beta)
|
|
178
|
+
Perfect for heavy computation, encryption, image processing, or low-level system access.
|
|
179
|
+
> **Note:** The Native Rust Action API is currently in **Beta**.
|
|
180
|
+
```rust
|
|
181
|
+
use axum::{response::{IntoResponse, Json}, http::Request, body::Body};
|
|
182
|
+
use serde_json::json;
|
|
183
|
+
|
|
184
|
+
pub async fn run(req: Request<Body>) -> impl IntoResponse {
|
|
185
|
+
let result = heavy_computation();
|
|
186
|
+
t.log("Processed 1M records in Rust");
|
|
187
|
+
Json(json!({ "result": result }))
|
|
188
|
+
}
|
|
189
|
+
```
|
|
190
|
+
|
|
191
|
+
**Titan automatically detects, compiles, and routes all types.**
|
|
192
|
+
* `.ts` files are type-checked and compiled with esbuild.
|
|
193
|
+
* `.js` files are bundled with esbuild.
|
|
194
|
+
* `.rs` files are compiled into the native binary.
|
|
195
|
+
* All share the same `routes.json` configuration.
|
|
196
|
+
|
|
197
|
+
---
|
|
198
|
+
|
|
199
|
+
# 🛡️ Strict Type Safety & Error Logs
|
|
200
|
+
|
|
201
|
+
Titan prioritizes code quality by enforcing **Strict TypeScript** logic during development.
|
|
202
|
+
|
|
203
|
+
If `titan dev` detects a type error, the server **will not run**. This ensures you never ship or test broken code.
|
|
204
|
+
|
|
205
|
+
### Sample Error Output
|
|
206
|
+
When a type error occurs, Titan pauses execution and provides a clear, actionable log:
|
|
207
|
+
|
|
208
|
+
```text
|
|
209
|
+
[Titan] ❌ TypeScript Error:
|
|
210
|
+
app/actions/payment.ts(12,5): error TS2322: Type 'string' is not assignable to type 'number'.
|
|
211
|
+
|
|
212
|
+
10 | const amount: number = req.body.amount;
|
|
213
|
+
11 |
|
|
214
|
+
> 12 | processPayment( "100" ); // Error here
|
|
215
|
+
| ^^^^^^^^^^^^^^^^^^^^^^^
|
|
216
|
+
|
|
217
|
+
[Titan] 🛑 Server paused due to type errors. Fix them to resume.
|
|
218
|
+
```
|
|
219
|
+
|
|
220
|
+
Once fixed, the server automatically resumes.
|
|
221
|
+
|
|
222
|
+
---
|
|
223
|
+
|
|
224
|
+
# ✨ Core Capabilities
|
|
225
|
+
|
|
226
|
+
### 🔌 Unified Runtime API (`t`)
|
|
227
|
+
All actions (JS/TS/Rust) have access to the powerful `t` namespace:
|
|
228
|
+
|
|
229
|
+
* `t.fetch(url, options)` — High-performance HTTP client
|
|
230
|
+
* `t.log(msg)` — Sandboxed, structured logging
|
|
231
|
+
* `t.jwt.sign / verify` — Fast JWT operations
|
|
232
|
+
* `t.password.hash / verify` — Secure password handling
|
|
233
|
+
* `t.db` — Database access
|
|
234
|
+
---
|
|
235
|
+
|
|
236
|
+
### 🧩 Extensions System
|
|
237
|
+
Extend the runtime with custom Rust engines using **Titan Extensions**.
|
|
238
|
+
* `titan create ext <name>`: Scaffold a new extension.
|
|
239
|
+
* `titan run ext`: Test your extension in a lightweight harness.
|
|
240
|
+
|
|
241
|
+
---
|
|
242
|
+
|
|
243
|
+
# 📦 Deployment
|
|
244
|
+
|
|
245
|
+
Titan compiles your entire app—JS/TS code, Rust code, and server logic—into a **single executable**.
|
|
246
|
+
|
|
247
|
+
* **Tiny Docker Images**: Alpine-based, ~20MB compressed.
|
|
248
|
+
* **Instant Startup**: No node_modules overhead.
|
|
249
|
+
* **Secure**: No access to system APIs from JS unless explicitly bridged.
|
|
250
|
+
|
|
251
|
+
---
|
|
252
|
+
|
|
253
|
+
|
|
254
|
+
**To know more read docs 💟 **Titan Planet docs:** https://titan-docs-ez.vercel.app/docs**
|
package/index.js
ADDED
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
|
|
3
|
+
/*
|
|
4
|
+
* The Titan CLI has been completely rewritten and moved to packages/cli.
|
|
5
|
+
* This file remains for backward compatibility and redirects execution to the new CLI.
|
|
6
|
+
*/
|
|
7
|
+
import path from "path";
|
|
8
|
+
import { fileURLToPath } from "url";
|
|
9
|
+
import { spawn } from "child_process";
|
|
10
|
+
|
|
11
|
+
const __filename = fileURLToPath(import.meta.url);
|
|
12
|
+
const __dirname = path.dirname(__filename);
|
|
13
|
+
|
|
14
|
+
const newCliPath = path.join(__dirname, "packages", "cli", "index.js");
|
|
15
|
+
|
|
16
|
+
const args = process.argv.slice(2);
|
|
17
|
+
const child = spawn("node", [newCliPath, ...args], {
|
|
18
|
+
stdio: "inherit",
|
|
19
|
+
cwd: process.cwd()
|
|
20
|
+
});
|
|
21
|
+
|
|
22
|
+
child.on("close", (code) => {
|
|
23
|
+
process.exit(code);
|
|
24
|
+
});
|
package/package.json
ADDED
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "titanpl",
|
|
3
|
+
"version": "1.0.0",
|
|
4
|
+
"description": "Titan Planet is a JavaScript-first backend framework that embeds JS actions into a Rust + Axum server and ships as a single native binary. Routes are compiled to static metadata; only actions run in the embedded JS runtime. No Node.js. No event loop in production.",
|
|
5
|
+
"license": "ISC",
|
|
6
|
+
"author": "ezetgalaxy",
|
|
7
|
+
"type": "module",
|
|
8
|
+
"main": "index.js",
|
|
9
|
+
"bin": {
|
|
10
|
+
"tit": "./packages/cli/index.js",
|
|
11
|
+
"titan": "./packages/cli/index.js"
|
|
12
|
+
},
|
|
13
|
+
"workspaces": [
|
|
14
|
+
"packages/*",
|
|
15
|
+
"testapp"
|
|
16
|
+
],
|
|
17
|
+
"files": [
|
|
18
|
+
"index.js",
|
|
19
|
+
"templates/",
|
|
20
|
+
"titanpl-sdk",
|
|
21
|
+
"README.md"
|
|
22
|
+
],
|
|
23
|
+
"keywords": [
|
|
24
|
+
"titan",
|
|
25
|
+
"titanpl",
|
|
26
|
+
"t8n",
|
|
27
|
+
"tpl",
|
|
28
|
+
"tgrv",
|
|
29
|
+
"titanjs",
|
|
30
|
+
"ezetgalaxy",
|
|
31
|
+
"framework",
|
|
32
|
+
"javascript",
|
|
33
|
+
"nodejs",
|
|
34
|
+
"backend",
|
|
35
|
+
"web-framework",
|
|
36
|
+
"api-framework",
|
|
37
|
+
"rust",
|
|
38
|
+
"rust-backend",
|
|
39
|
+
"axum",
|
|
40
|
+
"boa",
|
|
41
|
+
"js-to-rust",
|
|
42
|
+
"server",
|
|
43
|
+
"high-performance",
|
|
44
|
+
"native-performance",
|
|
45
|
+
"microservices",
|
|
46
|
+
"cli",
|
|
47
|
+
"esbuild",
|
|
48
|
+
"modern-backend",
|
|
49
|
+
"edge-computing",
|
|
50
|
+
"super-backend"
|
|
51
|
+
],
|
|
52
|
+
"scripts": {
|
|
53
|
+
"cli-helper": "node ./scripts/cli-helper.mjs",
|
|
54
|
+
"create-ext": "titan create ext",
|
|
55
|
+
"init": "rm -rf build && node index.js init build",
|
|
56
|
+
"build": "cd build && node ../index.js build",
|
|
57
|
+
"dev": "cd build && node ../index.js dev",
|
|
58
|
+
"start": "cd build && node ../index.js start",
|
|
59
|
+
"help": "cd build && node ../index.js help",
|
|
60
|
+
"update": "cd build && node ../index.js update",
|
|
61
|
+
"test": "vitest run",
|
|
62
|
+
"test:watch": "vitest",
|
|
63
|
+
"test:coverage": "vitest run --coverage",
|
|
64
|
+
"test:cov": "vitest run --coverage",
|
|
65
|
+
"test:ui": "vitest --ui",
|
|
66
|
+
"test:e2e": "vitest run --config vitest.config.e2e.ts",
|
|
67
|
+
"test:e2e:watch": "vitest --config vitest.config.e2e.ts",
|
|
68
|
+
"test:e2e:ui": "vitest --ui --config vitest.config.e2e.ts",
|
|
69
|
+
"test:all": "vitest run && vitest run --config vitest.config.e2e.ts"
|
|
70
|
+
},
|
|
71
|
+
"dependencies": {
|
|
72
|
+
"@titanpl/core": "26.16.0",
|
|
73
|
+
"@titanpl/node": "26.16.0",
|
|
74
|
+
"chokidar": "^5.0.0",
|
|
75
|
+
"esbuild": "^0.27.2",
|
|
76
|
+
"prompts": "^2.4.2"
|
|
77
|
+
},
|
|
78
|
+
"devDependencies": {
|
|
79
|
+
"@vitest/coverage-v8": "^4.0.17",
|
|
80
|
+
"@vitest/ui": "^4.0.17",
|
|
81
|
+
"vitest": "^4.0.17"
|
|
82
|
+
}
|
|
83
|
+
}
|
|
@@ -0,0 +1,141 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
|
|
3
|
+
import fs from "fs";
|
|
4
|
+
import path from "path";
|
|
5
|
+
import { fileURLToPath } from "url";
|
|
6
|
+
|
|
7
|
+
import { buildCommand } from "./src/commands/build.js";
|
|
8
|
+
import { devCommand } from "./src/commands/dev.js";
|
|
9
|
+
import { startCommand } from "./src/commands/start.js";
|
|
10
|
+
import { migrateCommand } from "./src/commands/migrate.js";
|
|
11
|
+
import { initCommand } from "./src/commands/init.js";
|
|
12
|
+
|
|
13
|
+
/* -------------------------------------------------------
|
|
14
|
+
* Resolve __dirname (ESM safe)
|
|
15
|
+
* ----------------------------------------------------- */
|
|
16
|
+
const __filename = fileURLToPath(import.meta.url);
|
|
17
|
+
const __dirname = path.dirname(__filename);
|
|
18
|
+
|
|
19
|
+
/* -------------------------------------------------------
|
|
20
|
+
* Colors (Old Titan Theme Style)
|
|
21
|
+
* ----------------------------------------------------- */
|
|
22
|
+
const cyan = (t) => `\x1b[36m${t}\x1b[0m`;
|
|
23
|
+
const green = (t) => `\x1b[32m${t}\x1b[0m`;
|
|
24
|
+
const yellow = (t) => `\x1b[33m${t}\x1b[0m`;
|
|
25
|
+
const red = (t) => `\x1b[31m${t}\x1b[0m`;
|
|
26
|
+
const bold = (t) => `\x1b[1m${t}\x1b[0m`;
|
|
27
|
+
const gray = (t) => `\x1b[90m${t}\x1b[0m`;
|
|
28
|
+
|
|
29
|
+
/* -------------------------------------------------------
|
|
30
|
+
* Version
|
|
31
|
+
* ----------------------------------------------------- */
|
|
32
|
+
let VERSION = "1.0.0";
|
|
33
|
+
|
|
34
|
+
try {
|
|
35
|
+
const pkg = JSON.parse(
|
|
36
|
+
fs.readFileSync(path.join(__dirname, "package.json"), "utf8")
|
|
37
|
+
);
|
|
38
|
+
VERSION = pkg.version;
|
|
39
|
+
} catch { }
|
|
40
|
+
|
|
41
|
+
/* -------------------------------------------------------
|
|
42
|
+
* Help Output
|
|
43
|
+
* ----------------------------------------------------- */
|
|
44
|
+
function help() {
|
|
45
|
+
console.log(`
|
|
46
|
+
${bold(cyan("╭───────────────────────────────────────────────╮"))}
|
|
47
|
+
${bold(cyan("│"))} 🪐 ${bold(cyan("Titan Planet"))} CLI ${gray(`v${VERSION}`.padEnd(6, ' '))} ${bold(cyan("│"))}
|
|
48
|
+
${bold(cyan("╰───────────────────────────────────────────────╯"))}
|
|
49
|
+
|
|
50
|
+
${yellow("Usage:")} ${bold("titan <command> [options]")}
|
|
51
|
+
|
|
52
|
+
${bold("Commands:")}
|
|
53
|
+
${cyan("init")} ${gray("Scaffold a new Titan project")}
|
|
54
|
+
${cyan("build")} ${gray("Compile actions and build production dist")}
|
|
55
|
+
${cyan("dev")} ${gray("Start the Gravity Engine in dev/watch mode")}
|
|
56
|
+
${cyan("start")} ${gray("Start the production Gravity Engine")}
|
|
57
|
+
${cyan("migrate")} ${gray("Migrate a legacy project to the new architecture")}
|
|
58
|
+
|
|
59
|
+
${bold("Options:")}
|
|
60
|
+
${cyan("-v, --version")} ${gray("Output the current version")}
|
|
61
|
+
${cyan("-h, --help")} ${gray("Display this help message")}
|
|
62
|
+
|
|
63
|
+
${gray(" The Titan Planet Engine runs your JS/TS server natively without Node.js. ")}
|
|
64
|
+
${cyan("https://titan-docs-ez.vercel.app")}
|
|
65
|
+
`);
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
/* -------------------------------------------------------
|
|
69
|
+
* CLI Router
|
|
70
|
+
* ----------------------------------------------------- */
|
|
71
|
+
const cmd = process.argv[2];
|
|
72
|
+
|
|
73
|
+
(async () => {
|
|
74
|
+
try {
|
|
75
|
+
// -------------------------------------------------------
|
|
76
|
+
// Legacy Check
|
|
77
|
+
// -------------------------------------------------------
|
|
78
|
+
if (cmd !== 'migrate' && cmd !== 'init') {
|
|
79
|
+
const legacyCargo = path.join(process.cwd(), "server", "Cargo.toml");
|
|
80
|
+
if (fs.existsSync(legacyCargo)) {
|
|
81
|
+
console.log(yellow(`\n⚠️ This project uses legacy server architecture. Migration recommended.`));
|
|
82
|
+
console.log(`Please run: ${bold(cyan('titan migrate'))}\n`);
|
|
83
|
+
process.exit(1);
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
// -------------------------------------------------------
|
|
88
|
+
// Old tit / titan detection note
|
|
89
|
+
// -------------------------------------------------------
|
|
90
|
+
const scriptBase = path.basename(process.argv[1]);
|
|
91
|
+
if (scriptBase === 'tit') {
|
|
92
|
+
console.log(yellow(`\n⚠️ [Notice]: \`tit\` is deprecated. Please use \`titan\` instead.\n`));
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
|
|
96
|
+
switch (cmd) {
|
|
97
|
+
case "init": {
|
|
98
|
+
const projectName = process.argv[3];
|
|
99
|
+
let template = null;
|
|
100
|
+
const tIndex = process.argv.indexOf("-t") !== -1 ? process.argv.indexOf("-t") : process.argv.indexOf("--template");
|
|
101
|
+
if (tIndex !== -1 && process.argv[tIndex + 1]) {
|
|
102
|
+
template = process.argv[tIndex + 1];
|
|
103
|
+
}
|
|
104
|
+
await initCommand(projectName, template);
|
|
105
|
+
break;
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
case "build":
|
|
109
|
+
console.log(cyan("→ Building Titan project..."));
|
|
110
|
+
await buildCommand();
|
|
111
|
+
console.log(green("✔ Build complete"));
|
|
112
|
+
break;
|
|
113
|
+
|
|
114
|
+
case "dev":
|
|
115
|
+
await devCommand();
|
|
116
|
+
break;
|
|
117
|
+
|
|
118
|
+
case "start":
|
|
119
|
+
console.log(cyan("→ Starting Titan Server..."));
|
|
120
|
+
startCommand();
|
|
121
|
+
break;
|
|
122
|
+
|
|
123
|
+
case "migrate":
|
|
124
|
+
await migrateCommand();
|
|
125
|
+
break;
|
|
126
|
+
|
|
127
|
+
case "--version":
|
|
128
|
+
case "-v":
|
|
129
|
+
case "version":
|
|
130
|
+
console.log(cyan(`Titan CLI v${VERSION}`));
|
|
131
|
+
break;
|
|
132
|
+
|
|
133
|
+
default:
|
|
134
|
+
help();
|
|
135
|
+
}
|
|
136
|
+
} catch (err) {
|
|
137
|
+
console.error(red("✖ Titan CLI Error"));
|
|
138
|
+
console.error(gray(err?.message || err));
|
|
139
|
+
process.exit(1);
|
|
140
|
+
}
|
|
141
|
+
})();
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
TITAN_DEV=1
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
# ================================================================
|
|
2
|
+
# STAGE 1 — Build TitanPl
|
|
3
|
+
# ================================================================
|
|
4
|
+
FROM node:20.20.0-slim AS builder
|
|
5
|
+
|
|
6
|
+
WORKDIR /app
|
|
7
|
+
|
|
8
|
+
# Install native dependencies in case of native modules or hybrids
|
|
9
|
+
RUN apt-get update && apt-get install -y --no-install-recommends \
|
|
10
|
+
curl ca-certificates build-essential pkg-config libssl-dev git bash \
|
|
11
|
+
&& rm -rf /var/lib/apt/lists/*
|
|
12
|
+
|
|
13
|
+
ENV NODE_ENV=production
|
|
14
|
+
|
|
15
|
+
# ---------- Node Dependencies ----------
|
|
16
|
+
COPY package.json package-lock.json* ./
|
|
17
|
+
RUN npm install
|
|
18
|
+
|
|
19
|
+
# ---------- Copy Project ----------
|
|
20
|
+
COPY . .
|
|
21
|
+
|
|
22
|
+
# Run the Titan build command (compiles dist/)
|
|
23
|
+
RUN npx titan build
|
|
24
|
+
|
|
25
|
+
# ================================================================
|
|
26
|
+
# STAGE 2 — Gravity Engine (Production Ready)
|
|
27
|
+
# ================================================================
|
|
28
|
+
FROM node:20.20.0-slim
|
|
29
|
+
|
|
30
|
+
WORKDIR /app
|
|
31
|
+
|
|
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/*
|
|
36
|
+
|
|
37
|
+
# ---- Copy Production package.json and install ONLY dependencies ----
|
|
38
|
+
COPY package.json package-lock.json* ./
|
|
39
|
+
RUN npm ci --omit=dev
|
|
40
|
+
|
|
41
|
+
# ---- Copy Dist Build from Builder ----
|
|
42
|
+
COPY --from=builder /app/dist ./dist
|
|
43
|
+
|
|
44
|
+
# ---------------- OPTIONAL APP FOLDERS ----------------
|
|
45
|
+
# Static assets
|
|
46
|
+
# COPY --from=builder /app/app/static ./static
|
|
47
|
+
|
|
48
|
+
# Public assets
|
|
49
|
+
# COPY --from=builder /app/app/public ./public
|
|
50
|
+
|
|
51
|
+
# DB
|
|
52
|
+
# COPY --from=builder /app/app/db ./db
|
|
53
|
+
|
|
54
|
+
# ---- Create User After Copy ----
|
|
55
|
+
RUN useradd -m titan && chown -R titan:titan /app
|
|
56
|
+
USER titan
|
|
57
|
+
|
|
58
|
+
# ---- Platform Defaults ----
|
|
59
|
+
ENV HOST=0.0.0.0
|
|
60
|
+
ENV PORT=5100
|
|
61
|
+
ENV TITAN_DEV=0
|
|
62
|
+
|
|
63
|
+
EXPOSE 5100
|
|
64
|
+
|
|
65
|
+
# ---- Force Foreground Process via Titan CLI ----
|
|
66
|
+
CMD ["npx", "titan", "start"]
|
|
@@ -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 Gravity 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
|