genbox 1.0.68 → 1.0.70
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/commands/init.js +2 -0
- package/dist/commands/rebuild.js +9 -1
- package/dist/db-utils.js +3 -16
- package/dist/scanner/index.js +38 -0
- package/package.json +1 -1
package/dist/commands/init.js
CHANGED
|
@@ -1241,6 +1241,8 @@ function inferPortSource(app) {
|
|
|
1241
1241
|
return 'package.json scripts.dev (--port flag)';
|
|
1242
1242
|
if (app.scripts?.dev?.includes('PORT='))
|
|
1243
1243
|
return 'package.json scripts.dev (PORT= env)';
|
|
1244
|
+
if (app.framework)
|
|
1245
|
+
return `${app.framework} default`;
|
|
1244
1246
|
return 'framework default';
|
|
1245
1247
|
}
|
|
1246
1248
|
function inferStageReason(script) {
|
package/dist/commands/rebuild.js
CHANGED
|
@@ -858,7 +858,14 @@ exports.rebuildCommand = new commander_1.Command('rebuild')
|
|
|
858
858
|
console.log(chalk_1.default.red(`✗ Rebuild failed: ${rebuildResult.error}`));
|
|
859
859
|
console.log(chalk_1.default.dim(` Failed during: ${currentStep}`));
|
|
860
860
|
}
|
|
861
|
-
//
|
|
861
|
+
// Build services map to update on API
|
|
862
|
+
const services = {};
|
|
863
|
+
for (const app of resolved.apps) {
|
|
864
|
+
if (app.port) {
|
|
865
|
+
services[app.name] = { port: app.port, healthcheck: app.healthcheck };
|
|
866
|
+
}
|
|
867
|
+
}
|
|
868
|
+
// Notify API about the rebuild (for tracking and status update)
|
|
862
869
|
try {
|
|
863
870
|
await (0, api_1.fetchApi)(`/genboxes/${genbox._id}/soft-rebuild-completed`, {
|
|
864
871
|
method: 'POST',
|
|
@@ -867,6 +874,7 @@ exports.rebuildCommand = new commander_1.Command('rebuild')
|
|
|
867
874
|
branch: resolved.repos[0]?.branch,
|
|
868
875
|
newBranch: resolved.repos[0]?.newBranch,
|
|
869
876
|
sourceBranch: resolved.repos[0]?.sourceBranch,
|
|
877
|
+
services, // Update services map
|
|
870
878
|
}),
|
|
871
879
|
});
|
|
872
880
|
}
|
package/dist/db-utils.js
CHANGED
|
@@ -286,7 +286,8 @@ async function runRemoteMongoRestoreDynamic(ipAddress, options = {}) {
|
|
|
286
286
|
return new Promise((resolve) => {
|
|
287
287
|
options.onProgress?.('Detecting MongoDB and restoring database...');
|
|
288
288
|
// The restore command - detects MongoDB port dynamically
|
|
289
|
-
// Note: Uses sed
|
|
289
|
+
// Note: Uses sed instead of grep -P for portability (grep -P not available on Alpine)
|
|
290
|
+
// Note: Skips mongosh check since it's not installed on genboxes - mongorestore will fail if DB not ready
|
|
290
291
|
const restoreCmd = `
|
|
291
292
|
set -e
|
|
292
293
|
|
|
@@ -304,23 +305,9 @@ fi
|
|
|
304
305
|
|
|
305
306
|
echo "MongoDB detected on port: $MONGO_PORT"
|
|
306
307
|
|
|
307
|
-
# Wait for MongoDB to be responsive
|
|
308
|
-
for i in $(seq 1 30); do
|
|
309
|
-
if mongosh --quiet --host localhost --port $MONGO_PORT --eval "db.runCommand({ping:1})" 2>/dev/null; then
|
|
310
|
-
echo "MongoDB is ready"
|
|
311
|
-
break
|
|
312
|
-
fi
|
|
313
|
-
if [ $i -eq 30 ]; then
|
|
314
|
-
echo "ERROR: MongoDB not responding after 30 attempts"
|
|
315
|
-
exit 1
|
|
316
|
-
fi
|
|
317
|
-
echo "Waiting for MongoDB... ($i/30)"
|
|
318
|
-
sleep 2
|
|
319
|
-
done
|
|
320
|
-
|
|
321
308
|
# Restore the database from the uploaded dump
|
|
322
309
|
if [ -f /home/dev/.db-dump.gz ]; then
|
|
323
|
-
echo "Restoring database..."
|
|
310
|
+
echo "Restoring database to localhost:$MONGO_PORT..."
|
|
324
311
|
# The dump is a raw mongodump --archive file (gzipped), not a tar archive
|
|
325
312
|
# Don't use --db flag with --archive as it causes issues
|
|
326
313
|
mongorestore --host localhost:$MONGO_PORT --drop --gzip --archive=/home/dev/.db-dump.gz
|
package/dist/scanner/index.js
CHANGED
|
@@ -64,6 +64,8 @@ class ProjectScanner {
|
|
|
64
64
|
const compose = options.skipCompose ? null : await this.composeParser.parse(root);
|
|
65
65
|
// Layer 5: Discover apps (different approach based on structure)
|
|
66
66
|
const apps = await this.discoverApps(root, structure, compose, options.exclude);
|
|
67
|
+
// Layer 5.5: Apply framework detection to apps (ports, commands, etc.)
|
|
68
|
+
await this.applyFrameworkDefaults(root, apps, frameworks);
|
|
67
69
|
// Layer 6: Analyze environment variables (skip if option set)
|
|
68
70
|
const envAnalysis = options.skipEnv
|
|
69
71
|
? { required: [], optional: [], secrets: [], references: [], sources: [] }
|
|
@@ -341,6 +343,42 @@ class ProjectScanner {
|
|
|
341
343
|
// If it has a start script, it's probably an app
|
|
342
344
|
return hasStartScript ? 'backend' : 'library';
|
|
343
345
|
}
|
|
346
|
+
/**
|
|
347
|
+
* Apply framework defaults (ports, commands) to discovered apps
|
|
348
|
+
*/
|
|
349
|
+
async applyFrameworkDefaults(root, apps, frameworks) {
|
|
350
|
+
const path = require('path');
|
|
351
|
+
for (const app of apps) {
|
|
352
|
+
// Skip if app already has a port (from docker-compose or package.json)
|
|
353
|
+
if (app.port)
|
|
354
|
+
continue;
|
|
355
|
+
// Skip libraries
|
|
356
|
+
if (app.type === 'library')
|
|
357
|
+
continue;
|
|
358
|
+
// Get the app's directory
|
|
359
|
+
const appPath = path.isAbsolute(app.path) ? app.path : path.join(root, app.path);
|
|
360
|
+
// Detect framework for this specific app
|
|
361
|
+
const runtime = { language: 'node' }; // Default to node
|
|
362
|
+
const appFramework = await this.frameworkDetector.detectForApp(appPath, runtime);
|
|
363
|
+
if (appFramework) {
|
|
364
|
+
// Apply framework name if not already set
|
|
365
|
+
if (!app.framework) {
|
|
366
|
+
app.framework = appFramework.name;
|
|
367
|
+
}
|
|
368
|
+
// Apply default port from framework
|
|
369
|
+
if (!app.port && appFramework.defaultPort) {
|
|
370
|
+
app.port = appFramework.defaultPort;
|
|
371
|
+
}
|
|
372
|
+
}
|
|
373
|
+
else if (app.framework) {
|
|
374
|
+
// App has framework name but we need to look up its default port
|
|
375
|
+
const matchingFramework = frameworks.find(f => f.name === app.framework);
|
|
376
|
+
if (matchingFramework?.defaultPort && !app.port) {
|
|
377
|
+
app.port = matchingFramework.defaultPort;
|
|
378
|
+
}
|
|
379
|
+
}
|
|
380
|
+
}
|
|
381
|
+
}
|
|
344
382
|
async detectGit(root) {
|
|
345
383
|
const { execSync } = require('child_process');
|
|
346
384
|
try {
|