genbox 1.0.49 → 1.0.51
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 +44 -22
- package/package.json +1 -1
package/dist/commands/init.js
CHANGED
|
@@ -875,9 +875,14 @@ async function setupProfiles(detected, environments) {
|
|
|
875
875
|
value: name,
|
|
876
876
|
}));
|
|
877
877
|
const profilesToEdit = await prompts.checkbox({
|
|
878
|
-
message: 'Select profiles to edit:',
|
|
878
|
+
message: 'Select profiles to edit (space to select, enter to confirm):',
|
|
879
879
|
choices: profileChoices,
|
|
880
|
+
required: true,
|
|
880
881
|
});
|
|
882
|
+
if (profilesToEdit.length === 0) {
|
|
883
|
+
console.log(chalk_1.default.dim('No profiles selected for editing.'));
|
|
884
|
+
return profiles;
|
|
885
|
+
}
|
|
881
886
|
for (const profileName of profilesToEdit) {
|
|
882
887
|
profiles[profileName] = await editSingleProfile(profileName, profiles[profileName], detected, environments);
|
|
883
888
|
}
|
|
@@ -963,6 +968,20 @@ async function editSingleProfile(name, profile, detected, environments) {
|
|
|
963
968
|
console.log(chalk_1.default.green(`✓ Updated profile: ${name}`));
|
|
964
969
|
return result;
|
|
965
970
|
}
|
|
971
|
+
/**
|
|
972
|
+
* Calculate recommended server size based on apps + infrastructure count
|
|
973
|
+
* 1-2: small, 3-5: medium, 6-9: large, 10+: xl
|
|
974
|
+
*/
|
|
975
|
+
function calculateSize(appCount, infraCount = 0) {
|
|
976
|
+
const total = appCount + infraCount;
|
|
977
|
+
if (total <= 2)
|
|
978
|
+
return 'small';
|
|
979
|
+
if (total <= 5)
|
|
980
|
+
return 'medium';
|
|
981
|
+
if (total <= 9)
|
|
982
|
+
return 'large';
|
|
983
|
+
return 'xl';
|
|
984
|
+
}
|
|
966
985
|
/**
|
|
967
986
|
* Generate default profiles based on detected apps and environments
|
|
968
987
|
*/
|
|
@@ -971,45 +990,48 @@ function generateDefaultProfiles(detected, environments) {
|
|
|
971
990
|
const frontendApps = Object.entries(detected.apps).filter(([, app]) => app.type === 'frontend');
|
|
972
991
|
const backendApps = Object.entries(detected.apps).filter(([, app]) => app.type === 'backend' || app.type === 'gateway');
|
|
973
992
|
const allRunnableApps = Object.entries(detected.apps).filter(([, app]) => app.type !== 'library');
|
|
993
|
+
const infraCount = detected.infrastructure?.length || 0;
|
|
974
994
|
const envNames = Object.keys(environments || {});
|
|
975
995
|
const remoteEnv = envNames.includes('staging') ? 'staging' :
|
|
976
996
|
envNames.includes('production') ? 'production' :
|
|
977
997
|
envNames[0];
|
|
978
|
-
// Quick UI profiles for frontends
|
|
998
|
+
// Quick UI profiles for frontends (no local infra needed when connecting to remote)
|
|
979
999
|
if (remoteEnv) {
|
|
980
1000
|
for (const [name] of frontendApps.slice(0, 2)) {
|
|
981
1001
|
profiles[`${name}-quick`] = {
|
|
982
1002
|
description: `${name} only, connected to ${remoteEnv}`,
|
|
983
|
-
size:
|
|
1003
|
+
size: calculateSize(1, 0),
|
|
984
1004
|
apps: [name],
|
|
985
1005
|
default_connection: remoteEnv,
|
|
986
1006
|
};
|
|
987
1007
|
}
|
|
988
1008
|
}
|
|
989
|
-
// Full local development
|
|
990
|
-
if (frontendApps.length >
|
|
991
|
-
const [frontendName]
|
|
992
|
-
|
|
993
|
-
|
|
994
|
-
|
|
995
|
-
|
|
996
|
-
|
|
997
|
-
|
|
1009
|
+
// Full local development - only create if multiple frontends exist (otherwise full-stack covers it)
|
|
1010
|
+
if (frontendApps.length > 1 && backendApps.length > 0) {
|
|
1011
|
+
for (const [frontendName] of frontendApps.slice(0, 2)) {
|
|
1012
|
+
const appCount = 1 + backendApps.length;
|
|
1013
|
+
profiles[`${frontendName}-full`] = {
|
|
1014
|
+
description: `${frontendName} + local backend` + (remoteEnv ? ' + DB copy' : ''),
|
|
1015
|
+
size: calculateSize(appCount, infraCount),
|
|
1016
|
+
apps: [frontendName, ...backendApps.map(([n]) => n)],
|
|
1017
|
+
database: remoteEnv ? { mode: 'copy', source: remoteEnv } : { mode: 'local' },
|
|
1018
|
+
};
|
|
1019
|
+
}
|
|
998
1020
|
}
|
|
999
|
-
// Backend development
|
|
1021
|
+
// Backend development (includes local infra like database)
|
|
1000
1022
|
for (const [name] of backendApps.slice(0, 2)) {
|
|
1001
1023
|
profiles[`${name}-dev`] = {
|
|
1002
1024
|
description: `${name} with local infrastructure`,
|
|
1003
|
-
size:
|
|
1025
|
+
size: calculateSize(1, infraCount),
|
|
1004
1026
|
apps: [name],
|
|
1005
1027
|
database: { mode: 'local' },
|
|
1006
1028
|
};
|
|
1007
1029
|
}
|
|
1008
|
-
// Full stack
|
|
1030
|
+
// Full stack - includes all runnable apps + infra
|
|
1009
1031
|
if (allRunnableApps.length > 1) {
|
|
1010
1032
|
profiles['full-stack'] = {
|
|
1011
1033
|
description: 'Everything local' + (remoteEnv ? ' with DB copy' : ''),
|
|
1012
|
-
size:
|
|
1034
|
+
size: calculateSize(allRunnableApps.length, infraCount),
|
|
1013
1035
|
apps: allRunnableApps.map(([n]) => n),
|
|
1014
1036
|
database: remoteEnv ? { mode: 'copy', source: remoteEnv } : { mode: 'local' },
|
|
1015
1037
|
};
|
|
@@ -1551,14 +1573,14 @@ exports.initCommand = new commander_1.Command('init')
|
|
|
1551
1573
|
let detected;
|
|
1552
1574
|
const existingDetected = loadDetectedConfig(rootDir);
|
|
1553
1575
|
if (existingDetected && !nonInteractive) {
|
|
1554
|
-
console.log(chalk_1.default.dim(`Found
|
|
1555
|
-
const
|
|
1556
|
-
message: '
|
|
1557
|
-
default:
|
|
1576
|
+
console.log(chalk_1.default.dim(`Found cached project scan from ${existingDetected._meta.generated_at}`));
|
|
1577
|
+
const rescan = await prompts.confirm({
|
|
1578
|
+
message: 'Rescan the project?',
|
|
1579
|
+
default: false,
|
|
1558
1580
|
});
|
|
1559
|
-
if (
|
|
1581
|
+
if (!rescan) {
|
|
1560
1582
|
detected = existingDetected;
|
|
1561
|
-
console.log(chalk_1.default.dim('Using
|
|
1583
|
+
console.log(chalk_1.default.dim('Using cached scan results.'));
|
|
1562
1584
|
}
|
|
1563
1585
|
else {
|
|
1564
1586
|
const spinner = (0, ora_1.default)('Scanning project...').start();
|