genbox 1.0.69 → 1.0.71
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 +18 -1
- 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
|
@@ -811,6 +811,15 @@ exports.rebuildCommand = new commander_1.Command('rebuild')
|
|
|
811
811
|
}
|
|
812
812
|
// Get git token from env
|
|
813
813
|
const envVars = configLoader.loadEnvVars(process.cwd());
|
|
814
|
+
// Notify API that rebuild is starting (set status to provisioning)
|
|
815
|
+
try {
|
|
816
|
+
await (0, api_1.fetchApi)(`/genboxes/${genbox._id}/soft-rebuild-started`, {
|
|
817
|
+
method: 'POST',
|
|
818
|
+
});
|
|
819
|
+
}
|
|
820
|
+
catch {
|
|
821
|
+
// Silently ignore - status update is not critical
|
|
822
|
+
}
|
|
814
823
|
// Run soft rebuild
|
|
815
824
|
console.log('');
|
|
816
825
|
console.log(chalk_1.default.blue(`=== Starting ${options.hard ? 'Hard' : 'Soft'} Rebuild ===`));
|
|
@@ -858,7 +867,14 @@ exports.rebuildCommand = new commander_1.Command('rebuild')
|
|
|
858
867
|
console.log(chalk_1.default.red(`✗ Rebuild failed: ${rebuildResult.error}`));
|
|
859
868
|
console.log(chalk_1.default.dim(` Failed during: ${currentStep}`));
|
|
860
869
|
}
|
|
861
|
-
//
|
|
870
|
+
// Build services map to update on API
|
|
871
|
+
const services = {};
|
|
872
|
+
for (const app of resolved.apps) {
|
|
873
|
+
if (app.port) {
|
|
874
|
+
services[app.name] = { port: app.port, healthcheck: app.healthcheck };
|
|
875
|
+
}
|
|
876
|
+
}
|
|
877
|
+
// Notify API about the rebuild (for tracking and status update)
|
|
862
878
|
try {
|
|
863
879
|
await (0, api_1.fetchApi)(`/genboxes/${genbox._id}/soft-rebuild-completed`, {
|
|
864
880
|
method: 'POST',
|
|
@@ -867,6 +883,7 @@ exports.rebuildCommand = new commander_1.Command('rebuild')
|
|
|
867
883
|
branch: resolved.repos[0]?.branch,
|
|
868
884
|
newBranch: resolved.repos[0]?.newBranch,
|
|
869
885
|
sourceBranch: resolved.repos[0]?.sourceBranch,
|
|
886
|
+
services, // Update services map
|
|
870
887
|
}),
|
|
871
888
|
});
|
|
872
889
|
}
|
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 {
|