@times-components/depend
Advanced tools
Comparing version 2.1.15 to 2.1.16
@@ -6,2 +6,10 @@ # Change Log | ||
## [2.1.16](https://github.com/newsuk/times-components/compare/@times-components/depend@2.1.15...@times-components/depend@2.1.16) (2019-05-09) | ||
**Note:** Version bump only for package @times-components/depend | ||
## [2.1.15](https://github.com/newsuk/times-components/compare/@times-components/depend@2.1.14...@times-components/depend@2.1.15) (2019-04-30) | ||
@@ -8,0 +16,0 @@ |
@@ -1,1 +0,1 @@ | ||
Object.defineProperty(exports,"__esModule",{value:true});var _slicedToArray=function(){function sliceIterator(arr,i){var _arr=[];var _n=true;var _d=false;var _e=undefined;try{for(var _i=arr[typeof Symbol==="function"?Symbol.iterator:"@@iterator"](),_s;!(_n=(_s=_i.next()).done);_n=true){_arr.push(_s.value);if(i&&_arr.length===i)break;}}catch(err){_d=true;_e=err;}finally{try{if(!_n&&_i["return"])_i["return"]();}finally{if(_d)throw _e;}}return _arr;}return function(arr,i){if(Array.isArray(arr)){return arr;}else if((typeof Symbol==="function"?Symbol.iterator:"@@iterator")in Object(arr)){return sliceIterator(arr,i);}else{throw new TypeError("Invalid attempt to destructure non-iterable instance");}};}();var _commander=require("commander");var _commander2=_interopRequireDefault(_commander);var _package=require("../package.json");var _strategies=require("./strategies");var strategies=_interopRequireWildcard(_strategies);function _interopRequireWildcard(obj){if(obj&&obj.__esModule){return obj;}else{var newObj={};if(obj!=null){for(var key in obj){if(Object.prototype.hasOwnProperty.call(obj,key))newObj[key]=obj[key];}}newObj.default=obj;return newObj;}}function _interopRequireDefault(obj){return obj&&obj.__esModule?obj:{default:obj};}function _defineProperty(obj,key,value){if(key in obj){Object.defineProperty(obj,key,{value:value,enumerable:true,configurable:true,writable:true});}else{obj[key]=value;}return obj;}function validatePick(rule){var parts=rule.split("@");switch(parts.length){case 2:{var _parts=_slicedToArray(parts,2),name=_parts[0],ver=_parts[1];return _defineProperty({},name,ver);}case 3:{var _parts$slice=parts.slice(1),_parts$slice2=_slicedToArray(_parts$slice,2),_name=_parts$slice2[0],_ver=_parts$slice2[1];return _defineProperty({},"@"+_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];}exports.default=_commander2.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"); | ||
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");exports.default=_default; |
#!/usr/bin/env node | ||
var _process=require("process");var _fsExtra=require("fs-extra");var _getPackages=require("./get-packages");var _getPackages2=_interopRequireDefault(_getPackages);var _cliParser=require("./cli-parser");var _cliParser2=_interopRequireDefault(_cliParser);var _main=require("./main");var _main2=_interopRequireDefault(_main);function _interopRequireDefault(obj){return obj&&obj.__esModule?obj:{default:obj};}var log=function log(){var _console;return(_console=console).log.apply(_console,arguments);};var argv=_cliParser2.default.parse(process.argv);(0,_main2.default)({argv:argv,exit:_process.exit,getPackages:_getPackages2.default,log:log,readJson:_fsExtra.readJson,writeJson:_fsExtra.writeJson}); | ||
var _interopRequireDefault=require("@babel/runtime/helpers/interopRequireDefault");var _process=require("process");var _fsExtra=require("fs-extra");var _getPackages=_interopRequireDefault(require("./get-packages"));var _cliParser=_interopRequireDefault(require("./cli-parser"));var _main=_interopRequireDefault(require("./main"));var log=function log(){var _console;return(_console=console).log.apply(_console,arguments);};var argv=_cliParser.default.parse(process.argv);(0,_main.default)({argv:argv,exit:_process.exit,getPackages:_getPackages.default,log:log,readJson:_fsExtra.readJson,writeJson:_fsExtra.writeJson}); |
@@ -1,1 +0,1 @@ | ||
Object.defineProperty(exports,"__esModule",{value:true});exports.applyPatch=undefined;var _slicedToArray=function(){function sliceIterator(arr,i){var _arr=[];var _n=true;var _d=false;var _e=undefined;try{for(var _i=arr[typeof Symbol==="function"?Symbol.iterator:"@@iterator"](),_s;!(_n=(_s=_i.next()).done);_n=true){_arr.push(_s.value);if(i&&_arr.length===i)break;}}catch(err){_d=true;_e=err;}finally{try{if(!_n&&_i["return"])_i["return"]();}finally{if(_d)throw _e;}}return _arr;}return function(arr,i){if(Array.isArray(arr)){return arr;}else if((typeof Symbol==="function"?Symbol.iterator:"@@iterator")in Object(arr)){return sliceIterator(arr,i);}else{throw new TypeError("Invalid attempt to destructure non-iterable instance");}};}();var _extends=Object.assign||function(target){for(var i=1;i<arguments.length;i++){var source=arguments[i];for(var key in source){if(Object.prototype.hasOwnProperty.call(source,key)){target[key]=source[key];}}}return target;};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;require("babel-polyfill");var _minimatch=require("minimatch");var _minimatch2=_interopRequireDefault(_minimatch);function _interopRequireDefault(obj){return obj&&obj.__esModule?obj:{default:obj};}function _defineProperty(obj,key,value){if(key in obj){Object.defineProperty(obj,key,{value:value,enumerable:true,configurable:true,writable:true});}else{obj[key]=value;}return obj;}function _toConsumableArray(arr){if(Array.isArray(arr)){for(var i=0,arr2=Array(arr.length);i<arr.length;i++){arr2[i]=arr[i];}return arr2;}else{return Array.from(arr);}}var keys=Object.keys,values=Object.values,entries=Object.entries;var toObject=function toObject(a,b){return _extends({},a,b);};var count=function count(o){return keys(o).length;};var distinct=function distinct(x){return[].concat(_toConsumableArray(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=_slicedToArray(_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 _defineProperty({},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=exports.applyPatch=function applyPatch(packageJson,_ref5){var _ref5$dependencies=_ref5.dependencies,dependencies=_ref5$dependencies===undefined?{}:_ref5$dependencies,_ref5$devDependencies=_ref5.devDependencies,devDependencies=_ref5$devDependencies===undefined?{}:_ref5$devDependencies;return _extends({},packageJson,{dependencies:objectOrUndefined(_extends({},packageJson.dependencies,dependencies)),devDependencies:objectOrUndefined(_extends({},packageJson.devDependencies,devDependencies))});};function getAllRequirements(packages){return packages.map(function(p){return{deps:[].concat(_toConsumableArray(entries(p.dependencies||{})),_toConsumableArray(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=_slicedToArray(_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 _extends({},sets,_defineProperty({},name,distinct([version].concat(_toConsumableArray(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=_slicedToArray(_ref11,2),dependee=_ref12[0],dependency=_ref12[1];return _extends({},deps,_defineProperty({},dependee,distinct([dependency].concat(_toConsumableArray(deps[dependee]||[])))));},{});}function computeReverseLookupMap(requirements,versionSets){var flatReverseLookup=computeFlatReverseLookupMap(requirements);return entries(versionSets).map(function(_ref13){var _ref14=_slicedToArray(_ref13,2),dependency=_ref14[0],versions=_ref14[1];return _defineProperty({},dependency,[].concat(_toConsumableArray(versions.map(function(version){return{name:dependency,usedBy:[].concat(_toConsumableArray(flatReverseLookup[dependency+"@"+version]||[])),version:version};}))));}).reduce(toObject,{});}function findWrongVersions(packages){var expectedVersions=packages.map(function(_ref16){var name=_ref16.name,version=_ref16.version;return _defineProperty({},name,version);}).reduce(toObject,{});return packages.flatMap(function(p){return[].concat(_toConsumableArray(entries(p.dependencies||{})),_toConsumableArray(entries(p.devDependencies||{}))).map(function(_ref18){var _ref19=_slicedToArray(_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(_toConsumableArray(entries(patch.dependencies).map(function(_ref23){var _ref24=_slicedToArray(_ref23,2),name=_ref24[0],version=_ref24[1];return[name,packageJson.dependencies[name],version];}).filter(function(x){return x[1];})),_toConsumableArray(entries(patch.devDependencies).map(function(_ref25){var _ref26=_slicedToArray(_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=_slicedToArray(_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(_toConsumableArray(resolved.map(function(w){return _defineProperty({},w.name,w.version);})),_toConsumableArray(wrong.map(function(w){return _defineProperty({},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,_minimatch2.default)(name,expr);}:function(){return true;};return requirements.filter(function(requirement){return filter(requirement.requires.name);});}exports.default=function compute(packagesList,strategy,filter){var overrides=arguments.length>3&&arguments[3]!==undefined?arguments[3]:{};var packages,requirements,targetRequirements,_applyStrategy,versionSets,resolved,wrong,rules,todo,fixedPackages,suggestions;return regeneratorRuntime.async(function compute$(_context){while(1){switch(_context.prev=_context.next){case 0: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,_extends({},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 10:case"end":return _context.stop();}}},null,this);}; | ||
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("@babel/polyfill");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();}}});} |
@@ -1,1 +0,1 @@ | ||
Object.defineProperty(exports,"__esModule",{value:true});exports.default=getPackages;var _glob=require("glob");var _glob2=_interopRequireDefault(_glob);var _fsExtra=require("fs-extra");function _interopRequireDefault(obj){return obj&&obj.__esModule?obj:{default:obj};}function getPackages(expr){return new Promise(function(resolve,reject){(0,_glob2.default)(expr,function(error,paths){if(error)return reject(error);return resolve(paths.map(function(p){return(0,_fsExtra.readJson)(p).then(function(json){return[p,json];});}));});}).then(function(files){return Promise.all(files);});} | ||
var _interopRequireDefault=require("@babel/runtime/helpers/interopRequireDefault");Object.defineProperty(exports,"__esModule",{value:true});exports.default=getPackages;var _glob=_interopRequireDefault(require("glob"));var _fsExtra=require("fs-extra");function getPackages(expr){return new Promise(function(resolve,reject){(0,_glob.default)(expr,function(error,paths){if(error)return reject(error);return resolve(paths.map(function(p){return(0,_fsExtra.readJson)(p).then(function(json){return[p,json];});}));});}).then(function(files){return Promise.all(files);});} |
@@ -1,1 +0,1 @@ | ||
Object.defineProperty(exports,"__esModule",{value:true});var _slicedToArray=function(){function sliceIterator(arr,i){var _arr=[];var _n=true;var _d=false;var _e=undefined;try{for(var _i=arr[typeof Symbol==="function"?Symbol.iterator:"@@iterator"](),_s;!(_n=(_s=_i.next()).done);_n=true){_arr.push(_s.value);if(i&&_arr.length===i)break;}}catch(err){_d=true;_e=err;}finally{try{if(!_n&&_i["return"])_i["return"]();}finally{if(_d)throw _e;}}return _arr;}return function(arr,i){if(Array.isArray(arr)){return arr;}else if((typeof Symbol==="function"?Symbol.iterator:"@@iterator")in Object(arr)){return sliceIterator(arr,i);}else{throw new TypeError("Invalid attempt to destructure non-iterable instance");}};}();exports.default=graph;var _patRegexp=require("./pat-regexp");var _patRegexp2=_interopRequireDefault(_patRegexp);function _interopRequireDefault(obj){return obj&&obj.__esModule?obj:{default:obj};}var req2Name=function req2Name(_ref){var name=_ref.name,version=_ref.version;return name+"@"+version;};function graph(requirements,pattern){var _pattern$split$map$ma=pattern.split("=>").map(function(x){return x||"";}).map(function(x){return x.trim();}).map(_patRegexp2.default).map(function(x){return new RegExp(x);}),_pattern$split$map$ma2=_slicedToArray(_pattern$split$map$ma,2),l=_pattern$split$map$ma2[0],r=_pattern$split$map$ma2[1];var connections=requirements.map(function(req){return[req2Name(req.package),req2Name(req.requires)];}).filter(function(_ref2){var _ref3=_slicedToArray(_ref2,2),x=_ref3[0],y=_ref3[1];return x.match(l)&&y.match(r);}).map(function(_ref4){var _ref5=_slicedToArray(_ref4,2),x=_ref5[0],y=_ref5[1];return" \""+x+"\" -> \""+y+"\";";}).join("\n");return"digraph G {\n"+connections+"\n}";} | ||
var _interopRequireDefault=require("@babel/runtime/helpers/interopRequireDefault");Object.defineProperty(exports,"__esModule",{value:true});exports.default=graph;var _slicedToArray2=_interopRequireDefault(require("@babel/runtime/helpers/slicedToArray"));var _patRegexp=_interopRequireDefault(require("./pat-regexp"));var req2Name=function req2Name(_ref){var name=_ref.name,version=_ref.version;return name+"@"+version;};function graph(requirements,pattern){var _pattern$split$map$ma=pattern.split("=>").map(function(x){return x||"";}).map(function(x){return x.trim();}).map(_patRegexp.default).map(function(x){return new RegExp(x);}),_pattern$split$map$ma2=(0,_slicedToArray2.default)(_pattern$split$map$ma,2),l=_pattern$split$map$ma2[0],r=_pattern$split$map$ma2[1];var connections=requirements.map(function(req){return[req2Name(req.package),req2Name(req.requires)];}).filter(function(_ref2){var _ref3=(0,_slicedToArray2.default)(_ref2,2),x=_ref3[0],y=_ref3[1];return x.match(l)&&y.match(r);}).map(function(_ref4){var _ref5=(0,_slicedToArray2.default)(_ref4,2),x=_ref5[0],y=_ref5[1];return" \""+x+"\" -> \""+y+"\";";}).join("\n");return"digraph G {\n"+connections+"\n}";} |
@@ -1,1 +0,1 @@ | ||
Object.defineProperty(exports,"__esModule",{value:true});var _slicedToArray=function(){function sliceIterator(arr,i){var _arr=[];var _n=true;var _d=false;var _e=undefined;try{for(var _i=arr[typeof Symbol==="function"?Symbol.iterator:"@@iterator"](),_s;!(_n=(_s=_i.next()).done);_n=true){_arr.push(_s.value);if(i&&_arr.length===i)break;}}catch(err){_d=true;_e=err;}finally{try{if(!_n&&_i["return"])_i["return"]();}finally{if(_d)throw _e;}}return _arr;}return function(arr,i){if(Array.isArray(arr)){return arr;}else if((typeof Symbol==="function"?Symbol.iterator:"@@iterator")in Object(arr)){return sliceIterator(arr,i);}else{throw new TypeError("Invalid attempt to destructure non-iterable instance");}};}();var _chalk=require("chalk");var _chalk2=_interopRequireDefault(_chalk);var _path=require("path");var _depend=require("./depend");var _depend2=_interopRequireDefault(_depend);var _graph=require("./graph");var _graph2=_interopRequireDefault(_graph);function _interopRequireDefault(obj){return obj&&obj.__esModule?obj:{default:obj};}function _toConsumableArray(arr){if(Array.isArray(arr)){for(var i=0,arr2=Array(arr.length);i<arr.length;i++){arr2[i]=arr[i];}return arr2;}else{return Array.from(arr);}}function prettifyHint(_ref){var _ref2=_slicedToArray(_ref,3),name=_ref2[0],current=_ref2[1],target=_ref2[2];return" "+_chalk2.default.blue(name)+": "+_chalk2.default.red(current)+" -> "+_chalk2.default.green(target);}exports.default=function main(_ref3){var log=_ref3.log,getPackages=_ref3.getPackages,readJson=_ref3.readJson,writeJson=_ref3.writeJson,argv=_ref3.argv,exit=_ref3.exit;var _argv$lerna,lerna,expr,lernaPath,lernaPackages,packagesToFind,packagesList;return regeneratorRuntime.async(function main$(_context){while(1){switch(_context.prev=_context.next){case 0:_argv$lerna=argv.lerna,lerna=_argv$lerna===undefined?"":_argv$lerna,expr=argv.expr;lernaPath=lerna||!expr?(0,_path.join)(lerna,"lerna.json"):"";if(!lernaPath){_context.next=8;break;}_context.next=5;return regeneratorRuntime.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 5:_context.t0=_context.sent;_context.next=9;break;case 8:_context.t0=[];case 9:lernaPackages=_context.t0;packagesToFind=[].concat(_toConsumableArray(lernaPackages),[expr]).filter(function(x){return x;});_context.next=13;return regeneratorRuntime.awrap(Promise.all(packagesToFind.map(function(path){return getPackages(path);})).then(function(packages){return packages.flatten();}));case 13:packagesList=_context.sent;return _context.abrupt("return",(0,_depend2.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,_graph2.default)(requirements,argv.graph));Promise.resolve(0);}if(argv.list){Object.entries(versionSets).sort(function(_ref6,_ref7){var _ref9=_slicedToArray(_ref6,1),a=_ref9[0];var _ref8=_slicedToArray(_ref7,1),b=_ref8[0];return a.localeCompare(b);}).map(function(_ref10){var _ref11=_slicedToArray(_ref10,2),name=_ref11[0],versions=_ref11[1];return[name,[].concat(_toConsumableArray(versions))];}).forEach(function(_ref12,i){var _ref13=_slicedToArray(_ref12,2),name=_ref13[0],versions=_ref13[1];var color=function(){if(versions.length>1&&!rules[name]){return _chalk2.default.red;}return!rules[name]?_chalk2.default.green:_chalk2.default.yellow;}();log(_chalk2.default.blue(i+1),name,color(versions.join(" ")));});}if(argv.showRules){log(rules);}if(argv.hint||argv.fix){suggestions.forEach(function(_ref14){var _ref15=_slicedToArray(_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=_slicedToArray(_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 15:case"end":return _context.stop();}}},null,this);}; | ||
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();}}});} |
@@ -1,1 +0,1 @@ | ||
Object.defineProperty(exports,"__esModule",{value:true});exports.majorityProgressive=exports.majorityConservative=undefined;exports.conservative=conservative;exports.progressive=progressive;exports.majority=majority;var _semver=require("semver");var _semver2=_interopRequireDefault(_semver);function _interopRequireDefault(obj){return obj&&obj.__esModule?obj:{default:obj};}function combine(s1,s2){return function(a,b){return s1(a,b)||s2(a,b);};}function conservative(a,b){return _semver2.default.compare(a.version,b.version);}function progressive(a,b){return _semver2.default.compare(b.version,a.version);}function majority(a,b){return b.usedBy.length-a.usedBy.length;}var majorityConservative=exports.majorityConservative=combine(majority,conservative);var majorityProgressive=exports.majorityProgressive=combine(majority,progressive); | ||
var _interopRequireDefault=require("@babel/runtime/helpers/interopRequireDefault");Object.defineProperty(exports,"__esModule",{value:true});exports.conservative=conservative;exports.progressive=progressive;exports.majority=majority;exports.majorityProgressive=exports.majorityConservative=void 0;var _semver=_interopRequireDefault(require("semver"));function combine(s1,s2){return function(a,b){return s1(a,b)||s2(a,b);};}function conservative(a,b){return _semver.default.compare(a.version,b.version);}function progressive(a,b){return _semver.default.compare(b.version,a.version);}function majority(a,b){return b.usedBy.length-a.usedBy.length;}var majorityConservative=combine(majority,conservative);exports.majorityConservative=majorityConservative;var majorityProgressive=combine(majority,progressive);exports.majorityProgressive=majorityProgressive; |
{ | ||
"name": "@times-components/depend", | ||
"version": "2.1.15", | ||
"version": "2.1.16", | ||
"description": "dependency analyzer and fixer", | ||
@@ -56,14 +56,11 @@ "main": "dist/depend", | ||
"@times-components/eslint-config-thetimes": "0.8.10", | ||
"babel-cli": "6.26.0", | ||
"babel-core": "6.26.0", | ||
"babel-preset-react-native": "4.0.0", | ||
"babel-core": "^7.0.0-bridge.0", | ||
"babel-jest": "23.6.0", | ||
"depcheck": "0.6.9", | ||
"eslint": "5.9.0", | ||
"jest": "23.3.0", | ||
"jest": "23.6.0", | ||
"prettier": "1.14.3" | ||
}, | ||
"dependencies": { | ||
"babel-plugin-transform-runtime": "6.23.0", | ||
"babel-polyfill": "6.26.0", | ||
"babel-runtime": "6.26.0", | ||
"@babel/polyfill": "^7.0.0", | ||
"chalk": "2.4.1", | ||
@@ -73,2 +70,3 @@ "commander": "2.17.1", | ||
"glob": "7.1.2", | ||
"lodash.flatten": "4.4.0", | ||
"minimatch": "3.0.4", | ||
@@ -80,3 +78,3 @@ "semver": "5.5.0" | ||
}, | ||
"gitHead": "a109cc253d272d41f487221348c8e80f0da38997" | ||
"gitHead": "343f59149fa4252dc0020fe95ff0c42a4195e936" | ||
} |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Minified code
QualityThis package contains minified code. This may be harmless in some cases where minified code is included in packaged libraries, however packages on npm should not minify code.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Trivial Package
Supply chain riskPackages less than 10 lines of code are easily copied into your own project and may not warrant the additional supply chain risk of an external dependency.
Found 1 instance in 1 package
Minified code
QualityThis package contains minified code. This may be harmless in some cases where minified code is included in packaged libraries, however packages on npm should not minify code.
Found 1 instance in 1 package
8
7
14
16
0
40503
+ Added@babel/polyfill@^7.0.0
+ Addedlodash.flatten@4.4.0
+ Added@babel/polyfill@7.12.1(transitive)
+ Addedlodash.flatten@4.4.0(transitive)
+ Addedregenerator-runtime@0.13.11(transitive)
- Removedbabel-polyfill@6.26.0
- Removedbabel-runtime@6.26.0
- Removedbabel-plugin-transform-runtime@6.23.0(transitive)
- Removedbabel-polyfill@6.26.0(transitive)
- Removedbabel-runtime@6.26.0(transitive)
- Removedregenerator-runtime@0.10.50.11.1(transitive)