nstantpage-agent 0.5.5 → 0.5.7
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/dist/cli.js +1 -1
- package/dist/commands/start.js +1 -1
- package/dist/localServer.js +61 -29
- package/package.json +1 -1
package/dist/cli.js
CHANGED
|
@@ -25,7 +25,7 @@ const program = new Command();
|
|
|
25
25
|
program
|
|
26
26
|
.name('nstantpage')
|
|
27
27
|
.description('Local development agent for nstantpage.com — run projects on your machine, preview in the cloud')
|
|
28
|
-
.version('0.5.
|
|
28
|
+
.version('0.5.7');
|
|
29
29
|
program
|
|
30
30
|
.command('login')
|
|
31
31
|
.description('Authenticate with nstantpage.com')
|
package/dist/commands/start.js
CHANGED
|
@@ -24,7 +24,7 @@ import { getConfig, getProjectConfig, setProjectConfig, clearProjectConfig, getD
|
|
|
24
24
|
import { TunnelClient } from '../tunnel.js';
|
|
25
25
|
import { LocalServer } from '../localServer.js';
|
|
26
26
|
import { PackageInstaller } from '../packageInstaller.js';
|
|
27
|
-
const VERSION = '0.5.
|
|
27
|
+
const VERSION = '0.5.7';
|
|
28
28
|
/**
|
|
29
29
|
* Resolve the backend API base URL.
|
|
30
30
|
* - If --backend is passed, use it
|
package/dist/localServer.js
CHANGED
|
@@ -13,6 +13,7 @@
|
|
|
13
13
|
* Requests arrive through the tunnel from the gateway.
|
|
14
14
|
*/
|
|
15
15
|
import http from 'http';
|
|
16
|
+
import fs from 'fs';
|
|
16
17
|
import os from 'os';
|
|
17
18
|
import { createRequire } from 'module';
|
|
18
19
|
import { spawn } from 'child_process';
|
|
@@ -405,39 +406,70 @@ export class LocalServer {
|
|
|
405
406
|
const label = parsed.label || `Terminal ${sessionCounter}`;
|
|
406
407
|
let shell = null;
|
|
407
408
|
let ptyProcess = null;
|
|
409
|
+
// Ensure project directory exists (posix_spawnp fails if cwd is missing)
|
|
410
|
+
const spawnCwd = fs.existsSync(this.options.projectDir) ? this.options.projectDir : process.cwd();
|
|
408
411
|
// Prefer node-pty for real PTY (interactive shell, echo, prompt, resize)
|
|
409
412
|
if (ptyModule) {
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
stdio: ['pipe', 'pipe', 'pipe'],
|
|
424
|
-
});
|
|
413
|
+
try {
|
|
414
|
+
ptyProcess = ptyModule.spawn(shellCmd, [], {
|
|
415
|
+
name: 'xterm-256color',
|
|
416
|
+
cols,
|
|
417
|
+
rows,
|
|
418
|
+
cwd: spawnCwd,
|
|
419
|
+
env: shellEnv,
|
|
420
|
+
});
|
|
421
|
+
}
|
|
422
|
+
catch (ptyErr) {
|
|
423
|
+
console.warn(` [Terminal] node-pty spawn failed: ${ptyErr.message} — falling back to script`);
|
|
424
|
+
ptyProcess = null;
|
|
425
|
+
}
|
|
425
426
|
}
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
|
|
427
|
+
if (!ptyProcess && !shell) {
|
|
428
|
+
try {
|
|
429
|
+
if (process.platform === 'darwin') {
|
|
430
|
+
// macOS fallback: use 'script' to allocate a PTY
|
|
431
|
+
shell = spawn('script', ['-q', '/dev/null', shellCmd], {
|
|
432
|
+
cwd: spawnCwd,
|
|
433
|
+
env: shellEnv,
|
|
434
|
+
stdio: ['pipe', 'pipe', 'pipe'],
|
|
435
|
+
});
|
|
436
|
+
}
|
|
437
|
+
else if (process.platform === 'linux') {
|
|
438
|
+
// Linux fallback: 'script' with -c flag
|
|
439
|
+
shell = spawn('script', ['-qc', shellCmd, '/dev/null'], {
|
|
440
|
+
cwd: spawnCwd,
|
|
441
|
+
env: shellEnv,
|
|
442
|
+
stdio: ['pipe', 'pipe', 'pipe'],
|
|
443
|
+
});
|
|
444
|
+
}
|
|
445
|
+
else {
|
|
446
|
+
// Windows / other: raw spawn (limited interactivity)
|
|
447
|
+
shell = spawn(shellCmd, [], {
|
|
448
|
+
cwd: spawnCwd,
|
|
449
|
+
env: shellEnv,
|
|
450
|
+
stdio: ['pipe', 'pipe', 'pipe'],
|
|
451
|
+
});
|
|
452
|
+
}
|
|
453
|
+
}
|
|
454
|
+
catch (scriptErr) {
|
|
455
|
+
console.warn(` [Terminal] script fallback failed: ${scriptErr.message} — trying raw spawn`);
|
|
456
|
+
}
|
|
433
457
|
}
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
|
|
458
|
+
// Last resort: raw spawn with no PTY
|
|
459
|
+
if (!ptyProcess && !shell) {
|
|
460
|
+
try {
|
|
461
|
+
shell = spawn(shellCmd, [], {
|
|
462
|
+
cwd: spawnCwd,
|
|
463
|
+
env: shellEnv,
|
|
464
|
+
stdio: ['pipe', 'pipe', 'pipe'],
|
|
465
|
+
});
|
|
466
|
+
}
|
|
467
|
+
catch (rawErr) {
|
|
468
|
+
console.error(` [Terminal] All spawn methods failed: ${rawErr.message}`);
|
|
469
|
+
res.statusCode = 500;
|
|
470
|
+
this.json(res, { success: false, error: `Failed to spawn terminal: ${rawErr.message}` });
|
|
471
|
+
return;
|
|
472
|
+
}
|
|
441
473
|
}
|
|
442
474
|
const session = {
|
|
443
475
|
id: sessionId,
|
package/package.json
CHANGED