Skip to content

Commit 21cf522

Browse files
feat. Oclif v2 migration (#171)
* oclif v2 migration Co-authored-by: Jesse MacFadyen <purplecabbage@gmail.com>
1 parent 95c9431 commit 21cf522

33 files changed

Lines changed: 101 additions & 112 deletions

package.json

Lines changed: 6 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -10,36 +10,29 @@
1010
"@adobe/aio-lib-core-logging": "^1.1.0",
1111
"@adobe/aio-lib-env": "^1.1.0",
1212
"@adobe/aio-lib-ims": "^5.0.0",
13-
"@oclif/command": "^1",
14-
"@oclif/config": "1.15.1",
15-
"@oclif/errors": "^1.1.2",
16-
"@oclif/plugin-help": "^2.2.3",
17-
"cli-ux": "^5.4.5",
13+
"@oclif/core": "^1.4.0",
1814
"js-yaml": "^3.13.1"
1915
},
2016
"devDependencies": {
2117
"@adobe/eslint-config-aio-lib-config": "^1.4.0",
2218
"@babel/core": "^7.9.6",
23-
"@oclif/dev-cli": "^1",
24-
"@oclif/test": "^1",
25-
"@types/jest": "^26.0.20",
26-
"babel-jest": "^26.0.1",
19+
"@types/jest": "^27.4.1",
20+
"babel-jest": "^27.5.1",
2721
"babel-runtime": "^6.26.0",
2822
"chalk": "^4.0.0",
2923
"eol": "^0.9.1",
3024
"eslint": "^7.32.0",
31-
"eslint-config-oclif": "^3.1.0",
25+
"eslint-config-oclif": "^4.0.0",
3226
"eslint-config-standard": "^16.0.3",
3327
"eslint-plugin-import": "^2.25.4",
3428
"eslint-plugin-jest": "^23.20.0",
3529
"eslint-plugin-jsdoc": "^37.5.1",
3630
"eslint-plugin-node": "^11.1.0",
3731
"eslint-plugin-promise": "^5.2.0",
38-
"eslint-plugin-standard": "^4.0.1",
3932
"execa": "^4.0.0",
4033
"jest": "^27",
41-
"jest-haste-map": "^25.1.0",
42-
"jest-junit": "^10.0.0",
34+
"jest-haste-map": "^27.5.1",
35+
"jest-junit": "^13.0.0",
4336
"jest-plugin-fs": "^2.9.0",
4437
"stdout-stderr": "^0.1.9",
4538
"typescript": "^4.5.4"
@@ -61,9 +54,6 @@
6154
"oclif": {
6255
"commands": "./src/commands",
6356
"bin": "aio",
64-
"devPlugins": [
65-
"@oclif/plugin-help"
66-
],
6757
"hooks": {
6858
"init": "./src/hooks/upgrade-config-hook.js"
6959
},

src/commands/console/index.js

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -12,19 +12,18 @@ governing permissions and limitations under the License.
1212

1313
const aioConsoleLogger = require('@adobe/aio-lib-core-logging')('@adobe/aio-cli-plugin-console', { provider: 'debug' })
1414
const config = require('@adobe/aio-lib-core-config')
15-
const { Command, flags } = require('@oclif/command')
15+
const { Command, Flags, Help } = require('@oclif/core')
1616
const { getToken, context } = require('@adobe/aio-lib-ims')
1717
const LibConsoleCLI = require('@adobe/aio-cli-lib-console')
1818
const { CLI } = require('@adobe/aio-lib-ims/src/context')
19-
const Help = require('@oclif/plugin-help').default
19+
const { getCliEnv } = require('@adobe/aio-lib-env')
2020
const yaml = require('js-yaml')
2121
const { CONFIG_KEYS, API_KEYS } = require('../../config')
22-
const { getCliEnv } = require('@adobe/aio-lib-env')
2322

2423
class ConsoleCommand extends Command {
2524
async run () {
2625
const help = new Help(this.config)
27-
help.showHelp(['console', '--help'])
26+
await help.showHelp(['console', '--help'])
2827
}
2928

3029
async initSdk () {
@@ -133,7 +132,7 @@ ConsoleCommand.description = 'Console plugin for the Adobe I/O CLI'
133132

134133
// common flags
135134
ConsoleCommand.flags = {
136-
help: flags.boolean({ description: 'Show help' })
135+
help: Flags.boolean({ description: 'Show help' })
137136
}
138137

139138
module.exports = ConsoleCommand

src/commands/console/org/index.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,13 +9,13 @@ OF ANY KIND, either express or implied. See the License for the specific languag
99
governing permissions and limitations under the License.
1010
*/
1111

12-
const Help = require('@oclif/plugin-help').default
12+
const { Help } = require('@oclif/core')
1313
const ConsoleCommand = require('../')
1414

1515
class IndexCommand extends ConsoleCommand {
1616
async run () {
1717
const help = new Help(this.config)
18-
help.showHelp(['console:org', '--help'])
18+
await help.showHelp(['console:org', '--help'])
1919
}
2020
}
2121

src/commands/console/org/list.js

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -11,15 +11,14 @@ governing permissions and limitations under the License.
1111
*/
1212

1313
const aioConsoleLogger = require('@adobe/aio-lib-core-logging')('@adobe/aio-cli-plugin-console:org:list', { provider: 'debug' })
14-
const { flags } = require('@oclif/command')
15-
const { cli } = require('cli-ux')
14+
const { Flags, CliUx: { ux: cli } } = require('@oclif/core')
1615
const { ORG_TYPE_ENTERPRISE } = require('../../../config')
1716

1817
const ConsoleCommand = require('../index')
1918

2019
class ListCommand extends ConsoleCommand {
2120
async run () {
22-
const { flags } = this.parse(ListCommand)
21+
const { flags } = await this.parse(ListCommand)
2322

2423
await this.initSdk()
2524

@@ -82,12 +81,12 @@ ListCommand.description = 'List your Organizations'
8281

8382
ListCommand.flags = {
8483
...ConsoleCommand.flags,
85-
json: flags.boolean({
84+
json: Flags.boolean({
8685
description: 'Output json',
8786
char: 'j',
8887
exclusive: ['yml']
8988
}),
90-
yml: flags.boolean({
89+
yml: Flags.boolean({
9190
description: 'Output yml',
9291
char: 'y',
9392
exclusive: ['json']

src/commands/console/org/select.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ const ConsoleCommand = require('../index')
1616

1717
class SelectCommand extends ConsoleCommand {
1818
async run () {
19-
const { args } = this.parse(SelectCommand)
19+
const { args } = await this.parse(SelectCommand)
2020

2121
await this.initSdk()
2222

src/commands/console/project/index.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,13 +9,13 @@ OF ANY KIND, either express or implied. See the License for the specific languag
99
governing permissions and limitations under the License.
1010
*/
1111

12-
const Help = require('@oclif/plugin-help').default
12+
const { Help } = require('@oclif/core')
1313
const ConsoleCommand = require('../')
1414

1515
class IndexCommand extends ConsoleCommand {
1616
async run () {
1717
const help = new Help(this.config)
18-
help.showHelp(['console:project', '--help'])
18+
await help.showHelp(['console:project', '--help'])
1919
}
2020
}
2121

src/commands/console/project/list.js

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -10,14 +10,12 @@ OF ANY KIND, either express or implied. See the License for the specific languag
1010
governing permissions and limitations under the License.
1111
*/
1212
const aioConsoleLogger = require('@adobe/aio-lib-core-logging')('@adobe/aio-cli-plugin-console:project:list', { provider: 'debug' })
13-
const { flags } = require('@oclif/command')
14-
const { cli } = require('cli-ux')
13+
const { Flags, CliUx: { ux: cli } } = require('@oclif/core')
1514
const ConsoleCommand = require('../index')
1615

1716
class ListCommand extends ConsoleCommand {
1817
async run () {
19-
const { flags } = this.parse(ListCommand)
20-
18+
const { flags } = await this.parse(ListCommand)
2119
const orgId = flags.orgId || this.getConfig('org.id')
2220
if (!orgId) {
2321
this.log('You have not selected an Organization. Please select first.')
@@ -50,7 +48,7 @@ class ListCommand extends ConsoleCommand {
5048
* Retrieve projects from an Org
5149
*
5250
* @param {string} orgId organization id
53-
* @returns {Array} Projects
51+
* @returns {Promise<Array>} Projects
5452
*/
5553
async getConsoleOrgProjects (orgId) {
5654
const response = await this.consoleCLI.getProjects(orgId)
@@ -77,15 +75,15 @@ ListCommand.description = 'List your Projects for the selected Organization'
7775

7876
ListCommand.flags = {
7977
...ConsoleCommand.flags,
80-
orgId: flags.string({
78+
orgId: Flags.string({
8179
description: 'OrgID for listing projects'
8280
}),
83-
json: flags.boolean({
81+
json: Flags.boolean({
8482
description: 'Output json',
8583
char: 'j',
8684
exclusive: ['yml']
8785
}),
88-
yml: flags.boolean({
86+
yml: Flags.boolean({
8987
description: 'Output yml',
9088
char: 'y',
9189
exclusive: ['json']

src/commands/console/project/select.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,14 +10,14 @@ OF ANY KIND, either express or implied. See the License for the specific languag
1010
governing permissions and limitations under the License.
1111
*/
1212
const aioConsoleLogger = require('@adobe/aio-lib-core-logging')('@adobe/aio-cli-plugin-console:project:select', { provider: 'debug' })
13-
const { flags } = require('@oclif/command')
13+
const { Flags } = require('@oclif/core')
1414
const { CONFIG_KEYS } = require('../../../config')
1515

1616
const ConsoleCommand = require('../index')
1717

1818
class SelectCommand extends ConsoleCommand {
1919
async run () {
20-
const { args, flags } = this.parse(SelectCommand)
20+
const { args, flags } = await this.parse(SelectCommand)
2121

2222
const orgId = flags.orgId || this.getConfig(`${CONFIG_KEYS.ORG}.id`)
2323

@@ -69,7 +69,7 @@ SelectCommand.args = [
6969

7070
SelectCommand.flags = {
7171
...ConsoleCommand.flags,
72-
orgId: flags.string({
72+
orgId: Flags.string({
7373
description: 'Organization id of the Console Project to select'
7474
})
7575
}

src/commands/console/publickey/delete.js

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -10,13 +10,13 @@ governing permissions and limitations under the License.
1010
*/
1111

1212
const aioConsoleLogger = require('@adobe/aio-lib-core-logging')('@adobe/aio-cli-plugin-console:publickey:list', { provider: 'debug' })
13-
const { flags } = require('@oclif/command')
13+
const { Flags } = require('@oclif/core')
1414
const { CONFIG_KEYS } = require('../../../config')
1515
const ConsoleCommand = require('../index')
1616

1717
class DeleteCommand extends ConsoleCommand {
1818
async run () {
19-
const { args, flags } = this.parse(DeleteCommand)
19+
const { args, flags } = await this.parse(DeleteCommand)
2020

2121
const orgId = flags.orgId || this.getConfig(`${CONFIG_KEYS.ORG}.id`)
2222
if (!orgId) {
@@ -72,13 +72,13 @@ DeleteCommand.description = 'Delete a public key certificate from the selected W
7272

7373
DeleteCommand.flags = {
7474
...ConsoleCommand.flags,
75-
orgId: flags.string({
75+
orgId: Flags.string({
7676
description: 'Organization id of the Console Workspace to delete the public key certificate from'
7777
}),
78-
projectId: flags.string({
78+
projectId: Flags.string({
7979
description: 'Project id of the Console Workspace to delete the public key certificate from'
8080
}),
81-
workspaceId: flags.string({
81+
workspaceId: Flags.string({
8282
description: 'Workspace id of the Console Workspace to delete the public key certificate from'
8383
})
8484
}

src/commands/console/publickey/index.js

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,14 +9,13 @@ OF ANY KIND, either express or implied. See the License for the specific languag
99
governing permissions and limitations under the License.
1010
*/
1111

12-
const Help = require('@oclif/plugin-help').default
13-
const ConsoleCommand = require('..')
14-
const { cli } = require('cli-ux')
12+
const { Help, CliUx: { ux: cli } } = require('@oclif/core')
13+
const ConsoleCommand = require('../')
1514

1615
class IndexCommand extends ConsoleCommand {
1716
async run () {
1817
const help = new Help(this.config)
19-
help.showHelp(['console:publickey', '--help'])
18+
await help.showHelp(['console:publickey', '--help'])
2019
}
2120
}
2221

0 commit comments

Comments
 (0)