Skip to content

Commit

Permalink
Align changes introduced post-migration on CLI commands (#2879)
Browse files Browse the repository at this point in the history
  • Loading branch information
sbosio committed May 13, 2024
1 parent f43713a commit f1d4690
Show file tree
Hide file tree
Showing 14 changed files with 22 additions and 144 deletions.
3 changes: 1 addition & 2 deletions packages/cli/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@
"fs-extra": "7.0.1",
"github-url-to-object": "^4.0.4",
"glob": "^10.3.10",
"got": "^9.6.0",
"got": "^11.8.6",
"http-call": "5.3.0",
"inquirer": "^8.2.6",
"lodash": "^4.17.21",
Expand Down Expand Up @@ -94,7 +94,6 @@
"@types/debug": "^4.1.2",
"@types/fs-extra": "^7.0.0",
"@types/glob": "^7.1.1",
"@types/got": "^9.6.7",
"@types/inquirer": "^8.2.10",
"@types/lodash": "^4.14.123",
"@types/mocha": "^10.0.6",
Expand Down
4 changes: 2 additions & 2 deletions packages/cli/src/commands/pg/links/create.ts
Original file line number Diff line number Diff line change
Expand Up @@ -44,9 +44,9 @@ export default class Create extends Command {
]) as [AddOnAttachmentWithConfigVarsAndPlan, AddOnAttachmentWithConfigVarsAndPlan]

if (essentialPlan(db))
throw new Error('pg:links isn\u2019t available for Essential-tier databases.')
throw new Error('pg:links isn’t available for Essential-tier databases.')
if (essentialPlan(target))
throw new Error('pg:links isn\u2019t available for Essential-tier databases.')
throw new Error('pg:links isn’t available for Essential-tier databases.')

ux.action.start(`Adding link from ${color.yellow(target.name)} to ${color.yellow(db.name)}`)
const {body: link} = await this.heroku.post<Link>(`/client/v11/databases/${db.id}/links`, {
Expand Down
2 changes: 1 addition & 1 deletion packages/cli/src/commands/pg/links/destroy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ export default class Destroy extends Command {
const {database, link} = args
const db = await getAddon(this.heroku, app, database)
if (essentialPlan(db))
throw new Error("pg:links isn't available for Essential-tier databases.")
throw new Error('pg:links isnt available for Essential-tier databases.')
await confirmCommand(app, confirm, heredoc(`
Destructive action
This command will affect the database ${color.yellow(db.name)}
Expand Down
2 changes: 1 addition & 1 deletion packages/cli/src/commands/pg/maintenance/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ export default class Index extends Command {
const {database} = args
const db = await getAddon(this.heroku, app, database)
if (essentialPlan(db))
ux.error("pg:maintenance isn't available for Essential-tier databases.")
ux.error('pg:maintenance isnt available for Essential-tier databases.')
const {body: info} = await this.heroku.get<MaintenanceApiResponse>(`/client/v11/databases/${db.id}/maintenance`, {hostname: pgHost()})
ux.log(info.message)
}
Expand Down
2 changes: 1 addition & 1 deletion packages/cli/src/commands/ps/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,7 @@ function decorateCommandDyno(dyno: DynoExtended) : string {
const since = ago(new Date(dyno.updated_at))
const state = dyno.state === 'up' ? color.green(dyno.state) : color.yellow(dyno.state)

return `${dyno.name}: ${color.green(state)} ${color.dim(since)}`
return `${dyno.name}: ${state} ${color.dim(since)}`
}

function printDynos(dynos: DynoExtended[]) : void {
Expand Down
3 changes: 1 addition & 2 deletions packages/cli/src/commands/releases/output.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import {Command, flags} from '@heroku-cli/command'
import {Args, ux} from '@oclif/core'
import * as Heroku from '@heroku-cli/schema'
import {findByLatestOrId} from '../../lib/releases/releases'
import {stream} from '../../lib/releases/output'

Expand Down Expand Up @@ -29,7 +28,7 @@ export default class Output extends Command {

await stream(streamUrl)
.catch(error => {
if (error.statusCode === 404) {
if (error.statusCode === 404 || error.response?.statusCode === 404) {
ux.warn('Release command not started yet. Please try again in a few seconds.')
return
}
Expand Down
2 changes: 1 addition & 1 deletion packages/cli/src/commands/releases/rollback.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ export default class Rollback extends Command {
ux.log('Running release command...')
await stream(streamUrl)
.catch(error => {
if (error.statusCode === 404) {
if (error.statusCode === 404 || error.response?.statusCode === 404) {
ux.warn('Release command starting. Use `heroku releases:output` to view the log.')
return
}
Expand Down
4 changes: 2 additions & 2 deletions packages/cli/src/commands/spaces/info.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import heredoc from 'tsheredoc'
import {renderInfo} from '../../lib/spaces/spaces'
import debug from 'debug'

const pgDebug = debug('pg')
const spacesDebug = debug('spaces:info')

export default class Info extends Command {
static topic = 'spaces'
Expand Down Expand Up @@ -43,7 +43,7 @@ export default class Info extends Command {
const {body: outbound_ips} = await this.heroku.get<Heroku.SpaceNetworkAddressTranslation>(`/spaces/${spaceName}/nat`)
space.outbound_ips = outbound_ips
} catch (error) {
pgDebug(`Retrieving NAT details for the space failed with ${error}`)
spacesDebug(`Retrieving NAT details for the space failed with ${error}`)
}
}

Expand Down
4 changes: 2 additions & 2 deletions packages/cli/src/commands/spaces/wait.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import debug from 'debug'
import {renderInfo} from '../../lib/spaces/spaces'
import {Notification, notify} from '@heroku-cli/notifications'

const pgDebug = debug('pg')
const spacesDebug = debug('spaces:wait')

export default class Wait extends Command {
static topic = 'spaces'
Expand Down Expand Up @@ -68,7 +68,7 @@ export default class Wait extends Command {
const {body: nat} = await this.heroku.get<Heroku.SpaceNetworkAddressTranslation>(`/spaces/${spaceName}/nat`)
space.outbound_ips = nat
} catch (error) {
pgDebug(`Retrieving NAT details for the space failed with ${error}`)
spacesDebug(`Retrieving NAT details for the space failed with ${error}`)
}

action.stop()
Expand Down
6 changes: 2 additions & 4 deletions packages/cli/src/lib/ci/source.ts
Original file line number Diff line number Diff line change
@@ -1,15 +1,13 @@
import {Command} from '@heroku-cli/command'
import * as fs from 'async-file'
import {ux} from '@oclif/core'

import * as git from './git'

const got = require('got')
import got from 'got'

async function uploadArchive(url: string, filePath: string) {
const request = got.stream.put(url, {
headers: {
'content-length': (await fs.stat(filePath)).size,
'content-length': (await fs.stat(filePath)).size.toString(),
},
})

Expand Down
3 changes: 1 addition & 2 deletions packages/cli/src/lib/releases/output.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import got = require('got')
import got from 'got'

export const stream = function (url: string) {
return new Promise(function (resolve, reject) {
Expand All @@ -9,4 +9,3 @@ export const stream = function (url: string) {
piped.on('error', reject)
})
}

2 changes: 1 addition & 1 deletion packages/cli/test/unit/commands/ci/run.unit.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import {expect, test} from '@oclif/test'
import * as fs from 'async-file'

import * as git from '../../../../src/lib/ci/git'
const got = require('got')
import got from 'got'

describe('ci:run', function () {
test
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ describe('pg:links:destroy', function () {
'postgres-link',
])
.catch(error => {
expect(error.message).to.equal("pg:links isn't available for Essential-tier databases.")
expect(error.message).to.equal('pg:links isnt available for Essential-tier databases.')
})
})
})
Expand Down

0 comments on commit f1d4690

Please sign in to comment.