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.6 to 3.0.0

18

CHANGELOG.md

@@ -0,1 +1,19 @@

# 3.0.0 (2020-12-22)
[Compare `check-peer-dependencies` versions 2.0.6 and 3.0.0](https://github.com/christopherthielen/check-peer-dependencies/compare/2.0.6...3.0.0)
### Features
* **findSolutions:** Add a toggle to find solutions and print installation commands. ([c34735a](https://github.com/christopherthielen/check-peer-dependencies/commit/c34735a))
* **orderBy:** Change default orderBy to 'dependee' ([e77e069](https://github.com/christopherthielen/check-peer-dependencies/commit/e77e069))
* **report:** For a given unmet peer dependency, show every related peer dependency, even if currently met ([516a259](https://github.com/christopherthielen/check-peer-dependencies/commit/516a259))
### BREAKING CHANGES
* **orderBy:** default order changed from 'depender' to 'dependee'
* **findSolutions:** no longer prints installation commands by default, instead prints a message about using --install
## 2.0.6 (2020-09-20)

@@ -2,0 +20,0 @@ [Compare `check-peer-dependencies` versions 2.0.5 and 2.0.6](https://github.com/christopherthielen/check-peer-dependencies/compare/2.0.5...2.0.6)

143

dist/checkPeerDependencies.js

@@ -31,49 +31,22 @@ #!/usr/bin/env node

var recursiveCount = 0;
var reportPeerDependencyStatusByDepender = function (dep, options) {
var reportPeerDependencyStatus = function (dep, byDepender, force) {
var message = byDepender ?
dep.depender + "@" + dep.dependerVersion + " requires " + dep.name + " " + dep.version :
dep.name + " " + dep.version + " is required by " + dep.depender + "@" + dep.dependerVersion;
if (dep.semverSatisfies) {
if (options.verbose) {
console.log(" \u2705 " + dep.depender + "@" + dep.dependerVersion + " requires " + dep.name + " " + dep.version + " (" + dep.installedVersion + " is installed)");
if (force) {
console.log(" \u2705 " + message + " (" + dep.installedVersion + " is installed)");
}
}
else if (dep.isYalc) {
console.log(" \u2611\uFE0F " + dep.depender + "@" + dep.dependerVersion + " requires " + dep.name + " " + dep.version + " (" + dep.installedVersion + " is installed via yalc)");
console.log(" \u2611\uFE0F " + message + " (" + dep.installedVersion + " is installed via yalc)");
}
else if (dep.installedVersion) {
console.log(" \u274C " + dep.depender + "@" + dep.dependerVersion + " requires " + dep.name + " " + dep.version + " (" + dep.installedVersion + " is installed)");
console.log(" \u274C " + message + ") (" + dep.installedVersion + " is installed)");
}
else {
console.log(" \u274C " + dep.depender + "@" + dep.dependerVersion + " requires " + dep.name + " " + dep.version + " (" + dep.name + " is not installed)");
console.log(" \u274C " + message + " (" + dep.name + " is not installed)");
}
};
var reportPeerDependencyStatusByDependee = function (dep, options) {
if (dep.semverSatisfies) {
if (options.verbose) {
console.log(" \u2705 " + dep.name + " " + dep.version + " is required by " + dep.depender + "@" + dep.dependerVersion + " (" + dep.installedVersion + " is installed)");
}
}
else if (dep.isYalc) {
console.log(" \u2611\uFE0F " + dep.name + " " + dep.version + " is required by " + dep.depender + "@" + dep.dependerVersion + " (" + dep.installedVersion + " is installed via yalc)");
}
else if (dep.installedVersion) {
console.log(" \u274C " + dep.name + " " + dep.version + " is required by " + dep.depender + "@" + dep.dependerVersion + " (" + dep.installedVersion + " is installed)");
}
else {
console.log(" \u274C " + dep.name + " " + dep.version + " is required by " + dep.depender + "@" + dep.dependerVersion + " (" + dep.name + " is not installed)");
}
};
function checkPeerDependencies(packageManager, options) {
var allNestedPeerDependencies = getAllNestedPeerDependencies(options);
if (options.orderBy === 'depender') {
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') {
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 = allNestedPeerDependencies.filter(function (dep) { return !dep.semverSatisfies && !dep.isYalc; });
if (!problems.length) {
console.log(' ✅ All peer dependencies are met');
return;
}
function findSolutions(problems, allNestedPeerDependencies) {
console.log();

@@ -95,34 +68,80 @@ console.log('Searching for solutions...');

}
var commandLines = packageManager_1.getCommandLines(packageManager, resolutionsWithSolutions);
if (options.install && commandLines.length > 0) {
console.log('Installing peerDependencies...');
return { resolutionsWithSolutions: resolutionsWithSolutions, nosolution: nosolution };
}
function installPeerDependencies(commandLines, options, nosolution, packageManager) {
console.log('Installing peerDependencies...');
console.log();
commandLines.forEach(function (command) {
console.log("$ " + command);
shelljs_1.exec(command);
console.log();
commandLines.forEach(function (command) {
console.log("$ " + command);
shelljs_1.exec(command);
console.log();
});
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) {
console.log('All peer dependencies are met');
});
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) {
console.log('All peer dependencies are met');
}
if (newUnsatisfiedDeps.length > 0) {
console.log("Found " + newUnsatisfiedDeps.length + " new unmet peerDependencies...");
if (++recursiveCount < 5) {
return checkPeerDependencies(packageManager, options);
}
if (newUnsatisfiedDeps.length > 0) {
console.log("Found " + newUnsatisfiedDeps.length + " new unmet peerDependencies...");
if (++recursiveCount < 5) {
return checkPeerDependencies(packageManager, options);
}
else {
console.error('Recursion limit reached (5)');
process.exit(5);
}
else {
console.error('Recursion limit reached (5)');
process.exit(5);
}
}
return;
}
function report(options, allNestedPeerDependencies) {
if (options.orderBy === 'depender') {
allNestedPeerDependencies.sort(function (a, b) { return ("" + a.depender + a.name).localeCompare("" + b.depender + b.name); });
}
else if (options.orderBy == 'dependee') {
allNestedPeerDependencies.sort(function (a, b) { return ("" + a.name + a.depender).localeCompare("" + b.name + b.depender); });
}
allNestedPeerDependencies.forEach(function (dep) {
var isUnsatisfied = function (dep) { return !dep.semverSatisfies && !dep.isYalc; };
var relatedPeerDeps = allNestedPeerDependencies.filter(function (other) { return other.name === dep.name && other !== dep; });
var force = options.verbose || relatedPeerDeps.some(isUnsatisfied);
reportPeerDependencyStatus(dep, options.orderBy === 'depender', force);
});
}
function checkPeerDependencies(packageManager, options) {
var allNestedPeerDependencies = getAllNestedPeerDependencies(options);
report(options, allNestedPeerDependencies);
var problems = allNestedPeerDependencies.filter(function (dep) { return !dep.semverSatisfies && !dep.isYalc; });
if (!problems.length) {
console.log(' ✅ All peer dependencies are met');
return;
}
else if (commandLines.length > 0) {
console.log("Install peerDependencies using " + (commandLines.length > 1 ? 'these commands:' : 'this command') + ":");
if (options.install) {
var _a = findSolutions(problems, allNestedPeerDependencies), nosolution = _a.nosolution, resolutionsWithSolutions = _a.resolutionsWithSolutions;
var commandLines = packageManager_1.getCommandLines(packageManager, resolutionsWithSolutions);
if (commandLines.length) {
return installPeerDependencies(commandLines, options, nosolution, packageManager);
}
}
else if (options.findSolutions) {
var resolutionsWithSolutions = findSolutions(problems, allNestedPeerDependencies).resolutionsWithSolutions;
var commandLines = packageManager_1.getCommandLines(packageManager, resolutionsWithSolutions);
if (commandLines.length) {
console.log();
console.log("Install peerDependencies using " + (commandLines.length > 1 ? 'these commands:' : 'this command') + ":");
console.log();
commandLines.forEach(function (command) { return console.log(command); });
console.log();
}
}
else {
console.log();
commandLines.forEach(function (command) { return console.log(command); });
console.log("Search for solutions using this command:");
console.log();
console.log("npx check-peer-dependencies --findSolutions");
console.log();
console.log("Install peerDependencies using this command:");
console.log();
console.log("npx check-peer-dependencies --install");
console.log();
}

@@ -129,0 +148,0 @@ process.exit(1);

@@ -23,3 +23,3 @@ #!/usr/bin/env node

choices: ['depender', 'dependee'],
"default": 'depender',
"default": 'dependee',
description: 'Order the output by depender or dependee'

@@ -42,2 +42,7 @@ })

})
.option('findSolutions', {
boolean: true,
"default": false,
description: 'Search for solutions and print package installation commands'
})
.option('install', {

@@ -44,0 +49,0 @@ boolean: true,

@@ -29,2 +29,3 @@ "use strict";

var requiredPeerVersions = allPeerDeps.filter(function (dep) { return dep.name === packageName; });
// todo: skip this step if only one required peer version and it's an exact version
var command = "npm view " + packageName + " versions";

@@ -31,0 +32,0 @@ var rawVersionsInfo;

{
"name": "check-peer-dependencies",
"version": "2.0.6",
"version": "3.0.0",
"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",

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