genbox 1.0.101 → 1.0.103
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/api.js +24 -0
- package/dist/commands/backup.js +410 -0
- package/dist/commands/backups.js +193 -0
- package/dist/commands/create.js +254 -4
- package/dist/commands/extend.js +11 -2
- package/dist/commands/init.js +158 -22
- package/dist/commands/status.js +74 -8
- package/dist/index.js +5 -1
- package/package.json +1 -1
package/dist/commands/status.js
CHANGED
|
@@ -400,19 +400,81 @@ exports.statusCommand = new commander_1.Command('status')
|
|
|
400
400
|
}
|
|
401
401
|
// Show Docker containers status
|
|
402
402
|
const dockerStatus = sshExec(target.ipAddress, keyPath, 'docker ps --format "{{.Names}}\\t{{.Status}}" 2>/dev/null', 10);
|
|
403
|
-
|
|
403
|
+
const hasDockerServices = dockerStatus && dockerStatus.trim();
|
|
404
|
+
if (hasDockerServices) {
|
|
404
405
|
console.log(chalk_1.default.blue('[INFO] === Docker Services ==='));
|
|
405
406
|
console.log('NAMES\tSTATUS');
|
|
406
407
|
console.log(dockerStatus);
|
|
407
408
|
console.log('');
|
|
408
409
|
}
|
|
409
|
-
// Show PM2 processes
|
|
410
|
+
// Show PM2 processes (only if there are actual apps)
|
|
410
411
|
const pm2Status = sshExec(target.ipAddress, keyPath, 'source ~/.nvm/nvm.sh 2>/dev/null; pm2 list 2>/dev/null || echo ""', 10);
|
|
411
|
-
|
|
412
|
+
// Check for actual PM2 apps - empty tables don't contain status keywords
|
|
413
|
+
const hasPm2Apps = pm2Status && pm2Status.trim() &&
|
|
414
|
+
!pm2Status.includes('No process') &&
|
|
415
|
+
(pm2Status.includes('online') || pm2Status.includes('stopped') ||
|
|
416
|
+
pm2Status.includes('errored') || pm2Status.includes('launching'));
|
|
417
|
+
if (hasPm2Apps) {
|
|
412
418
|
console.log(chalk_1.default.blue('[INFO] === PM2 Services ==='));
|
|
413
419
|
console.log(pm2Status);
|
|
414
420
|
console.log('');
|
|
415
421
|
}
|
|
422
|
+
// Warn if no services are running and try to diagnose why
|
|
423
|
+
if (!hasDockerServices && !hasPm2Apps) {
|
|
424
|
+
console.log(chalk_1.default.yellow('[WARN] No Docker or PM2 services are running!'));
|
|
425
|
+
// First, check for saved errors from setup (fast - just read a file)
|
|
426
|
+
const savedErrors = sshExec(target.ipAddress, keyPath, 'cat ~/.genbox-errors 2>/dev/null || echo ""', 10);
|
|
427
|
+
if (savedErrors && savedErrors.trim()) {
|
|
428
|
+
// Found saved errors from setup
|
|
429
|
+
console.log(chalk_1.default.red('[ERROR] Build failed during setup:'));
|
|
430
|
+
console.log(savedErrors);
|
|
431
|
+
console.log('');
|
|
432
|
+
console.log(chalk_1.default.dim(' Fix the error and run: cd ~/goodpass/api && docker compose up -d'));
|
|
433
|
+
}
|
|
434
|
+
else {
|
|
435
|
+
// No saved errors - try docker compose build to diagnose (uses cache, fails fast)
|
|
436
|
+
console.log(chalk_1.default.dim(' Checking for build errors...'));
|
|
437
|
+
console.log('');
|
|
438
|
+
const buildResult = sshExec(target.ipAddress, keyPath, 'cd ~/goodpass/api 2>/dev/null && docker compose build 2>&1 | tail -60 || echo "No compose file found"', 120);
|
|
439
|
+
if (buildResult && buildResult.trim()) {
|
|
440
|
+
// Check for common error patterns
|
|
441
|
+
if (buildResult.includes('ERROR') || buildResult.includes('TS2') ||
|
|
442
|
+
buildResult.includes('failed') || buildResult.includes('ELIFECYCLE') ||
|
|
443
|
+
buildResult.includes('exit code') || buildResult.includes('did not complete successfully')) {
|
|
444
|
+
console.log(chalk_1.default.red('[ERROR] Docker build failed:'));
|
|
445
|
+
// Extract just the error portion
|
|
446
|
+
const lines = buildResult.split('\n');
|
|
447
|
+
const errorLines = lines.filter(line => line.includes('ERROR') || line.includes('TS2') || line.includes('TS1') ||
|
|
448
|
+
line.includes('failed') || line.includes('exit code') ||
|
|
449
|
+
line.includes('>') || line.includes('^') ||
|
|
450
|
+
line.match(/^\s*\d+\s*\|/) // Source code lines with line numbers
|
|
451
|
+
).slice(-20);
|
|
452
|
+
if (errorLines.length > 0) {
|
|
453
|
+
console.log(errorLines.join('\n'));
|
|
454
|
+
}
|
|
455
|
+
else {
|
|
456
|
+
// Show last 25 lines if no specific error pattern found
|
|
457
|
+
console.log(lines.slice(-25).join('\n'));
|
|
458
|
+
}
|
|
459
|
+
console.log('');
|
|
460
|
+
console.log(chalk_1.default.dim(' Fix the error and run: cd ~/goodpass/api && docker compose up -d'));
|
|
461
|
+
}
|
|
462
|
+
else if (buildResult.includes('Built') || buildResult.includes('FINISHED')) {
|
|
463
|
+
// Build succeeded, services just need to start
|
|
464
|
+
console.log(chalk_1.default.dim(' Build OK. Start services with: cd ~/goodpass/api && docker compose up -d'));
|
|
465
|
+
}
|
|
466
|
+
else {
|
|
467
|
+
console.log(chalk_1.default.dim(buildResult));
|
|
468
|
+
console.log('');
|
|
469
|
+
console.log(chalk_1.default.dim(' Try: cd ~/goodpass/api && docker compose up -d'));
|
|
470
|
+
}
|
|
471
|
+
}
|
|
472
|
+
else {
|
|
473
|
+
console.log(chalk_1.default.dim(' Try: cd ~/goodpass/api && docker compose up -d'));
|
|
474
|
+
}
|
|
475
|
+
}
|
|
476
|
+
console.log('');
|
|
477
|
+
}
|
|
416
478
|
// Show URLs if available
|
|
417
479
|
if (target.urls && Object.keys(target.urls).length > 0) {
|
|
418
480
|
console.log(chalk_1.default.blue('[INFO] === Service URLs ==='));
|
|
@@ -786,13 +848,17 @@ exports.statusCommand = new commander_1.Command('status')
|
|
|
786
848
|
console.log(chalk_1.default.dim(pkgError));
|
|
787
849
|
}
|
|
788
850
|
console.log('');
|
|
789
|
-
// Show PM2 processes
|
|
790
|
-
|
|
791
|
-
const
|
|
792
|
-
|
|
851
|
+
// Show PM2 processes (only if there are actual apps)
|
|
852
|
+
const pm2List = sshExec(target.ipAddress, keyPath, "source ~/.nvm/nvm.sh 2>/dev/null; pm2 list 2>/dev/null || echo ''", 10);
|
|
853
|
+
const hasPm2Apps = pm2List && pm2List.trim() &&
|
|
854
|
+
!pm2List.includes('No process') &&
|
|
855
|
+
(pm2List.includes('online') || pm2List.includes('stopped') ||
|
|
856
|
+
pm2List.includes('errored') || pm2List.includes('launching'));
|
|
857
|
+
if (hasPm2Apps) {
|
|
858
|
+
console.log(chalk_1.default.blue('[INFO] === Running Services (PM2) ==='));
|
|
793
859
|
console.log(pm2List);
|
|
860
|
+
console.log('');
|
|
794
861
|
}
|
|
795
|
-
console.log('');
|
|
796
862
|
// Show URLs if available
|
|
797
863
|
if (target.urls && Object.keys(target.urls).length > 0) {
|
|
798
864
|
console.log(chalk_1.default.blue('[INFO] === Service URLs ==='));
|
package/dist/index.js
CHANGED
|
@@ -33,6 +33,8 @@ const rebuild_1 = require("./commands/rebuild");
|
|
|
33
33
|
const extend_1 = require("./commands/extend");
|
|
34
34
|
const cleanup_ssh_1 = require("./commands/cleanup-ssh");
|
|
35
35
|
const restart_1 = require("./commands/restart");
|
|
36
|
+
const backup_1 = require("./commands/backup");
|
|
37
|
+
const backups_1 = require("./commands/backups");
|
|
36
38
|
program
|
|
37
39
|
.addCommand(init_1.initCommand)
|
|
38
40
|
.addCommand(create_1.createCommand)
|
|
@@ -58,5 +60,7 @@ program
|
|
|
58
60
|
.addCommand(rebuild_1.rebuildCommand)
|
|
59
61
|
.addCommand(extend_1.extendCommand)
|
|
60
62
|
.addCommand(cleanup_ssh_1.cleanupSshCommand)
|
|
61
|
-
.addCommand(restart_1.restartCommand)
|
|
63
|
+
.addCommand(restart_1.restartCommand)
|
|
64
|
+
.addCommand(backup_1.backupCommand)
|
|
65
|
+
.addCommand(backups_1.backupsCommand);
|
|
62
66
|
program.parse(process.argv);
|