@fabr-client/core 1.0.0 → 1.0.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.
- package/README.md +12 -0
- package/bin/fabr-client.js +171 -170
- package/package.json +9 -7
- package/postinstall.js +95 -94
package/README.md
CHANGED
|
@@ -48,6 +48,7 @@ Published platform packages:
|
|
|
48
48
|
- `@fabr-client/core-win32-x64`
|
|
49
49
|
- `@fabr-client/core-darwin-x64`
|
|
50
50
|
- `@fabr-client/core-darwin-arm64`
|
|
51
|
+
- `@fabr-client/core-linux-arm64`
|
|
51
52
|
|
|
52
53
|
## Publish Checklist
|
|
53
54
|
|
|
@@ -85,6 +86,17 @@ On macOS, build both `darwin-x64` and `darwin-arm64` payloads:
|
|
|
85
86
|
--codex-runtime-repo /path/to/codex-runtime
|
|
86
87
|
```
|
|
87
88
|
|
|
89
|
+
On Linux ARM64, build the `linux-arm64` payload on an ARM64 Linux build host:
|
|
90
|
+
|
|
91
|
+
```bash
|
|
92
|
+
./scripts/package-fabr-client.sh \
|
|
93
|
+
--profile release \
|
|
94
|
+
--target aarch64-unknown-linux-gnu \
|
|
95
|
+
--pack-npm \
|
|
96
|
+
--codex-runtime-mode build \
|
|
97
|
+
--codex-runtime-repo /path/to/codex-runtime
|
|
98
|
+
```
|
|
99
|
+
|
|
88
100
|
Validate and publish:
|
|
89
101
|
|
|
90
102
|
```bash
|
package/bin/fabr-client.js
CHANGED
|
@@ -13,181 +13,182 @@ const packageByPlatform = {
|
|
|
13
13
|
"win32-x64": "@fabr-client/core-win32-x64",
|
|
14
14
|
"darwin-x64": "@fabr-client/core-darwin-x64",
|
|
15
15
|
"darwin-arm64": "@fabr-client/core-darwin-arm64",
|
|
16
|
+
"linux-arm64": "@fabr-client/core-linux-arm64",
|
|
16
17
|
};
|
|
17
18
|
|
|
18
|
-
function resolvePlatformPackageBinary(pkg) {
|
|
19
|
-
if (!pkg) {
|
|
20
|
-
return null;
|
|
21
|
-
}
|
|
22
|
-
try {
|
|
23
|
-
return path.join(path.dirname(require.resolve(`${pkg}/package.json`)), "bin", exe);
|
|
24
|
-
} catch {
|
|
25
|
-
return null;
|
|
26
|
-
}
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
function npmCommand() {
|
|
30
|
-
const npmExecPath = process.env.npm_execpath;
|
|
31
|
-
if (npmExecPath) {
|
|
32
|
-
return { command: process.execPath, args: [npmExecPath] };
|
|
33
|
-
}
|
|
34
|
-
return {
|
|
35
|
-
command: platform === "win32" ? "npm.cmd" : "npm",
|
|
36
|
-
args: [],
|
|
37
|
-
};
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
function npmSpawnOptions(cwd) {
|
|
41
|
-
const npm = npmCommand();
|
|
42
|
-
return {
|
|
43
|
-
npm,
|
|
44
|
-
options: {
|
|
45
|
-
cwd,
|
|
46
|
-
env: process.env,
|
|
47
|
-
shell: platform === "win32" && npm.command.endsWith(".cmd"),
|
|
48
|
-
stdio: "inherit",
|
|
49
|
-
windowsHide: true,
|
|
50
|
-
},
|
|
51
|
-
};
|
|
52
|
-
}
|
|
53
|
-
|
|
54
|
-
function packageSpec(pkg) {
|
|
55
|
-
if (process.env.FABR_CLIENT_PLATFORM_PACKAGE_SPEC) {
|
|
56
|
-
return process.env.FABR_CLIENT_PLATFORM_PACKAGE_SPEC;
|
|
57
|
-
}
|
|
58
|
-
if (process.env.FABR_CLIENT_PLATFORM_PACKAGE_TARBALL) {
|
|
59
|
-
return process.env.FABR_CLIENT_PLATFORM_PACKAGE_TARBALL;
|
|
60
|
-
}
|
|
61
|
-
|
|
62
|
-
const ownPackage = require("../package.json");
|
|
63
|
-
const version = ownPackage.optionalDependencies?.[pkg] || ownPackage.version;
|
|
64
|
-
return `${pkg}@${version}`;
|
|
65
|
-
}
|
|
66
|
-
|
|
67
|
-
function runNpmInstall(label, args, cwd) {
|
|
68
|
-
const { npm, options } = npmSpawnOptions(cwd);
|
|
69
|
-
console.error(label);
|
|
70
|
-
const result = spawnSync(npm.command, [...npm.args, ...args], options);
|
|
71
|
-
|
|
72
|
-
if (result.error || result.status !== 0) {
|
|
73
|
-
const message = result.error ? result.error.message : `npm exited with status ${result.status}`;
|
|
74
|
-
console.error(`${label} failed: ${message}`);
|
|
75
|
-
return false;
|
|
76
|
-
}
|
|
77
|
-
|
|
78
|
-
return true;
|
|
79
|
-
}
|
|
80
|
-
|
|
81
|
-
function installPlatformPackageLocal(spec) {
|
|
82
|
-
return runNpmInstall(
|
|
83
|
-
`Installing Fabr Client native payload: ${spec}`,
|
|
84
|
-
[
|
|
85
|
-
"install",
|
|
86
|
-
spec,
|
|
87
|
-
"--no-save",
|
|
88
|
-
"--package-lock=false",
|
|
89
|
-
"--include=optional",
|
|
90
|
-
],
|
|
91
|
-
path.join(__dirname, ".."),
|
|
92
|
-
);
|
|
93
|
-
}
|
|
94
|
-
|
|
95
|
-
function installPlatformPackageGlobal(spec) {
|
|
96
|
-
return runNpmInstall(
|
|
97
|
-
`Installing Fabr Client native payload globally: ${spec}`,
|
|
98
|
-
[
|
|
99
|
-
"install",
|
|
100
|
-
"-g",
|
|
101
|
-
spec,
|
|
102
|
-
"--include=optional",
|
|
103
|
-
],
|
|
104
|
-
path.join(__dirname, ".."),
|
|
105
|
-
);
|
|
106
|
-
}
|
|
107
|
-
|
|
108
|
-
function installPlatformPackageGlobalFromFallbackRegistry(spec) {
|
|
109
|
-
if (process.env.FABR_CLIENT_SKIP_REGISTRY_FALLBACK === "1") {
|
|
110
|
-
return false;
|
|
111
|
-
}
|
|
112
|
-
const registry =
|
|
113
|
-
process.env.FABR_CLIENT_NPM_FALLBACK_REGISTRY || "https://registry.npmjs.org";
|
|
114
|
-
return runNpmInstall(
|
|
115
|
-
`Installing Fabr Client native payload globally from fallback registry: ${spec}`,
|
|
116
|
-
[
|
|
117
|
-
"install",
|
|
118
|
-
"-g",
|
|
119
|
-
spec,
|
|
120
|
-
"--include=optional",
|
|
121
|
-
`--registry=${registry}`,
|
|
122
|
-
],
|
|
123
|
-
path.join(__dirname, ".."),
|
|
124
|
-
);
|
|
125
|
-
}
|
|
126
|
-
|
|
127
|
-
function resolveInstalledBinary(pkg) {
|
|
128
|
-
const binary = resolvePlatformPackageBinary(pkg);
|
|
129
|
-
return binary && fs.existsSync(binary) ? binary : null;
|
|
130
|
-
}
|
|
131
|
-
|
|
132
|
-
function installAndResolvePlatformPackage(pkg) {
|
|
133
|
-
if (!pkg || process.env.FABR_CLIENT_SKIP_PLATFORM_INSTALL === "1") {
|
|
134
|
-
return null;
|
|
135
|
-
}
|
|
136
|
-
|
|
137
|
-
const spec = packageSpec(pkg);
|
|
138
|
-
if (installPlatformPackageLocal(spec)) {
|
|
139
|
-
const binary = resolveInstalledBinary(pkg);
|
|
140
|
-
if (binary) {
|
|
141
|
-
return binary;
|
|
142
|
-
}
|
|
143
|
-
}
|
|
144
|
-
|
|
145
|
-
if (installPlatformPackageGlobal(spec)) {
|
|
146
|
-
const binary = resolveInstalledBinary(pkg);
|
|
147
|
-
if (binary) {
|
|
148
|
-
return binary;
|
|
149
|
-
}
|
|
150
|
-
}
|
|
151
|
-
|
|
152
|
-
if (installPlatformPackageGlobalFromFallbackRegistry(spec)) {
|
|
153
|
-
const binary = resolveInstalledBinary(pkg);
|
|
154
|
-
if (binary) {
|
|
155
|
-
return binary;
|
|
156
|
-
}
|
|
157
|
-
}
|
|
158
|
-
|
|
159
|
-
return null;
|
|
160
|
-
}
|
|
161
|
-
|
|
162
|
-
const pkg = packageByPlatform[platformDir];
|
|
163
|
-
const candidates = [
|
|
164
|
-
process.env.FABR_CLIENT_BIN,
|
|
165
|
-
resolvePlatformPackageBinary(pkg),
|
|
166
|
-
// Local development fallback: package payloads staged next to this repo.
|
|
167
|
-
path.join(__dirname, "..", "..", "npm-platforms", platformDir, "bin", exe),
|
|
168
|
-
path.join(__dirname, platformDir, exe),
|
|
19
|
+
function resolvePlatformPackageBinary(pkg) {
|
|
20
|
+
if (!pkg) {
|
|
21
|
+
return null;
|
|
22
|
+
}
|
|
23
|
+
try {
|
|
24
|
+
return path.join(path.dirname(require.resolve(`${pkg}/package.json`)), "bin", exe);
|
|
25
|
+
} catch {
|
|
26
|
+
return null;
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
function npmCommand() {
|
|
31
|
+
const npmExecPath = process.env.npm_execpath;
|
|
32
|
+
if (npmExecPath) {
|
|
33
|
+
return { command: process.execPath, args: [npmExecPath] };
|
|
34
|
+
}
|
|
35
|
+
return {
|
|
36
|
+
command: platform === "win32" ? "npm.cmd" : "npm",
|
|
37
|
+
args: [],
|
|
38
|
+
};
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
function npmSpawnOptions(cwd) {
|
|
42
|
+
const npm = npmCommand();
|
|
43
|
+
return {
|
|
44
|
+
npm,
|
|
45
|
+
options: {
|
|
46
|
+
cwd,
|
|
47
|
+
env: process.env,
|
|
48
|
+
shell: platform === "win32" && npm.command.endsWith(".cmd"),
|
|
49
|
+
stdio: "inherit",
|
|
50
|
+
windowsHide: true,
|
|
51
|
+
},
|
|
52
|
+
};
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
function packageSpec(pkg) {
|
|
56
|
+
if (process.env.FABR_CLIENT_PLATFORM_PACKAGE_SPEC) {
|
|
57
|
+
return process.env.FABR_CLIENT_PLATFORM_PACKAGE_SPEC;
|
|
58
|
+
}
|
|
59
|
+
if (process.env.FABR_CLIENT_PLATFORM_PACKAGE_TARBALL) {
|
|
60
|
+
return process.env.FABR_CLIENT_PLATFORM_PACKAGE_TARBALL;
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
const ownPackage = require("../package.json");
|
|
64
|
+
const version = ownPackage.optionalDependencies?.[pkg] || ownPackage.version;
|
|
65
|
+
return `${pkg}@${version}`;
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
function runNpmInstall(label, args, cwd) {
|
|
69
|
+
const { npm, options } = npmSpawnOptions(cwd);
|
|
70
|
+
console.error(label);
|
|
71
|
+
const result = spawnSync(npm.command, [...npm.args, ...args], options);
|
|
72
|
+
|
|
73
|
+
if (result.error || result.status !== 0) {
|
|
74
|
+
const message = result.error ? result.error.message : `npm exited with status ${result.status}`;
|
|
75
|
+
console.error(`${label} failed: ${message}`);
|
|
76
|
+
return false;
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
return true;
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
function installPlatformPackageLocal(spec) {
|
|
83
|
+
return runNpmInstall(
|
|
84
|
+
`Installing Fabr Client native payload: ${spec}`,
|
|
85
|
+
[
|
|
86
|
+
"install",
|
|
87
|
+
spec,
|
|
88
|
+
"--no-save",
|
|
89
|
+
"--package-lock=false",
|
|
90
|
+
"--include=optional",
|
|
91
|
+
],
|
|
92
|
+
path.join(__dirname, ".."),
|
|
93
|
+
);
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
function installPlatformPackageGlobal(spec) {
|
|
97
|
+
return runNpmInstall(
|
|
98
|
+
`Installing Fabr Client native payload globally: ${spec}`,
|
|
99
|
+
[
|
|
100
|
+
"install",
|
|
101
|
+
"-g",
|
|
102
|
+
spec,
|
|
103
|
+
"--include=optional",
|
|
104
|
+
],
|
|
105
|
+
path.join(__dirname, ".."),
|
|
106
|
+
);
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
function installPlatformPackageGlobalFromFallbackRegistry(spec) {
|
|
110
|
+
if (process.env.FABR_CLIENT_SKIP_REGISTRY_FALLBACK === "1") {
|
|
111
|
+
return false;
|
|
112
|
+
}
|
|
113
|
+
const registry =
|
|
114
|
+
process.env.FABR_CLIENT_NPM_FALLBACK_REGISTRY || "https://registry.npmjs.org";
|
|
115
|
+
return runNpmInstall(
|
|
116
|
+
`Installing Fabr Client native payload globally from fallback registry: ${spec}`,
|
|
117
|
+
[
|
|
118
|
+
"install",
|
|
119
|
+
"-g",
|
|
120
|
+
spec,
|
|
121
|
+
"--include=optional",
|
|
122
|
+
`--registry=${registry}`,
|
|
123
|
+
],
|
|
124
|
+
path.join(__dirname, ".."),
|
|
125
|
+
);
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
function resolveInstalledBinary(pkg) {
|
|
129
|
+
const binary = resolvePlatformPackageBinary(pkg);
|
|
130
|
+
return binary && fs.existsSync(binary) ? binary : null;
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
function installAndResolvePlatformPackage(pkg) {
|
|
134
|
+
if (!pkg || process.env.FABR_CLIENT_SKIP_PLATFORM_INSTALL === "1") {
|
|
135
|
+
return null;
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
const spec = packageSpec(pkg);
|
|
139
|
+
if (installPlatformPackageLocal(spec)) {
|
|
140
|
+
const binary = resolveInstalledBinary(pkg);
|
|
141
|
+
if (binary) {
|
|
142
|
+
return binary;
|
|
143
|
+
}
|
|
144
|
+
}
|
|
145
|
+
|
|
146
|
+
if (installPlatformPackageGlobal(spec)) {
|
|
147
|
+
const binary = resolveInstalledBinary(pkg);
|
|
148
|
+
if (binary) {
|
|
149
|
+
return binary;
|
|
150
|
+
}
|
|
151
|
+
}
|
|
152
|
+
|
|
153
|
+
if (installPlatformPackageGlobalFromFallbackRegistry(spec)) {
|
|
154
|
+
const binary = resolveInstalledBinary(pkg);
|
|
155
|
+
if (binary) {
|
|
156
|
+
return binary;
|
|
157
|
+
}
|
|
158
|
+
}
|
|
159
|
+
|
|
160
|
+
return null;
|
|
161
|
+
}
|
|
162
|
+
|
|
163
|
+
const pkg = packageByPlatform[platformDir];
|
|
164
|
+
const candidates = [
|
|
165
|
+
process.env.FABR_CLIENT_BIN,
|
|
166
|
+
resolvePlatformPackageBinary(pkg),
|
|
167
|
+
// Local development fallback: package payloads staged next to this repo.
|
|
168
|
+
path.join(__dirname, "..", "..", "npm-platforms", platformDir, "bin", exe),
|
|
169
|
+
path.join(__dirname, platformDir, exe),
|
|
169
170
|
path.join(__dirname, "..", platformDir, exe),
|
|
170
171
|
path.join(__dirname, exe),
|
|
171
172
|
].filter(Boolean);
|
|
172
|
-
|
|
173
|
-
let binary = candidates.find((candidate) => fs.existsSync(candidate));
|
|
174
|
-
|
|
175
|
-
if (!binary) {
|
|
176
|
-
binary = installAndResolvePlatformPackage(pkg);
|
|
177
|
-
}
|
|
178
|
-
|
|
179
|
-
if (!binary) {
|
|
180
|
-
const spec = pkg ? packageSpec(pkg) : null;
|
|
181
|
-
const installHint = pkg
|
|
182
|
-
? `Try: npm install -g ${spec}`
|
|
183
|
-
: "This platform is not currently supported by @fabr-client/core.";
|
|
184
|
-
console.error(
|
|
185
|
-
`Fabr Client does not include a binary for ${platformDir}.\n` +
|
|
186
|
-
"Please reinstall @fabr-client/core with optional dependencies enabled, or install the matching platform package.\n" +
|
|
187
|
-
installHint
|
|
188
|
-
);
|
|
189
|
-
process.exit(1);
|
|
190
|
-
}
|
|
173
|
+
|
|
174
|
+
let binary = candidates.find((candidate) => fs.existsSync(candidate));
|
|
175
|
+
|
|
176
|
+
if (!binary) {
|
|
177
|
+
binary = installAndResolvePlatformPackage(pkg);
|
|
178
|
+
}
|
|
179
|
+
|
|
180
|
+
if (!binary) {
|
|
181
|
+
const spec = pkg ? packageSpec(pkg) : null;
|
|
182
|
+
const installHint = pkg
|
|
183
|
+
? `Try: npm install -g ${spec}`
|
|
184
|
+
: "This platform is not currently supported by @fabr-client/core.";
|
|
185
|
+
console.error(
|
|
186
|
+
`Fabr Client does not include a binary for ${platformDir}.\n` +
|
|
187
|
+
"Please reinstall @fabr-client/core with optional dependencies enabled, or install the matching platform package.\n" +
|
|
188
|
+
installHint
|
|
189
|
+
);
|
|
190
|
+
process.exit(1);
|
|
191
|
+
}
|
|
191
192
|
|
|
192
193
|
const result = spawnSync(binary, process.argv.slice(2), {
|
|
193
194
|
stdio: "inherit",
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@fabr-client/core",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.2",
|
|
4
4
|
"description": "Cross-platform launcher for Fabr Client",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"homepage": "https://pivot.enclaws.com",
|
|
@@ -18,11 +18,12 @@
|
|
|
18
18
|
"postinstall": "node postinstall.js",
|
|
19
19
|
"smoke": "node bin/fabr-client.js --help"
|
|
20
20
|
},
|
|
21
|
-
"optionalDependencies": {
|
|
22
|
-
"@fabr-client/core-win32-x64": "1.0.
|
|
23
|
-
"@fabr-client/core-darwin-x64": "1.0.
|
|
24
|
-
"@fabr-client/core-darwin-arm64": "1.0.
|
|
25
|
-
|
|
21
|
+
"optionalDependencies": {
|
|
22
|
+
"@fabr-client/core-win32-x64": "1.0.2",
|
|
23
|
+
"@fabr-client/core-darwin-x64": "1.0.2",
|
|
24
|
+
"@fabr-client/core-darwin-arm64": "1.0.2",
|
|
25
|
+
"@fabr-client/core-linux-arm64": "1.0.2"
|
|
26
|
+
},
|
|
26
27
|
"files": [
|
|
27
28
|
"bin/",
|
|
28
29
|
"postinstall.js",
|
|
@@ -36,7 +37,8 @@
|
|
|
36
37
|
},
|
|
37
38
|
"os": [
|
|
38
39
|
"darwin",
|
|
39
|
-
"win32"
|
|
40
|
+
"win32",
|
|
41
|
+
"linux"
|
|
40
42
|
],
|
|
41
43
|
"cpu": [
|
|
42
44
|
"arm64",
|
package/postinstall.js
CHANGED
|
@@ -1,94 +1,95 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
const { spawnSync } = require("node:child_process");
|
|
4
|
-
const fs = require("node:fs");
|
|
5
|
-
const path = require("node:path");
|
|
6
|
-
|
|
7
|
-
const platform = process.platform;
|
|
8
|
-
const arch = process.arch;
|
|
9
|
-
const exe = platform === "win32" ? "fabr-client.exe" : "fabr-client";
|
|
10
|
-
const platformDir = `${platform}-${arch}`;
|
|
11
|
-
const packageByPlatform = {
|
|
12
|
-
"win32-x64": "@fabr-client/core-win32-x64",
|
|
13
|
-
"darwin-x64": "@fabr-client/core-darwin-x64",
|
|
14
|
-
"darwin-arm64": "@fabr-client/core-darwin-arm64",
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
const
|
|
46
|
-
|
|
47
|
-
}
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
const
|
|
61
|
-
const
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
"--
|
|
67
|
-
"--
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
const { spawnSync } = require("node:child_process");
|
|
4
|
+
const fs = require("node:fs");
|
|
5
|
+
const path = require("node:path");
|
|
6
|
+
|
|
7
|
+
const platform = process.platform;
|
|
8
|
+
const arch = process.arch;
|
|
9
|
+
const exe = platform === "win32" ? "fabr-client.exe" : "fabr-client";
|
|
10
|
+
const platformDir = `${platform}-${arch}`;
|
|
11
|
+
const packageByPlatform = {
|
|
12
|
+
"win32-x64": "@fabr-client/core-win32-x64",
|
|
13
|
+
"darwin-x64": "@fabr-client/core-darwin-x64",
|
|
14
|
+
"darwin-arm64": "@fabr-client/core-darwin-arm64",
|
|
15
|
+
"linux-arm64": "@fabr-client/core-linux-arm64",
|
|
16
|
+
};
|
|
17
|
+
|
|
18
|
+
function resolvePlatformPackageBinary(pkg) {
|
|
19
|
+
try {
|
|
20
|
+
return path.join(path.dirname(require.resolve(`${pkg}/package.json`)), "bin", exe);
|
|
21
|
+
} catch {
|
|
22
|
+
return null;
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
function npmCommand() {
|
|
27
|
+
const npmExecPath = process.env.npm_execpath;
|
|
28
|
+
if (npmExecPath) {
|
|
29
|
+
return { command: process.execPath, args: [npmExecPath] };
|
|
30
|
+
}
|
|
31
|
+
return {
|
|
32
|
+
command: platform === "win32" ? "npm.cmd" : "npm",
|
|
33
|
+
args: [],
|
|
34
|
+
};
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
function packageSpec(pkg) {
|
|
38
|
+
if (process.env.FABR_CLIENT_PLATFORM_PACKAGE_SPEC) {
|
|
39
|
+
return process.env.FABR_CLIENT_PLATFORM_PACKAGE_SPEC;
|
|
40
|
+
}
|
|
41
|
+
if (process.env.FABR_CLIENT_PLATFORM_PACKAGE_TARBALL) {
|
|
42
|
+
return process.env.FABR_CLIENT_PLATFORM_PACKAGE_TARBALL;
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
const ownPackage = require("./package.json");
|
|
46
|
+
const version = ownPackage.optionalDependencies?.[pkg] || ownPackage.version;
|
|
47
|
+
return `${pkg}@${version}`;
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
const pkg = packageByPlatform[platformDir];
|
|
51
|
+
if (!pkg || process.env.FABR_CLIENT_SKIP_PLATFORM_INSTALL === "1") {
|
|
52
|
+
process.exit(0);
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
const existingBinary = resolvePlatformPackageBinary(pkg);
|
|
56
|
+
if (existingBinary && fs.existsSync(existingBinary)) {
|
|
57
|
+
process.exit(0);
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
const spec = packageSpec(pkg);
|
|
61
|
+
const npm = npmCommand();
|
|
62
|
+
const args = [
|
|
63
|
+
...npm.args,
|
|
64
|
+
"install",
|
|
65
|
+
spec,
|
|
66
|
+
"--no-save",
|
|
67
|
+
"--package-lock=false",
|
|
68
|
+
"--include=optional",
|
|
69
|
+
];
|
|
70
|
+
|
|
71
|
+
console.log(`Installing Fabr Client native payload: ${spec}`);
|
|
72
|
+
const result = spawnSync(npm.command, args, {
|
|
73
|
+
cwd: __dirname,
|
|
74
|
+
env: process.env,
|
|
75
|
+
shell: platform === "win32" && npm.command.endsWith(".cmd"),
|
|
76
|
+
stdio: "inherit",
|
|
77
|
+
windowsHide: true,
|
|
78
|
+
});
|
|
79
|
+
|
|
80
|
+
if (result.error || result.status !== 0) {
|
|
81
|
+
const message = result.error ? result.error.message : `npm exited with status ${result.status}`;
|
|
82
|
+
console.warn(
|
|
83
|
+
`Unable to install ${pkg} automatically: ${message}\n` +
|
|
84
|
+
`Run "npm install -g ${pkg}" if "fabr-client" cannot find its native binary.`
|
|
85
|
+
);
|
|
86
|
+
process.exit(0);
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
const installedBinary = resolvePlatformPackageBinary(pkg);
|
|
90
|
+
if (!installedBinary || !fs.existsSync(installedBinary)) {
|
|
91
|
+
console.warn(
|
|
92
|
+
`Installed ${pkg}, but ${exe} was not found.\n` +
|
|
93
|
+
`Run "npm install -g ${pkg}" if "fabr-client" cannot find its native binary.`
|
|
94
|
+
);
|
|
95
|
+
}
|