Skip to content

Commit fd4c8c0

Browse files
authored
refactor: apply lint formatting to git through pg commands (#3666)
* refactor: apply lint formatting to git through pg commands Applies automated lint formatting to command files in preparation for migration to eslint 9. Changes include import ordering, class property ordering, object property ordering, and whitespace cleanup. Affected command groups: git, keys, labs, local, logs, maintenance, mcp, members, notifications, orgs, data, pg. * Switch back to if else.
1 parent 7e84cbf commit fd4c8c0

112 files changed

Lines changed: 751 additions & 1058 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

src/commands/data/maintenances/history.ts

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
import {color, hux, utils} from '@heroku/heroku-cli-util'
21
import {flags as Flags} from '@heroku-cli/command'
2+
import {color, hux, utils} from '@heroku/heroku-cli-util'
33
import {Args, ux} from '@oclif/core'
44

55
import BaseCommand from '../../../lib/data/base-command.js'
@@ -10,16 +10,13 @@ export default class DataMaintenancesHistory extends BaseCommand {
1010
static args = {
1111
addon: Args.string({description: 'data addon', required: true}),
1212
}
13-
1413
static description = 'show details of the most recent maintenances for an addon'
15-
1614
static examples = [
1715
'$ heroku data:maintenances:history postgresql-sinuous-92834',
1816
'$ heroku data:maintenances:history postgresql-sinuous-92834 --num 10',
1917
'$ heroku data:maintenances:history postgresql-sinuous-92834 --json',
2018
'$ heroku data:maintenances:history DATABASE --app production-app',
2119
]
22-
2320
static flags = {
2421
app: Flags.app(),
2522
columns: Flags.string({description: 'only show provided columns (comma-separated)'}),
@@ -57,6 +54,7 @@ export default class DataMaintenancesHistory extends BaseCommand {
5754
return
5855
}
5956

57+
/* eslint-disable perfectionist/sort-objects */
6058
const allTableColumns = {
6159
scheduled_for: {
6260
get: (row: Maintenance) => row && row.scheduled_for ? row.scheduled_for : '-',
@@ -85,7 +83,7 @@ export default class DataMaintenancesHistory extends BaseCommand {
8583
header: 'Window',
8684
},
8785
}
88-
86+
/* eslint-enable perfectionist/sort-objects */
8987
const tableColumns = constructTableColumns(allTableColumns, Object.keys(allTableColumns), false, flags.columns)
9088

9189
if (flags.json) {

src/commands/data/maintenances/index.ts

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,12 +9,10 @@ import {constructSortFilterTableOptions, constructTableColumns, outputCSV} from
99

1010
export default class DataMaintenancesIndex extends BaseCommand {
1111
static description = 'list maintenances for an app\'s data addons'
12-
1312
static examples = [
1413
'$ heroku data:maintenances --app production-app',
1514
'$ heroku data:maintenances --app production-app --json',
1615
]
17-
1816
static flags = {
1917
app: Flags.app({
2018
description: 'app to list addon maintenances for',

src/commands/data/maintenances/info.ts

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
1-
import {color, hux, utils} from '@heroku/heroku-cli-util'
21
import {flags} from '@heroku-cli/command'
2+
import {color, hux, utils} from '@heroku/heroku-cli-util'
33
import {Args, ux} from '@oclif/core'
44

55
import BaseCommand from '../../../lib/data/base-command.js'
6-
import {lazyModuleLoader} from '../../../lib/lazy-module-loader.js'
76
import {Maintenance} from '../../../lib/data/types.js'
7+
import {lazyModuleLoader} from '../../../lib/lazy-module-loader.js'
88

99
interface StyledMaintenance extends Maintenance {
1010
[key: string]: any;
@@ -18,15 +18,12 @@ export default class DataMaintenancesInfo extends BaseCommand {
1818
required: true,
1919
}),
2020
}
21-
2221
static description = 'display details of the most recent maintenance for an addon'
23-
2422
static examples = [
2523
'$ heroku data:maintenances:info postgresql-sinuous-83720',
2624
'$ heroku data:maintenances:info postgresql-sinuous-83720 --json',
2725
'$ heroku data:maintenances:info DATABASE --app test-app',
2826
]
29-
3027
static flags = {
3128
app: flags.app({description: 'app to list addon maintenances for'}),
3229
json: flags.boolean({char: 'j', description: 'output result in json'}),
@@ -57,14 +54,14 @@ export default class DataMaintenancesInfo extends BaseCommand {
5754
}
5855

5956
['app', 'addon'].forEach((key: string) => {
60-
Object.keys(styledMaintenance[key]).forEach(childKey => {
57+
for (const childKey of Object.keys(styledMaintenance[key])) {
6158
const composedKey = `${key}_${childKey}`
6259
const childValue = styledMaintenance[key][childKey]
6360

6461
if (childValue !== undefined) {
6562
styledMaintenance[composedKey] = childValue
6663
}
67-
})
64+
}
6865

6966
// after flattening the child keys from `key`, we can remove `key`
7067
// off the of object so that it isn't shown

src/commands/data/maintenances/run.ts

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,16 +13,13 @@ export default class DataMaintenancesRun extends BaseCommand {
1313
required: true,
1414
}),
1515
}
16-
1716
static description = 'triggers a scheduled maintenance for a data add-on'
18-
1917
static examples = [
2018
'$ heroku data:maintenances:run postgresql-sinuous-92834',
2119
'$ heroku data:maintenances:run postgresql-sinuous-92834 --confirm production-app',
2220
'$ heroku data:maintenances:run postgresql-sinuous-92834 --wait',
2321
'$ heroku data:maintenances:run DATABASE --app production-app',
2422
]
25-
2623
static flags = {
2724
app: Flags.app({description: 'app to run addon maintenance for'}),
2825
confirm: Flags.string({

src/commands/data/maintenances/schedule.ts

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

66
import BaseCommand from '../../../lib/data/base-command.js'
7-
import {lazyModuleLoader} from '../../../lib/lazy-module-loader.js'
87
import {Maintenance} from '../../../lib/data/types.js'
8+
import {lazyModuleLoader} from '../../../lib/lazy-module-loader.js'
99

1010
export default class DataMaintenancesSchedule extends BaseCommand {
1111
static args = {
@@ -14,17 +14,14 @@ export default class DataMaintenancesSchedule extends BaseCommand {
1414
required: true,
1515
}),
1616
}
17-
1817
static description = 'schedule or re-schedule maintenance for an add-on'
19-
2018
static examples = [
2119
'$ heroku data:maintenances:schedule postgresql-sinuous-83910',
2220
'$ heroku data:maintenances:schedule postgresql-sinuous-83910 --weeks 3',
2321
'$ heroku data:maintenances:schedule postgresql-sinuous-83910 --weeks -2',
2422
'$ heroku data:maintenances:schedule postgresql-sinuous-83910 --week 2020-02-23',
2523
'$ heroku data:maintenances:schedule HEROKU_POSTGRESQL_RED --app test-app',
2624
]
27-
2825
static flags = {
2926
app: flags.app(),
3027
remote: flags.remote(),

src/commands/data/maintenances/wait.ts

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
import {color, utils} from '@heroku/heroku-cli-util'
21
import {flags as Flags} from '@heroku-cli/command'
2+
import {color, utils} from '@heroku/heroku-cli-util'
33
import {Args, ux} from '@oclif/core'
44

55
import BaseCommand from '../../../lib/data/base-command.js'
@@ -10,14 +10,11 @@ export default class DataMaintenancesWait extends BaseCommand {
1010
static args = {
1111
addon: Args.string({description: 'data addon', required: true}),
1212
}
13-
1413
static description = 'blocks until the maintenance process has completed'
15-
1614
static examples = [
1715
'$ heroku data:maintenances:wait postgresql-sinuous-83720',
1816
'$ heroku data:maintenances:wait DATABASE --app production-app',
1917
]
20-
2118
static flags = {
2219
app: Flags.app(),
2320
remote: Flags.remote(),

src/commands/data/maintenances/window/index.ts

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
import {color, hux, utils} from '@heroku/heroku-cli-util'
21
import {flags as Flags} from '@heroku-cli/command'
2+
import {color, hux, utils} from '@heroku/heroku-cli-util'
33
import {Args, ux} from '@oclif/core'
44

55
import BaseCommand from '../../../../lib/data/base-command.js'
@@ -12,14 +12,11 @@ export default class DataMaintenancesWindow extends BaseCommand {
1212
required: true,
1313
}),
1414
}
15-
1615
static description = 'describe the maintenance window on an add-on'
17-
1816
static examples = [
1917
'$ heroku data:maintenances:window postgresql-sinuous-92834',
2018
'$ heroku data:maintenances:window DATABASE --app production-app',
2119
]
22-
2320
static flags = {
2421
app: Flags.app({description: 'app to show addon maintenance window for'}),
2522
json: Flags.boolean({char: 'j', description: 'output result in json'}),

src/commands/data/maintenances/window/update.ts

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
import {color, hux, utils} from '@heroku/heroku-cli-util'
21
import {flags as Flags} from '@heroku-cli/command'
2+
import {color, hux, utils} from '@heroku/heroku-cli-util'
33
import {Args, ux} from '@oclif/core'
44

55
import BaseCommand from '../../../../lib/data/base-command.js'
@@ -20,15 +20,12 @@ export default class DataMaintenancesWindowUpdate extends BaseCommand {
2020
required: true,
2121
}),
2222
}
23-
2423
static description = 'update maintenance window on an add-on'
25-
2624
static examples = [
2725
'$ heroku data:maintenances:window postgresql-sinuous-92834 sunday 13:30',
2826
'$ heroku data:maintenances:window postgresql-sinuous-92834 sunday 1:30PM',
2927
'$ heroku data:maintenances:window DATABASE sunday 1:30PM --app production-app',
3028
]
31-
3229
static flags = {
3330
app: Flags.app({description: 'app to update addon maintenance window for'}),
3431
json: Flags.boolean({char: 'j', description: 'output result in json'}),
@@ -41,9 +38,7 @@ export default class DataMaintenancesWindowUpdate extends BaseCommand {
4138
const addon = await addonResolver.resolve(args.addon, flags.app)
4239

4340
const combinedWindowLabel = `${args.day_of_week} ${args.time_of_day}`
44-
ux.action.start(
45-
`Setting maintenance window for ${color.addon(addon.name!)} to ${combinedWindowLabel}`,
46-
)
41+
ux.action.start(`Setting maintenance window for ${color.addon(addon.name!)} to ${combinedWindowLabel}`)
4742

4843
const {body: result} = await this.dataApi.post<Window>(
4944
`/data/maintenances/v1/${addon.id}/window`,

src/commands/data/pg/attachments/create.ts

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

@@ -16,9 +16,7 @@ export default class DataPgAttachmentsCreate extends BaseCommand {
1616
required: true,
1717
}),
1818
}
19-
2019
static description = 'attach an existing Postgres Advanced database to an app'
21-
2220
static flags = {
2321
app: Flags.app({required: true}),
2422
as: Flags.string({description: 'name for Postgres database attachment'}),
@@ -56,10 +54,8 @@ export default class DataPgAttachmentsCreate extends BaseCommand {
5654
if (!utils.pg.isAdvancedDatabase(addon)) {
5755
const cmd = `heroku addons:attach ${addon.name} -a ${app}${as ? ` --as ${as}` : ''}`
5856
+ `${credential ? ` --credential ${credential}` : ''}`
59-
ux.error(
60-
'You can only use this command on Advanced-tier databases.\n'
61-
+ `Use ${color.code(cmd)} instead.`,
62-
)
57+
ux.error('You can only use this command on Advanced-tier databases.\n'
58+
+ `Use ${color.code(cmd)} instead.`)
6359
}
6460

6561
const createAttachment = async (confirmed?: string): Promise<Required<Heroku.AddOnAttachment>> => {
@@ -99,25 +95,23 @@ export default class DataPgAttachmentsCreate extends BaseCommand {
9995
}
10096

10197
if (credential) {
102-
const {body: credentialConfig} = await this.heroku.get<Required<Heroku.AddOnConfig>[]>(
103-
`/addons/${addon.name}/config/role:${encodeURIComponent(credential)}`,
104-
)
98+
const {body: credentialConfig} = await this.heroku.get<Required<Heroku.AddOnConfig>[]>(`/addons/${addon.name}/config/role:${encodeURIComponent(credential)}`)
10599
if (credentialConfig.length === 0) {
106-
ux.error(heredoc`
100+
ux.error(
101+
heredoc`
107102
The credential ${color.name(credential)} doesn't exist on the database ${color.datastore(addon.name)}.
108103
Use ${color.code(`heroku data:pg:credentials ${addon.name} -a ${app}`)} to list the credentials on the database.`,
109-
{exit: 1},
104+
{exit: 1},
110105
)
111106
}
112107
} else if (pool) {
113-
const {body: poolConfig} = await this.heroku.get<Required<Heroku.AddOnConfig>[]>(
114-
`/addons/${addon.name}/config/pool:${encodeURIComponent(pool)}`,
115-
)
108+
const {body: poolConfig} = await this.heroku.get<Required<Heroku.AddOnConfig>[]>(`/addons/${addon.name}/config/pool:${encodeURIComponent(pool)}`)
116109
if (poolConfig.length === 0) {
117-
ux.error(heredoc`
110+
ux.error(
111+
heredoc`
118112
The pool ${color.name(pool)} doesn't exist on the database ${color.datastore(addon.name)}.
119113
Use ${color.code(`heroku data:pg:info ${addon.name} -a ${app}`)} to list the pools on the database.`,
120-
{exit: 1},
114+
{exit: 1},
121115
)
122116
}
123117
}

src/commands/data/pg/attachments/destroy.ts

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

66
import BaseCommand from '../../../../lib/data/base-command.js'
@@ -12,9 +12,7 @@ export default class DataPgAttachmentsDestroy extends BaseCommand {
1212
required: true,
1313
}),
1414
}
15-
1615
static description = 'detach an existing database attachment from an app'
17-
1816
static flags = {
1917
app: Flags.app({required: true}),
2018
confirm: Flags.string({char: 'c', description: 'pass in the app name to skip confirmation prompts'}),
@@ -25,25 +23,19 @@ export default class DataPgAttachmentsDestroy extends BaseCommand {
2523
const {args, flags} = await this.parse(DataPgAttachmentsDestroy)
2624
const {attachment_name: attachmentName} = args
2725
const {app, confirm} = flags
28-
const {body: attachment} = await this.heroku.get<Required<Heroku.AddOnAttachment>>(
29-
`/apps/${app}/addon-attachments/${attachmentName}`,
30-
)
26+
const {body: attachment} = await this.heroku.get<Required<Heroku.AddOnAttachment>>(`/apps/${app}/addon-attachments/${attachmentName}`)
3127
const addonResolver = new utils.AddonResolver(this.heroku)
3228
const addon = await addonResolver.resolve(attachment.addon.name, undefined, utils.pg.addonService())
3329

3430
if (!utils.pg.isAdvancedDatabase(addon)) {
35-
ux.error(
36-
'You can only use this command on Advanced-tier databases.\n'
37-
+ `Use ${color.code(`heroku addons:detach ${attachmentName} -a ${app}`)} instead.`,
38-
)
31+
ux.error('You can only use this command on Advanced-tier databases.\n'
32+
+ `Use ${color.code(`heroku addons:detach ${attachmentName} -a ${app}`)} instead.`)
3933
}
4034

4135
await hux.confirmCommand({comparison: app, confirmation: confirm})
4236

4337
try {
44-
ux.action.start(
45-
`Detaching ${color.attachment(attachmentName)} on ${color.datastore(addon.name)} from ${color.app(app)}`,
46-
)
38+
ux.action.start(`Detaching ${color.attachment(attachmentName)} on ${color.datastore(addon.name)} from ${color.app(app)}`)
4739
await this.heroku.delete(`/addon-attachments/${attachment.id}`)
4840
ux.action.stop()
4941
} catch (error) {

0 commit comments

Comments
 (0)