@fabr-client/core 0.1.13 → 0.1.14

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.
@@ -15,179 +15,179 @@ const packageByPlatform = {
15
15
  "darwin-arm64": "@fabr-client/core-darwin-arm64",
16
16
  };
17
17
 
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),
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),
169
169
  path.join(__dirname, "..", platformDir, exe),
170
170
  path.join(__dirname, exe),
171
171
  ].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
- }
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
+ }
191
191
 
192
192
  const result = spawnSync(binary, process.argv.slice(2), {
193
193
  stdio: "inherit",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@fabr-client/core",
3
- "version": "0.1.13",
3
+ "version": "0.1.14",
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.13",
23
- "@fabr-client/core-darwin-x64": "0.1.13",
24
- "@fabr-client/core-darwin-arm64": "0.1.13"
22
+ "@fabr-client/core-win32-x64": "0.1.14",
23
+ "@fabr-client/core-darwin-x64": "0.1.14",
24
+ "@fabr-client/core-darwin-arm64": "0.1.14"
25
25
  },
26
26
  "files": [
27
27
  "bin/",
package/postinstall.js CHANGED
@@ -1,94 +1,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
- };
16
-
17
- function resolvePlatformPackageBinary(pkg) {
18
- try {
19
- return path.join(path.dirname(require.resolve(`${pkg}/package.json`)), "bin", exe);
20
- } catch {
21
- return null;
22
- }
23
- }
24
-
25
- function npmCommand() {
26
- const npmExecPath = process.env.npm_execpath;
27
- if (npmExecPath) {
28
- return { command: process.execPath, args: [npmExecPath] };
29
- }
30
- return {
31
- command: platform === "win32" ? "npm.cmd" : "npm",
32
- args: [],
33
- };
34
- }
35
-
36
- function packageSpec(pkg) {
37
- if (process.env.FABR_CLIENT_PLATFORM_PACKAGE_SPEC) {
38
- return process.env.FABR_CLIENT_PLATFORM_PACKAGE_SPEC;
39
- }
40
- if (process.env.FABR_CLIENT_PLATFORM_PACKAGE_TARBALL) {
41
- return process.env.FABR_CLIENT_PLATFORM_PACKAGE_TARBALL;
42
- }
43
-
44
- const ownPackage = require("./package.json");
45
- const version = ownPackage.optionalDependencies?.[pkg] || ownPackage.version;
46
- return `${pkg}@${version}`;
47
- }
48
-
49
- const pkg = packageByPlatform[platformDir];
50
- if (!pkg || process.env.FABR_CLIENT_SKIP_PLATFORM_INSTALL === "1") {
51
- process.exit(0);
52
- }
53
-
54
- const existingBinary = resolvePlatformPackageBinary(pkg);
55
- if (existingBinary && fs.existsSync(existingBinary)) {
56
- process.exit(0);
57
- }
58
-
59
- const spec = packageSpec(pkg);
60
- const npm = npmCommand();
61
- const args = [
62
- ...npm.args,
63
- "install",
64
- spec,
65
- "--no-save",
66
- "--package-lock=false",
67
- "--include=optional",
68
- ];
69
-
70
- console.log(`Installing Fabr Client native payload: ${spec}`);
71
- const result = spawnSync(npm.command, args, {
72
- cwd: __dirname,
73
- env: process.env,
74
- shell: platform === "win32" && npm.command.endsWith(".cmd"),
75
- stdio: "inherit",
76
- windowsHide: true,
77
- });
78
-
79
- if (result.error || result.status !== 0) {
80
- const message = result.error ? result.error.message : `npm exited with status ${result.status}`;
81
- console.warn(
82
- `Unable to install ${pkg} automatically: ${message}\n` +
83
- `Run "npm install -g ${pkg}" if "fabr-client" cannot find its native binary.`
84
- );
85
- process.exit(0);
86
- }
87
-
88
- const installedBinary = resolvePlatformPackageBinary(pkg);
89
- if (!installedBinary || !fs.existsSync(installedBinary)) {
90
- console.warn(
91
- `Installed ${pkg}, but ${exe} was not found.\n` +
92
- `Run "npm install -g ${pkg}" if "fabr-client" cannot find its native binary.`
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
+ };
16
+
17
+ function resolvePlatformPackageBinary(pkg) {
18
+ try {
19
+ return path.join(path.dirname(require.resolve(`${pkg}/package.json`)), "bin", exe);
20
+ } catch {
21
+ return null;
22
+ }
23
+ }
24
+
25
+ function npmCommand() {
26
+ const npmExecPath = process.env.npm_execpath;
27
+ if (npmExecPath) {
28
+ return { command: process.execPath, args: [npmExecPath] };
29
+ }
30
+ return {
31
+ command: platform === "win32" ? "npm.cmd" : "npm",
32
+ args: [],
33
+ };
34
+ }
35
+
36
+ function packageSpec(pkg) {
37
+ if (process.env.FABR_CLIENT_PLATFORM_PACKAGE_SPEC) {
38
+ return process.env.FABR_CLIENT_PLATFORM_PACKAGE_SPEC;
39
+ }
40
+ if (process.env.FABR_CLIENT_PLATFORM_PACKAGE_TARBALL) {
41
+ return process.env.FABR_CLIENT_PLATFORM_PACKAGE_TARBALL;
42
+ }
43
+
44
+ const ownPackage = require("./package.json");
45
+ const version = ownPackage.optionalDependencies?.[pkg] || ownPackage.version;
46
+ return `${pkg}@${version}`;
47
+ }
48
+
49
+ const pkg = packageByPlatform[platformDir];
50
+ if (!pkg || process.env.FABR_CLIENT_SKIP_PLATFORM_INSTALL === "1") {
51
+ process.exit(0);
52
+ }
53
+
54
+ const existingBinary = resolvePlatformPackageBinary(pkg);
55
+ if (existingBinary && fs.existsSync(existingBinary)) {
56
+ process.exit(0);
57
+ }
58
+
59
+ const spec = packageSpec(pkg);
60
+ const npm = npmCommand();
61
+ const args = [
62
+ ...npm.args,
63
+ "install",
64
+ spec,
65
+ "--no-save",
66
+ "--package-lock=false",
67
+ "--include=optional",
68
+ ];
69
+
70
+ console.log(`Installing Fabr Client native payload: ${spec}`);
71
+ const result = spawnSync(npm.command, args, {
72
+ cwd: __dirname,
73
+ env: process.env,
74
+ shell: platform === "win32" && npm.command.endsWith(".cmd"),
75
+ stdio: "inherit",
76
+ windowsHide: true,
77
+ });
78
+
79
+ if (result.error || result.status !== 0) {
80
+ const message = result.error ? result.error.message : `npm exited with status ${result.status}`;
81
+ console.warn(
82
+ `Unable to install ${pkg} automatically: ${message}\n` +
83
+ `Run "npm install -g ${pkg}" if "fabr-client" cannot find its native binary.`
84
+ );
85
+ process.exit(0);
86
+ }
87
+
88
+ const installedBinary = resolvePlatformPackageBinary(pkg);
89
+ if (!installedBinary || !fs.existsSync(installedBinary)) {
90
+ console.warn(
91
+ `Installed ${pkg}, but ${exe} was not found.\n` +
92
+ `Run "npm install -g ${pkg}" if "fabr-client" cannot find its native binary.`
93
+ );
94
+ }