titanpl 1.0.0 → 1.5.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/README.md +15 -18
- package/package.json +7 -5
- package/packages/cli/README.md +17 -0
- package/packages/cli/index.js +20 -0
- package/packages/cli/package.json +34 -0
- package/packages/cli/src/commands/build.js +6 -0
- package/packages/cli/src/commands/dev.js +5 -0
- package/packages/cli/src/commands/init.js +182 -0
- package/packages/cli/src/commands/migrate.js +106 -0
- package/packages/cli/src/commands/start.js +5 -0
- package/packages/cli/src/commands/update.js +90 -0
- package/packages/cli/src/engine.js +143 -0
- package/packages/engine-darwin-arm64/README.md +13 -0
- package/packages/engine-darwin-arm64/package.json +10 -0
- package/packages/engine-linux-x64/README.md +11 -0
- package/packages/engine-linux-x64/package.json +10 -0
- package/packages/engine-win32-x64/README.md +11 -0
- package/packages/engine-win32-x64/bin/titan-engine.exe +0 -0
- package/packages/engine-win32-x64/bin/titan-server.exe +0 -0
- package/packages/engine-win32-x64/package.json +10 -0
- package/packages/native/README.md +11 -0
- package/packages/native/index.d.ts +41 -0
- package/packages/native/index.js +39 -0
- package/packages/native/package.json +26 -0
- package/packages/native/t.native.d.ts +2043 -0
- package/packages/packet/README.md +11 -0
- package/packages/packet/index.js +84 -0
- package/packages/packet/js/titan/builder.js +50 -0
- package/packages/packet/js/titan/bundle.js +164 -0
- package/packages/packet/js/titan/dev.js +172 -0
- package/packages/packet/js/titan/error-box.js +277 -0
- package/packages/packet/node_modules/typescript/LICENSE.txt +55 -0
- package/packages/packet/node_modules/typescript/README.md +50 -0
- package/packages/packet/node_modules/typescript/SECURITY.md +41 -0
- package/packages/packet/node_modules/typescript/ThirdPartyNoticeText.txt +193 -0
- package/packages/packet/node_modules/typescript/bin/tsc +2 -0
- package/packages/packet/node_modules/typescript/bin/tsserver +2 -0
- package/packages/packet/node_modules/typescript/lib/_tsc.js +133818 -0
- package/packages/packet/node_modules/typescript/lib/_tsserver.js +659 -0
- package/packages/packet/node_modules/typescript/lib/_typingsInstaller.js +222 -0
- package/packages/packet/node_modules/typescript/lib/cs/diagnosticMessages.generated.json +2122 -0
- package/packages/packet/node_modules/typescript/lib/de/diagnosticMessages.generated.json +2122 -0
- package/packages/packet/node_modules/typescript/lib/es/diagnosticMessages.generated.json +2122 -0
- package/packages/packet/node_modules/typescript/lib/fr/diagnosticMessages.generated.json +2122 -0
- package/packages/packet/node_modules/typescript/lib/it/diagnosticMessages.generated.json +2122 -0
- package/packages/packet/node_modules/typescript/lib/ja/diagnosticMessages.generated.json +2122 -0
- package/packages/packet/node_modules/typescript/lib/ko/diagnosticMessages.generated.json +2122 -0
- package/packages/packet/node_modules/typescript/lib/lib.d.ts +22 -0
- package/packages/packet/node_modules/typescript/lib/lib.decorators.d.ts +384 -0
- package/packages/packet/node_modules/typescript/lib/lib.decorators.legacy.d.ts +22 -0
- package/packages/packet/node_modules/typescript/lib/lib.dom.asynciterable.d.ts +41 -0
- package/packages/packet/node_modules/typescript/lib/lib.dom.d.ts +39429 -0
- package/packages/packet/node_modules/typescript/lib/lib.dom.iterable.d.ts +571 -0
- package/packages/packet/node_modules/typescript/lib/lib.es2015.collection.d.ts +147 -0
- package/packages/packet/node_modules/typescript/lib/lib.es2015.core.d.ts +597 -0
- package/packages/packet/node_modules/typescript/lib/lib.es2015.d.ts +28 -0
- package/packages/packet/node_modules/typescript/lib/lib.es2015.generator.d.ts +77 -0
- package/packages/packet/node_modules/typescript/lib/lib.es2015.iterable.d.ts +605 -0
- package/packages/packet/node_modules/typescript/lib/lib.es2015.promise.d.ts +81 -0
- package/packages/packet/node_modules/typescript/lib/lib.es2015.proxy.d.ts +128 -0
- package/packages/packet/node_modules/typescript/lib/lib.es2015.reflect.d.ts +144 -0
- package/packages/packet/node_modules/typescript/lib/lib.es2015.symbol.d.ts +46 -0
- package/packages/packet/node_modules/typescript/lib/lib.es2015.symbol.wellknown.d.ts +326 -0
- package/packages/packet/node_modules/typescript/lib/lib.es2016.array.include.d.ts +116 -0
- package/packages/packet/node_modules/typescript/lib/lib.es2016.d.ts +21 -0
- package/packages/packet/node_modules/typescript/lib/lib.es2016.full.d.ts +23 -0
- package/packages/packet/node_modules/typescript/lib/lib.es2016.intl.d.ts +31 -0
- package/packages/packet/node_modules/typescript/lib/lib.es2017.arraybuffer.d.ts +21 -0
- package/packages/packet/node_modules/typescript/lib/lib.es2017.d.ts +26 -0
- package/packages/packet/node_modules/typescript/lib/lib.es2017.date.d.ts +31 -0
- package/packages/packet/node_modules/typescript/lib/lib.es2017.full.d.ts +23 -0
- package/packages/packet/node_modules/typescript/lib/lib.es2017.intl.d.ts +44 -0
- package/packages/packet/node_modules/typescript/lib/lib.es2017.object.d.ts +49 -0
- package/packages/packet/node_modules/typescript/lib/lib.es2017.sharedmemory.d.ts +135 -0
- package/packages/packet/node_modules/typescript/lib/lib.es2017.string.d.ts +45 -0
- package/packages/packet/node_modules/typescript/lib/lib.es2017.typedarrays.d.ts +53 -0
- package/packages/packet/node_modules/typescript/lib/lib.es2018.asyncgenerator.d.ts +77 -0
- package/packages/packet/node_modules/typescript/lib/lib.es2018.asynciterable.d.ts +53 -0
- package/packages/packet/node_modules/typescript/lib/lib.es2018.d.ts +24 -0
- package/packages/packet/node_modules/typescript/lib/lib.es2018.full.d.ts +24 -0
- package/packages/packet/node_modules/typescript/lib/lib.es2018.intl.d.ts +83 -0
- package/packages/packet/node_modules/typescript/lib/lib.es2018.promise.d.ts +30 -0
- package/packages/packet/node_modules/typescript/lib/lib.es2018.regexp.d.ts +37 -0
- package/packages/packet/node_modules/typescript/lib/lib.es2019.array.d.ts +79 -0
- package/packages/packet/node_modules/typescript/lib/lib.es2019.d.ts +24 -0
- package/packages/packet/node_modules/typescript/lib/lib.es2019.full.d.ts +24 -0
- package/packages/packet/node_modules/typescript/lib/lib.es2019.intl.d.ts +23 -0
- package/packages/packet/node_modules/typescript/lib/lib.es2019.object.d.ts +33 -0
- package/packages/packet/node_modules/typescript/lib/lib.es2019.string.d.ts +37 -0
- package/packages/packet/node_modules/typescript/lib/lib.es2019.symbol.d.ts +24 -0
- package/packages/packet/node_modules/typescript/lib/lib.es2020.bigint.d.ts +765 -0
- package/packages/packet/node_modules/typescript/lib/lib.es2020.d.ts +27 -0
- package/packages/packet/node_modules/typescript/lib/lib.es2020.date.d.ts +42 -0
- package/packages/packet/node_modules/typescript/lib/lib.es2020.full.d.ts +24 -0
- package/packages/packet/node_modules/typescript/lib/lib.es2020.intl.d.ts +474 -0
- package/packages/packet/node_modules/typescript/lib/lib.es2020.number.d.ts +28 -0
- package/packages/packet/node_modules/typescript/lib/lib.es2020.promise.d.ts +47 -0
- package/packages/packet/node_modules/typescript/lib/lib.es2020.sharedmemory.d.ts +99 -0
- package/packages/packet/node_modules/typescript/lib/lib.es2020.string.d.ts +44 -0
- package/packages/packet/node_modules/typescript/lib/lib.es2020.symbol.wellknown.d.ts +41 -0
- package/packages/packet/node_modules/typescript/lib/lib.es2021.d.ts +23 -0
- package/packages/packet/node_modules/typescript/lib/lib.es2021.full.d.ts +24 -0
- package/packages/packet/node_modules/typescript/lib/lib.es2021.intl.d.ts +166 -0
- package/packages/packet/node_modules/typescript/lib/lib.es2021.promise.d.ts +48 -0
- package/packages/packet/node_modules/typescript/lib/lib.es2021.string.d.ts +33 -0
- package/packages/packet/node_modules/typescript/lib/lib.es2021.weakref.d.ts +78 -0
- package/packages/packet/node_modules/typescript/lib/lib.es2022.array.d.ts +121 -0
- package/packages/packet/node_modules/typescript/lib/lib.es2022.d.ts +25 -0
- package/packages/packet/node_modules/typescript/lib/lib.es2022.error.d.ts +75 -0
- package/packages/packet/node_modules/typescript/lib/lib.es2022.full.d.ts +24 -0
- package/packages/packet/node_modules/typescript/lib/lib.es2022.intl.d.ts +145 -0
- package/packages/packet/node_modules/typescript/lib/lib.es2022.object.d.ts +26 -0
- package/packages/packet/node_modules/typescript/lib/lib.es2022.regexp.d.ts +39 -0
- package/packages/packet/node_modules/typescript/lib/lib.es2022.string.d.ts +25 -0
- package/packages/packet/node_modules/typescript/lib/lib.es2023.array.d.ts +924 -0
- package/packages/packet/node_modules/typescript/lib/lib.es2023.collection.d.ts +21 -0
- package/packages/packet/node_modules/typescript/lib/lib.es2023.d.ts +22 -0
- package/packages/packet/node_modules/typescript/lib/lib.es2023.full.d.ts +24 -0
- package/packages/packet/node_modules/typescript/lib/lib.es2023.intl.d.ts +56 -0
- package/packages/packet/node_modules/typescript/lib/lib.es2024.arraybuffer.d.ts +65 -0
- package/packages/packet/node_modules/typescript/lib/lib.es2024.collection.d.ts +29 -0
- package/packages/packet/node_modules/typescript/lib/lib.es2024.d.ts +26 -0
- package/packages/packet/node_modules/typescript/lib/lib.es2024.full.d.ts +24 -0
- package/packages/packet/node_modules/typescript/lib/lib.es2024.object.d.ts +29 -0
- package/packages/packet/node_modules/typescript/lib/lib.es2024.promise.d.ts +35 -0
- package/packages/packet/node_modules/typescript/lib/lib.es2024.regexp.d.ts +25 -0
- package/packages/packet/node_modules/typescript/lib/lib.es2024.sharedmemory.d.ts +68 -0
- package/packages/packet/node_modules/typescript/lib/lib.es2024.string.d.ts +29 -0
- package/packages/packet/node_modules/typescript/lib/lib.es5.d.ts +4601 -0
- package/packages/packet/node_modules/typescript/lib/lib.es6.d.ts +23 -0
- package/packages/packet/node_modules/typescript/lib/lib.esnext.array.d.ts +35 -0
- package/packages/packet/node_modules/typescript/lib/lib.esnext.collection.d.ts +96 -0
- package/packages/packet/node_modules/typescript/lib/lib.esnext.d.ts +29 -0
- package/packages/packet/node_modules/typescript/lib/lib.esnext.decorators.d.ts +28 -0
- package/packages/packet/node_modules/typescript/lib/lib.esnext.disposable.d.ts +193 -0
- package/packages/packet/node_modules/typescript/lib/lib.esnext.error.d.ts +24 -0
- package/packages/packet/node_modules/typescript/lib/lib.esnext.float16.d.ts +445 -0
- package/packages/packet/node_modules/typescript/lib/lib.esnext.full.d.ts +24 -0
- package/packages/packet/node_modules/typescript/lib/lib.esnext.intl.d.ts +21 -0
- package/packages/packet/node_modules/typescript/lib/lib.esnext.iterator.d.ts +148 -0
- package/packages/packet/node_modules/typescript/lib/lib.esnext.promise.d.ts +34 -0
- package/packages/packet/node_modules/typescript/lib/lib.esnext.sharedmemory.d.ts +25 -0
- package/packages/packet/node_modules/typescript/lib/lib.scripthost.d.ts +322 -0
- package/packages/packet/node_modules/typescript/lib/lib.webworker.asynciterable.d.ts +41 -0
- package/packages/packet/node_modules/typescript/lib/lib.webworker.d.ts +13150 -0
- package/packages/packet/node_modules/typescript/lib/lib.webworker.importscripts.d.ts +23 -0
- package/packages/packet/node_modules/typescript/lib/lib.webworker.iterable.d.ts +340 -0
- package/packages/packet/node_modules/typescript/lib/pl/diagnosticMessages.generated.json +2122 -0
- package/packages/packet/node_modules/typescript/lib/pt-br/diagnosticMessages.generated.json +2122 -0
- package/packages/packet/node_modules/typescript/lib/ru/diagnosticMessages.generated.json +2122 -0
- package/packages/packet/node_modules/typescript/lib/tr/diagnosticMessages.generated.json +2122 -0
- package/packages/packet/node_modules/typescript/lib/tsc.js +8 -0
- package/packages/packet/node_modules/typescript/lib/tsserver.js +8 -0
- package/packages/packet/node_modules/typescript/lib/tsserverlibrary.d.ts +17 -0
- package/packages/packet/node_modules/typescript/lib/tsserverlibrary.js +21 -0
- package/packages/packet/node_modules/typescript/lib/typesMap.json +497 -0
- package/packages/packet/node_modules/typescript/lib/typescript.d.ts +11437 -0
- package/packages/packet/node_modules/typescript/lib/typescript.js +200276 -0
- package/packages/packet/node_modules/typescript/lib/typingsInstaller.js +8 -0
- package/packages/packet/node_modules/typescript/lib/watchGuard.js +53 -0
- package/packages/packet/node_modules/typescript/lib/zh-cn/diagnosticMessages.generated.json +2122 -0
- package/packages/packet/node_modules/typescript/lib/zh-tw/diagnosticMessages.generated.json +2122 -0
- package/packages/packet/node_modules/typescript/package.json +120 -0
- package/packages/packet/package.json +23 -0
- package/packages/packet/ts/titan/builder.js +74 -0
- package/packages/packet/ts/titan/bundle.js +227 -0
- package/packages/packet/ts/titan/dev.js +175 -0
- package/packages/packet/ts/titan/error-box.js +277 -0
- package/packages/route/README.md +24 -0
- package/packages/route/index.d.ts +16 -0
- package/packages/route/index.js +52 -0
- package/packages/route/package.json +22 -0
- package/templates/extension/README.md +4 -0
- package/templates/extension/index.js +1 -12
- package/templates/extension/package.json +4 -4
- package/templates/js/app/app.js +1 -1
- package/templates/js/package.json +10 -9
- package/templates/rust-js/package.json +7 -7
- package/templates/rust-js/titan/dev.js +2 -2
- package/templates/rust-ts/package.json +7 -7
- package/templates/rust-ts/titan/dev.js +2 -2
- package/templates/ts/app/app.ts +1 -1
- package/templates/ts/package.json +8 -7
- package/titanpl-sdk/README.md +2 -0
- package/titanpl-sdk/package.json +4 -4
- package/titanpl-sdk/templates/titan/bundle.js +1 -1
- package/titanpl-sdk/templates/titan/dev.js +2 -2
- package/titanpl-sdk/templates/titan/error-box.js +2 -2
package/README.md
CHANGED
|
@@ -9,8 +9,8 @@
|
|
|
9
9
|
</p>
|
|
10
10
|
|
|
11
11
|
<p align="center">
|
|
12
|
-
<a href="https://www.npmjs.com/package
|
|
13
|
-
<img src="https://img.shields.io/npm/v
|
|
12
|
+
<a href="https://www.npmjs.com/package/titanpl">
|
|
13
|
+
<img src="https://img.shields.io/npm/v/titanpl?style=for-the-badge&logo=npm&logoColor=white" />
|
|
14
14
|
</a>
|
|
15
15
|
|
|
16
16
|
<img src="https://img.shields.io/badge/Runtime-Gravity(V8)%20%26%20Rust%20Tokio-1f2937?style=for-the-badge" />
|
|
@@ -84,8 +84,9 @@ Titan handles the integration automatically.
|
|
|
84
84
|
* **Node.js** (v18+): Required for CLI and JS tooling.
|
|
85
85
|
|
|
86
86
|
### 2. Install CLI
|
|
87
|
+
**The `titanpl` CLI is used to create and manage all your new projects and everything related to Titan.**
|
|
87
88
|
```bash
|
|
88
|
-
npm install -g @
|
|
89
|
+
npm install -g @titanpl/cli@latest
|
|
89
90
|
```
|
|
90
91
|
|
|
91
92
|
### 3. Initialize & Run
|
|
@@ -103,29 +104,25 @@ titan init my-app
|
|
|
103
104
|
1. `Standard` (Pure JS/TS)
|
|
104
105
|
2. `Rust + JS/TS (Hybrid)` (High-performance native actions)
|
|
105
106
|
|
|
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
107
|
Inside your project:
|
|
113
108
|
```bash
|
|
114
109
|
cd my-app
|
|
115
|
-
|
|
110
|
+
npm run dev
|
|
116
111
|
```
|
|
117
112
|
|
|
118
113
|
You'll see the Titan Dev Server spin up:
|
|
119
114
|
```
|
|
120
|
-
Titan Planet
|
|
115
|
+
⏣ Titan Planet v1.0.0 [ Dev Mode ]
|
|
121
116
|
|
|
122
|
-
Type:
|
|
117
|
+
Type: TS Actions
|
|
123
118
|
Hot Reload: Enabled
|
|
124
|
-
|
|
119
|
+
Env: Loaded
|
|
120
|
+
|
|
121
|
+
🚀 Starting Titan Engine...
|
|
122
|
+
[Titan] 1 reply route(s) pre-computed
|
|
123
|
+
Titan server running at: http://localhost:5100 (Threads: 32, Stack: 8MB, Dev Mode)
|
|
124
|
+
|
|
125
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
126
|
```
|
|
130
127
|
|
|
131
128
|
|
|
@@ -136,7 +133,7 @@ Titan is unique because it allows you to write endpoints in **JavaScript, TypeSc
|
|
|
136
133
|
| Feature | Status | Notes |
|
|
137
134
|
| :--- | :--- | :--- |
|
|
138
135
|
| **Standard JavaScript** | ✅ Stable | Production Ready |
|
|
139
|
-
| **Standard TypeScript** |
|
|
136
|
+
| **Standard TypeScript** | ✅ Stable | Production Ready |
|
|
140
137
|
| **Rust + JS (Hybrid)** | 🧪 Experimental | **Dev Only**, Production Under Testing |
|
|
141
138
|
| **Rust + TS (Hybrid)** | 🧪 Experimental | **Dev Only**, Production Under Testing |
|
|
142
139
|
|
|
@@ -144,7 +141,7 @@ Titan is unique because it allows you to write endpoints in **JavaScript, TypeSc
|
|
|
144
141
|
Fully typed, strict, and auto-compiled.
|
|
145
142
|
|
|
146
143
|
```typescript
|
|
147
|
-
import { defineAction } from "
|
|
144
|
+
import { defineAction } from "@titanpl/native";
|
|
148
145
|
|
|
149
146
|
interface HelloResponse {
|
|
150
147
|
message: string;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "titanpl",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.5.0",
|
|
4
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
5
|
"license": "ISC",
|
|
6
6
|
"author": "ezetgalaxy",
|
|
@@ -8,7 +8,8 @@
|
|
|
8
8
|
"main": "index.js",
|
|
9
9
|
"bin": {
|
|
10
10
|
"tit": "./packages/cli/index.js",
|
|
11
|
-
"titan": "./packages/cli/index.js"
|
|
11
|
+
"titan": "./packages/cli/index.js",
|
|
12
|
+
"titanpl": "./packages/cli/index.js"
|
|
12
13
|
},
|
|
13
14
|
"workspaces": [
|
|
14
15
|
"packages/*",
|
|
@@ -16,6 +17,7 @@
|
|
|
16
17
|
],
|
|
17
18
|
"files": [
|
|
18
19
|
"index.js",
|
|
20
|
+
"packages/",
|
|
19
21
|
"templates/",
|
|
20
22
|
"titanpl-sdk",
|
|
21
23
|
"README.md"
|
|
@@ -69,8 +71,8 @@
|
|
|
69
71
|
"test:all": "vitest run && vitest run --config vitest.config.e2e.ts"
|
|
70
72
|
},
|
|
71
73
|
"dependencies": {
|
|
72
|
-
"@titanpl/core": "
|
|
73
|
-
"@titanpl/node": "
|
|
74
|
+
"@titanpl/core": "1.4.0",
|
|
75
|
+
"@titanpl/node": "1.4.0",
|
|
74
76
|
"chokidar": "^5.0.0",
|
|
75
77
|
"esbuild": "^0.27.2",
|
|
76
78
|
"prompts": "^2.4.2"
|
|
@@ -80,4 +82,4 @@
|
|
|
80
82
|
"@vitest/ui": "^4.0.17",
|
|
81
83
|
"vitest": "^4.0.17"
|
|
82
84
|
}
|
|
83
|
-
}
|
|
85
|
+
}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
# @titanpl/cli
|
|
2
|
+
|
|
3
|
+
The command-line interface (CLI) for Titan Planet. It provides the `titan` and `tit` commands for initializing, building, and running Titan Planet servers.
|
|
4
|
+
|
|
5
|
+
## What it works (What it does)
|
|
6
|
+
The CLI is responsible for bridging your JavaScript codebase with the underlying Rust/Axum engine. It handles scaffolding, compiling JS actions, generating metadata, and running the server.
|
|
7
|
+
|
|
8
|
+
## How it works
|
|
9
|
+
You can install this package globally or use it via your package runner (e.g., `npx`). Alternatively, you can install it as a dev dependency in your project.
|
|
10
|
+
|
|
11
|
+
```bash
|
|
12
|
+
npx titan help
|
|
13
|
+
```
|
|
14
|
+
|
|
15
|
+
It parses your application source code, coordinates with `@titanpl/packet` to build the required JS endpoints, and then spins up the pre-compiled native core engine for your OS.
|
|
16
|
+
|
|
17
|
+
**Important Note:** Currently, Titan Planet and its entire package ecosystem are only for Windows. The Linux version is in development (dev only) for the new architecture and will be launched later.
|
package/packages/cli/index.js
CHANGED
|
@@ -8,6 +8,7 @@ import { buildCommand } from "./src/commands/build.js";
|
|
|
8
8
|
import { devCommand } from "./src/commands/dev.js";
|
|
9
9
|
import { startCommand } from "./src/commands/start.js";
|
|
10
10
|
import { migrateCommand } from "./src/commands/migrate.js";
|
|
11
|
+
import { updateCommand } from "./src/commands/update.js";
|
|
11
12
|
import { initCommand } from "./src/commands/init.js";
|
|
12
13
|
|
|
13
14
|
/* -------------------------------------------------------
|
|
@@ -51,9 +52,11 @@ ${bold(cyan("╰─────────────────────
|
|
|
51
52
|
|
|
52
53
|
${bold("Commands:")}
|
|
53
54
|
${cyan("init")} ${gray("Scaffold a new Titan project")}
|
|
55
|
+
${cyan("create")} ${gray("Create a new project or extension (e.g. 'titan create ext my-ext')")}
|
|
54
56
|
${cyan("build")} ${gray("Compile actions and build production dist")}
|
|
55
57
|
${cyan("dev")} ${gray("Start the Gravity Engine in dev/watch mode")}
|
|
56
58
|
${cyan("start")} ${gray("Start the production Gravity Engine")}
|
|
59
|
+
${cyan("update")} ${gray("Update an existing project to latest Titan version")}
|
|
57
60
|
${cyan("migrate")} ${gray("Migrate a legacy project to the new architecture")}
|
|
58
61
|
|
|
59
62
|
${bold("Options:")}
|
|
@@ -68,6 +71,7 @@ ${gray(" The Titan Planet Engine runs your JS/TS server natively without Node.j
|
|
|
68
71
|
/* -------------------------------------------------------
|
|
69
72
|
* CLI Router
|
|
70
73
|
* ----------------------------------------------------- */
|
|
74
|
+
process.title = "TitanPL";
|
|
71
75
|
const cmd = process.argv[2];
|
|
72
76
|
|
|
73
77
|
(async () => {
|
|
@@ -105,6 +109,18 @@ const cmd = process.argv[2];
|
|
|
105
109
|
break;
|
|
106
110
|
}
|
|
107
111
|
|
|
112
|
+
case "create": {
|
|
113
|
+
const type = process.argv[3];
|
|
114
|
+
const name = process.argv[4];
|
|
115
|
+
if (type === "ext" || type === "extension") {
|
|
116
|
+
await initCommand(name, "extension");
|
|
117
|
+
} else {
|
|
118
|
+
// Fallback to init behavior
|
|
119
|
+
await initCommand(type, null);
|
|
120
|
+
}
|
|
121
|
+
break;
|
|
122
|
+
}
|
|
123
|
+
|
|
108
124
|
case "build":
|
|
109
125
|
console.log(cyan("→ Building Titan project..."));
|
|
110
126
|
await buildCommand();
|
|
@@ -120,6 +136,10 @@ const cmd = process.argv[2];
|
|
|
120
136
|
startCommand();
|
|
121
137
|
break;
|
|
122
138
|
|
|
139
|
+
case "update":
|
|
140
|
+
await updateCommand();
|
|
141
|
+
break;
|
|
142
|
+
|
|
123
143
|
case "migrate":
|
|
124
144
|
await migrateCommand();
|
|
125
145
|
break;
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@titanpl/cli",
|
|
3
|
+
"version": "1.5.0",
|
|
4
|
+
"description": "The unified CLI for Titan Planet. Use it to create, manage, build, and deploy high-performance backend projects.",
|
|
5
|
+
"keywords": [
|
|
6
|
+
"titanpl",
|
|
7
|
+
"titan",
|
|
8
|
+
"ezetgalaxy",
|
|
9
|
+
"cli"
|
|
10
|
+
],
|
|
11
|
+
"license": "ISC",
|
|
12
|
+
"author": "ezetgalaxy",
|
|
13
|
+
"type": "module",
|
|
14
|
+
"main": "index.js",
|
|
15
|
+
"scripts": {
|
|
16
|
+
"test": "echo \"Error: no test specified\" && exit 1"
|
|
17
|
+
},
|
|
18
|
+
"bin": {
|
|
19
|
+
"titan": "./index.js",
|
|
20
|
+
"titanpl": "./index.js",
|
|
21
|
+
"tit": "./index.js"
|
|
22
|
+
},
|
|
23
|
+
"optionalDependencies": {
|
|
24
|
+
"@titanpl/engine-win32-x64": "1.5.0",
|
|
25
|
+
"@titanpl/engine-linux-x64": "1.5.0",
|
|
26
|
+
"@titanpl/engine-darwin-arm64": "1.5.0"
|
|
27
|
+
},
|
|
28
|
+
"dependencies": {
|
|
29
|
+
"@titanpl/packet": "1.5.0",
|
|
30
|
+
"prompts": "^2.4.2",
|
|
31
|
+
"commander": "^11.0.0",
|
|
32
|
+
"chalk": "^4.1.2"
|
|
33
|
+
}
|
|
34
|
+
}
|
|
@@ -0,0 +1,182 @@
|
|
|
1
|
+
import fs from 'fs';
|
|
2
|
+
import path from 'path';
|
|
3
|
+
import { fileURLToPath } from 'url';
|
|
4
|
+
import { spawn } from 'child_process';
|
|
5
|
+
import prompts from 'prompts';
|
|
6
|
+
import chalk from 'chalk';
|
|
7
|
+
|
|
8
|
+
const __filename = fileURLToPath(import.meta.url);
|
|
9
|
+
const __dirname = path.dirname(__filename);
|
|
10
|
+
|
|
11
|
+
export function copyDir(src, dest, excludes = []) {
|
|
12
|
+
fs.mkdirSync(dest, { recursive: true });
|
|
13
|
+
|
|
14
|
+
for (const file of fs.readdirSync(src)) {
|
|
15
|
+
if (excludes.includes(file)) continue;
|
|
16
|
+
|
|
17
|
+
const srcPath = path.join(src, file);
|
|
18
|
+
const destPath = path.join(dest, file);
|
|
19
|
+
|
|
20
|
+
if (fs.lstatSync(srcPath).isDirectory()) {
|
|
21
|
+
copyDir(srcPath, destPath, excludes);
|
|
22
|
+
} else {
|
|
23
|
+
fs.copyFileSync(srcPath, destPath);
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
export async function initCommand(projectName, templateName) {
|
|
29
|
+
let projName = projectName;
|
|
30
|
+
|
|
31
|
+
if (!projName) {
|
|
32
|
+
const res = await prompts({
|
|
33
|
+
type: 'text',
|
|
34
|
+
name: 'name',
|
|
35
|
+
message: 'Project name:',
|
|
36
|
+
initial: 'my-titan-app'
|
|
37
|
+
});
|
|
38
|
+
projName = res.name;
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
if (!projName) {
|
|
42
|
+
console.log(chalk.red("✖ Initialization cancelled."));
|
|
43
|
+
process.exit(1);
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
let selectedTemplate = templateName;
|
|
47
|
+
|
|
48
|
+
if (!selectedTemplate) {
|
|
49
|
+
const langRes = await prompts({
|
|
50
|
+
type: 'select',
|
|
51
|
+
name: 'value',
|
|
52
|
+
message: 'Select language:',
|
|
53
|
+
choices: [
|
|
54
|
+
{ title: 'JavaScript', value: 'js' },
|
|
55
|
+
{ title: 'TypeScript', value: 'ts' },
|
|
56
|
+
],
|
|
57
|
+
initial: 0
|
|
58
|
+
});
|
|
59
|
+
|
|
60
|
+
if (!langRes.value) {
|
|
61
|
+
console.log(chalk.red("✖ Operation cancelled."));
|
|
62
|
+
process.exit(1);
|
|
63
|
+
}
|
|
64
|
+
const lang = langRes.value;
|
|
65
|
+
|
|
66
|
+
const archRes = await prompts({
|
|
67
|
+
type: 'select',
|
|
68
|
+
name: 'value',
|
|
69
|
+
message: 'Select template:',
|
|
70
|
+
choices: [
|
|
71
|
+
{
|
|
72
|
+
title: `Standard (${lang.toUpperCase()})`,
|
|
73
|
+
description: `Standard Titan app with ${lang.toUpperCase()} actions`,
|
|
74
|
+
value: 'standard'
|
|
75
|
+
},
|
|
76
|
+
{
|
|
77
|
+
title: `Rust + ${lang.toUpperCase()} (Hybrid)`,
|
|
78
|
+
description: `High-performance Rust actions + ${lang.toUpperCase()} flexibility`,
|
|
79
|
+
value: 'hybrid'
|
|
80
|
+
}
|
|
81
|
+
],
|
|
82
|
+
initial: 0
|
|
83
|
+
});
|
|
84
|
+
|
|
85
|
+
if (!archRes.value) {
|
|
86
|
+
console.log(chalk.red("✖ Operation cancelled."));
|
|
87
|
+
process.exit(1);
|
|
88
|
+
}
|
|
89
|
+
const arch = archRes.value;
|
|
90
|
+
|
|
91
|
+
if (lang === 'js') {
|
|
92
|
+
selectedTemplate = arch === 'standard' ? 'js' : 'rust-js';
|
|
93
|
+
} else {
|
|
94
|
+
selectedTemplate = arch === 'standard' ? 'ts' : 'rust-ts';
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
const target = path.resolve(process.cwd(), projName);
|
|
99
|
+
const templateDir = path.resolve(__dirname, '..', '..', '..', '..', 'templates', selectedTemplate);
|
|
100
|
+
const commonDir = path.resolve(__dirname, '..', '..', '..', '..', 'templates', 'common');
|
|
101
|
+
|
|
102
|
+
if (!fs.existsSync(templateDir) || !fs.existsSync(commonDir)) {
|
|
103
|
+
console.log(chalk.red(`✖ Error finding template paths.Are you in a valid Titan monorepo ? `));
|
|
104
|
+
process.exit(1);
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
if (fs.existsSync(target)) {
|
|
108
|
+
console.log(chalk.red(`✖ Directory '${projName}' already exists.`));
|
|
109
|
+
process.exit(1);
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
console.log(chalk.cyan(`\n→ Creating new Titan project in '${projName}'...\n`));
|
|
113
|
+
|
|
114
|
+
// 1. Copy common
|
|
115
|
+
copyDir(commonDir, target);
|
|
116
|
+
|
|
117
|
+
// 2. Copy specific template
|
|
118
|
+
copyDir(templateDir, target);
|
|
119
|
+
|
|
120
|
+
// 3. Dotfiles and Template Remapping
|
|
121
|
+
const remapping = {
|
|
122
|
+
"_gitignore": ".gitignore",
|
|
123
|
+
"_dockerignore": ".dockerignore",
|
|
124
|
+
"_titan.json": "titan.json",
|
|
125
|
+
".env": ".env"
|
|
126
|
+
};
|
|
127
|
+
for (const [srcName, destName] of Object.entries(remapping)) {
|
|
128
|
+
const src = path.join(target, srcName);
|
|
129
|
+
const dest = path.join(target, destName);
|
|
130
|
+
if (fs.existsSync(src)) {
|
|
131
|
+
fs.renameSync(src, dest);
|
|
132
|
+
}
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
// Recursive template substitution
|
|
136
|
+
const substitute = (dir) => {
|
|
137
|
+
for (const file of fs.readdirSync(dir)) {
|
|
138
|
+
const fullPath = path.join(dir, file);
|
|
139
|
+
if (fs.lstatSync(fullPath).isDirectory()) {
|
|
140
|
+
if (file !== "node_modules" && file !== ".git" && file !== "target") {
|
|
141
|
+
substitute(fullPath);
|
|
142
|
+
}
|
|
143
|
+
} else {
|
|
144
|
+
// Only process text files
|
|
145
|
+
const ext = path.extname(file).toLowerCase();
|
|
146
|
+
const textExts = ['.js', '.ts', '.json', '.md', '.txt', '.rs', '.toml', '.html', '.css', '.d.ts'];
|
|
147
|
+
if (textExts.includes(ext) || file === ".env" || file === "Dockerfile") {
|
|
148
|
+
let content = fs.readFileSync(fullPath, 'utf8');
|
|
149
|
+
let changed = false;
|
|
150
|
+
if (content.includes("{{name}}")) {
|
|
151
|
+
content = content.replace(/{{name}}/g, projName);
|
|
152
|
+
changed = true;
|
|
153
|
+
}
|
|
154
|
+
if (content.includes("{{native_name}}")) {
|
|
155
|
+
content = content.replace(/{{native_name}}/g, projName.replace(/-/g, '_'));
|
|
156
|
+
changed = true;
|
|
157
|
+
}
|
|
158
|
+
if (changed) {
|
|
159
|
+
fs.writeFileSync(fullPath, content);
|
|
160
|
+
}
|
|
161
|
+
}
|
|
162
|
+
}
|
|
163
|
+
}
|
|
164
|
+
};
|
|
165
|
+
substitute(target);
|
|
166
|
+
|
|
167
|
+
console.log(chalk.gray(` Installing dependencies...`));
|
|
168
|
+
|
|
169
|
+
await new Promise((resolve, reject) => {
|
|
170
|
+
const npm = spawn('npm', ['install'], {
|
|
171
|
+
cwd: target,
|
|
172
|
+
stdio: 'inherit',
|
|
173
|
+
shell: true
|
|
174
|
+
});
|
|
175
|
+
npm.on('error', reject);
|
|
176
|
+
npm.on('close', resolve);
|
|
177
|
+
});
|
|
178
|
+
|
|
179
|
+
console.log(chalk.green(`\n✔ Project '${projName}' created successfully!\n`));
|
|
180
|
+
console.log(chalk.yellow(` cd ${projName}`));
|
|
181
|
+
console.log(chalk.yellow(` npm run dev\n`));
|
|
182
|
+
}
|
|
@@ -0,0 +1,106 @@
|
|
|
1
|
+
import fs from 'fs';
|
|
2
|
+
import path from 'path';
|
|
3
|
+
|
|
4
|
+
export async function migrateCommand() {
|
|
5
|
+
const root = process.cwd();
|
|
6
|
+
console.log(`\n🔍 Checking project for legacy Titan architecture...`);
|
|
7
|
+
|
|
8
|
+
const serverDir = path.join(root, 'server');
|
|
9
|
+
const titanDir = path.join(root, 'titan');
|
|
10
|
+
const pkgPath = path.join(root, 'package.json');
|
|
11
|
+
|
|
12
|
+
if (!fs.existsSync(serverDir) && !fs.existsSync(titanDir)) {
|
|
13
|
+
console.log(`✅ This project is already using the modern Titan runtime architecture.`);
|
|
14
|
+
return;
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
console.log(`\n⚠️ Legacy server architecture detected. Migrating to runtime-first model...`);
|
|
18
|
+
|
|
19
|
+
// 1. Delete server/
|
|
20
|
+
if (fs.existsSync(serverDir)) {
|
|
21
|
+
console.log(` Deleting legacy server/ folder...`);
|
|
22
|
+
fs.rmSync(serverDir, { recursive: true, force: true });
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
// 2. Delete titan/ folder
|
|
26
|
+
if (fs.existsSync(titanDir)) {
|
|
27
|
+
console.log(` Deleting legacy titan/ runtime folder...`);
|
|
28
|
+
fs.rmSync(titanDir, { recursive: true, force: true });
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
// 3. Update package.json
|
|
32
|
+
if (fs.existsSync(pkgPath)) {
|
|
33
|
+
console.log(` Updating package.json...`);
|
|
34
|
+
try {
|
|
35
|
+
const pkg = JSON.parse(fs.readFileSync(pkgPath, 'utf8'));
|
|
36
|
+
let modified = false;
|
|
37
|
+
|
|
38
|
+
// Update scripts
|
|
39
|
+
if (pkg.scripts) {
|
|
40
|
+
if (pkg.scripts.build && pkg.scripts.build.includes('cd server')) {
|
|
41
|
+
pkg.scripts.build = "titan build";
|
|
42
|
+
modified = true;
|
|
43
|
+
}
|
|
44
|
+
if (pkg.scripts.start && pkg.scripts.start.includes('cd server')) {
|
|
45
|
+
pkg.scripts.start = "titan start";
|
|
46
|
+
modified = true;
|
|
47
|
+
}
|
|
48
|
+
if (pkg.scripts.dev && pkg.scripts.dev.includes('titan/dev.js')) {
|
|
49
|
+
pkg.scripts.dev = "titan dev";
|
|
50
|
+
modified = true;
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
// Add dependencies
|
|
55
|
+
pkg.dependencies = pkg.dependencies || {};
|
|
56
|
+
if (!pkg.dependencies['@titan/native']) {
|
|
57
|
+
pkg.dependencies['@titan/native'] = "latest";
|
|
58
|
+
modified = true;
|
|
59
|
+
}
|
|
60
|
+
if (!pkg.dependencies['@titan/route']) {
|
|
61
|
+
pkg.dependencies['@titan/route'] = "latest";
|
|
62
|
+
modified = true;
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
if (modified) {
|
|
66
|
+
fs.writeFileSync(pkgPath, JSON.stringify(pkg, null, 2));
|
|
67
|
+
}
|
|
68
|
+
} catch (e) {
|
|
69
|
+
console.log(` ⚠️ Failed to update package.json automatically. Please do it manually.`);
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
// 4. Synchronize Dockerfile and other common files
|
|
74
|
+
try {
|
|
75
|
+
const commonDir = path.resolve(__dirname, '..', '..', '..', '..', 'templates', 'common');
|
|
76
|
+
if (fs.existsSync(commonDir)) {
|
|
77
|
+
const filesToSync = [
|
|
78
|
+
['Dockerfile', 'Dockerfile'],
|
|
79
|
+
['_dockerignore', '.dockerignore'],
|
|
80
|
+
['_gitignore', '.gitignore'],
|
|
81
|
+
['app/t.native.d.ts', 'app/t.native.d.ts'],
|
|
82
|
+
['app/t.native.js', 'app/t.native.js']
|
|
83
|
+
];
|
|
84
|
+
|
|
85
|
+
for (const [srcRel, destRel] of filesToSync) {
|
|
86
|
+
const src = path.join(commonDir, srcRel);
|
|
87
|
+
const dest = path.join(root, destRel);
|
|
88
|
+
if (fs.existsSync(src)) {
|
|
89
|
+
// Create parent dir if needed
|
|
90
|
+
const parent = path.dirname(dest);
|
|
91
|
+
if (!fs.existsSync(parent)) {
|
|
92
|
+
fs.mkdirSync(parent, { recursive: true });
|
|
93
|
+
}
|
|
94
|
+
fs.copyFileSync(src, dest);
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
console.log(` Synchronized Dockerfiles and native definitions.`);
|
|
98
|
+
}
|
|
99
|
+
} catch (e) {
|
|
100
|
+
console.log(` ⚠️ Failed to synchronize common template files.`);
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
console.log(`\n🎉 Migration complete!`);
|
|
104
|
+
console.log(` Please run 'npm install' to fetch the new dependencies.`);
|
|
105
|
+
console.log(` Then run 'titan dev' to start your application.\n`);
|
|
106
|
+
}
|
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
import fs from 'fs';
|
|
2
|
+
import path from 'path';
|
|
3
|
+
import { fileURLToPath } from 'url';
|
|
4
|
+
import chalk from 'chalk';
|
|
5
|
+
|
|
6
|
+
const __filename = fileURLToPath(import.meta.url);
|
|
7
|
+
const __dirname = path.dirname(__filename);
|
|
8
|
+
|
|
9
|
+
export async function updateCommand() {
|
|
10
|
+
const root = process.cwd();
|
|
11
|
+
console.log(chalk.cyan(`\n→ Updating Titan project to latest...`));
|
|
12
|
+
|
|
13
|
+
const pkgPath = path.join(root, 'package.json');
|
|
14
|
+
if (!fs.existsSync(pkgPath)) {
|
|
15
|
+
console.log(chalk.red(`✖ No package.json found. Are you in a project root ? `));
|
|
16
|
+
return;
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
// 1. Update package.json versions
|
|
20
|
+
try {
|
|
21
|
+
const pkg = JSON.parse(fs.readFileSync(pkgPath, 'utf8'));
|
|
22
|
+
let modified = false;
|
|
23
|
+
|
|
24
|
+
const titanDeps = [
|
|
25
|
+
'titanpl',
|
|
26
|
+
'titanpl-sdk',
|
|
27
|
+
'@titanpl/cli',
|
|
28
|
+
'@titanpl/route',
|
|
29
|
+
'@titanpl/native',
|
|
30
|
+
'@titanpl/packet',
|
|
31
|
+
'@titanpl/core',
|
|
32
|
+
'@titanpl/node'
|
|
33
|
+
];
|
|
34
|
+
|
|
35
|
+
if (pkg.dependencies) {
|
|
36
|
+
for (const dep of titanDeps) {
|
|
37
|
+
if (pkg.dependencies[dep]) {
|
|
38
|
+
pkg.dependencies[dep] = "latest";
|
|
39
|
+
modified = true;
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
if (pkg.devDependencies) {
|
|
45
|
+
for (const dep of titanDeps) {
|
|
46
|
+
if (pkg.devDependencies[dep]) {
|
|
47
|
+
pkg.devDependencies[dep] = "latest";
|
|
48
|
+
modified = true;
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
if (modified) {
|
|
54
|
+
fs.writeFileSync(pkgPath, JSON.stringify(pkg, null, 2) + '\n');
|
|
55
|
+
console.log(chalk.green(` ✔ Updated Titan dependencies in package.json`));
|
|
56
|
+
}
|
|
57
|
+
} catch (e) {
|
|
58
|
+
console.log(chalk.yellow(` ⚠️ Failed to update package.json: ${e.message}`));
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
// 2. Refresh Dockerfile and dotfiles from templates
|
|
62
|
+
const commonDir = path.resolve(__dirname, '..', '..', '..', '..', 'templates', 'common');
|
|
63
|
+
if (fs.existsSync(commonDir)) {
|
|
64
|
+
const filesToSync = [
|
|
65
|
+
['Dockerfile', 'Dockerfile'],
|
|
66
|
+
['_dockerignore', '.dockerignore'],
|
|
67
|
+
['_gitignore', '.gitignore'],
|
|
68
|
+
];
|
|
69
|
+
|
|
70
|
+
for (const [srcName, destName] of filesToSync) {
|
|
71
|
+
const src = path.join(commonDir, srcName);
|
|
72
|
+
const dest = path.join(root, destName);
|
|
73
|
+
if (fs.existsSync(src)) {
|
|
74
|
+
fs.copyFileSync(src, dest);
|
|
75
|
+
console.log(chalk.green(` ✔ Synchronized ${destName}`));
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
// Also update app/t.native.d.ts if it exists
|
|
80
|
+
const nativeTypesSrc = path.join(commonDir, 'app', 't.native.d.ts');
|
|
81
|
+
const nativeTypesDest = path.join(root, 'app', 't.native.d.ts');
|
|
82
|
+
if (fs.existsSync(nativeTypesSrc) && fs.existsSync(path.join(root, 'app'))) {
|
|
83
|
+
fs.copyFileSync(nativeTypesSrc, nativeTypesDest);
|
|
84
|
+
console.log(chalk.green(` ✔ Updated app/t.native.d.ts`));
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
console.log(chalk.green(`\n✔ Update complete!\n`));
|
|
89
|
+
console.log(chalk.yellow(` Please run 'npm install' to apply changes.\n`));
|
|
90
|
+
}
|