@titanpl/packet 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.
- package/js/titan/dev.js +39 -11
- package/package.json +1 -1
- package/ts/titan/dev.js +39 -11
package/js/titan/dev.js
CHANGED
|
@@ -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
|
|
42
|
-
if (fs.existsSync(
|
|
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
|
|
50
|
-
const cliPkgPath =
|
|
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
|
-
|
|
56
|
-
const
|
|
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
|
|
63
|
-
const pkgPath =
|
|
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
|
|
package/package.json
CHANGED
package/ts/titan/dev.js
CHANGED
|
@@ -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
|
|
42
|
-
if (fs.existsSync(
|
|
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
|
|
50
|
-
const cliPkgPath =
|
|
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
|
-
|
|
56
|
-
const
|
|
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
|
|
63
|
-
const pkgPath =
|
|
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
|
|