Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat. Oclif v2 migration #171

Merged
merged 3 commits into from
Jun 20, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 6 additions & 16 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,36 +10,29 @@
"@adobe/aio-lib-core-logging": "^1.1.0",
"@adobe/aio-lib-env": "^1.1.0",
"@adobe/aio-lib-ims": "^5.0.0",
"@oclif/command": "^1",
"@oclif/config": "1.15.1",
"@oclif/errors": "^1.1.2",
"@oclif/plugin-help": "^2.2.3",
"cli-ux": "^5.4.5",
"@oclif/core": "^1.4.0",
"js-yaml": "^3.13.1"
},
"devDependencies": {
"@adobe/eslint-config-aio-lib-config": "^1.4.0",
"@babel/core": "^7.9.6",
"@oclif/dev-cli": "^1",
"@oclif/test": "^1",
"@types/jest": "^26.0.20",
"babel-jest": "^26.0.1",
"@types/jest": "^27.4.1",
"babel-jest": "^27.5.1",
"babel-runtime": "^6.26.0",
"chalk": "^4.0.0",
"eol": "^0.9.1",
"eslint": "^7.32.0",
"eslint-config-oclif": "^3.1.0",
"eslint-config-oclif": "^4.0.0",
"eslint-config-standard": "^16.0.3",
"eslint-plugin-import": "^2.25.4",
"eslint-plugin-jest": "^23.20.0",
"eslint-plugin-jsdoc": "^37.5.1",
"eslint-plugin-node": "^11.1.0",
"eslint-plugin-promise": "^5.2.0",
"eslint-plugin-standard": "^4.0.1",
"execa": "^4.0.0",
"jest": "^27",
"jest-haste-map": "^25.1.0",
"jest-junit": "^10.0.0",
"jest-haste-map": "^27.5.1",
"jest-junit": "^13.0.0",
"jest-plugin-fs": "^2.9.0",
"stdout-stderr": "^0.1.9",
"typescript": "^4.5.4"
Expand All @@ -61,9 +54,6 @@
"oclif": {
"commands": "./src/commands",
"bin": "aio",
"devPlugins": [
"@oclif/plugin-help"
],
"hooks": {
"init": "./src/hooks/upgrade-config-hook.js"
},
Expand Down
9 changes: 4 additions & 5 deletions src/commands/console/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,19 +12,18 @@ governing permissions and limitations under the License.

const aioConsoleLogger = require('@adobe/aio-lib-core-logging')('@adobe/aio-cli-plugin-console', { provider: 'debug' })
const config = require('@adobe/aio-lib-core-config')
const { Command, flags } = require('@oclif/command')
const { Command, Flags, Help } = require('@oclif/core')
const { getToken, context } = require('@adobe/aio-lib-ims')
const LibConsoleCLI = require('@adobe/aio-cli-lib-console')
const { CLI } = require('@adobe/aio-lib-ims/src/context')
const Help = require('@oclif/plugin-help').default
const { getCliEnv } = require('@adobe/aio-lib-env')
const yaml = require('js-yaml')
const { CONFIG_KEYS, API_KEYS } = require('../../config')
const { getCliEnv } = require('@adobe/aio-lib-env')

class ConsoleCommand extends Command {
async run () {
const help = new Help(this.config)
help.showHelp(['console', '--help'])
await help.showHelp(['console', '--help'])
}

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

// common flags
ConsoleCommand.flags = {
help: flags.boolean({ description: 'Show help' })
help: Flags.boolean({ description: 'Show help' })
}

module.exports = ConsoleCommand
4 changes: 2 additions & 2 deletions src/commands/console/org/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,13 @@ OF ANY KIND, either express or implied. See the License for the specific languag
governing permissions and limitations under the License.
*/

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

class IndexCommand extends ConsoleCommand {
async run () {
const help = new Help(this.config)
help.showHelp(['console:org', '--help'])
await help.showHelp(['console:org', '--help'])
}
}

Expand Down
9 changes: 4 additions & 5 deletions src/commands/console/org/list.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,15 +11,14 @@ governing permissions and limitations under the License.
*/

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

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

class ListCommand extends ConsoleCommand {
async run () {
const { flags } = this.parse(ListCommand)
const { flags } = await this.parse(ListCommand)

await this.initSdk()

Expand Down Expand Up @@ -82,12 +81,12 @@ ListCommand.description = 'List your Organizations'

ListCommand.flags = {
...ConsoleCommand.flags,
json: flags.boolean({
json: Flags.boolean({
description: 'Output json',
char: 'j',
exclusive: ['yml']
}),
yml: flags.boolean({
yml: Flags.boolean({
description: 'Output yml',
char: 'y',
exclusive: ['json']
Expand Down
2 changes: 1 addition & 1 deletion src/commands/console/org/select.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ const ConsoleCommand = require('../index')

class SelectCommand extends ConsoleCommand {
async run () {
const { args } = this.parse(SelectCommand)
const { args } = await this.parse(SelectCommand)

await this.initSdk()

Expand Down
4 changes: 2 additions & 2 deletions src/commands/console/project/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,13 @@ OF ANY KIND, either express or implied. See the License for the specific languag
governing permissions and limitations under the License.
*/

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

class IndexCommand extends ConsoleCommand {
async run () {
const help = new Help(this.config)
help.showHelp(['console:project', '--help'])
await help.showHelp(['console:project', '--help'])
}
}

Expand Down
14 changes: 6 additions & 8 deletions src/commands/console/project/list.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,14 +10,12 @@ OF ANY KIND, either express or implied. See the License for the specific languag
governing permissions and limitations under the License.
*/
const aioConsoleLogger = require('@adobe/aio-lib-core-logging')('@adobe/aio-cli-plugin-console:project:list', { provider: 'debug' })
const { flags } = require('@oclif/command')
const { cli } = require('cli-ux')
const { Flags, CliUx: { ux: cli } } = require('@oclif/core')
const ConsoleCommand = require('../index')

class ListCommand extends ConsoleCommand {
async run () {
const { flags } = this.parse(ListCommand)

const { flags } = await this.parse(ListCommand)
const orgId = flags.orgId || this.getConfig('org.id')
if (!orgId) {
this.log('You have not selected an Organization. Please select first.')
Expand Down Expand Up @@ -50,7 +48,7 @@ class ListCommand extends ConsoleCommand {
* Retrieve projects from an Org
*
* @param {string} orgId organization id
* @returns {Array} Projects
* @returns {Promise<Array>} Projects
*/
async getConsoleOrgProjects (orgId) {
const response = await this.consoleCLI.getProjects(orgId)
Expand All @@ -77,15 +75,15 @@ ListCommand.description = 'List your Projects for the selected Organization'

ListCommand.flags = {
...ConsoleCommand.flags,
orgId: flags.string({
orgId: Flags.string({
description: 'OrgID for listing projects'
}),
json: flags.boolean({
json: Flags.boolean({
description: 'Output json',
char: 'j',
exclusive: ['yml']
}),
yml: flags.boolean({
yml: Flags.boolean({
description: 'Output yml',
char: 'y',
exclusive: ['json']
Expand Down
6 changes: 3 additions & 3 deletions src/commands/console/project/select.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,14 +10,14 @@ OF ANY KIND, either express or implied. See the License for the specific languag
governing permissions and limitations under the License.
*/
const aioConsoleLogger = require('@adobe/aio-lib-core-logging')('@adobe/aio-cli-plugin-console:project:select', { provider: 'debug' })
const { flags } = require('@oclif/command')
const { Flags } = require('@oclif/core')
const { CONFIG_KEYS } = require('../../../config')

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

class SelectCommand extends ConsoleCommand {
async run () {
const { args, flags } = this.parse(SelectCommand)
const { args, flags } = await this.parse(SelectCommand)

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

Expand Down Expand Up @@ -69,7 +69,7 @@ SelectCommand.args = [

SelectCommand.flags = {
...ConsoleCommand.flags,
orgId: flags.string({
orgId: Flags.string({
description: 'Organization id of the Console Project to select'
})
}
Expand Down
10 changes: 5 additions & 5 deletions src/commands/console/publickey/delete.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,13 @@ governing permissions and limitations under the License.
*/

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

class DeleteCommand extends ConsoleCommand {
async run () {
const { args, flags } = this.parse(DeleteCommand)
const { args, flags } = await this.parse(DeleteCommand)

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

DeleteCommand.flags = {
...ConsoleCommand.flags,
orgId: flags.string({
orgId: Flags.string({
description: 'Organization id of the Console Workspace to delete the public key certificate from'
}),
projectId: flags.string({
projectId: Flags.string({
description: 'Project id of the Console Workspace to delete the public key certificate from'
}),
workspaceId: flags.string({
workspaceId: Flags.string({
description: 'Workspace id of the Console Workspace to delete the public key certificate from'
})
}
Expand Down
7 changes: 3 additions & 4 deletions src/commands/console/publickey/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,13 @@ OF ANY KIND, either express or implied. See the License for the specific languag
governing permissions and limitations under the License.
*/

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

class IndexCommand extends ConsoleCommand {
async run () {
const help = new Help(this.config)
help.showHelp(['console:publickey', '--help'])
await help.showHelp(['console:publickey', '--help'])
}
}

Expand Down
14 changes: 7 additions & 7 deletions src/commands/console/publickey/list.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,15 +10,15 @@ governing permissions and limitations under the License.
*/

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

const ConsoleCommand = require('../index')
const IndexCommand = require('./index')

class ListCommand extends ConsoleCommand {
async run () {
const { flags } = this.parse(ListCommand)
const { flags } = await this.parse(ListCommand)

const orgId = flags.orgId || this.getConfig(`${CONFIG_KEYS.ORG}.id`)
if (!orgId) {
Expand Down Expand Up @@ -71,21 +71,21 @@ ListCommand.description = 'List the public key certificates bound to the selecte

ListCommand.flags = {
...ConsoleCommand.flags,
orgId: flags.string({
orgId: Flags.string({
description: 'Organization id of the Console Workspace to list the public key certificates for'
}),
projectId: flags.string({
projectId: Flags.string({
description: 'Project id of the Console Workspace to list the public key certificate for'
}),
workspaceId: flags.string({
workspaceId: Flags.string({
description: 'Workspace id of the Console Workspace to list the public key certificate for'
}),
json: flags.boolean({
json: Flags.boolean({
description: 'Output json',
char: 'j',
exclusive: ['yml']
}),
yml: flags.boolean({
yml: Flags.boolean({
description: 'Output yml',
char: 'y',
exclusive: ['json']
Expand Down
14 changes: 7 additions & 7 deletions src/commands/console/publickey/upload.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTA
OF ANY KIND, either express or implied. See the License for the specific language
governing permissions and limitations under the License.
*/
const { flags } = require('@oclif/command')
const { Flags } = require('@oclif/core')
const ConsoleCommand = require('../index')
const IndexCommand = require('./index')
const fs = require('fs')
Expand All @@ -19,7 +19,7 @@ const aioConsoleLogger = require('@adobe/aio-lib-core-logging')('@adobe/aio-cli-

class UploadAndBindCommand extends ConsoleCommand {
async run () {
const { args, flags } = this.parse(UploadAndBindCommand)
const { args, flags } = await this.parse(UploadAndBindCommand)

const orgId = flags.orgId || this.getConfig(`${CONFIG_KEYS.ORG}.id`)
if (!orgId) {
Expand Down Expand Up @@ -99,21 +99,21 @@ UploadAndBindCommand.description = 'Upload a public key certificate to the selec

UploadAndBindCommand.flags = {
...ConsoleCommand.flags,
orgId: flags.string({
orgId: Flags.string({
description: 'Organization id of the Console Workspace to upload the public key certificate to'
}),
projectId: flags.string({
projectId: Flags.string({
description: 'Project id of the Console Workspace to upload the public key certificate to'
}),
workspaceId: flags.string({
workspaceId: Flags.string({
description: 'Workspace id of the Console Workspace to upload the public key certificate to'
}),
json: flags.boolean({
json: Flags.boolean({
description: 'Output json',
char: 'j',
exclusive: ['yml']
}),
yml: flags.boolean({
yml: Flags.boolean({
description: 'Output yml',
char: 'y',
exclusive: ['json']
Expand Down
Loading