update cli docs and fix cli scripts with new syntax
This commit is contained in:
39
graph.ce
39
graph.ce
@@ -22,8 +22,10 @@ var target_locator = null
|
||||
var format = 'tree'
|
||||
var show_locked = false
|
||||
var show_world = false
|
||||
var i = 0
|
||||
var resolved = null
|
||||
|
||||
for (var i = 0; i < length(args); i++) {
|
||||
for (i = 0; i < length(args); i++) {
|
||||
if (args[i] == '--format' || args[i] == '-f') {
|
||||
if (i + 1 < length(args)) {
|
||||
format = args[++i]
|
||||
@@ -91,7 +93,7 @@ function gather_graph(locator, visited) {
|
||||
|
||||
add_node(locator)
|
||||
|
||||
try {
|
||||
var _gather = function() {
|
||||
var deps = pkg.dependencies(locator)
|
||||
if (deps) {
|
||||
arrfor(array(deps), function(alias) {
|
||||
@@ -101,17 +103,19 @@ function gather_graph(locator, visited) {
|
||||
gather_graph(dep_locator, visited)
|
||||
})
|
||||
}
|
||||
} catch (e) {
|
||||
} disruption {
|
||||
// Package might not have dependencies
|
||||
}
|
||||
_gather()
|
||||
}
|
||||
|
||||
// Gather graph from roots
|
||||
var roots = []
|
||||
|
||||
var packages = null
|
||||
if (show_world) {
|
||||
// Use all packages in shop as roots
|
||||
var packages = shop.list_packages()
|
||||
packages = shop.list_packages()
|
||||
arrfor(packages, function(p) {
|
||||
if (p != 'core') {
|
||||
push(roots, p)
|
||||
@@ -125,7 +129,7 @@ if (show_world) {
|
||||
|
||||
// Resolve local paths
|
||||
if (target_locator == '.' || starts_with(target_locator, './') || starts_with(target_locator, '../') || fd.is_dir(target_locator)) {
|
||||
var resolved = fd.realpath(target_locator)
|
||||
resolved = fd.realpath(target_locator)
|
||||
if (resolved) {
|
||||
target_locator = resolved
|
||||
}
|
||||
@@ -141,14 +145,19 @@ arrfor(roots, function(root) {
|
||||
// Output based on format
|
||||
if (format == 'tree') {
|
||||
function print_tree(locator, prefix, is_last, visited) {
|
||||
var node = null
|
||||
var suffix = null
|
||||
var children = null
|
||||
var j = 0
|
||||
var child_prefix = null
|
||||
if (visited[locator]) {
|
||||
log.console(prefix + (is_last ? "\\-- " : "|-- ") + locator + " (circular)")
|
||||
return
|
||||
}
|
||||
visited[locator] = true
|
||||
|
||||
var node = nodes[locator]
|
||||
var suffix = ""
|
||||
node = nodes[locator]
|
||||
suffix = ""
|
||||
if (node.linked) suffix += " -> " + node.effective
|
||||
if (node.commit) suffix += " @" + node.commit
|
||||
if (node.local) suffix += " (local)"
|
||||
@@ -156,30 +165,32 @@ if (format == 'tree') {
|
||||
log.console(prefix + (is_last ? "\\-- " : "|-- ") + locator + suffix)
|
||||
|
||||
// Get children
|
||||
var children = []
|
||||
children = []
|
||||
arrfor(edges, function(e) {
|
||||
if (e.from == locator) {
|
||||
push(children, e)
|
||||
}
|
||||
})
|
||||
|
||||
for (var i = 0; i < length(children); i++) {
|
||||
var child_prefix = prefix + (is_last ? " " : "| ")
|
||||
print_tree(children[i].to, child_prefix, i == length(children) - 1, visited)
|
||||
for (j = 0; j < length(children); j++) {
|
||||
child_prefix = prefix + (is_last ? " " : "| ")
|
||||
print_tree(children[j].to, child_prefix, j == length(children) - 1, visited)
|
||||
}
|
||||
}
|
||||
|
||||
for (var i = 0; i < length(roots); i++) {
|
||||
var children = null
|
||||
var j = 0
|
||||
for (i = 0; i < length(roots); i++) {
|
||||
log.console(roots[i])
|
||||
|
||||
var children = []
|
||||
children = []
|
||||
arrfor(edges, function(e) {
|
||||
if (e.from == roots[i]) {
|
||||
push(children, e)
|
||||
}
|
||||
})
|
||||
|
||||
for (var j = 0; j < length(children); j++) {
|
||||
for (j = 0; j < length(children); j++) {
|
||||
print_tree(children[j].to, "", j == length(children) - 1, {})
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user