pkgs-graph
Advanced tools
Comparing version 1.1.1 to 2.0.0-0
@@ -22,3 +22,9 @@ export declare type Manifest = { | ||
export default function (pkgs: Package[]): { | ||
[id: string]: PackageNode; | ||
graph: { | ||
[id: string]: PackageNode; | ||
}; | ||
unmatched: Array<{ | ||
pkgName: string; | ||
range: string; | ||
}>; | ||
}; |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
const semver = require("semver"); | ||
const commonTags = require("common-tags"); | ||
const chalk_1 = require("chalk"); | ||
const R = require("ramda"); | ||
const npa = require("npm-package-arg"); | ||
const oneLine = commonTags.oneLine; | ||
const highlight = chalk_1.default.yellow; | ||
function default_1(pkgs) { | ||
const pkgMap = createPkgMap(pkgs); | ||
const pkgNodeMap = Object.keys(pkgMap) | ||
const unmatched = []; | ||
const graph = Object.keys(pkgMap) | ||
.reduce((acc, pkgSpec) => { | ||
acc[pkgSpec] = Object.assign({}, pkgMap[pkgSpec], { | ||
acc[pkgSpec] = { | ||
manifest: pkgMap[pkgSpec].manifest, | ||
dependencies: createNode(pkgMap[pkgSpec]) | ||
}); | ||
}; | ||
return acc; | ||
}, {}); | ||
return pkgNodeMap; | ||
return { graph, unmatched }; | ||
function createNode(pkg) { | ||
@@ -30,3 +28,3 @@ const dependencies = Object.assign({}, pkg.manifest.devDependencies, pkg.manifest.optionalDependencies, pkg.manifest.dependencies); | ||
} | ||
return createPkgSpec(matchedPkg); | ||
return matchedPkg.path; | ||
} | ||
@@ -42,13 +40,11 @@ if (spec.type !== 'version' && spec.type !== 'range') | ||
const matchedPkg = pkgs.find(pkg => pkg.manifest.name === depName && pkg.manifest.version === range); | ||
return createPkgSpec(matchedPkg); | ||
return matchedPkg.path; | ||
} | ||
const matched = semver.maxSatisfying(versions, range); | ||
if (!matched) { | ||
console.warn(oneLine ` | ||
Cannot find local package ${highlight(depName)} satisfying ${highlight(range)} | ||
`); | ||
unmatched.push({ pkgName: depName, range }); | ||
return ''; | ||
} | ||
const matchedPkg = pkgs.find(pkg => pkg.manifest.name === depName && pkg.manifest.version === matched); | ||
return createPkgSpec(matchedPkg); | ||
return matchedPkg.path; | ||
}) | ||
@@ -62,18 +58,6 @@ .filter(Boolean); | ||
for (let pkg of pkgs) { | ||
const spec = createPkgSpec(pkg); | ||
if (pkgMap[spec]) { | ||
throw new Error(`There are two ${pkg.manifest.name} packages of the same version in the monorepo. | ||
Either remove or ignore one of them. | ||
One at ${pkgMap[spec].path} | ||
The other at ${pkg.path}`); | ||
} | ||
pkgMap[spec] = pkg; | ||
pkgMap[pkg.path] = pkg; | ||
} | ||
return pkgMap; | ||
} | ||
function createPkgSpec(pkg) { | ||
if (!pkg.manifest.name || !pkg.manifest.version) | ||
return pkg.path; | ||
return `${pkg.manifest.name}@${pkg.manifest.version}`; | ||
} | ||
//# sourceMappingURL=index.js.map |
{ | ||
"name": "pkgs-graph", | ||
"version": "1.1.1", | ||
"version": "2.0.0-0", | ||
"description": "Create a graph from an array of packages", | ||
@@ -36,14 +36,9 @@ "main": "lib/index.js", | ||
"dependencies": { | ||
"@types/common-tags": "^1.2.5", | ||
"@types/node": "^8.5.0", | ||
"@types/ramda": "^0.25.8", | ||
"@types/semver": "^5.3.31", | ||
"chalk": "^2.3.0", | ||
"common-tags": "^1.4.0", | ||
"find-packages": "^2.0.0", | ||
"npm-package-arg": "^6.0.0", | ||
"ramda": "^0.25.0", | ||
"semver": "^5.3.0", | ||
"toposort": "^1.0.3" | ||
"semver": "^5.3.0" | ||
} | ||
} |
@@ -18,3 +18,3 @@ # pkgs-graph | ||
const graph = createPkgsGraph([ | ||
const {graph} = createPkgsGraph([ | ||
{ | ||
@@ -28,3 +28,3 @@ manifest: { | ||
}, | ||
path: 'zkochan/src/foo', | ||
path: '/home/zkochan/src/foo', | ||
}, | ||
@@ -36,3 +36,3 @@ { | ||
}, | ||
path: 'zkochan/src/bar', | ||
path: '/home/zkochan/src/bar', | ||
} | ||
@@ -43,4 +43,4 @@ ]) | ||
//> { | ||
// 'foo@1.0.0': { | ||
// dependencies: ['bar@1.1.0'], | ||
// '/home/zkochan/src/foo': { | ||
// dependencies: ['/home/zkochan/src/bar'], | ||
// manifest: { | ||
@@ -53,5 +53,4 @@ // name: 'foo', | ||
// }, | ||
// path: 'zkochan/src/foo', | ||
// }, | ||
// 'bar@1.1.0': { | ||
// '/home/zkochan/src/bar': { | ||
// dependencies: [], | ||
@@ -62,3 +61,2 @@ // manifest: { | ||
// }, | ||
// path: 'zkochan/src/bar', | ||
// }, | ||
@@ -65,0 +63,0 @@ // } |
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
No v1
QualityPackage is not semver >=1. This means it is not stable and does not support ^ ranges.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
6
9048
88
1
68
- Removed@types/common-tags@^1.2.5
- Removedchalk@^2.3.0
- Removedcommon-tags@^1.4.0
- Removedfind-packages@^2.0.0
- Removedtoposort@^1.0.3
- Removed@mrmlnc/readdir-enhanced@2.2.1(transitive)
- Removed@nodelib/fs.stat@1.1.3(transitive)
- Removed@types/common-tags@1.8.4(transitive)
- Removed@types/node@9.6.61(transitive)
- Removedansi-styles@3.2.1(transitive)
- Removedarr-diff@4.0.0(transitive)
- Removedarr-flatten@1.1.0(transitive)
- Removedarr-union@3.1.0(transitive)
- Removedarray-unique@0.3.2(transitive)
- Removedassign-symbols@1.0.0(transitive)
- Removedatob@2.1.2(transitive)
- Removedbase@0.11.2(transitive)
- Removedbraces@2.3.2(transitive)
- Removedcache-base@1.0.1(transitive)
- Removedcall-me-maybe@1.0.2(transitive)
- Removedchalk@2.4.2(transitive)
- Removedclass-utils@0.3.6(transitive)
- Removedcollection-visit@1.0.0(transitive)
- Removedcolor-convert@1.9.3(transitive)
- Removedcolor-name@1.1.3(transitive)
- Removedcommon-tags@1.8.2(transitive)
- Removedcomponent-emitter@1.3.1(transitive)
- Removedcopy-descriptor@0.1.1(transitive)
- Removeddebug@2.6.9(transitive)
- Removeddecode-uri-component@0.2.2(transitive)
- Removeddefine-property@0.2.51.0.02.0.2(transitive)
- Removederror-ex@1.3.2(transitive)
- Removedescape-string-regexp@1.0.5(transitive)
- Removedexpand-brackets@2.1.4(transitive)
- Removedextend-shallow@2.0.13.0.2(transitive)
- Removedextglob@2.0.4(transitive)
- Removedfast-glob@2.2.7(transitive)
- Removedfill-range@4.0.0(transitive)
- Removedfind-packages@2.2.0(transitive)
- Removedfor-in@1.0.2(transitive)
- Removedfragment-cache@0.2.1(transitive)
- Removedfunction-bind@1.1.2(transitive)
- Removedget-value@2.0.6(transitive)
- Removedglob-parent@3.1.0(transitive)
- Removedglob-to-regexp@0.3.0(transitive)
- Removedgraceful-fs@4.2.11(transitive)
- Removedhas-flag@3.0.0(transitive)
- Removedhas-value@0.3.11.0.0(transitive)
- Removedhas-values@0.1.41.0.0(transitive)
- Removedhasown@2.0.2(transitive)
- Removedis-accessor-descriptor@1.0.1(transitive)
- Removedis-arrayish@0.2.1(transitive)
- Removedis-buffer@1.1.6(transitive)
- Removedis-core-module@2.16.1(transitive)
- Removedis-data-descriptor@1.0.1(transitive)
- Removedis-descriptor@0.1.71.0.3(transitive)
- Removedis-extendable@0.1.11.0.1(transitive)
- Removedis-extglob@2.1.1(transitive)
- Removedis-glob@3.1.04.0.3(transitive)
- Removedis-number@3.0.0(transitive)
- Removedis-plain-object@2.0.4(transitive)
- Removedis-windows@1.0.2(transitive)
- Removedisarray@1.0.0(transitive)
- Removedisobject@2.1.03.0.1(transitive)
- Removedjson-parse-better-errors@1.0.2(transitive)
- Removedkind-of@3.2.24.0.06.0.3(transitive)
- Removedload-json-file@4.0.0(transitive)
- Removedmap-cache@0.2.2(transitive)
- Removedmap-visit@1.0.0(transitive)
- Removedmerge2@1.4.1(transitive)
- Removedmicromatch@3.1.10(transitive)
- Removedmixin-deep@1.3.2(transitive)
- Removedms@2.0.0(transitive)
- Removednanomatch@1.2.13(transitive)
- Removednormalize-package-data@2.5.0(transitive)
- Removedobject-copy@0.1.0(transitive)
- Removedobject-visit@1.0.1(transitive)
- Removedobject.pick@1.3.0(transitive)
- Removedp-filter@1.0.0(transitive)
- Removedp-map@1.2.0(transitive)
- Removedparse-json@4.0.0(transitive)
- Removedpascalcase@0.1.1(transitive)
- Removedpath-dirname@1.0.2(transitive)
- Removedpath-parse@1.0.7(transitive)
- Removedpath-type@3.0.0(transitive)
- Removedpify@3.0.0(transitive)
- Removedposix-character-classes@0.1.1(transitive)
- Removedread-pkg@3.0.0(transitive)
- Removedregex-not@1.0.2(transitive)
- Removedrepeat-element@1.1.4(transitive)
- Removedrepeat-string@1.6.1(transitive)
- Removedresolve@1.22.10(transitive)
- Removedresolve-url@0.2.1(transitive)
- Removedret@0.1.15(transitive)
- Removedsafe-regex@1.1.0(transitive)
- Removedset-value@2.0.1(transitive)
- Removedsnapdragon@0.8.2(transitive)
- Removedsnapdragon-node@2.1.1(transitive)
- Removedsnapdragon-util@3.0.1(transitive)
- Removedsource-map@0.5.7(transitive)
- Removedsource-map-resolve@0.5.3(transitive)
- Removedsource-map-url@0.4.1(transitive)
- Removedspdx-correct@3.2.0(transitive)
- Removedspdx-exceptions@2.5.0(transitive)
- Removedspdx-expression-parse@3.0.1(transitive)
- Removedspdx-license-ids@3.0.20(transitive)
- Removedsplit-string@3.1.0(transitive)
- Removedstatic-extend@0.1.2(transitive)
- Removedstrip-bom@3.0.0(transitive)
- Removedsupports-color@5.5.0(transitive)
- Removedsupports-preserve-symlinks-flag@1.0.0(transitive)
- Removedto-object-path@0.3.0(transitive)
- Removedto-regex@3.0.2(transitive)
- Removedto-regex-range@2.1.1(transitive)
- Removedtoposort@1.0.7(transitive)
- Removedunion-value@1.0.1(transitive)
- Removedunset-value@1.0.0(transitive)
- Removedurix@0.1.0(transitive)
- Removeduse@3.1.1(transitive)
- Removedvalidate-npm-package-license@3.0.4(transitive)