87 lines
2.1 KiB
Plaintext
87 lines
2.1 KiB
Plaintext
// cell fetch - Fetch package zips from remote sources
|
|
//
|
|
// This command ensures that the zip files on disk match what's in the lock file.
|
|
// For local packages, this is a no-op.
|
|
// For remote packages, downloads the zip if not present or hash mismatch.
|
|
//
|
|
// Usage:
|
|
// cell fetch - Fetch all packages
|
|
// cell fetch <package> - Fetch a specific package
|
|
|
|
var shop = use('internal/shop')
|
|
|
|
// Parse arguments
|
|
var target_pkg = null
|
|
|
|
for (var i = 0; i < args.length; i++) {
|
|
if (args[i] == '--help' || args[i] == '-h') {
|
|
log.console("Usage: cell fetch [package]")
|
|
log.console("Fetch package zips from remote sources.")
|
|
log.console("")
|
|
log.console("Arguments:")
|
|
log.console(" package Optional package name to fetch. If omitted, fetches all.")
|
|
log.console("")
|
|
log.console("This command ensures that the zip files on disk match what's in")
|
|
log.console("the lock file. For local packages, this is a no-op.")
|
|
$stop()
|
|
} else if (!args[i].startsWith('-')) {
|
|
target_pkg = args[i]
|
|
}
|
|
}
|
|
|
|
var all_packages = shop.list_packages()
|
|
var lock = shop.load_lock()
|
|
var packages_to_fetch = []
|
|
|
|
if (target_pkg) {
|
|
// Fetch specific package
|
|
if (!all_packages.includes(target_pkg)) {
|
|
log.error("Package not found: " + target_pkg)
|
|
$stop()
|
|
}
|
|
packages_to_fetch.push(target_pkg)
|
|
} else {
|
|
// Fetch all packages
|
|
packages_to_fetch = all_packages
|
|
}
|
|
|
|
log.console("Fetching " + text(packages_to_fetch.length) + " package(s)...")
|
|
|
|
var success_count = 0
|
|
var skip_count = 0
|
|
var fail_count = 0
|
|
|
|
for (var pkg of packages_to_fetch) {
|
|
var entry = lock[pkg]
|
|
|
|
// Skip local packages
|
|
if (entry && entry.type == 'local') {
|
|
skip_count++
|
|
continue
|
|
}
|
|
|
|
// Skip core (handled separately)
|
|
if (pkg == 'core') {
|
|
skip_count++
|
|
continue
|
|
}
|
|
|
|
var result = shop.fetch(pkg)
|
|
if (result) {
|
|
if (result.zip_blob) {
|
|
log.console("Fetched: " + pkg)
|
|
success_count++
|
|
} else {
|
|
skip_count++
|
|
}
|
|
} else {
|
|
log.error("Failed to fetch: " + pkg)
|
|
fail_count++
|
|
}
|
|
}
|
|
|
|
log.console("")
|
|
log.console("Fetch complete: " + text(success_count) + " fetched, " + text(skip_count) + " skipped, " + text(fail_count) + " failed")
|
|
|
|
$stop()
|