@titanpl/cli 26.17.0 → 26.17.2

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.
Files changed (2) hide show
  1. package/package.json +5 -5
  2. package/src/engine.js +28 -6
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@titanpl/cli",
3
- "version": "26.17.0",
3
+ "version": "26.17.2",
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",
@@ -19,12 +19,12 @@
19
19
  "titan": "./index.js"
20
20
  },
21
21
  "optionalDependencies": {
22
- "@titanpl/engine-win32-x64": "26.17.0",
23
- "@titanpl/engine-linux-x64": "26.17.0",
24
- "@titanpl/engine-darwin-arm64": "26.17.0"
22
+ "@titanpl/engine-win32-x64": "26.17.2",
23
+ "@titanpl/engine-linux-x64": "26.17.2",
24
+ "@titanpl/engine-darwin-arm64": "26.17.2"
25
25
  },
26
26
  "dependencies": {
27
- "@titanpl/packet": "26.17.0",
27
+ "@titanpl/packet": "26.17.2",
28
28
  "prompts": "^2.4.2",
29
29
  "commander": "^11.0.0",
30
30
  "chalk": "^4.1.2"
package/src/engine.js CHANGED
@@ -16,16 +16,38 @@ export function getEngineBinaryPath() {
16
16
  const pkgName = `@titanpl/engine-${platform}-${arch}`;
17
17
  const binName = platform === 'win32' ? 'titan-server.exe' : 'titan-server';
18
18
 
19
- // 1. Monorepo Dev Fallback
20
- const serverExeName = platform === 'win32' ? 'titan-server.exe' : 'titan-server';
21
- const localFallback = path.resolve(__dirname, '..', '..', '..', 'engine', 'target', 'release', serverExeName);
22
- if (fs.existsSync(localFallback)) {
23
- return localFallback;
19
+ // 1. Robust Binary Discovery (Monorepo, Local, or Global)
20
+ const searchPaths = [
21
+ __dirname,
22
+ process.cwd(),
23
+ path.join(process.cwd(), '..'),
24
+ path.join(process.cwd(), '..', '..')
25
+ ];
26
+
27
+ for (let startPath of searchPaths) {
28
+ let current = startPath;
29
+ for (let i = 0; i < 8; i++) {
30
+ const potential = path.join(current, 'engine', 'target', 'release', binName);
31
+ if (fs.existsSync(potential)) return potential;
32
+
33
+ const parent = path.dirname(current);
34
+ if (parent === current) break;
35
+ current = parent;
36
+ }
24
37
  }
25
38
 
26
39
  // 2. Resolve installed optional dependency
27
40
  try {
28
- const pkgPath = require.resolve(`${pkgName}/package.json`);
41
+ // We use a try/catch specifically for the resolve to provide a better diagnostic
42
+ let pkgPath;
43
+ try {
44
+ pkgPath = require.resolve(`${pkgName}/package.json`);
45
+ } catch (e) {
46
+ // Fallback: check if the binary exists in a standard location even if require.resolve fails
47
+ const fallbackBin = path.join(process.cwd(), 'node_modules', pkgName, 'bin', binName);
48
+ if (fs.existsSync(fallbackBin)) return fallbackBin;
49
+ throw e;
50
+ }
29
51
  const pkgDir = path.dirname(pkgPath);
30
52
  const binaryPath = path.join(pkgDir, 'bin', binName);
31
53