Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

pkgs-graph

Package Overview
Dependencies
Maintainers
1
Versions
30
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

pkgs-graph - npm Package Compare versions

Comparing version 1.1.1 to 2.0.0-0

8

lib/index.d.ts

@@ -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;
}>;
};

38

lib/index.js
"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

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