shuvcode 1.0.223-2 → 1.0.223-4
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/package.json +15 -12
- package/postinstall.mjs +140 -0
- package/bin/shuvcode +0 -84
package/package.json
CHANGED
|
@@ -3,19 +3,22 @@
|
|
|
3
3
|
"bin": {
|
|
4
4
|
"shuvcode": "./bin/shuvcode"
|
|
5
5
|
},
|
|
6
|
-
"
|
|
6
|
+
"scripts": {
|
|
7
|
+
"postinstall": "node ./postinstall.mjs"
|
|
8
|
+
},
|
|
9
|
+
"version": "1.0.223-4",
|
|
7
10
|
"optionalDependencies": {
|
|
8
|
-
"shuvcode-linux-arm64": "1.0.223-
|
|
9
|
-
"shuvcode-linux-x64": "1.0.223-
|
|
10
|
-
"shuvcode-linux-x64-baseline": "1.0.223-
|
|
11
|
-
"shuvcode-linux-arm64-musl": "1.0.223-
|
|
12
|
-
"shuvcode-linux-x64-musl": "1.0.223-
|
|
13
|
-
"shuvcode-linux-x64-baseline-musl": "1.0.223-
|
|
14
|
-
"shuvcode-darwin-arm64": "1.0.223-
|
|
15
|
-
"shuvcode-darwin-x64": "1.0.223-
|
|
16
|
-
"shuvcode-darwin-x64-baseline": "1.0.223-
|
|
17
|
-
"shuvcode-windows-x64": "1.0.223-
|
|
18
|
-
"shuvcode-windows-x64-baseline": "1.0.223-
|
|
11
|
+
"shuvcode-linux-arm64": "1.0.223-4",
|
|
12
|
+
"shuvcode-linux-x64": "1.0.223-4",
|
|
13
|
+
"shuvcode-linux-x64-baseline": "1.0.223-4",
|
|
14
|
+
"shuvcode-linux-arm64-musl": "1.0.223-4",
|
|
15
|
+
"shuvcode-linux-x64-musl": "1.0.223-4",
|
|
16
|
+
"shuvcode-linux-x64-baseline-musl": "1.0.223-4",
|
|
17
|
+
"shuvcode-darwin-arm64": "1.0.223-4",
|
|
18
|
+
"shuvcode-darwin-x64": "1.0.223-4",
|
|
19
|
+
"shuvcode-darwin-x64-baseline": "1.0.223-4",
|
|
20
|
+
"shuvcode-windows-x64": "1.0.223-4",
|
|
21
|
+
"shuvcode-windows-x64-baseline": "1.0.223-4"
|
|
19
22
|
},
|
|
20
23
|
"repository": {
|
|
21
24
|
"type": "git",
|
package/postinstall.mjs
ADDED
|
@@ -0,0 +1,140 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
|
|
3
|
+
import fs from "fs"
|
|
4
|
+
import path from "path"
|
|
5
|
+
import os from "os"
|
|
6
|
+
import { fileURLToPath } from "url"
|
|
7
|
+
import { createRequire } from "module"
|
|
8
|
+
|
|
9
|
+
const __dirname = path.dirname(fileURLToPath(import.meta.url))
|
|
10
|
+
const require = createRequire(import.meta.url)
|
|
11
|
+
|
|
12
|
+
function detectPlatformAndArch() {
|
|
13
|
+
// Map platform names
|
|
14
|
+
let platform
|
|
15
|
+
switch (os.platform()) {
|
|
16
|
+
case "darwin":
|
|
17
|
+
platform = "darwin"
|
|
18
|
+
break
|
|
19
|
+
case "linux":
|
|
20
|
+
platform = "linux"
|
|
21
|
+
break
|
|
22
|
+
case "win32":
|
|
23
|
+
platform = "windows"
|
|
24
|
+
break
|
|
25
|
+
default:
|
|
26
|
+
platform = os.platform()
|
|
27
|
+
break
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
// Map architecture names
|
|
31
|
+
let arch
|
|
32
|
+
switch (os.arch()) {
|
|
33
|
+
case "x64":
|
|
34
|
+
arch = "x64"
|
|
35
|
+
break
|
|
36
|
+
case "arm64":
|
|
37
|
+
arch = "arm64"
|
|
38
|
+
break
|
|
39
|
+
case "arm":
|
|
40
|
+
arch = "arm"
|
|
41
|
+
break
|
|
42
|
+
default:
|
|
43
|
+
arch = os.arch()
|
|
44
|
+
break
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
return { platform, arch }
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
function findBinary() {
|
|
51
|
+
const { platform, arch } = detectPlatformAndArch()
|
|
52
|
+
const basePackageName = `shuvcode-${platform}-${arch}`
|
|
53
|
+
const binaryName = platform === "windows" ? "shuvcode.exe" : "shuvcode"
|
|
54
|
+
|
|
55
|
+
try {
|
|
56
|
+
// Try exact package name first
|
|
57
|
+
try {
|
|
58
|
+
const packageJsonPath = require.resolve(`${basePackageName}/package.json`)
|
|
59
|
+
const packageDir = path.dirname(packageJsonPath)
|
|
60
|
+
const binaryPath = path.join(packageDir, "bin", binaryName)
|
|
61
|
+
|
|
62
|
+
if (fs.existsSync(binaryPath)) {
|
|
63
|
+
return { binaryPath, binaryName }
|
|
64
|
+
}
|
|
65
|
+
} catch (error) {
|
|
66
|
+
// Exact match failed, try baseline variant
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
// Fallback: search for baseline variants (e.g., shuvcode-linux-x64-baseline)
|
|
70
|
+
const nodeModulesPath = path.join(__dirname, "..")
|
|
71
|
+
if (fs.existsSync(nodeModulesPath)) {
|
|
72
|
+
const entries = fs.readdirSync(nodeModulesPath)
|
|
73
|
+
for (const entry of entries) {
|
|
74
|
+
if (entry.startsWith(basePackageName)) {
|
|
75
|
+
const binaryPath = path.join(nodeModulesPath, entry, "bin", binaryName)
|
|
76
|
+
if (fs.existsSync(binaryPath)) {
|
|
77
|
+
return { binaryPath, binaryName }
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
throw new Error(`No binary package found for ${basePackageName}`)
|
|
84
|
+
} catch (error) {
|
|
85
|
+
throw new Error(`Could not find package ${basePackageName}: ${error.message}`)
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
function prepareBinDirectory(binaryName) {
|
|
90
|
+
const binDir = path.join(__dirname, "bin")
|
|
91
|
+
const targetPath = path.join(binDir, binaryName)
|
|
92
|
+
|
|
93
|
+
// Ensure bin directory exists
|
|
94
|
+
if (!fs.existsSync(binDir)) {
|
|
95
|
+
fs.mkdirSync(binDir, { recursive: true })
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
// Remove existing binary/symlink if it exists
|
|
99
|
+
if (fs.existsSync(targetPath)) {
|
|
100
|
+
fs.unlinkSync(targetPath)
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
return { binDir, targetPath }
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
function symlinkBinary(sourcePath, binaryName) {
|
|
107
|
+
const { targetPath } = prepareBinDirectory(binaryName)
|
|
108
|
+
|
|
109
|
+
fs.symlinkSync(sourcePath, targetPath)
|
|
110
|
+
console.log(`shuvcode binary symlinked: ${targetPath} -> ${sourcePath}`)
|
|
111
|
+
|
|
112
|
+
// Verify the file exists after operation
|
|
113
|
+
if (!fs.existsSync(targetPath)) {
|
|
114
|
+
throw new Error(`Failed to symlink binary to ${targetPath}`)
|
|
115
|
+
}
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
async function main() {
|
|
119
|
+
try {
|
|
120
|
+
if (os.platform() === "win32") {
|
|
121
|
+
// On Windows, the .exe is already included in the package and bin field points to it
|
|
122
|
+
// No postinstall setup needed
|
|
123
|
+
console.log("Windows detected: binary setup not needed (using packaged .exe)")
|
|
124
|
+
return
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
const { binaryPath, binaryName } = findBinary()
|
|
128
|
+
symlinkBinary(binaryPath, binaryName)
|
|
129
|
+
} catch (error) {
|
|
130
|
+
console.error("Failed to setup shuvcode binary:", error.message)
|
|
131
|
+
process.exit(1)
|
|
132
|
+
}
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
try {
|
|
136
|
+
main()
|
|
137
|
+
} catch (error) {
|
|
138
|
+
console.error("Postinstall script error:", error.message)
|
|
139
|
+
process.exit(0)
|
|
140
|
+
}
|
package/bin/shuvcode
DELETED
|
@@ -1,84 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/env node
|
|
2
|
-
|
|
3
|
-
const childProcess = require("child_process")
|
|
4
|
-
const fs = require("fs")
|
|
5
|
-
const path = require("path")
|
|
6
|
-
const os = require("os")
|
|
7
|
-
|
|
8
|
-
function run(target) {
|
|
9
|
-
const result = childProcess.spawnSync(target, process.argv.slice(2), {
|
|
10
|
-
stdio: "inherit",
|
|
11
|
-
})
|
|
12
|
-
if (result.error) {
|
|
13
|
-
console.error(result.error.message)
|
|
14
|
-
process.exit(1)
|
|
15
|
-
}
|
|
16
|
-
const code = typeof result.status === "number" ? result.status : 0
|
|
17
|
-
process.exit(code)
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
const envPath = process.env.OPENCODE_BIN_PATH
|
|
21
|
-
if (envPath) {
|
|
22
|
-
run(envPath)
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
const scriptPath = fs.realpathSync(__filename)
|
|
26
|
-
const scriptDir = path.dirname(scriptPath)
|
|
27
|
-
|
|
28
|
-
const platformMap = {
|
|
29
|
-
darwin: "darwin",
|
|
30
|
-
linux: "linux",
|
|
31
|
-
win32: "windows",
|
|
32
|
-
}
|
|
33
|
-
const archMap = {
|
|
34
|
-
x64: "x64",
|
|
35
|
-
arm64: "arm64",
|
|
36
|
-
arm: "arm",
|
|
37
|
-
}
|
|
38
|
-
|
|
39
|
-
let platform = platformMap[os.platform()]
|
|
40
|
-
if (!platform) {
|
|
41
|
-
platform = os.platform()
|
|
42
|
-
}
|
|
43
|
-
let arch = archMap[os.arch()]
|
|
44
|
-
if (!arch) {
|
|
45
|
-
arch = os.arch()
|
|
46
|
-
}
|
|
47
|
-
const base = "shuvcode-" + platform + "-" + arch
|
|
48
|
-
const binary = platform === "windows" ? "shuvcode.exe" : "shuvcode"
|
|
49
|
-
|
|
50
|
-
function findBinary(startDir) {
|
|
51
|
-
let current = startDir
|
|
52
|
-
for (;;) {
|
|
53
|
-
const modules = path.join(current, "node_modules")
|
|
54
|
-
if (fs.existsSync(modules)) {
|
|
55
|
-
const entries = fs.readdirSync(modules)
|
|
56
|
-
for (const entry of entries) {
|
|
57
|
-
if (!entry.startsWith(base)) {
|
|
58
|
-
continue
|
|
59
|
-
}
|
|
60
|
-
const candidate = path.join(modules, entry, "bin", binary)
|
|
61
|
-
if (fs.existsSync(candidate)) {
|
|
62
|
-
return candidate
|
|
63
|
-
}
|
|
64
|
-
}
|
|
65
|
-
}
|
|
66
|
-
const parent = path.dirname(current)
|
|
67
|
-
if (parent === current) {
|
|
68
|
-
return
|
|
69
|
-
}
|
|
70
|
-
current = parent
|
|
71
|
-
}
|
|
72
|
-
}
|
|
73
|
-
|
|
74
|
-
const resolved = findBinary(scriptDir)
|
|
75
|
-
if (!resolved) {
|
|
76
|
-
console.error(
|
|
77
|
-
'It seems that your package manager failed to install the right version of shuvcode for your platform. You can try manually installing the "' +
|
|
78
|
-
base +
|
|
79
|
-
'" package',
|
|
80
|
-
)
|
|
81
|
-
process.exit(1)
|
|
82
|
-
}
|
|
83
|
-
|
|
84
|
-
run(resolved)
|