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

@times-components/depend

Package Overview
Dependencies
Maintainers
3
Versions
57
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@times-components/depend - npm Package Compare versions

Comparing version 2.1.26 to 2.1.27

8

CHANGELOG.md

@@ -6,2 +6,10 @@ # Change Log

## [2.1.27](https://github.com/newsuk/times-components/compare/@times-components/depend@2.1.26...@times-components/depend@2.1.27) (2021-07-21)
**Note:** Version bump only for package @times-components/depend
## [2.1.26](https://github.com/newsuk/times-components/compare/@times-components/depend@2.1.25...@times-components/depend@2.1.26) (2019-10-11)

@@ -8,0 +16,0 @@

2

dist/cli-parser.js

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

var _interopRequireWildcard=require("@babel/runtime/helpers/interopRequireWildcard");var _interopRequireDefault=require("@babel/runtime/helpers/interopRequireDefault");Object.defineProperty(exports,"__esModule",{value:true});exports.default=void 0;var _defineProperty2=_interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));var _slicedToArray2=_interopRequireDefault(require("@babel/runtime/helpers/slicedToArray"));var _commander=_interopRequireDefault(require("commander"));var _package=require("../package.json");var strategies=_interopRequireWildcard(require("./strategies"));function validatePick(rule){var parts=rule.split("@");switch(parts.length){case 2:{var _parts=(0,_slicedToArray2.default)(parts,2),name=_parts[0],ver=_parts[1];return(0,_defineProperty2.default)({},name,ver);}case 3:{var _parts$slice=parts.slice(1),_parts$slice2=(0,_slicedToArray2.default)(_parts$slice,2),_name=_parts$slice2[0],_ver=_parts$slice2[1];return(0,_defineProperty2.default)({},"@"+_name,_ver);}default:{console.error("\""+rule+"\" is an invalid rule. Format: \"-p {[@namespace]name}@{ver}\"");process.exit(1);return null;}}}function validateStrategies(name){if(!strategies[name]){var options=Object.keys(strategies).join(", ");console.error("\""+name+"\" is invalid strategy. Chose one of: "+options+"\"");process.exit(1);}return strategies[name];}var _default=_commander.default.version(_package.version).usage("depend [...options]").description("tool to analyze, visualize and fix dependencies of a javascript monorepo").option("-l --lerna <path>","path to project root. Uses packages field to find all packages").option("-e --expr <glob>","glob expression that finds package.json files").option("-p --pick <dependency>","sets all package dependencies to {package}@{version}",validatePick).option("-g --graph [filter]","output the dependency graph for all matching requirements").option("-s --strategy <strategy>","how to resolve conflicts. possible strategies: conservative, progressive, majority, majorityConservative, majorityProgressive",validateStrategies).option("-on --only <glob>","glob expression that restricts dependencies to process").option("-f --fix","fixed dependencies with wrong versions").option("-sr --show-rules","prints rules that will be applied").option("-l --list","prints all dependencies in use").option("-b --bail","returns 1 if packages need fixing").option("--hint","print fix suggestions").on("--help",function(){console.log(" For more details see https://github.com/newsuk/times-components/tree/master/packages/depend");console.log("");});exports.default=_default;
var _interopRequireDefault=require("@babel/runtime/helpers/interopRequireDefault");Object.defineProperty(exports,"__esModule",{value:true});exports.default=void 0;var _defineProperty2=_interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));var _slicedToArray2=_interopRequireDefault(require("@babel/runtime/helpers/slicedToArray"));var _commander=_interopRequireDefault(require("commander"));var _package=require("../package.json");var strategies=_interopRequireWildcard(require("./strategies"));function _getRequireWildcardCache(nodeInterop){if(typeof WeakMap!=="function")return null;var cacheBabelInterop=new WeakMap();var cacheNodeInterop=new WeakMap();return(_getRequireWildcardCache=function _getRequireWildcardCache(nodeInterop){return nodeInterop?cacheNodeInterop:cacheBabelInterop;})(nodeInterop);}function _interopRequireWildcard(obj,nodeInterop){if(!nodeInterop&&obj&&obj.__esModule){return obj;}if(obj===null||typeof obj!=="object"&&typeof obj!=="function"){return{default:obj};}var cache=_getRequireWildcardCache(nodeInterop);if(cache&&cache.has(obj)){return cache.get(obj);}var newObj={};var hasPropertyDescriptor=Object.defineProperty&&Object.getOwnPropertyDescriptor;for(var key in obj){if(key!=="default"&&Object.prototype.hasOwnProperty.call(obj,key)){var desc=hasPropertyDescriptor?Object.getOwnPropertyDescriptor(obj,key):null;if(desc&&(desc.get||desc.set)){Object.defineProperty(newObj,key,desc);}else{newObj[key]=obj[key];}}}newObj.default=obj;if(cache){cache.set(obj,newObj);}return newObj;}function validatePick(rule){var parts=rule.split("@");switch(parts.length){case 2:{var _parts=(0,_slicedToArray2.default)(parts,2),name=_parts[0],ver=_parts[1];return(0,_defineProperty2.default)({},name,ver);}case 3:{var _parts$slice=parts.slice(1),_parts$slice2=(0,_slicedToArray2.default)(_parts$slice,2),_name=_parts$slice2[0],_ver=_parts$slice2[1];return(0,_defineProperty2.default)({},"@"+_name,_ver);}default:{console.error("\""+rule+"\" is an invalid rule. Format: \"-p {[@namespace]name}@{ver}\"");process.exit(1);return null;}}}function validateStrategies(name){if(!strategies[name]){var options=Object.keys(strategies).join(", ");console.error("\""+name+"\" is invalid strategy. Chose one of: "+options+"\"");process.exit(1);}return strategies[name];}var _default=_commander.default.version(_package.version).usage("depend [...options]").description("tool to analyze, visualize and fix dependencies of a javascript monorepo").option("-l --lerna <path>","path to project root. Uses packages field to find all packages").option("-e --expr <glob>","glob expression that finds package.json files").option("-p --pick <dependency>","sets all package dependencies to {package}@{version}",validatePick).option("-g --graph [filter]","output the dependency graph for all matching requirements").option("-s --strategy <strategy>","how to resolve conflicts. possible strategies: conservative, progressive, majority, majorityConservative, majorityProgressive",validateStrategies).option("-on --only <glob>","glob expression that restricts dependencies to process").option("-f --fix","fixed dependencies with wrong versions").option("-sr --show-rules","prints rules that will be applied").option("-l --list","prints all dependencies in use").option("-b --bail","returns 1 if packages need fixing").option("--hint","print fix suggestions").on("--help",function(){console.log(" For more details see https://github.com/newsuk/times-components/tree/master/packages/depend");console.log("");});exports.default=_default;

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

var _interopRequireDefault=require("@babel/runtime/helpers/interopRequireDefault");Object.defineProperty(exports,"__esModule",{value:true});exports.suggestFix=suggestFix;exports.getAllRequirements=getAllRequirements;exports.computeVersionSets=computeVersionSets;exports.computeFlatReverseLookupMap=computeFlatReverseLookupMap;exports.computeReverseLookupMap=computeReverseLookupMap;exports.findWrongVersions=findWrongVersions;exports.fixTodo=fixTodo;exports.getSuggestions=getSuggestions;exports.getTodos=getTodos;exports.createRules=createRules;exports.applyStrategy=applyStrategy;exports.restrictRequirements=restrictRequirements;exports.default=compute;exports.applyPatch=void 0;var _regenerator=_interopRequireDefault(require("@babel/runtime/regenerator"));var _defineProperty2=_interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));var _slicedToArray2=_interopRequireDefault(require("@babel/runtime/helpers/slicedToArray"));var _toConsumableArray2=_interopRequireDefault(require("@babel/runtime/helpers/toConsumableArray"));var _objectSpread4=_interopRequireDefault(require("@babel/runtime/helpers/objectSpread"));require("core-js/fn/array/flat-map");require("regenerator-runtime/runtime");var _minimatch=_interopRequireDefault(require("minimatch"));var keys=Object.keys,values=Object.values,entries=Object.entries;var toObject=function toObject(a,b){return(0,_objectSpread4.default)({},a,b);};var count=function count(o){return keys(o).length;};var distinct=function distinct(x){return(0,_toConsumableArray2.default)(new Set(x));};var objectOrUndefined=function objectOrUndefined(dep){return count(dep)?dep:undefined;};function resolveConflicts(strategy,packages){var _packages$sort$=packages.sort(strategy)[0],name=_packages$sort$.name,version=_packages$sort$.version;return{name:name,version:version};}function suggestFix(){var packageJson=arguments.length>0&&arguments[0]!==undefined?arguments[0]:{};var rules=arguments.length>1&&arguments[1]!==undefined?arguments[1]:{};var fixup=function fixup(){var dep=arguments.length>0&&arguments[0]!==undefined?arguments[0]:{};return entries(dep).map(function(_ref){var _ref2=(0,_slicedToArray2.default)(_ref,2),name=_ref2[0],version=_ref2[1];return{expected:rules[name],name:name,version:version};}).filter(function(x){return x.expected;}).filter(function(x){return x.expected!==x.version;}).map(function(_ref3){var name=_ref3.name,expected=_ref3.expected;return(0,_defineProperty2.default)({},name,expected);}).reduce(toObject,{});};var dependencies=fixup(packageJson.dependencies);var devDependencies=fixup(packageJson.devDependencies);if(!count(dependencies)&&!count(devDependencies)){return null;}return{dependencies:dependencies,devDependencies:devDependencies};}var applyPatch=function applyPatch(packageJson,_ref5){var _ref5$dependencies=_ref5.dependencies,dependencies=_ref5$dependencies===void 0?{}:_ref5$dependencies,_ref5$devDependencies=_ref5.devDependencies,devDependencies=_ref5$devDependencies===void 0?{}:_ref5$devDependencies;return(0,_objectSpread4.default)({},packageJson,{dependencies:objectOrUndefined((0,_objectSpread4.default)({},packageJson.dependencies,dependencies)),devDependencies:objectOrUndefined((0,_objectSpread4.default)({},packageJson.devDependencies,devDependencies))});};exports.applyPatch=applyPatch;function getAllRequirements(packages){return packages.map(function(p){return{deps:[].concat((0,_toConsumableArray2.default)(entries(p.dependencies||{})),(0,_toConsumableArray2.default)(entries(p.devDependencies||{}))),name:p.name,version:p.version};}).flatMap(function(_ref6){var name=_ref6.name,version=_ref6.version,deps=_ref6.deps;return deps.map(function(_ref7){var _ref8=(0,_slicedToArray2.default)(_ref7,2),depName=_ref8[0],depVersion=_ref8[1];return{package:{name:name,version:version},requires:{name:depName,version:depVersion}};});});}function computeVersionSets(requirements){return requirements.map(function(p){return p.requires;}).reduce(function(sets,_ref9){var name=_ref9.name,version=_ref9.version;return(0,_objectSpread4.default)({},sets,(0,_defineProperty2.default)({},name,distinct([version].concat((0,_toConsumableArray2.default)(sets[name]||[])))));},{});}function computeFlatReverseLookupMap(requirements){var packName=function packName(_ref10){var name=_ref10.name,version=_ref10.version;return name+"@"+version;};return requirements.map(function(r){return[packName(r.package),packName(r.requires)];}).reduce(function(deps,_ref11){var _ref12=(0,_slicedToArray2.default)(_ref11,2),dependee=_ref12[0],dependency=_ref12[1];return(0,_objectSpread4.default)({},deps,(0,_defineProperty2.default)({},dependee,distinct([dependency].concat((0,_toConsumableArray2.default)(deps[dependee]||[])))));},{});}function computeReverseLookupMap(requirements,versionSets){var flatReverseLookup=computeFlatReverseLookupMap(requirements);return entries(versionSets).map(function(_ref13){var _ref14=(0,_slicedToArray2.default)(_ref13,2),dependency=_ref14[0],versions=_ref14[1];return(0,_defineProperty2.default)({},dependency,(0,_toConsumableArray2.default)(versions.map(function(version){return{name:dependency,usedBy:(0,_toConsumableArray2.default)(flatReverseLookup[dependency+"@"+version]||[]),version:version};})));}).reduce(toObject,{});}function findWrongVersions(packages){var expectedVersions=packages.map(function(_ref16){var name=_ref16.name,version=_ref16.version;return(0,_defineProperty2.default)({},name,version);}).reduce(toObject,{});return packages.flatMap(function(p){return[].concat((0,_toConsumableArray2.default)(entries(p.dependencies||{})),(0,_toConsumableArray2.default)(entries(p.devDependencies||{}))).map(function(_ref18){var _ref19=(0,_slicedToArray2.default)(_ref18,2),name=_ref19[0],installs=_ref19[1];return{expected:expectedVersions[name],installs:installs,package:name,usedBy:p.name};}).filter(function(_ref20){var installs=_ref20.installs,expected=_ref20.expected;return expected&&installs!==expected;});});}function fixTodo(_ref21){var path=_ref21.path,packageJson=_ref21.packageJson,patch=_ref21.patch;return[path,applyPatch(packageJson,patch)];}function getSuggestions(todo){return todo.map(function(_ref22){var path=_ref22.path,packageJson=_ref22.packageJson,patch=_ref22.patch;return[path,[].concat((0,_toConsumableArray2.default)(entries(patch.dependencies).map(function(_ref23){var _ref24=(0,_slicedToArray2.default)(_ref23,2),name=_ref24[0],version=_ref24[1];return[name,packageJson.dependencies[name],version];}).filter(function(x){return x[1];})),(0,_toConsumableArray2.default)(entries(patch.devDependencies).map(function(_ref25){var _ref26=(0,_slicedToArray2.default)(_ref25,2),name=_ref26[0],version=_ref26[1];return[name,packageJson.devDependencies[name],version];}).filter(function(x){return x[1];})))];});}function getTodos(packagesList,rules){return packagesList.map(function(_ref27){var _ref28=(0,_slicedToArray2.default)(_ref27,2),path=_ref28[0],packageJson=_ref28[1];return{packageJson:packageJson,patch:suggestFix(packageJson,rules),path:path};}).filter(function(x){return x.patch;});}function createRules(resolved,wrong){return[].concat((0,_toConsumableArray2.default)(resolved.map(function(w){return(0,_defineProperty2.default)({},w.name,w.version);})),(0,_toConsumableArray2.default)(wrong.map(function(w){return(0,_defineProperty2.default)({},w.package,w.expected);}))).reduce(toObject,{});}function applyStrategy(requirements,strategy){var versionSets=computeVersionSets(requirements);if(!strategy){return{resolved:[],versionSets:versionSets};}var reverseLookup=computeReverseLookupMap(requirements,versionSets);var divergent=values(reverseLookup).filter(function(x){return x.length>1;});var resolved=divergent.map(function(c){return resolveConflicts(strategy,c);});return{resolved:resolved,versionSets:versionSets};}function restrictRequirements(requirements,expr){var filter=expr?function(name){return(0,_minimatch.default)(name,expr);}:function(){return true;};return requirements.filter(function(requirement){return filter(requirement.requires.name);});}function compute(packagesList,strategy,filter){var overrides,packages,requirements,targetRequirements,_applyStrategy,versionSets,resolved,wrong,rules,todo,fixedPackages,suggestions,_args=arguments;return _regenerator.default.async(function compute$(_context){while(1){switch(_context.prev=_context.next){case 0:overrides=_args.length>3&&_args[3]!==undefined?_args[3]:{};packages=packagesList.map(function(p){return p[1];});requirements=getAllRequirements(packages);targetRequirements=restrictRequirements(requirements,filter);_applyStrategy=applyStrategy(targetRequirements,strategy),versionSets=_applyStrategy.versionSets,resolved=_applyStrategy.resolved;wrong=findWrongVersions(packages);rules=createRules(resolved,wrong);todo=getTodos(packagesList,(0,_objectSpread4.default)({},rules,overrides));fixedPackages=todo.map(fixTodo);suggestions=getSuggestions(todo);return _context.abrupt("return",{fixedPackages:fixedPackages,requirements:targetRequirements,rules:rules,suggestions:suggestions,versionSets:versionSets,wrong:wrong});case 11:case"end":return _context.stop();}}});}
var _interopRequireDefault=require("@babel/runtime/helpers/interopRequireDefault");Object.defineProperty(exports,"__esModule",{value:true});exports.suggestFix=suggestFix;exports.getAllRequirements=getAllRequirements;exports.computeVersionSets=computeVersionSets;exports.computeFlatReverseLookupMap=computeFlatReverseLookupMap;exports.computeReverseLookupMap=computeReverseLookupMap;exports.findWrongVersions=findWrongVersions;exports.fixTodo=fixTodo;exports.getSuggestions=getSuggestions;exports.getTodos=getTodos;exports.createRules=createRules;exports.applyStrategy=applyStrategy;exports.restrictRequirements=restrictRequirements;exports.default=compute;exports.applyPatch=void 0;var _regenerator=_interopRequireDefault(require("@babel/runtime/regenerator"));var _slicedToArray2=_interopRequireDefault(require("@babel/runtime/helpers/slicedToArray"));var _toConsumableArray2=_interopRequireDefault(require("@babel/runtime/helpers/toConsumableArray"));var _defineProperty2=_interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));require("core-js/fn/array/flat-map");require("regenerator-runtime/runtime");var _minimatch=_interopRequireDefault(require("minimatch"));function ownKeys(object,enumerableOnly){var keys=Object.keys(object);if(Object.getOwnPropertySymbols){var symbols=Object.getOwnPropertySymbols(object);if(enumerableOnly){symbols=symbols.filter(function(sym){return Object.getOwnPropertyDescriptor(object,sym).enumerable;});}keys.push.apply(keys,symbols);}return keys;}function _objectSpread(target){for(var i=1;i<arguments.length;i++){var source=arguments[i]!=null?arguments[i]:{};if(i%2){ownKeys(Object(source),true).forEach(function(key){(0,_defineProperty2.default)(target,key,source[key]);});}else if(Object.getOwnPropertyDescriptors){Object.defineProperties(target,Object.getOwnPropertyDescriptors(source));}else{ownKeys(Object(source)).forEach(function(key){Object.defineProperty(target,key,Object.getOwnPropertyDescriptor(source,key));});}}return target;}var keys=Object.keys,values=Object.values,entries=Object.entries;var toObject=function toObject(a,b){return _objectSpread(_objectSpread({},a),b);};var count=function count(o){return keys(o).length;};var distinct=function distinct(x){return(0,_toConsumableArray2.default)(new Set(x));};var objectOrUndefined=function objectOrUndefined(dep){return count(dep)?dep:undefined;};function resolveConflicts(strategy,packages){var _packages$sort$=packages.sort(strategy)[0],name=_packages$sort$.name,version=_packages$sort$.version;return{name:name,version:version};}function suggestFix(){var packageJson=arguments.length>0&&arguments[0]!==undefined?arguments[0]:{};var rules=arguments.length>1&&arguments[1]!==undefined?arguments[1]:{};var fixup=function fixup(){var dep=arguments.length>0&&arguments[0]!==undefined?arguments[0]:{};return entries(dep).map(function(_ref){var _ref2=(0,_slicedToArray2.default)(_ref,2),name=_ref2[0],version=_ref2[1];return{expected:rules[name],name:name,version:version};}).filter(function(x){return x.expected;}).filter(function(x){return x.expected!==x.version;}).map(function(_ref3){var name=_ref3.name,expected=_ref3.expected;return(0,_defineProperty2.default)({},name,expected);}).reduce(toObject,{});};var dependencies=fixup(packageJson.dependencies);var devDependencies=fixup(packageJson.devDependencies);if(!count(dependencies)&&!count(devDependencies)){return null;}return{dependencies:dependencies,devDependencies:devDependencies};}var applyPatch=function applyPatch(packageJson,_ref5){var _ref5$dependencies=_ref5.dependencies,dependencies=_ref5$dependencies===void 0?{}:_ref5$dependencies,_ref5$devDependencies=_ref5.devDependencies,devDependencies=_ref5$devDependencies===void 0?{}:_ref5$devDependencies;return _objectSpread(_objectSpread({},packageJson),{},{dependencies:objectOrUndefined(_objectSpread(_objectSpread({},packageJson.dependencies),dependencies)),devDependencies:objectOrUndefined(_objectSpread(_objectSpread({},packageJson.devDependencies),devDependencies))});};exports.applyPatch=applyPatch;function getAllRequirements(packages){return packages.map(function(p){return{deps:[].concat((0,_toConsumableArray2.default)(entries(p.dependencies||{})),(0,_toConsumableArray2.default)(entries(p.devDependencies||{}))),name:p.name,version:p.version};}).flatMap(function(_ref6){var name=_ref6.name,version=_ref6.version,deps=_ref6.deps;return deps.map(function(_ref7){var _ref8=(0,_slicedToArray2.default)(_ref7,2),depName=_ref8[0],depVersion=_ref8[1];return{package:{name:name,version:version},requires:{name:depName,version:depVersion}};});});}function computeVersionSets(requirements){return requirements.map(function(p){return p.requires;}).reduce(function(sets,_ref9){var name=_ref9.name,version=_ref9.version;return _objectSpread(_objectSpread({},sets),{},(0,_defineProperty2.default)({},name,distinct([version].concat((0,_toConsumableArray2.default)(sets[name]||[])))));},{});}function computeFlatReverseLookupMap(requirements){var packName=function packName(_ref10){var name=_ref10.name,version=_ref10.version;return name+"@"+version;};return requirements.map(function(r){return[packName(r.package),packName(r.requires)];}).reduce(function(deps,_ref11){var _ref12=(0,_slicedToArray2.default)(_ref11,2),dependee=_ref12[0],dependency=_ref12[1];return _objectSpread(_objectSpread({},deps),{},(0,_defineProperty2.default)({},dependee,distinct([dependency].concat((0,_toConsumableArray2.default)(deps[dependee]||[])))));},{});}function computeReverseLookupMap(requirements,versionSets){var flatReverseLookup=computeFlatReverseLookupMap(requirements);return entries(versionSets).map(function(_ref13){var _ref14=(0,_slicedToArray2.default)(_ref13,2),dependency=_ref14[0],versions=_ref14[1];return(0,_defineProperty2.default)({},dependency,(0,_toConsumableArray2.default)(versions.map(function(version){return{name:dependency,usedBy:(0,_toConsumableArray2.default)(flatReverseLookup[dependency+"@"+version]||[]),version:version};})));}).reduce(toObject,{});}function findWrongVersions(packages){var expectedVersions=packages.map(function(_ref16){var name=_ref16.name,version=_ref16.version;return(0,_defineProperty2.default)({},name,version);}).reduce(toObject,{});return packages.flatMap(function(p){return[].concat((0,_toConsumableArray2.default)(entries(p.dependencies||{})),(0,_toConsumableArray2.default)(entries(p.devDependencies||{}))).map(function(_ref18){var _ref19=(0,_slicedToArray2.default)(_ref18,2),name=_ref19[0],installs=_ref19[1];return{expected:expectedVersions[name],installs:installs,package:name,usedBy:p.name};}).filter(function(_ref20){var installs=_ref20.installs,expected=_ref20.expected;return expected&&installs!==expected;});});}function fixTodo(_ref21){var path=_ref21.path,packageJson=_ref21.packageJson,patch=_ref21.patch;return[path,applyPatch(packageJson,patch)];}function getSuggestions(todo){return todo.map(function(_ref22){var path=_ref22.path,packageJson=_ref22.packageJson,patch=_ref22.patch;return[path,[].concat((0,_toConsumableArray2.default)(entries(patch.dependencies).map(function(_ref23){var _ref24=(0,_slicedToArray2.default)(_ref23,2),name=_ref24[0],version=_ref24[1];return[name,packageJson.dependencies[name],version];}).filter(function(x){return x[1];})),(0,_toConsumableArray2.default)(entries(patch.devDependencies).map(function(_ref25){var _ref26=(0,_slicedToArray2.default)(_ref25,2),name=_ref26[0],version=_ref26[1];return[name,packageJson.devDependencies[name],version];}).filter(function(x){return x[1];})))];});}function getTodos(packagesList,rules){return packagesList.map(function(_ref27){var _ref28=(0,_slicedToArray2.default)(_ref27,2),path=_ref28[0],packageJson=_ref28[1];return{packageJson:packageJson,patch:suggestFix(packageJson,rules),path:path};}).filter(function(x){return x.patch;});}function createRules(resolved,wrong){return[].concat((0,_toConsumableArray2.default)(resolved.map(function(w){return(0,_defineProperty2.default)({},w.name,w.version);})),(0,_toConsumableArray2.default)(wrong.map(function(w){return(0,_defineProperty2.default)({},w.package,w.expected);}))).reduce(toObject,{});}function applyStrategy(requirements,strategy){var versionSets=computeVersionSets(requirements);if(!strategy){return{resolved:[],versionSets:versionSets};}var reverseLookup=computeReverseLookupMap(requirements,versionSets);var divergent=values(reverseLookup).filter(function(x){return x.length>1;});var resolved=divergent.map(function(c){return resolveConflicts(strategy,c);});return{resolved:resolved,versionSets:versionSets};}function restrictRequirements(requirements,expr){var filter=expr?function(name){return(0,_minimatch.default)(name,expr);}:function(){return true;};return requirements.filter(function(requirement){return filter(requirement.requires.name);});}function compute(packagesList,strategy,filter){var overrides,packages,requirements,targetRequirements,_applyStrategy,versionSets,resolved,wrong,rules,todo,fixedPackages,suggestions,_args=arguments;return _regenerator.default.async(function compute$(_context){while(1){switch(_context.prev=_context.next){case 0:overrides=_args.length>3&&_args[3]!==undefined?_args[3]:{};packages=packagesList.map(function(p){return p[1];});requirements=getAllRequirements(packages);targetRequirements=restrictRequirements(requirements,filter);_applyStrategy=applyStrategy(targetRequirements,strategy),versionSets=_applyStrategy.versionSets,resolved=_applyStrategy.resolved;wrong=findWrongVersions(packages);rules=createRules(resolved,wrong);todo=getTodos(packagesList,_objectSpread(_objectSpread({},rules),overrides));fixedPackages=todo.map(fixTodo);suggestions=getSuggestions(todo);return _context.abrupt("return",{fixedPackages:fixedPackages,requirements:targetRequirements,rules:rules,suggestions:suggestions,versionSets:versionSets,wrong:wrong});case 11:case"end":return _context.stop();}}},null,null,null,Promise);}

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

var _interopRequireDefault=require("@babel/runtime/helpers/interopRequireDefault");Object.defineProperty(exports,"__esModule",{value:true});exports.default=main;var _regenerator=_interopRequireDefault(require("@babel/runtime/regenerator"));var _toConsumableArray2=_interopRequireDefault(require("@babel/runtime/helpers/toConsumableArray"));var _slicedToArray2=_interopRequireDefault(require("@babel/runtime/helpers/slicedToArray"));var _chalk=_interopRequireDefault(require("chalk"));var _path=require("path");var _lodash=_interopRequireDefault(require("lodash.flatten"));var _depend=_interopRequireDefault(require("./depend"));var _graph=_interopRequireDefault(require("./graph"));function prettifyHint(_ref){var _ref2=(0,_slicedToArray2.default)(_ref,3),name=_ref2[0],current=_ref2[1],target=_ref2[2];return" "+_chalk.default.blue(name)+": "+_chalk.default.red(current)+" -> "+_chalk.default.green(target);}function main(_ref3){var log,getPackages,readJson,writeJson,argv,exit,_argv$lerna,lerna,expr,lernaPath,lernaPackages,packagesToFind,packagesList;return _regenerator.default.async(function main$(_context){while(1){switch(_context.prev=_context.next){case 0:log=_ref3.log,getPackages=_ref3.getPackages,readJson=_ref3.readJson,writeJson=_ref3.writeJson,argv=_ref3.argv,exit=_ref3.exit;_argv$lerna=argv.lerna,lerna=_argv$lerna===void 0?"":_argv$lerna,expr=argv.expr;lernaPath=lerna||!expr?(0,_path.join)(lerna,"lerna.json"):"";if(!lernaPath){_context.next=9;break;}_context.next=6;return _regenerator.default.awrap(readJson(lernaPath).then(function(_ref4){var packages=_ref4.packages;return packages;}).then(function(packages){return packages.map(function(pattern){return(0,_path.join)(lerna,pattern,"package.json");});}).catch(function(e){log(e);exit(1);return[];}));case 6:_context.t0=_context.sent;_context.next=10;break;case 9:_context.t0=[];case 10:lernaPackages=_context.t0;packagesToFind=[].concat((0,_toConsumableArray2.default)(lernaPackages),[expr]).filter(function(x){return x;});_context.next=14;return _regenerator.default.awrap(Promise.all(packagesToFind.map(function(path){return getPackages(path);})).then(function(packages){return(0,_lodash.default)(packages);}));case 14:packagesList=_context.sent;return _context.abrupt("return",(0,_depend.default)(packagesList,argv.strategy,argv.only,argv.pick).then(function(_ref5){var requirements=_ref5.requirements,rules=_ref5.rules,suggestions=_ref5.suggestions,fixedPackages=_ref5.fixedPackages,versionSets=_ref5.versionSets;if(argv.graph){log((0,_graph.default)(requirements,argv.graph));Promise.resolve(0);}if(argv.list){Object.entries(versionSets).sort(function(_ref6,_ref7){var _ref8=(0,_slicedToArray2.default)(_ref6,1),a=_ref8[0];var _ref9=(0,_slicedToArray2.default)(_ref7,1),b=_ref9[0];return a.localeCompare(b);}).map(function(_ref10){var _ref11=(0,_slicedToArray2.default)(_ref10,2),name=_ref11[0],versions=_ref11[1];return[name,(0,_toConsumableArray2.default)(versions)];}).forEach(function(_ref12,i){var _ref13=(0,_slicedToArray2.default)(_ref12,2),name=_ref13[0],versions=_ref13[1];var color=function(){if(versions.length>1&&!rules[name]){return _chalk.default.red;}return!rules[name]?_chalk.default.green:_chalk.default.yellow;}();log(_chalk.default.blue(i+1),name,color(versions.join(" ")));});}if(argv.showRules){log(rules);}if(argv.hint||argv.fix){suggestions.forEach(function(_ref14){var _ref15=(0,_slicedToArray2.default)(_ref14,2),path=_ref15[0],suggestionList=_ref15[1];log(path);log(" "+suggestionList.map(prettifyHint).join("\n"));});}if(argv.bail&&suggestions.length){exit(1);return Promise.resolve();}if(argv.fix){return Promise.all(fixedPackages.map(function(_ref16){var _ref17=(0,_slicedToArray2.default)(_ref16,2),path=_ref17[0],json=_ref17[1];return writeJson(path,json,{spaces:2});}));}return Promise.resolve();}).catch(function(e){log(e.toString());exit(1);}));case 16:case"end":return _context.stop();}}});}
var _interopRequireDefault=require("@babel/runtime/helpers/interopRequireDefault");Object.defineProperty(exports,"__esModule",{value:true});exports.default=main;var _regenerator=_interopRequireDefault(require("@babel/runtime/regenerator"));var _toConsumableArray2=_interopRequireDefault(require("@babel/runtime/helpers/toConsumableArray"));var _slicedToArray2=_interopRequireDefault(require("@babel/runtime/helpers/slicedToArray"));var _chalk=_interopRequireDefault(require("chalk"));var _path=require("path");var _lodash=_interopRequireDefault(require("lodash.flatten"));var _depend=_interopRequireDefault(require("./depend"));var _graph=_interopRequireDefault(require("./graph"));function prettifyHint(_ref){var _ref2=(0,_slicedToArray2.default)(_ref,3),name=_ref2[0],current=_ref2[1],target=_ref2[2];return" "+_chalk.default.blue(name)+": "+_chalk.default.red(current)+" -> "+_chalk.default.green(target);}function main(_ref3){var log,getPackages,readJson,writeJson,argv,exit,_argv$lerna,lerna,expr,lernaPath,lernaPackages,packagesToFind,packagesList;return _regenerator.default.async(function main$(_context){while(1){switch(_context.prev=_context.next){case 0:log=_ref3.log,getPackages=_ref3.getPackages,readJson=_ref3.readJson,writeJson=_ref3.writeJson,argv=_ref3.argv,exit=_ref3.exit;_argv$lerna=argv.lerna,lerna=_argv$lerna===void 0?"":_argv$lerna,expr=argv.expr;lernaPath=lerna||!expr?(0,_path.join)(lerna,"lerna.json"):"";if(!lernaPath){_context.next=9;break;}_context.next=6;return _regenerator.default.awrap(readJson(lernaPath).then(function(_ref4){var packages=_ref4.packages;return packages;}).then(function(packages){return packages.map(function(pattern){return(0,_path.join)(lerna,pattern,"package.json");});}).catch(function(e){log(e);exit(1);return[];}));case 6:_context.t0=_context.sent;_context.next=10;break;case 9:_context.t0=[];case 10:lernaPackages=_context.t0;packagesToFind=[].concat((0,_toConsumableArray2.default)(lernaPackages),[expr]).filter(function(x){return x;});_context.next=14;return _regenerator.default.awrap(Promise.all(packagesToFind.map(function(path){return getPackages(path);})).then(function(packages){return(0,_lodash.default)(packages);}));case 14:packagesList=_context.sent;return _context.abrupt("return",(0,_depend.default)(packagesList,argv.strategy,argv.only,argv.pick).then(function(_ref5){var requirements=_ref5.requirements,rules=_ref5.rules,suggestions=_ref5.suggestions,fixedPackages=_ref5.fixedPackages,versionSets=_ref5.versionSets;if(argv.graph){log((0,_graph.default)(requirements,argv.graph));Promise.resolve(0);}if(argv.list){Object.entries(versionSets).sort(function(_ref6,_ref7){var _ref8=(0,_slicedToArray2.default)(_ref6,1),a=_ref8[0];var _ref9=(0,_slicedToArray2.default)(_ref7,1),b=_ref9[0];return a.localeCompare(b);}).map(function(_ref10){var _ref11=(0,_slicedToArray2.default)(_ref10,2),name=_ref11[0],versions=_ref11[1];return[name,(0,_toConsumableArray2.default)(versions)];}).forEach(function(_ref12,i){var _ref13=(0,_slicedToArray2.default)(_ref12,2),name=_ref13[0],versions=_ref13[1];var color=function(){if(versions.length>1&&!rules[name]){return _chalk.default.red;}return!rules[name]?_chalk.default.green:_chalk.default.yellow;}();log(_chalk.default.blue(i+1),name,color(versions.join(" ")));});}if(argv.showRules){log(rules);}if(argv.hint||argv.fix){suggestions.forEach(function(_ref14){var _ref15=(0,_slicedToArray2.default)(_ref14,2),path=_ref15[0],suggestionList=_ref15[1];log(path);log(" "+suggestionList.map(prettifyHint).join("\n"));});}if(argv.bail&&suggestions.length){exit(1);return Promise.resolve();}if(argv.fix){return Promise.all(fixedPackages.map(function(_ref16){var _ref17=(0,_slicedToArray2.default)(_ref16,2),path=_ref17[0],json=_ref17[1];return writeJson(path,json,{spaces:2});}));}return Promise.resolve();}).catch(function(e){log(e.toString());exit(1);}));case 16:case"end":return _context.stop();}}},null,null,null,Promise);}
{
"name": "@times-components/depend",
"version": "2.1.26",
"version": "2.1.27",
"description": "dependency analyzer and fixer",

@@ -71,3 +71,3 @@ "main": "dist/depend",

"minimatch": "3.0.4",
"regenerator-runtime": "0.13.2",
"regenerator-runtime": "0.13.7",
"semver": "5.5.0"

@@ -78,3 +78,3 @@ },

},
"gitHead": "a23a9f1dfce9b407541de715bfc1fd7b92072d56"
"gitHead": "caf40e1ea78611206a3d67052b0308ed7fa98a46"
}
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