genbox 1.0.8 → 1.0.9
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/create.js +8 -0
- package/dist/commands/destroy.js +1 -0
- package/dist/commands/init.js +35 -2
- package/dist/profile-resolver.js +14 -1
- package/package.json +1 -1
package/dist/commands/create.js
CHANGED
|
@@ -233,6 +233,14 @@ function displayResolvedConfig(resolved) {
|
|
|
233
233
|
console.log(chalk_1.default.dim(` deps: ${deps}`));
|
|
234
234
|
}
|
|
235
235
|
}
|
|
236
|
+
if (resolved.repos.length > 0) {
|
|
237
|
+
console.log('');
|
|
238
|
+
console.log(` ${chalk_1.default.bold('Repos:')}`);
|
|
239
|
+
for (const repo of resolved.repos) {
|
|
240
|
+
console.log(` • ${repo.name}: ${repo.url}`);
|
|
241
|
+
console.log(chalk_1.default.dim(` → ${repo.path}`));
|
|
242
|
+
}
|
|
243
|
+
}
|
|
236
244
|
if (resolved.infrastructure.length > 0) {
|
|
237
245
|
console.log('');
|
|
238
246
|
console.log(` ${chalk_1.default.bold('Infrastructure:')}`);
|
package/dist/commands/destroy.js
CHANGED
|
@@ -12,6 +12,7 @@ const api_1 = require("../api");
|
|
|
12
12
|
const genbox_selector_1 = require("../genbox-selector");
|
|
13
13
|
const ssh_config_1 = require("../ssh-config");
|
|
14
14
|
exports.destroyCommand = new commander_1.Command('destroy')
|
|
15
|
+
.alias('delete')
|
|
15
16
|
.description('Destroy a Genbox')
|
|
16
17
|
.argument('[name]', 'Name of the Genbox to destroy (optional - will prompt if not provided)')
|
|
17
18
|
.option('-y, --yes', 'Skip confirmation')
|
package/dist/commands/init.js
CHANGED
|
@@ -153,6 +153,8 @@ exports.initCommand = new commander_1.Command('init')
|
|
|
153
153
|
}
|
|
154
154
|
console.log(chalk_1.default.blue('Initializing Genbox...'));
|
|
155
155
|
console.log('');
|
|
156
|
+
// Track env vars to add to .env.genbox
|
|
157
|
+
const envVarsToAdd = {};
|
|
156
158
|
// Get initial exclusions from CLI options only
|
|
157
159
|
let exclude = [];
|
|
158
160
|
if (options.exclude) {
|
|
@@ -291,6 +293,7 @@ exports.initCommand = new commander_1.Command('init')
|
|
|
291
293
|
});
|
|
292
294
|
if (selectedRepos.length > 0) {
|
|
293
295
|
v3Config.repos = {};
|
|
296
|
+
let hasHttpsRepos = false;
|
|
294
297
|
for (const repoName of selectedRepos) {
|
|
295
298
|
const repo = appGitRepos.find(r => r.appName === repoName);
|
|
296
299
|
v3Config.repos[repo.appName] = {
|
|
@@ -299,6 +302,24 @@ exports.initCommand = new commander_1.Command('init')
|
|
|
299
302
|
branch: repo.branch !== 'main' && repo.branch !== 'master' ? repo.branch : undefined,
|
|
300
303
|
auth: repo.type === 'ssh' ? 'ssh' : 'token',
|
|
301
304
|
};
|
|
305
|
+
if (repo.type === 'https') {
|
|
306
|
+
hasHttpsRepos = true;
|
|
307
|
+
}
|
|
308
|
+
}
|
|
309
|
+
// Prompt for GIT_TOKEN if any HTTPS repos are selected
|
|
310
|
+
if (hasHttpsRepos) {
|
|
311
|
+
console.log('');
|
|
312
|
+
console.log(chalk_1.default.yellow('Private repositories require a GitHub token for cloning.'));
|
|
313
|
+
const gitToken = await prompts.password({
|
|
314
|
+
message: 'GitHub Personal Access Token (leave empty to skip):',
|
|
315
|
+
});
|
|
316
|
+
if (gitToken) {
|
|
317
|
+
envVarsToAdd['GIT_TOKEN'] = gitToken;
|
|
318
|
+
console.log(chalk_1.default.green('✓ GIT_TOKEN will be added to .env.genbox'));
|
|
319
|
+
}
|
|
320
|
+
else {
|
|
321
|
+
console.log(chalk_1.default.dim(' Skipped - add GIT_TOKEN to .env.genbox later if needed'));
|
|
322
|
+
}
|
|
302
323
|
}
|
|
303
324
|
}
|
|
304
325
|
}
|
|
@@ -425,7 +446,7 @@ exports.initCommand = new commander_1.Command('init')
|
|
|
425
446
|
fs_1.default.writeFileSync(configPath, yamlContent);
|
|
426
447
|
console.log(chalk_1.default.green(`\n✔ Configuration saved to ${CONFIG_FILENAME}`));
|
|
427
448
|
// Generate .env.genbox
|
|
428
|
-
await setupEnvFile(projectName, v3Config, nonInteractive, scan, isMultiRepo);
|
|
449
|
+
await setupEnvFile(projectName, v3Config, nonInteractive, scan, isMultiRepo, envVarsToAdd);
|
|
429
450
|
// Show warnings
|
|
430
451
|
if (generated.warnings.length > 0) {
|
|
431
452
|
console.log('');
|
|
@@ -718,7 +739,7 @@ async function setupEnvironments(scan, config, isMultiRepo = false) {
|
|
|
718
739
|
/**
|
|
719
740
|
* Setup .env.genbox file
|
|
720
741
|
*/
|
|
721
|
-
async function setupEnvFile(projectName, config, nonInteractive = false, scan, isMultiRepo = false) {
|
|
742
|
+
async function setupEnvFile(projectName, config, nonInteractive = false, scan, isMultiRepo = false, extraEnvVars = {}) {
|
|
722
743
|
const envPath = path_1.default.join(process.cwd(), ENV_FILENAME);
|
|
723
744
|
if (fs_1.default.existsSync(envPath)) {
|
|
724
745
|
console.log(chalk_1.default.dim(` ${ENV_FILENAME} already exists, skipping...`));
|
|
@@ -829,6 +850,18 @@ async function setupEnvFile(projectName, config, nonInteractive = false, scan, i
|
|
|
829
850
|
}
|
|
830
851
|
}
|
|
831
852
|
}
|
|
853
|
+
// Append extra env vars (like GIT_TOKEN) to the file
|
|
854
|
+
if (Object.keys(extraEnvVars).length > 0 && fs_1.default.existsSync(envPath)) {
|
|
855
|
+
let content = fs_1.default.readFileSync(envPath, 'utf8');
|
|
856
|
+
// Add extra env vars section
|
|
857
|
+
let extraSection = '\n# === Added by genbox init ===\n';
|
|
858
|
+
for (const [key, value] of Object.entries(extraEnvVars)) {
|
|
859
|
+
// Remove any existing commented placeholder
|
|
860
|
+
content = content.replace(new RegExp(`^#\\s*${key}=.*$`, 'gm'), '');
|
|
861
|
+
extraSection += `${key}=${value}\n`;
|
|
862
|
+
}
|
|
863
|
+
fs_1.default.writeFileSync(envPath, content.trim() + '\n' + extraSection);
|
|
864
|
+
}
|
|
832
865
|
// Add to .gitignore
|
|
833
866
|
const gitignorePath = path_1.default.join(process.cwd(), '.gitignore');
|
|
834
867
|
if (fs_1.default.existsSync(gitignorePath)) {
|
package/dist/profile-resolver.js
CHANGED
|
@@ -410,7 +410,7 @@ class ProfileResolver {
|
|
|
410
410
|
const seen = new Set();
|
|
411
411
|
for (const app of apps) {
|
|
412
412
|
const appConfig = config.apps[app.name];
|
|
413
|
-
// Check if app has specific repo
|
|
413
|
+
// Check if app has specific repo field
|
|
414
414
|
if (appConfig?.repo && config.repos?.[appConfig.repo]) {
|
|
415
415
|
const repoConfig = config.repos[appConfig.repo];
|
|
416
416
|
if (!seen.has(repoConfig.url)) {
|
|
@@ -423,6 +423,19 @@ class ProfileResolver {
|
|
|
423
423
|
seen.add(repoConfig.url);
|
|
424
424
|
}
|
|
425
425
|
}
|
|
426
|
+
// Auto-match: if app name matches a repo name, use that repo
|
|
427
|
+
else if (config.repos?.[app.name]) {
|
|
428
|
+
const repoConfig = config.repos[app.name];
|
|
429
|
+
if (!seen.has(repoConfig.url)) {
|
|
430
|
+
repos.push({
|
|
431
|
+
name: app.name,
|
|
432
|
+
url: repoConfig.url,
|
|
433
|
+
path: repoConfig.path,
|
|
434
|
+
branch: repoConfig.branch,
|
|
435
|
+
});
|
|
436
|
+
seen.add(repoConfig.url);
|
|
437
|
+
}
|
|
438
|
+
}
|
|
426
439
|
}
|
|
427
440
|
// If no specific repos, use main project repo
|
|
428
441
|
if (repos.length === 0 && config.repos) {
|