Comparing version 0.0.2 to 0.0.3
45
deps.js
@@ -1,19 +0,20 @@ | ||
import graphlib from 'graphlib'; | ||
import semver from 'semver'; | ||
import * as list from 'croc-list'; | ||
var graphlib = require('graphlib'); | ||
var semver = require('semver'); | ||
var list = require('croc-list'); | ||
export function order({lenient}) { | ||
const graph = new graphlib.Graph(); | ||
const packages = list.packages(); | ||
exports.order = function(options) { | ||
var opts = options || {}; | ||
var graph = new graphlib.Graph(); | ||
var packages = list.packages(); | ||
Object.keys(packages).forEach((key) => { | ||
const pkg = packages[key]; | ||
const info = require(pkg.file); | ||
const pkgDeps = info.dependencies || {}; | ||
Object.keys(packages).forEach(function(key) { | ||
var pkg = packages[key]; | ||
var info = require(pkg.file); | ||
var pkgDeps = info.dependencies || {}; | ||
graph.setNode(pkg.name); | ||
Object.keys(pkgDeps) | ||
.filter(dName => packages[dName]) | ||
.filter(dName => lenient || semver.satisfies(packages[dName].version, pkgDeps[dName])) | ||
.forEach(dName => graph.setEdge(pkg.name, dName, pkgDeps[dName])); | ||
.filter(function(dName) { return packages[dName]; }) | ||
.filter(function(dName) { return options.lenient || semver.satisfies(packages[dName].version, pkgDeps[dName]); }) | ||
.forEach(function(dName) { graph.setEdge(pkg.name, dName, pkgDeps[dName]) }); | ||
}); | ||
@@ -23,11 +24,13 @@ | ||
.reverse() | ||
.map(pName => [ | ||
pName, | ||
packages[pName].version, | ||
graph.successors(pName).map(dName => dName + '#' + graph.edge(pName, dName)), | ||
packages[pName].file | ||
]); | ||
.map(function(pName) { | ||
return [ | ||
pName, | ||
packages[pName].version, | ||
graph.successors(pName).map(function(dName) { return dName + '#' + graph.edge(pName, dName); }), | ||
packages[pName].file | ||
]; | ||
}); | ||
}; | ||
// const findPredecessors = (graph, node) => { | ||
// var findPredecessors = (graph, node) => { | ||
// let acc = new Set() | ||
@@ -41,2 +44,2 @@ // let findPredAcc = (node) => { | ||
// const needBuild = changed.reduce((sum, ch) => new Set([...sum, ...findPredecessors(graph, ch)]), new Set()); | ||
// var needBuild = changed.reduce((sum, ch) => new Set([...sum, ...findPredecessors(graph, ch)]), new Set()); |
{ | ||
"name": "croc-deps", | ||
"version": "0.0.2", | ||
"version": "0.0.3", | ||
"description": "", | ||
"main": "dist/deps-es5.js", | ||
"jsnext:main": "deps.js", | ||
"main": "deps.js", | ||
"scripts": { | ||
"test": "echo \"No test is available.\"", | ||
"prebuild": "rm -rf dist/ && mkdir dist", | ||
"build": "babel --presets es2015 -o dist/deps-es5.js deps.js" | ||
"build": "echo \"No need for build.\"" | ||
}, | ||
@@ -17,4 +15,4 @@ "author": "Pavel Fatrdla", | ||
"graphlib": "~1.0.7", | ||
"semver": "~5.0.3" | ||
"semver": "~5.0.3" | ||
} | ||
} |
Sorry, the diff of this file is not supported yet
2
1735
3
36