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

check-peer-dependencies

Package Overview
Dependencies
Maintainers
1
Versions
24
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

check-peer-dependencies - npm Package Compare versions

Comparing version 2.0.0 to 2.0.1

11

CHANGELOG.md

@@ -0,1 +1,11 @@

## 2.0.1 (2020-04-10)
[Compare `check-peer-dependencies` versions 2.0.0 and 2.0.1](https://github.com/christopherthielen/check-peer-dependencies/compare/2.0.0...2.0.1)
### Bug Fixes
* **peerDevDependencies:** Use an array of package names in 'peerDevDependencies' in conjunction with the standard 'peerDependencies' object to install peer deps as devDependencies. ([681a80b](https://github.com/christopherthielen/check-peer-dependencies/commit/681a80b))
# 2.0.0 (2020-04-10)

@@ -6,3 +16,2 @@ [Compare `check-peer-dependencies` versions 1.0.11 and 2.0.0](https://github.com/christopherthielen/check-peer-dependencies/compare/1.0.11...2.0.0)

* **check-peer-dependencies-optional-dependency:** Added a workaround for yarn swallowing postinstall script output ([a9c9fdf](https://github.com/christopherthielen/check-peer-dependencies/commit/a9c9fdf))
* **peerDevDependencies:** Add support for 'peerDevDependencies' -- 'peerDependencies' that should be installed as 'devDependencies' ([47d40ef](https://github.com/christopherthielen/check-peer-dependencies/commit/47d40ef))

@@ -9,0 +18,0 @@

47

dist/checkPeerDependencies.js

@@ -14,9 +14,2 @@ #!/usr/bin/env node

};
var __spreadArrays = (this && this.__spreadArrays) || function () {
for (var s = 0, i = 0, il = arguments.length; i < il; i++) s += arguments[i].length;
for (var r = Array(s), k = 0, i = 0; i < il; i++)
for (var a = arguments[i], j = 0, jl = a.length; j < jl; j++, k++)
r[k] = a[j];
return r;
};
exports.__esModule = true;

@@ -36,5 +29,3 @@ var semver = require("semver");

}
var allNestedPeerDependencies = gatheredDependencies.peerDependencies.map(applySemverInformation);
var allNestedPeerDevDependencies = gatheredDependencies.peerDevDependencies.map(applySemverInformation);
return { allNestedPeerDependencies: allNestedPeerDependencies, allNestedPeerDevDependencies: allNestedPeerDevDependencies };
return gatheredDependencies.map(applySemverInformation);
}

@@ -75,13 +66,12 @@ var recursiveCount = 0;

function checkPeerDependencies(packageManager, options) {
var _a = getAllNestedPeerDependencies(options), allNestedPeerDependencies = _a.allNestedPeerDependencies, allNestedPeerDevDependencies = _a.allNestedPeerDevDependencies;
var combinedPeerAndPeerDevDependencies = __spreadArrays(allNestedPeerDependencies, allNestedPeerDevDependencies);
var allNestedPeerDependencies = getAllNestedPeerDependencies(options);
if (options.orderBy === 'depender') {
combinedPeerAndPeerDevDependencies.sort(function (a, b) { return ("" + a.depender + a.name).localeCompare("" + b.depender + b.name); });
combinedPeerAndPeerDevDependencies.forEach(function (dep) { return reportPeerDependencyStatusByDepender(dep, options); });
allNestedPeerDependencies.sort(function (a, b) { return ("" + a.depender + a.name).localeCompare("" + b.depender + b.name); });
allNestedPeerDependencies.forEach(function (dep) { return reportPeerDependencyStatusByDepender(dep, options); });
}
else if (options.orderBy === 'dependee') {
combinedPeerAndPeerDevDependencies.sort(function (a, b) { return ("" + a.name + a.depender).localeCompare("" + b.name + b.depender); });
combinedPeerAndPeerDevDependencies.forEach(function (dep) { return reportPeerDependencyStatusByDependee(dep, options); });
allNestedPeerDependencies.sort(function (a, b) { return ("" + a.name + a.depender).localeCompare("" + b.name + b.depender); });
allNestedPeerDependencies.forEach(function (dep) { return reportPeerDependencyStatusByDependee(dep, options); });
}
var problems = combinedPeerAndPeerDevDependencies.filter(function (dep) { return !dep.semverSatisfies && !dep.isYalc; });
var problems = allNestedPeerDependencies.filter(function (dep) { return !dep.semverSatisfies && !dep.isYalc; });
if (!problems.length) {

@@ -94,3 +84,3 @@ console.log(' ✅ All peer dependencies are met');

console.log();
var resolutions = solution_1.findPossibleResolutions(problems, allNestedPeerDependencies, allNestedPeerDevDependencies);
var resolutions = solution_1.findPossibleResolutions(problems, allNestedPeerDependencies);
var resolutionsWithSolutions = resolutions.filter(function (r) { return r.resolution; });

@@ -101,3 +91,3 @@ var nosolution = resolutions.filter(function (r) { return !r.resolution; });

var errorPrefix = "Unable to find a version of " + name + " that satisfies the following peerDependencies:";
var peerDepRanges = combinedPeerAndPeerDevDependencies.filter(function (dep) { return dep.name === name; })
var peerDepRanges = allNestedPeerDependencies.filter(function (dep) { return dep.name === name; })
.reduce(function (acc, dep) { return acc.includes(dep.version) ? acc : acc.concat(dep.version); }, []);

@@ -118,5 +108,5 @@ console.error(" \u274C " + errorPrefix + " " + peerDepRanges.join(" and "));

});
var checkAgain = getAllNestedPeerDependencies(options);
var newUnsatisfiedDeps = __spreadArrays(checkAgain.allNestedPeerDependencies, checkAgain.allNestedPeerDevDependencies).filter(function (dep) { return !dep.semverSatisfies; })
.filter(function (dep) { return !nosolution.some(function (x) { return isSameDep(x.problem, dep); }); });
var newUnsatisfiedDeps = getAllNestedPeerDependencies(options)
.filter(function (dep) { return !dep.semverSatisfies; })
.filter(function (dep) { return !nosolution.some(function (x) { return packageUtils_1.isSameDep(x.problem, dep); }); });
if (nosolution.length === 0 && newUnsatisfiedDeps.length === 0) {

@@ -146,14 +136,1 @@ console.log('All peer dependencies are met');

exports.checkPeerDependencies = checkPeerDependencies;
function isSameDep(a, b) {
var keys = [
"name",
"version",
"depender",
"dependerPath",
"dependerVersion",
"installedVersion",
"semverSatisfies",
"isYalc"
];
return keys.every(function (key) { return a[key] === b[key]; });
}
"use strict";
var __assign = (this && this.__assign) || function () {
__assign = Object.assign || function(t) {
for (var s, i = 1, n = arguments.length; i < n; i++) {
s = arguments[i];
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
t[p] = s[p];
}
return t;
};
return __assign.apply(this, arguments);
};
exports.__esModule = true;

@@ -9,22 +20,10 @@ var fs = require("fs");

var peerDeps = [];
var peerDevDeps = [];
var visitor = function (path, json, deps) {
peerDeps = peerDeps.concat(deps.peerDependencies);
peerDevDeps = peerDevDeps.concat(deps.peerDevDependencies);
};
walkPackageDependencyTree(packagePath, visitor, [], options);
// Eliminate duplicates
var isSame = function (dep, dep2) {
return dep.name === dep2.name
&& dep.version === dep2.version
&& dep.depender === dep2.depender
&& dep.dependerVersion === dep2.dependerVersion;
};
var peerDependencies = peerDeps.reduce(function (acc, dep) {
return acc.some(function (dep2) { return isSame(dep, dep2); }) ? acc : acc.concat(dep);
return peerDeps.reduce(function (acc, dep) {
return acc.some(function (dep2) { return isSameDep(dep, dep2); }) ? acc : acc.concat(dep);
}, []);
var peerDevDependencies = peerDevDeps.reduce(function (acc, dep) {
return acc.some(function (dep2) { return isSame(dep, dep2); }) ? acc : acc.concat(dep);
}, []);
return { peerDependencies: peerDependencies, peerDevDependencies: peerDevDependencies };
}

@@ -71,3 +70,6 @@ exports.gatherPeerDependencies = gatherPeerDependencies;

function getPackageDependencies(packagePath, packageJson) {
var name = packageJson.name, _a = packageJson.dependencies, dependencies = _a === void 0 ? {} : _a, _b = packageJson.devDependencies, devDependencies = _b === void 0 ? {} : _b, _c = packageJson.peerDependencies, peerDependencies = _c === void 0 ? {} : _c, _d = packageJson.peerDevDependencies, peerDevDependencies = _d === void 0 ? {} : _d;
var name = packageJson.name, _a = packageJson.dependencies, dependencies = _a === void 0 ? {} : _a, _b = packageJson.devDependencies, devDependencies = _b === void 0 ? {} : _b, _c = packageJson.peerDependencies, peerDependencies = _c === void 0 ? {} : _c, _d = packageJson.peerDevDependencies, peerDevDependencies = _d === void 0 ? [] : _d;
var applyPeerDevDependencies = function (dep) {
return (__assign(__assign({}, dep), { isPeerDevDependency: peerDevDependencies.includes(dep.name) }));
};
return {

@@ -77,4 +79,4 @@ packageName: name,

devDependencies: buildDependencyArray(packagePath, packageJson, devDependencies),
peerDependencies: buildDependencyArray(packagePath, packageJson, peerDependencies),
peerDevDependencies: buildDependencyArray(packagePath, packageJson, peerDevDependencies)
peerDependencies: buildDependencyArray(packagePath, packageJson, peerDependencies).map(applyPeerDevDependencies),
peerDevDependencies: peerDevDependencies
};

@@ -113,1 +115,16 @@ }

exports.getInstalledVersion = getInstalledVersion;
function isSameDep(a, b) {
var keys = [
"name",
"version",
"depender",
"dependerPath",
"dependerVersion",
"installedVersion",
"semverSatisfies",
"isYalc",
"isPeerDevDependency",
];
return keys.every(function (key) { return a[key] === b[key]; });
}
exports.isSameDep = isSameDep;
"use strict";
var __spreadArrays = (this && this.__spreadArrays) || function () {
for (var s = 0, i = 0, il = arguments.length; i < il; i++) s += arguments[i].length;
for (var r = Array(s), k = 0, i = 0; i < il; i++)
for (var a = arguments[i], j = 0, jl = a.length; j < jl; j++, k++)
r[k] = a[j];
return r;
};
exports.__esModule = true;

@@ -23,9 +16,7 @@ var semver = require("semver");

}
function findPossibleResolutions(problems, peerDependencies, peerDevDependencies) {
var allPeerDependencies = __spreadArrays(peerDependencies, peerDevDependencies);
function findPossibleResolutions(problems, allPeerDependencies) {
var uniq = problems.reduce(function (acc, problem) { return acc.some(function (dep) { return dep.name === problem.name; }) ? acc : acc.concat(problem); }, []);
return uniq.map(function (problem) {
var shouldUpgrade = !!problem.installedVersion;
var isPeerDevDep = peerDevDependencies.some(function (dep) { return dep.name === problem.name; });
var resolutionType = shouldUpgrade ? 'upgrade' : isPeerDevDep ? 'devInstall' : 'install';
var resolutionType = shouldUpgrade ? 'upgrade' : problem.isPeerDevDependency ? 'devInstall' : 'install';
var resolutionVersion = findPossibleResolution(problem.name, allPeerDependencies);

@@ -32,0 +23,0 @@ var resolution = resolutionVersion ? problem.name + "@" + resolutionVersion : null;

{
"name": "check-peer-dependencies",
"version": "2.0.0",
"version": "2.0.1",
"description": "Checks peer dependencies of the current package. Offers solutions for any that are unmet.",

@@ -5,0 +5,0 @@ "main": "dist/check_peer_dependencies.js",

@@ -29,2 +29,21 @@ ## check-peer-dependencies

## Installing peerDependencies as devDependencies
If a package has a peerDependency that should be installed as a devDependency by,
it can list the package name in "peerDevDependencies".
This is not a standard and is only understood by this `check-peer-dependencies`.
```json
{
"name": "somepackage",
"peerDependencies": {
"react": "16.x",
"react-dom": "16.x",
"typescript": "~3.8.0",
"eslint": "*"
},
"peerDevDependencies": ["typescript", "eslint"]
}
```
## Example outputs:

@@ -37,8 +56,3 @@

❯ npx check-peer-dependencies
✅ @uirouter/visualizer@6.0.2 requires @uirouter/core >=5.0.0 (5.0.23 is installed)
✅ ajv-keywords@3.4.1 requires ajv ^6.9.1 (6.10.2 is installed)
✅ @uirouter/react@0.8.9 requires react ^16.3.0 (16.10.1 is installed)
✅ react-dom@16.10.1 requires react ^16.0.0 (16.10.1 is installed)
✅ file-loader@1.1.11 requires webpack ^2.0.0 || ^3.0.0 || ^4.0.0 (4.39.1 is installed)
No problems found!
✅ All peer dependencies are met
```

@@ -51,10 +65,3 @@

❯ npx check-peer-dependencies
✅ @uirouter/angular@5.0.0 requires @angular/common ^5.0.0 || ^6.0.0 || ^7.0.0 || ^8.0.0 (5.2.11 is installed)
✅ @uirouter/angular-hybrid@9.0.0 requires @angular/core ^5.0.0 || ^6.0.0 || ^7.0.0 || ^8.0.0 (5.2.11 is installed)
❌ @uirouter/angular@5.0.0 requires @angular/router ^5.0.0 || ^6.0.0 || ^7.0.0 || ^8.0.0 (@angular/router is not installed)
✅ @uirouter/angular-hybrid@9.0.0 requires @angular/upgrade ^5.0.0 || ^6.0.0 || ^7.0.0 || ^8.0.0 (5.2.11 is installed)
✅ @uirouter/rx@0.6.0 requires @uirouter/core >=6.0.1 (6.0.1 is installed)
✅ @uirouter/angular-hybrid@9.0.0 requires angular ^1.5.0 (1.7.8 is installed)
✅ @uirouter/angularjs@1.0.23 requires angular >=1.2.0 (1.7.8 is installed)
✅ @uirouter/rx@0.6.0 requires rxjs ^6.0.0 (6.5.3 is installed)

@@ -69,17 +76,5 @@ Searching for solutions:

❯ npx check-peer-dependencies
✅ @angular/forms@9.0.0-next.9 requires @angular/common 9.0.0-next.9 (9.0.0-next.9 is installed)
❌ @uirouter/angular@5.0.0 requires @angular/common ^5.0.0 || ^6.0.0 || ^7.0.0 || ^8.0.0 (9.0.0-next.9 is installed)
✅ @angular/platform-browser-dynamic@9.0.0-next.9 requires @angular/compiler 9.0.0-next.9 (9.0.0-next.9 is installed)
✅ @angular/common@9.0.0-next.9 requires @angular/core 9.0.0-next.9 (9.0.0-next.9 is installed)
❌ @uirouter/angular@5.0.0 requires @angular/core ^5.0.0 || ^6.0.0 || ^7.0.0 || ^8.0.0 (9.0.0-next.9 is installed)
✅ @angular/forms@9.0.0-next.9 requires @angular/platform-browser 9.0.0-next.9 (9.0.0-next.9 is installed)
❌ @uirouter/angular@5.0.0 requires @angular/router ^5.0.0 || ^6.0.0 || ^7.0.0 || ^8.0.0 (9.0.0-next.9 is installed)
✅ @uirouter/rx@0.6.0 requires @uirouter/core >=6.0.1 (6.0.1 is installed)
✅ @uirouter/visualizer@6.0.2 requires @uirouter/core >=5.0.0 (6.0.1 is installed)
✅ ajv-keywords@3.1.0 requires ajv ^6.0.0 (6.10.2 is installed)
✅ @angular/common@9.0.0-next.9 requires rxjs ^6.5.3 (6.5.3 is installed)
✅ @uirouter/rx@0.6.0 requires rxjs ^6.0.0 (6.5.3 is installed)
✅ ts-helpers@1.1.2 requires typescript >=1.8.0 <2.1.0 || >=1.9.0-dev || >=2.0.0-dev || || >=2.1.0-dev (3.5.3 is installed)
✅ file-loader@1.1.11 requires webpack ^2.0.0 || ^3.0.0 || ^4.0.0 (4.41.0 is installed)
✅ @angular/core@9.0.0-next.9 requires zone.js ~0.10.2 (0.10.2 is installed)

@@ -93,4 +88,1 @@ Searching for solutions:

## Running as postinstall script using `yarn` package manager
Please see [check-peer-dependencies-optional-dependency](https://github.com/christopherthielen/check-peer-dependencies/tree/master/packages/check-peer-dependencies-optional-dependency)

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