Skip to content

Commit e63a888

Browse files
author
Manus AI
committed
feat: Auto-clone Fleetbase repository if not present
The install-fleetbase command now automatically clones the Fleetbase repository into the target directory if docker-compose.yml is not found. This improves the user experience by eliminating the need to manually clone the repository before running the install command. Changes: - Automatically detects if Fleetbase files are missing - Clones repository using 'git clone' if needed - Creates target directory if it doesn't exist - Provides clear feedback during the cloning process - Gracefully handles clone failures with helpful error messages
1 parent 7d9233f commit e63a888

1 file changed

Lines changed: 22 additions & 11 deletions

File tree

index.js

Lines changed: 22 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -881,18 +881,29 @@ async function installFleetbaseCommand(options) {
881881
console.log(` HTTPS: ${useHttps}`);
882882

883883
// Check if directory exists and has Fleetbase files
884-
if (!await fs.pathExists(directory)) {
885-
console.error(`\n✖ Directory does not exist: ${directory}`);
886-
console.log('\nℹ️ Please clone the Fleetbase repository first:');
887-
console.log(' git clone https://github.com/fleetbase/fleetbase.git');
888-
process.exit(1);
889-
}
890-
891884
const dockerComposePath = path.join(directory, 'docker-compose.yml');
892-
if (!await fs.pathExists(dockerComposePath)) {
893-
console.error(`\n✖ docker-compose.yml not found in ${directory}`);
894-
console.log('\nℹ️ Please ensure you are in the Fleetbase root directory.');
895-
process.exit(1);
885+
const needsClone = !await fs.pathExists(dockerComposePath);
886+
887+
if (needsClone) {
888+
console.log('\n⏳ Fleetbase repository not found, cloning...');
889+
890+
// Ensure parent directory exists
891+
await fs.ensureDir(directory);
892+
893+
// Clone the repository
894+
const { execSync } = require('child_process');
895+
try {
896+
execSync('git clone https://github.com/fleetbase/fleetbase.git .', {
897+
cwd: directory,
898+
stdio: 'inherit'
899+
});
900+
console.log('✔ Repository cloned successfully');
901+
} catch (error) {
902+
console.error('\n✖ Failed to clone repository:', error.message);
903+
console.log('\nℹ️ You can manually clone with:');
904+
console.log(' git clone https://github.com/fleetbase/fleetbase.git');
905+
process.exit(1);
906+
}
896907
}
897908

898909
// Generate APP_KEY

0 commit comments

Comments
 (0)