@lerna/filter-options
Advanced tools
Comparing version 3.16.5 to 3.18.0
@@ -6,2 +6,21 @@ # Change Log | ||
# [3.18.0](https://github.com/lerna/lerna/compare/v3.17.0...v3.18.0) (2019-10-15) | ||
### Bug Fixes | ||
* **bootstrap:** Move all filter logging into get-filtered-packages method ([54dca56](https://github.com/lerna/lerna/commit/54dca563efb13ad88d478ac31668f6e13a1d99e7)) | ||
### Features | ||
* **filter-options:** Add `--exclude-dependents` option ([ff50e29](https://github.com/lerna/lerna/commit/ff50e299aa990b121e1bd987548252376177c68a)), closes [#2198](https://github.com/lerna/lerna/issues/2198) | ||
* **filter-options:** Allow command to continue if no packages are matched ([#2280](https://github.com/lerna/lerna/issues/2280)) ([a706023](https://github.com/lerna/lerna/commit/a706023b585846c8e43771657d65ba8797125504)) | ||
* **filter-options:** Rename `--include-filtered-*` options ([f2c3a92](https://github.com/lerna/lerna/commit/f2c3a92fe41b6fdc5d11269f0f2c3e27761b4c85)) | ||
* **filter-options:** Use figgy-pudding in getFilteredPackages() ([73badee](https://github.com/lerna/lerna/commit/73badee5da06745ff58ee96f762d7240e9b4d6f1)) | ||
## [3.16.5](https://github.com/lerna/lerna/compare/v3.16.4...v3.16.5) (2019-10-07) | ||
@@ -8,0 +27,0 @@ |
56
index.js
"use strict"; | ||
const log = require("npmlog"); | ||
const dedent = require("dedent"); | ||
@@ -38,10 +39,19 @@ const getFilteredPackages = require("./lib/get-filtered-packages"); | ||
}, | ||
"include-filtered-dependents": { | ||
"exclude-dependents": { | ||
describe: dedent` | ||
Exclude all transitive dependents when running a command | ||
with --since, overriding the default "changed" algorithm. | ||
`, | ||
conflicts: "include-dependents", | ||
type: "boolean", | ||
}, | ||
"include-dependents": { | ||
describe: dedent` | ||
Include all transitive dependents when running a command | ||
regardless of --scope, --ignore, or --since. | ||
`, | ||
conflicts: "exclude-dependents", | ||
type: "boolean", | ||
}, | ||
"include-filtered-dependencies": { | ||
"include-dependencies": { | ||
describe: dedent` | ||
@@ -53,5 +63,45 @@ Include all transitive dependencies when running a command | ||
}, | ||
"continue-if-no-match": { | ||
describe: "Don't fail if no package is matched", | ||
hidden: true, | ||
type: "boolean", | ||
}, | ||
}; | ||
return yargs.options(opts).group(Object.keys(opts), "Filter Options:"); | ||
return yargs | ||
.options(opts) | ||
.group(Object.keys(opts), "Filter Options:") | ||
.option("include-filtered-dependents", { | ||
// TODO: remove in next major release | ||
hidden: true, | ||
conflicts: ["exclude-dependents", "include-dependents"], | ||
type: "boolean", | ||
}) | ||
.option("include-filtered-dependencies", { | ||
// TODO: remove in next major release | ||
hidden: true, | ||
conflicts: "include-dependencies", | ||
type: "boolean", | ||
}) | ||
.check(argv => { | ||
/* eslint-disable no-param-reassign */ | ||
if (argv.includeFilteredDependents) { | ||
argv.includeDependents = true; | ||
argv["include-dependents"] = true; | ||
delete argv.includeFilteredDependents; | ||
delete argv["include-filtered-dependents"]; | ||
log.warn("deprecated", "--include-filtered-dependents has been renamed --include-dependents"); | ||
} | ||
if (argv.includeFilteredDependencies) { | ||
argv.includeDependencies = true; | ||
argv["include-dependencies"] = true; | ||
delete argv.includeFilteredDependencies; | ||
delete argv["include-filtered-dependencies"]; | ||
log.warn("deprecated", "--include-filtered-dependencies has been renamed --include-dependencies"); | ||
} | ||
/* eslint-enable no-param-reassign */ | ||
return argv; | ||
}); | ||
} |
"use strict"; | ||
const npmlog = require("npmlog"); | ||
const figgyPudding = require("figgy-pudding"); | ||
const collectUpdates = require("@lerna/collect-updates"); | ||
@@ -8,12 +10,48 @@ const filterPackages = require("@lerna/filter-packages"); | ||
function getFilteredPackages(packageGraph, execOpts, options) { | ||
const FilterConfig = figgyPudding({ | ||
scope: {}, | ||
ignore: {}, | ||
private: {}, | ||
since: {}, | ||
continueIfNoMatch: {}, | ||
excludeDependents: {}, | ||
includeDependents: {}, | ||
includeDependencies: {}, | ||
includeFilteredDependents: "includeDependents", | ||
includeFilteredDependencies: "includeDependencies", | ||
log: { default: npmlog }, | ||
}); | ||
function getFilteredPackages(packageGraph, execOpts, opts) { | ||
const options = FilterConfig(opts); | ||
if (options.scope) { | ||
options.log.notice("filter", "including %j", options.scope); | ||
} | ||
if (options.ignore) { | ||
options.log.notice("filter", "excluding %j", options.ignore); | ||
} | ||
let chain = Promise.resolve(); | ||
chain = chain.then(() => | ||
filterPackages(packageGraph.rawPackageList, options.scope, options.ignore, options.private) | ||
filterPackages( | ||
packageGraph.rawPackageList, | ||
options.scope, | ||
options.ignore, | ||
options.private, | ||
options.continueIfNoMatch | ||
) | ||
); | ||
if (options.since !== undefined) { | ||
options.log.notice("filter", "changed since %j", options.since); | ||
if (options.excludeDependents) { | ||
options.log.notice("filter", "excluding dependents"); | ||
} | ||
chain = chain.then(filteredPackages => | ||
Promise.resolve(collectUpdates(filteredPackages, packageGraph, execOpts, options)).then(updates => { | ||
Promise.resolve(collectUpdates(filteredPackages, packageGraph, execOpts, opts)).then(updates => { | ||
const updated = new Set(updates.map(({ pkg }) => pkg.name)); | ||
@@ -26,7 +64,11 @@ | ||
if (options.includeFilteredDependents) { | ||
if (options.includeDependents) { | ||
options.log.notice("filter", "including dependents"); | ||
chain = chain.then(filteredPackages => packageGraph.addDependents(filteredPackages)); | ||
} | ||
if (options.includeFilteredDependencies) { | ||
if (options.includeDependencies) { | ||
options.log.notice("filter", "including dependencies"); | ||
chain = chain.then(filteredPackages => packageGraph.addDependencies(filteredPackages)); | ||
@@ -33,0 +75,0 @@ } |
{ | ||
"name": "@lerna/filter-options", | ||
"version": "3.16.5", | ||
"version": "3.18.0", | ||
"description": "Options for lerna sub-commands that need filtering", | ||
@@ -35,7 +35,9 @@ "keywords": [ | ||
"dependencies": { | ||
"@lerna/collect-updates": "3.16.5", | ||
"@lerna/filter-packages": "3.16.0", | ||
"dedent": "^0.7.0" | ||
"@lerna/collect-updates": "3.18.0", | ||
"@lerna/filter-packages": "3.18.0", | ||
"dedent": "^0.7.0", | ||
"figgy-pudding": "^3.5.1", | ||
"npmlog": "^4.1.2" | ||
}, | ||
"gitHead": "f0574092a2db90142b3a27ec1a4941cddbdcdf62" | ||
"gitHead": "0ea8fb136f408fb4de3fd39bb7069d976235d53d" | ||
} |
@@ -54,7 +54,13 @@ # `@lerna/filter-options` | ||
### `--include-filtered-dependents` | ||
### `--exclude-dependents` | ||
Exclude all transitive dependents when running a command with `--since`, overriding the default "changed" algorithm. | ||
This flag has no effect without `--since`, and will throw an error in that case. | ||
### `--include-dependents` | ||
Include all transitive dependents when running a command regardless of `--scope`, `--ignore`, or `--since`. | ||
### `--include-filtered-dependencies` | ||
### `--include-dependencies` | ||
@@ -73,3 +79,3 @@ Include all transitive dependencies when running a command regardless of `--scope`, `--ignore`, or `--since`. | ||
```sh | ||
$ lerna bootstrap --scope my-component --include-filtered-dependencies | ||
$ lerna bootstrap --scope my-component --include-dependencies | ||
# my-component and all of its dependencies will be bootstrapped | ||
@@ -79,5 +85,5 @@ ``` | ||
```sh | ||
$ lerna bootstrap --scope "package-*" --ignore "package-util-*" --include-filtered-dependencies | ||
$ lerna bootstrap --scope "package-*" --ignore "package-util-*" --include-dependencies | ||
# all packages matching "package-util-*" will be ignored unless they are | ||
# depended upon by a package whose name matches "package-*" | ||
``` |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
16903
158
87
5
+ Addedfiggy-pudding@^3.5.1
+ Addednpmlog@^4.1.2
+ Added@lerna/collect-updates@3.18.0(transitive)
+ Added@lerna/filter-packages@3.18.0(transitive)
+ Addedfiggy-pudding@3.5.2(transitive)
- Removed@lerna/collect-updates@3.16.5(transitive)
- Removed@lerna/filter-packages@3.16.0(transitive)