@ericsanchezok/synergy 2.4.3 → 2.4.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.
Files changed (2) hide show
  1. package/package.json +12 -13
  2. package/postinstall.mjs +33 -8
package/package.json CHANGED
@@ -6,20 +6,19 @@
6
6
  "scripts": {
7
7
  "postinstall": "bun ./postinstall.mjs || node ./postinstall.mjs"
8
8
  },
9
- "version": "2.4.3",
9
+ "version": "2.4.4",
10
10
  "optionalDependencies": {
11
- "@ericsanchezok/synergy-darwin-arm64": "2.4.3",
12
- "@ericsanchezok/synergy-linux-arm64-musl": "2.4.3",
13
- "@ericsanchezok/synergy-darwin-x64": "2.4.3",
14
- "@ericsanchezok/synergy-linux-arm64": "2.4.3",
15
- "@ericsanchezok/synergy-linux-x64-baseline": "2.4.3",
16
- "@ericsanchezok/synergy-linux-x64": "2.4.3",
17
- "@ericsanchezok/synergy-linux-x64-musl": "2.4.3",
18
- "@ericsanchezok/synergy-windows-arm64": "2.4.3",
19
- "@ericsanchezok/synergy-windows-x64-baseline": "2.4.3",
20
- "@ericsanchezok/synergy-darwin-x64-baseline": "2.4.3",
21
- "@ericsanchezok/synergy-windows-x64": "2.4.3",
22
- "@ericsanchezok/synergy-linux-x64-baseline-musl": "2.4.3"
11
+ "@ericsanchezok/synergy-darwin-x64": "2.4.4",
12
+ "@ericsanchezok/synergy-linux-x64-musl": "2.4.4",
13
+ "@ericsanchezok/synergy-windows-x64-baseline": "2.4.4",
14
+ "@ericsanchezok/synergy-darwin-arm64": "2.4.4",
15
+ "@ericsanchezok/synergy-linux-arm64": "2.4.4",
16
+ "@ericsanchezok/synergy-linux-x64": "2.4.4",
17
+ "@ericsanchezok/synergy-linux-x64-baseline-musl": "2.4.4",
18
+ "@ericsanchezok/synergy-windows-x64": "2.4.4",
19
+ "@ericsanchezok/synergy-darwin-x64-baseline": "2.4.4",
20
+ "@ericsanchezok/synergy-linux-arm64-musl": "2.4.4",
21
+ "@ericsanchezok/synergy-linux-x64-baseline": "2.4.4"
23
22
  },
24
23
  "repository": {
25
24
  "type": "git",
package/postinstall.mjs CHANGED
@@ -60,7 +60,22 @@ function symlinkBinary(sourcePath, binaryName) {
60
60
  }
61
61
  }
62
62
 
63
- async function installSandboxHelper() {
63
+ function filesEqual(left, right) {
64
+ try {
65
+ const leftStat = fs.statSync(left)
66
+ const rightStat = fs.statSync(right)
67
+ return (
68
+ leftStat.isFile() &&
69
+ rightStat.isFile() &&
70
+ leftStat.size === rightStat.size &&
71
+ fs.readFileSync(left).equals(fs.readFileSync(right))
72
+ )
73
+ } catch {
74
+ return false
75
+ }
76
+ }
77
+
78
+ async function installSandboxHelper(binaryPath) {
64
79
  const platform = os.platform()
65
80
  const homedir = os.homedir()
66
81
 
@@ -84,14 +99,23 @@ async function installSandboxHelper() {
84
99
  const destDir = path.join(homedir, ".synergy", "sandbox-helper")
85
100
  const destPath = path.join(destDir, helperBinaryName)
86
101
 
87
- // Idempotent: skip if already installed
88
- if (fs.existsSync(destPath)) return
89
-
90
- // Search for the helper in node_modules/@ericsanchezok/
102
+ // Prefer the helper embedded in the selected platform package, then support
103
+ // legacy standalone helper packages if one is present.
91
104
  const scopeDir = path.join(__dirname, "..", "node_modules", "@ericsanchezok")
92
105
  let found = false
93
106
 
94
- if (fs.existsSync(scopeDir)) {
107
+ const packagedHelper = path.resolve(path.dirname(binaryPath), "..", "sandbox", helperBinaryName)
108
+ if (fs.existsSync(packagedHelper)) {
109
+ if (!filesEqual(packagedHelper, destPath)) {
110
+ fs.mkdirSync(destDir, { recursive: true })
111
+ fs.copyFileSync(packagedHelper, destPath)
112
+ if (platform === "linux") fs.chmodSync(destPath, 0o755)
113
+ console.log(`Sandbox helper installed: ${destPath}`)
114
+ }
115
+ found = true
116
+ }
117
+
118
+ if (!found && fs.existsSync(scopeDir)) {
95
119
  try {
96
120
  const entries = fs.readdirSync(scopeDir)
97
121
  for (const entry of entries) {
@@ -123,13 +147,14 @@ async function main() {
123
147
  // On Windows, the .exe is already included in the package and bin field points to it
124
148
  // No postinstall setup needed
125
149
  console.log("Windows detected: binary setup not needed (using packaged .exe)")
126
- await installSandboxHelper()
150
+ const { binaryPath } = findBinary()
151
+ await installSandboxHelper(binaryPath)
127
152
  return
128
153
  }
129
154
 
130
155
  const { binaryPath, binaryName } = findBinary()
131
156
  symlinkBinary(binaryPath, binaryName)
132
- await installSandboxHelper()
157
+ await installSandboxHelper(binaryPath)
133
158
  } catch (error) {
134
159
  console.error("Failed to setup synergy binary:", error.message)
135
160
  process.exit(1)