Skip to content

Commit a445738

Browse files
authored
chore: upgrade @oclif/core to v4 and eslint-config to v5 (#241)
- chore: upgrade @oclif/core to v4 and @adobe/eslint-config-aio-lib-config to v5 - Bump @oclif/core from ^2 to ^4 - Replace ux.table() (removed in v4) with a custom table utility that replicates the same output format (src/utils/table.js) - Patch Command.prototype.parse in jest setup to provide a mock config.runHook, required by @oclif/core v4 when commands are instantiated directly in tests - Upgrade @adobe/eslint-config-aio-lib-config from v4 to v5 (ESLint 9 flat config) - Replace .eslintrc.json with eslint.config.js using new flat config format - Upgrade eslint from ^8 to ^9 and eslint-plugin-jest to ^29 - Add neostandard as peer dependency; remove eslint-plugin-node, eslint-config-standard, eslint-plugin-import, eslint-plugin-n, eslint-plugin-promise (all superseded by neostandard) - Remove stale eslint-disable directives obsoleted by the new config
1 parent 06805bd commit a445738

14 files changed

Lines changed: 180 additions & 47 deletions

File tree

.eslintrc.json

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

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,3 +11,4 @@ node_modules
1111
.DS_Store
1212

1313
oclif.manifest.json
14+
.claude

eslint.config.js

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
/*
2+
Copyright 2020 Adobe. 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 aioLibConfig = require('@adobe/eslint-config-aio-lib-config')
14+
const jest = require('eslint-plugin-jest')
15+
16+
module.exports = [
17+
...aioLibConfig,
18+
jest.configs['flat/recommended'],
19+
{
20+
files: ['test/**/*.js'],
21+
...jest.configs['flat/recommended'],
22+
languageOptions: {
23+
globals: jest.environments.globals.globals
24+
}
25+
}
26+
]

package.json

Lines changed: 5 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -10,31 +10,26 @@
1010
"@adobe/aio-lib-core-logging": "^3",
1111
"@adobe/aio-lib-env": "^3",
1212
"@adobe/aio-lib-ims": "^7",
13-
"@oclif/core": "^2.0.0",
13+
"@oclif/core": "^4.0.0",
1414
"js-yaml": "^4.1.0",
1515
"open": "^10.2.0"
1616
},
1717
"devDependencies": {
18-
"@adobe/eslint-config-aio-lib-config": "^4.0.0",
18+
"@adobe/eslint-config-aio-lib-config": "5.0.0",
1919
"@babel/core": "^7.9.6",
2020
"@types/jest": "^29.5.3",
2121
"babel-jest": "^29.6.1",
2222
"babel-runtime": "^6.26.0",
2323
"chalk": "^4.0.0",
2424
"eol": "^0.9.1",
25-
"eslint": "^8.57.1",
26-
"eslint-config-oclif": "^5.2.2",
27-
"eslint-config-standard": "^17.1.0",
28-
"eslint-plugin-import": "^2.31.0",
29-
"eslint-plugin-jest": "^27.9.0",
25+
"eslint": "^9",
26+
"eslint-plugin-jest": "^29",
3027
"eslint-plugin-jsdoc": "^48.11.0",
31-
"eslint-plugin-n": "^15.7.0",
32-
"eslint-plugin-node": "^11.1.0",
33-
"eslint-plugin-promise": "^6.6.0",
3428
"execa": "^9.5.2",
3529
"jest": "^29",
3630
"jest-haste-map": "^29.6.1",
3731
"jest-junit": "^16.0.0",
32+
"neostandard": "^0",
3833
"oclif": "^4.17.13",
3934
"stdout-stderr": "^0.1.9"
4035
},

src/commands/console/open.js

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,6 @@ class OpenCommand extends ConsoleCommand {
3131
}
3232
}
3333
aioLogger.debug(`opening url ${url}`)
34-
// eslint-disable-next-line node/no-unsupported-features/es-syntax
3534
const { default: open } = await import('open')
3635
open(url)
3736
}

src/commands/console/org/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 aioConsoleLogger = require('@adobe/aio-lib-core-logging')('@adobe/aio-cli-plugin-console:org:list', { provider: 'debug' })
14-
const { Flags, ux } = require('@oclif/core')
14+
const { Flags } = require('@oclif/core')
15+
const { table } = require('../../../utils/table')
1516
const { ORG_TYPE_ENTERPRISE } = require('../../../config')
1617

1718
const ConsoleCommand = require('../index')
@@ -73,7 +74,7 @@ class ListCommand extends ConsoleCommand {
7374
header: 'Org Name'
7475
}
7576
}
76-
ux.table(orgs, columns)
77+
table(orgs, columns)
7778
}
7879
}
7980

src/commands/console/project/list.js

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,8 @@ OF ANY KIND, either express or implied. See the License for the specific languag
1010
governing permissions and limitations under the License.
1111
*/
1212
const aioConsoleLogger = require('@adobe/aio-lib-core-logging')('@adobe/aio-cli-plugin-console:project:list', { provider: 'debug' })
13-
const { Flags, ux } = require('@oclif/core')
13+
const { Flags } = require('@oclif/core')
14+
const { table } = require('../../../utils/table')
1415
const ConsoleCommand = require('../index')
1516

1617
class ListCommand extends ConsoleCommand {
@@ -67,7 +68,7 @@ class ListCommand extends ConsoleCommand {
6768
header: 'Title'
6869
}
6970
}
70-
ux.table(projects, columns)
71+
table(projects, columns)
7172
}
7273
}
7374

src/commands/console/publickey/index.js

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,8 @@ OF ANY KIND, either express or implied. See the License for the specific languag
99
governing permissions and limitations under the License.
1010
*/
1111

12-
const { Help, ux } = require('@oclif/core')
12+
const { Help } = require('@oclif/core')
13+
const { table } = require('../../../utils/table')
1314
const ConsoleCommand = require('../')
1415

1516
class IndexCommand extends ConsoleCommand {
@@ -47,7 +48,7 @@ IndexCommand.printBindings = function (bindings) {
4748
decorated.expiresString = binding.notAfter ? this.formatExpiry(binding.notAfter) : ''
4849
decorateds.push(decorated)
4950
})
50-
ux.table(decorateds, columns)
51+
table(decorateds, columns)
5152
}
5253

5354
/**

src/commands/console/workspace/list.js

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,8 @@ the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTA
99
OF ANY KIND, either express or implied. See the License for the specific language
1010
governing permissions and limitations under the License.
1111
*/
12-
const { Flags, ux } = require('@oclif/core')
12+
const { Flags } = require('@oclif/core')
13+
const { table } = require('../../../utils/table')
1314
const { CONFIG_KEYS } = require('../../../config')
1415

1516
const ConsoleCommand = require('../index')
@@ -44,7 +45,7 @@ class ListCommand extends ConsoleCommand {
4445
this.printYaml(workspaces)
4546
} else {
4647
// print formatted result
47-
ux.table(workspaces, {
48+
table(workspaces, {
4849
id: {
4950
minWidth: 25
5051
},

src/utils/table.js

Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
/*
2+
Copyright 2026 Adobe. 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+
/**
14+
* Print a table to stdout, replicating the ux.table output format from @oclif/core v2.
15+
* Required because ux.table was removed in @oclif/core v4.
16+
*
17+
* @param {Array<object>} data Array of row objects
18+
* @param {object} columns Column definitions keyed by object property name.
19+
* Each column may have: header (string), minWidth (number)
20+
* @param {object} [options] Options
21+
* @param {Function} [options.printLine] Function to print each line (defaults to process.stdout.write)
22+
*/
23+
function table (data, columns, options = {}) {
24+
const printLine = options.printLine || ((line) => process.stdout.write(line + '\n'))
25+
26+
const cols = Object.entries(columns).map(([key, opts]) => {
27+
const header = opts.header || capitalize(key)
28+
const minContentWidth = opts.minWidth ? opts.minWidth - 1 : 0
29+
const maxDataWidth = data.reduce((max, row) => {
30+
const val = String(row[key] === undefined || row[key] === null ? '' : row[key])
31+
return Math.max(max, val.length)
32+
}, 0)
33+
const width = Math.max(header.length, maxDataWidth, minContentWidth)
34+
return { key, header, width }
35+
})
36+
37+
// Header row
38+
printLine(cols.map(col => ' ' + col.header.padEnd(col.width)).join('') + ' ')
39+
40+
// Separator row
41+
printLine(cols.map(col => ' ' + '\u2500'.repeat(col.width)).join('') + ' ')
42+
43+
// Data rows
44+
for (const row of data) {
45+
printLine(cols.map(col => {
46+
const val = String(row[col.key] === undefined || row[col.key] === null ? '' : row[col.key])
47+
return ' ' + val.padEnd(col.width)
48+
}).join('') + ' ')
49+
}
50+
}
51+
52+
/**
53+
* Capitalize the first letter of a string.
54+
*
55+
* @param {string} str input string
56+
* @returns {string} string with first letter uppercased
57+
*/
58+
function capitalize (str) {
59+
return str.charAt(0).toUpperCase() + str.slice(1)
60+
}
61+
62+
module.exports = { table }

0 commit comments

Comments
 (0)