diff --git a/package.json b/package.json index 52ff6d1..7edd9eb 100644 --- a/package.json +++ b/package.json @@ -7,11 +7,12 @@ "bugs": "https://github.com/adobe/aio-cli-plugin-info/issues", "dependencies": { "@adobe/aio-lib-core-config": "^5", - "@oclif/core": "^1.5.0", + "@oclif/core": "^2.0.0", "chalk": "^4.0.0", "debug": "^4.3.3", "envinfo": "^7.5.0", "js-yaml": "^4.1.0", + "open": "^8.4.2", "proxy-from-env": "^1.1.0", "semver": "^7.3.7" }, diff --git a/src/commands/report.js b/src/commands/report.js index c5f45e2..a6028c2 100644 --- a/src/commands/report.js +++ b/src/commands/report.js @@ -10,8 +10,9 @@ OF ANY KIND, either express or implied. See the License for the specific languag governing permissions and limitations under the License. */ -const { Command, Flags, CliUx: { ux: cli } } = require('@oclif/core') +const { Command, Flags } = require('@oclif/core') const envinfo = require('envinfo') +const open = require('open') // /////////////// const issueTemplate = `### Expected Behaviour\n @@ -59,7 +60,7 @@ class ReportCommand extends Command { const issueBody = issueTemplate.replace('%replaced%', resInfo) url = `${baseReportUrl}?body=${encodeURIComponent(issueBody)}&title=new+bug+report&labels=bug` } - cli.open(url) + open(url) } } diff --git a/test/__mocks__/cli-ux.js b/test/__mocks__/cli-ux.js deleted file mode 100644 index aec035e..0000000 --- a/test/__mocks__/cli-ux.js +++ /dev/null @@ -1,22 +0,0 @@ -/* -Copyright 2019 Adobe. All rights reserved. -This file is licensed to you under the Apache License, Version 2.0 (the "License"); -you may not use this file except in compliance with the License. You may obtain a copy -of the License at http://www.apache.org/licenses/LICENSE-2.0 -Unless required by applicable law or agreed to in writing, software distributed under -the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS -OF ANY KIND, either express or implied. See the License for the specific language -governing permissions and limitations under the License. -*/ - -module.exports = { - cli: { - table: jest.fn(), - action: { - start: jest.fn(), - stop: jest.fn() - }, - info: jest.fn(), - open: jest.fn() - } -} diff --git a/test/commands/report.test.js b/test/commands/report.test.js index 62e7e5d..a019a70 100644 --- a/test/commands/report.test.js +++ b/test/commands/report.test.js @@ -14,17 +14,8 @@ const Command = require('../../src/commands/report') const { stdout } = require('stdout-stderr') const envinfo = require('envinfo') jest.mock('envinfo') -jest.mock('@oclif/core', () => { - return { - ...jest.requireActual('@oclif/core'), - CliUx: { - ux: { - open: jest.fn() - } - } - } -}) -const { CliUx: { ux: cli } } = require('@oclif/core') +jest.mock('open', () => jest.fn()) +const open = require('open') test('exports', async () => { expect(typeof Command).toEqual('function') @@ -48,7 +39,7 @@ describe('instance methods', () => { beforeEach(() => { command = new Command([]) envinfo.run.mockResolvedValue('ok') - cli.open.mockResolvedValue('mkay') + open.mockResolvedValue('mkay') }) describe('run', () => { @@ -70,7 +61,7 @@ describe('instance methods', () => { console: false })) expect(stdout.output).toMatch('') - expect(cli.open).toHaveBeenCalled() + expect(open).toHaveBeenCalled() }) }) @@ -88,7 +79,7 @@ describe('instance methods', () => { console: false })) expect(stdout.output).toMatch('') - expect(cli.open).toHaveBeenCalled() + expect(open).toHaveBeenCalled() }) }) @@ -97,7 +88,7 @@ describe('instance methods', () => { command.config = { pjson: { bugs: { url: 'some-link' } } } return command.run().then(() => { expect(envinfo.run).not.toHaveBeenCalled() - expect(cli.open).toHaveBeenCalled() + expect(open).toHaveBeenCalled() expect(stdout.output).toMatch('') }) }) @@ -120,7 +111,7 @@ describe('instance methods', () => { expect(envinfo.run).not.toHaveBeenCalled() expect(stdout.output).toMatch('') expect(command.error).toHaveBeenCalled() - expect(cli.open).not.toHaveBeenCalled() + expect(open).not.toHaveBeenCalled() }) }) })