Skip to content

Commit 999503e

Browse files
committed
Merge branch 'v11.0.0' into sbosio/reconcile-util-functions
2 parents 52969f0 + 1254896 commit 999503e

17 files changed

Lines changed: 545 additions & 407 deletions

File tree

package-lock.json

Lines changed: 33 additions & 4 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

packages/cli/src/commands/addons/create.ts

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,13 @@
1-
21
import {color} from '@heroku/heroku-cli-util'
32
import {Command, flags} from '@heroku-cli/command'
3+
import * as Heroku from '@heroku-cli/schema'
44
import {Args, ux} from '@oclif/core'
55
import tsheredoc from 'tsheredoc'
66

77
import createAddon from '../../lib/addons/create_addon.js'
8+
import * as util from '../../lib/addons/util.js'
89
import notify from '../../lib/notify.js'
10+
911
const heredoc = tsheredoc.default
1012

1113
function parseConfig(args: string[]) {
@@ -46,9 +48,9 @@ export default class Create extends Command {
4648
}
4749

4850
static description = heredoc`
49-
Create a new add-on resource.
51+
Create a new add-on resource.
5052
51-
In order to add additional config items, please place them at the end of the command after a double-dash (--).
53+
In order to add additional config items, please place them at the end of the command after a double-dash (--).
5254
`
5355

5456
static examples = [
@@ -76,15 +78,13 @@ export default class Create extends Command {
7678

7779
static strict = false
7880

79-
static topic = 'addons'
80-
8181
public async run(): Promise<void> {
8282
this.allowArbitraryFlags = true
8383
const {args, flags, ...restParse} = await this.parse(Create)
8484
const {app, as, confirm, name, wait} = flags
8585
const servicePlan = args['service:plan']
86-
const argv = (restParse.argv as string[])
8786
// oclif duplicates specified args in argv
87+
const argv = (restParse.argv as string[])
8888
.filter(arg => arg !== servicePlan)
8989

9090
if (restParse.nonExistentFlags && restParse.nonExistentFlags.length > 0) {
@@ -93,9 +93,9 @@ export default class Create extends Command {
9393
}
9494

9595
const config = parseConfig(argv)
96-
let addon
96+
let addon: Heroku.AddOn
9797
try {
98-
addon = await createAddon(this.heroku, app, servicePlan, confirm, wait, {config, name, as})
98+
addon = await createAddon(this.heroku, app, servicePlan, confirm, wait, {as, config, name})
9999
if (wait) {
100100
Create.notifier(`heroku addons:create ${addon.name}`, 'Add-on successfully provisioned')
101101
}
@@ -109,6 +109,6 @@ export default class Create extends Command {
109109

110110
await this.config.runHook('recache', {addon, app, type: 'addon'})
111111
// eslint-disable-next-line no-unsafe-optional-chaining
112-
ux.stdout(`Use ${color.code('heroku addons:docs ' + addon?.addon_service?.name || '')} to view documentation`)
112+
ux.stdout(`Run ${color.code('heroku addons:docs ' + addon?.addon_service?.name || '')} to view documentation.`)
113113
}
114114
}

packages/cli/src/commands/addons/destroy.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,10 @@
1-
import {color} from '@heroku/heroku-cli-util'
1+
import {color, utils} from '@heroku/heroku-cli-util'
22
import {Command, flags} from '@heroku-cli/command'
33
import * as Heroku from '@heroku-cli/schema'
44
import {Args} from '@oclif/core'
55
import _ from 'lodash'
66

77
import destroyAddon from '../../lib/addons/destroy_addon.js'
8-
import {resolveAddon} from '../../lib/addons/resolve.js'
98
import ConfirmCommand from '../../lib/confirmCommand.js'
109
import notify from '../../lib/notify.js'
1110

@@ -36,8 +35,9 @@ export default class Destroy extends Command {
3635
const {argv, flags} = await this.parse(Destroy)
3736
const {app, confirm, wait} = flags
3837
const force = flags.force || process.env.HEROKU_FORCE === '1'
38+
const addonResolver = new utils.AddonResolver(this.heroku)
3939

40-
const addons = await Promise.all(argv.map((name: string) => resolveAddon(this.heroku, app, name as string)))
40+
const addons = await Promise.all(argv.map((name: string) => addonResolver.resolve(name as string, app)))
4141
for (const addon of addons) {
4242
// prevent deletion of add-on when context.app is set but the addon is attached to a different app
4343
const addonApp = addon.app?.name
Lines changed: 11 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
1-
/*
21
import {Command, flags} from '@heroku-cli/command'
3-
import {Args} from '@oclif/core'
2+
import {Args, ux} from '@oclif/core'
43
import {utils} from '@heroku/heroku-cli-util'
5-
import {nls} from '../../nls'
4+
5+
import {nls} from '../../nls.js'
66

77
const query = `
88
WITH constants AS (
@@ -68,16 +68,16 @@ ORDER BY raw_waste DESC, bloat DESC
6868
`
6969

7070
export default class Bloat extends Command {
71-
static topic = 'pg';
72-
static description = 'show table and index bloat in your database ordered by most wasteful';
71+
static description = 'show table and index bloat in your database ordered by most wasteful'
72+
static topic = 'pg'
73+
static args = {
74+
database: Args.string({description: `${nls('pg:database:arg:description')} ${nls('pg:database:arg:description:default:suffix')}`}),
75+
}
76+
7377
static flags = {
7478
app: flags.app({required: true}),
7579
remote: flags.remote(),
76-
};
77-
78-
static args = {
79-
database: Args.string({description: `${nls('pg:database:arg:description')} ${nls('pg:database:arg:description:default:suffix')}`}),
80-
};
80+
}
8181

8282
public async run(): Promise<void> {
8383
const {flags, args} = await this.parse(Bloat)
@@ -86,7 +86,6 @@ export default class Bloat extends Command {
8686
const db = await dbResolver.getDatabase(app, args.database)
8787
const psqlService = new utils.pg.PsqlService(db)
8888
const output = await psqlService.execQuery(query)
89-
process.stdout.write(output)
89+
ux.stdout(output)
9090
}
9191
}
92-
*/

0 commit comments

Comments
 (0)