@synsci/openscience 1.2.4 → 1.2.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/openscience CHANGED
@@ -10,12 +10,18 @@ function run(target) {
10
10
  // Install dir stays as ~/.openscience/ until the path-migration follow-up PR.
11
11
  const openscienceDir = path.join(os.homedir(), ".openscience")
12
12
  for (const poison of ["package.json", ".gitignore", "bun.lockb", "bunfig.toml"]) {
13
- try { fs.unlinkSync(path.join(openscienceDir, poison)) } catch {}
13
+ try {
14
+ fs.unlinkSync(path.join(openscienceDir, poison))
15
+ } catch {}
14
16
  }
15
- try { fs.rmSync(path.join(openscienceDir, "node_modules"), { recursive: true }) } catch {}
17
+ try {
18
+ fs.rmSync(path.join(openscienceDir, "node_modules"), { recursive: true })
19
+ } catch {}
16
20
  // Clear macOS extended attributes that cause Bun binaries to hang
17
21
  if (os.platform() === "darwin") {
18
- try { childProcess.spawnSync("xattr", ["-rc", openscienceDir], { stdio: "ignore" }) } catch {}
22
+ try {
23
+ childProcess.spawnSync("xattr", ["-rc", openscienceDir], { stdio: "ignore" })
24
+ } catch {}
19
25
  }
20
26
 
21
27
  const result = childProcess.spawnSync(target, process.argv.slice(2), {
@@ -61,6 +67,26 @@ const arch = archMap[os.arch()] || os.arch()
61
67
  const base = "openscience-" + platform + "-" + arch
62
68
  const scopedBase = "openscience-" + platform + "-" + arch
63
69
 
70
+ // Rank matching platform packages instead of trusting readdir order (which
71
+ // is filesystem-dependent): right libc first, exact name before suffixed
72
+ // variants like -baseline, wrong libc only as a last resort.
73
+ const musl = (() => {
74
+ if (platform !== "linux") return false
75
+ try {
76
+ return fs.readdirSync("/lib").some((f) => f.startsWith("ld-musl-"))
77
+ } catch {
78
+ return false
79
+ }
80
+ })()
81
+ function variantRank(prefix, entry) {
82
+ const entryMusl = entry.includes("-musl")
83
+ if (entryMusl !== musl) return 0
84
+ return entry === prefix || entry === prefix + "-musl" ? 2 : 1
85
+ }
86
+ function matchingVariants(prefix, entries) {
87
+ return entries.filter((e) => e.startsWith(prefix)).sort((a, b) => variantRank(prefix, b) - variantRank(prefix, a))
88
+ }
89
+
64
90
  // 2. Search this install's node_modules for the matching platform package.
65
91
  // This must come before ~/.openscience or Homebrew fallbacks; otherwise an npm
66
92
  // install can accidentally launch an older globally-installed binary.
@@ -70,21 +96,17 @@ while (true) {
70
96
  if (fs.existsSync(modules)) {
71
97
  try {
72
98
  const entries = fs.readdirSync(modules)
73
- for (const entry of entries) {
74
- if (entry.startsWith(base)) {
75
- const candidate = path.join(modules, entry, "bin", binary)
76
- if (isBinary(candidate)) run(candidate)
77
- }
99
+ for (const entry of matchingVariants(base, entries)) {
100
+ const candidate = path.join(modules, entry, "bin", binary)
101
+ if (isBinary(candidate)) run(candidate)
78
102
  }
79
103
  // Check scoped packages (@synsci/openscience-darwin-arm64)
80
104
  const scoped = path.join(modules, "@synsci")
81
105
  if (fs.existsSync(scoped)) {
82
106
  const scopedEntries = fs.readdirSync(scoped)
83
- for (const entry of scopedEntries) {
84
- if (entry.startsWith(scopedBase)) {
85
- const candidate = path.join(scoped, entry, "bin", binary)
86
- if (isBinary(candidate)) run(candidate)
87
- }
107
+ for (const entry of matchingVariants(scopedBase, scopedEntries)) {
108
+ const candidate = path.join(scoped, entry, "bin", binary)
109
+ if (isBinary(candidate)) run(candidate)
88
110
  }
89
111
  }
90
112
  } catch {}
@@ -111,6 +133,6 @@ if (isBinary("/usr/local/bin/openscience")) {
111
133
  }
112
134
 
113
135
  console.error("openscience binary not found.")
114
- console.error("Install with: curl -fsSL https://syntheticsciences.ai/install | bash")
136
+ console.error("Install with: curl -fsSL https://openscience.sh/install | bash")
115
137
  console.error("Or set OPENSCIENCE_BIN_PATH environment variable.")
116
138
  process.exit(1)
package/package.json CHANGED
@@ -7,22 +7,22 @@
7
7
  "preinstall": "node ./preinstall.mjs || exit 0",
8
8
  "postinstall": "bun ./postinstall.mjs || node ./postinstall.mjs"
9
9
  },
10
- "version": "1.2.4",
10
+ "version": "1.2.6",
11
11
  "repository": {
12
12
  "type": "git",
13
13
  "url": "git+https://github.com/synthetic-sciences/openscience.git"
14
14
  },
15
15
  "optionalDependencies": {
16
- "@synsci/openscience-linux-x64-baseline": "1.2.4",
17
- "@synsci/openscience-linux-arm64": "1.2.4",
18
- "@synsci/openscience-linux-x64": "1.2.4",
19
- "@synsci/openscience-windows-x64": "1.2.4",
20
- "@synsci/openscience-darwin-arm64": "1.2.4",
21
- "@synsci/openscience-darwin-x64": "1.2.4",
22
- "@synsci/openscience-linux-x64-baseline-musl": "1.2.4",
23
- "@synsci/openscience-linux-x64-musl": "1.2.4",
24
- "@synsci/openscience-linux-arm64-musl": "1.2.4",
25
- "@synsci/openscience-windows-x64-baseline": "1.2.4",
26
- "@synsci/openscience-darwin-x64-baseline": "1.2.4"
16
+ "@synsci/openscience-linux-x64-baseline": "1.2.6",
17
+ "@synsci/openscience-linux-arm64": "1.2.6",
18
+ "@synsci/openscience-linux-x64": "1.2.6",
19
+ "@synsci/openscience-windows-x64": "1.2.6",
20
+ "@synsci/openscience-darwin-arm64": "1.2.6",
21
+ "@synsci/openscience-darwin-x64": "1.2.6",
22
+ "@synsci/openscience-linux-x64-baseline-musl": "1.2.6",
23
+ "@synsci/openscience-linux-x64-musl": "1.2.6",
24
+ "@synsci/openscience-linux-arm64-musl": "1.2.6",
25
+ "@synsci/openscience-windows-x64-baseline": "1.2.6",
26
+ "@synsci/openscience-darwin-x64-baseline": "1.2.6"
27
27
  }
28
28
  }
package/postinstall.mjs CHANGED
@@ -52,10 +52,7 @@ function findBinary() {
52
52
  const binaryName = platform === "windows" ? "openscience.exe" : "openscience"
53
53
 
54
54
  // Try scoped package first (@synsci/openscience-darwin-arm64), then unscoped (openscience-darwin-arm64)
55
- const packageNames = [
56
- `@synsci/openscience-${platform}-${arch}`,
57
- `openscience-${platform}-${arch}`,
58
- ]
55
+ const packageNames = [`@synsci/openscience-${platform}-${arch}`, `openscience-${platform}-${arch}`]
59
56
 
60
57
  for (const packageName of packageNames) {
61
58
  try {