From d92984def0442b247848e3527527f35f1a2abbbe Mon Sep 17 00:00:00 2001 From: "Benjamin E. Coe" Date: Thu, 4 Jan 2024 10:59:08 -0500 Subject: [PATCH] fix(build): update typescript / eslint / rollup deps fixing bundling of yargs (#2384) build(node)!: require Node >= 16.15.1 --- .github/workflows/ci.yaml | 20 ++++++++++---------- .github/workflows/release-please.yml | 5 ++--- lib/argsert.ts | 2 +- lib/middleware.ts | 7 ++++--- lib/usage.ts | 8 ++++---- lib/yargs-factory.ts | 27 +++++++++++++++------------ package.json | 21 +++++++++++---------- rollup.config.cjs | 2 +- 8 files changed, 48 insertions(+), 44 deletions(-) diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index c80a0ea91..efe145087 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -13,13 +13,13 @@ jobs: runs-on: ubuntu-latest strategy: matrix: - node: [12, 14, 16] + node: [16, 18, 20] steps: - uses: actions/checkout@v1 - uses: actions/setup-node@v1 with: node-version: ${{ matrix.node }} - - run: npm install -g npm@7 + - run: npm install -g npm@8 - run: node --version - run: npm install --engine-strict - run: npm test @@ -29,21 +29,21 @@ jobs: - uses: actions/checkout@v2 - uses: actions/setup-node@v1 with: - node-version: 12 - - run: npm install -g npm@7 + node-version: 20 + - run: npm install -g npm@8 - run: npm install - run: npm test esm: runs-on: ubuntu-latest strategy: matrix: - node: [14] + node: [20] steps: - uses: actions/checkout@v1 - uses: actions/setup-node@v1 with: node-version: ${{ matrix.node }} - - run: npm install -g npm@7 + - run: npm install -g npm@8 - run: node --version - run: npm install --engine-strict - run: npm run test:esm @@ -53,8 +53,8 @@ jobs: - uses: actions/checkout@v2 - uses: actions/setup-node@v1 with: - node-version: 14 - - run: npm install -g npm@7 + node-version: 20 + - run: npm install -g npm@8 - run: npm install - run: npm run compile - uses: denoland/setup-deno@v1 @@ -69,8 +69,8 @@ jobs: - uses: actions/checkout@v1 - uses: actions/setup-node@v1 with: - node-version: 15 - - run: npm install -g npm@7 + node-version: 20 + - run: npm install -g npm@8 - run: npm install - run: npm test - run: npm run coverage diff --git a/.github/workflows/release-please.yml b/.github/workflows/release-please.yml index ce806bd7d..ec36b4e21 100644 --- a/.github/workflows/release-please.yml +++ b/.github/workflows/release-please.yml @@ -12,16 +12,15 @@ jobs: runs-on: ubuntu-latest steps: - - uses: google-github-actions/release-please-action@v3 + - uses: google-github-actions/release-please-action@v4 id: release with: token: ${{ secrets.GITHUB_TOKEN }} release-type: node - package-name: yargs - uses: actions/checkout@v2 - uses: actions/setup-node@v1 with: - node-version: 14 + node-version: 20 - run: npm install npm@latest -g - run: npm install - run: npm run compile diff --git a/lib/argsert.ts b/lib/argsert.ts index f2c2351af..7d8977a86 100644 --- a/lib/argsert.ts +++ b/lib/argsert.ts @@ -16,7 +16,7 @@ export function argsert( function parseArgs(): [ Pick, any[], - number? + number?, ] { return typeof arg1 === 'object' ? [{demanded: [], optional: []}, arg1, arg2 as number | undefined] diff --git a/lib/middleware.ts b/lib/middleware.ts index 940d5cea0..2e536e02b 100644 --- a/lib/middleware.ts +++ b/lib/middleware.ts @@ -119,9 +119,10 @@ export function applyMiddleware( } export interface MiddlewareCallback { - (argv: Arguments, yargs: YargsInstance): - | Partial - | Promise>; + ( + argv: Arguments, + yargs: YargsInstance + ): Partial | Promise>; } export interface Middleware extends MiddlewareCallback { diff --git a/lib/usage.ts b/lib/usage.ts index c1189e153..13b46a6b1 100644 --- a/lib/usage.ts +++ b/lib/usage.ts @@ -363,8 +363,8 @@ export function usage(yargs: YargsInstance, shim: PlatformShim) { ? '-' : '--' : sw.length > 1 - ? '--' - : '-') + sw + ? '--' + : '-') + sw ); } }) @@ -373,8 +373,8 @@ export function usage(yargs: YargsInstance, shim: PlatformShim) { isLongSwitch(sw1) === isLongSwitch(sw2) ? 0 : isLongSwitch(sw1) - ? 1 - : -1 + ? 1 + : -1 ) .join(', '); diff --git a/lib/yargs-factory.ts b/lib/yargs-factory.ts index 1d58fdf33..6545500e5 100644 --- a/lib/yargs-factory.ts +++ b/lib/yargs-factory.ts @@ -1656,7 +1656,7 @@ export class YargsInstance { | Exclude, DictionaryKeyof> | 'default', K extends keyof Options[T] & string = keyof Options[T] & string, - V extends ValueOf = ValueOf + V extends ValueOf = ValueOf, >( builder: (key: K, value: V, ...otherArgs: any[]) => YargsInstance, type: T, @@ -1678,7 +1678,7 @@ export class YargsInstance { K extends keyof Options[T] & string = keyof Options[T] & string, V extends ValueOf> | ValueOf>[] = | ValueOf> - | ValueOf>[] + | ValueOf>[], >( builder: (key: K, value: V, ...otherArgs: any[]) => YargsInstance, type: T, @@ -1700,7 +1700,7 @@ export class YargsInstance { [kPopulateParserHintDictionary]< T extends keyof Options, K extends keyof Options[T], - V + V, >( builder: (key: K, value: V, ...otherArgs: any[]) => YargsInstance, type: T, @@ -1876,15 +1876,18 @@ export class YargsInstance { // add all groups not set to local to preserved groups Object.assign( this.#preservedGroups, - Object.keys(this.#groups).reduce((acc, groupName) => { - const keys = this.#groups[groupName].filter( - key => !(key in localLookup) - ); - if (keys.length > 0) { - acc[groupName] = keys; - } - return acc; - }, {} as Dictionary) + Object.keys(this.#groups).reduce( + (acc, groupName) => { + const keys = this.#groups[groupName].filter( + key => !(key in localLookup) + ); + if (keys.length > 0) { + acc[groupName] = keys; + } + return acc; + }, + {} as Dictionary + ) ); // groups can now be reset this.#groups = {}; diff --git a/package.json b/package.json index a7a4db60a..58e19d154 100644 --- a/package.json +++ b/package.json @@ -62,27 +62,28 @@ "yargs-parser": "^21.1.1" }, "devDependencies": { + "@rollup/plugin-terser": "^0.4.4", "@types/chai": "^4.2.11", "@types/mocha": "^9.0.0", "@types/node": "^18.0.0", - "c8": "^7.7.0", + "browserslist-generator": "^2.0.1", + "c8": "^9.0.0", "chai": "^4.2.0", "chalk": "^4.0.0", "concurrently": "^7.6.0", - "coveralls": "^3.0.9", "cpr": "^3.0.1", "cross-env": "^7.0.2", "cross-spawn": "^7.0.0", - "eslint": "^7.23.0", - "gts": "^3.0.0", + "eslint": "^8.56.0", + "eslint-plugin-prettier": "^5.1.2", + "gts": "^5.2.0", "hashish": "0.0.4", "mocha": "^9.0.0", "rimraf": "^3.0.2", - "rollup": "^2.23.0", - "rollup-plugin-cleanup": "^3.1.1", - "rollup-plugin-terser": "^7.0.2", - "rollup-plugin-ts": "^2.0.4", - "typescript": "^4.0.2", + "rollup": "^3.29.4", + "rollup-plugin-cleanup": "^3.2.1", + "rollup-plugin-ts": "^3.4.5", + "typescript": "^5.3.3", "which": "^2.0.0", "yargs-test-extends": "^1.0.1" }, @@ -122,6 +123,6 @@ ], "license": "MIT", "engines": { - "node": ">=12" + "node": ">=16.15.1" } } diff --git a/rollup.config.cjs b/rollup.config.cjs index 7999869c6..17b2fa85e 100644 --- a/rollup.config.cjs +++ b/rollup.config.cjs @@ -1,6 +1,6 @@ const cleanup = require('rollup-plugin-cleanup'); const ts = require('rollup-plugin-ts'); -const {terser} = require('rollup-plugin-terser'); +const terser = require('@rollup/plugin-terser'); const output = { format: 'cjs',