From 45491270e91e676db916fe3c3e495065d74966ed Mon Sep 17 00:00:00 2001 From: Shazron Abdullah <36107+shazron@users.noreply.github.com> Date: Wed, 25 Mar 2026 19:00:37 +0800 Subject: [PATCH 1/2] chore: upgrade @oclif/core from v2 to v4 (fixes #119) - Update @oclif/core dependency to ^4.10.2 - Move this.parse() inside try/catch in info.js (v4 parse() calls config.runHook internally) - Spread config.plugins.values() since config.plugins is now a Map in v4 - Add runHook mock to test configs to satisfy v4's parse() lifecycle - Allow @oclif/core in node/no-missing-require rule (eslint-plugin-node@11 doesn't resolve package.json exports field) Co-Authored-By: Claude Sonnet 4.6 --- .eslintrc.json | 7 ++++++- package.json | 2 +- src/commands/info.js | 5 ++--- test/commands/info.test.js | 9 +++++++++ test/commands/report.test.js | 8 ++++---- 5 files changed, 22 insertions(+), 9 deletions(-) diff --git a/.eslintrc.json b/.eslintrc.json index 3673765..a2cd0a5 100644 --- a/.eslintrc.json +++ b/.eslintrc.json @@ -4,5 +4,10 @@ "jsdoc": { "ignorePrivate": true } - } + }, + "rules": { + "node/no-missing-require": ["error", { + "allowModules": ["@oclif/core"] + }] + } } \ No newline at end of file diff --git a/package.json b/package.json index 9c0459e..4ef7763 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", 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/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') From 733c428749bf563de975d70154e97141021d85e7 Mon Sep 17 00:00:00 2001 From: Shazron Abdullah <36107+shazron@users.noreply.github.com> Date: Wed, 25 Mar 2026 20:13:17 +0800 Subject: [PATCH 2/2] chore: migrate to eslint v9 flat config with @adobe/eslint-config-aio-lib-config@5 - Replace .eslintrc.json, test/.eslintrc.json, e2e/.eslintrc.json with eslint.config.js - Update devDependencies: eslint@^9, @adobe/eslint-config-aio-lib-config@^5, eslint-plugin-jest@^29, eslint-plugin-jsdoc@^48, neostandard@^0 - Drop node/no-missing-require allowlist for @oclif/core (eslint-plugin-n v17 supports package.json exports field natively) Co-Authored-By: Claude Sonnet 4.6 --- .eslintrc.json | 13 ------------- .gitignore | 1 + e2e/.eslintrc.json | 5 ----- eslint.config.js | 28 ++++++++++++++++++++++++++++ package.json | 15 +++++---------- test/.eslintrc.json | 5 ----- 6 files changed, 34 insertions(+), 33 deletions(-) delete mode 100644 .eslintrc.json delete mode 100644 e2e/.eslintrc.json create mode 100644 eslint.config.js delete mode 100644 test/.eslintrc.json diff --git a/.eslintrc.json b/.eslintrc.json deleted file mode 100644 index a2cd0a5..0000000 --- a/.eslintrc.json +++ /dev/null @@ -1,13 +0,0 @@ -{ - "extends": "@adobe/eslint-config-aio-lib-config", - "settings": { - "jsdoc": { - "ignorePrivate": true - } - }, - "rules": { - "node/no-missing-require": ["error", { - "allowModules": ["@oclif/core"] - }] - } -} \ 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 4ef7763..cfa859f 100644 --- a/package.json +++ b/package.json @@ -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/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