sloppycode 0.1.204 → 0.1.206
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/slopcode +3 -2
- package/package.json +12 -12
- package/postinstall.mjs +72 -2
package/bin/slopcode
CHANGED
|
@@ -149,7 +149,8 @@ function names(prefix) {
|
|
|
149
149
|
return [base]
|
|
150
150
|
}
|
|
151
151
|
|
|
152
|
-
const
|
|
152
|
+
const packageNames = names("slopcode-bin")
|
|
153
|
+
const resolvedNames = Array.from(new Set([...packageNames, ...names("slopcode")]))
|
|
153
154
|
|
|
154
155
|
function resolveBinary() {
|
|
155
156
|
for (const name of resolvedNames) {
|
|
@@ -186,7 +187,7 @@ const resolved = resolveBinary() || findBinary(scriptDir)
|
|
|
186
187
|
if (!resolved) {
|
|
187
188
|
console.error(
|
|
188
189
|
"It seems that your package manager failed to install the right version of the slopcode CLI for your platform. You can try manually installing " +
|
|
189
|
-
|
|
190
|
+
packageNames.map((n) => `\"${n}\"`).join(" or ") +
|
|
190
191
|
" package",
|
|
191
192
|
)
|
|
192
193
|
process.exit(1)
|
package/package.json
CHANGED
|
@@ -34,19 +34,19 @@
|
|
|
34
34
|
"scripts": {
|
|
35
35
|
"postinstall": "bun ./postinstall.mjs || node ./postinstall.mjs"
|
|
36
36
|
},
|
|
37
|
-
"version": "0.1.
|
|
37
|
+
"version": "0.1.206",
|
|
38
38
|
"license": "MIT",
|
|
39
39
|
"optionalDependencies": {
|
|
40
|
-
"slopcode-bin-linux-x64": "0.1.
|
|
41
|
-
"slopcode-bin-linux-x64-baseline-musl": "0.1.
|
|
42
|
-
"slopcode-bin-windows-x64-baseline": "0.1.
|
|
43
|
-
"slopcode-bin-linux-x64-baseline": "0.1.
|
|
44
|
-
"slopcode-bin-windows-x64": "0.1.
|
|
45
|
-
"slopcode-bin-darwin-x64-baseline": "0.1.
|
|
46
|
-
"slopcode-bin-darwin-arm64": "0.1.
|
|
47
|
-
"slopcode-bin-linux-x64-musl": "0.1.
|
|
48
|
-
"slopcode-bin-darwin-x64": "0.1.
|
|
49
|
-
"slopcode-bin-linux-arm64-musl": "0.1.
|
|
50
|
-
"slopcode-bin-linux-arm64": "0.1.
|
|
40
|
+
"slopcode-bin-linux-x64": "0.1.206",
|
|
41
|
+
"slopcode-bin-linux-x64-baseline-musl": "0.1.206",
|
|
42
|
+
"slopcode-bin-windows-x64-baseline": "0.1.206",
|
|
43
|
+
"slopcode-bin-linux-x64-baseline": "0.1.206",
|
|
44
|
+
"slopcode-bin-windows-x64": "0.1.206",
|
|
45
|
+
"slopcode-bin-darwin-x64-baseline": "0.1.206",
|
|
46
|
+
"slopcode-bin-darwin-arm64": "0.1.206",
|
|
47
|
+
"slopcode-bin-linux-x64-musl": "0.1.206",
|
|
48
|
+
"slopcode-bin-darwin-x64": "0.1.206",
|
|
49
|
+
"slopcode-bin-linux-arm64-musl": "0.1.206",
|
|
50
|
+
"slopcode-bin-linux-arm64": "0.1.206"
|
|
51
51
|
}
|
|
52
52
|
}
|
package/postinstall.mjs
CHANGED
|
@@ -47,12 +47,82 @@ function detectPlatformAndArch() {
|
|
|
47
47
|
return { platform, arch }
|
|
48
48
|
}
|
|
49
49
|
|
|
50
|
+
function supportsAvx2(platform, arch) {
|
|
51
|
+
if (arch !== "x64") return false
|
|
52
|
+
|
|
53
|
+
if (platform === "linux") {
|
|
54
|
+
try {
|
|
55
|
+
return /(^|\s)avx2(\s|$)/i.test(fs.readFileSync("/proc/cpuinfo", "utf8"))
|
|
56
|
+
} catch {
|
|
57
|
+
return false
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
if (platform === "darwin") {
|
|
62
|
+
try {
|
|
63
|
+
const result = require("child_process").spawnSync("sysctl", ["-n", "hw.optional.avx2_0"], {
|
|
64
|
+
encoding: "utf8",
|
|
65
|
+
timeout: 1500,
|
|
66
|
+
})
|
|
67
|
+
if (result.status !== 0) return false
|
|
68
|
+
return (result.stdout || "").trim() === "1"
|
|
69
|
+
} catch {
|
|
70
|
+
return false
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
return false
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
function names(platform, arch) {
|
|
78
|
+
const base = `slopcode-bin-${platform}-${arch}`
|
|
79
|
+
const avx2 = supportsAvx2(platform, arch)
|
|
80
|
+
const baseline = arch === "x64" && !avx2
|
|
81
|
+
|
|
82
|
+
if (platform === "linux") {
|
|
83
|
+
const musl = (() => {
|
|
84
|
+
try {
|
|
85
|
+
if (fs.existsSync("/etc/alpine-release")) return true
|
|
86
|
+
} catch {}
|
|
87
|
+
|
|
88
|
+
try {
|
|
89
|
+
const result = require("child_process").spawnSync("ldd", ["--version"], { encoding: "utf8" })
|
|
90
|
+
const text = ((result.stdout || "") + (result.stderr || "")).toLowerCase()
|
|
91
|
+
if (text.includes("musl")) return true
|
|
92
|
+
} catch {}
|
|
93
|
+
|
|
94
|
+
return false
|
|
95
|
+
})()
|
|
96
|
+
|
|
97
|
+
if (musl) {
|
|
98
|
+
if (arch === "x64") {
|
|
99
|
+
if (baseline) return [`${base}-baseline-musl`, `${base}-musl`, `${base}-baseline`, base]
|
|
100
|
+
return [`${base}-musl`, `${base}-baseline-musl`, base, `${base}-baseline`]
|
|
101
|
+
}
|
|
102
|
+
return [`${base}-musl`, base]
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
if (arch === "x64") {
|
|
106
|
+
if (baseline) return [`${base}-baseline`, base, `${base}-baseline-musl`, `${base}-musl`]
|
|
107
|
+
return [base, `${base}-baseline`, `${base}-musl`, `${base}-baseline-musl`]
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
return [base, `${base}-musl`]
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
if (arch === "x64") {
|
|
114
|
+
if (baseline) return [`${base}-baseline`, base]
|
|
115
|
+
return [base, `${base}-baseline`]
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
return [base]
|
|
119
|
+
}
|
|
120
|
+
|
|
50
121
|
function findBinary() {
|
|
51
122
|
const { platform, arch } = detectPlatformAndArch()
|
|
52
123
|
const binaryName = platform === "windows" ? "slopcode.exe" : "slopcode"
|
|
53
|
-
const names = [`slopcode-bin-${platform}-${arch}`, `slopcode-${platform}-${arch}`]
|
|
54
124
|
|
|
55
|
-
for (const name of names) {
|
|
125
|
+
for (const name of names(platform, arch)) {
|
|
56
126
|
try {
|
|
57
127
|
const packageJsonPath = require.resolve(`${name}/package.json`)
|
|
58
128
|
const packageDir = path.dirname(packageJsonPath)
|