Skip to content

Commit c095659

Browse files
authored
Upgrade many oclif and misc packages (#91)
* Upgrade many oclif and misc packages * Upgrade versions based on new package.json specs
1 parent 0845944 commit c095659

File tree

6 files changed

+1025
-1479
lines changed

6 files changed

+1025
-1479
lines changed

package.json

Lines changed: 19 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -5,31 +5,31 @@
55
"author": "Heroku",
66
"bugs": "https://github.com/heroku/heroku-cli-addons-admin/issues",
77
"dependencies": {
8-
"@heroku-cli/color": "^1.1.5",
9-
"@heroku-cli/command": "^8.1.26",
8+
"@heroku-cli/color": "^2.0.4",
9+
"@heroku-cli/command": "^8.5.0",
1010
"@heroku-cli/schema": "^1.0.3",
11-
"@oclif/command": "^1.5.4",
12-
"@oclif/config": "^1.8.8",
13-
"@types/fs-extra": "^5.0.4",
14-
"cli-ux": "^4.7.3",
11+
"@oclif/command": "^1.8.36",
12+
"@oclif/config": "^1.18.17",
13+
"@oclif/plugin-help": "^3.3.1",
14+
"cli-ux": "^5.2.1",
1515
"diff": "^3.5.0",
16-
"fs-extra": "^7.0.0",
17-
"inquirer": "^6.5.2",
16+
"fs-extra": "^9.1.0",
17+
"http-call": "5.3.0",
18+
"inquirer": "^8.2.6",
1819
"jsdiff": "^1.1.1",
19-
"lodash": "^4.17.11",
20+
"lodash": "^4.17.21",
2021
"randomstring": "^1.3.0",
21-
"tslib": "^1"
22+
"tslib": "2.6.3"
2223
},
2324
"devDependencies": {
24-
"@oclif/config": "^1.8.8",
25-
"@oclif/dev-cli": "^1",
26-
"@oclif/plugin-help": "^1",
27-
"@oclif/test": "^1.1.0",
25+
"@heroku-cli/dev-cli": "^1.26.13",
26+
"@oclif/test": "^2.5.6",
2827
"@types/chai": "^4",
2928
"@types/diff": "^3.5.1",
3029
"@types/execa": "^0.9.0",
31-
"@types/glob": "^7.2.0",
32-
"@types/inquirer": "^6.0.2",
30+
"@types/fs-extra": "^9.0.13",
31+
"@types/glob": "8.1.0",
32+
"@types/inquirer": "^8.2.10",
3333
"@types/mocha": "^10.0.7",
3434
"@types/nock": "^9.3.0",
3535
"@types/node": "^10.9.4",
@@ -44,9 +44,9 @@
4444
"mocha": "^10.7.3",
4545
"nock": "^13.5.4",
4646
"nyc": "^15.1.0",
47-
"sinon": "^16.1.3",
48-
"ts-node": "^7.0.1",
49-
"tsutils": "2.27.2",
47+
"sinon": "^18.0.0",
48+
"ts-node": "^10.9.2",
49+
"tsheredoc": "^1.0.1",
5050
"typescript": "4.9.5"
5151
},
5252
"engines": {

src/addon-client.ts

Lines changed: 15 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import {APIClient} from '@heroku-cli/command'
22
import cli from 'cli-ux'
3-
import * as _ from 'lodash'
43
import * as url from 'url'
4+
import {HTTPError} from 'http-call'
55

66
export default class AddonClient {
77
private readonly client: APIClient
@@ -23,39 +23,35 @@ export default class AddonClient {
2323
}
2424

2525
async get(path: string): Promise<any> {
26-
try {
27-
const response = await this.client.get(path, this.options)
28-
return response.body
29-
} catch (error) {
30-
const errorBody = _.get(error, 'body.error')
26+
const response = await this.client.get(path, this.options).catch((error: HTTPError) => {
27+
const errorBody = error?.body?.error
3128
if (errorBody) {
3229
cli.error(errorBody)
3330
}
3431

3532
throw error
36-
}
33+
})
34+
return response.body
3735
}
3836

39-
async post(path: string, requestBody: any): Promise<any> {
40-
try {
41-
const opts = {
42-
...this.options,
43-
body: requestBody,
44-
}
45-
const response = await this.client.post(path, opts)
46-
return response.body
47-
} catch (error) {
48-
const baseErrors = _.get(error, 'body.error.base')
37+
async post(path: string, requestBody: unknown): Promise<any> {
38+
const opts = {
39+
...this.options,
40+
body: requestBody,
41+
}
42+
const response = await this.client.post(path, opts).catch((error: HTTPError) => {
43+
const baseErrors = error?.body?.error?.base
4944
if (baseErrors) {
5045
cli.error(baseErrors.join(', '))
5146
}
5247

53-
const errorBody = _.get(error, 'body.error')
48+
const errorBody = error?.body?.error
5449
if (errorBody) {
5550
cli.error(errorBody)
5651
}
5752

5853
throw error
59-
}
54+
})
55+
return response.body
6056
}
6157
}

src/addon.ts

Lines changed: 9 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import cli from 'cli-ux'
22

33
import color from '@heroku-cli/color'
44
import {IConfig} from '@oclif/config'
5-
import * as _ from 'lodash'
5+
import {HTTPError} from 'http-call'
66

77
import AddonClient from './addon-client'
88
import {ManifestInterface, ManifestLocal, ManifestRemote} from './manifest'
@@ -44,21 +44,19 @@ export default class Addon {
4444
}
4545

4646
async manifests(): Promise<ManifestInterface[]> {
47-
try {
48-
const slug = await this.slug()
49-
cli.action.start(`Fetching add-on manifests for ${color.addon(slug)}`)
50-
const body = await this._client.get(`/api/v3/addons/${encodeURIComponent(slug)}/manifests`)
51-
cli.action.stop()
52-
53-
return body
54-
} catch (error) {
55-
const errorBody = _.get(error, 'body.error')
47+
const slug = await this.slug()
48+
cli.action.start(`Fetching add-on manifests for ${color.addon(slug)}`)
49+
const body = await this._client.get(`/api/v3/addons/${encodeURIComponent(slug)}/manifests`).catch((error: HTTPError) => {
50+
const errorBody = error?.body?.error
5651
if (errorBody) {
5752
cli.error(errorBody)
5853
}
5954

6055
throw error
61-
}
56+
})
57+
58+
cli.action.stop()
59+
return body
6260
}
6361

6462
async manifest(uuid: string): Promise<ManifestInterface> {

src/commands/addons/admin/manifests.ts

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -16,11 +16,14 @@ export default class AddonsAdminManifests extends Command {
1616

1717
const body = await addon.manifests()
1818

19-
const columns = [
20-
{label: 'Manifest', key: 'id'},
21-
{label: 'Created At', key: 'created_at'},
22-
]
23-
24-
cli.table(_.orderBy(body, 'created_at', 'desc'), {columns})
19+
const manifests = _.orderBy(body, 'created_at', 'desc')
20+
cli.table(manifests, {
21+
Manifest: {
22+
get: (row: any) => row.id,
23+
},
24+
'Created At': {
25+
get: (row: any) => row.created_at,
26+
},
27+
})
2528
}
2629
}

test/commands/addons/admin/manifests.test.ts

Lines changed: 11 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import {expect} from '@oclif/test'
2-
2+
import heredoc from 'tsheredoc'
33
import test from '../../../utils/test'
44

55
const host = process.env.HEROKU_ADDONS_HOST || 'https://addons.heroku.com'
@@ -30,13 +30,11 @@ describe('addons:admin:manifests', () => {
3030
.stdout()
3131
.command(['addons:admin:manifests'])
3232
.it('prints a list of manifests', ctx => {
33-
expect(ctx.stdout).to.equal(
34-
// eslint-disable-next-line indent
35-
`Manifest Created At
36-
──────────────────────────────────── ────────────────────────
37-
80d90dfb-049f-436b-9543-24cc7b691352 2017-07-19T21:47:25.894Z
38-
1a2e3c33-c949-4599-97d9-4ed684c35c2f 2017-07-18T21:47:25.894Z
39-
`)
33+
expect(ctx.stdout.trim()).to.eq(heredoc(`
34+
Manifest Created at
35+
──────────────────────────────────── ────────────────────────
36+
80d90dfb-049f-436b-9543-24cc7b691352 2017-07-19T21:47:25.894Z
37+
1a2e3c33-c949-4599-97d9-4ed684c35c2f 2017-07-18T21:47:25.894Z`))
4038
})
4139

4240
test
@@ -47,12 +45,10 @@ describe('addons:admin:manifests', () => {
4745
.stdout()
4846
.command(['addons:admin:manifests', 'arg-slug'])
4947
.it('prints a list of manifests', ctx => {
50-
expect(ctx.stdout).to.equal(
51-
// eslint-disable-next-line indent
52-
`Manifest Created At
53-
──────────────────────────────────── ────────────────────────
54-
80d90dfb-049f-436b-9543-24cc7b691352 2017-07-19T21:47:25.894Z
55-
1a2e3c33-c949-4599-97d9-4ed684c35c2f 2017-07-18T21:47:25.894Z
56-
`)
48+
expect(ctx.stdout.trim()).to.eq(heredoc(`
49+
Manifest Created at
50+
──────────────────────────────────── ────────────────────────
51+
80d90dfb-049f-436b-9543-24cc7b691352 2017-07-19T21:47:25.894Z
52+
1a2e3c33-c949-4599-97d9-4ed684c35c2f 2017-07-18T21:47:25.894Z`))
5753
})
5854
})

0 commit comments

Comments
 (0)