codecane 1.0.406 → 1.0.408
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.
|
@@ -205,44 +205,56 @@ async function downloadBinary(version) {
|
|
|
205
205
|
|
|
206
206
|
const buffer = Buffer.concat(chunks)
|
|
207
207
|
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
208
|
+
try {
|
|
209
|
+
if (fileName.endsWith('.zip')) {
|
|
210
|
+
// Windows ZIP extraction
|
|
211
|
+
const AdmZip = require('adm-zip')
|
|
212
|
+
const zipPath = path.join(CONFIG.configDir, fileName)
|
|
212
213
|
|
|
213
|
-
|
|
214
|
+
fs.writeFileSync(zipPath, buffer)
|
|
214
215
|
|
|
215
|
-
|
|
216
|
-
|
|
216
|
+
const zip = new AdmZip(zipPath)
|
|
217
|
+
zip.extractAllTo(CONFIG.configDir, true)
|
|
217
218
|
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
219
|
+
fs.unlinkSync(zipPath)
|
|
220
|
+
} else {
|
|
221
|
+
// Unix tar.gz extraction
|
|
222
|
+
await new Promise((resolve, reject) => {
|
|
223
|
+
const gunzip = zlib.createGunzip()
|
|
224
|
+
const extract = tar.extract({ cwd: CONFIG.configDir })
|
|
224
225
|
|
|
225
|
-
|
|
226
|
+
gunzip.pipe(extract).on('finish', resolve).on('error', reject)
|
|
226
227
|
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
228
|
+
gunzip.end(buffer)
|
|
229
|
+
})
|
|
230
|
+
}
|
|
230
231
|
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
232
|
+
// Rename extracted binary to standard name
|
|
233
|
+
const extractedName = fileName.replace(/\.(tar\.gz|zip)$/, '')
|
|
234
|
+
const extractedPath = path.join(CONFIG.configDir, extractedName)
|
|
234
235
|
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
236
|
+
if (fs.existsSync(extractedPath)) {
|
|
237
|
+
if (process.platform !== 'win32') {
|
|
238
|
+
fs.chmodSync(extractedPath, 0o755)
|
|
239
|
+
}
|
|
240
|
+
// Remove existing binary if it exists
|
|
241
|
+
if (fs.existsSync(CONFIG.binaryPath)) {
|
|
242
|
+
fs.unlinkSync(CONFIG.binaryPath)
|
|
243
|
+
}
|
|
244
|
+
fs.renameSync(extractedPath, CONFIG.binaryPath)
|
|
245
|
+
} else {
|
|
246
|
+
throw new Error(
|
|
247
|
+
`Binary not found after extraction. Expected: ${extractedPath}.`
|
|
248
|
+
)
|
|
238
249
|
}
|
|
239
|
-
fs.renameSync(extractedPath, CONFIG.binaryPath)
|
|
240
|
-
} else {
|
|
241
|
-
throw new Error(`Binary not found after extraction`)
|
|
242
|
-
}
|
|
243
250
|
|
|
244
|
-
|
|
245
|
-
|
|
251
|
+
// Clear the line after successful download
|
|
252
|
+
term.clearLine()
|
|
253
|
+
} catch (error) {
|
|
254
|
+
term.clearLine()
|
|
255
|
+
console.error(`Extraction failed: ${error.message}`)
|
|
256
|
+
process.exit(1)
|
|
257
|
+
}
|
|
246
258
|
}
|
|
247
259
|
|
|
248
260
|
async function ensureBinaryExists() {
|
|
@@ -286,7 +298,6 @@ async function checkForUpdates(runningProcess, exitListener) {
|
|
|
286
298
|
|
|
287
299
|
if (compareVersions(currentVersion, latestVersion) < 0) {
|
|
288
300
|
term.clearLine()
|
|
289
|
-
console.log(`\nUpdate available: ${currentVersion} → ${latestVersion}`)
|
|
290
301
|
|
|
291
302
|
// Remove the specific exit listener to prevent it from interfering with the update
|
|
292
303
|
runningProcess.removeListener('exit', exitListener)
|
|
@@ -306,6 +317,8 @@ async function checkForUpdates(runningProcess, exitListener) {
|
|
|
306
317
|
}, 5000)
|
|
307
318
|
})
|
|
308
319
|
|
|
320
|
+
console.log(`\nUpdate available: ${currentVersion} → ${latestVersion}`)
|
|
321
|
+
|
|
309
322
|
await downloadBinary(latestVersion)
|
|
310
323
|
|
|
311
324
|
// Restart with new binary - this replaces the current process
|
package/package.json
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "codecane",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.408",
|
|
4
4
|
"description": "AI coding agent",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"bin": {
|
|
7
|
-
"codecane": "
|
|
7
|
+
"codecane": "index.js"
|
|
8
8
|
},
|
|
9
9
|
"files": [
|
|
10
|
-
"
|
|
10
|
+
"index.js",
|
|
11
11
|
"README.md"
|
|
12
12
|
],
|
|
13
13
|
"os": [
|