Skip to content

Commit f4b69e6

Browse files
authored
chore: update @oclif/core to v4 and migrate ESLint to v9 flat config (#392)
- feat: update @oclif/core to v4 and migrate ESLint to v9 flat config - Upgrade @oclif/core from ^2.8.12 to ^4.0.0 (fixes #391) - Replace removed ux.table with custom src/ux-table.js (ESM-only @oclif/table is incompatible with CJS) - Upgrade @adobe/eslint-config-aio-lib-config to 5.0.0, eslint to ^9.0.0 - Migrate ESLint config from .eslintrc to eslint.config.js (flat config format) - Patch Command.prototype.parse in test setup for oclif v4 config.runHook requirement - Update createTestFlagsFunction to check 'flags' instead of '_flags' (oclif v4 change) - Simplify api/list.js --json flag handling (remove oclif v2 workaround) - Maintain 100% branch/line/statement coverage
1 parent 7d178b5 commit f4b69e6

17 files changed

Lines changed: 318 additions & 79 deletions

File tree

.eslintrc

Lines changed: 0 additions & 22 deletions
This file was deleted.

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,3 +16,4 @@ junit.xml
1616
oclif.manifest.json
1717
.vscode
1818
.idea
19+
.claude

eslint.config.js

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
/*
2+
Copyright 2019 Adobe Inc. All rights reserved.
3+
This file is licensed to you under the Apache License, Version 2.0 (the "License");
4+
you may not use this file except in compliance with the License. You may obtain a copy
5+
of the License at http://www.apache.org/licenses/LICENSE-2.0
6+
7+
Unless required by applicable law or agreed to in writing, software distributed under
8+
the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
9+
OF ANY KIND, either express or implied. See the License for the specific language
10+
governing permissions and limitations under the License.
11+
*/
12+
13+
const aioConfig = require('@adobe/eslint-config-aio-lib-config')
14+
const jestPlugin = require('eslint-plugin-jest')
15+
16+
const testGlobals = {
17+
fixtureFile: 'readonly',
18+
fixtureFileWithTimeZoneAdjustment: 'readonly',
19+
fixtureJson: 'readonly',
20+
fixtureZip: 'readonly',
21+
fakeFileSystem: 'readonly',
22+
createTestBaseFlagsFunction: 'readonly',
23+
createTestFlagsFunction: 'readonly'
24+
}
25+
26+
module.exports = [
27+
...aioConfig,
28+
{
29+
ignores: ['node_modules/**', 'coverage/**']
30+
},
31+
{
32+
rules: {
33+
'jsdoc/tag-lines': ['error', 'never', { startLines: null }]
34+
}
35+
},
36+
{
37+
files: ['test/**/*.js', 'e2e/**/*.js'],
38+
...jestPlugin.configs['flat/recommended'],
39+
languageOptions: {
40+
globals: {
41+
...jestPlugin.configs['flat/recommended'].languageOptions.globals,
42+
...testGlobals
43+
}
44+
}
45+
}
46+
]

package.json

Lines changed: 6 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
"@adobe/aio-lib-env": "^3.0.1",
1414
"@adobe/aio-lib-ims": "^8.0.1",
1515
"@adobe/aio-lib-runtime": "^7.1.0",
16-
"@oclif/core": "^2.8.12",
16+
"@oclif/core": "^4.0.0",
1717
"@types/jest": "^29.5.3",
1818
"chalk": "^4.1.2",
1919
"dayjs": "^1.10.4",
@@ -27,26 +27,21 @@
2727
"sha1": "^1.1.1"
2828
},
2929
"devDependencies": {
30-
"@adobe/eslint-config-aio-lib-config": "^4.0.0",
30+
"@adobe/eslint-config-aio-lib-config": "5.0.0",
3131
"@babel/core": "^7.16.12",
3232
"@babel/preset-env": "^7.16.11",
3333
"babel-jest": "^29.5.0",
3434
"babel-runtime": "^6.26.0",
3535
"dedent-js": "^1.0.1",
3636
"eol": "^0.10.0",
37-
"eslint": "^8.57.1",
38-
"eslint-config-oclif": "^5.2.2",
39-
"eslint-config-standard": "^17.1.0",
40-
"eslint-plugin-import": "^2.31.0",
41-
"eslint-plugin-jest": "^27.9.0",
37+
"eslint": "^9.0.0",
38+
"eslint-plugin-jest": "^29.0.0",
4239
"eslint-plugin-jsdoc": "^48.11.0",
43-
"eslint-plugin-n": "^15.7.0",
44-
"eslint-plugin-node": "^11.1.0",
45-
"eslint-plugin-promise": "^6.6.0",
4640
"execa": "^4.0.0",
4741
"jest": "^29.6.2",
4842
"jest-junit": "^16.0.0",
49-
"oclif": "^3.2.0",
43+
"neostandard": "^0",
44+
"oclif": "^4.0.0",
5045
"stdout-stderr": "^0.1.9"
5146
},
5247
"engines": {

src/commands/runtime/action/list.js

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,8 @@ governing permissions and limitations under the License.
1313
const moment = require('dayjs')
1414
const RuntimeBaseCommand = require('../../../RuntimeBaseCommand')
1515
const { parsePackageName } = require('@adobe/aio-lib-runtime').utils
16-
const { Args, Flags, ux } = require('@oclif/core')
16+
const { Args, Flags } = require('@oclif/core')
17+
const { table } = require('../../../ux-table')
1718
const decorators = require('../../../decorators').decorators()
1819

1920
class ActionList extends RuntimeBaseCommand {
@@ -86,7 +87,7 @@ class ActionList extends RuntimeBaseCommand {
8687
}
8788
}
8889
}
89-
ux.table(result, columns)
90+
table(result, columns)
9091
}
9192
} catch (err) {
9293
await this.handleError('failed to list the actions', err)

src/commands/runtime/activation/list.js

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,8 @@ governing permissions and limitations under the License.
1212

1313
const moment = require('dayjs')
1414
const RuntimeBaseCommand = require('../../../RuntimeBaseCommand')
15-
const { Args, Flags, ux } = require('@oclif/core')
15+
const { Args, Flags } = require('@oclif/core')
16+
const { table } = require('../../../ux-table')
1617
const decorators = require('../../../decorators').decorators()
1718
const statusStrings = ['success', 'app error', 'dev error', 'sys error']
1819

@@ -114,6 +115,7 @@ class ActivationList extends RuntimeBaseCommand {
114115
},
115116
Topmost: {
116117
header: '',
118+
minWidth: 2,
117119
maxWidth: 2,
118120
get: row => {
119121
if (row.annotations && row.annotations.length) {
@@ -187,7 +189,7 @@ class ActivationList extends RuntimeBaseCommand {
187189
}
188190
}
189191
if (listActivation) {
190-
ux.table(listActivation, columns, {
192+
table(listActivation, columns, {
191193
'no-truncate': true
192194
})
193195
}

src/commands/runtime/api/list.js

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,8 @@ governing permissions and limitations under the License.
1010
*/
1111

1212
const RuntimeBaseCommand = require('../../../RuntimeBaseCommand')
13-
const { Args, Flags, ux } = require('@oclif/core')
13+
const { Args, Flags } = require('@oclif/core')
14+
const { table } = require('../../../ux-table')
1415

1516
/** @private */
1617
function processApi (api) {
@@ -40,13 +41,8 @@ function processApi (api) {
4041

4142
class ApiList extends RuntimeBaseCommand {
4243
async run () {
43-
// Workaround for oclif v2 parsing issue: capture argv before parse() when multiple optional args are present
44-
// oclif v2 doesn't properly parse --json flag when command has 3+ optional positional arguments
45-
// Related: https://github.com/oclif/core/issues/854 (workaround: search argv directly)
46-
const argvBeforeParse = [...(this.argv ?? [])]
4744
const { args, flags } = await this.parse(ApiList)
48-
const hasJsonInArgv = argvBeforeParse.includes('--json')
49-
const shouldOutputJson = flags.json || hasJsonInArgv
45+
const shouldOutputJson = flags.json
5046

5147
try {
5248
const ow = await this.wsk()
@@ -74,7 +70,7 @@ class ApiList extends RuntimeBaseCommand {
7470
}, data)
7571
})
7672

77-
ux.table(data, {
73+
table(data, {
7874
Action: { minWidth: 10 },
7975
Verb: { minWidth: 10 },
8076
APIName: { header: 'API Name', minWidth: 10 },

src/commands/runtime/namespace/get.js

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,8 @@ governing permissions and limitations under the License.
1111
*/
1212

1313
const RuntimeBaseCommand = require('../../../RuntimeBaseCommand')
14-
const { Flags, ux } = require('@oclif/core')
14+
const { Flags } = require('@oclif/core')
15+
const { table } = require('../../../ux-table')
1516

1617
/** @private */
1718
function createColumns (columnName) {
@@ -79,10 +80,10 @@ class NamespaceGet extends RuntimeBaseCommand {
7980
} else {
8081
this.log('Entities in namespace:')
8182

82-
ux.table(data.packages, createColumns('packages'))
83-
ux.table(data.actions, createColumns('actions'))
84-
ux.table(data.triggers, createColumns('triggers'))
85-
ux.table(data.rules, createColumns('rules'))
83+
table(data.packages, createColumns('packages'))
84+
table(data.actions, createColumns('actions'))
85+
table(data.triggers, createColumns('triggers'))
86+
table(data.rules, createColumns('rules'))
8687
}
8788
} catch (err) {
8889
await this.handleError('failed to get the data for a namespace', err)

src/commands/runtime/namespace/list.js

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,8 @@ governing permissions and limitations under the License.
1111
*/
1212

1313
const RuntimeBaseCommand = require('../../../RuntimeBaseCommand')
14-
const { Flags, ux } = require('@oclif/core')
14+
const { Flags } = require('@oclif/core')
15+
const { table } = require('../../../ux-table')
1516

1617
class NamespaceList extends RuntimeBaseCommand {
1718
async run () {
@@ -29,7 +30,7 @@ class NamespaceList extends RuntimeBaseCommand {
2930
get: row => row
3031
}
3132
}
32-
ux.table(result, columns)
33+
table(result, columns)
3334
}
3435
} catch (err) {
3536
await this.handleError('failed to list namespaces', err)

src/commands/runtime/package/list.js

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,8 @@ governing permissions and limitations under the License.
1212

1313
const moment = require('dayjs')
1414
const RuntimeBaseCommand = require('../../../RuntimeBaseCommand')
15-
const { Args, Flags, ux } = require('@oclif/core')
15+
const { Args, Flags } = require('@oclif/core')
16+
const { table } = require('../../../ux-table')
1617

1718
class PackageList extends RuntimeBaseCommand {
1819
async run () {
@@ -78,7 +79,7 @@ class PackageList extends RuntimeBaseCommand {
7879
get: row => row.name
7980
}
8081
}
81-
ux.table(result, columns)
82+
table(result, columns)
8283
}
8384
} catch (err) {
8485
await this.handleError('failed to list the packages', err)

0 commit comments

Comments
 (0)