Socket
Socket
Sign inDemoInstall

@lerna/query-graph

Package Overview
Dependencies
Maintainers
2
Versions
53
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@lerna/query-graph - npm Package Compare versions

Comparing version 3.18.5 to 4.0.0

32

CHANGELOG.md

@@ -6,2 +6,34 @@ # Change Log

# [4.0.0](https://github.com/lerna/lerna/compare/v3.22.1...v4.0.0) (2021-02-10)
### Bug Fixes
* Improve accuracy of JSDoc type annotations ([1ec69f0](https://github.com/lerna/lerna/commit/1ec69f0e0f7a3f1e0c74dbacb17fab2d7b7a8a44))
### Features
* Consume named exports of sibling modules ([63499e3](https://github.com/lerna/lerna/commit/63499e33652bc78fe23751875d74017e2f16a689))
* Drop support for Node v6.x & v8.x ([ff4bb4d](https://github.com/lerna/lerna/commit/ff4bb4da215555e3bb136f5af09b5cbc631e57bb))
* Expose named export ([c1303f1](https://github.com/lerna/lerna/commit/c1303f13adc4cf15f96ff25889b52149f8224c0e))
* Remove default export ([e2f1ec3](https://github.com/lerna/lerna/commit/e2f1ec3dd049d2a89880029908a2aa7c66f15082))
* **query-graph:** Remove figgy-pudding ([3b0e2fe](https://github.com/lerna/lerna/commit/3b0e2fec7c274bc93627404295b51638cb7d7e60))
### BREAKING CHANGES
* The default export has been removed, please use a named export instead.
* Node v6.x & v8.x are no longer supported. Please upgrade to the latest LTS release.
Here's the gnarly one-liner I used to make these changes:
```
npx lerna exec --concurrency 1 --stream -- 'json -I -f package.json -e '"'"'this.engines=this.engines||{};this.engines.node=">= 10.18.0"'"'"
```
(requires `npm i -g json` beforehand)
## [3.18.5](https://github.com/lerna/lerna/compare/v3.18.4...v3.18.5) (2019-11-20)

@@ -8,0 +40,0 @@

9

package.json
{
"name": "@lerna/query-graph",
"version": "3.18.5",
"version": "4.0.0",
"description": "An internal Lerna tool",

@@ -20,3 +20,3 @@ "keywords": [

"engines": {
"node": ">= 6.9.0"
"node": ">= 10.18.0"
},

@@ -35,6 +35,5 @@ "publishConfig": {

"dependencies": {
"@lerna/package-graph": "3.18.5",
"figgy-pudding": "^3.5.1"
"@lerna/package-graph": "4.0.0"
},
"gitHead": "2612f51e7eecec58eacf0571724e6989e4b8e42d"
"gitHead": "4582c476e07dddddd6b2e3ab6e7f52c1f9eed59a"
}
"use strict";
const figgyPudding = require("figgy-pudding");
const PackageGraph = require("@lerna/package-graph");
const { PackageGraph } = require("@lerna/package-graph");
const QueryGraphConfig = figgyPudding({
"graph-type": {},
graphType: "graph-type",
"reject-cycles": {},
rejectCycles: "reject-cycles",
});
/**
* @typedef {object} QueryGraphConfig
* @property {'allDependencies'|'dependencies'} [graphType] "dependencies" excludes devDependencies from graph
* @property {boolean} [rejectCycles] Whether or not to reject dependency cycles
*/
/**
* A mutable PackageGraph used to query for next available packages.
*/
class QueryGraph {
/**
* A mutable PackageGraph used to query for next available packages.
* Sort a list of Packages topologically.
*
* @param {Array<Package>} packages An array of Packages to build the graph out of
* @param {String} [opts.graphType="allDependencies"] "dependencies" excludes devDependencies from graph
* @param {Boolean} [opts.rejectCycles] Whether or not to reject cycles
* @constructor
* @param {import("@lerna/package").Package[]} packages An array of Packages to build the list out of
* @param {QueryGraphConfig} [options]
*
* @returns {import("@lerna/package").Package[]} A list of Package instances in topological order
*/
constructor(packages, opts) {
const options = QueryGraphConfig(opts);
static toposort(packages, options) {
const graph = new QueryGraph(packages, options);
const result = [];
let batch = graph.getAvailablePackages();
while (batch.length) {
for (const node of batch) {
// no need to take() in synchronous loop
result.push(node.pkg);
graph.markAsDone(node);
}
batch = graph.getAvailablePackages();
}
return result;
}
/**
* @param {import("@lerna/package").Package[]} packages An array of Packages to build the graph out of
* @param {QueryGraphConfig} [options]
*/
constructor(packages, { graphType = "allDependencies", rejectCycles } = {}) {
// Create dependency graph
this.graph = new PackageGraph(packages, options.graphType);
this.graph = new PackageGraph(packages, graphType);
// Evaluate cycles
this.cycles = this.graph.collapseCycles(options.rejectCycles);
this.cycles = this.graph.collapseCycles(rejectCycles);
}
_getNextLeaf() {
return Array.from(this.graph.values()).filter(node => node.localDependencies.size === 0);
return Array.from(this.graph.values()).filter((node) => node.localDependencies.size === 0);
}
_getNextCycle() {
const cycle = Array.from(this.cycles).find(cycleNode => cycleNode.localDependencies.size === 0);
const cycle = Array.from(this.cycles).find((cycleNode) => cycleNode.localDependencies.size === 0);

@@ -59,2 +81,5 @@ if (!cycle) {

/**
* @param {string} name
*/
markAsTaken(name) {

@@ -64,2 +89,5 @@ this.graph.delete(name);

/**
* @param {import("@lerna/package-graph").PackageGraphNode} candidateNode
*/
markAsDone(candidateNode) {

@@ -74,32 +102,3 @@ this.graph.remove(candidateNode);

module.exports = QueryGraph;
module.exports.toposort = toposort;
/**
* Sort the input list topologically.
*
* @param {!Array.<Package>} packages An array of Packages to build the list out of
* @param {Object} [options]
* @param {Boolean} options.graphType "allDependencies" or "dependencies", which excludes devDependencies
* @param {Boolean} options.rejectCycles Whether or not to reject cycles
*
* @returns {Array<Package>} a list of Package instances in topological order
*/
function toposort(packages, opts) {
const graph = new QueryGraph(packages, opts);
const result = [];
let batch = graph.getAvailablePackages();
while (batch.length) {
for (const node of batch) {
// no need to take() in synchronous loop
result.push(node.pkg);
graph.markAsDone(node);
}
batch = graph.getAvailablePackages();
}
return result;
}
module.exports.QueryGraph = QueryGraph;
module.exports.toposort = QueryGraph.toposort;
SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc