Repository navigation
feat(cli): void github — install + connect a repo for Deploy-on-GitHub
#229
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
13 commits
Select commit
Hold shift + click to select a range
feb1efa
feat(cli): add PlatformClient GitHub methods + types
Brooooooklyn b6da13d
feat(cli): add github subcommand arg parser
Brooooooklyn 9273c57
fix(cli): error on github connect value-flag with no value
Brooooooklyn a01f858
feat(cli): implement void github command (install/installations/connect)
Brooooooklyn 31f557d
fix(cli): correct github connect error mapping to real API strings
Brooooooklyn 7633a0a
feat(cli): wire void github command into dispatcher + help
Brooooooklyn 44b43b4
fix(cli): harden void github connect (empty-flag guard, --project, in…
Brooooooklyn d7f0a7b
fix(cli): auto-pick single selected repo + accurate no-project message
Brooooooklyn 2eaba5f
fix(cli): github connect rejects whitespace-only branch (trim before …
Brooooooklyn 7d8fc59
fix(cli): launch browser via execFile/argv instead of a shell
Brooooooklyn 89365bb
fix(cli): require --repo for all-repo installs in non-interactive con…
Brooooooklyn 3fd474c
test(cli): mock execFile in auth-login (openBrowser no longer uses exec)
Brooooooklyn 880d06f
docs(cli): correct non-interactive github connect flag requirements
Brooooooklyn File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,115 @@ | ||
| import type { SubcommandDef } from './subcommand-prompt.ts'; | ||
|
|
||
| export const githubSubcommands: Array<SubcommandDef> = [ | ||
| { name: 'install', description: 'Open the GitHub App install page in your browser' }, | ||
| { name: 'installations', description: 'List your GitHub App installations' }, | ||
| { | ||
| name: 'connect', | ||
| arg: '[project]', | ||
| description: 'Connect a repository to a project for auto-deploy', | ||
| }, | ||
| ]; | ||
|
|
||
| export type GithubArgs = | ||
| | { subcommand: 'install' } | ||
| | { subcommand: 'installations' } | ||
| | { | ||
| subcommand: 'connect'; | ||
| projectName: string; | ||
| installationId?: string; | ||
| repo?: string; | ||
| branch?: string; | ||
| executor?: 'container' | 'github_actions'; | ||
| }; | ||
|
|
||
| export function parseGithubArgs(args: Array<string>): GithubArgs { | ||
| const [subcommand, ...rest] = args; | ||
|
|
||
| if (subcommand === 'install') { | ||
| if (rest.length > 0) { | ||
| throw new Error(`github: Unexpected argument '${rest[0]}'.`); | ||
| } | ||
| return { subcommand }; | ||
| } | ||
|
|
||
| if (subcommand === 'installations') { | ||
| if (rest.length > 0) { | ||
| throw new Error(`github: Unexpected argument '${rest[0]}'.`); | ||
| } | ||
| return { subcommand }; | ||
| } | ||
|
|
||
| if (subcommand === 'connect') { | ||
| let projectName = ''; | ||
| let installationId: string | undefined; | ||
| let repo: string | undefined; | ||
| let branch: string | undefined; | ||
| let executor: 'container' | 'github_actions' | undefined; | ||
|
|
||
| for (let i = 0; i < rest.length; i++) { | ||
| const arg = rest[i]; | ||
| if (arg === '--installation') { | ||
| if (i + 1 >= rest.length) { | ||
| throw new Error('github: --installation requires a value.'); | ||
| } | ||
| const value = rest[++i]!; | ||
| if (value.trim() === '') { | ||
| throw new Error('github: --installation requires a value.'); | ||
| } | ||
| installationId = value; | ||
| } else if (arg === '--repo') { | ||
| if (i + 1 >= rest.length) { | ||
| throw new Error('github: --repo requires a value.'); | ||
| } | ||
| const value = rest[++i]!; | ||
| if (value.trim() === '') { | ||
| throw new Error('github: --repo requires a value.'); | ||
| } | ||
| repo = value; | ||
| } else if (arg === '--branch') { | ||
| if (i + 1 >= rest.length) { | ||
| throw new Error('github: --branch requires a value.'); | ||
| } | ||
| const value = rest[++i]!; | ||
| if (value.trim() === '') { | ||
| throw new Error('github: --branch requires a value.'); | ||
| } | ||
| branch = value; | ||
| } else if (arg === '--project') { | ||
| if (i + 1 >= rest.length) { | ||
| throw new Error('github: --project requires a value.'); | ||
| } | ||
| const value = rest[++i]!; | ||
| if (value.trim() === '') { | ||
| throw new Error('github: --project requires a value.'); | ||
| } | ||
| if (projectName) { | ||
| throw new Error(`github: Unexpected argument '${value}'.`); | ||
| } | ||
| projectName = value; | ||
| } else if (arg === '--executor') { | ||
| if (i + 1 >= rest.length) { | ||
| throw new Error('github: --executor requires a value.'); | ||
| } | ||
| const value = rest[++i]!; | ||
| if (value.trim() === '') { | ||
| throw new Error('github: --executor requires a value.'); | ||
| } | ||
| if (value !== 'container' && value !== 'github_actions') { | ||
| throw new Error('github: invalid --executor (expected container|github_actions).'); | ||
| } | ||
| executor = value; | ||
| } else if (arg.startsWith('-')) { | ||
| throw new Error(`github: Unexpected argument '${arg}'.`); | ||
| } else if (projectName) { | ||
| throw new Error(`github: Unexpected argument '${arg}'.`); | ||
| } else { | ||
| projectName = arg; | ||
| } | ||
| } | ||
|
|
||
| return { subcommand, projectName, installationId, repo, branch, executor }; | ||
| } | ||
|
|
||
| throw new Error('github: Usage: void github <install|installations|connect>.'); | ||
| } |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.