Skip to content

Commit

Permalink
better messaging and prompt on github apps add
Browse files Browse the repository at this point in the history
  • Loading branch information
gregsadetsky committed Jan 11, 2025
1 parent 35de37e commit 3f67364
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 1 deletion.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "disco",
"description": "deploy and manage your web projects",
"version": "0.5.33",
"version": "0.5.34",
"author": "The disco Team",
"bin": {
"disco": "./bin/run.js"
Expand Down
22 changes: 22 additions & 0 deletions src/commands/github/apps/add.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import {Command, Flags} from '@oclif/core'
import {getDisco} from '../../../config.js'
import {request} from '../../../auth-request.js'
import open from 'open'
import input from '@inquirer/input'

export default class GithubAppsAdd extends Command {
static description = 'add a Github app'
Expand All @@ -23,6 +24,27 @@ export default class GithubAppsAdd extends Command {
const url = `https://${discoConfig.host}/api/github-apps/create`
const res = await request({method: 'POST', url, discoConfig, body, expectedStatuses: [201]})
const respBody = (await res.json()) as any

// thanks @robsimmons for this excellent suggestion!
this.log('')
this.log("I'm about to open a browser that is going to create a GitHub Application.")
this.log('This app will be named: Disco (some-random-name)')
this.log('')
this.log(
"You'll be able to control which repositories disco has access to through this app. When you 'git push' changes to an authorized repo, disco will automatically trigger a deployment.",
)

this.log('')
const response = await input({message: 'Is it okay to open a browser? y/n', default: 'y'})
if (response === 'n') {
this.log('')
this.log('You need to copy and paste this URL into a browser to finish setup:')
this.log('')
this.log(respBody.pendingApp.url)
return
}

this.log('')
this.log('Opening the URL to install the app:')
this.log('')
this.log(respBody.pendingApp.url)
Expand Down

0 comments on commit 3f67364

Please sign in to comment.