Skip to content

Commit

Permalink
feat: introduce prompt for github repo visibility choice (#32)
Browse files Browse the repository at this point in the history
  • Loading branch information
maneike authored Nov 18, 2024
1 parent 47fce3b commit 31bda76
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 5 deletions.
1 change: 0 additions & 1 deletion packages/core/installMachine/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -327,7 +327,6 @@ const createInstallMachine = (initialContext: InstallMachineContext) => {
try {
await initializeRepository({
projectName: input.stateData.options.name,
visibility: 'private',
stateData: input.stateData,
});
input.stateData.stepsCompleted.initializeRepository = true;
Expand Down
5 changes: 2 additions & 3 deletions packages/core/installMachine/installSteps/github/install.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ import { InstallMachineContext } from '../../../types';

interface ProjectRepositoryOptions {
projectName: string;
visibility: 'public' | 'private';
stateData: InstallMachineContext['stateData'];
}

Expand Down Expand Up @@ -63,7 +62,7 @@ const ensureGitHubAuthentication = async () => {
};

export const initializeRepository = async (options: ProjectRepositoryOptions) => {
const { projectName, visibility, stateData } = options;
const { projectName, stateData } = options;

await checkGitHubCLI();
await ensureGitHubAuthentication();
Expand All @@ -76,7 +75,7 @@ export const initializeRepository = async (options: ProjectRepositoryOptions) =>
}

// Check if the repository exists and create it
await createGitHubRepository(projectName, visibility, username, stateData);
await createGitHubRepository(projectName, username, stateData);

await setupGitRepository();
};
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,6 @@ export const fetchGitHubUsername = async (): Promise<string | null> => {

export const createGitHubRepository = async (
projectName: string,
repositoryVisibility: 'public' | 'private',
username: string,
stateData: InstallMachineContext['stateData'],
) => {
Expand Down Expand Up @@ -104,6 +103,16 @@ export const createGitHubRepository = async (

await logger.withSpinner('github', `Creating repository: ${repoName}...`, async (spinner) => {
try {
spinner.stop();
const { repositoryVisibility } = await inquirer.prompt([
{
type: 'list',
name: 'repositoryVisibility',
message: 'Choose the repository visibility:',
choices: ['public', 'private'],
default: 'public',
},
]);
const visibilityFlag = repositoryVisibility === 'public' ? '--public' : '--private';
const command = `gh repo create ${repoName} ${visibilityFlag}`;
await execAsync(command);
Expand Down

0 comments on commit 31bda76

Please sign in to comment.