genbox 1.0.90 → 1.0.91
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 +34 -1
- package/dist/scanner/compose-parser.js +33 -19
- package/package.json +1 -1
package/dist/commands/init.js
CHANGED
|
@@ -331,6 +331,38 @@ async function selectApps(detected) {
|
|
|
331
331
|
}
|
|
332
332
|
return { ...detected, apps: filteredApps };
|
|
333
333
|
}
|
|
334
|
+
/**
|
|
335
|
+
* Interactive infrastructure selection
|
|
336
|
+
*/
|
|
337
|
+
async function selectInfrastructure(detected) {
|
|
338
|
+
if (!detected.infrastructure || detected.infrastructure.length === 0) {
|
|
339
|
+
return detected;
|
|
340
|
+
}
|
|
341
|
+
console.log('');
|
|
342
|
+
console.log(chalk_1.default.blue('=== Detected Infrastructure ==='));
|
|
343
|
+
console.log('');
|
|
344
|
+
for (const infra of detected.infrastructure) {
|
|
345
|
+
const parts = [
|
|
346
|
+
chalk_1.default.cyan(infra.name),
|
|
347
|
+
`(${infra.type})`,
|
|
348
|
+
infra.image ? `[${infra.image}]` : '',
|
|
349
|
+
infra.port ? `port:${infra.port}` : '',
|
|
350
|
+
].filter(Boolean);
|
|
351
|
+
console.log(` ${parts.join(' ')}`);
|
|
352
|
+
}
|
|
353
|
+
console.log('');
|
|
354
|
+
const infraChoices = detected.infrastructure.map(infra => ({
|
|
355
|
+
name: `${infra.name} (${infra.type}${infra.image ? `, ${infra.image}` : ''})`,
|
|
356
|
+
value: infra.name,
|
|
357
|
+
checked: true, // Infrastructure is typically required, so default to selected
|
|
358
|
+
}));
|
|
359
|
+
const selectedInfra = await prompts.checkbox({
|
|
360
|
+
message: 'Select infrastructure to include:',
|
|
361
|
+
choices: infraChoices,
|
|
362
|
+
});
|
|
363
|
+
const filteredInfra = detected.infrastructure.filter(infra => selectedInfra.includes(infra.name));
|
|
364
|
+
return { ...detected, infrastructure: filteredInfra.length > 0 ? filteredInfra : undefined };
|
|
365
|
+
}
|
|
334
366
|
/**
|
|
335
367
|
* Interactive app editing
|
|
336
368
|
*/
|
|
@@ -1832,9 +1864,10 @@ exports.initCommand = new commander_1.Command('init')
|
|
|
1832
1864
|
return;
|
|
1833
1865
|
}
|
|
1834
1866
|
// =========================================
|
|
1835
|
-
// PHASE 2: App Configuration
|
|
1867
|
+
// PHASE 2: App & Infrastructure Configuration
|
|
1836
1868
|
// =========================================
|
|
1837
1869
|
detected = await selectApps(detected);
|
|
1870
|
+
detected = await selectInfrastructure(detected);
|
|
1838
1871
|
if (!options.skipEdit) {
|
|
1839
1872
|
detected = await editApps(detected);
|
|
1840
1873
|
}
|
|
@@ -141,26 +141,40 @@ class ComposeParser {
|
|
|
141
141
|
}
|
|
142
142
|
findComposeFiles(root) {
|
|
143
143
|
const files = [];
|
|
144
|
-
const
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
144
|
+
const seenPaths = new Set();
|
|
145
|
+
const findRecursively = (dir, depth = 0) => {
|
|
146
|
+
// Limit depth to avoid going too deep
|
|
147
|
+
if (depth > 5)
|
|
148
|
+
return;
|
|
149
|
+
try {
|
|
150
|
+
const entries = fs.readdirSync(dir, { withFileTypes: true });
|
|
151
|
+
for (const entry of entries) {
|
|
152
|
+
const fullPath = path.join(dir, entry.name);
|
|
153
|
+
if (entry.isDirectory()) {
|
|
154
|
+
// Skip hidden dirs and node_modules
|
|
155
|
+
if (entry.name.startsWith('.') || entry.name === 'node_modules')
|
|
156
|
+
continue;
|
|
157
|
+
findRecursively(fullPath, depth + 1);
|
|
158
|
+
}
|
|
159
|
+
else if (entry.isFile()) {
|
|
160
|
+
// Check if it's a docker-compose file
|
|
161
|
+
const name = entry.name.toLowerCase();
|
|
162
|
+
if ((name.startsWith('docker-compose') || name.startsWith('compose')) &&
|
|
163
|
+
(name.endsWith('.yml') || name.endsWith('.yaml'))) {
|
|
164
|
+
const realPath = fs.realpathSync(fullPath);
|
|
165
|
+
if (!seenPaths.has(realPath)) {
|
|
166
|
+
seenPaths.add(realPath);
|
|
167
|
+
files.push(fullPath);
|
|
168
|
+
}
|
|
169
|
+
}
|
|
170
|
+
}
|
|
171
|
+
}
|
|
162
172
|
}
|
|
163
|
-
|
|
173
|
+
catch {
|
|
174
|
+
// Ignore errors reading directories
|
|
175
|
+
}
|
|
176
|
+
};
|
|
177
|
+
findRecursively(root);
|
|
164
178
|
return files;
|
|
165
179
|
}
|
|
166
180
|
normalizeService(name, config, root) {
|