genbox 1.0.57 → 1.0.58
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/rebuild.js +46 -0
- package/package.json +1 -1
package/dist/commands/rebuild.js
CHANGED
|
@@ -278,6 +278,26 @@ function buildRebuildPayload(resolved, config, publicKey, privateKey, configLoad
|
|
|
278
278
|
gitToken: envVars.GIT_TOKEN,
|
|
279
279
|
};
|
|
280
280
|
}
|
|
281
|
+
/**
|
|
282
|
+
* Validate git configuration and warn about missing credentials
|
|
283
|
+
*/
|
|
284
|
+
function validateGitCredentials(repos, gitToken, privateKey) {
|
|
285
|
+
const warnings = [];
|
|
286
|
+
const errors = [];
|
|
287
|
+
for (const repo of repos) {
|
|
288
|
+
const isHttps = repo.url.startsWith('https://');
|
|
289
|
+
const isSsh = repo.url.startsWith('git@') || repo.url.includes('ssh://');
|
|
290
|
+
const isPrivateRepo = repo.url.includes('github.com') && !repo.url.includes('/public/');
|
|
291
|
+
if (isHttps && !gitToken && isPrivateRepo) {
|
|
292
|
+
warnings.push(`Repository '${repo.name}' uses HTTPS URL but GIT_TOKEN is not set.`);
|
|
293
|
+
warnings.push(` Add GIT_TOKEN=<your-github-token> to .env.genbox for private repos.`);
|
|
294
|
+
}
|
|
295
|
+
if (isSsh && !privateKey) {
|
|
296
|
+
warnings.push(`Repository '${repo.name}' uses SSH URL but no SSH key was injected.`);
|
|
297
|
+
}
|
|
298
|
+
}
|
|
299
|
+
return { warnings, errors };
|
|
300
|
+
}
|
|
281
301
|
/**
|
|
282
302
|
* Generate setup script
|
|
283
303
|
*/
|
|
@@ -709,6 +729,32 @@ exports.rebuildCommand = new commander_1.Command('rebuild')
|
|
|
709
729
|
}
|
|
710
730
|
}
|
|
711
731
|
}
|
|
732
|
+
// Validate git credentials before rebuilding
|
|
733
|
+
const envVarsForValidation = configLoader.loadEnvVars(process.cwd());
|
|
734
|
+
const gitValidation = validateGitCredentials(resolved.repos.map(r => ({ url: r.url, name: r.name })), envVarsForValidation.GIT_TOKEN, privateKeyContent);
|
|
735
|
+
if (gitValidation.warnings.length > 0) {
|
|
736
|
+
console.log('');
|
|
737
|
+
console.log(chalk_1.default.yellow('⚠ Git Authentication Warnings:'));
|
|
738
|
+
for (const warning of gitValidation.warnings) {
|
|
739
|
+
console.log(chalk_1.default.yellow(` ${warning}`));
|
|
740
|
+
}
|
|
741
|
+
console.log('');
|
|
742
|
+
if (!options.yes) {
|
|
743
|
+
const proceed = await prompts.confirm({
|
|
744
|
+
message: 'Git clone may fail without credentials. Continue anyway?',
|
|
745
|
+
default: false,
|
|
746
|
+
});
|
|
747
|
+
if (!proceed) {
|
|
748
|
+
console.log(chalk_1.default.dim('Cancelled. Add GIT_TOKEN to .env.genbox and try again.'));
|
|
749
|
+
return;
|
|
750
|
+
}
|
|
751
|
+
}
|
|
752
|
+
else {
|
|
753
|
+
console.log(chalk_1.default.red('Error: Missing git credentials with --yes flag'));
|
|
754
|
+
console.log(chalk_1.default.dim('Add GIT_TOKEN=<your-github-token> to .env.genbox'));
|
|
755
|
+
return;
|
|
756
|
+
}
|
|
757
|
+
}
|
|
712
758
|
// Build payload
|
|
713
759
|
const payload = buildRebuildPayload(resolved, config, publicKey, privateKeyContent, configLoader);
|
|
714
760
|
// Add database info to payload if we have a snapshot
|