remotosh 1.3.4 → 1.3.5
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/bin/remoto.js +93 -9
- package/package.json +1 -1
package/bin/remoto.js
CHANGED
|
@@ -159,12 +159,46 @@ async function authenticate() {
|
|
|
159
159
|
// Detect shell
|
|
160
160
|
const shell = process.env.SHELL || (os.platform() === 'win32' ? 'powershell.exe' : 'zsh');
|
|
161
161
|
|
|
162
|
+
// Early check for node-pty native bindings
|
|
163
|
+
function checkPtyAvailable() {
|
|
164
|
+
try {
|
|
165
|
+
const testPty = pty.spawn(shell, ['-c', 'exit 0'], {
|
|
166
|
+
cols: 80,
|
|
167
|
+
rows: 24,
|
|
168
|
+
cwd: os.homedir(),
|
|
169
|
+
});
|
|
170
|
+
testPty.kill();
|
|
171
|
+
return { ok: true };
|
|
172
|
+
} catch (err) {
|
|
173
|
+
return { ok: false, error: err };
|
|
174
|
+
}
|
|
175
|
+
}
|
|
176
|
+
|
|
177
|
+
function showPtyError(err) {
|
|
178
|
+
console.error(chalk.red(`\n native module error: ${err.message}\n`));
|
|
179
|
+
|
|
180
|
+
if (err.message.includes('posix_spawnp') || err.message.includes('spawn-helper')) {
|
|
181
|
+
console.log(chalk.yellow(' node-pty needs to be rebuilt for your system.\n'));
|
|
182
|
+
console.log(chalk.white(' quick fix:\n'));
|
|
183
|
+
console.log(chalk.cyan(' npm uninstall -g remotosh && npm install -g remotosh\n'));
|
|
184
|
+
console.log(chalk.dim(' if that doesn\'t work, you may need build tools:'));
|
|
185
|
+
if (os.platform() === 'darwin') {
|
|
186
|
+
console.log(chalk.cyan(' xcode-select --install'));
|
|
187
|
+
} else if (os.platform() === 'linux') {
|
|
188
|
+
console.log(chalk.cyan(' sudo apt install build-essential # debian/ubuntu'));
|
|
189
|
+
}
|
|
190
|
+
console.log(chalk.dim('\n run `remoto doctor` for full diagnostics\n'));
|
|
191
|
+
} else {
|
|
192
|
+
console.log(chalk.dim(' run `remoto doctor` to diagnose the issue\n'));
|
|
193
|
+
}
|
|
194
|
+
}
|
|
195
|
+
|
|
162
196
|
// Terminal dimensions
|
|
163
197
|
let cols = process.stdout.columns || 80;
|
|
164
198
|
let rows = process.stdout.rows || 24;
|
|
165
199
|
|
|
166
200
|
// Version
|
|
167
|
-
const VERSION = '1.3.
|
|
201
|
+
const VERSION = '1.3.5';
|
|
168
202
|
|
|
169
203
|
// Show help
|
|
170
204
|
function showHelp() {
|
|
@@ -215,15 +249,34 @@ async function runDoctor() {
|
|
|
215
249
|
issues++;
|
|
216
250
|
}
|
|
217
251
|
|
|
252
|
+
// Check platform/architecture
|
|
253
|
+
console.log(chalk.green(` ✓ platform: ${os.platform()} ${os.arch()}`));
|
|
254
|
+
|
|
255
|
+
// Check shell
|
|
256
|
+
console.log(chalk.green(` ✓ shell: ${shell}`));
|
|
257
|
+
|
|
218
258
|
// Check node-pty
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
ptyTest.kill();
|
|
259
|
+
const ptyCheck = checkPtyAvailable();
|
|
260
|
+
if (ptyCheck.ok) {
|
|
222
261
|
console.log(chalk.green(' ✓ node-pty working'));
|
|
223
|
-
}
|
|
224
|
-
|
|
225
|
-
console.log(chalk.
|
|
262
|
+
} else {
|
|
263
|
+
const errMsg = ptyCheck.error.message;
|
|
264
|
+
console.log(chalk.red(' ✗ node-pty failed: ' + errMsg));
|
|
226
265
|
issues++;
|
|
266
|
+
|
|
267
|
+
// Provide specific fix based on error
|
|
268
|
+
if (errMsg.includes('posix_spawnp') || errMsg.includes('spawn-helper')) {
|
|
269
|
+
console.log(chalk.dim(' └─ native module not built for your system'));
|
|
270
|
+
console.log(chalk.dim(' fix: npm uninstall -g remotosh && npm install -g remotosh'));
|
|
271
|
+
if (os.platform() === 'darwin') {
|
|
272
|
+
console.log(chalk.dim(' if that fails: xcode-select --install'));
|
|
273
|
+
} else if (os.platform() === 'linux') {
|
|
274
|
+
console.log(chalk.dim(' if that fails: sudo apt install build-essential'));
|
|
275
|
+
}
|
|
276
|
+
} else if (errMsg.includes('ENOENT')) {
|
|
277
|
+
console.log(chalk.dim(` └─ shell "${shell}" not found`));
|
|
278
|
+
console.log(chalk.dim(' check your SHELL environment variable'));
|
|
279
|
+
}
|
|
227
280
|
}
|
|
228
281
|
|
|
229
282
|
// Check network connectivity
|
|
@@ -311,6 +364,13 @@ async function main() {
|
|
|
311
364
|
console.log(chalk.bold.white('\n remoto'));
|
|
312
365
|
console.log(chalk.dim(' control your terminal from your phone\n'));
|
|
313
366
|
|
|
367
|
+
// Check node-pty before doing anything else
|
|
368
|
+
const ptyCheck = checkPtyAvailable();
|
|
369
|
+
if (!ptyCheck.ok) {
|
|
370
|
+
showPtyError(ptyCheck.error);
|
|
371
|
+
process.exit(1);
|
|
372
|
+
}
|
|
373
|
+
|
|
314
374
|
// Authenticate
|
|
315
375
|
const token = await authenticate();
|
|
316
376
|
|
|
@@ -427,6 +487,8 @@ async function main() {
|
|
|
427
487
|
console.log(chalk.dim(`\n ${connectionUrl}\n`));
|
|
428
488
|
console.log(chalk.dim(' scan the qr code or open the link on your phone'));
|
|
429
489
|
console.log(chalk.dim(` session expires in ${durationMinutes} minutes`));
|
|
490
|
+
console.log(chalk.yellow(' ⚠ keep this qr code private - anyone with it can access your terminal'));
|
|
491
|
+
console.log(chalk.dim(' tip: press Cmd+K (mac) or Ctrl+L (linux) to clear the screen\n'));
|
|
430
492
|
console.log(chalk.dim(' waiting for connection...\n'));
|
|
431
493
|
console.log(chalk.dim('─'.repeat(Math.min(cols, 60))));
|
|
432
494
|
});
|
|
@@ -443,8 +505,30 @@ async function main() {
|
|
|
443
505
|
env: sanitizedEnv,
|
|
444
506
|
});
|
|
445
507
|
} catch (err) {
|
|
446
|
-
console.error(chalk.red(
|
|
447
|
-
|
|
508
|
+
console.error(chalk.red(`\n failed to start shell: ${err.message}\n`));
|
|
509
|
+
|
|
510
|
+
// Provide helpful guidance for common errors
|
|
511
|
+
if (err.message.includes('posix_spawnp') || err.message.includes('spawn-helper')) {
|
|
512
|
+
console.log(chalk.yellow(' this usually means node-pty needs to be rebuilt for your system.\n'));
|
|
513
|
+
console.log(chalk.white(' try these fixes:\n'));
|
|
514
|
+
console.log(chalk.dim(' 1. reinstall globally:'));
|
|
515
|
+
console.log(chalk.cyan(' npm uninstall -g remotosh && npm install -g remotosh\n'));
|
|
516
|
+
console.log(chalk.dim(' 2. if that fails, install build tools first:'));
|
|
517
|
+
if (os.platform() === 'darwin') {
|
|
518
|
+
console.log(chalk.cyan(' xcode-select --install'));
|
|
519
|
+
} else if (os.platform() === 'linux') {
|
|
520
|
+
console.log(chalk.cyan(' sudo apt install build-essential # debian/ubuntu'));
|
|
521
|
+
console.log(chalk.cyan(' sudo dnf groupinstall "Development Tools" # fedora'));
|
|
522
|
+
}
|
|
523
|
+
console.log(chalk.dim('\n 3. then reinstall remotosh\n'));
|
|
524
|
+
console.log(chalk.dim(' run `remoto doctor` for more diagnostics\n'));
|
|
525
|
+
} else if (err.message.includes('ENOENT')) {
|
|
526
|
+
console.log(chalk.yellow(` shell not found: ${shell}`));
|
|
527
|
+
console.log(chalk.dim(' check your SHELL environment variable\n'));
|
|
528
|
+
}
|
|
529
|
+
|
|
530
|
+
ws.close();
|
|
531
|
+
process.exit(1);
|
|
448
532
|
}
|
|
449
533
|
|
|
450
534
|
ptyProcess.onData((data) => {
|