electerm 3.3.2 → 3.3.3

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/npm/install.js +10 -118
  2. package/package.json +1 -1
package/npm/install.js CHANGED
@@ -207,23 +207,16 @@ async function runLinux (folderName, filePattern) {
207
207
  }
208
208
 
209
209
  async function runWin (archName) {
210
- console.log(' [DEBUG] runWin started')
211
- console.log(` [DEBUG] packageRoot: ${packageRoot}`)
212
- console.log(` [DEBUG] extractDir: ${extractDir}`)
213
-
214
210
  const rawVer = await getVer()
215
211
  const ver = sanitizeVersion(rawVer)
216
212
 
217
- console.log(` [DEBUG] Raw version from server: ${rawVer}`)
218
- console.log(` Sanitized version: ${ver}`)
213
+ console.log(` Version: ${ver}`)
219
214
  console.log(` Target: win-${archName}`)
220
215
 
221
216
  const target = join(packageRoot, `electerm-${ver}-win-${archName}`)
222
- console.log(` [DEBUG] Target folder: ${target}`)
223
217
 
224
- console.log(' Cleaning old installations...')
225
218
  rm('-rf', [target, extractDir])
226
- console.log(' [DEBUG] Old installations cleaned')
219
+ fs.mkdirSync(extractDir, { recursive: true })
227
220
 
228
221
  const pattern = new RegExp(`electerm-\\d+\\.\\d+\\.\\d+-win-${archName}\\.tar\\.gz$`)
229
222
  console.log(' Fetching release info...')
@@ -231,70 +224,24 @@ async function runWin (archName) {
231
224
  if (!releaseInfo) {
232
225
  throw new Error(`No release found for Windows ${archName}`)
233
226
  }
234
- console.log(` [DEBUG] Release info found: ${JSON.stringify(releaseInfo, null, 2)}`)
235
227
 
228
+ // Download to a temp file, then extract directly to extractDir with strip:1
229
+ // (avoids a rename which can fail on Windows when AV has file locks)
236
230
  const tmpDir = join(packageRoot, '.electerm-tmp')
237
- console.log(` [DEBUG] Creating temp directory: ${tmpDir}`)
238
231
  rm('-rf', tmpDir)
239
232
  fs.mkdirSync(tmpDir, { recursive: true })
240
233
 
241
234
  const proxyUrl = applyProxy(releaseInfo.browser_download_url)
242
- console.log(` [DEBUG] Proxy URL: ${proxyUrl}`)
243
- console.log(` [DEBUG] Download URL: ${releaseInfo.browser_download_url}`)
235
+ console.log(` URL: ${proxyUrl}`)
244
236
 
245
- console.log(' Downloading...')
246
237
  const { filepath } = await download(releaseInfo.browser_download_url, tmpDir, { extract: false, displayName: releaseInfo.name })
247
- console.log(` [DEBUG] Downloaded to: ${filepath}`)
248
- console.log(` [DEBUG] File exists: ${fs.existsSync(filepath)}`)
249
- console.log(` [DEBUG] File size: ${fs.statSync(filepath).size}`)
250
-
251
- console.log(' Extracting...')
252
- await extractTarGz(filepath, tmpDir)
253
- console.log(' [DEBUG] Extraction complete')
254
-
255
- console.log(' [DEBUG] Listing temp directory contents:')
256
- const entries = fs.readdirSync(tmpDir)
257
- entries.forEach(e => {
258
- const fullPath = join(tmpDir, e)
259
- const stat = fs.statSync(fullPath)
260
- console.log(` [DEBUG] ${e} - ${stat.isDirectory() ? 'DIR' : 'FILE'} (${stat.size} bytes)`)
261
- })
262
-
263
- const extractedFolder = entries.find(e => fs.statSync(join(tmpDir, e)).isDirectory())
264
-
265
- if (!extractedFolder) {
266
- console.error(' [DEBUG] No directory found in extracted archive')
267
- console.error(' [DEBUG] All entries:', entries)
268
- throw new Error('No folder found in extracted archive')
269
- }
270
-
271
- console.log(` [DEBUG] Extracted folder: ${extractedFolder}`)
272
- console.log(' [DEBUG] Contents of extracted folder:')
273
- const extractedContents = fs.readdirSync(join(tmpDir, extractedFolder))
274
- extractedContents.forEach(e => {
275
- const fullPath = join(tmpDir, extractedFolder, e)
276
- const stat = fs.statSync(fullPath)
277
- console.log(` [DEBUG] ${e} - ${stat.isDirectory() ? 'DIR' : 'FILE'} (${stat.size} bytes)`)
278
- })
279
238
 
280
239
  console.log(` Installing to: ${extractDir}`)
281
- fs.renameSync(join(tmpDir, extractedFolder), extractDir)
282
- console.log(' [DEBUG] Renamed folder to extractDir')
283
-
284
- console.log(' [DEBUG] Verifying extractDir contents:')
285
- const installContents = fs.readdirSync(extractDir)
286
- installContents.forEach(e => {
287
- const fullPath = join(extractDir, e)
288
- const stat = fs.statSync(fullPath)
289
- console.log(` [DEBUG] ${e} - ${stat.isDirectory() ? 'DIR' : 'FILE'} (${stat.size} bytes)`)
290
- })
240
+ await extractTarGz(filepath, extractDir, 1)
291
241
 
292
242
  rm('-rf', tmpDir)
293
- console.log(' [DEBUG] Temp directory cleaned')
294
243
 
295
244
  const exePath = getElectermExePath()
296
- console.log(` [DEBUG] Expected exe path: ${exePath}`)
297
- console.log(` [DEBUG] Exe exists: ${fs.existsSync(exePath)}`)
298
245
  if (!fs.existsSync(exePath)) {
299
246
  throw new Error(`electerm.exe not found at ${exePath} after extraction. Archive may have an unexpected structure.`)
300
247
  }
@@ -303,93 +250,38 @@ async function runWin (archName) {
303
250
  }
304
251
 
305
252
  async function runWin7 () {
306
- console.log(' [DEBUG] runWin7 started')
307
- console.log(` [DEBUG] packageRoot: ${packageRoot}`)
308
- console.log(` [DEBUG] extractDir: ${extractDir}`)
309
-
310
253
  const rawVer = await getVer()
311
254
  const ver = sanitizeVersion(rawVer)
312
255
 
313
- console.log(` [DEBUG] Raw version from server: ${rawVer}`)
314
- console.log(` Sanitized version: ${ver}`)
256
+ console.log(` Version: ${ver}`)
315
257
  console.log(' Target: win7')
316
258
 
317
259
  const target = join(packageRoot, `electerm-${ver}-win7`)
318
- console.log(` [DEBUG] Target folder: ${target}`)
319
260
 
320
- console.log(' Cleaning old installations...')
321
261
  rm('-rf', [target, extractDir])
322
- console.log(' [DEBUG] Old installations cleaned')
262
+ fs.mkdirSync(extractDir, { recursive: true })
323
263
 
324
264
  console.log(' Fetching release info...')
325
265
  const releaseInfo = await getReleaseInfo(r => /electerm-\d+\.\d+\.\d+-win7\.tar\.gz$/.test(r.name))
326
266
  if (!releaseInfo) {
327
267
  throw new Error('No release found for Windows 7')
328
268
  }
329
- console.log(` [DEBUG] Release info found: ${JSON.stringify(releaseInfo, null, 2)}`)
330
269
 
331
270
  const tmpDir = join(packageRoot, '.electerm-tmp')
332
- console.log(` [DEBUG] Creating temp directory: ${tmpDir}`)
333
271
  rm('-rf', tmpDir)
334
272
  fs.mkdirSync(tmpDir, { recursive: true })
335
273
 
336
274
  const proxyUrl = applyProxy(releaseInfo.browser_download_url)
337
- console.log(` [DEBUG] Proxy URL: ${proxyUrl}`)
338
- console.log(` [DEBUG] Download URL: ${releaseInfo.browser_download_url}`)
275
+ console.log(` URL: ${proxyUrl}`)
339
276
 
340
- console.log(' Downloading...')
341
277
  const { filepath } = await download(releaseInfo.browser_download_url, tmpDir, { extract: false, displayName: releaseInfo.name })
342
- console.log(` [DEBUG] Downloaded to: ${filepath}`)
343
- console.log(` [DEBUG] File exists: ${fs.existsSync(filepath)}`)
344
- console.log(` [DEBUG] File size: ${fs.statSync(filepath).size}`)
345
-
346
- console.log(' Extracting...')
347
- await extractTarGz(filepath, tmpDir)
348
- console.log(' [DEBUG] Extraction complete')
349
-
350
- console.log(' [DEBUG] Listing temp directory contents:')
351
- const entries = fs.readdirSync(tmpDir)
352
- entries.forEach(e => {
353
- const fullPath = join(tmpDir, e)
354
- const stat = fs.statSync(fullPath)
355
- console.log(` [DEBUG] ${e} - ${stat.isDirectory() ? 'DIR' : 'FILE'} (${stat.size} bytes)`)
356
- })
357
-
358
- const extractedFolder = entries.find(e => fs.statSync(join(tmpDir, e)).isDirectory())
359
-
360
- if (!extractedFolder) {
361
- console.error(' [DEBUG] No directory found in extracted archive')
362
- console.error(' [DEBUG] All entries:', entries)
363
- throw new Error('No folder found in extracted archive')
364
- }
365
-
366
- console.log(` [DEBUG] Extracted folder: ${extractedFolder}`)
367
- console.log(' [DEBUG] Contents of extracted folder:')
368
- const extractedContents = fs.readdirSync(join(tmpDir, extractedFolder))
369
- extractedContents.forEach(e => {
370
- const fullPath = join(tmpDir, extractedFolder, e)
371
- const stat = fs.statSync(fullPath)
372
- console.log(` [DEBUG] ${e} - ${stat.isDirectory() ? 'DIR' : 'FILE'} (${stat.size} bytes)`)
373
- })
374
278
 
375
279
  console.log(` Installing to: ${extractDir}`)
376
- fs.renameSync(join(tmpDir, extractedFolder), extractDir)
377
- console.log(' [DEBUG] Renamed folder to extractDir')
378
-
379
- console.log(' [DEBUG] Verifying extractDir contents:')
380
- const installContents = fs.readdirSync(extractDir)
381
- installContents.forEach(e => {
382
- const fullPath = join(extractDir, e)
383
- const stat = fs.statSync(fullPath)
384
- console.log(` [DEBUG] ${e} - ${stat.isDirectory() ? 'DIR' : 'FILE'} (${stat.size} bytes)`)
385
- })
280
+ await extractTarGz(filepath, extractDir, 1)
386
281
 
387
282
  rm('-rf', tmpDir)
388
- console.log(' [DEBUG] Temp directory cleaned')
389
283
 
390
284
  const exePath = getElectermExePath()
391
- console.log(` [DEBUG] Expected exe path: ${exePath}`)
392
- console.log(` [DEBUG] Exe exists: ${fs.existsSync(exePath)}`)
393
285
  if (!fs.existsSync(exePath)) {
394
286
  throw new Error(`electerm.exe not found at ${exePath} after extraction. Archive may have an unexpected structure.`)
395
287
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "electerm",
3
- "version": "3.3.2",
3
+ "version": "3.3.3",
4
4
  "description": "Terminal/ssh/telnet/serialport/sftp client(linux, mac, win)",
5
5
  "main": "app.js",
6
6
  "bin": "npm/electerm",