Skip to content
Merged
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
33 changes: 0 additions & 33 deletions .eslintrc.json

This file was deleted.

63 changes: 63 additions & 0 deletions eslint.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
const config = require('@adobe/eslint-config-aio-lib-config')

module.exports = [
...config,
{
languageOptions: {
globals: {
NoErrorThrownError: true,
getErrorForCallThatShouldThrowAnError: true,
fixturePath: true,
fixtureFile: true,
fixtureJson: true,
fixtureHjson: true,
fixtureYaml: true,
fakeFileSystem: true,
setFetchMock: true,
createOclifMockConfig: true,
loadFixtureApp: true,
defaultAppHostName: true,
defaultTvmUrl: true,
defaultOwApihost: true,
fakeS3Bucket: true,
fakeOrgId: true,
fakeConfig: true,
aioLegacyAppConfig: true,
fakeS3Creds: true,
extraConfig: true,
fakeTVMResponse: true
}
},
settings: {
jsdoc: {
ignorePrivate: true
}
},
rules: {
'jsdoc/no-defaults': 0,
'jsdoc/tag-lines': [
'error',
'never',
{
startLines: null
}
]
}
},
{
files: ['test/**/*.js'],
languageOptions: {
globals: {
jest: true,
describe: true,
test: true,
it: true,
expect: true,
beforeEach: true,
afterEach: true,
beforeAll: true,
afterAll: true
}
}
}
]
13 changes: 4 additions & 9 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
"@adobe/generator-aio-app": "^9",
"@adobe/generator-app-common-lib": "^3",
"@adobe/inquirer-table-checkbox": "^2",
"@oclif/core": "^2.11.6",
"@oclif/core": "^4.9.0",
"@octokit/rest": "^19.0.11",
"@parcel/core": "^2.7.0",
"@parcel/reporter-cli": "^2.7.0",
Expand Down Expand Up @@ -51,19 +51,14 @@
},
"devDependencies": {
"@adobe/aio-lib-test-proxy": "^2",
"@adobe/eslint-config-aio-lib-config": "^4.0.0",
"@adobe/eslint-config-aio-lib-config": "^5.0.0",
"@types/jest": "^29",
"babel-runtime": "^6.26.0",
"core-js": "^3",
"eol": "^0.9.1",
"eslint": "^8.57.1",
"eslint-config-standard": "^17.1.0",
"eslint-plugin-import": "^2.31.0",
"eslint-plugin-jest": "^27.9.0",
"eslint": "^9",
"eslint-plugin-jsdoc": "^48.11.0",
"eslint-plugin-n": "^15.7.0",
"eslint-plugin-node": "^11.1.0",
"eslint-plugin-promise": "^6.6.0",
"neostandard": "^0",
"jest": "^29.5.0",
"nock": "^13.2.9",
"oclif": "^4.17.13",
Expand Down
1 change: 0 additions & 1 deletion src/commands/app/install.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@ const jsYaml = require('js-yaml')
const { USER_CONFIG_FILE, DEPLOY_CONFIG_FILE, PACKAGE_LOCK_FILE } = require('../../lib/defaults')
const ora = require('ora')

// eslint-disable-next-line node/no-missing-require
const libConfig = require('@adobe/aio-cli-lib-app-config')

class InstallCommand extends BaseCommand {
Expand Down
1 change: 0 additions & 1 deletion src/commands/app/pack.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@ const { getObjectValue } = require('../../lib/app-helper')
const ora = require('ora')
const junk = require('junk')

// eslint-disable-next-line node/no-missing-require
const libConfig = require('@adobe/aio-cli-lib-app-config')

const DIST_FOLDER = 'dist'
Expand Down
4 changes: 2 additions & 2 deletions src/lib/cleanup.js
Original file line number Diff line number Diff line change
Expand Up @@ -40,11 +40,11 @@ class Cleanup {
try {
await this.run()
aioLogger.info('exiting!')
process.exit(0) // eslint-disable-line no-process-exit
process.exit(0)
} catch (e) {
aioLogger.error('unexpected error while cleaning up!')
aioLogger.error(e)
process.exit(1) // eslint-disable-line no-process-exit
process.exit(1)
}
})
}
Expand Down
1 change: 0 additions & 1 deletion src/lib/install-helper.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ const ajvAddFormats = require('ajv-formats')
* @returns {object} with keys valid (boolean) and errors (object). errors is null if no errors
*/
function validateJsonWithSchema (fileJson, schemaName) {
/* eslint-disable-next-line node/no-unpublished-require */
const schemas = require('../../schema/index')
const ajv = new Ajv({
allErrors: true,
Expand Down
1 change: 0 additions & 1 deletion src/lib/run-dev.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTA
OF ANY KIND, either express or implied. See the License for the specific language
governing permissions and limitations under the License.
*/
/* eslint-disable no-template-curly-in-string */
const aioLogger = require('@adobe/aio-lib-core-logging')('@adobe/aio-cli-plugin-app:runDev', { provider: 'debug' })
const rtLib = require('@adobe/aio-lib-runtime')
const rtLibUtils = rtLib.utils
Expand Down
7 changes: 6 additions & 1 deletion test/BaseCommand.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -282,21 +282,23 @@ describe('getLibConsoleCLI', () => {

test('init', async () => {
const cmd = new TheCommand([])
cmd.config = {}
cmd.config = global.createOclifMockConfig()
await cmd.init()
expect(cmd.prompt).toBe(mockExtensionPrompt)
expect(inquirer.createPromptModule).toHaveBeenCalledWith({ output: process.stderr })
})

test('catch', async () => {
const cmd = new TheCommand([])
cmd.config = global.createOclifMockConfig()
cmd.error = jest.fn()
await cmd.catch(new Error('fake error'))
expect(cmd.error).toHaveBeenCalledWith('fake error')
})

test('will change error message when aio app outside of the application root', async () => {
const cmd = new TheCommand([])
cmd.config = global.createOclifMockConfig()
cmd.error = jest.fn()
await cmd.catch(new Error('ENOENT: no such file or directory, open \'package.json\''))

Expand All @@ -308,6 +310,7 @@ test('will change error message when aio app outside of the application root', a

test('will change error message when aio app outside of the application root (--verbose)', async () => {
const cmd = new TheCommand(['--verbose'])
cmd.config = global.createOclifMockConfig()
cmd.error = jest.fn()
await cmd.catch(new Error('ENOENT: no such file or directory, open \'package.json\''))

Expand All @@ -319,6 +322,7 @@ test('will change error message when aio app outside of the application root (--

test('will handle errors without stack traces when using --verbose flag', async () => {
const cmd = new TheCommand(['--verbose'])
cmd.config = global.createOclifMockConfig()
cmd.error = jest.fn()
const errorWithoutStack = new Error('fake error')
delete errorWithoutStack.stack
Expand All @@ -329,6 +333,7 @@ test('will handle errors without stack traces when using --verbose flag', async

test('will handle errors without stack traces when not using --verbose flag', async () => {
const cmd = new TheCommand([])
cmd.config = global.createOclifMockConfig()
cmd.error = jest.fn()
const errorWithoutStack = new Error('fake error')
delete errorWithoutStack.stack
Expand Down
2 changes: 1 addition & 1 deletion test/TemplatesCommand.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ beforeEach(() => {
command = new TheCommand()
command.config = {
runCommand: jest.fn(),
runHook: jest.fn()
runHook: jest.fn().mockResolvedValue({ successes: [] })
}

inquirer.registerPrompt.mockReset()
Expand Down
2 changes: 1 addition & 1 deletion test/commands/app/add/action.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ beforeEach(() => {
command.getLibConsoleCLI.mockResolvedValue({
getEnabledServicesForOrg: mockGetEnabledServicesForOrg
})
command.config = { bin: 'aio' }
command.config = global.createOclifMockConfig({ bin: 'aio' })

command.selectTemplates = jest.fn()
command.selectTemplates.mockResolvedValue([])
Expand Down
1 change: 1 addition & 0 deletions test/commands/app/add/event.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ const createAppConfig = (aioConfig = {}, appFixtureName = 'legacy-app') => {
let command
beforeEach(() => {
command = new TheCommand([])
command.config = global.createOclifMockConfig()
command.getAppExtConfigs = jest.fn()
command.getAppExtConfigs.mockResolvedValue(createAppConfig(command.appConfig))
command.getFullConfig = jest.fn()
Expand Down
4 changes: 2 additions & 2 deletions test/commands/app/add/extension.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -41,9 +41,9 @@ beforeEach(() => {
command.getFullConfig.mockResolvedValue(createFullConfig({}))
command.getConfigFileForKey = jest.fn()
command.getConfigFileForKey.mockResolvedValue({})
command.config = {
command.config = global.createOclifMockConfig({
runCommand: jest.fn()
}
})

command.selectTemplates = jest.fn()
command.selectTemplates.mockResolvedValue([])
Expand Down
2 changes: 1 addition & 1 deletion test/commands/app/add/index.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ describe('instance methods', () => {

test('returns help file for app:add command', () => {
const spy = jest.spyOn(Help.prototype, 'showHelp').mockReturnValue(true)
command.config = {}
command.config = global.createOclifMockConfig()
return command.run().then(() => {
expect(spy).toHaveBeenCalledWith(['app:add', '--help'])
})
Expand Down
1 change: 1 addition & 0 deletions test/commands/app/add/web-assets.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ const createAppConfig = (aioConfig = {}, appFixtureName = 'legacy-app') => {
let command
beforeEach(() => {
command = new TheCommand([])
command.config = global.createOclifMockConfig()
command.getAppExtConfigs = jest.fn()
command.getAppExtConfigs.mockResolvedValue(createAppConfig(command.appConfig))
command.getFullConfig = jest.fn()
Expand Down
1 change: 1 addition & 0 deletions test/commands/app/build.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -202,6 +202,7 @@ describe('run', () => {
beforeEach(() => {
spinner = ora()
command = new TheCommand([])
command.config = global.createOclifMockConfig()
command.error = jest.fn()
command.log = jest.fn()
command.getAppExtConfigs = jest.fn()
Expand Down
2 changes: 1 addition & 1 deletion test/commands/app/config/get/index.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ const { Help } = require('@oclif/core')

test('returns help file for app:config:get command', () => {
const command = new TheCommand([])
command.config = {}
command.config = global.createOclifMockConfig()
const spy = jest.spyOn(Help.prototype, 'showHelp').mockReturnValue(true)
return command.run().then(() => {
expect(spy).toHaveBeenCalledWith(['app:config:get', '--help'])
Expand Down
1 change: 1 addition & 0 deletions test/commands/app/config/get/log-forwarding.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ jest.mock('../../../../../src/lib/log-forwarding', () => {
let command, lf
beforeEach(async () => {
command = new TheCommand([])
command.config = global.createOclifMockConfig()
command.appConfig = {
aio: {
runtime: {
Expand Down
1 change: 1 addition & 0 deletions test/commands/app/config/get/log-forwarding/errors.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ jest.mock('@adobe/aio-lib-runtime', () => ({
let command, logForwarding
beforeEach(async () => {
command = new TheCommand([])
command.config = global.createOclifMockConfig()
command.appConfig = {
aio: {
runtime: {
Expand Down
2 changes: 1 addition & 1 deletion test/commands/app/config/index.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ const { Help } = require('@oclif/core')

test('returns help file for app:config command', () => {
const command = new TheCommand([])
command.config = {}
command.config = global.createOclifMockConfig()
const spy = jest.spyOn(Help.prototype, 'showHelp').mockReturnValue(true)
return command.run().then(() => {
expect(spy).toHaveBeenCalledWith(['app:config', '--help'])
Expand Down
2 changes: 1 addition & 1 deletion test/commands/app/config/set/index.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ const { Help } = require('@oclif/core')

test('returns help file for app:config:set command', () => {
const command = new TheCommand([])
command.config = {}
command.config = global.createOclifMockConfig()
const spy = jest.spyOn(Help.prototype, 'showHelp').mockReturnValue(true)
return command.run().then(() => {
expect(spy).toHaveBeenCalledWith(['app:config:set', '--help'])
Expand Down
1 change: 1 addition & 0 deletions test/commands/app/config/set/log-forwarding.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ beforeEach(async () => {
authHelper.setRuntimeApiHostAndAuthHandler.mockClear()

command = new TheCommand([])
command.config = global.createOclifMockConfig()
command.appConfig = {
aio: {
runtime: {
Expand Down
2 changes: 2 additions & 0 deletions test/commands/app/delete/action.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,7 @@ beforeEach(() => {
fs.removeSync.mockClear()

command = new TheCommand([])
command.config = global.createOclifMockConfig()
command.log = jest.fn()
command.appConfig = cloneDeep(mockConfigData)
command.buildOneExt = jest.fn()
Expand All @@ -101,6 +102,7 @@ describe('command interface, flags', () => {

test('--yes without <action-name>', async () => {
const command = new TheCommand(['--yes'])
command.config = global.createOclifMockConfig()
expect(typeof command.run).toBe('function')
await expect(command.run()).rejects.toThrow('<action-name> must also be provided')
})
Expand Down
1 change: 1 addition & 0 deletions test/commands/app/delete/ci.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ beforeEach(() => {
fs.removeSync.mockClear()
fs.existsSync.mockClear()
command = new TheCommand([])
command.config = global.createOclifMockConfig()
command.prompt = jest.fn()
})

Expand Down
1 change: 1 addition & 0 deletions test/commands/app/delete/extension.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ let command

beforeEach(() => {
command = new TheCommand([])
command.config = global.createOclifMockConfig()

command.getAppExtConfigs = jest.fn()
command.getAppExtConfigs.mockResolvedValue(createAppConfig(command.appConfig))
Expand Down
2 changes: 1 addition & 1 deletion test/commands/app/delete/index.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ describe('instance methods', () => {

test('returns help file for app:delete command', () => {
const spy = jest.spyOn(Help.prototype, 'showHelp').mockReturnValue(true)
command.config = {}
command.config = global.createOclifMockConfig()
return command.run().then(() => {
expect(spy).toHaveBeenCalledWith(['app:delete', '--help'])
})
Expand Down
2 changes: 2 additions & 0 deletions test/commands/app/delete/web-assets.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ describe('bad flags', () => {
let command
beforeEach(() => {
command = new TheCommand([])
command.config = global.createOclifMockConfig()
})
test('unknown', async () => {
command.argv = ['--wtf']
Expand Down Expand Up @@ -68,6 +69,7 @@ describe('bad user selections', () => {
let command
beforeEach(() => {
command = new TheCommand([])
command.config = global.createOclifMockConfig()
command.getAppExtConfigs = jest.fn()
command.appConfig = cloneDeep(mockConfigData)
fs.removeSync.mockClear()
Expand Down
Loading
Loading