Skip to content

Commit 040fa28

Browse files
committed
Merge branch 'v11.0.0' into sbosio/reconcile-util-functions
2 parents bb269db + e52168b commit 040fa28

7 files changed

Lines changed: 38 additions & 211 deletions

File tree

packages/cli/src/oldCommands/pg/unfollow.ts renamed to packages/cli/src/commands/pg/unfollow.ts

Lines changed: 11 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,18 @@
1-
/*
2-
import color from '@heroku-cli/color'
31
import {Command, flags} from '@heroku-cli/command'
42
import {Args, ux} from '@oclif/core'
53
import * as Heroku from '@heroku-cli/schema'
6-
import {utils} from '@heroku/heroku-cli-util'
7-
import {databaseNameFromUrl} from '../../lib/pg/util'
8-
import confirmCommand from '../../lib/confirmCommand'
9-
import {PgDatabase} from '../../lib/pg/types'
10-
import heredoc from 'tsheredoc'
11-
import {nls} from '../../nls'
4+
import {utils, color} from '@heroku/heroku-cli-util'
5+
import {databaseNameFromUrl} from '../../lib/pg/util.js'
6+
import ConfirmCommand from '../../lib/confirmCommand.js'
7+
import {PgDatabase} from '../../lib/pg/types.js'
8+
import tsheredoc from 'tsheredoc'
9+
import {nls} from '../../nls.js'
10+
11+
const heredoc = tsheredoc.default
1212

1313
export default class Unfollow extends Command {
14-
static topic = 'pg';
15-
static description = 'stop a replica from following and make it a writeable database';
14+
static topic = 'pg'
15+
static description = 'stop a replica from following and make it a writeable database'
1616
static flags = {
1717
confirm: flags.string({char: 'c'}),
1818
app: flags.app({required: true}),
@@ -33,7 +33,7 @@ export default class Unfollow extends Command {
3333
ux.error(`${color.addon(db.name)} is not a follower`)
3434
const {body: configVars} = await this.heroku.get<Heroku.ConfigVars>(`/apps/${app}/config-vars`)
3535
const origin = databaseNameFromUrl(replica.following as string, configVars)
36-
await confirmCommand(app, confirm, heredoc(`
36+
await new ConfirmCommand().confirm(app, confirm, heredoc(`
3737
Destructive action
3838
${color.addon(db.name)} will become writeable and no longer follow ${origin}. This cannot be undone.
3939
`))
@@ -42,4 +42,3 @@ export default class Unfollow extends Command {
4242
ux.action.stop()
4343
}
4444
}
45-
*/

packages/cli/src/oldCommands/pg/vacuum-stats.ts renamed to packages/cli/src/commands/pg/vacuum-stats.ts

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,14 @@
1-
/*
21
import {Command, flags} from '@heroku-cli/command'
32
import {Args, ux} from '@oclif/core'
43
import {utils} from '@heroku/heroku-cli-util'
5-
import heredoc from 'tsheredoc'
6-
import {nls} from '../../nls'
4+
import tsheredoc from 'tsheredoc'
5+
import {nls} from '../../nls.js'
6+
7+
const heredoc = tsheredoc.default
78

89
export default class VacuumStats extends Command {
9-
static topic = 'pg';
10-
static description = 'show dead rows and whether an automatic vacuum is expected to be triggered';
10+
static topic = 'pg'
11+
static description = 'show dead rows and whether an automatic vacuum is expected to be triggered'
1112
static flags = {
1213
app: flags.app({required: true}),
1314
remote: flags.remote(),
@@ -63,7 +64,6 @@ export default class VacuumStats extends Command {
6364
ORDER BY 1
6465
`)
6566
const output = await psqlService.execQuery(query)
66-
ux.log(output)
67+
ux.stdout(output)
6768
}
6869
}
69-
*/
Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,11 @@
1-
/*
2-
import color from '@heroku-cli/color'
31
import {Command, flags} from '@heroku-cli/command'
42
import {Args, ux} from '@oclif/core'
53
import debug from 'debug'
6-
import {ExtendedAddonAttachment, utils} from '@heroku/heroku-cli-util'
7-
import notify from '../../lib/notify'
8-
import {PgStatus} from '../../lib/pg/types'
4+
import {utils, pg, color} from '@heroku/heroku-cli-util'
5+
import notify from '../../lib/notify.js'
6+
import {PgStatus} from '../../lib/pg/types.js'
97
import {HTTPError} from '@heroku/http-call'
10-
import {nls} from '../../nls'
8+
import {nls} from '../../nls.js'
119

1210
const wait = (ms: number) => new Promise(resolve => {
1311
setTimeout(resolve, ms)
@@ -33,7 +31,7 @@ export default class Wait extends Command {
3331
const dbName = args.database
3432
const pgDebug = debug('pg')
3533

36-
const waitFor = async (db: ExtendedAddonAttachment['addon']) => {
34+
const waitFor = async (db: pg.ExtendedAddonAttachment['addon']) => {
3735
let interval = waitInterval && Number.parseInt(waitInterval, 10)
3836
if (!interval || interval < 0) interval = 5
3937
let status
@@ -79,7 +77,7 @@ export default class Wait extends Command {
7977
}
8078
}
8179

82-
let dbs: ExtendedAddonAttachment['addon'][]
80+
let dbs: pg.ExtendedAddonAttachment['addon'][]
8381
if (dbName) {
8482
const dbResolver = new utils.pg.DatabaseResolver(this.heroku)
8583
const {addon} = await dbResolver.getAttachment(app, dbName)
@@ -94,4 +92,3 @@ export default class Wait extends Command {
9492
}
9593
}
9694
}
97-
*/

packages/cli/src/oldCommands/pg/upgrade.ts

Lines changed: 0 additions & 65 deletions
This file was deleted.

packages/cli/test/unit/commands/pg/unfollow.unit.test.ts

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,10 @@
11
import {stderr} from 'stdout-stderr'
22
import nock from 'nock'
3-
// import Cmd from '../../../../src/commands/pg/unfollow'
3+
import Cmd from '../../../../src/commands/pg/unfollow.js'
44
import runCommand from '../../../helpers/runCommand.js'
55
import expectOutput from '../../../helpers/utils/expectOutput.js'
6-
import heredoc from 'tsheredoc'
76
import * as fixtures from '../../../fixtures/addons/fixtures.js'
87

9-
/*
108
describe('pg:unfollow', function () {
119
const addon = fixtures.addons['dwh-db']
1210
const appName = 'myapp'
@@ -35,11 +33,6 @@ describe('pg:unfollow', function () {
3533
appName,
3634
'DATABASE',
3735
])
38-
expectOutput(stderr.output, heredoc(`
39-
${addon.name} unfollowing...
40-
${addon.name} unfollowing... done
41-
`))
36+
expectOutput(stderr.output, `${addon.name} unfollowing... done`)
4237
})
4338
})
44-
45-
*/

packages/cli/test/unit/commands/pg/upgrade.unit.test.ts

Lines changed: 0 additions & 87 deletions
This file was deleted.

packages/cli/test/unit/commands/pg/wait.unit.test.ts

Lines changed: 12 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,16 @@
1+
import Cmd from '../../../../src/commands/pg/wait.js'
12
import {stdout, stderr} from 'stdout-stderr'
23
import {expect} from 'chai'
34
import nock from 'nock'
4-
import * as proxyquire from 'proxyquire'
5-
import heredoc from 'tsheredoc'
6-
// import {CLIError} from '@oclif/core/lib/errors'
5+
import {Errors} from '@oclif/core'
76
import runCommand from '../../../helpers/runCommand.js'
87
import expectOutput from '../../../helpers/utils/expectOutput.js'
98

109
const all = [
1110
{id: 1, name: 'postgres-1', plan: {name: 'heroku-postgresql:hobby-dev'}},
1211
{id: 2, name: 'postgres-2', plan: {name: 'heroku-postgresql:hobby-dev'}},
1312
]
14-
const fetcher = {
15-
all: () => Promise.resolve(all),
16-
}
1713

18-
// const {default: Cmd} = proxyquire('../../../../src/commands/pg/wait', {
19-
// '../../lib/pg/fetcher': fetcher,
20-
// })
21-
22-
/*
2314
describe('pg:wait', function () {
2415
let pg: nock.Scope
2516
let api: nock.Scope
@@ -30,6 +21,7 @@ describe('pg:wait', function () {
3021
})
3122

3223
afterEach(function () {
24+
api.done()
3325
pg.done()
3426
nock.cleanAll()
3527
})
@@ -50,13 +42,13 @@ describe('pg:wait', function () {
5042
'DATABASE_URL',
5143
])
5244
expect(stdout.output).to.equal('')
53-
expectOutput(stderr.output, heredoc(`
54-
Waiting for database postgres-1... pending
55-
Waiting for database postgres-1... available
56-
`))
45+
expectOutput(stderr.output, 'Waiting for database postgres-1... available')
5746
})
5847

5948
it('waits for all databases to be available', async function () {
49+
api
50+
.get('/apps/myapp/addon-attachments')
51+
.reply(200, all.map(db => ({addon: db})))
6052
pg
6153
.get('/client/v11/databases/1/wait_status').reply(200, {'waiting?': false})
6254
.get('/client/v11/databases/2/wait_status').reply(200, {'waiting?': false})
@@ -70,14 +62,17 @@ describe('pg:wait', function () {
7062
})
7163

7264
it('displays errors', async function () {
65+
api
66+
.get('/apps/myapp/addon-attachments')
67+
.reply(200, [{addon: all[0]}])
7368
pg
7469
.get('/client/v11/databases/1/wait_status').reply(200, {'error?': true, message: 'this is an error message'})
7570

7671
await runCommand(Cmd, [
7772
'--app',
7873
'myapp',
7974
]).catch(error => {
80-
const {message, oclif} = error as CLIError
75+
const {message, oclif} = error as Errors.CLIError
8176
expect(message).to.equal('this is an error message')
8277
expect(oclif.exit).to.equal(1)
8378
})
@@ -99,11 +94,6 @@ describe('pg:wait', function () {
9994
'DATABASE_URL',
10095
])
10196
expect(stdout.output).to.equal('')
102-
expectOutput(stderr.output, heredoc(`
103-
Waiting for database postgres-1... upgrading
104-
Waiting for database postgres-1... available
105-
`))
97+
expectOutput(stderr.output, 'Waiting for database postgres-1... available')
10698
})
10799
})
108-
109-
*/

0 commit comments

Comments
 (0)