diff --git a/.eslintrc b/.eslintrc deleted file mode 100644 index 1886281..0000000 --- a/.eslintrc +++ /dev/null @@ -1,4 +0,0 @@ -{ - "extends": "@adobe/eslint-config-aio-lib-config", - "parserOptions": { "ecmaVersion": 2020} -} diff --git a/.gitignore b/.gitignore index 305c5ee..ba384ef 100644 --- a/.gitignore +++ b/.gitignore @@ -14,3 +14,4 @@ coverage/ junit.xml package-lock.json oclif.manifest.json +.claude diff --git a/eslint.config.js b/eslint.config.js new file mode 100644 index 0000000..61ff77d --- /dev/null +++ b/eslint.config.js @@ -0,0 +1,25 @@ +/* +Copyright 2022 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 jestPlugin = require('eslint-plugin-jest') + +module.exports = [ + ...aioLibConfig, + { + files: ['test/**/*.js'], + ...jestPlugin.configs['flat/recommended'], + rules: { + ...jestPlugin.configs['flat/recommended'].rules, + 'jsdoc/require-jsdoc': 'off' + } + } +] diff --git a/package.json b/package.json index 24c3126..f8fec1a 100644 --- a/package.json +++ b/package.json @@ -7,7 +7,7 @@ "dependencies": { "@adobe/aio-lib-core-config": "^5", "@adobe/aio-lib-core-networking": "^5.0.4", - "@oclif/core": "^1.3.4", + "@oclif/core": "^4", "ci-info": "^4.0.0", "debug": "^4.1.1", "inquirer": "^8.2.1", @@ -15,17 +15,11 @@ "splunk-logging": "^0.11.1" }, "devDependencies": { - "@adobe/eslint-config-aio-lib-config": "^4.0.0", - "eslint": "^8.57.1", - "eslint-config-oclif": "^1", - "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-plugin-standard": "^4.0.1", + "@adobe/eslint-config-aio-lib-config": "5.0.0", + "eslint": "^9", + "eslint-plugin-jest": "^28", + "eslint-plugin-jsdoc": "^48", + "neostandard": "^0", "execa": "^4.0.2", "jest": "^29", "jest-fetch-mock": "^3.0.0", diff --git a/src/commands/telemetry/index.js b/src/commands/telemetry/index.js index ac52497..0b364b6 100644 --- a/src/commands/telemetry/index.js +++ b/src/commands/telemetry/index.js @@ -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 { Command, Flags } = require('@oclif/core') +const { Args, Command, Flags } = require('@oclif/core') const telemetryLib = require('../../telemetry-lib') class IndexCommand extends Command { @@ -63,11 +63,13 @@ IndexCommand.flags = { }) } -IndexCommand.args = [{ - name: 'state', - required: false, - description: 'set telemetry state', - options: ['on', 'off', 'yes', 'no'] -}] +IndexCommand.args = { + state: Args.string({ + required: false, + description: 'set telemetry state', + options: ['on', 'off', 'yes', 'no'], + ignoreStdin: true + }) +} module.exports = IndexCommand diff --git a/test/index.test.js b/test/index.test.js index b2e384b..b0306e9 100644 --- a/test/index.test.js +++ b/test/index.test.js @@ -13,15 +13,22 @@ const { createFetch } = require('@adobe/aio-lib-core-networking') const TheCommand = require('../src/commands/telemetry') const { stdout } = require('stdout-stderr') +const config = require('@adobe/aio-lib-core-config') jest.mock('inquirer') +jest.mock('@adobe/aio-lib-core-config') const fetch = createFetch() let command +let mockConfig beforeEach(() => { fetch.resetMocks() - command = new TheCommand([]) + config.get.mockReturnValue(false) // telemetry enabled by default + mockConfig = { + runHook: jest.fn().mockResolvedValue({ successes: [], failures: [] }) + } + command = new TheCommand([], mockConfig) fetch.mockResponseOnce('ok') }) @@ -49,6 +56,7 @@ describe('telemetry command', () => { }) test('telemetry (get) off', async () => { + config.get.mockReturnValue(true) // optOut=true means telemetry off command.argv = [] await command.run() expect(stdout.output).toMatch('Telemetry is off')