shuvcode 1.1.48 → 1.1.50
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/LICENSE +21 -0
- package/package.json +16 -12
- package/postinstall.mjs +125 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2025 opencode
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/package.json
CHANGED
|
@@ -3,19 +3,23 @@
|
|
|
3
3
|
"bin": {
|
|
4
4
|
"shuvcode": "./bin/shuvcode"
|
|
5
5
|
},
|
|
6
|
-
"
|
|
6
|
+
"scripts": {
|
|
7
|
+
"postinstall": "bun ./postinstall.mjs || node ./postinstall.mjs"
|
|
8
|
+
},
|
|
9
|
+
"version": "1.1.50",
|
|
10
|
+
"license": "MIT",
|
|
7
11
|
"optionalDependencies": {
|
|
8
|
-
"shuvcode-linux-arm64": "1.1.
|
|
9
|
-
"shuvcode-linux-x64": "1.1.
|
|
10
|
-
"shuvcode-linux-x64-baseline": "1.1.
|
|
11
|
-
"shuvcode-linux-arm64-musl": "1.1.
|
|
12
|
-
"shuvcode-linux-x64-musl": "1.1.
|
|
13
|
-
"shuvcode-linux-x64-baseline-musl": "1.1.
|
|
14
|
-
"shuvcode-darwin-arm64": "1.1.
|
|
15
|
-
"shuvcode-darwin-x64": "1.1.
|
|
16
|
-
"shuvcode-darwin-x64-baseline": "1.1.
|
|
17
|
-
"shuvcode-windows-x64": "1.1.
|
|
18
|
-
"shuvcode-windows-x64-baseline": "1.1.
|
|
12
|
+
"shuvcode-linux-arm64": "1.1.50",
|
|
13
|
+
"shuvcode-linux-x64": "1.1.50",
|
|
14
|
+
"shuvcode-linux-x64-baseline": "1.1.50",
|
|
15
|
+
"shuvcode-linux-arm64-musl": "1.1.50",
|
|
16
|
+
"shuvcode-linux-x64-musl": "1.1.50",
|
|
17
|
+
"shuvcode-linux-x64-baseline-musl": "1.1.50",
|
|
18
|
+
"shuvcode-darwin-arm64": "1.1.50",
|
|
19
|
+
"shuvcode-darwin-x64": "1.1.50",
|
|
20
|
+
"shuvcode-darwin-x64-baseline": "1.1.50",
|
|
21
|
+
"shuvcode-windows-x64": "1.1.50",
|
|
22
|
+
"shuvcode-windows-x64-baseline": "1.1.50"
|
|
19
23
|
},
|
|
20
24
|
"repository": {
|
|
21
25
|
"type": "git",
|
package/postinstall.mjs
ADDED
|
@@ -0,0 +1,125 @@
|
|
|
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 packageName = `shuvcode-${platform}-${arch}`
|
|
53
|
+
const binaryName = platform === "windows" ? "opencode.exe" : "opencode"
|
|
54
|
+
|
|
55
|
+
try {
|
|
56
|
+
// Use require.resolve to find the package
|
|
57
|
+
const packageJsonPath = require.resolve(`${packageName}/package.json`)
|
|
58
|
+
const packageDir = path.dirname(packageJsonPath)
|
|
59
|
+
const binaryPath = path.join(packageDir, "bin", binaryName)
|
|
60
|
+
|
|
61
|
+
if (!fs.existsSync(binaryPath)) {
|
|
62
|
+
throw new Error(`Binary not found at ${binaryPath}`)
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
return { binaryPath, binaryName }
|
|
66
|
+
} catch (error) {
|
|
67
|
+
throw new Error(`Could not find package ${packageName}: ${error.message}`)
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
function prepareBinDirectory(binaryName) {
|
|
72
|
+
const binDir = path.join(__dirname, "bin")
|
|
73
|
+
const targetPath = path.join(binDir, binaryName)
|
|
74
|
+
|
|
75
|
+
// Ensure bin directory exists
|
|
76
|
+
if (!fs.existsSync(binDir)) {
|
|
77
|
+
fs.mkdirSync(binDir, { recursive: true })
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
// Remove existing binary/symlink if it exists
|
|
81
|
+
if (fs.existsSync(targetPath)) {
|
|
82
|
+
fs.unlinkSync(targetPath)
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
return { binDir, targetPath }
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
function symlinkBinary(sourcePath, binaryName) {
|
|
89
|
+
const { targetPath } = prepareBinDirectory(binaryName)
|
|
90
|
+
|
|
91
|
+
fs.symlinkSync(sourcePath, targetPath)
|
|
92
|
+
console.log(`opencode binary symlinked: ${targetPath} -> ${sourcePath}`)
|
|
93
|
+
|
|
94
|
+
// Verify the file exists after operation
|
|
95
|
+
if (!fs.existsSync(targetPath)) {
|
|
96
|
+
throw new Error(`Failed to symlink binary to ${targetPath}`)
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
async function main() {
|
|
101
|
+
try {
|
|
102
|
+
if (os.platform() === "win32") {
|
|
103
|
+
// On Windows, the .exe is already included in the package and bin field points to it
|
|
104
|
+
// No postinstall setup needed
|
|
105
|
+
console.log("Windows detected: binary setup not needed (using packaged .exe)")
|
|
106
|
+
return
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
// On non-Windows platforms, just verify the binary package exists
|
|
110
|
+
// Don't replace the wrapper script - it handles binary execution
|
|
111
|
+
const { binaryPath } = findBinary()
|
|
112
|
+
console.log(`Platform binary verified at: ${binaryPath}`)
|
|
113
|
+
console.log("Wrapper script will handle binary execution")
|
|
114
|
+
} catch (error) {
|
|
115
|
+
console.error("Failed to setup opencode binary:", error.message)
|
|
116
|
+
process.exit(1)
|
|
117
|
+
}
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
try {
|
|
121
|
+
main()
|
|
122
|
+
} catch (error) {
|
|
123
|
+
console.error("Postinstall script error:", error.message)
|
|
124
|
+
process.exit(0)
|
|
125
|
+
}
|