Skip to content
Open
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
4 changes: 0 additions & 4 deletions .eslintrc

This file was deleted.

1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -14,3 +14,4 @@ coverage/
junit.xml
package-lock.json
oclif.manifest.json
.claude
25 changes: 25 additions & 0 deletions eslint.config.js
Original file line number Diff line number Diff line change
@@ -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'
}
}
]
18 changes: 6 additions & 12 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,25 +7,19 @@
"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",
"os-name": "^4.0.1",
"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",
Expand Down
16 changes: 9 additions & 7 deletions src/commands/telemetry/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 { Command, Flags } = require('@oclif/core')
const { Args, Command, Flags } = require('@oclif/core')
const telemetryLib = require('../../telemetry-lib')

class IndexCommand extends Command {
Expand Down Expand Up @@ -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
10 changes: 9 additions & 1 deletion test/index.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -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')
})

Expand Down Expand Up @@ -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')
Expand Down
Loading