@ericsanchezok/synergy 2.1.2 → 2.2.0
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 +12 -12
- package/postinstall.mjs +60 -1
package/package.json
CHANGED
|
@@ -6,19 +6,19 @@
|
|
|
6
6
|
"scripts": {
|
|
7
7
|
"postinstall": "bun ./postinstall.mjs || node ./postinstall.mjs"
|
|
8
8
|
},
|
|
9
|
-
"version": "2.
|
|
9
|
+
"version": "2.2.0",
|
|
10
10
|
"optionalDependencies": {
|
|
11
|
-
"@ericsanchezok/synergy-darwin-arm64": "2.
|
|
12
|
-
"@ericsanchezok/synergy-linux-arm64-musl": "2.
|
|
13
|
-
"@ericsanchezok/synergy-darwin-x64": "2.
|
|
14
|
-
"@ericsanchezok/synergy-linux-arm64": "2.
|
|
15
|
-
"@ericsanchezok/synergy-linux-x64-baseline": "2.
|
|
16
|
-
"@ericsanchezok/synergy-linux-x64": "2.
|
|
17
|
-
"@ericsanchezok/synergy-linux-x64-musl": "2.
|
|
18
|
-
"@ericsanchezok/synergy-windows-x64-baseline": "2.
|
|
19
|
-
"@ericsanchezok/synergy-darwin-x64-baseline": "2.
|
|
20
|
-
"@ericsanchezok/synergy-windows-x64": "2.
|
|
21
|
-
"@ericsanchezok/synergy-linux-x64-baseline-musl": "2.
|
|
11
|
+
"@ericsanchezok/synergy-darwin-arm64": "2.2.0",
|
|
12
|
+
"@ericsanchezok/synergy-linux-arm64-musl": "2.2.0",
|
|
13
|
+
"@ericsanchezok/synergy-darwin-x64": "2.2.0",
|
|
14
|
+
"@ericsanchezok/synergy-linux-arm64": "2.2.0",
|
|
15
|
+
"@ericsanchezok/synergy-linux-x64-baseline": "2.2.0",
|
|
16
|
+
"@ericsanchezok/synergy-linux-x64": "2.2.0",
|
|
17
|
+
"@ericsanchezok/synergy-linux-x64-musl": "2.2.0",
|
|
18
|
+
"@ericsanchezok/synergy-windows-x64-baseline": "2.2.0",
|
|
19
|
+
"@ericsanchezok/synergy-darwin-x64-baseline": "2.2.0",
|
|
20
|
+
"@ericsanchezok/synergy-windows-x64": "2.2.0",
|
|
21
|
+
"@ericsanchezok/synergy-linux-x64-baseline-musl": "2.2.0"
|
|
22
22
|
},
|
|
23
23
|
"repository": {
|
|
24
24
|
"type": "git",
|
package/postinstall.mjs
CHANGED
|
@@ -60,17 +60,76 @@ function symlinkBinary(sourcePath, binaryName) {
|
|
|
60
60
|
}
|
|
61
61
|
}
|
|
62
62
|
|
|
63
|
+
async function installSandboxHelper() {
|
|
64
|
+
const platform = os.platform()
|
|
65
|
+
const homedir = os.homedir()
|
|
66
|
+
|
|
67
|
+
// macOS uses sandbox-exec built into the OS — no helper needed
|
|
68
|
+
if (platform === "darwin") return
|
|
69
|
+
|
|
70
|
+
let helperBinaryName
|
|
71
|
+
let nodePkgPattern
|
|
72
|
+
|
|
73
|
+
if (platform === "linux") {
|
|
74
|
+
helperBinaryName = "synergy-sandbox-linux"
|
|
75
|
+
nodePkgPattern = "synergy-sandbox-linux-"
|
|
76
|
+
} else if (platform === "win32") {
|
|
77
|
+
helperBinaryName = "synergy-sandbox-windows.exe"
|
|
78
|
+
nodePkgPattern = "synergy-sandbox-windows-"
|
|
79
|
+
} else {
|
|
80
|
+
console.warn("Unsupported platform for sandbox helper:", platform)
|
|
81
|
+
return
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
const destDir = path.join(homedir, ".synergy", "sandbox-helper")
|
|
85
|
+
const destPath = path.join(destDir, helperBinaryName)
|
|
86
|
+
|
|
87
|
+
// Idempotent: skip if already installed
|
|
88
|
+
if (fs.existsSync(destPath)) return
|
|
89
|
+
|
|
90
|
+
// Search for the helper in node_modules/@ericsanchezok/
|
|
91
|
+
const scopeDir = path.join(__dirname, "..", "node_modules", "@ericsanchezok")
|
|
92
|
+
let found = false
|
|
93
|
+
|
|
94
|
+
if (fs.existsSync(scopeDir)) {
|
|
95
|
+
try {
|
|
96
|
+
const entries = fs.readdirSync(scopeDir)
|
|
97
|
+
for (const entry of entries) {
|
|
98
|
+
if (entry.startsWith(nodePkgPattern)) {
|
|
99
|
+
const helperPath = path.join(scopeDir, entry, "bin", helperBinaryName)
|
|
100
|
+
if (fs.existsSync(helperPath)) {
|
|
101
|
+
fs.mkdirSync(destDir, { recursive: true })
|
|
102
|
+
fs.copyFileSync(helperPath, destPath)
|
|
103
|
+
if (platform === "linux") {
|
|
104
|
+
fs.chmodSync(destPath, 0o755)
|
|
105
|
+
}
|
|
106
|
+
console.log(`Sandbox helper installed: ${destPath}`)
|
|
107
|
+
found = true
|
|
108
|
+
break
|
|
109
|
+
}
|
|
110
|
+
}
|
|
111
|
+
}
|
|
112
|
+
} catch {}
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
if (!found) {
|
|
116
|
+
console.warn(`Sandbox helper not found in node_modules. Sandbox will gracefully degrade.`)
|
|
117
|
+
}
|
|
118
|
+
}
|
|
119
|
+
|
|
63
120
|
async function main() {
|
|
64
121
|
try {
|
|
65
122
|
if (os.platform() === "win32") {
|
|
66
123
|
// On Windows, the .exe is already included in the package and bin field points to it
|
|
67
124
|
// No postinstall setup needed
|
|
68
125
|
console.log("Windows detected: binary setup not needed (using packaged .exe)")
|
|
126
|
+
await installSandboxHelper()
|
|
69
127
|
return
|
|
70
128
|
}
|
|
71
129
|
|
|
72
130
|
const { binaryPath, binaryName } = findBinary()
|
|
73
131
|
symlinkBinary(binaryPath, binaryName)
|
|
132
|
+
await installSandboxHelper()
|
|
74
133
|
} catch (error) {
|
|
75
134
|
console.error("Failed to setup synergy binary:", error.message)
|
|
76
135
|
process.exit(1)
|
|
@@ -81,5 +140,5 @@ try {
|
|
|
81
140
|
main()
|
|
82
141
|
} catch (error) {
|
|
83
142
|
console.error("Postinstall script error:", error.message)
|
|
84
|
-
process.exit(
|
|
143
|
+
process.exit(1)
|
|
85
144
|
}
|