Skip to content

Commit b2ddd5e

Browse files
committed
use message returned from request
1 parent 90aa38a commit b2ddd5e

3 files changed

Lines changed: 12 additions & 4 deletions

File tree

packages/cli/src/commands/pg/upgrade/prepare.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,8 @@ import {Args, ux} from '@oclif/core'
44
import heredoc from 'tsheredoc'
55
import {getAddon} from '../../../lib/pg/fetcher'
66
import pgHost from '../../../lib/pg/host'
7-
import {legacyEssentialPlan, essentialNumPlan} from '../../../lib/pg/util'
8-
import {PgDatabase} from '../../../lib/pg/types'
7+
import {legacyEssentialPlan, essentialNumPlan, formatResponseWithCommands} from '../../../lib/pg/util'
8+
import {PgDatabase, PgUpgradeResponse} from '../../../lib/pg/types'
99
import confirmCommand from '../../../lib/confirmCommand'
1010
import {nls} from '../../../nls'
1111

@@ -54,7 +54,7 @@ export default class Upgrade extends Command {
5454

5555
const data = {version}
5656
ux.action.start(`Preparing upgrade on ${color.addon(db.name)}`)
57-
await this.heroku.post(`/client/v11/databases/${db.id}/upgrade/prepare`, {hostname: pgHost(), body: data})
58-
ux.action.stop(`done\nYour database is scheduled for upgrade during your next available maintenance window.\nRun ${color.cmd('heroku pg:upgrade:wait')} to track its status.\nYou can also run this upgrade manually before the maintenance window with ${color.cmd('heroku pg:upgrade:run')}. You can only run the upgrade after it's fully prepared, which can take up to a day.`)
57+
const {body : response} = await this.heroku.post<PgUpgradeResponse>(`/client/v11/databases/${db.id}/upgrade/prepare`, {hostname: pgHost(), body: {}})
58+
ux.action.stop('done\n' + formatResponseWithCommands(response.message))
5959
}
6060
}

packages/cli/src/lib/pg/types.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -167,6 +167,10 @@ export type PgDatabaseTenant = {
167167

168168
export type PgDatabase = PgDatabaseService & PgDatabaseTenant
169169

170+
export type PgUpgradeResponse = {
171+
message: string
172+
}
173+
170174
export type AddOnWithPlan = Required<Heroku.AddOnAttachment['addon']> & {plan: Required<Heroku.AddOn['plan']>}
171175
export type AddOnAttachmentWithConfigVarsAndPlan = Required<Heroku.AddOnAttachment> & {
172176
config_vars: Heroku.AddOn['config_vars']

packages/cli/src/lib/pg/util.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,10 @@ export function getConfigVarNameFromAttachment(attachment: Required<AddOnAttachm
4040
return getConfigVarName(configVars)
4141
}
4242

43+
export function formatResponseWithCommands(response: string): string {
44+
return response.replace(/`(.*?)`/g, (_, word) => color.cmd(word))
45+
}
46+
4347
export function presentCredentialAttachments(app: string, credAttachments: Required<AddOnAttachment>[], credentials: CredentialsInfo, cred: string) {
4448
const isForeignApp = (attOrAddon: Required<AddOnAttachment>) => attOrAddon.app.name === app ? 0 : 1
4549
const comparators = [

0 commit comments

Comments
 (0)