@fabr-client/core 0.1.5 → 0.1.6
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/bin/fabr-client.js +76 -29
- package/package.json +4 -4
- package/postinstall.js +1 -0
package/bin/fabr-client.js
CHANGED
|
@@ -37,6 +37,20 @@ function npmCommand() {
|
|
|
37
37
|
};
|
|
38
38
|
}
|
|
39
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
|
+
|
|
40
54
|
function packageSpec(pkg) {
|
|
41
55
|
if (process.env.FABR_CLIENT_PLATFORM_PACKAGE_SPEC) {
|
|
42
56
|
return process.env.FABR_CLIENT_PLATFORM_PACKAGE_SPEC;
|
|
@@ -50,39 +64,75 @@ function packageSpec(pkg) {
|
|
|
50
64
|
return `${pkg}@${version}`;
|
|
51
65
|
}
|
|
52
66
|
|
|
53
|
-
function
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
const spec = packageSpec(pkg);
|
|
59
|
-
const npm = npmCommand();
|
|
60
|
-
const args = [
|
|
61
|
-
...npm.args,
|
|
62
|
-
"install",
|
|
63
|
-
spec,
|
|
64
|
-
"--no-save",
|
|
65
|
-
"--package-lock=false",
|
|
66
|
-
"--include=optional",
|
|
67
|
-
];
|
|
68
|
-
|
|
69
|
-
console.error(`Installing Fabr Client native payload: ${spec}`);
|
|
70
|
-
const result = spawnSync(npm.command, args, {
|
|
71
|
-
cwd: path.join(__dirname, ".."),
|
|
72
|
-
env: process.env,
|
|
73
|
-
stdio: "inherit",
|
|
74
|
-
windowsHide: true,
|
|
75
|
-
});
|
|
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);
|
|
76
71
|
|
|
77
72
|
if (result.error || result.status !== 0) {
|
|
78
73
|
const message = result.error ? result.error.message : `npm exited with status ${result.status}`;
|
|
79
|
-
console.error(
|
|
74
|
+
console.error(`${label} failed: ${message}`);
|
|
80
75
|
return false;
|
|
81
76
|
}
|
|
82
77
|
|
|
83
78
|
return true;
|
|
84
79
|
}
|
|
85
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 resolveInstalledBinary(pkg) {
|
|
109
|
+
const binary = resolvePlatformPackageBinary(pkg);
|
|
110
|
+
return binary && fs.existsSync(binary) ? binary : null;
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
function installAndResolvePlatformPackage(pkg) {
|
|
114
|
+
if (!pkg || process.env.FABR_CLIENT_SKIP_PLATFORM_INSTALL === "1") {
|
|
115
|
+
return null;
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
const spec = packageSpec(pkg);
|
|
119
|
+
if (installPlatformPackageLocal(spec)) {
|
|
120
|
+
const binary = resolveInstalledBinary(pkg);
|
|
121
|
+
if (binary) {
|
|
122
|
+
return binary;
|
|
123
|
+
}
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
if (installPlatformPackageGlobal(spec)) {
|
|
127
|
+
const binary = resolveInstalledBinary(pkg);
|
|
128
|
+
if (binary) {
|
|
129
|
+
return binary;
|
|
130
|
+
}
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
return null;
|
|
134
|
+
}
|
|
135
|
+
|
|
86
136
|
const pkg = packageByPlatform[platformDir];
|
|
87
137
|
const candidates = [
|
|
88
138
|
process.env.FABR_CLIENT_BIN,
|
|
@@ -96,11 +146,8 @@ const candidates = [
|
|
|
96
146
|
|
|
97
147
|
let binary = candidates.find((candidate) => fs.existsSync(candidate));
|
|
98
148
|
|
|
99
|
-
if (!binary
|
|
100
|
-
binary =
|
|
101
|
-
if (binary && !fs.existsSync(binary)) {
|
|
102
|
-
binary = null;
|
|
103
|
-
}
|
|
149
|
+
if (!binary) {
|
|
150
|
+
binary = installAndResolvePlatformPackage(pkg);
|
|
104
151
|
}
|
|
105
152
|
|
|
106
153
|
if (!binary) {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@fabr-client/core",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.6",
|
|
4
4
|
"description": "Cross-platform launcher for Fabr Client",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"homepage": "https://pivot.enclaws.com",
|
|
@@ -19,9 +19,9 @@
|
|
|
19
19
|
"smoke": "node bin/fabr-client.js --help"
|
|
20
20
|
},
|
|
21
21
|
"optionalDependencies": {
|
|
22
|
-
"@fabr-client/core-win32-x64": "0.1.
|
|
23
|
-
"@fabr-client/core-darwin-x64": "0.1.
|
|
24
|
-
"@fabr-client/core-darwin-arm64": "0.1.
|
|
22
|
+
"@fabr-client/core-win32-x64": "0.1.6",
|
|
23
|
+
"@fabr-client/core-darwin-x64": "0.1.6",
|
|
24
|
+
"@fabr-client/core-darwin-arm64": "0.1.6"
|
|
25
25
|
},
|
|
26
26
|
"files": [
|
|
27
27
|
"bin/",
|
package/postinstall.js
CHANGED
|
@@ -71,6 +71,7 @@ console.log(`Installing Fabr Client native payload: ${spec}`);
|
|
|
71
71
|
const result = spawnSync(npm.command, args, {
|
|
72
72
|
cwd: __dirname,
|
|
73
73
|
env: process.env,
|
|
74
|
+
shell: platform === "win32" && npm.command.endsWith(".cmd"),
|
|
74
75
|
stdio: "inherit",
|
|
75
76
|
windowsHide: true,
|
|
76
77
|
});
|