electerm 3.3.1 → 3.3.2
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/npm/electerm +6 -33
- package/npm/install.js +121 -8
- package/package.json +1 -1
package/npm/electerm
CHANGED
|
@@ -18,56 +18,37 @@ const os = require('os')
|
|
|
18
18
|
const plat = os.platform()
|
|
19
19
|
const packageRoot = path.resolve(__dirname, '..')
|
|
20
20
|
|
|
21
|
-
/**
|
|
22
|
-
* Get the path to the installed electerm binary
|
|
23
|
-
*/
|
|
24
21
|
function getElectermExePath () {
|
|
25
|
-
// macOS: prefer the installed app in /Applications
|
|
26
22
|
if (plat === 'darwin') {
|
|
27
23
|
const appBinary = '/Applications/electerm.app/Contents/MacOS/electerm'
|
|
28
24
|
if (fs.existsSync(appBinary)) {
|
|
29
25
|
return appBinary
|
|
30
26
|
}
|
|
31
|
-
// Fallback: extracted folder
|
|
32
27
|
return path.join(packageRoot, 'electerm', 'electerm')
|
|
33
28
|
}
|
|
34
29
|
|
|
35
|
-
// Windows
|
|
36
30
|
if (plat === 'win32') {
|
|
37
31
|
return path.join(packageRoot, 'electerm', 'electerm.exe')
|
|
38
32
|
}
|
|
39
33
|
|
|
40
|
-
// Linux
|
|
41
34
|
return path.join(packageRoot, 'electerm', 'electerm')
|
|
42
35
|
}
|
|
43
36
|
|
|
44
|
-
/**
|
|
45
|
-
* Check if the electerm binary exists
|
|
46
|
-
*/
|
|
47
|
-
function isElectermInstalled () {
|
|
48
|
-
return fs.existsSync(getElectermExePath())
|
|
49
|
-
}
|
|
50
|
-
|
|
51
|
-
/**
|
|
52
|
-
* Launch the installed electerm binary
|
|
53
|
-
*/
|
|
54
37
|
function launchElecterm () {
|
|
55
38
|
const exePath = getElectermExePath()
|
|
56
39
|
|
|
57
40
|
if (!fs.existsSync(exePath)) {
|
|
58
|
-
console.error('
|
|
41
|
+
console.error('electerm binary not found at:', exePath)
|
|
59
42
|
console.error('')
|
|
60
|
-
console.error('The binary may not have been installed.
|
|
43
|
+
console.error('The binary may not have been installed properly.')
|
|
44
|
+
console.error('Try running manually:')
|
|
61
45
|
console.error(' node', path.join(packageRoot, 'npm', 'install.js'))
|
|
62
46
|
process.exit(1)
|
|
63
47
|
}
|
|
64
48
|
|
|
65
|
-
// Spawn the binary, passing through all args
|
|
66
49
|
const child = spawn(exePath, process.argv.slice(2), {
|
|
67
50
|
stdio: 'inherit',
|
|
68
|
-
// On macOS/Linux, detach so the app survives if the terminal closes
|
|
69
51
|
detached: plat !== 'win32',
|
|
70
|
-
// On Windows, don't create a console window for the spawn
|
|
71
52
|
windowsHide: false
|
|
72
53
|
})
|
|
73
54
|
|
|
@@ -85,16 +66,8 @@ function launchElecterm () {
|
|
|
85
66
|
})
|
|
86
67
|
}
|
|
87
68
|
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
// ---------------------------------------------------------------------------
|
|
91
|
-
|
|
92
|
-
if (!isElectermInstalled()) {
|
|
93
|
-
console.error('electerm binary not found. It should have been installed during npm install.')
|
|
94
|
-
console.error('')
|
|
95
|
-
console.error('Try running manually:')
|
|
96
|
-
console.error(' node', path.join(packageRoot, 'npm', 'install.js'))
|
|
97
|
-
process.exit(1)
|
|
69
|
+
if (require.main === module) {
|
|
70
|
+
launchElecterm()
|
|
98
71
|
}
|
|
99
72
|
|
|
100
|
-
launchElecterm
|
|
73
|
+
module.exports = { launchElecterm }
|
package/npm/install.js
CHANGED
|
@@ -191,6 +191,15 @@ async function runLinux (folderName, filePattern) {
|
|
|
191
191
|
console.log(` Installing to: ${extractDir}`)
|
|
192
192
|
mv(join(tmpDir, extractedFolder), extractDir)
|
|
193
193
|
|
|
194
|
+
// Fix chrome-sandbox permissions on Linux (Electron requires specific permissions)
|
|
195
|
+
if (plat === 'linux') {
|
|
196
|
+
const chromeSandboxPath = join(extractDir, 'chrome-sandbox')
|
|
197
|
+
if (fs.existsSync(chromeSandboxPath)) {
|
|
198
|
+
console.log(' Fixing chrome-sandbox permissions...')
|
|
199
|
+
fs.chmodSync(chromeSandboxPath, 0o4755)
|
|
200
|
+
}
|
|
201
|
+
}
|
|
202
|
+
|
|
194
203
|
// Clean up temp files
|
|
195
204
|
rm('-rf', tmpDir)
|
|
196
205
|
|
|
@@ -198,15 +207,23 @@ async function runLinux (folderName, filePattern) {
|
|
|
198
207
|
}
|
|
199
208
|
|
|
200
209
|
async function runWin (archName) {
|
|
210
|
+
console.log(' [DEBUG] runWin started')
|
|
211
|
+
console.log(` [DEBUG] packageRoot: ${packageRoot}`)
|
|
212
|
+
console.log(` [DEBUG] extractDir: ${extractDir}`)
|
|
213
|
+
|
|
201
214
|
const rawVer = await getVer()
|
|
202
215
|
const ver = sanitizeVersion(rawVer)
|
|
203
216
|
|
|
204
|
-
console.log(`
|
|
217
|
+
console.log(` [DEBUG] Raw version from server: ${rawVer}`)
|
|
218
|
+
console.log(` Sanitized version: ${ver}`)
|
|
205
219
|
console.log(` Target: win-${archName}`)
|
|
206
220
|
|
|
207
221
|
const target = join(packageRoot, `electerm-${ver}-win-${archName}`)
|
|
222
|
+
console.log(` [DEBUG] Target folder: ${target}`)
|
|
208
223
|
|
|
224
|
+
console.log(' Cleaning old installations...')
|
|
209
225
|
rm('-rf', [target, extractDir])
|
|
226
|
+
console.log(' [DEBUG] Old installations cleaned')
|
|
210
227
|
|
|
211
228
|
const pattern = new RegExp(`electerm-\\d+\\.\\d+\\.\\d+-win-${archName}\\.tar\\.gz$`)
|
|
212
229
|
console.log(' Fetching release info...')
|
|
@@ -214,72 +231,168 @@ async function runWin (archName) {
|
|
|
214
231
|
if (!releaseInfo) {
|
|
215
232
|
throw new Error(`No release found for Windows ${archName}`)
|
|
216
233
|
}
|
|
234
|
+
console.log(` [DEBUG] Release info found: ${JSON.stringify(releaseInfo, null, 2)}`)
|
|
217
235
|
|
|
218
|
-
// Extract to temp, then move
|
|
219
236
|
const tmpDir = join(packageRoot, '.electerm-tmp')
|
|
237
|
+
console.log(` [DEBUG] Creating temp directory: ${tmpDir}`)
|
|
220
238
|
rm('-rf', tmpDir)
|
|
221
239
|
fs.mkdirSync(tmpDir, { recursive: true })
|
|
222
240
|
|
|
223
241
|
const proxyUrl = applyProxy(releaseInfo.browser_download_url)
|
|
224
|
-
console.log(` URL: ${proxyUrl}`)
|
|
242
|
+
console.log(` [DEBUG] Proxy URL: ${proxyUrl}`)
|
|
243
|
+
console.log(` [DEBUG] Download URL: ${releaseInfo.browser_download_url}`)
|
|
225
244
|
|
|
245
|
+
console.log(' Downloading...')
|
|
226
246
|
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}`)
|
|
227
250
|
|
|
251
|
+
console.log(' Extracting...')
|
|
228
252
|
await extractTarGz(filepath, tmpDir)
|
|
253
|
+
console.log(' [DEBUG] Extraction complete')
|
|
229
254
|
|
|
255
|
+
console.log(' [DEBUG] Listing temp directory contents:')
|
|
230
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
|
+
|
|
231
263
|
const extractedFolder = entries.find(e => fs.statSync(join(tmpDir, e)).isDirectory())
|
|
232
264
|
|
|
233
265
|
if (!extractedFolder) {
|
|
266
|
+
console.error(' [DEBUG] No directory found in extracted archive')
|
|
267
|
+
console.error(' [DEBUG] All entries:', entries)
|
|
234
268
|
throw new Error('No folder found in extracted archive')
|
|
235
269
|
}
|
|
236
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
|
+
|
|
237
280
|
console.log(` Installing to: ${extractDir}`)
|
|
238
|
-
|
|
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
|
+
})
|
|
291
|
+
|
|
239
292
|
rm('-rf', tmpDir)
|
|
293
|
+
console.log(' [DEBUG] Temp directory cleaned')
|
|
294
|
+
|
|
295
|
+
const exePath = getElectermExePath()
|
|
296
|
+
console.log(` [DEBUG] Expected exe path: ${exePath}`)
|
|
297
|
+
console.log(` [DEBUG] Exe exists: ${fs.existsSync(exePath)}`)
|
|
298
|
+
if (!fs.existsSync(exePath)) {
|
|
299
|
+
throw new Error(`electerm.exe not found at ${exePath} after extraction. Archive may have an unexpected structure.`)
|
|
300
|
+
}
|
|
240
301
|
|
|
241
302
|
showFinalMessage()
|
|
242
303
|
}
|
|
243
304
|
|
|
244
305
|
async function runWin7 () {
|
|
306
|
+
console.log(' [DEBUG] runWin7 started')
|
|
307
|
+
console.log(` [DEBUG] packageRoot: ${packageRoot}`)
|
|
308
|
+
console.log(` [DEBUG] extractDir: ${extractDir}`)
|
|
309
|
+
|
|
245
310
|
const rawVer = await getVer()
|
|
246
311
|
const ver = sanitizeVersion(rawVer)
|
|
247
312
|
|
|
248
|
-
console.log(`
|
|
313
|
+
console.log(` [DEBUG] Raw version from server: ${rawVer}`)
|
|
314
|
+
console.log(` Sanitized version: ${ver}`)
|
|
249
315
|
console.log(' Target: win7')
|
|
250
316
|
|
|
251
317
|
const target = join(packageRoot, `electerm-${ver}-win7`)
|
|
318
|
+
console.log(` [DEBUG] Target folder: ${target}`)
|
|
252
319
|
|
|
320
|
+
console.log(' Cleaning old installations...')
|
|
253
321
|
rm('-rf', [target, extractDir])
|
|
322
|
+
console.log(' [DEBUG] Old installations cleaned')
|
|
254
323
|
|
|
255
324
|
console.log(' Fetching release info...')
|
|
256
325
|
const releaseInfo = await getReleaseInfo(r => /electerm-\d+\.\d+\.\d+-win7\.tar\.gz$/.test(r.name))
|
|
257
326
|
if (!releaseInfo) {
|
|
258
327
|
throw new Error('No release found for Windows 7')
|
|
259
328
|
}
|
|
329
|
+
console.log(` [DEBUG] Release info found: ${JSON.stringify(releaseInfo, null, 2)}`)
|
|
260
330
|
|
|
261
|
-
// Extract to temp, then move
|
|
262
331
|
const tmpDir = join(packageRoot, '.electerm-tmp')
|
|
332
|
+
console.log(` [DEBUG] Creating temp directory: ${tmpDir}`)
|
|
263
333
|
rm('-rf', tmpDir)
|
|
264
334
|
fs.mkdirSync(tmpDir, { recursive: true })
|
|
265
335
|
|
|
266
336
|
const proxyUrl = applyProxy(releaseInfo.browser_download_url)
|
|
267
|
-
console.log(` URL: ${proxyUrl}`)
|
|
337
|
+
console.log(` [DEBUG] Proxy URL: ${proxyUrl}`)
|
|
338
|
+
console.log(` [DEBUG] Download URL: ${releaseInfo.browser_download_url}`)
|
|
268
339
|
|
|
340
|
+
console.log(' Downloading...')
|
|
269
341
|
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}`)
|
|
270
345
|
|
|
346
|
+
console.log(' Extracting...')
|
|
271
347
|
await extractTarGz(filepath, tmpDir)
|
|
348
|
+
console.log(' [DEBUG] Extraction complete')
|
|
272
349
|
|
|
350
|
+
console.log(' [DEBUG] Listing temp directory contents:')
|
|
273
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
|
+
|
|
274
358
|
const extractedFolder = entries.find(e => fs.statSync(join(tmpDir, e)).isDirectory())
|
|
275
359
|
|
|
276
360
|
if (!extractedFolder) {
|
|
361
|
+
console.error(' [DEBUG] No directory found in extracted archive')
|
|
362
|
+
console.error(' [DEBUG] All entries:', entries)
|
|
277
363
|
throw new Error('No folder found in extracted archive')
|
|
278
364
|
}
|
|
279
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
|
+
|
|
280
375
|
console.log(` Installing to: ${extractDir}`)
|
|
281
|
-
|
|
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
|
+
})
|
|
386
|
+
|
|
282
387
|
rm('-rf', tmpDir)
|
|
388
|
+
console.log(' [DEBUG] Temp directory cleaned')
|
|
389
|
+
|
|
390
|
+
const exePath = getElectermExePath()
|
|
391
|
+
console.log(` [DEBUG] Expected exe path: ${exePath}`)
|
|
392
|
+
console.log(` [DEBUG] Exe exists: ${fs.existsSync(exePath)}`)
|
|
393
|
+
if (!fs.existsSync(exePath)) {
|
|
394
|
+
throw new Error(`electerm.exe not found at ${exePath} after extraction. Archive may have an unexpected structure.`)
|
|
395
|
+
}
|
|
283
396
|
|
|
284
397
|
showFinalMessage()
|
|
285
398
|
}
|