@lerna/listable
Advanced tools
Comparing version 3.14.0 to 3.16.0
@@ -6,2 +6,18 @@ # Change Log | ||
# [3.16.0](https://github.com/lerna/lerna/compare/v3.15.0...v3.16.0) (2019-07-18) | ||
### Bug Fixes | ||
* **package-graph:** Flatten cycles to avoid skipping packages ([#2185](https://github.com/lerna/lerna/issues/2185)) ([b335763](https://github.com/lerna/lerna/commit/b335763)) | ||
### Features | ||
* **listable:** Output JSON adjacency list with `--graph` ([9457a21](https://github.com/lerna/lerna/commit/9457a21)), closes [#1970](https://github.com/lerna/lerna/issues/1970) | ||
# [3.14.0](https://github.com/lerna/lerna/compare/v3.13.4...v3.14.0) (2019-05-14) | ||
@@ -8,0 +24,0 @@ |
@@ -23,2 +23,4 @@ "use strict"; | ||
text = formatParseable(resultList, viewOptions); | ||
} else if (viewOptions.showGraph) { | ||
text = formatJSONGraph(resultList, viewOptions); | ||
} else { | ||
@@ -41,2 +43,3 @@ text = formatColumns(resultList, viewOptions); | ||
isTopological: options.toposort, | ||
showGraph: options.graph, | ||
}; | ||
@@ -76,2 +79,34 @@ } | ||
function formatJSONGraph(resultList, viewOptions) { | ||
// https://en.wikipedia.org/wiki/Adjacency_list | ||
const graph = {}; | ||
const getNeighbors = viewOptions.showAll | ||
? pkg => | ||
Object.keys( | ||
Object.assign( | ||
{}, | ||
pkg.devDependencies, | ||
pkg.peerDependencies, | ||
pkg.optionalDependencies, | ||
pkg.dependencies | ||
) | ||
).sort() | ||
: pkg => | ||
Object.keys( | ||
Object.assign( | ||
{}, | ||
// no devDependencies | ||
// no peerDependencies | ||
pkg.optionalDependencies, | ||
pkg.dependencies | ||
) | ||
).sort(); | ||
for (const pkg of resultList) { | ||
graph[pkg.name] = getNeighbors(pkg); | ||
} | ||
return JSON.stringify(graph, null, 2); | ||
} | ||
function makeParseable(pkg) { | ||
@@ -78,0 +113,0 @@ const result = [pkg.location, pkg.name]; |
@@ -40,3 +40,8 @@ "use strict"; | ||
}, | ||
graph: { | ||
group: "Command Options:", | ||
describe: "Show dependency graph as a JSON-formatted adjacency list", | ||
type: "boolean", | ||
}, | ||
}); | ||
} |
{ | ||
"name": "@lerna/listable", | ||
"version": "3.14.0", | ||
"version": "3.16.0", | ||
"description": "Shared logic for listing package information", | ||
@@ -32,7 +32,7 @@ "keywords": [ | ||
"dependencies": { | ||
"@lerna/query-graph": "3.14.0", | ||
"@lerna/query-graph": "3.16.0", | ||
"chalk": "^2.3.1", | ||
"columnify": "^1.5.4" | ||
}, | ||
"gitHead": "39da145c67ea587457694f318f32f967b9d66ea9" | ||
"gitHead": "8ca18bedecf4f141c6242a099086e84b2ced72de" | ||
} |
10297
197
+ Added@lerna/package-graph@3.16.0(transitive)
+ Added@lerna/prerelease-id-from-version@3.16.0(transitive)
+ Added@lerna/query-graph@3.16.0(transitive)
+ Addedsemver@6.3.1(transitive)
- Removed@lerna/package-graph@3.14.0(transitive)
- Removed@lerna/prerelease-id-from-version@3.14.0(transitive)
- Removed@lerna/query-graph@3.14.0(transitive)
Updated@lerna/query-graph@3.16.0