@titanpl/cli 2.0.2 → 2.0.3

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 +18 -1
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@titanpl/cli",
3
- "version": "2.0.2",
3
+ "version": "2.0.3",
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.3",
25
+ "@titanpl/engine-linux-x64": "2.0.3",
26
+ "@titanpl/engine-darwin-arm64": "2.0.3"
27
27
  },
28
28
  "dependencies": {
29
- "@titanpl/packet": "2.0.2",
29
+ "@titanpl/packet": "2.0.3",
30
30
  "prompts": "^2.4.2",
31
31
  "commander": "^11.0.0",
32
32
  "chalk": "^4.1.2"
package/src/engine.js CHANGED
@@ -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