92 lines
2.7 KiB
Plaintext
92 lines
2.7 KiB
Plaintext
// list installed packages
|
|
// cell list -> list packages installed in this package
|
|
// cell list all -> list all packages (including those that are there due to installed packages)
|
|
// cell list package <name> -> list the packages for the package <name>
|
|
|
|
var shop = use('shop')
|
|
|
|
var mode = 'local'
|
|
var target_pkg = null
|
|
|
|
if (args && args.length > 0) {
|
|
if (args[0] == 'all') {
|
|
mode = 'all'
|
|
} else if (args[0] == 'shop') {
|
|
mode = 'shop'
|
|
} else if (args[0] == 'package') {
|
|
if (args.length < 2) {
|
|
log.console("Usage: cell list package <name>")
|
|
$_.stop()
|
|
return
|
|
}
|
|
mode = 'package'
|
|
target_pkg = args[1]
|
|
} else {
|
|
log.console("Usage:")
|
|
log.console(" cell list : list local packages")
|
|
log.console(" cell list all : list all recursive packages")
|
|
log.console(" cell list package <name>: list dependencies of <name>")
|
|
log.console(" cell list shop : list all packages in shop")
|
|
$_.stop()
|
|
return
|
|
}
|
|
}
|
|
|
|
if (mode == 'local') {
|
|
log.console("Installed Packages (Local):")
|
|
print_deps(null)
|
|
} else if (mode == 'package') {
|
|
// Resolve alias to canonical package path
|
|
var canon = shop.get_canonical_package(target_pkg, null)
|
|
if (!canon) {
|
|
log.console("Package '" + target_pkg + "' not found in local dependencies.")
|
|
} else {
|
|
log.console("Dependencies for " + target_pkg + " (" + canon + "):")
|
|
print_deps(canon)
|
|
}
|
|
} else if (mode == 'all') {
|
|
log.console("All Packages:")
|
|
var all = shop.list_packages(null)
|
|
// list_packages returns an array of package strings (locators)
|
|
// We want to perhaps sort them
|
|
all.sort()
|
|
for (var i = 0; i < all.length; i++) {
|
|
log.console(" " + all[i])
|
|
}
|
|
if (all.length == 0) log.console(" (none)")
|
|
} else if (mode == 'shop') {
|
|
log.console("Shop Packages:")
|
|
var all = shop.list_shop_packages()
|
|
// Sort by package name or something
|
|
|
|
if (all.length == 0) {
|
|
log.console(" (none)")
|
|
} else {
|
|
for (var i = 0; i < all.length; i++) {
|
|
var item = all[i]
|
|
var name = item.package || "unknown"
|
|
var ver = item.commit || item.type || "unknown"
|
|
log.console(" " + name + " [" + ver + "]")
|
|
}
|
|
}
|
|
}
|
|
|
|
function print_deps(ctx) {
|
|
var deps = shop.dependencies(ctx)
|
|
var aliases = []
|
|
for (var k in deps) aliases.push(k)
|
|
aliases.sort()
|
|
|
|
if (aliases.length == 0) {
|
|
log.console(" (none)")
|
|
} else {
|
|
for (var i = 0; i < aliases.length; i++) {
|
|
var alias = aliases[i]
|
|
var locator = deps[alias]
|
|
log.console(" " + alias + " -> " + locator)
|
|
}
|
|
}
|
|
}
|
|
|
|
$_.stop()
|