Skip to content

Commit

Permalink
feat: add gh cli installation prompt (#24)
Browse files Browse the repository at this point in the history
  • Loading branch information
maneike authored Nov 8, 2024
1 parent bc5ea43 commit 87b1c34
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,6 @@ export const installGitHubCLI = (): boolean => {
logWithColoredPrefix('github', 'Installing GitHub CLI...');
try {
execSync(installCommand, { stdio: 'inherit' });
logWithColoredPrefix('github', 'GitHub CLI installed successfully.');
return true;
} catch (error) {
console.error('Failed to install GitHub CLI.');
Expand Down
23 changes: 19 additions & 4 deletions packages/core/installMachine/installSteps/github/install.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import inquirer from 'inquirer';
import { logWithColoredPrefix } from '../../../utils/logWithColoredPrefix';
import { installGitHubCLI, isGitHubCLIInstalled } from './ghInstaller';
import {
Expand All @@ -14,13 +15,27 @@ interface ProjectRepositoryOptions {
}

// Helper function to check if GitHub CLI is installed
const checkGitHubCLI = () => {
const checkGitHubCLI = async () => {
logWithColoredPrefix('github', 'Checking if GitHub CLI is installed...');
if (!isGitHubCLIInstalled()) {
logWithColoredPrefix('github', 'GitHub CLI is not installed.');
const installed = installGitHubCLI();
if (!installed) {
console.error('GitHub CLI installation failed. Exiting...');
const { shouldInstallGitHubCLI } = await inquirer.prompt([
{
type: 'confirm',
name: 'shouldInstallGitHubCLI',
message: 'Would you like us to install GitHub CLI?',
default: true,
},
]);

if (shouldInstallGitHubCLI) {
const installed = installGitHubCLI();
if (!installed) {
console.error('GitHub CLI installation failed. Exiting...');
process.exit(1);
}
} else {
console.error('GitHub CLI is not installed. Please install GitHub CLI and try again.');
process.exit(1);
}
}
Expand Down

0 comments on commit 87b1c34

Please sign in to comment.