Skip to content

Commit aefb1f4

Browse files
authored
refactor!: migrate plugin to oclif/core v2 (#85)
* chore: upgrade ci workflow to use v4 github actions * chore: rename .eslint.json to .eslint * chore: update node 20 and upgrade dependencies * refactor: migrate the api command to oclif/core v2 * refactor: update tests * chore: enable bin/run and bin/dev for local testing * chore: update command examples * chore: add test coverage reporting and downgrade ts * chore: remove nyc output * chore: update node engine version * chore: update tool-versions to node 20.18.2
1 parent 1eb5c9b commit aefb1f4

File tree

14 files changed

+3946
-3539
lines changed

14 files changed

+3946
-3539
lines changed

.eslintrc

+43
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
{
2+
"extends": [
3+
"oclif",
4+
"oclif-typescript",
5+
"plugin:mocha/recommended"
6+
],
7+
"ignorePatterns": ["**/test/**/*.js", "**/lib/"],
8+
"parser": "@typescript-eslint/parser",
9+
"parserOptions": {
10+
"ecmaVersion": 6,
11+
"sourceType": "module",
12+
"ecmaFeatures": {
13+
"modules": true
14+
}
15+
},
16+
"plugins": [
17+
"import",
18+
"mocha"
19+
],
20+
"rules": {
21+
"@typescript-eslint/explicit-module-boundary-types": "off",
22+
"@typescript-eslint/no-empty-function": "off",
23+
"camelcase":"off",
24+
"indent": ["error", 2, {"MemberExpression": 1}],
25+
"mocha/no-mocha-arrows": "warn",
26+
"mocha/no-exports": "warn",
27+
"mocha/no-setup-in-describe": "warn",
28+
"no-await-in-loop": "off", // Perfect legit to use await in loops, we should leave it off
29+
"no-constant-condition": ["error", {"checkLoops": false }],
30+
"node/no-missing-import": "off",
31+
"unicorn/filename-case": "off",
32+
"unicorn/import-style": "off",
33+
"unicorn/no-abusive-eslint-disable": "off",
34+
"unicorn/no-array-callback-reference": "off",
35+
"unicorn/no-array-for-each": "off",
36+
"unicorn/no-lonely-if":"off",
37+
"unicorn/no-process-exit": "off",
38+
"unicorn/numeric-separators-style":"off",
39+
"unicorn/prefer-module": "off",
40+
"unicorn/prefer-node-protocol": "off",
41+
"unicorn/prefer-regexp-test": "off"
42+
}
43+
}

.eslintrc.json

-23
This file was deleted.

.github/workflows/ci.yml

+2-2
Original file line numberDiff line numberDiff line change
@@ -14,9 +14,9 @@ jobs:
1414
os: [ubuntu-latest, macos-latest, windows-latest]
1515

1616
steps:
17-
- uses: actions/checkout@v3
17+
- uses: actions/checkout@v4
1818
- name: Use Node.js ${{ matrix.node-version }}
19-
uses: actions/setup-node@v3
19+
uses: actions/setup-node@v4
2020
with:
2121
node-version: ${{ matrix.node-version }}
2222
- run: yarn --frozen-lockfile --ignore-engines

.gitignore

+2
Original file line numberDiff line numberDiff line change
@@ -2,3 +2,5 @@ lib
22
node_modules
33
.idea
44
oclif.manifest.json
5+
.DS_STORE
6+
.nyc_output

.tool-versions

+1-1
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
nodejs 16.20.0
1+
nodejs 20.18.2

README.md

+16-8
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ make a manual API request
2121

2222
```
2323
USAGE
24-
$ heroku api METHOD [PATH] [-v <value>] [-a <value>] [-b <value>]
24+
$ heroku api METHOD [PATH] [-a <value>] [-b <value>] [-v <value>]
2525
2626
ARGUMENTS
2727
METHOD GET, POST, PUT, PATCH, or DELETE
@@ -53,18 +53,26 @@ EXAMPLES
5353
name: "myapp",
5454
5555
}
56+
5657
$ heroku api PATCH /apps/myapp/config-vars --body '{"FOO": "bar"}'
5758
{
5859
FOO: "bar"
5960
6061
}
61-
$ export HEROKU_HEADERS
62-
$ HEROKU_HEADERS='{
63-
"Content-Type": "application/x-www-form-urlencoded",
64-
"Accept": "application/json"
65-
}'
66-
$ printf 'type=web&qty=2' | heroku api POST /apps/myapp/ps/scale
67-
2
62+
63+
$ printf '{"updates":[{"type":"web", "quantity":2}]}' | heroku api POST /apps/myapp/formation
64+
[
65+
{
66+
"app": {
67+
"name": "myapp",
68+
"id": "01234567-89ab-cdef-0123-456789abcdef"
69+
},
70+
"quantity": 2,
71+
"type": "web",
72+
"updated_at": "2012-01-01T12:00:00Z"
73+
...
74+
}
75+
]
6876
```
6977

7078
_See code: [src/commands/api.ts](https://github.com/heroku/heroku-api-plugin/blob/v2.3.0/src/commands/api.ts)_

bin/dev.cmd

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
@echo off
2+
3+
node --loader ts-node/esm --no-warnings=ExperimentalWarning "%~dp0\dev" %*

bin/dev.js

+6
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
#!/usr/bin/env -S node --loader ts-node/esm --disable-warning=ExperimentalWarning
2+
3+
// eslint-disable-next-line n/shebang
4+
import {execute} from '@oclif/core'
5+
6+
await execute({development: true, dir: import.meta.url})

bin/run

+6
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
#!/usr/bin/env node
2+
3+
const oclif = require('@oclif/core')
4+
oclif.run().catch(async error => {
5+
return require('@oclif/core/handle')(error)
6+
})

bin/run.cmd

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
@echo off
2+
3+
node "%~dp0\run" %*

package.json

+22-21
Original file line numberDiff line numberDiff line change
@@ -7,37 +7,37 @@
77
"url": "https://github.com/heroku/heroku-api-plugin/issues"
88
},
99
"engines": {
10-
"node": ">= 16.0"
10+
"node": ">=20"
1111
},
1212
"dependencies": {
13+
"@heroku/http-call": "^5.4.0",
1314
"@heroku-cli/color": "^1.1.14",
14-
"@heroku-cli/command": "^8.4.0",
15-
"@oclif/command": "^1.8.0",
16-
"@oclif/config": "^1.17.0",
17-
"@oclif/errors": "^1.3.4",
18-
"cli-ux": "^4.6.1",
19-
"edit-string": "1.1.6",
15+
"@heroku-cli/command": "^11.4.0",
16+
"@oclif/core": "^2.16.0",
17+
"edit-string": "^1.1.6",
2018
"fs-extra": "^9.0.1",
2119
"get-stdin": "8.0.0",
20+
"tsheredoc": "^1.0.1",
2221
"http-call": "^5.3.0"
2322
},
2423
"devDependencies": {
25-
"@oclif/test": "^2.5.6",
26-
"@types/chai": "^4.3.14",
24+
"@oclif/test": "^2.3.28",
25+
"@types/chai": "^5.0.1",
2726
"@types/mocha": "^10.0.6",
28-
"@types/node": "16.11.7",
29-
"@types/supports-color": "^5.3.0",
27+
"@types/node": "^20.14.8",
28+
"@types/supports-color": "^8.1.3",
3029
"chai": "^4.4.1",
31-
"eslint": "^7.32.0",
32-
"eslint-config-oclif": "^4.0.0",
33-
"eslint-config-oclif-typescript": "^1.0.3",
30+
"eslint": "^8.57.1",
31+
"eslint-config-oclif": "^5.2.2",
32+
"eslint-config-oclif-typescript": "^3.1.13",
3433
"eslint-plugin-oclif": "^0.1.0",
3534
"globby": "^13.2.2",
3635
"mocha": "^10.4.0",
3736
"nock": "^13.5.1",
38-
"oclif": "3.17.2",
37+
"nyc": "^15.1.0",
38+
"oclif": "^4.17.13",
3939
"ts-node": "^10.9.2",
40-
"typescript": "5.5.4"
40+
"typescript": "4.8.4"
4141
},
4242
"files": [
4343
"oclif.manifest.json",
@@ -67,13 +67,14 @@
6767
"isbinaryfile": "4.0.10"
6868
},
6969
"scripts": {
70-
"lint": "eslint . --ext .ts",
70+
"build": "rm -rf lib && tsc",
71+
"lint": "eslint . --ext .ts --config=.eslintrc",
7172
"postpublish": "rm oclif.manifest.json",
7273
"posttest": "yarn lint && tsc --noEmit -p test",
73-
"prepare": "rm -rf lib && tsc",
74-
"prepack": "tsc && oclif manifest",
75-
"pretest": "tsc && oclif manifest",
76-
"test": "mocha test/**/*.test.ts",
74+
"prepare": "yarn build",
75+
"prepack": "yarn build && oclif manifest",
76+
"pretest": "yarn build && oclif manifest",
77+
"test": "nyc mocha test/**/*.test.ts",
7778
"version": "oclif readme && git add README.md"
7879
}
7980
}

0 commit comments

Comments
 (0)