Skip to content

Commit

Permalink
feat(cli): Upgrade to Yargs 12
Browse files Browse the repository at this point in the history
It is no longer necessary to specify `default: undefined` for boolean options,
as those keys are no longer automatically assigned to the parsed argv
regardless of presence in process.argv.
  • Loading branch information
evocateur committed Jul 16, 2018
1 parent 2d2ab8d commit 7899ab8
Show file tree
Hide file tree
Showing 16 changed files with 262 additions and 87 deletions.
1 change: 0 additions & 1 deletion commands/bootstrap/command.js
Expand Up @@ -35,7 +35,6 @@ exports.builder = yargs => {
group: "Command Options:",
describe: "Don't run lifecycle scripts in bootstrapped packages",
type: "boolean",
default: undefined,
},
"npm-client": {
group: "Command Options:",
Expand Down
1 change: 0 additions & 1 deletion commands/changed/command.js
Expand Up @@ -17,7 +17,6 @@ exports.builder = yargs =>
describe: "Show information in JSON format",
group: "Command Options:",
type: "boolean",
default: undefined,
},
});

Expand Down
1 change: 1 addition & 0 deletions commands/clean/command.js
Expand Up @@ -14,6 +14,7 @@ exports.builder = yargs => {
yes: {
group: "Command Options:",
describe: "Skip all confirmation prompts",
type: "boolean",
},
});

Expand Down
6 changes: 3 additions & 3 deletions commands/create/command.js
Expand Up @@ -42,7 +42,7 @@ exports.builder = yargs => {
"es-module": {
group: "Command Options:",
describe: "Initialize a transpiled ES Module",
// type: "boolean",
type: "boolean",
},
homepage: {
group: "Command Options:",
Expand All @@ -63,7 +63,7 @@ exports.builder = yargs => {
private: {
group: "Command Options:",
describe: "Make the new package private, never published to any external registry",
// type: "boolean",
type: "boolean",
},
registry: {
group: "Command Options:",
Expand All @@ -78,7 +78,7 @@ exports.builder = yargs => {
yes: {
group: "Command Options:",
describe: "Skip all prompts, accepting default values",
// type: "boolean",
type: "boolean",
},
});

Expand Down
8 changes: 2 additions & 6 deletions commands/exec/command.js
Expand Up @@ -25,30 +25,26 @@ exports.builder = yargs => {
bail: {
group: "Command Options:",
describe: "Stop when the command fails in a package.\nPass --no-bail to continue despite failure.",
defaultDescription: "true",
default: true,
type: "boolean",
default: undefined,
},
stream: {
group: "Command Options:",
describe: "Stream output with lines prefixed by package.",
type: "boolean",
default: undefined,
},
parallel: {
group: "Command Options:",
describe: "Run command in all packages with unlimited concurrency, streaming prefixed output",
type: "boolean",
default: undefined,
},
// This option controls prefix for stream output so that it can be disabled to be friendly
// to tools like Visual Studio Code to highlight the raw results
prefix: {
group: "Command Options:",
describe: "Pass --no-prefix to disable prefixing of streamed output.",
defaultDescription: "true",
default: true,
type: "boolean",
default: undefined,
},
});

Expand Down
2 changes: 2 additions & 0 deletions commands/import/command.js
Expand Up @@ -14,10 +14,12 @@ exports.builder = yargs =>
flatten: {
group: "Command Options:",
describe: "Import each merge commit as a single change the merge introduced",
type: "boolean",
},
yes: {
group: "Command Options:",
describe: "Skip all confirmation prompts",
type: "boolean",
},
});

Expand Down
2 changes: 0 additions & 2 deletions commands/init/command.js
Expand Up @@ -11,13 +11,11 @@ exports.builder = {
exact: {
describe: "Specify lerna dependency version in package.json without a caret (^)",
type: "boolean",
default: undefined,
},
independent: {
describe: "Version packages independently",
alias: "i",
type: "boolean",
default: undefined,
},
};

Expand Down
1 change: 0 additions & 1 deletion commands/link/command.js
Expand Up @@ -13,7 +13,6 @@ exports.builder = yargs => {
group: "Command Options:",
describe: "Force local sibling links regardless of version range match",
type: "boolean",
default: undefined,
},
});

Expand Down
1 change: 0 additions & 1 deletion commands/list/command.js
Expand Up @@ -17,7 +17,6 @@ exports.builder = yargs => {
group: "Command Options:",
describe: "Show information in JSON format",
type: "boolean",
default: undefined,
},
});

Expand Down
8 changes: 0 additions & 8 deletions commands/publish/command.js
Expand Up @@ -40,17 +40,14 @@ exports.builder = yargs => {
"conventional-commits": {
describe: "Use angular conventional-commit format to determine version bump and generate CHANGELOG.",
type: "boolean",
default: undefined,
},
"changelog-preset": {
describe: "Use another conventional-changelog preset rather than angular.",
type: "string",
default: undefined,
},
exact: {
describe: "Specify cross-dependency version numbers exactly rather than with a caret (^).",
type: "boolean",
default: undefined,
},
"git-remote": {
defaultDescription: "origin",
Expand All @@ -71,7 +68,6 @@ exports.builder = yargs => {
amend: {
describe: "Amend the existing commit, instead of generating a new one.",
type: "boolean",
default: false,
},
"npm-tag": {
describe: "Publish packages with the specified npm dist-tag",
Expand Down Expand Up @@ -101,22 +97,18 @@ exports.builder = yargs => {
"skip-git": {
describe: "Skip commiting, tagging, and pushing git changes.",
type: "boolean",
default: undefined,
},
"skip-npm": {
describe: "Stop before actually publishing change to npm.",
type: "boolean",
default: undefined,
},
"temp-tag": {
describe: "Create a temporary tag while publishing.",
type: "boolean",
default: undefined,
},
yes: {
describe: "Skip all confirmation prompts.",
type: "boolean",
default: undefined,
},
};

Expand Down
8 changes: 2 additions & 6 deletions commands/run/command.js
Expand Up @@ -20,30 +20,26 @@ exports.builder = yargs => {
bail: {
group: "Command Options:",
describe: "Stop when the script fails in a package.\nPass --no-bail to continue despite failure.",
defaultDescription: "true",
default: true,
type: "boolean",
default: undefined,
},
stream: {
group: "Command Options:",
describe: "Stream output with lines prefixed by package.",
type: "boolean",
default: undefined,
},
parallel: {
group: "Command Options:",
describe: "Run script in all packages with unlimited concurrency, streaming prefixed output.",
type: "boolean",
default: undefined,
},
// This option controls prefix for stream output so that it can be disabled to be friendly
// to tools like Visual Studio Code to highlight the raw results
prefix: {
group: "Command Options:",
describe: "Pass --no-prefix to disable prefixing of streamed output.",
defaultDescription: "true",
default: true,
type: "boolean",
default: undefined,
},
"npm-client": {
group: "Command Options:",
Expand Down
2 changes: 1 addition & 1 deletion core/cli/package.json
Expand Up @@ -50,6 +50,6 @@
"dedent": "^0.7.0",
"is-ci": "^1.0.10",
"npmlog": "^4.1.2",
"yargs": "^11.0.0"
"yargs": "^12.0.1"
}
}
4 changes: 2 additions & 2 deletions core/filter-options/index.js
Expand Up @@ -32,14 +32,14 @@ function filterOptions(yargs) {
Include all transitive dependents when running a command
regardless of --scope, --ignore, or --since.
`,
boolean: true,
type: "boolean",
},
"include-filtered-dependencies": {
describe: dedent`
Include all transitive dependencies when running a command
regardless of --scope, --ignore, or --since.
`,
boolean: true,
type: "boolean",
},
};

Expand Down
5 changes: 1 addition & 4 deletions core/global-options/index.js
Expand Up @@ -18,22 +18,19 @@ function globalOptions(yargs) {
"reject-cycles": {
describe: "Fail if a cycle is detected among dependencies.",
type: "boolean",
default: undefined,
},
progress: {
defaultDescription: "true",
describe: "Enable progress bars. Pass --no-progress to disable. (Always off in CI)",
type: "boolean",
default: undefined,
},
sort: {
defaultDescription: "true",
describe: "Sort packages topologically (all dependencies before dependents).",
type: "boolean",
default: undefined,
},
"max-buffer": {
describe: "Set max-buffer(bytes) for Command execution",
describe: "Set max-buffer (in bytes) for subcommand execution",
type: "number",
requiresArg: true,
},
Expand Down
2 changes: 1 addition & 1 deletion helpers/command-runner/package.json
Expand Up @@ -7,6 +7,6 @@
"license": "MIT",
"dependencies": {
"@lerna/global-options": "file:../../core/global-options",
"yargs": "^11.0.0"
"yargs": "^12.0.1"
}
}

0 comments on commit 7899ab8

Please sign in to comment.