vibex-sh 0.2.2 β 0.2.4
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/index.js +12 -31
- package/package.json +3 -2
package/index.js
CHANGED
|
@@ -399,15 +399,8 @@ async function main() {
|
|
|
399
399
|
console.log(' π‘ Tip: Use -s to send more logs to this session');
|
|
400
400
|
console.log(` Example: echo '{"cpu": 45, "memory": 78}' | npx vibex-sh -s ${sessionSlug}${localFlag}\n`);
|
|
401
401
|
} else {
|
|
402
|
-
// When reusing a session, show minimal info
|
|
403
|
-
|
|
404
|
-
? `${webUrl}/${sessionId}?auth=${authCode}`
|
|
405
|
-
: `${webUrl}/${sessionId}`;
|
|
406
|
-
console.log(` π Sending logs to session: ${sessionId}`);
|
|
407
|
-
if (authCode) {
|
|
408
|
-
console.log(` Auth Code: ${authCode}`);
|
|
409
|
-
}
|
|
410
|
-
console.log(` Dashboard: ${dashboardUrl}\n`);
|
|
402
|
+
// When reusing a session, show minimal info (no auth code)
|
|
403
|
+
console.log(` π Sending logs to session: ${sessionId}\n`);
|
|
411
404
|
}
|
|
412
405
|
|
|
413
406
|
const socket = io(socketUrl, {
|
|
@@ -427,23 +420,21 @@ async function main() {
|
|
|
427
420
|
|
|
428
421
|
// Store auth code received from socket
|
|
429
422
|
let receivedAuthCode = authCode;
|
|
423
|
+
|
|
424
|
+
// Track if this is a new session (not reusing an existing one)
|
|
425
|
+
const isNewSession = !options.sessionId;
|
|
430
426
|
|
|
431
427
|
socket.on('connect', () => {
|
|
432
428
|
isConnected = true;
|
|
433
429
|
console.log(' β Connected to server\n');
|
|
434
|
-
console.error(`[CLI DEBUG] Socket connected, socket.id: ${socket.id}`);
|
|
435
|
-
console.error(`[CLI DEBUG] About to emit join-session for: ${sessionId}`);
|
|
436
430
|
// Rejoin session on reconnect
|
|
437
431
|
socket.emit('join-session', sessionId);
|
|
438
|
-
console.error(`[CLI DEBUG] β
join-session emitted, waiting 100ms before setting hasJoinedSession`);
|
|
439
432
|
// Wait a tiny bit for join-session to be processed
|
|
440
433
|
setTimeout(() => {
|
|
441
434
|
hasJoinedSession = true;
|
|
442
|
-
console.error(`[CLI DEBUG] hasJoinedSession set to true, processing ${logQueue.length} queued logs`);
|
|
443
435
|
// Process any queued logs
|
|
444
436
|
while (logQueue.length > 0) {
|
|
445
437
|
const logData = logQueue.shift();
|
|
446
|
-
console.error(`[CLI DEBUG] Emitting queued cli-emit (connect) for sessionId: ${sessionId}`);
|
|
447
438
|
socket.emit('cli-emit', {
|
|
448
439
|
sessionId,
|
|
449
440
|
...logData,
|
|
@@ -453,15 +444,17 @@ async function main() {
|
|
|
453
444
|
});
|
|
454
445
|
|
|
455
446
|
// Listen for auth code from socket.io (for unclaimed sessions)
|
|
447
|
+
// Only display auth code if this is a new session (not when reusing existing session)
|
|
456
448
|
socket.on('session-auth-code', (data) => {
|
|
457
449
|
if (data.sessionId === sessionId && data.authCode) {
|
|
458
|
-
//
|
|
459
|
-
// This ensures we show it even if we didn't get it from claimSession
|
|
450
|
+
// Update received auth code
|
|
460
451
|
if (!receivedAuthCode || receivedAuthCode !== data.authCode) {
|
|
461
452
|
receivedAuthCode = data.authCode;
|
|
462
|
-
//
|
|
463
|
-
|
|
464
|
-
|
|
453
|
+
// Only display auth code for new sessions, not when reusing existing sessions
|
|
454
|
+
if (isNewSession) {
|
|
455
|
+
console.log(` π Auth Code: ${receivedAuthCode}`);
|
|
456
|
+
console.log(` π Dashboard: ${webUrl}/${sessionId}?auth=${receivedAuthCode}\n`);
|
|
457
|
+
}
|
|
465
458
|
}
|
|
466
459
|
}
|
|
467
460
|
});
|
|
@@ -476,7 +469,6 @@ async function main() {
|
|
|
476
469
|
// Process any queued logs
|
|
477
470
|
while (logQueue.length > 0) {
|
|
478
471
|
const logData = logQueue.shift();
|
|
479
|
-
console.error(`[CLI DEBUG] Emitting queued cli-emit (reconnect) for sessionId: ${sessionId}`);
|
|
480
472
|
socket.emit('cli-emit', {
|
|
481
473
|
sessionId,
|
|
482
474
|
...logData,
|
|
@@ -583,10 +575,8 @@ async function main() {
|
|
|
583
575
|
});
|
|
584
576
|
|
|
585
577
|
rl.on('line', (line) => {
|
|
586
|
-
console.error(`[CLI DEBUG] Received line from stdin: "${line}"`);
|
|
587
578
|
const trimmedLine = line.trim();
|
|
588
579
|
if (!trimmedLine) {
|
|
589
|
-
console.error(`[CLI DEBUG] Line is empty, skipping`);
|
|
590
580
|
return;
|
|
591
581
|
}
|
|
592
582
|
|
|
@@ -598,31 +588,22 @@ async function main() {
|
|
|
598
588
|
payload: parsed,
|
|
599
589
|
timestamp: Date.now(),
|
|
600
590
|
};
|
|
601
|
-
console.error(`[CLI DEBUG] Parsed as JSON log`);
|
|
602
591
|
} catch (e) {
|
|
603
592
|
logData = {
|
|
604
593
|
type: 'text',
|
|
605
594
|
payload: trimmedLine,
|
|
606
595
|
timestamp: Date.now(),
|
|
607
596
|
};
|
|
608
|
-
console.error(`[CLI DEBUG] Parsed as text log`);
|
|
609
597
|
}
|
|
610
598
|
|
|
611
|
-
console.error(`[CLI DEBUG] Connection state - isConnected: ${isConnected}, hasJoinedSession: ${hasJoinedSession}, socket.connected: ${socket?.connected}`);
|
|
612
|
-
|
|
613
599
|
// If connected and joined session, send immediately; otherwise queue it
|
|
614
600
|
if (isConnected && hasJoinedSession && socket.connected) {
|
|
615
|
-
console.error(`[CLI DEBUG] β
Ready to emit - Emitting cli-emit for sessionId: ${sessionId}`);
|
|
616
|
-
console.error(`[CLI DEBUG] Log data:`, JSON.stringify(logData, null, 2));
|
|
617
601
|
socket.emit('cli-emit', {
|
|
618
602
|
sessionId,
|
|
619
603
|
...logData,
|
|
620
604
|
});
|
|
621
|
-
console.error(`[CLI DEBUG] β
cli-emit event emitted successfully`);
|
|
622
605
|
} else {
|
|
623
|
-
console.error(`[CLI DEBUG] βΈοΈ Queueing log - isConnected: ${isConnected}, hasJoinedSession: ${hasJoinedSession}, socket.connected: ${socket?.connected}`);
|
|
624
606
|
logQueue.push(logData);
|
|
625
|
-
console.error(`[CLI DEBUG] Queue now has ${logQueue.length} items`);
|
|
626
607
|
}
|
|
627
608
|
});
|
|
628
609
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "vibex-sh",
|
|
3
|
-
"version": "0.2.
|
|
3
|
+
"version": "0.2.4",
|
|
4
4
|
"description": "Zero-config observability CLI - pipe logs and visualize instantly",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"bin": {
|
|
@@ -27,6 +27,7 @@
|
|
|
27
27
|
"homepage": "https://vibex.sh",
|
|
28
28
|
"dependencies": {
|
|
29
29
|
"commander": "^11.1.0",
|
|
30
|
-
"socket.io-client": "^4.7.2"
|
|
30
|
+
"socket.io-client": "^4.7.2",
|
|
31
|
+
"vibex-sh": "^0.2.3"
|
|
31
32
|
}
|
|
32
33
|
}
|