@codebolt/narrative 1.12.54 → 1.12.57
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/dist/binary.d.ts +2 -1
- package/dist/binary.js +57 -5
- package/package.json +6 -6
package/dist/binary.d.ts
CHANGED
|
@@ -5,6 +5,7 @@
|
|
|
5
5
|
* 1. Explicit path passed as argument
|
|
6
6
|
* 2. CODEBOLT_NARRATIVE_BINARY env var
|
|
7
7
|
* 3. Platform-specific npm package (@codebolt/narrative-{os}-{arch})
|
|
8
|
-
* 4.
|
|
8
|
+
* 4. Workspace / Electron bundled binary locations
|
|
9
|
+
* 5. PATH lookup via `which`
|
|
9
10
|
*/
|
|
10
11
|
export declare function resolveBinary(explicitPath?: string): string;
|
package/dist/binary.js
CHANGED
|
@@ -12,7 +12,8 @@ const BINARY_NAME = process.platform === 'win32' ? 'codebolt-narrative.exe' : 'c
|
|
|
12
12
|
* 1. Explicit path passed as argument
|
|
13
13
|
* 2. CODEBOLT_NARRATIVE_BINARY env var
|
|
14
14
|
* 3. Platform-specific npm package (@codebolt/narrative-{os}-{arch})
|
|
15
|
-
* 4.
|
|
15
|
+
* 4. Workspace / Electron bundled binary locations
|
|
16
|
+
* 5. PATH lookup via `which`
|
|
16
17
|
*/
|
|
17
18
|
function resolveBinary(explicitPath) {
|
|
18
19
|
// 1. Explicit path
|
|
@@ -35,7 +36,12 @@ function resolveBinary(explicitPath) {
|
|
|
35
36
|
if (platformPath) {
|
|
36
37
|
return platformPath;
|
|
37
38
|
}
|
|
38
|
-
// 4.
|
|
39
|
+
// 4. Workspace / Electron bundled binary locations
|
|
40
|
+
const localPath = resolveLocalBinary();
|
|
41
|
+
if (localPath) {
|
|
42
|
+
return localPath;
|
|
43
|
+
}
|
|
44
|
+
// 5. PATH lookup
|
|
39
45
|
const pathResult = resolveFromPath();
|
|
40
46
|
if (pathResult) {
|
|
41
47
|
return pathResult;
|
|
@@ -57,9 +63,7 @@ function resolvePlatformPackage() {
|
|
|
57
63
|
// Binaries inside an ASAR can't be executed directly, so we rewrite the
|
|
58
64
|
// path to the unpacked copy that electron-builder extracts automatically
|
|
59
65
|
// when the file matches an `asarUnpack` glob.
|
|
60
|
-
|
|
61
|
-
binaryPath = binaryPath.replace('app.asar', 'app.asar.unpacked');
|
|
62
|
-
}
|
|
66
|
+
binaryPath = normalizeAsarPath(binaryPath);
|
|
63
67
|
if ((0, fs_1.existsSync)(binaryPath)) {
|
|
64
68
|
return binaryPath;
|
|
65
69
|
}
|
|
@@ -69,6 +73,54 @@ function resolvePlatformPackage() {
|
|
|
69
73
|
}
|
|
70
74
|
return null;
|
|
71
75
|
}
|
|
76
|
+
function resolveLocalBinary() {
|
|
77
|
+
const platformKey = `${process.platform}-${process.arch}`;
|
|
78
|
+
const platformPackage = `@codebolt/narrative-${platformKey}`;
|
|
79
|
+
const candidates = [];
|
|
80
|
+
for (const root of collectSearchRoots()) {
|
|
81
|
+
candidates.push((0, path_1.join)(root, 'node_modules', platformPackage, 'bin', BINARY_NAME), (0, path_1.join)(root, 'packages', 'codeboltNarrative', 'npm', platformKey, 'bin', BINARY_NAME), (0, path_1.join)(root, 'codeboltNarrative', 'npm', platformKey, 'bin', BINARY_NAME));
|
|
82
|
+
}
|
|
83
|
+
for (const candidate of Array.from(new Set(candidates.map(normalizeAsarPath)))) {
|
|
84
|
+
if ((0, fs_1.existsSync)(candidate)) {
|
|
85
|
+
return candidate;
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
return null;
|
|
89
|
+
}
|
|
90
|
+
function collectSearchRoots() {
|
|
91
|
+
const roots = [];
|
|
92
|
+
const addRoot = (root) => {
|
|
93
|
+
if (root)
|
|
94
|
+
roots.push(root);
|
|
95
|
+
};
|
|
96
|
+
addRoot(__dirname);
|
|
97
|
+
addRoot(process.cwd());
|
|
98
|
+
addRoot(require.main?.filename ? (0, path_1.dirname)(require.main.filename) : undefined);
|
|
99
|
+
const resourcesPath = process.resourcesPath;
|
|
100
|
+
if (resourcesPath) {
|
|
101
|
+
addRoot(resourcesPath);
|
|
102
|
+
addRoot((0, path_1.join)(resourcesPath, 'app'));
|
|
103
|
+
addRoot((0, path_1.join)(resourcesPath, 'app.asar'));
|
|
104
|
+
addRoot((0, path_1.join)(resourcesPath, 'app.asar.unpacked'));
|
|
105
|
+
}
|
|
106
|
+
const parentRoots = [];
|
|
107
|
+
for (const root of roots) {
|
|
108
|
+
let current = normalizeAsarPath(root);
|
|
109
|
+
for (let i = 0; i < 10; i += 1) {
|
|
110
|
+
parentRoots.push(current);
|
|
111
|
+
const parent = (0, path_1.dirname)(current);
|
|
112
|
+
if (parent === current)
|
|
113
|
+
break;
|
|
114
|
+
current = parent;
|
|
115
|
+
}
|
|
116
|
+
}
|
|
117
|
+
return Array.from(new Set(parentRoots));
|
|
118
|
+
}
|
|
119
|
+
function normalizeAsarPath(pathValue) {
|
|
120
|
+
return pathValue.includes('app.asar') && !pathValue.includes('app.asar.unpacked')
|
|
121
|
+
? pathValue.replace('app.asar', 'app.asar.unpacked')
|
|
122
|
+
: pathValue;
|
|
123
|
+
}
|
|
72
124
|
function resolveFromPath() {
|
|
73
125
|
try {
|
|
74
126
|
const cmd = process.platform === 'win32' ? 'where' : 'which';
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@codebolt/narrative",
|
|
3
|
-
"version": "1.12.
|
|
3
|
+
"version": "1.12.57",
|
|
4
4
|
"description": "TypeScript client for the Codebolt Narrative Engine",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"types": "dist/index.d.ts",
|
|
@@ -17,11 +17,11 @@
|
|
|
17
17
|
"dist/**/*"
|
|
18
18
|
],
|
|
19
19
|
"optionalDependencies": {
|
|
20
|
-
"@codebolt/narrative-darwin-arm64": "1.12.
|
|
21
|
-
"@codebolt/narrative-darwin-x64": "1.12.
|
|
22
|
-
"@codebolt/narrative-linux-x64": "1.12.
|
|
23
|
-
"@codebolt/narrative-linux-arm64": "1.12.
|
|
24
|
-
"@codebolt/narrative-win32-x64": "1.12.
|
|
20
|
+
"@codebolt/narrative-darwin-arm64": "1.12.57",
|
|
21
|
+
"@codebolt/narrative-darwin-x64": "1.12.57",
|
|
22
|
+
"@codebolt/narrative-linux-x64": "1.12.57",
|
|
23
|
+
"@codebolt/narrative-linux-arm64": "1.12.57",
|
|
24
|
+
"@codebolt/narrative-win32-x64": "1.12.57"
|
|
25
25
|
},
|
|
26
26
|
"license": "MIT"
|
|
27
27
|
}
|