fix
This commit is contained in:
88
update.ce
88
update.ce
@@ -1,45 +1,77 @@
|
||||
// cell update [alias] - Update packages to latest versions and rebuild dynamic libraries
|
||||
// cell update - Update packages from remote sources
|
||||
//
|
||||
// This command:
|
||||
// 1. Updates all packages from their remote sources
|
||||
// 2. Rebuilds all dynamic libraries via 'cell build -d'
|
||||
// This command checks for updates to all packages and downloads new versions.
|
||||
// For local packages, ensures the symlink is correct.
|
||||
// For remote packages, checks the remote for new commits.
|
||||
//
|
||||
// Usage:
|
||||
// cell update - Update all packages
|
||||
// cell update <package> - Update a specific package
|
||||
|
||||
var shop = use('shop')
|
||||
var os = use('os')
|
||||
|
||||
var target = null
|
||||
var target_pkg = null
|
||||
|
||||
// Parse arguments
|
||||
for (var i = 0; i < args.length; i++) {
|
||||
if (args[i] == '--target' || args[i] == '-t') {
|
||||
if (i + 1 < args.length) {
|
||||
target = args[i + 1]
|
||||
i++
|
||||
}
|
||||
} else if (args[i] == '--help' || args[i] == '-h') {
|
||||
log.console("Usage: cell update [options]")
|
||||
log.console("Update packages and rebuild dynamic libraries.")
|
||||
if (args[i] == '--help' || args[i] == '-h') {
|
||||
log.console("Usage: cell update [package]")
|
||||
log.console("Update packages from remote sources.")
|
||||
log.console("")
|
||||
log.console("Options:")
|
||||
log.console(" --target, -t <target> Build for specific target platform")
|
||||
log.console("Arguments:")
|
||||
log.console(" package Optional package name to update. If omitted, updates all.")
|
||||
log.console("")
|
||||
log.console("This command updates all installed packages from their remote")
|
||||
log.console("sources, then rebuilds all dynamic libraries.")
|
||||
log.console("This command checks for updates to all packages and downloads")
|
||||
log.console("new versions. For local packages, ensures the symlink is correct.")
|
||||
$_.stop()
|
||||
} else if (!args[i].startsWith('-')) {
|
||||
target_pkg = args[i]
|
||||
}
|
||||
}
|
||||
|
||||
var packages = shop.list_shop_packages()
|
||||
|
||||
log.console("Checking for updates (" + text(packages.length) + " packages)...")
|
||||
|
||||
// 1. Update all packages
|
||||
for (var info of packages) {
|
||||
var pack = info.package
|
||||
if (!pack || pack == 'core') continue
|
||||
function update_and_fetch(pkg)
|
||||
{
|
||||
var lock = shop.load_lock()
|
||||
var old_entry = lock[pkg]
|
||||
var old_commit = old_entry ? old_entry.commit : null
|
||||
|
||||
log.console("Updating " + pack)
|
||||
shop.update(pack)
|
||||
var new_entry = shop.update(pkg)
|
||||
|
||||
if (new_entry && new_entry.commit) {
|
||||
log.console(" " + pkg + " " + old_commit.substring(0, 8) + " -> " + new_entry.commit.substring(0, 8))
|
||||
shop.fetch(pkg)
|
||||
shop.build_package_scripts(pkg)
|
||||
return true
|
||||
}
|
||||
return false
|
||||
}
|
||||
|
||||
if (target_pkg) {
|
||||
if (update_and_fetch(target_pkg))
|
||||
log.console("Updated " + target_pkg + ".")
|
||||
else
|
||||
log.console(target_pkg + " is up to date.")
|
||||
} else {
|
||||
var packages = shop.list_packages()
|
||||
var pkg_count = packages.length
|
||||
log.console("Checking for updates (" + text(pkg_count) + " package" + (pkg_count == 1 ? "" : "s") + ")...")
|
||||
|
||||
var updated_count = 0
|
||||
|
||||
for (var i = 0; i < packages.length; i++) {
|
||||
var pkg = packages[i]
|
||||
if (pkg == 'core') continue
|
||||
|
||||
if (update_and_fetch(pkg)) {
|
||||
updated_count++
|
||||
}
|
||||
}
|
||||
|
||||
if (updated_count > 0) {
|
||||
log.console("Updated " + text(updated_count) + " package" + (updated_count == 1 ? "" : "s") + ".")
|
||||
} else {
|
||||
log.console("All packages are up to date.")
|
||||
}
|
||||
}
|
||||
|
||||
$_.stop()
|
||||
|
||||
Reference in New Issue
Block a user