Feat: Add support for creating git prototypes to cli. #12
Feat: Add support for creating git prototypes to cli. #12
Conversation
| 'repo', | ||
| 'create', | ||
| options.repoName, | ||
| '--public', |
There was a problem hiding this comment.
Do we want to provide an option to make a private project?
There was a problem hiding this comment.
We could have a default...and maybe the default is public, but I would think maybe the opposite actually.
| } | ||
|
|
||
| try { | ||
| await execa('git', ['add', '.'], { cwd, stdio: 'inherit' }); |
There was a problem hiding this comment.
Is there no selective adding ability? What if they only want to push a particular file or directory within the project?
| ]); | ||
|
|
||
| const commitMessage = (message as string).trim(); | ||
| if (!commitMessage) { |
There was a problem hiding this comment.
It seems this condition won't even be reached due to the validate function for the commit message above requiring a string, right? I think it can be removed, but maybe I'm misunderstanding.
| if (err && typeof err === 'object' && 'exitCode' in err) { | ||
| const code = (err as { exitCode?: number }).exitCode; | ||
| if (code === 128) { | ||
| console.error( | ||
| '\n❌ Pull failed. You may need to set a remote (e.g. "git remote add origin <url>") or run "gh auth login".\n', | ||
| ); | ||
| } else { | ||
| console.error('\n❌ Pull failed. See the output above for details.\n'); | ||
| } | ||
| } else { | ||
| console.error('\n❌ An error occurred:'); | ||
| if (err instanceof Error) console.error(` ${err.message}\n`); | ||
| else console.error(` ${String(err)}\n`); | ||
| } | ||
| throw err; |
There was a problem hiding this comment.
Seems this is duplicated in the save.ts file...instead of repeating the code here, maybe make a helper called something like handleGitError?
| console.log('\n✅ Changes saved and pushed to GitHub successfully.\n'); | ||
| } catch (err) { | ||
| if (err && typeof err === 'object' && 'exitCode' in err) { | ||
| const code = (err as { exitCode?: number }).exitCode; |
There was a problem hiding this comment.
I think you can remove this casting if you update the condition above to something like if (err instanceof ExecaError) instead of if (err && typeof err === 'object' && 'exitCode' in err)
| { | ||
| type: 'confirm', | ||
| name: 'useSSH', | ||
| message: 'Use SSH URL for cloning?', |
There was a problem hiding this comment.
Will non-devs understand this question and how to answer it?
src/cli.ts
Outdated
| }, | ||
| ]); | ||
|
|
||
| if (createGitHub) { |
There was a problem hiding this comment.
Maybe the create logic could be separated into its own function to make the CLI more readable here, and could be unit tested separately.
Closes issue #7 :