Skip to content

Commit

Permalink
fix(version): Make changes to packages in batched topological order
Browse files Browse the repository at this point in the history
  • Loading branch information
evocateur committed Aug 27, 2018
1 parent 0d7ffcf commit d799fbf
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 2 deletions.
13 changes: 11 additions & 2 deletions commands/version/index.js
Expand Up @@ -17,6 +17,7 @@ const PromptUtilities = require("@lerna/prompt");
const output = require("@lerna/output");
const collectUpdates = require("@lerna/collect-updates");
const { createRunner } = require("@lerna/run-lifecycle");
const batchPackages = require("@lerna/batch-packages");
const ValidationError = require("@lerna/validation-error");

const getCurrentBranch = require("./lib/get-current-branch");
Expand Down Expand Up @@ -148,6 +149,7 @@ class VersionCommand extends Command {
const tasks = [
() => this.getVersionsForUpdates(),
versions => this.setUpdatesForVersions(versions),
() => this.setBatchUpdates(),
() => this.confirmVersions(),
];

Expand Down Expand Up @@ -324,6 +326,11 @@ class VersionCommand extends Command {
}
}

setBatchUpdates() {
this.packagesToVersion = this.updates.map(({ pkg }) => pkg);
this.batchedPackages = batchPackages(this.packagesToVersion, this.options.rejectCycles);
}

confirmVersions() {
const changes = this.updates.map(({ pkg }) => {
let line = ` - ${pkg.name}: ${pkg.version} => ${this.updatesVersions.get(pkg.name)}`;
Expand Down Expand Up @@ -416,8 +423,10 @@ class VersionCommand extends Command {
const mapUpdate = pPipe(actions);

chain = chain.then(() =>
// TODO: tune the concurrency?
pMap(this.updates, mapUpdate, { concurrency: 100 })
pReduce(this.batchedPackages, (_, batch) =>
// TODO: tune the concurrency?
pMap(batch, mapUpdate, { concurrency: 100 })
)
);

if (!independentVersions) {
Expand Down
1 change: 1 addition & 0 deletions commands/version/package.json
Expand Up @@ -32,6 +32,7 @@
"test": "echo \"Run tests from root\" && exit 1"
},
"dependencies": {
"@lerna/batch-packages": "file:../../utils/batch-packages",
"@lerna/check-working-tree": "file:../../utils/check-working-tree",
"@lerna/child-process": "file:../../core/child-process",
"@lerna/collect-updates": "file:../../utils/collect-updates",
Expand Down
1 change: 1 addition & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit d799fbf

Please sign in to comment.