Skip to content

Commit

Permalink
fix(filter-options): Ensure --include-merged-tags is available to a…
Browse files Browse the repository at this point in the history
…ll `--since`-filterable commands

Fixes #2332
  • Loading branch information
evocateur committed Nov 8, 2019
1 parent b649b35 commit 287bcd8
Show file tree
Hide file tree
Showing 9 changed files with 36 additions and 5 deletions.
2 changes: 1 addition & 1 deletion commands/add/README.md
Expand Up @@ -21,7 +21,7 @@ If no `version` specifier is provided, it defaults to the `latest` dist-tag, jus

## Options

`lerna add` respects the `--ignore`, `--scope`, and `--include-dependencies` flags (see [Filter Flags](https://www.npmjs.com/package/@lerna/filter-options)).
`lerna add` accepts all [filter flags](https://www.npmjs.com/package/@lerna/filter-options).

### `--dev`

Expand Down
2 changes: 1 addition & 1 deletion commands/bootstrap/README.md
Expand Up @@ -20,7 +20,7 @@ When run, this command will:
3. `npm run prepublish` in all bootstrapped packages (unless `--ignore-prepublish` is passed).
4. `npm run prepare` in all bootstrapped packages.

`lerna bootstrap` respects the `--ignore`, `--scope`, and `--include-dependencies` flags (see [Filter Flags](https://www.npmjs.com/package/@lerna/filter-options)).
`lerna bootstrap` accepts all [filter flags](https://www.npmjs.com/package/@lerna/filter-options).

Pass extra arguments to npm client by placing them after `--`:

Expand Down
3 changes: 2 additions & 1 deletion commands/clean/README.md
Expand Up @@ -12,6 +12,7 @@ $ lerna clean

Remove the `node_modules` directory from all packages.

`lerna clean` respects the `--ignore`, `--scope`, and `--yes` flags (see [Filter Flags](https://www.npmjs.com/package/@lerna/filter-options)).
`lerna clean` accepts all [filter flags](https://www.npmjs.com/package/@lerna/filter-options), as well as `--yes`.


> `lerna clean` does not remove modules from the root `node_modules` directory, even if you have the `--hoist` option enabled.
2 changes: 1 addition & 1 deletion commands/exec/README.md
Expand Up @@ -29,7 +29,7 @@ $ lerna exec -- node \$LERNA_ROOT_PATH/scripts/some-script.js

## Options

`lerna exec` respects the `--concurrency`, `--scope`, and `--ignore` flags (see [Filter Flags](https://www.npmjs.com/package/@lerna/filter-options)).
`lerna exec` accepts all [filter flags](https://www.npmjs.com/package/@lerna/filter-options).

```sh
$ lerna exec --scope my-component -- ls -la
Expand Down
13 changes: 13 additions & 0 deletions commands/exec/__tests__/exec-command.test.js
Expand Up @@ -181,6 +181,19 @@ describe("ExecCommand", () => {
"packages/package-2 ls (prefix: false)",
]);
});

it("does not explode with filter flags", async () => {
await lernaExec(testDir)(
"ls",
"--no-private",
"--since",
"--include-merged-tags",
"--exclude-dependents",
"--include-dependencies"
);

expect(calledInPackages()).toEqual(["package-1", "package-2"]);
});
});

describe("with --no-sort", () => {
Expand Down
2 changes: 1 addition & 1 deletion commands/run/README.md
Expand Up @@ -19,7 +19,7 @@ Run an [npm script](https://docs.npmjs.com/misc/scripts) in each package that co

## Options

`lerna run` respects the `--concurrency`, `--scope`, and `--ignore` flags (see [Filter Flags](https://www.npmjs.com/package/@lerna/filter-options)).
`lerna run` accepts all [filter flags](https://www.npmjs.com/package/@lerna/filter-options).

```sh
$ lerna run --scope my-component test
Expand Down
8 changes: 8 additions & 0 deletions core/filter-options/README.md
Expand Up @@ -84,3 +84,11 @@ $ lerna bootstrap --scope "package-*" --ignore "package-util-*" --include-depend
# all packages matching "package-util-*" will be ignored unless they are
# depended upon by a package whose name matches "package-*"
```

### `--include-merged-tags`

```sh
$ lerna exec --since --include-merged-tags -- ls -la
```

Include tags from merged branches when running a command with `--since`. This is only useful if you do a lot of publishing from feature branches, which is not generally recommended.
4 changes: 4 additions & 0 deletions core/filter-options/index.js
Expand Up @@ -59,6 +59,10 @@ function filterOptions(yargs) {
`,
type: "boolean",
},
"include-merged-tags": {
describe: "Include tags from merged branches when running a command with --since.",
type: "boolean",
},
"continue-if-no-match": {
describe: "Don't fail if no package is matched",
hidden: true,
Expand Down
5 changes: 5 additions & 0 deletions core/filter-options/lib/get-filtered-packages.js
Expand Up @@ -18,6 +18,7 @@ const FilterConfig = figgyPudding({
includeDependencies: {},
includeFilteredDependents: "includeDependents",
includeFilteredDependencies: "includeDependencies",
includeMergedTags: {},
log: { default: npmlog },
});

Expand Down Expand Up @@ -51,6 +52,10 @@ function getFilteredPackages(packageGraph, execOpts, opts) {
options.log.notice("filter", "excluding dependents");
}

if (options.includeMergedTags) {
options.log.notice("filter", "including merged tags");
}

chain = chain.then(filteredPackages =>
Promise.resolve(collectUpdates(filteredPackages, packageGraph, execOpts, opts)).then(updates => {
const updated = new Set(updates.map(({ pkg }) => pkg.name));
Expand Down

0 comments on commit 287bcd8

Please sign in to comment.