From d92984def0442b247848e3527527f35f1a2abbbe Mon Sep 17 00:00:00 2001 From: "Benjamin E. Coe" Date: Thu, 4 Jan 2024 10:59:08 -0500 Subject: [PATCH 1/4] 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', From 136a79a840dc36697a535a4bbb5cc8d7fae65cc2 Mon Sep 17 00:00:00 2001 From: John Gee Date: Fri, 5 Jan 2024 05:55:22 +1300 Subject: [PATCH 2/4] docs: fix typos in .terminalWidth example (#2382) Co-authored-by: Benjamin E. Coe --- docs/typescript.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/docs/typescript.md b/docs/typescript.md index 2086c45e7..d3f10d8aa 100644 --- a/docs/typescript.md +++ b/docs/typescript.md @@ -131,8 +131,8 @@ import { hideBin } from 'yargs/helpers'; const yargsInstance = yargs(hideBin(process.argv)); -cosnt args = yargsInstance - .wrap(myYargs.terminalWidth()) +const args = yargsInstance + .wrap(yargsInstance.terminalWidth()) // .otherMethods(...) .argv From 9bb4d6ea10303eec00d64d8d3cb2d801b853d72a Mon Sep 17 00:00:00 2001 From: "renovate[bot]" <29139614+renovate[bot]@users.noreply.github.com> Date: Fri, 5 Jan 2024 11:17:11 -0500 Subject: [PATCH 3/4] chore(deps): update dependency @types/node to v20 (#2370) Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com> --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 58e19d154..ca14983cd 100644 --- a/package.json +++ b/package.json @@ -65,7 +65,7 @@ "@rollup/plugin-terser": "^0.4.4", "@types/chai": "^4.2.11", "@types/mocha": "^9.0.0", - "@types/node": "^18.0.0", + "@types/node": "^20.0.0", "browserslist-generator": "^2.0.1", "c8": "^9.0.0", "chai": "^4.2.0", From 4266485b20e9b0f3a7f196e84c6d8284b04642cd Mon Sep 17 00:00:00 2001 From: Omer M <125453822+mendlero@users.noreply.github.com> Date: Fri, 5 Jan 2024 18:23:42 +0200 Subject: [PATCH 4/4] feat(locale): adds hebrew translation (#2357) --- docs/api.md | 6 +++++- locales/he.json | 55 +++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 60 insertions(+), 1 deletion(-) create mode 100644 locales/he.json diff --git a/docs/api.md b/docs/api.md index 2762bb04d..2a7ac4d29 100644 --- a/docs/api.md +++ b/docs/api.md @@ -1047,10 +1047,13 @@ Ye be havin' to set the followin' argument land lubber: option Locales currently supported: * **be:** Belarusian. +* **cs:** Czech. * **de:** German. * **en:** American English. * **es:** Spanish. +* **fi:** Finnish. * **fr:** French. +* **he:** Hebrew. * **hi:** Hindi. * **hu:** Hungarian. * **id:** Indonesian. @@ -1065,9 +1068,10 @@ Locales currently supported: * **pt:** Portuguese. * **pt_BR:** Brazilian Portuguese. * **ru:** Russian. -* **uz:** Uzbek. * **th:** Thai. * **tr:** Turkish. +* **uk_UA:** Ukrainian (Ukraine). +* **uz:** Uzbek. * **zh_CN:** Chinese (Mainland China). * **zh_TW:** Chinese (Taiwan). diff --git a/locales/he.json b/locales/he.json new file mode 100644 index 000000000..947cc8870 --- /dev/null +++ b/locales/he.json @@ -0,0 +1,55 @@ +{ + "Commands:": "פקודות:", + "Options:": "אופציות:", + "Examples:": "דוגמות:", + "boolean": "בוליאני", + "count": "ספירה", + "string": "מחרוזת", + "number": "מספר", + "array": "מערך", + "required": "דרוש", + "default": "ברירת מחדל", + "default:": "ברירת מחדל:", + "choices:": "בחירות:", + "aliases:": "כינויים:", + "generated-value": "ערך-שנוצר", + "Not enough non-option arguments: got %s, need at least %s": { + "one": "אין מספיק טיעונים שאינם אופציונלים: קיבל %s, צריך לפחות %s", + "other": "אין מספיק טיעונים שאינם אופציונלים: קיבל %s, צריך לפחות %s" + }, + "Too many non-option arguments: got %s, maximum of %s": { + "one": "יותר מדי טיעונים שאינם אופציונלים: קיבל %s, מקסימום של %s", + "other": "יותר מדי טיעונים שאינם אופציונלים: קיבל %s, מקסימום של %s" + }, + "Missing argument value: %s": { + "one": "חסר ערך הטענה: %s", + "other": "חסרים ערכי הטענה: %s" + }, + "Missing required argument: %s": { + "one": "חסר טענה דרושה: %s", + "other": "חסרות טענות דרושות: %s" + }, + "Unknown argument: %s": { + "one": "טענה לא ידוע: %s", + "other": "טענות לא ידועות: %s" + }, + "Unknown command: %s": { + "one": "פקודת לא ידועה: %s", + "other": "פקודות לא ידועות: %s" + }, + "Invalid values:": "ערכים לא חוקיים:", + "Argument: %s, Given: %s, Choices: %s": "טענות: %s, ניתנו: %s, בחירות: %s", + "Argument check failed: %s": "בדיקת הטענה נכשלה: %s", + "Implications failed:": "חסרים טיעונים תלויים:", + "Not enough arguments following: %s": "אין מספיק טיעונים לאחר: %s", + "Invalid JSON config file: %s": "קובץ תצורה לא תקין של JSON: %s", + "Path to JSON config file": "נתיב לקובץ התצורה של JSON", + "Show help": "הצג עזרה", + "Show version number": "הצג מספר גרסה", + "Did you mean %s?": "האם התכוונת ל- %s?", + "Arguments %s and %s are mutually exclusive" : "טענות %s ו- %s סותרים זה את זה", + "Positionals:": "עמדות:", + "command": "פקודה", + "deprecated": "הוצא משימוש", + "deprecated: %s": "הוצא משימוש: %s" +}