diff --git a/.eslintrc.json b/.eslintrc.json deleted file mode 100644 index 3673765..0000000 --- a/.eslintrc.json +++ /dev/null @@ -1,8 +0,0 @@ -{ - "extends": "@adobe/eslint-config-aio-lib-config", - "settings": { - "jsdoc": { - "ignorePrivate": true - } - } -} \ No newline at end of file diff --git a/.gitignore b/.gitignore index 64eca7c..33c00b7 100644 --- a/.gitignore +++ b/.gitignore @@ -13,3 +13,4 @@ coverage/ junit.xml package-lock.json oclif.manifest.json +.claude diff --git a/e2e/.eslintrc.json b/e2e/.eslintrc.json deleted file mode 100644 index 9738bc9..0000000 --- a/e2e/.eslintrc.json +++ /dev/null @@ -1,5 +0,0 @@ -{ - "rules": { - "node/no-unpublished-require": 0 - } -} \ No newline at end of file diff --git a/eslint.config.js b/eslint.config.js new file mode 100644 index 0000000..069b2dd --- /dev/null +++ b/eslint.config.js @@ -0,0 +1,28 @@ +/* +Copyright 2020 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. +*/ + +const aioLibConfig = require('@adobe/eslint-config-aio-lib-config') +const jest = require('eslint-plugin-jest') + +module.exports = [ + ...aioLibConfig, + { + ...jest.configs['flat/recommended'], + files: ['test/**/*.js', 'e2e/**/*.js'] + }, + { + files: ['test/**/*.js', 'e2e/**/*.js'], + rules: { + 'n/no-unpublished-require': 'off' + } + } +] diff --git a/package.json b/package.json index 9c0459e..cfa859f 100644 --- a/package.json +++ b/package.json @@ -7,7 +7,7 @@ "bugs": "https://github.com/adobe/aio-cli-plugin-info/issues", "dependencies": { "@adobe/aio-lib-core-config": "^5", - "@oclif/core": "^2.0.0", + "@oclif/core": "^4.10.2", "chalk": "^4.0.0", "debug": "^4.3.3", "envinfo": "^7.5.0", @@ -17,23 +17,18 @@ "semver": "^7.3.7" }, "devDependencies": { - "@adobe/eslint-config-aio-lib-config": "^4.0.0", + "@adobe/eslint-config-aio-lib-config": "^5.0.0", "acorn": "^8.7.0", "dedent": "^1.5.1", - "eslint": "^8.57.1", - "eslint-config-oclif": "^5.2.2", - "eslint-config-standard": "^17.1.0", - "eslint-plugin-import": "^2.31.0", - "eslint-plugin-jest": "^27.9.0", - "eslint-plugin-jsdoc": "^48.11.0", - "eslint-plugin-n": "^15.7.0", - "eslint-plugin-node": "^11.1.0", - "eslint-plugin-promise": "^6.6.0", + "eslint": "^9", + "eslint-plugin-jest": "^29", + "eslint-plugin-jsdoc": "^48", "execa": "^9.5.2", "jest": "^29.5.0", "jest-haste-map": "^29.5.0", "jest-junit": "^16.0.0", "jest-resolve": "^29.7.0", + "neostandard": "^0", "oclif": "^4.17.13", "stdout-stderr": "^0.1.13" }, diff --git a/src/commands/info.js b/src/commands/info.js index 269be44..b94abbe 100644 --- a/src/commands/info.js +++ b/src/commands/info.js @@ -43,9 +43,8 @@ class InfoCommand extends Command { } async run () { - const { flags } = await this.parse(InfoCommand) - try { + const { flags } = await this.parse(InfoCommand) const resInfo = await envinfo.run({ System: ['OS', 'CPU', 'Memory', 'Shell'], Binaries: ['Node', 'Yarn', 'npm'], @@ -57,7 +56,7 @@ class InfoCommand extends Command { showNotFound: true }) - const plugins = this.config.plugins + const plugins = [...this.config.plugins.values()] .filter(p => !p.parent) .sort((a, b) => a.name < b.name ? -1 : 1) diff --git a/test/.eslintrc.json b/test/.eslintrc.json deleted file mode 100644 index 9738bc9..0000000 --- a/test/.eslintrc.json +++ /dev/null @@ -1,5 +0,0 @@ -{ - "rules": { - "node/no-unpublished-require": 0 - } -} \ No newline at end of file diff --git a/test/commands/info.test.js b/test/commands/info.test.js index 9411dfe..2f1f6b4 100644 --- a/test/commands/info.test.js +++ b/test/commands/info.test.js @@ -93,6 +93,7 @@ describe('instance methods', () => { test('calls envinfo.run', () => { command.argv = [] command.config = { + runHook: jest.fn().mockResolvedValue({ successes: [], failures: [] }), pjson: { name: 'ima-cli', oclif: { @@ -126,6 +127,7 @@ describe('instance methods', () => { test('proxies, cli plugins (core, user, link) stdout', () => { command.argv = [] command.config = { + runHook: jest.fn().mockResolvedValue({ successes: [], failures: [] }), pjson: { name: 'ima-cli', oclif: { @@ -178,6 +180,7 @@ describe('instance methods', () => { command.argv = [] command.config = { + runHook: jest.fn().mockResolvedValue({ successes: [], failures: [] }), pjson: { name: 'ima-cli', oclif: { @@ -222,6 +225,7 @@ describe('instance methods', () => { test('proxies, cli plugins (core, user, link) --json', () => { command.argv = ['-j'] command.config = { + runHook: jest.fn().mockResolvedValue({ successes: [], failures: [] }), pjson: { name: 'ima-cli', oclif: { @@ -297,6 +301,7 @@ describe('instance methods', () => { test('proxies, cli plugins (core, user, link) --yml', async () => { command.argv = ['-y'] command.config = { + runHook: jest.fn().mockResolvedValue({ successes: [], failures: [] }), pjson: { name: 'ima-cli', oclif: { @@ -352,6 +357,7 @@ describe('instance methods', () => { test('calls envinfo.run --json', () => { command.argv = ['-j'] command.config = { + runHook: jest.fn().mockResolvedValue({ successes: [], failures: [] }), pjson: { name: 'ima-cli', oclif: { @@ -385,6 +391,7 @@ describe('instance methods', () => { test('calls envinfo.run --yml', () => { command.argv = ['-y'] command.config = { + runHook: jest.fn().mockResolvedValue({ successes: [], failures: [] }), pjson: { name: 'ima-cli', oclif: { @@ -428,6 +435,7 @@ describe('instance methods', () => { test('warns if node is not supported', async () => { command.config = { + runHook: jest.fn().mockResolvedValue({ successes: [], failures: [] }), pjson: { name: 'ima-cli', oclif: { @@ -451,6 +459,7 @@ describe('instance methods', () => { test('plugins list is sorted', async () => { command.config = { + runHook: jest.fn().mockResolvedValue({ successes: [], failures: [] }), pjson: { name: 'ima-cli', oclif: { diff --git a/test/commands/report.test.js b/test/commands/report.test.js index a019a70..b411bac 100644 --- a/test/commands/report.test.js +++ b/test/commands/report.test.js @@ -49,7 +49,7 @@ describe('instance methods', () => { test('calls envinfo.run for bugs (object)', () => { command.argv = [] - command.config = { pjson: { bugs: { url: 'some-link' } } } + command.config = { runHook: jest.fn().mockResolvedValue({ successes: [], failures: [] }), pjson: { bugs: { url: 'some-link' } } } return command.run() .then(() => { expect(envinfo.run).toHaveBeenCalledWith(expect.objectContaining({ @@ -67,7 +67,7 @@ describe('instance methods', () => { test('calls envinfo.run for bugs (string)', () => { command.argv = [] - command.config = { pjson: { bugs: 'some-link' } } + command.config = { runHook: jest.fn().mockResolvedValue({ successes: [], failures: [] }), pjson: { bugs: 'some-link' } } return command.run() .then(() => { expect(envinfo.run).toHaveBeenCalledWith(expect.objectContaining({ @@ -85,7 +85,7 @@ describe('instance methods', () => { test('does not call envinfo.run for feature', () => { command.argv = ['-f'] - command.config = { pjson: { bugs: { url: 'some-link' } } } + command.config = { runHook: jest.fn().mockResolvedValue({ successes: [], failures: [] }), pjson: { bugs: { url: 'some-link' } } } return command.run().then(() => { expect(envinfo.run).not.toHaveBeenCalled() expect(open).toHaveBeenCalled() @@ -95,7 +95,7 @@ describe('instance methods', () => { test('outputs error if cli package.json does not define a bugs.url', async () => { command.argv = [] - command.config = { pjson: { bugs: { } } } + command.config = { runHook: jest.fn().mockResolvedValue({ successes: [], failures: [] }), pjson: { bugs: { } } } command.error = jest.fn(() => { throw new Error('Bang bang there goes your heart') }) const unexpectedError = new Error('it should not reach here')