From cebcfbe1d9ee0c4c4e4b7ac14645bf7845c48cb1 Mon Sep 17 00:00:00 2001 From: Paul Gschwendtner Date: Sun, 26 Sep 2021 12:29:54 +0200 Subject: [PATCH] refactor: update yargs to new API for ESM compatibility (#43431) Given that we ship all of compiler-cli and localize in ESM mode now, we need to use a ESM compatible version of Yargs. The latest version seems ESM compatible but with some small API changes. This commit updates Yargs and updates the command line option code to use the new API. PR Close #43431 --- package.json | 4 ++-- packages/compiler-cli/ngcc/src/command_line_options.ts | 4 ++-- packages/compiler-cli/package.json | 2 +- packages/localize/package.json | 2 +- packages/localize/tools/src/extract/cli.ts | 4 ++-- packages/localize/tools/src/migrate/cli.ts | 4 ++-- packages/localize/tools/src/translate/cli.ts | 4 ++-- yarn.lock | 10 +++++----- 8 files changed, 17 insertions(+), 17 deletions(-) diff --git a/package.json b/package.json index 9829c54549a..5bd4c0d87df 100644 --- a/package.json +++ b/package.json @@ -97,7 +97,7 @@ "@types/shelljs": "^0.8.6", "@types/systemjs": "0.19.32", "@types/uuid": "^8.3.1", - "@types/yargs": "^16.0.1", + "@types/yargs": "^17.0.3", "@webcomponents/custom-elements": "^1.1.0", "angular-1.5": "npm:angular@1.5", "angular-1.6": "npm:angular@1.6", @@ -161,7 +161,7 @@ "tslint": "6.1.3", "typescript": "~4.4.2", "xhr2": "0.2.1", - "yargs": "^17.0.0" + "yargs": "^17.2.1" }, "// 2": "devDependencies are not used under Bazel. Many can be removed after test.sh is deleted.", "devDependencies": { diff --git a/packages/compiler-cli/ngcc/src/command_line_options.ts b/packages/compiler-cli/ngcc/src/command_line_options.ts index e0ceae5ab5e..5c8cb4c6fed 100644 --- a/packages/compiler-cli/ngcc/src/command_line_options.ts +++ b/packages/compiler-cli/ngcc/src/command_line_options.ts @@ -14,7 +14,7 @@ import {NgccOptions} from './ngcc_options'; export function parseCommandLineOptions(args: string[]): NgccOptions { const options = - yargs + yargs(args) .option('s', { alias: 'source', describe: @@ -114,7 +114,7 @@ export function parseCommandLineOptions(args: string[]): NgccOptions { }) .strict() .help() - .parse(args); + .parseSync(); if (options.f?.length) { console.error( diff --git a/packages/compiler-cli/package.json b/packages/compiler-cli/package.json index a9d5b1577bd..3ba2282aac9 100644 --- a/packages/compiler-cli/package.json +++ b/packages/compiler-cli/package.json @@ -61,7 +61,7 @@ "source-map": "^0.6.1", "sourcemap-codec": "^1.4.8", "tslib": "^2.3.0", - "yargs": "^17.0.0" + "yargs": "^17.2.1" }, "peerDependencies": { "@angular/compiler": "0.0.0-PLACEHOLDER", diff --git a/packages/localize/package.json b/packages/localize/package.json index 9b4e83f2c40..87fdde531bb 100644 --- a/packages/localize/package.json +++ b/packages/localize/package.json @@ -36,7 +36,7 @@ "dependencies": { "@babel/core": "7.8.6", "glob": "7.2.0", - "yargs": "^17.0.0" + "yargs": "^17.2.1" }, "peerDependencies": { "@angular/compiler": "0.0.0-PLACEHOLDER", diff --git a/packages/localize/tools/src/extract/cli.ts b/packages/localize/tools/src/extract/cli.ts index bd90d2e2ccd..12235bef1f9 100644 --- a/packages/localize/tools/src/extract/cli.ts +++ b/packages/localize/tools/src/extract/cli.ts @@ -18,7 +18,7 @@ import {extractTranslations} from './index'; process.title = 'Angular Localization Message Extractor (localize-extract)'; const args = process.argv.slice(2); const options = - yargs + yargs(args) .option('l', { alias: 'locale', describe: 'The locale of the source being processed', @@ -88,7 +88,7 @@ const options = }) .strict() .help() - .parse(args); + .parseSync(); const fileSystem = new NodeJSFileSystem(); setFileSystem(fileSystem); diff --git a/packages/localize/tools/src/migrate/cli.ts b/packages/localize/tools/src/migrate/cli.ts index 18540490ec2..cb94b448dad 100644 --- a/packages/localize/tools/src/migrate/cli.ts +++ b/packages/localize/tools/src/migrate/cli.ts @@ -14,7 +14,7 @@ import {migrateFiles} from './index'; const args = process.argv.slice(2); const options = - yargs + yargs(args) .option('r', { alias: 'root', default: '.', @@ -38,7 +38,7 @@ const options = }) .strict() .help() - .parse(args); + .parseSync(); const fs = new NodeJSFileSystem(); setFileSystem(fs); diff --git a/packages/localize/tools/src/translate/cli.ts b/packages/localize/tools/src/translate/cli.ts index 0282c1df608..8e20bc77fea 100644 --- a/packages/localize/tools/src/translate/cli.ts +++ b/packages/localize/tools/src/translate/cli.ts @@ -17,7 +17,7 @@ import {translateFiles} from './index'; process.title = 'Angular Localization Message Translator (localize-translate)'; const args = process.argv.slice(2); const options = - yargs + yargs(args) .option('r', { alias: 'root', required: true, @@ -88,7 +88,7 @@ const options = .strict() .help() - .parse(args); + .parseSync(); const fs = new NodeJSFileSystem(); setFileSystem(fs); diff --git a/yarn.lock b/yarn.lock index e52afaa30a9..98970946f39 100644 --- a/yarn.lock +++ b/yarn.lock @@ -2331,10 +2331,10 @@ resolved "https://registry.yarnpkg.com/@types/yargs-parser/-/yargs-parser-20.2.1.tgz#3b9ce2489919d9e4fea439b76916abc34b2df129" integrity sha512-7tFImggNeNBVMsn0vLrpn1H1uPrUBdnARPTpZoitY37ZrdJREzf7I16tMrlK3hen349gr1NYh8CmZQa7CTG6Aw== -"@types/yargs@^16.0.1": - version "16.0.4" - resolved "https://registry.yarnpkg.com/@types/yargs/-/yargs-16.0.4.tgz#26aad98dd2c2a38e421086ea9ad42b9e51642977" - integrity sha512-T8Yc9wt/5LbJyCaLiHPReJa0kApcIgJ7Bn735GjItUfh08Z1pJvu8QZqb9s+mMvKV6WUQRV7K2R46YbjMXTTJw== +"@types/yargs@^17.0.3": + version "17.0.3" + resolved "https://registry.yarnpkg.com/@types/yargs/-/yargs-17.0.3.tgz#e6c552aa3277b21a8e802019d03ee5e77894cf27" + integrity sha512-K7rm3Ke3ag/pAniBe80A6J6fjoqRibvCrl3dRmtXV9eCEt9h/pZwmHX9MzjQVUc/elneQTL4Ky7XKorC71Lmxw== dependencies: "@types/yargs-parser" "*" @@ -13948,7 +13948,7 @@ yargs@^16.0.0, yargs@^16.1.1, yargs@^16.2.0: y18n "^5.0.5" yargs-parser "^20.2.2" -yargs@^17.0.0: +yargs@^17.0.0, yargs@^17.2.1: version "17.2.1" resolved "https://registry.yarnpkg.com/yargs/-/yargs-17.2.1.tgz#e2c95b9796a0e1f7f3bf4427863b42e0418191ea" integrity sha512-XfR8du6ua4K6uLGm5S6fA+FIJom/MdJcFNVY8geLlp2v8GYbOXD4EB1tPNZsRn4vBzKGMgb5DRZMeWuFc2GO8Q==