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 1.0.8 to 1.0.9

11

CHANGELOG.md

@@ -0,1 +1,12 @@

## 1.0.9 (2019-12-31)
[Compare `check-peer-dependencies` versions 1.0.8 and 1.0.9](https://github.com/christopherthielen/check-peer-dependencies/compare/1.0.8...1.0.9)
### Features
* **debug:** Added a --debug cli flag ([862232e](https://github.com/christopherthielen/check-peer-dependencies/commit/862232e))
* **orderBy:** Added a --orderBy cli flag ([9e7b8af](https://github.com/christopherthielen/check-peer-dependencies/commit/9e7b8af))
## 1.0.8 (2019-12-27)

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

66

dist/checkPeerDependencies.js

@@ -20,4 +20,4 @@ #!/usr/bin/env node

var solution_1 = require("./solution");
function getAllNestedPeerDependencies() {
var gatheredDependencies = packageUtils_1.gatherPeerDependencies(".");
function getAllNestedPeerDependencies(options) {
var gatheredDependencies = packageUtils_1.gatherPeerDependencies(".", options);
var allNestedPeerDependencies = gatheredDependencies.map(function (dep) {

@@ -29,21 +29,43 @@ var installedVersion = packageUtils_1.getInstalledVersion(dep);

});
return allNestedPeerDependencies.sort(function (a, b) { return ("" + a.depender + a.name).localeCompare("" + b.depender + b.name); });
return allNestedPeerDependencies;
}
var recursiveCount = 0;
function checkPeerDependencies(packageManager, installMissingPeerDependencies) {
var allNestedPeerDependencies = getAllNestedPeerDependencies();
allNestedPeerDependencies.forEach(function (dep) {
if (dep.semverSatisfies) {
console.log("\u2705 " + dep.depender + "@" + dep.dependerVersion + " requires " + dep.name + " " + dep.version + " (" + 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)");
}
else if (dep.installedVersion) {
console.log("\u274C " + dep.depender + "@" + dep.dependerVersion + " requires " + dep.name + " " + dep.version + " (" + dep.installedVersion + " is installed)");
}
else {
console.log("\u274C " + dep.depender + "@" + dep.dependerVersion + " requires " + dep.name + " " + dep.version + " (" + dep.name + " is not installed)");
}
});
var reportPeerDependencyStatusByDepender = function (dep) {
if (dep.semverSatisfies) {
console.log("\u2705 " + dep.depender + "@" + dep.dependerVersion + " requires " + dep.name + " " + dep.version + " (" + 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)");
}
else if (dep.installedVersion) {
console.log("\u274C " + dep.depender + "@" + dep.dependerVersion + " requires " + dep.name + " " + dep.version + " (" + dep.installedVersion + " is installed)");
}
else {
console.log("\u274C " + dep.depender + "@" + dep.dependerVersion + " requires " + dep.name + " " + dep.version + " (" + dep.name + " is not installed)");
}
};
var reportPeerDependencyStatusByDependee = function (dep) {
if (dep.semverSatisfies) {
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(reportPeerDependencyStatusByDepender);
}
else if (options.orderBy === 'dependee') {
allNestedPeerDependencies.sort(function (a, b) { return ("" + a.name + a.depender).localeCompare("" + b.name + b.depender); });
allNestedPeerDependencies.forEach(reportPeerDependencyStatusByDependee);
}
var problems = allNestedPeerDependencies.filter(function (dep) { return !dep.semverSatisfies && !dep.isYalc; });

@@ -72,3 +94,3 @@ if (!problems.length) {

var commandLines = packageManager_1.getCommandLines(packageManager, installs, upgrades);
if (installMissingPeerDependencies && commandLines.length > 0) {
if (options.install && commandLines.length > 0) {
console.log('Installing peerDependencies...');

@@ -81,3 +103,3 @@ console.log();

});
var newUnsatisfiedDeps = getAllNestedPeerDependencies()
var newUnsatisfiedDeps = getAllNestedPeerDependencies(options)
.filter(function (dep) { return !dep.semverSatisfies; })

@@ -91,3 +113,3 @@ .filter(function (dep) { return !nosolution.some(function (x) { return isSameDep(x.problem, dep); }); });

if (++recursiveCount < 5) {
return checkPeerDependencies(packageManager, installMissingPeerDependencies);
return checkPeerDependencies(packageManager, options);
}

@@ -94,0 +116,0 @@ else {

@@ -21,2 +21,11 @@ #!/usr/bin/env node

})
.option('orderBy', {
choices: ['depender', 'dependee'],
"default": 'depender',
description: 'Order the output by depender or dependee'
})
.option('debug', {
boolean: true,
description: 'Print debugging information'
})
.option('install', {

@@ -36,2 +45,2 @@ boolean: true,

var packageManager = packageManager_1.getPackageManager(options.yarn, options.npm);
checkPeerDependencies_1.checkPeerDependencies(packageManager, options.install);
checkPeerDependencies_1.checkPeerDependencies(packageManager, options);

@@ -7,14 +7,21 @@ "use strict";

var readJson_1 = require("./readJson");
function gatherPeerDependencies(packagePath) {
function gatherPeerDependencies(packagePath, options) {
var peerDeps = [];
walkPackageDependencyTree(packagePath, function (path, json, deps) {
var visitor = function (path, json, deps) {
peerDeps = peerDeps.concat(deps.peerDependencies);
}, []);
};
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;
};
return peerDeps.reduce(function (acc, dep) {
return acc.some(function (dep2) { return dep.name === dep2.name && dep.version === dep2.version; }) ? acc : acc.concat(dep);
return acc.some(function (dep2) { return isSame(dep, dep2); }) ? acc : acc.concat(dep);
}, []);
}
exports.gatherPeerDependencies = gatherPeerDependencies;
function walkPackageDependencyTree(packagePath, visitor, visitedPaths) {
function walkPackageDependencyTree(packagePath, visitor, visitedPaths, options) {
if (visitedPaths.includes(packagePath)) {

@@ -30,2 +37,6 @@ return;

var packageDependencies = getPackageDependencies(packagePath, packageJson);
if (options.debug) {
console.log(packageJsonPath);
packageDependencies.peerDependencies.forEach(function (dep) { return console.log(dep); });
}
visitor(packagePath, packageJson, packageDependencies);

@@ -40,3 +51,3 @@ function walkDependency(dependency) {

}
walkPackageDependencyTree(dependencyPath, visitor, visitedPaths);
walkPackageDependencyTree(dependencyPath, visitor, visitedPaths, options);
}

@@ -81,2 +92,3 @@ packageDependencies.dependencies.forEach(walkDependency);

}
// noinspection JSUnusedAssignment
return packagePath;

@@ -83,0 +95,0 @@ }

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