Skip to content

Commit

Permalink
chore(core): update yargs to 17.4.0 (#9511)
Browse files Browse the repository at this point in the history
  • Loading branch information
FrozenPandaz committed Mar 28, 2022
1 parent 3acced0 commit 8b0f9d2
Show file tree
Hide file tree
Showing 13 changed files with 65 additions and 42 deletions.
6 changes: 3 additions & 3 deletions package.json
Expand Up @@ -112,7 +112,7 @@
"@types/react-router-dom": "5.1.7",
"@types/semver": "^7.3.8",
"@types/tmp": "^0.2.0",
"@types/yargs": "^15.0.5",
"@types/yargs": "^17.0.10",
"@typescript-eslint/eslint-plugin": "5.10.1",
"@typescript-eslint/experimental-utils": "5.10.1",
"@typescript-eslint/parser": "5.10.1",
Expand Down Expand Up @@ -254,8 +254,8 @@
"webpack-sources": "^3.0.2",
"webpack-subresource-integrity": "^5.1.0",
"xstate": "^4.25.0",
"yargs": "15.4.1",
"yargs-parser": "20.0.0",
"yargs": "^17.4.0",
"yargs-parser": "21.0.1",
"zone.js": "~0.11.4"
},
"author": "Victor Savkin",
Expand Down
2 changes: 1 addition & 1 deletion packages/add-nx-to-monorepo/package.json
Expand Up @@ -33,6 +33,6 @@
"@nrwl/devkit": "*",
"nx": "*",
"enquirer": "~2.3.6",
"yargs-parser": "20.0.0"
"yargs-parser": "21.0.1"
}
}
2 changes: 1 addition & 1 deletion packages/cra-to-nx/package.json
Expand Up @@ -26,6 +26,6 @@
"@nrwl/devkit": "*",
"nx": "*",
"fs-extra": "^9.1.0",
"yargs-parser": "^20.0.0"
"yargs-parser": "21.0.1"
}
}
2 changes: 1 addition & 1 deletion packages/create-nx-plugin/package.json
Expand Up @@ -33,6 +33,6 @@
"enquirer": "~2.3.6",
"fs-extra": "^9.1.0",
"tmp": "~0.2.1",
"yargs-parser": "20.0.0"
"yargs-parser": "21.0.1"
}
}
2 changes: 1 addition & 1 deletion packages/create-nx-workspace/package.json
Expand Up @@ -29,7 +29,7 @@
"homepage": "https://nx.dev",
"dependencies": {
"tmp": "~0.2.1",
"yargs-parser": "20.0.0",
"yargs-parser": "21.0.1",
"enquirer": "~2.3.6",
"flat": "^5.0.2",
"chalk": "4.1.0",
Expand Down
4 changes: 2 additions & 2 deletions packages/make-angular-cli-faster/package.json
Expand Up @@ -33,7 +33,7 @@
"nx": "*",
"semver": "7.3.4",
"tmp": "~0.2.1",
"yargs": "15.4.1",
"yargs-parser": "20.0.0"
"yargs": "^17.4.0",
"yargs-parser": "21.0.1"
}
}
5 changes: 4 additions & 1 deletion packages/nx/bin/init-local.ts
Expand Up @@ -58,7 +58,10 @@ function wrapIntoQuotesIfNeeded(arg: string) {
function isKnownCommand() {
const commands = [
...Object.keys(
(commandsObject as any).getCommandInstance().getCommandHandlers()
(commandsObject as any)
.getInternalMethods()
.getCommandInstance()
.getCommandHandlers()
),
'g',
'dep-graph',
Expand Down
4 changes: 2 additions & 2 deletions packages/nx/package.json
Expand Up @@ -52,8 +52,8 @@
"rxjs": "^6.5.4",
"semver": "7.3.4",
"tmp": "~0.2.1",
"yargs": "15.4.1",
"yargs-parser": "20.0.0",
"yargs": "^17.4.0",
"yargs-parser": "21.0.1",
"chalk": "4.1.0",
"flat": "^5.0.2",
"minimatch": "3.0.4",
Expand Down
41 changes: 25 additions & 16 deletions packages/nx/src/command-line/nx-commands.ts
Expand Up @@ -6,7 +6,6 @@ import { generateDaemonHelpOutput } from '../core/project-graph/daemon/client/ge
import { nxVersion } from '../utils/versions';
import { examples } from './examples';
import { appRootPath } from 'nx/src/utils/app-root';
import type { ListArgs } from './list';
import { getPackageManagerCommand } from '../utils/package-manager';
import { writeJsonFile } from 'nx/src/utils/fileutils';

Expand Down Expand Up @@ -45,6 +44,8 @@ ${daemonHelpOutput}
aliases: ['g'],
builder: (yargs) => withGenerateOptions(yargs),
handler: async (args) => {
// Remove the command from the args
args._ = args._.slice(1);
process.exit(
await (await import('./generate')).generate(process.cwd(), args)
);
Expand Down Expand Up @@ -237,9 +238,9 @@ ${daemonHelpOutput}
command: 'workspace-generator [name]',
describe: 'Runs a workspace generator from the tools/generators directory',
aliases: ['workspace-schematic [name]'],
builder: (yargs) =>
builder: async (yargs) =>
linkToNxDevAndExamples(
withWorkspaceGeneratorOptions(yargs),
await withWorkspaceGeneratorOptions(yargs),
'workspace-generator'
),
handler: async () =>
Expand Down Expand Up @@ -288,11 +289,13 @@ ${daemonHelpOutput}
command: 'new [_..]',
describe: false,
builder: (yargs) => withNewOptions(yargs),
handler: async (args) =>
(await import('./generate')).newWorkspace(
handler: async (args) => {
args._ = args._.slice(1);
return (await import('./generate')).newWorkspace(
args['nxWorkspaceRoot'] as string,
args
),
);
},
})
.command(
'_migrate [packageAndVersion]',
Expand Down Expand Up @@ -612,20 +615,23 @@ function withRunOneOptions(yargs: yargs.Argv) {
}
}

function withWorkspaceGeneratorOptions(yargs: yargs.Argv) {
yargs.option('list-generators', {
describe: 'List the available workspace-generators',
type: 'boolean',
});
async function withWorkspaceGeneratorOptions(yargs: yargs.Argv) {
yargs
.option('list-generators', {
describe: 'List the available workspace-generators',
type: 'boolean',
})
.positional('name', {
type: 'string',
describe: 'The name of your generator`',
});

/**
* Don't require `name` if only listing available
* schematics
*/
if (yargs.argv.listGenerators !== true) {
yargs.demandOption(['name']).positional('name', {
type: 'string',
describe: 'The name of your generator`',
});
if ((await yargs.argv).listGenerators !== true) {
yargs.demandOption('name');
}
return yargs;
}
Expand Down Expand Up @@ -653,6 +659,9 @@ function withMigrationOptions(yargs: yargs.Argv) {
}

function parseCSV(args: string[]) {
if (!args) {
return args;
}
return args
.map((arg) => arg.split(','))
.reduce((acc, value) => {
Expand Down
2 changes: 0 additions & 2 deletions packages/nx/src/command-line/workspace-generators.ts
Expand Up @@ -131,9 +131,7 @@ function listGenerators(collectionFile: string) {
});
} catch (error) {
logger.fatal(error.message);
return 1;
}
return 0;
}

function parseOptions(
Expand Down
4 changes: 2 additions & 2 deletions packages/workspace/package.json
Expand Up @@ -73,8 +73,8 @@
"rxjs": "^6.5.4",
"semver": "7.3.4",
"tmp": "~0.2.1",
"yargs": "15.4.1",
"yargs-parser": "20.0.0",
"yargs": "^17.4.0",
"yargs-parser": "21.0.1",
"chalk": "4.1.0",
"flat": "^5.0.2",
"minimatch": "3.0.4",
Expand Down
12 changes: 9 additions & 3 deletions scripts/documentation/generate-cli-data.ts
Expand Up @@ -66,7 +66,10 @@ export async function generateCLIDocumentation() {
removeSync(commandsOutputDirectory);

function getCommands(command) {
return command.getCommandInstance().getCommandHandlers();
return command
.getInternalMethods()
.getCommandInstance()
.getCommandHandlers();
}
async function parseCommandInstance(
name: string,
Expand All @@ -89,9 +92,12 @@ export async function generateCLIDocumentation() {
}
// Show all the options we can get from yargs
const builder = await command.builder(
importFresh('yargs')().resetOptions()
importFresh('yargs')().getInternalMethods().reset()
);
const builderDescriptions = builder.getUsageInstance().getDescriptions();
const builderDescriptions = builder
.getInternalMethods()
.getUsageInstance()
.getDescriptions();
const builderDefaultOptions = builder.getOptions().default;
const builderDeprecatedOptions = builder.getDeprecatedOptions();
return {
Expand Down
21 changes: 14 additions & 7 deletions yarn.lock
Expand Up @@ -5091,7 +5091,7 @@
resolved "https://registry.yarnpkg.com/@types/yargs-parser/-/yargs-parser-21.0.0.tgz#0c60e537fa790f5f9472ed2776c2b71ec117351b"
integrity sha512-iO9ZQHkZxHn4mSakYV0vFHAVDyEOIJQrV2uZ06HxEPcx+mt8swXoZHIbaaJ2crJYFfErySgktuTZ3BeLz+XmFA==

"@types/yargs@^15.0.0", "@types/yargs@^15.0.5":
"@types/yargs@^15.0.0":
version "15.0.14"
resolved "https://registry.yarnpkg.com/@types/yargs/-/yargs-15.0.14.tgz#26d821ddb89e70492160b66d10a0eb6df8f6fb06"
integrity sha512-yEJzHoxf6SyQGhBhIYGXQDSCkJjB6HohDShto7m8vaKg9Yp0Yn8+71J9eakh2bnPg6BfsH9PRMhiRTZnd4eXGQ==
Expand All @@ -5105,6 +5105,13 @@
dependencies:
"@types/yargs-parser" "*"

"@types/yargs@^17.0.10":
version "17.0.10"
resolved "https://registry.yarnpkg.com/@types/yargs/-/yargs-17.0.10.tgz#591522fce85d8739bca7b8bb90d048e4478d186a"
integrity sha512-gmEaFwpj/7f/ROdtIlci1R1VYU1J4j95m8T+Tj3iBgiBFKg1foE/PSl93bBd5T9LDXNPo8UlNN6W0qwD8O5OaA==
dependencies:
"@types/yargs-parser" "*"

"@types/yauzl@^2.9.1":
version "2.9.2"
resolved "https://registry.yarnpkg.com/@types/yauzl/-/yauzl-2.9.2.tgz#c48e5d56aff1444409e39fa164b0b4d4552a7b7a"
Expand Down Expand Up @@ -23537,6 +23544,11 @@ yargs-parser@20.2.9, yargs-parser@20.x, yargs-parser@^20.2.2, yargs-parser@^20.2
resolved "https://registry.yarnpkg.com/yargs-parser/-/yargs-parser-20.2.9.tgz#2eb7dc3b0289718fc295f362753845c41a0c94ee"
integrity sha512-y11nGElTIV+CT3Zv9t7VKl+Q3hTQoT9a1Qzezhhl6Rp21gJ/IVTW7Z3y9EWXhuUBC2Shnf+DX0antecpAwSP8w==

yargs-parser@21.0.1, yargs-parser@^21.0.0:
version "21.0.1"
resolved "https://registry.yarnpkg.com/yargs-parser/-/yargs-parser-21.0.1.tgz#0267f286c877a4f0f728fceb6f8a3e4cb95c6e35"
integrity sha512-9BK1jFpLzJROCI5TzwZL/TU4gqjK5xiHV/RfWLOahrjAko/e4DJkRDZQXfvqAsiZzzYhgAzbgz6lg48jcm4GLg==

yargs-parser@^18.1.2:
version "18.1.3"
resolved "https://registry.yarnpkg.com/yargs-parser/-/yargs-parser-18.1.3.tgz#be68c4975c6b2abf469236b0c870362fab09a7b0"
Expand All @@ -23545,11 +23557,6 @@ yargs-parser@^18.1.2:
camelcase "^5.0.0"
decamelize "^1.2.0"

yargs-parser@^21.0.0:
version "21.0.1"
resolved "https://registry.yarnpkg.com/yargs-parser/-/yargs-parser-21.0.1.tgz#0267f286c877a4f0f728fceb6f8a3e4cb95c6e35"
integrity sha512-9BK1jFpLzJROCI5TzwZL/TU4gqjK5xiHV/RfWLOahrjAko/e4DJkRDZQXfvqAsiZzzYhgAzbgz6lg48jcm4GLg==

yargs@15.4.1:
version "15.4.1"
resolved "https://registry.yarnpkg.com/yargs/-/yargs-15.4.1.tgz#0d87a16de01aee9d8bec2bfbf74f67851730f4f8"
Expand Down Expand Up @@ -23580,7 +23587,7 @@ yargs@^16.1.0, yargs@^16.2.0:
y18n "^5.0.5"
yargs-parser "^20.2.2"

yargs@^17.2.1:
yargs@^17.2.1, yargs@^17.4.0:
version "17.4.0"
resolved "https://registry.yarnpkg.com/yargs/-/yargs-17.4.0.tgz#9fc9efc96bd3aa2c1240446af28499f0e7593d00"
integrity sha512-WJudfrk81yWFSOkZYpAZx4Nt7V4xp7S/uJkX0CnxovMCt1wCE8LNftPpNuF9X/u9gN5nsD7ycYtRcDf2pL3UiA==
Expand Down

1 comment on commit 8b0f9d2

@vercel
Copy link

@vercel vercel bot commented on 8b0f9d2 Mar 28, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.