@pylonsync/cli 0.4.16 → 0.4.19

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.
Files changed (2) hide show
  1. package/bin/pylon.js +43 -4
  2. package/package.json +3 -3
package/bin/pylon.js CHANGED
@@ -46,6 +46,28 @@ const UNSUPPORTED_HINTS = {
46
46
  "(libxmlsec1 cross-compile from ubuntu-latest is unsolved).",
47
47
  };
48
48
 
49
+ // `process.arch` is the architecture node was BUILT for, not the machine's.
50
+ // An x64 node on an Apple Silicon Mac runs under Rosetta and reports "x64",
51
+ // which would send an M-series user to the "Intel Macs aren't supported"
52
+ // message above — a wrong answer with no way out of it. That setup is common
53
+ // rather than exotic: Migration Assistant carries the Intel node and the
54
+ // /usr/local Homebrew over to the new Mac, and both keep working, so nothing
55
+ // signals that the toolchain is now the odd one out.
56
+ //
57
+ // Ask the kernel about the hardware instead. `hw.optional.arm64` is 1 on
58
+ // every Apple Silicon Mac and readable from inside a translated process.
59
+ // Only darwin-x64 pays for the probe; a native arm64 or Linux node returns
60
+ // immediately without spawning anything.
61
+ function hardwareArch() {
62
+ if (process.platform !== "darwin" || process.arch !== "x64") {
63
+ return process.arch;
64
+ }
65
+ const probe = spawnSync("sysctl", ["-n", "hw.optional.arm64"], {
66
+ encoding: "utf8",
67
+ });
68
+ return probe.status === 0 && probe.stdout.trim() === "1" ? "arm64" : "x64";
69
+ }
70
+
49
71
  function resolveBinary() {
50
72
  // Escape hatch for a locally-built binary (esbuild's ESBUILD_BINARY_PATH
51
73
  // pattern). Without this, a `cargo install`ed or hand-built `pylon` is
@@ -64,7 +86,9 @@ function resolveBinary() {
64
86
  return override;
65
87
  }
66
88
 
67
- const key = `${process.platform}-${process.arch}`;
89
+ const arch = hardwareArch();
90
+ const translated = arch !== process.arch;
91
+ const key = `${process.platform}-${arch}`;
68
92
  const pkg = PLATFORM_PACKAGES[key];
69
93
  if (!pkg) {
70
94
  const hint = UNSUPPORTED_HINTS[key]
@@ -83,10 +107,25 @@ function resolveBinary() {
83
107
  try {
84
108
  entry = require.resolve(`${pkg}/package.json`);
85
109
  } catch (e) {
110
+ // Package managers match optionalDependencies against the `cpu` field
111
+ // using the architecture of the running node, so a Rosetta node skips
112
+ // the arm64 binary at install time. The package is genuinely absent
113
+ // here and reinstalling the same way will skip it again — say so, and
114
+ // give the flags that override the match.
115
+ const cause = translated
116
+ ? `node is an x64 build running under Rosetta, so the install ` +
117
+ `matched optional dependencies against x64 and skipped the ` +
118
+ `arm64 binary. The machine itself is Apple Silicon.\n\n` +
119
+ `Fix it for good by installing an arm64 node (the x64 one came ` +
120
+ `over from an Intel Mac):\n` +
121
+ ` arch -arm64 brew install node\n\n` +
122
+ `Or install the binary for this machine directly:\n` +
123
+ ` npm install --os=darwin --cpu=arm64 ${pkg}\n`
124
+ : `This usually means npm/bun install skipped the optional ` +
125
+ `dependency.\n` +
126
+ `Try: npm install --no-optional=false @pylonsync/cli\n`;
86
127
  throw new Error(
87
- `@pylonsync/cli: ${pkg} is not installed.\n` +
88
- `This usually means npm/bun install skipped the optional dependency.\n` +
89
- `Try: npm install --no-optional=false @pylonsync/cli\n\n` +
128
+ `@pylonsync/cli: ${pkg} is not installed.\n${cause}\n` +
90
129
  `Underlying error: ${e.message}`,
91
130
  );
92
131
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pylonsync/cli",
3
- "version": "0.4.16",
3
+ "version": "0.4.19",
4
4
  "description": "Pylon CLI — `pylon dev`, `pylon start`, `pylon migrate`, etc. Bundles the native binary for your platform via optionalDependencies, no postinstall script required.",
5
5
  "license": "MIT",
6
6
  "homepage": "https://pylonsync.com",
@@ -25,7 +25,7 @@
25
25
  "node": ">=18"
26
26
  },
27
27
  "optionalDependencies": {
28
- "@pylonsync/cli-darwin-arm64": "0.4.16",
29
- "@pylonsync/cli-linux-x64": "0.4.16"
28
+ "@pylonsync/cli-darwin-arm64": "0.4.19",
29
+ "@pylonsync/cli-linux-x64": "0.4.19"
30
30
  }
31
31
  }