titanpl 2.0.2 → 2.0.4

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 CHANGED
@@ -80,7 +80,7 @@ Titan handles the integration automatically.
80
80
 
81
81
  # 🚀 Quick Start
82
82
  ### 1. Prerequisites
83
- * **Rust** (latest stable): [Install Rust](https://rust-lang.org/tools/install/)
83
+ * **Rust** (latest stable): [Install Rust](https://rust-lang.org/tools/install/) [Optional]
84
84
  * **Node.js** (v18+): Required for CLI and JS tooling.
85
85
 
86
86
  ### 2. Install CLI
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "titanpl",
3
- "version": "2.0.2",
3
+ "version": "2.0.4",
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",
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@titanpl/cli",
3
- "version": "2.0.2",
3
+ "version": "2.0.4",
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",
@@ -21,12 +21,12 @@
21
21
  "tit": "./index.js"
22
22
  },
23
23
  "optionalDependencies": {
24
- "@titanpl/engine-win32-x64": "2.0.2",
25
- "@titanpl/engine-linux-x64": "2.0.2",
26
- "@titanpl/engine-darwin-arm64": "2.0.2"
24
+ "@titanpl/engine-win32-x64": "2.0.4",
25
+ "@titanpl/engine-linux-x64": "2.0.4",
26
+ "@titanpl/engine-darwin-arm64": "2.0.4"
27
27
  },
28
28
  "dependencies": {
29
- "@titanpl/packet": "2.0.2",
29
+ "@titanpl/packet": "2.0.4",
30
30
  "prompts": "^2.4.2",
31
31
  "commander": "^11.0.0",
32
32
  "chalk": "^4.1.2"
@@ -99,8 +99,27 @@ export async function initCommand(projectName, templateName) {
99
99
  let templateDir = path.resolve(__dirname, '..', '..', '..', '..', 'templates', selectedTemplate);
100
100
  let commonDir = path.resolve(__dirname, '..', '..', '..', '..', 'templates', 'common');
101
101
 
102
+ const tryPaths = [
103
+ // 1. Monorepo root / titanpl package root
104
+ { t: path.resolve(__dirname, '..', '..', '..', '..', 'templates', selectedTemplate), c: path.resolve(__dirname, '..', '..', '..', '..', 'templates', 'common') },
105
+ // 2. Published CLI package (global install / npm package)
106
+ { t: path.resolve(__dirname, '..', '..', 'templates', selectedTemplate), c: path.resolve(__dirname, '..', '..', 'templates', 'common') },
107
+ // 3. Fallback: one dir up? Just in case
108
+ { t: path.resolve(__dirname, '..', '..', '..', 'templates', selectedTemplate), c: path.resolve(__dirname, '..', '..', '..', 'templates', 'common') }
109
+ ];
110
+
111
+ let found = false;
112
+ for (const paths of tryPaths) {
113
+ if (fs.existsSync(paths.t) && fs.existsSync(paths.c)) {
114
+ templateDir = paths.t;
115
+ commonDir = paths.c;
116
+ found = true;
117
+ break;
118
+ }
119
+ }
120
+
102
121
  // Robust monorepo/fallback template search: look upwards from cwd
103
- if (!fs.existsSync(templateDir) || !fs.existsSync(commonDir)) {
122
+ if (!found) {
104
123
  let searchDir = process.cwd();
105
124
  while (searchDir !== path.parse(searchDir).root) {
106
125
  const potentialTemplateDir = path.join(searchDir, 'templates', selectedTemplate);
@@ -108,6 +127,7 @@ export async function initCommand(projectName, templateName) {
108
127
  if (fs.existsSync(potentialTemplateDir) && fs.existsSync(potentialCommonDir)) {
109
128
  templateDir = potentialTemplateDir;
110
129
  commonDir = potentialCommonDir;
130
+ found = true;
111
131
  break;
112
132
  }
113
133
  const sdkPotentialTemplateDir = path.join(searchDir, 'titanpl-sdk', 'templates', selectedTemplate);
@@ -115,13 +135,14 @@ export async function initCommand(projectName, templateName) {
115
135
  if (fs.existsSync(sdkPotentialTemplateDir) && fs.existsSync(sdkPotentialCommonDir)) {
116
136
  templateDir = sdkPotentialTemplateDir;
117
137
  commonDir = sdkPotentialCommonDir;
138
+ found = true;
118
139
  break;
119
140
  }
120
141
  searchDir = path.dirname(searchDir);
121
142
  }
122
143
  }
123
144
 
124
- if (!fs.existsSync(templateDir) || !fs.existsSync(commonDir)) {
145
+ if (!found) {
125
146
  console.log(chalk.red(`✖ Error finding template paths. Are you in a valid Titan monorepo?`));
126
147
  process.exit(1);
127
148
  }
@@ -2,7 +2,7 @@ import os from 'os';
2
2
  import path from 'path';
3
3
  import fs from 'fs';
4
4
  import { createRequire } from 'module';
5
- import { spawn } from 'child_process';
5
+ import { spawn, execSync } from 'child_process';
6
6
  import { fileURLToPath } from 'url';
7
7
 
8
8
  const __filename = fileURLToPath(import.meta.url);
@@ -51,6 +51,23 @@ export function resolveEngineBinaryPath() {
51
51
  const siblingBin = path.join(cliParent, pkgName, 'bin', binName);
52
52
  if (fs.existsSync(siblingBin)) return siblingBin;
53
53
 
54
+ // 4. Walk upwards from current dir searching for node_modules/@titanpl/engine-...
55
+ let searchDir = process.cwd();
56
+ for (let i = 0; i < 5; i++) {
57
+ const nmBin = path.join(searchDir, 'node_modules', pkgName, 'bin', binName);
58
+ if (fs.existsSync(nmBin)) return nmBin;
59
+ const parent = path.dirname(searchDir);
60
+ if (parent === searchDir) break;
61
+ searchDir = parent;
62
+ }
63
+
64
+ // 5. Check global npm
65
+ try {
66
+ const globalModules = execSync('npm root -g').toString().trim();
67
+ const globalBin = path.join(globalModules, pkgName, 'bin', binName);
68
+ if (fs.existsSync(globalBin)) return globalBin;
69
+ } catch (e) { }
70
+
54
71
  return null;
55
72
  }
56
73
 
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@titanpl/engine-darwin-arm64",
3
- "version": "2.0.2",
3
+ "version": "2.0.4",
4
4
  "os": [
5
5
  "darwin"
6
6
  ],
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@titanpl/engine-linux-x64",
3
- "version": "2.0.2",
3
+ "version": "2.0.4",
4
4
  "os": [
5
5
  "linux"
6
6
  ],
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@titanpl/engine-win32-x64",
3
- "version": "2.0.2",
3
+ "version": "2.0.4",
4
4
  "os": [
5
5
  "win32"
6
6
  ],
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@titanpl/native",
3
- "version": "2.0.2",
3
+ "version": "2.0.4",
4
4
  "description": "Titan native utilities package",
5
5
  "type": "module",
6
6
  "keywords": [
@@ -38,33 +38,53 @@ function getEngineBinaryPath(root) {
38
38
  // 1. Monorepo search (dev environment)
39
39
  let current = root;
40
40
  for (let i = 0; i < 5; i++) {
41
- const potential = path.join(current, 'engine', 'target', 'release', binName);
42
- if (fs.existsSync(potential)) return potential;
41
+ const potentialRelease = path.join(current, 'engine', 'target', 'release', binName);
42
+ if (fs.existsSync(potentialRelease)) return potentialRelease;
43
+ const potentialDebug = path.join(current, 'engine', 'target', 'debug', binName);
44
+ if (fs.existsSync(potentialDebug)) return potentialDebug;
45
+
46
+ // Check sibling monorepo folder for test-apps
47
+ const siblingRelease = path.join(current, 'titanpl', 'engine', 'target', 'release', binName);
48
+ if (fs.existsSync(siblingRelease)) return siblingRelease;
49
+ const siblingDebug = path.join(current, 'titanpl', 'engine', 'target', 'debug', binName);
50
+ if (fs.existsSync(siblingDebug)) return siblingDebug;
51
+ const siblingPkg = path.join(current, 'titanpl', 'packages', pkgName.replace('@titanpl/', ''), 'bin', binName);
52
+ if (fs.existsSync(siblingPkg)) return siblingPkg;
53
+
43
54
  current = path.dirname(current);
44
55
  }
45
56
 
46
57
  // 2. Search relative to @titanpl/cli (where optionalDependencies are installed)
47
- // This is the primary path for globally-installed CLI users.
48
58
  try {
49
- const require = createRequire(import.meta.url);
50
- const cliPkgPath = require.resolve('@titanpl/cli/package.json');
59
+ const req = createRequire(import.meta.url);
60
+ const cliPkgPath = req.resolve('@titanpl/cli/package.json');
51
61
  const cliDir = path.dirname(cliPkgPath);
52
- // Check cli's own node_modules (global install sibling)
53
62
  const cliNodeModulesBin = path.join(cliDir, 'node_modules', pkgName, 'bin', binName);
54
63
  if (fs.existsSync(cliNodeModulesBin)) return cliNodeModulesBin;
55
- // Check parent node_modules (hoisted global install)
56
- const parentNodeModulesBin = path.join(path.dirname(cliDir), pkgName, 'bin', binName);
64
+
65
+ const nodeModulesDir = path.dirname(path.dirname(cliDir));
66
+ const parentNodeModulesBin = path.join(nodeModulesDir, pkgName, 'bin', binName);
57
67
  if (fs.existsSync(parentNodeModulesBin)) return parentNodeModulesBin;
58
68
  } catch (e) { }
59
69
 
60
- // 3. Search in the project's own node_modules
70
+ // 3. Search in the project's own node_modules directly
61
71
  try {
62
- const require = createRequire(import.meta.url);
63
- const pkgPath = require.resolve(`${pkgName}/package.json`);
72
+ const req = createRequire(import.meta.url);
73
+ const pkgPath = req.resolve(`${pkgName}/package.json`);
64
74
  const binPath = path.join(path.dirname(pkgPath), 'bin', binName);
65
75
  if (fs.existsSync(binPath)) return binPath;
66
76
  } catch (e) { }
67
77
 
78
+ // Walk upwards from current dir searching for node_modules/@titanpl/engine-...
79
+ let searchDir = process.cwd();
80
+ for (let i = 0; i < 5; i++) {
81
+ const nmBin = path.join(searchDir, 'node_modules', pkgName, 'bin', binName);
82
+ if (fs.existsSync(nmBin)) return nmBin;
83
+ const parent = path.dirname(searchDir);
84
+ if (parent === searchDir) break;
85
+ searchDir = parent;
86
+ }
87
+
68
88
  // 4. Fallback: check common global npm paths
69
89
  const globalSearchRoots = [
70
90
  process.env.npm_config_prefix,
@@ -76,8 +96,16 @@ function getEngineBinaryPath(root) {
76
96
  for (const gRoot of globalSearchRoots) {
77
97
  const gBin = path.join(gRoot, 'node_modules', pkgName, 'bin', binName);
78
98
  if (fs.existsSync(gBin)) return gBin;
99
+ const libNodeModulesBin = path.join(gRoot, 'lib', 'node_modules', pkgName, 'bin', binName);
100
+ if (fs.existsSync(libNodeModulesBin)) return libNodeModulesBin;
79
101
  }
80
102
 
103
+ try {
104
+ const globalModules = execSync('npm root -g').toString().trim();
105
+ const globalBin = path.join(globalModules, pkgName, 'bin', binName);
106
+ if (fs.existsSync(globalBin)) return globalBin;
107
+ } catch (e) { }
108
+
81
109
  return null;
82
110
  }
83
111
 
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@titanpl/packet",
3
- "version": "2.0.2",
3
+ "version": "2.0.4",
4
4
  "description": "The bundler for TitanPl servers.",
5
5
  "keywords": [
6
6
  "bundler",
@@ -38,33 +38,53 @@ function getEngineBinaryPath(root) {
38
38
  // 1. Monorepo search (dev environment)
39
39
  let current = root;
40
40
  for (let i = 0; i < 5; i++) {
41
- const potential = path.join(current, 'engine', 'target', 'release', binName);
42
- if (fs.existsSync(potential)) return potential;
41
+ const potentialRelease = path.join(current, 'engine', 'target', 'release', binName);
42
+ if (fs.existsSync(potentialRelease)) return potentialRelease;
43
+ const potentialDebug = path.join(current, 'engine', 'target', 'debug', binName);
44
+ if (fs.existsSync(potentialDebug)) return potentialDebug;
45
+
46
+ // Check sibling monorepo folder for test-apps
47
+ const siblingRelease = path.join(current, 'titanpl', 'engine', 'target', 'release', binName);
48
+ if (fs.existsSync(siblingRelease)) return siblingRelease;
49
+ const siblingDebug = path.join(current, 'titanpl', 'engine', 'target', 'debug', binName);
50
+ if (fs.existsSync(siblingDebug)) return siblingDebug;
51
+ const siblingPkg = path.join(current, 'titanpl', 'packages', pkgName.replace('@titanpl/', ''), 'bin', binName);
52
+ if (fs.existsSync(siblingPkg)) return siblingPkg;
53
+
43
54
  current = path.dirname(current);
44
55
  }
45
56
 
46
57
  // 2. Search relative to @titanpl/cli (where optionalDependencies are installed)
47
- // This is the primary path for globally-installed CLI users.
48
58
  try {
49
- const require = createRequire(import.meta.url);
50
- const cliPkgPath = require.resolve('@titanpl/cli/package.json');
59
+ const req = createRequire(import.meta.url);
60
+ const cliPkgPath = req.resolve('@titanpl/cli/package.json');
51
61
  const cliDir = path.dirname(cliPkgPath);
52
- // Check cli's own node_modules (global install sibling)
53
62
  const cliNodeModulesBin = path.join(cliDir, 'node_modules', pkgName, 'bin', binName);
54
63
  if (fs.existsSync(cliNodeModulesBin)) return cliNodeModulesBin;
55
- // Check parent node_modules (hoisted global install)
56
- const parentNodeModulesBin = path.join(path.dirname(cliDir), pkgName, 'bin', binName);
64
+
65
+ const nodeModulesDir = path.dirname(path.dirname(cliDir));
66
+ const parentNodeModulesBin = path.join(nodeModulesDir, pkgName, 'bin', binName);
57
67
  if (fs.existsSync(parentNodeModulesBin)) return parentNodeModulesBin;
58
68
  } catch (e) { }
59
69
 
60
- // 3. Search in the project's own node_modules
70
+ // 3. Search in the project's own node_modules directly
61
71
  try {
62
- const require = createRequire(import.meta.url);
63
- const pkgPath = require.resolve(`${pkgName}/package.json`);
72
+ const req = createRequire(import.meta.url);
73
+ const pkgPath = req.resolve(`${pkgName}/package.json`);
64
74
  const binPath = path.join(path.dirname(pkgPath), 'bin', binName);
65
75
  if (fs.existsSync(binPath)) return binPath;
66
76
  } catch (e) { }
67
77
 
78
+ // Walk upwards from current dir searching for node_modules/@titanpl/engine-...
79
+ let searchDir = process.cwd();
80
+ for (let i = 0; i < 5; i++) {
81
+ const nmBin = path.join(searchDir, 'node_modules', pkgName, 'bin', binName);
82
+ if (fs.existsSync(nmBin)) return nmBin;
83
+ const parent = path.dirname(searchDir);
84
+ if (parent === searchDir) break;
85
+ searchDir = parent;
86
+ }
87
+
68
88
  // 4. Fallback: check common global npm paths
69
89
  const globalSearchRoots = [
70
90
  process.env.npm_config_prefix,
@@ -76,8 +96,16 @@ function getEngineBinaryPath(root) {
76
96
  for (const gRoot of globalSearchRoots) {
77
97
  const gBin = path.join(gRoot, 'node_modules', pkgName, 'bin', binName);
78
98
  if (fs.existsSync(gBin)) return gBin;
99
+ const libNodeModulesBin = path.join(gRoot, 'lib', 'node_modules', pkgName, 'bin', binName);
100
+ if (fs.existsSync(libNodeModulesBin)) return libNodeModulesBin;
79
101
  }
80
102
 
103
+ try {
104
+ const globalModules = execSync('npm root -g').toString().trim();
105
+ const globalBin = path.join(globalModules, pkgName, 'bin', binName);
106
+ if (fs.existsSync(globalBin)) return globalBin;
107
+ } catch (e) { }
108
+
81
109
  return null;
82
110
  }
83
111
 
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@titanpl/route",
3
- "version": "2.0.2",
3
+ "version": "2.0.4",
4
4
  "description": "Titan routing DSL",
5
5
  "type": "module",
6
6
  "main": "index.js",
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "{{name}}",
3
- "version": "2.0.2",
3
+ "version": "2.0.4",
4
4
  "description": "A Titan Planet extension",
5
5
  "main": "index.js",
6
6
  "types": "index.d.ts",
@@ -18,7 +18,7 @@
18
18
  "@titanpl/core": "latest",
19
19
  "chokidar": "^5.0.0",
20
20
  "esbuild": "^0.27.2",
21
- "titanpl-sdk": "2.0.2"
21
+ "titanpl-sdk": "2.0.4"
22
22
  },
23
23
  "devDependencies": {
24
24
  "@tgrv/microgravity": "latest"
@@ -6,12 +6,12 @@
6
6
  "template": "js"
7
7
  },
8
8
  "dependencies": {
9
- "@titanpl/cli": "2.0.2",
10
- "@titanpl/route": "2.0.2",
11
- "@titanpl/native": "2.0.2",
9
+ "@titanpl/cli": "2.0.4",
10
+ "@titanpl/route": "2.0.4",
11
+ "@titanpl/native": "2.0.4",
12
12
  "@titanpl/core": "latest",
13
13
  "@titanpl/node": "latest",
14
- "@titanpl/packet": "2.0.2"
14
+ "@titanpl/packet": "2.0.4"
15
15
  },
16
16
  "scripts": {
17
17
  "build": "titan build",
@@ -24,5 +24,5 @@
24
24
  "eslint": "^9.39.2",
25
25
  "eslint-plugin-titanpl": "latest"
26
26
  },
27
- "version": "2.0.2"
27
+ "version": "2.0.4"
28
28
  }
@@ -1,15 +1,15 @@
1
1
  {
2
2
  "name": "titanpl",
3
- "version": "2.0.2",
3
+ "version": "2.0.4",
4
4
  "description": "A Titan Planet server",
5
5
  "type": "module",
6
6
  "titan": {
7
7
  "template": "rust-js"
8
8
  },
9
9
  "dependencies": {
10
- "@titanpl/cli": "2.0.2",
11
- "@titanpl/route": "2.0.2",
12
- "@titanpl/native": "2.0.2",
10
+ "@titanpl/cli": "2.0.4",
11
+ "@titanpl/route": "2.0.4",
12
+ "@titanpl/native": "2.0.4",
13
13
  "@titanpl/core": "latest",
14
14
  "@titanpl/node": "latest"
15
15
  },
@@ -1,15 +1,15 @@
1
1
  {
2
2
  "name": "titanpl",
3
- "version": "2.0.2",
3
+ "version": "2.0.4",
4
4
  "description": "A Titan Planet server (Rust + TypeScript)",
5
5
  "type": "module",
6
6
  "titan": {
7
7
  "template": "rust-ts"
8
8
  },
9
9
  "dependencies": {
10
- "@titanpl/cli": "2.0.2",
11
- "@titanpl/route": "2.0.2",
12
- "@titanpl/native": "2.0.2",
10
+ "@titanpl/cli": "2.0.4",
11
+ "@titanpl/route": "2.0.4",
12
+ "@titanpl/native": "2.0.4",
13
13
  "@titanpl/core": "latest",
14
14
  "@titanpl/node": "latest",
15
15
  "typescript": "^5.0.0"
@@ -6,12 +6,12 @@
6
6
  "template": "ts"
7
7
  },
8
8
  "dependencies": {
9
- "@titanpl/cli": "2.0.2",
10
- "@titanpl/route": "2.0.2",
11
- "@titanpl/native": "2.0.2",
9
+ "@titanpl/cli": "2.0.4",
10
+ "@titanpl/route": "2.0.4",
11
+ "@titanpl/native": "2.0.4",
12
12
  "@titanpl/core": "latest",
13
13
  "@titanpl/node": "latest",
14
- "@titanpl/packet": "2.0.2",
14
+ "@titanpl/packet": "2.0.4",
15
15
  "typescript": "^5.0.0"
16
16
  },
17
17
  "scripts": {
@@ -26,5 +26,5 @@
26
26
  "eslint-plugin-titanpl": "latest",
27
27
  "@typescript-eslint/parser": "^8.54.0"
28
28
  },
29
- "version": "2.0.2"
29
+ "version": "2.0.4"
30
30
  }
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "titanpl-sdk",
3
- "version": "2.0.2",
3
+ "version": "2.0.4",
4
4
  "description": "Development SDK for Titan Planet. Provides TypeScript type definitions for the global 't' runtime object and a 'lite' test-harness runtime for building and verifying extensions.",
5
5
  "main": "index.js",
6
6
  "type": "module",