terminal-smart-cli 0.48.0 → 0.49.0
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/ts.js +20 -2
- package/package.json +1 -1
package/bin/ts.js
CHANGED
|
@@ -1373,6 +1373,13 @@ async function cloudCmd(args) {
|
|
|
1373
1373
|
if (sub === 'exec' || sub === 'sh' || sub === 'run') {
|
|
1374
1374
|
const cmd = rest.join(' ').trim();
|
|
1375
1375
|
if (!cmd) { console.log(ui.errLine(en ? 'usage: ts cloud exec "<command>"' : 'uso: ts cloud exec "<comando>"')); return; }
|
|
1376
|
+
// Saída AO VIVO via SSE quando é terminal interativo; fallback pro modo bloqueante.
|
|
1377
|
+
if (process.stdout.isTTY) {
|
|
1378
|
+
try {
|
|
1379
|
+
await sse('/api/cloud/exec-stream', { token, body: { cmd, timeoutMs: 300000 }, timeoutMs: 310000, onEvent: (e) => { if (e.chunk) process.stdout.write(e.chunk); } });
|
|
1380
|
+
return;
|
|
1381
|
+
} catch (e) { if (e.code === 'auth') { console.log(ui.errLine(T.need_login)); return; } }
|
|
1382
|
+
}
|
|
1376
1383
|
const r = await call('exec', { method: 'POST', body: { cmd }, timeoutMs: 300000 });
|
|
1377
1384
|
if (r.out) process.stdout.write(r.out);
|
|
1378
1385
|
if (!r.ok && r.error) console.log(ui.errLine(r.error));
|
|
@@ -1386,8 +1393,19 @@ async function cloudCmd(args) {
|
|
|
1386
1393
|
if (!st.exists) { console.log(C.dim(en ? 'creating box…' : 'criando caixa…')); const up = await call('up', { method: 'POST', body: {}, timeoutMs: 120000 }); if (!up.ok) { console.log(ui.errLine(up.error || 'falha')); if (up.code === 'plan_required') console.log(C.dim('terminalsmart.com.br/planos')); return; } }
|
|
1387
1394
|
console.log(C.dim(en ? 'running ts meta inside the cloud box (may take a while)…' : 'rodando ts meta dentro da caixa (pode demorar)…'));
|
|
1388
1395
|
const safe = goal.replace(/(["\\$`])/g, '\\$1');
|
|
1389
|
-
const
|
|
1390
|
-
|
|
1396
|
+
const cmdMeta = 'cd /workspace && ts meta "' + safe + '" --yes 2>&1';
|
|
1397
|
+
// Build AO VIVO via SSE quando é terminal interativo; fallback bloqueante com tail.
|
|
1398
|
+
let streamed = false;
|
|
1399
|
+
if (process.stdout.isTTY) {
|
|
1400
|
+
try {
|
|
1401
|
+
await sse('/api/cloud/exec-stream', { token, body: { cmd: cmdMeta, timeoutMs: 1800000 }, timeoutMs: 1860000, onEvent: (e) => { if (e.chunk) process.stdout.write(e.chunk); } });
|
|
1402
|
+
streamed = true;
|
|
1403
|
+
} catch (e) { if (e.code === 'auth') { console.log(ui.errLine(T.need_login)); return; } }
|
|
1404
|
+
}
|
|
1405
|
+
if (!streamed) {
|
|
1406
|
+
const r = await call('exec', { method: 'POST', body: { cmd: cmdMeta + ' | tail -50' }, timeoutMs: 1800000 });
|
|
1407
|
+
if (r.out) process.stdout.write(r.out);
|
|
1408
|
+
}
|
|
1391
1409
|
// EXPÕE o app na porta 3000 de forma PERSISTENTE (o startCmd fica salvo e é
|
|
1392
1410
|
// re-executado no resume, então sobrevive ao idle-suspend). npm start senão estático.
|
|
1393
1411
|
const startCmd = 'if [ -f package.json ] && grep -q \'"start"\' package.json; then PORT=3000 npm start; elif [ -f index.html ] || ls *.html >/dev/null 2>&1; then python3 -m http.server 3000; fi';
|