Skip to content

PackageGraph is a Map, its nodes store relationship Sets#1260

Merged
evocateur merged 3 commits into
lerna:masterfrom
evocateur:graph-theory
Feb 12, 2018
Merged

PackageGraph is a Map, its nodes store relationship Sets#1260
evocateur merged 3 commits into
lerna:masterfrom
evocateur:graph-theory

Conversation

@evocateur

@evocateur evocateur commented Feb 12, 2018

Copy link
Copy Markdown
Member

sorry this is so big

A lot of existing code was re-calculating stuff that should live inside the PackageGraph; namely, the relationships between packages (localDependencies and localDependents). I made PackageGraph a subclass of Map, mostly because it already had a .get() method, and now it can be iterated and such. It's a lot more elegant, overall.

A big piece of the new relationship logic is based on npm-package-arg parsing, which resolves a lot of previously half-baked logic. It's no longer necessary to pass the git version parser to the graph constructor, for example. npm-package-arg will also facilitate future graph manipulations, such as recognizing relative file: specifiers correctly.

Package

  • The package bin field now properly resolves an object when the original value is a string shorthand.
  • Many Package properties are immutable now, and very few are actually enumerable.

PackageGraph

  • --force-local evaluation has been moved into PackageGraph's constructor, simplifying the existing evaluation of local dependencies during symlink creation in LinkCommand.
  • Cycle detection and removal has been moved into a PackageGraph instance method, making the topological batching algogrithm much easier to read.
  • PackageGraphNodes no longer have a confusingly-named "dependencies" list, but distinct Map instances .localDependencies and .localDependents.
  • PackageGraphNodes themselves now forward most of the interesting Package properties, so the potential is there to use them directly, instead of the myriad places we pluck a (renamed) pkg property from various containers.

UpdatedPackagesCollector

  • Now reuses all of the new graph calculation in PackageGraph instead of blithely duplicating it.
  • There's a lot of room for other improvements in this utility.

PackageUtilities

  • I renamed topologicallyBatchPackages() to batchPackages(), because ain't nobody got time for that many syllables.

@evocateur evocateur force-pushed the graph-theory branch 2 times, most recently from 464ea38 to 29fa7c6 Compare February 12, 2018 21:12
@evocateur evocateur added this to the v3.0.0 milestone Feb 12, 2018
@evocateur evocateur merged commit a560b73 into lerna:master Feb 12, 2018
@evocateur evocateur deleted the graph-theory branch February 12, 2018 22:39
evocateur added a commit that referenced this pull request Feb 13, 2018
This builds on #1260, utilizing the new `Map`-and-`Set`-based `PackageGraph` idioms. In the process, some algorithms were dramatically simplified, and performance improved noticeably (especially in the integration tests).

### `PublishCommand`

* Literally every callback except the superclass lifecycle replaced with Promise-based patterns.
* Integration test now actually tests `--conventional-commits` completely, shaving off a few seconds of execution time on average.

### `ConventionalCommitUtilities`

* Use programmatic (async) `conventional-commits` APIs instead of synchronous CLI calls.
* Now supports presets for `conventional-recommended-bump`, as long as they support the [new preset API](conventional-changelog/conventional-changelog#262).
* Only the default (`conventional-commits-angular`) is included as a dependency, anything custom will need to be installed by the consumer.
@lock

lock Bot commented Dec 27, 2018

Copy link
Copy Markdown

This thread has been automatically locked because there has not been any recent activity after it was closed. Please open a new issue for related bugs.

@lock lock Bot locked as resolved and limited conversation to collaborators Dec 27, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant