Skip to content

Commit

Permalink
Add onlyExplicitUpdates flag so that only packages that have change…
Browse files Browse the repository at this point in the history
…d have version bumps rather than all packages that depend on the updated packages
  • Loading branch information
hzoo committed Jun 23, 2016
1 parent 8364ee4 commit 25b5e62
Show file tree
Hide file tree
Showing 3 changed files with 39 additions and 1 deletion.
13 changes: 13 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -461,3 +461,16 @@ The `ignore` flag, when used with the `bootstrap` command, can also be set in `l

> Hint: The glob is matched against the package name defined in `package.json`,
> not the directory name the package lives in.
#### --only-explicit-updates

Only will bump versions for packages that have been updated explicitly rather than cross-dependencies.

> This may not make sense for a major version bump since other packages that depend on the updated packages wouldn't be updated.
```sh
$ lerna updated --only-explicit-updates
$ lerna publish --only-explicit-updates
```

Ex: in Babel, `babel-types` is depended upon by all packages in the monorepo (over 100). However, Babel uses `^` for most of it's dependencies so it isn't necessary to bump the versions of all packages if only `babel-types` is updated. This option allows only the packages that have been explicitly updated to make a new version.
2 changes: 1 addition & 1 deletion src/UpdatedPackagesCollector.js
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@ export default class UpdatedPackagesCollector {

collectUpdates() {
return this.packages.filter(pkg => {
return this.updatedPackages[pkg.name] || this.dependents[pkg.name] || this.flags.canary;
return this.updatedPackages[pkg.name] || (this.flags.onlyExplicitUpdates ? false : this.dependents[pkg.name]) || this.flags.canary;
}).map(pkg => {
return new Update(pkg);
});
Expand Down
25 changes: 25 additions & 0 deletions test/UpdatedCommand.js
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,31 @@ describe("UpdatedCommand", () => {

updatedCommand.runCommand(exitWithCode(0, done));
});

it("should list changes for explicitly changed packages", done => {
execSync("git tag v1.0.0");
execSync("touch " + path.join(testDir, "packages/package-2/random-file"));
execSync("git add -A");
execSync("git commit -m 'Commit'");

const updatedCommand = new UpdatedCommand([], {
onlyExplicitUpdates: true
});

updatedCommand.runValidations();
updatedCommand.runPreparations();

let calls = 0;
stub(logger, "info", message => {
if (calls === 0) assert.equal(message, "Checking for updated packages...");
if (calls === 1) assert.equal(message, "");
if (calls === 2) assert.equal(message, "- package-2");
if (calls === 3) assert.equal(message, "");
calls++;
});

updatedCommand.runCommand(exitWithCode(0, done));
});
});

/** =========================================================================
Expand Down

0 comments on commit 25b5e62

Please sign in to comment.