Skip to content
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
8 changes: 4 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,9 @@
"@adobe/aio-lib-core-logging": "^3",
"@adobe/aio-lib-env": "^3",
"@adobe/aio-lib-ims": "^7",
"@oclif/core": "^1.4.0",
"js-yaml": "^4.1.0"
"@oclif/core": "^2.0.0",
"js-yaml": "^4.1.0",
"open": "^10.2.0"
},
"devDependencies": {
"@adobe/eslint-config-aio-lib-config": "^4.0.0",
Expand All @@ -34,7 +35,6 @@
"jest": "^29",
"jest-haste-map": "^29.6.1",
"jest-junit": "^16.0.0",
"jest-plugin-fs": "^2.9.0",
"oclif": "^4.17.13",
"stdout-stderr": "^0.1.9"
},
Expand Down Expand Up @@ -69,7 +69,7 @@
"scripts": {
"eslint": "eslint src test e2e",
"test": "npm run unit-tests && npm run eslint",
"unit-tests": "jest --ci -w=2",
"unit-tests": "node --experimental-vm-modules node_modules/jest/bin/jest.js --ci -w=2",
"prepack": "oclif manifest && oclif readme --no-aliases",
"postpack": "rm -f oclif.manifest.json",
"version": "oclif readme && git add README.md",
Expand Down
5 changes: 2 additions & 3 deletions src/commands/console/open.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,8 @@ governing permissions and limitations under the License.
*/
const aioLogger = require('@adobe/aio-lib-core-logging')('@adobe/aio-cli-plugin-console:open', { provider: 'debug' })
const { getCliEnv } = require('@adobe/aio-lib-env')
const { CliUx } = require('@oclif/core')
const { OPEN_URLS } = require('../../config')

const open = require('open')
const ConsoleCommand = require('./index')
class OpenCommand extends ConsoleCommand {
async run () {
Expand All @@ -33,7 +32,7 @@ class OpenCommand extends ConsoleCommand {
}
}
aioLogger.debug(`opening url ${url}`)
CliUx.ux.open(url)
open(url)
}
}

Expand Down
4 changes: 2 additions & 2 deletions src/commands/console/org/list.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ 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, CliUx: { ux: cli } } = require('@oclif/core')
const { Flags, ux } = require('@oclif/core')
const { ORG_TYPE_ENTERPRISE } = require('../../../config')

const ConsoleCommand = require('../index')
Expand Down Expand Up @@ -73,7 +73,7 @@ class ListCommand extends ConsoleCommand {
header: 'Org Name'
}
}
cli.table(orgs, columns)
ux.table(orgs, columns)
}
}

Expand Down
11 changes: 5 additions & 6 deletions src/commands/console/org/select.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ governing permissions and limitations under the License.
*/
const aioConsoleLogger = require('@adobe/aio-lib-core-logging')('@adobe/aio-cli-plugin-console:org:select', { provider: 'debug' })
const { CONFIG_KEYS } = require('../../../config')

const { Args } = require('@oclif/core')
const ConsoleCommand = require('../index')

class SelectCommand extends ConsoleCommand {
Expand Down Expand Up @@ -53,13 +53,12 @@ class SelectCommand extends ConsoleCommand {

SelectCommand.description = 'Select an Organization'

SelectCommand.args = [
{
name: 'orgCode',
SelectCommand.args = {
orgCode: Args.string({
required: false,
description: 'Adobe Developer Console Org code'
}
]
})
}

SelectCommand.aliases = [
'console:org:sel'
Expand Down
4 changes: 2 additions & 2 deletions src/commands/console/project/list.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ 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, CliUx: { ux: cli } } = require('@oclif/core')
const { Flags, ux } = require('@oclif/core')
const ConsoleCommand = require('../index')

class ListCommand extends ConsoleCommand {
Expand Down Expand Up @@ -67,7 +67,7 @@ class ListCommand extends ConsoleCommand {
header: 'Title'
}
}
cli.table(projects, columns)
ux.table(projects, columns)
}
}

Expand Down
12 changes: 5 additions & 7 deletions src/commands/console/project/select.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,8 @@ 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/core')
const { Flags, Args } = require('@oclif/core')
const { CONFIG_KEYS } = require('../../../config')

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

class SelectCommand extends ConsoleCommand {
Expand Down Expand Up @@ -59,13 +58,12 @@ class SelectCommand extends ConsoleCommand {

SelectCommand.description = 'Select a Project for the selected Organization'

SelectCommand.args = [
{
name: 'projectIdOrName',
SelectCommand.args = {
projectIdOrName: Args.string({
required: false,
description: 'Adobe Developer Console Project id or Project name'
}
]
})
}

SelectCommand.flags = {
...ConsoleCommand.flags,
Expand Down
11 changes: 5 additions & 6 deletions src/commands/console/publickey/delete.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ 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/core')
const { Flags, Args } = require('@oclif/core')
const { CONFIG_KEYS } = require('../../../config')
const ConsoleCommand = require('../index')

Expand Down Expand Up @@ -83,13 +83,12 @@ DeleteCommand.flags = {
})
}

DeleteCommand.args = [
{
name: 'idOrFingerprint',
DeleteCommand.args = {
idOrFingerprint: Args.string({
required: true,
description: 'The bindingId or the fingerprint of the public key binding to delete'
}
]
})
}

DeleteCommand.aliases = []

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

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

class IndexCommand extends ConsoleCommand {
Expand Down Expand Up @@ -47,7 +47,7 @@ IndexCommand.printBindings = function (bindings) {
decorated.expiresString = binding.notAfter ? this.formatExpiry(binding.notAfter) : ''
decorateds.push(decorated)
})
cli.table(decorateds, columns)
ux.table(decorateds, columns)
}

/**
Expand Down
11 changes: 5 additions & 6 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/core')
const { Flags, Args } = require('@oclif/core')
const ConsoleCommand = require('../index')
const IndexCommand = require('./index')
const fs = require('fs')
Expand Down Expand Up @@ -122,12 +122,11 @@ UploadAndBindCommand.flags = {

UploadAndBindCommand.aliases = []

UploadAndBindCommand.args = [
{
name: 'file',
UploadAndBindCommand.args = {
file: Args.string({
required: true,
description: 'Path to public key certificate file in PEM format'
}
]
})
}

module.exports = UploadAndBindCommand
11 changes: 7 additions & 4 deletions src/commands/console/workspace/download.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/core')
const { Flags, Args } = require('@oclif/core')
const path = require('path')
const ConsoleCommand = require('../index')
const aioConsoleLogger = require('@adobe/aio-lib-core-logging')('@adobe/aio-cli-plugin-console:workspace:download', { provider: 'debug' })
Expand Down Expand Up @@ -102,8 +102,11 @@ DownloadCommand.aliases = [
'console:ws:dl'
]

DownloadCommand.args = [
{ name: 'destination', required: false, description: 'Output file name or folder name where the Console Workspace configuration file should be saved' }
]
DownloadCommand.args = {
destination: Args.string({
required: false,
description: 'Output file name or folder name where the Console Workspace configuration file should be saved'
})
}

module.exports = DownloadCommand
4 changes: 2 additions & 2 deletions src/commands/console/workspace/list.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, CliUx: { ux: cli } } = require('@oclif/core')
const { Flags, ux } = require('@oclif/core')
const { CONFIG_KEYS } = require('../../../config')

const ConsoleCommand = require('../index')
Expand Down Expand Up @@ -44,7 +44,7 @@ class ListCommand extends ConsoleCommand {
this.printYaml(workspaces)
} else {
// print formatted result
cli.table(workspaces, {
ux.table(workspaces, {
id: {
minWidth: 25
},
Expand Down
11 changes: 5 additions & 6 deletions src/commands/console/workspace/select.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/core')
const { Flags, Args } = require('@oclif/core')
const ConsoleCommand = require('../index')
const aioConsoleLogger = require('@adobe/aio-lib-core-logging')('@adobe/aio-cli-plugin-console:workspace:select', { provider: 'debug' })
const { CONFIG_KEYS } = require('../../../config')
Expand Down Expand Up @@ -84,12 +84,11 @@ SelectCommand.flags = {
})
}

SelectCommand.args = [
{
name: 'workspaceIdOrName',
SelectCommand.args = {
workspaceIdOrName: Args.string({
required: false,
description: 'Adobe Developer Console Workspace id or Workspace name'
}
]
})
}

module.exports = SelectCommand
24 changes: 8 additions & 16 deletions test/commands/console/open.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,17 +13,9 @@ const TestCommand = require('../../../src/commands/console/open')
const config = require('@adobe/aio-lib-core-config')
const { STAGE_ENV } = require('@adobe/aio-lib-env')

jest.mock('@oclif/core', () => {
return {
...jest.requireActual('@oclif/core'),
CliUx: {
ux: {
open: jest.fn()
}
}
}
})
const { Command, CliUx: { ux: cli } } = require('@oclif/core')
jest.mock('open', () => jest.fn())
const { Command } = require('@oclif/core')
const open = require('open')

let command
let ORIGINAL_AIO_CLI_ENV
Expand Down Expand Up @@ -64,19 +56,19 @@ describe('console:open', () => {

test('should open a browser', async () => {
await expect(command.run()).resolves.not.toThrow()
expect(cli.open).toHaveBeenCalledWith('https://developer.adobe.com/console/projects')
expect(open).toHaveBeenCalledWith('https://developer.adobe.com/console/projects')
})

test('should open a browser (stage_env)', async () => {
process.env.AIO_CLI_ENV = STAGE_ENV
await expect(command.run()).resolves.not.toThrow()
expect(cli.open).toHaveBeenCalledWith('https://developer-stage.adobe.com/console/projects')
expect(open).toHaveBeenCalledWith('https://developer-stage.adobe.com/console/projects')
})

test('should open a browser with default view if no project/workspace selected', async () => {
config.get.mockReturnValue(null)
await expect(command.run()).resolves.not.toThrow()
expect(cli.open).toHaveBeenLastCalledWith('https://developer.adobe.com/console/projects')
expect(open).toHaveBeenLastCalledWith('https://developer.adobe.com/console/projects')
})

test('should open a browser with project overview', async () => {
Expand All @@ -90,7 +82,7 @@ describe('console:open', () => {
}
})
await expect(command.run()).resolves.not.toThrow()
expect(cli.open).toHaveBeenLastCalledWith('https://developer.adobe.com/console/projects/53444/4566206088344853970/overview')
expect(open).toHaveBeenLastCalledWith('https://developer.adobe.com/console/projects/53444/4566206088344853970/overview')
})

test('should open a browser with project workspace', async () => {
Expand All @@ -105,6 +97,6 @@ describe('console:open', () => {
workspace: { id: '4566206088344859372', name: 'Stage' }
})
await expect(command.run()).resolves.not.toThrow()
expect(cli.open).toHaveBeenLastCalledWith('https://developer.adobe.com/console/projects/53444/4566206088344853970/workspaces/4566206088344859372/details')
expect(open).toHaveBeenLastCalledWith('https://developer.adobe.com/console/projects/53444/4566206088344853970/workspaces/4566206088344859372/details')
})
})
2 changes: 1 addition & 1 deletion test/commands/console/org/index.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ test('description', async () => {
})

test('args', async () => {
expect(TheCommand.args).toBeUndefined()
expect(TheCommand.args).toEqual({})
})

test('flags', async () => {
Expand Down
3 changes: 1 addition & 2 deletions test/commands/console/org/select.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -56,8 +56,7 @@ test('aliases', async () => {
})

test('args', async () => {
const orgCode = SelectCommand.args[0]
expect(orgCode.name).toEqual('orgCode')
const orgCode = SelectCommand.args.orgCode
expect(orgCode.required).toEqual(false)
expect(orgCode.description).toBeDefined()
})
Expand Down
2 changes: 1 addition & 1 deletion test/commands/console/project/index.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ test('description', async () => {
})

test('args', async () => {
expect(TheCommand.args).toBeUndefined()
expect(TheCommand.args).toEqual({})
})

test('flags', async () => {
Expand Down
3 changes: 1 addition & 2 deletions test/commands/console/project/select.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -77,8 +77,7 @@ test('aliases', async () => {
})

test('args', async () => {
const projectId = SelectCommand.args[0]
expect(projectId.name).toEqual('projectIdOrName')
const projectId = SelectCommand.args.projectIdOrName
expect(projectId.required).toEqual(false)
expect(projectId.description).toBeDefined()
})
Expand Down
Loading