shuvcode 2.3.1-shuv.1 → 2.3.1-shuv.3
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/launcher.mjs +51 -43
- package/package.json +13 -13
package/bin/launcher.mjs
CHANGED
|
@@ -56,36 +56,35 @@ function supportsAvx2() {
|
|
|
56
56
|
|
|
57
57
|
function isMusl() {
|
|
58
58
|
if (platform !== "linux") return false
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
}
|
|
59
|
+
if (fs.existsSync("/etc/alpine-release")) return true
|
|
60
|
+
const result = childProcess.spawnSync("ldd", ["--version"], { encoding: "utf8", timeout: 1500 })
|
|
61
|
+
const output = `${result.stdout || ""}${result.stderr || ""}`.toLowerCase()
|
|
62
|
+
if (output.includes("musl")) return true
|
|
63
|
+
if (output.includes("glibc") || output.includes("gnu libc")) return false
|
|
64
|
+
return !process.report?.getReport?.()?.header?.glibcVersionRuntime
|
|
66
65
|
}
|
|
67
66
|
|
|
68
67
|
function packageNames() {
|
|
69
68
|
const baseline = arch === "x64" && !supportsAvx2()
|
|
70
|
-
const
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
return
|
|
69
|
+
const musl = platform === "linux" && isMusl()
|
|
70
|
+
// A binary built for the other libc fails at exec time with a loader error, so never fall back across libc.
|
|
71
|
+
const names = musl
|
|
72
|
+
? arch === "x64"
|
|
73
|
+
? baseline
|
|
74
|
+
? [`${base}-baseline-musl`, `${base}-musl`]
|
|
75
|
+
: [`${base}-musl`, `${base}-baseline-musl`]
|
|
76
|
+
: [`${base}-musl`]
|
|
77
|
+
: arch === "x64"
|
|
78
|
+
? baseline
|
|
79
|
+
? [`${base}-baseline`, base]
|
|
80
|
+
: [base, `${base}-baseline`]
|
|
81
|
+
: [base]
|
|
82
|
+
const candidates = names.filter((name) => dependencies[name])
|
|
83
|
+
if (candidates.length === 0)
|
|
84
|
+
fail(
|
|
85
|
+
`${packageJson.name}@${packageJson.version} does not provide a ${platform === "linux" ? `Linux ${musl ? "musl" : "glibc"}` : platform} binary for ${arch}.`,
|
|
86
|
+
)
|
|
87
|
+
return candidates
|
|
89
88
|
}
|
|
90
89
|
|
|
91
90
|
function resolveBinary(name) {
|
|
@@ -94,7 +93,9 @@ function resolveBinary(name) {
|
|
|
94
93
|
// which would silently run the previous release under the new launcher.
|
|
95
94
|
const version = JSON.parse(fs.readFileSync(packagePath, "utf8")).version
|
|
96
95
|
if (version !== dependencies[name]) {
|
|
97
|
-
const error = new Error(
|
|
96
|
+
const error = new Error(
|
|
97
|
+
`${name} is ${version}, expected ${dependencies[name]}. Reinstall ${packageJson.name}@${packageJson.version}.`,
|
|
98
|
+
)
|
|
98
99
|
error.code = "STALE_PLATFORM_BINARY"
|
|
99
100
|
throw error
|
|
100
101
|
}
|
|
@@ -109,23 +110,30 @@ function fail(message) {
|
|
|
109
110
|
}
|
|
110
111
|
|
|
111
112
|
const names = packageNames()
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
}
|
|
126
|
-
|
|
113
|
+
// A stale candidate (for example one hoisted into a parent node_modules) only fails the launch
|
|
114
|
+
// when no other compatible candidate resolves at the expected version.
|
|
115
|
+
const resolved = names.reduce(
|
|
116
|
+
(result, name) => {
|
|
117
|
+
if (result.binary) return result
|
|
118
|
+
try {
|
|
119
|
+
return { ...result, binary: resolveBinary(name) }
|
|
120
|
+
} catch (error) {
|
|
121
|
+
if (error && error.code === "STALE_PLATFORM_BINARY") return { ...result, stale: result.stale ?? error }
|
|
122
|
+
if (error && error.code === "MODULE_NOT_FOUND") return result
|
|
123
|
+
return { ...result, broken: result.broken ?? error }
|
|
124
|
+
}
|
|
125
|
+
},
|
|
126
|
+
{ binary: undefined, stale: undefined, broken: undefined },
|
|
127
|
+
)
|
|
127
128
|
|
|
128
|
-
if (!binary) fail(
|
|
129
|
+
if (!resolved.binary && resolved.stale) fail(resolved.stale.message)
|
|
130
|
+
if (!resolved.binary && resolved.broken)
|
|
131
|
+
fail(`${resolved.broken.message}. Reinstall ${packageJson.name}@${packageJson.version}.`)
|
|
132
|
+
if (!resolved.binary)
|
|
133
|
+
fail(
|
|
134
|
+
`Missing platform binary package ${names[0]}@${dependencies[names[0]]}. Reinstall ${packageJson.name}@${packageJson.version}.`,
|
|
135
|
+
)
|
|
136
|
+
const binary = resolved.binary
|
|
129
137
|
|
|
130
138
|
const result = childProcess.spawnSync(binary, process.argv.slice(2), {
|
|
131
139
|
stdio: "inherit",
|
package/package.json
CHANGED
|
@@ -14,7 +14,7 @@
|
|
|
14
14
|
"import": "./client/index.js"
|
|
15
15
|
}
|
|
16
16
|
},
|
|
17
|
-
"version": "2.3.1-shuv.
|
|
17
|
+
"version": "2.3.1-shuv.3",
|
|
18
18
|
"license": "MIT",
|
|
19
19
|
"repository": {
|
|
20
20
|
"type": "git",
|
|
@@ -30,17 +30,17 @@
|
|
|
30
30
|
"x64"
|
|
31
31
|
],
|
|
32
32
|
"optionalDependencies": {
|
|
33
|
-
"shuvcode-windows-x64-baseline": "2.3.1-shuv.
|
|
34
|
-
"shuvcode-windows-
|
|
35
|
-
"shuvcode-linux-
|
|
36
|
-
"shuvcode-darwin-
|
|
37
|
-
"shuvcode-
|
|
38
|
-
"shuvcode-linux-arm64": "2.3.1-shuv.
|
|
39
|
-
"shuvcode-
|
|
40
|
-
"shuvcode-
|
|
41
|
-
"shuvcode-
|
|
42
|
-
"shuvcode-
|
|
43
|
-
"shuvcode-linux-x64": "2.3.1-shuv.
|
|
44
|
-
"shuvcode-
|
|
33
|
+
"shuvcode-windows-x64-baseline": "2.3.1-shuv.3",
|
|
34
|
+
"shuvcode-windows-x64": "2.3.1-shuv.3",
|
|
35
|
+
"shuvcode-linux-arm64": "2.3.1-shuv.3",
|
|
36
|
+
"shuvcode-darwin-x64-baseline": "2.3.1-shuv.3",
|
|
37
|
+
"shuvcode-linux-x64-baseline-musl": "2.3.1-shuv.3",
|
|
38
|
+
"shuvcode-linux-arm64-musl": "2.3.1-shuv.3",
|
|
39
|
+
"shuvcode-windows-arm64": "2.3.1-shuv.3",
|
|
40
|
+
"shuvcode-darwin-x64": "2.3.1-shuv.3",
|
|
41
|
+
"shuvcode-linux-x64-baseline": "2.3.1-shuv.3",
|
|
42
|
+
"shuvcode-darwin-arm64": "2.3.1-shuv.3",
|
|
43
|
+
"shuvcode-linux-x64": "2.3.1-shuv.3",
|
|
44
|
+
"shuvcode-linux-x64-musl": "2.3.1-shuv.3"
|
|
45
45
|
}
|
|
46
46
|
}
|