@titanpl/cli 2.0.4 → 3.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 +2 -2
- package/templates/common/Dockerfile +0 -66
- package/templates/common/_dockerignore +0 -35
- package/templates/common/_gitignore +0 -33
- package/templates/common/app/t.native.d.ts +0 -2043
- package/templates/common/app/t.native.js +0 -39
- package/templates/extension/README.md +0 -69
- package/templates/extension/index.d.ts +0 -27
- package/templates/extension/index.js +0 -17
- package/templates/extension/jsconfig.json +0 -14
- package/templates/extension/native/Cargo.toml +0 -9
- package/templates/extension/native/src/lib.rs +0 -5
- package/templates/extension/package-lock.json +0 -522
- package/templates/extension/package.json +0 -26
- package/templates/extension/titan.json +0 -18
- package/templates/js/app/actions/getuser.js +0 -9
- package/templates/js/app/app.js +0 -7
- package/templates/js/eslint.config.js +0 -5
- package/templates/js/jsconfig.json +0 -27
- package/templates/js/package.json +0 -28
- package/templates/rust-js/app/actions/getuser.js +0 -9
- package/templates/rust-js/app/actions/rust_hello.rs +0 -14
- package/templates/rust-js/app/app.js +0 -9
- package/templates/rust-js/eslint.config.js +0 -5
- package/templates/rust-js/jsconfig.json +0 -27
- package/templates/rust-js/package.json +0 -27
- package/templates/rust-js/titan/bundle.js +0 -157
- package/templates/rust-js/titan/dev.js +0 -323
- package/templates/rust-js/titan/titan.js +0 -126
- package/templates/rust-ts/app/actions/getuser.ts +0 -9
- package/templates/rust-ts/app/actions/rust_hello.rs +0 -14
- package/templates/rust-ts/app/app.ts +0 -9
- package/templates/rust-ts/eslint.config.js +0 -12
- package/templates/rust-ts/package.json +0 -29
- package/templates/rust-ts/titan/bundle.js +0 -163
- package/templates/rust-ts/titan/dev.js +0 -435
- package/templates/rust-ts/titan/titan.d.ts +0 -19
- package/templates/rust-ts/titan/titan.js +0 -124
- package/templates/rust-ts/tsconfig.json +0 -28
- package/templates/ts/app/actions/getuser.ts +0 -9
- package/templates/ts/app/app.ts +0 -7
- package/templates/ts/eslint.config.js +0 -12
- package/templates/ts/package.json +0 -30
- package/templates/ts/tsconfig.json +0 -28
|
@@ -1,124 +0,0 @@
|
|
|
1
|
-
import { bundle } from "./bundle.js";
|
|
2
|
-
import fs from "fs";
|
|
3
|
-
import path from "path";
|
|
4
|
-
|
|
5
|
-
const cyan = (t) => `\x1b[36m${t}\x1b[0m`;
|
|
6
|
-
const green = (t) => `\x1b[32m${t}\x1b[0m`;
|
|
7
|
-
|
|
8
|
-
const routes = {};
|
|
9
|
-
const dynamicRoutes = {};
|
|
10
|
-
const actionMap = {};
|
|
11
|
-
|
|
12
|
-
function addRoute(method, route) {
|
|
13
|
-
const key = `${method.toUpperCase()}:${route}`;
|
|
14
|
-
|
|
15
|
-
return {
|
|
16
|
-
reply(value) {
|
|
17
|
-
routes[key] = {
|
|
18
|
-
type: typeof value === "object" ? "json" : "text",
|
|
19
|
-
value
|
|
20
|
-
};
|
|
21
|
-
},
|
|
22
|
-
|
|
23
|
-
action(name) {
|
|
24
|
-
if (route.includes(":")) {
|
|
25
|
-
if (!dynamicRoutes[method]) dynamicRoutes[method] = [];
|
|
26
|
-
dynamicRoutes[method].push({
|
|
27
|
-
method: method.toUpperCase(),
|
|
28
|
-
pattern: route,
|
|
29
|
-
action: name
|
|
30
|
-
});
|
|
31
|
-
} else {
|
|
32
|
-
routes[key] = {
|
|
33
|
-
type: "action",
|
|
34
|
-
value: name
|
|
35
|
-
};
|
|
36
|
-
actionMap[key] = name;
|
|
37
|
-
}
|
|
38
|
-
}
|
|
39
|
-
};
|
|
40
|
-
}
|
|
41
|
-
|
|
42
|
-
/**
|
|
43
|
-
* @typedef {Object} RouteHandler
|
|
44
|
-
* @property {(value: any) => void} reply - Send a direct response
|
|
45
|
-
* @property {(name: string) => void} action - Bind to a server-side action
|
|
46
|
-
*/
|
|
47
|
-
|
|
48
|
-
/**
|
|
49
|
-
* Titan App Builder
|
|
50
|
-
*/
|
|
51
|
-
const t = {
|
|
52
|
-
/**
|
|
53
|
-
* Define a GET route
|
|
54
|
-
* @param {string} route
|
|
55
|
-
* @returns {RouteHandler}
|
|
56
|
-
*/
|
|
57
|
-
get(route) {
|
|
58
|
-
return addRoute("GET", route);
|
|
59
|
-
},
|
|
60
|
-
|
|
61
|
-
/**
|
|
62
|
-
* Define a POST route
|
|
63
|
-
* @param {string} route
|
|
64
|
-
* @returns {RouteHandler}
|
|
65
|
-
*/
|
|
66
|
-
post(route) {
|
|
67
|
-
return addRoute("POST", route);
|
|
68
|
-
},
|
|
69
|
-
|
|
70
|
-
log(module, msg) {
|
|
71
|
-
console.log(`[\x1b[35m${module}\x1b[0m] ${msg}`);
|
|
72
|
-
},
|
|
73
|
-
|
|
74
|
-
/**
|
|
75
|
-
* Start the Titan Server
|
|
76
|
-
* @param {number} [port=3000]
|
|
77
|
-
* @param {string} [msg=""]
|
|
78
|
-
*/
|
|
79
|
-
async start(port = 3000, msg = "") {
|
|
80
|
-
try {
|
|
81
|
-
console.log(cyan("[Titan] Preparing runtime..."));
|
|
82
|
-
await bundle();
|
|
83
|
-
|
|
84
|
-
const base = path.join(process.cwd(), "server");
|
|
85
|
-
if (!fs.existsSync(base)) {
|
|
86
|
-
fs.mkdirSync(base, { recursive: true });
|
|
87
|
-
}
|
|
88
|
-
|
|
89
|
-
const routesPath = path.join(base, "routes.json");
|
|
90
|
-
const actionMapPath = path.join(base, "action_map.json");
|
|
91
|
-
|
|
92
|
-
fs.writeFileSync(
|
|
93
|
-
routesPath,
|
|
94
|
-
JSON.stringify(
|
|
95
|
-
{
|
|
96
|
-
__config: { port },
|
|
97
|
-
routes,
|
|
98
|
-
__dynamic_routes: Object.values(dynamicRoutes).flat()
|
|
99
|
-
},
|
|
100
|
-
null,
|
|
101
|
-
2
|
|
102
|
-
)
|
|
103
|
-
);
|
|
104
|
-
|
|
105
|
-
fs.writeFileSync(
|
|
106
|
-
actionMapPath,
|
|
107
|
-
JSON.stringify(actionMap, null, 2)
|
|
108
|
-
);
|
|
109
|
-
|
|
110
|
-
console.log(green("✔ Titan metadata written successfully"));
|
|
111
|
-
if (msg) console.log(cyan(msg));
|
|
112
|
-
|
|
113
|
-
} catch (e) {
|
|
114
|
-
console.error(`\x1b[31m[Titan] Build Error: ${e.message}\x1b[0m`);
|
|
115
|
-
process.exit(1);
|
|
116
|
-
}
|
|
117
|
-
}
|
|
118
|
-
};
|
|
119
|
-
|
|
120
|
-
/**
|
|
121
|
-
* Titan App Builder (Alias for t)
|
|
122
|
-
*/
|
|
123
|
-
export const Titan = t;
|
|
124
|
-
export default t;
|
|
@@ -1,28 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"compilerOptions": {
|
|
3
|
-
"target": "ESNext",
|
|
4
|
-
"module": "ESNext",
|
|
5
|
-
"moduleResolution": "node",
|
|
6
|
-
"esModuleInterop": true,
|
|
7
|
-
"forceConsistentCasingInFileNames": true,
|
|
8
|
-
"strict": true,
|
|
9
|
-
"skipLibCheck": true,
|
|
10
|
-
"baseUrl": ".",
|
|
11
|
-
"paths": {
|
|
12
|
-
"@titanpl/native": [
|
|
13
|
-
"app/t.native"
|
|
14
|
-
],
|
|
15
|
-
"@titanpl/route": [
|
|
16
|
-
"./titan/titan"
|
|
17
|
-
],
|
|
18
|
-
"*": [
|
|
19
|
-
"./app/*"
|
|
20
|
-
]
|
|
21
|
-
}
|
|
22
|
-
},
|
|
23
|
-
"include": [
|
|
24
|
-
"app/**/*",
|
|
25
|
-
"titan/**/*",
|
|
26
|
-
"node_modules/**/titan-ext.d.ts"
|
|
27
|
-
]
|
|
28
|
-
}
|
package/templates/ts/app/app.ts
DELETED
|
@@ -1,30 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"name": "{{name}}",
|
|
3
|
-
"description": "A Titan Planet server (TypeScript)",
|
|
4
|
-
"type": "module",
|
|
5
|
-
"titan": {
|
|
6
|
-
"template": "ts"
|
|
7
|
-
},
|
|
8
|
-
"dependencies": {
|
|
9
|
-
"@titanpl/cli": "2.0.4",
|
|
10
|
-
"@titanpl/route": "2.0.4",
|
|
11
|
-
"@titanpl/native": "2.0.4",
|
|
12
|
-
"@titanpl/core": "latest",
|
|
13
|
-
"@titanpl/node": "latest",
|
|
14
|
-
"@titanpl/packet": "2.0.4",
|
|
15
|
-
"typescript": "^5.0.0"
|
|
16
|
-
},
|
|
17
|
-
"scripts": {
|
|
18
|
-
"build": "titan build",
|
|
19
|
-
"dev": "titan dev",
|
|
20
|
-
"start": "titan start",
|
|
21
|
-
"lint": "eslint .",
|
|
22
|
-
"lint:fix": "eslint . --fix"
|
|
23
|
-
},
|
|
24
|
-
"devDependencies": {
|
|
25
|
-
"eslint": "^9.39.2",
|
|
26
|
-
"eslint-plugin-titanpl": "latest",
|
|
27
|
-
"@typescript-eslint/parser": "^8.54.0"
|
|
28
|
-
},
|
|
29
|
-
"version": "2.0.4"
|
|
30
|
-
}
|
|
@@ -1,28 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"compilerOptions": {
|
|
3
|
-
"target": "ESNext",
|
|
4
|
-
"module": "ESNext",
|
|
5
|
-
"moduleResolution": "node",
|
|
6
|
-
"esModuleInterop": true,
|
|
7
|
-
"forceConsistentCasingInFileNames": true,
|
|
8
|
-
"strict": true,
|
|
9
|
-
"skipLibCheck": true,
|
|
10
|
-
"baseUrl": ".",
|
|
11
|
-
"paths": {
|
|
12
|
-
"@titanpl/native": [
|
|
13
|
-
"app/t.native"
|
|
14
|
-
],
|
|
15
|
-
"@titanpl/route": [
|
|
16
|
-
"./titan/titan"
|
|
17
|
-
],
|
|
18
|
-
"*": [
|
|
19
|
-
"./app/*"
|
|
20
|
-
]
|
|
21
|
-
}
|
|
22
|
-
},
|
|
23
|
-
"include": [
|
|
24
|
-
"app/**/*",
|
|
25
|
-
"titan/**/*",
|
|
26
|
-
"node_modules/**/titan-ext.d.ts"
|
|
27
|
-
]
|
|
28
|
-
}
|