improved fetch

This commit is contained in:
2026-02-20 15:00:08 -06:00
parent 4ac92c8a87
commit 35d0890242
14 changed files with 504 additions and 462 deletions

204
add.ce
View File

@@ -21,111 +21,115 @@ var added = 0
var failed = 0 var failed = 0
var _add_dep = null var _add_dep = null
var _install = null var _install = null
var i = 0
array(args, function(arg) { var run = function() {
if (arg == '--help' || arg == '-h') { for (i = 0; i < length(args); i++) {
if (args[i] == '--help' || args[i] == '-h') {
log.console("Usage: cell add <locator> [alias]")
log.console("")
log.console("Add a dependency to the current package.")
log.console("")
log.console("Examples:")
log.console(" cell add gitea.pockle.world/john/prosperon")
log.console(" cell add gitea.pockle.world/john/cell-image image")
log.console(" cell add ../local-package")
log.console(" cell add -r ../packages")
return
} else if (args[i] == '-r') {
recursive = true
} else if (!starts_with(args[i], '-')) {
if (!locator) {
locator = args[i]
} else if (!alias) {
alias = args[i]
}
}
}
if (!locator && !recursive) {
log.console("Usage: cell add <locator> [alias]") log.console("Usage: cell add <locator> [alias]")
log.console("") return
log.console("Add a dependency to the current package.") }
log.console("")
log.console("Examples:") if (locator)
log.console(" cell add gitea.pockle.world/john/prosperon") locator = shop.resolve_locator(locator)
log.console(" cell add gitea.pockle.world/john/cell-image image")
log.console(" cell add ../local-package") // Generate default alias from locator
log.console(" cell add -r ../packages") if (!alias && locator) {
$stop() parts = array(locator, '/')
} else if (arg == '-r') { alias = parts[length(parts) - 1]
recursive = true if (search(alias, '@') != null)
} else if (!starts_with(arg, '-')) { alias = array(alias, '@')[0]
if (!locator) { }
locator = arg
} else if (!alias) { // Check we're in a package directory
alias = arg if (!fd.is_file(cwd + '/cell.toml')) {
log.error("Not in a package directory (no cell.toml found)")
return
}
// Recursive mode
if (recursive) {
if (!locator) locator = '.'
locator = shop.resolve_locator(locator)
if (!fd.is_dir(locator)) {
log.error(`${locator} is not a directory`)
return
} }
} locators = filter(pkg.find_packages(locator), function(p) {
}) return p != cwd
})
if (!locator && !recursive) { if (length(locators) == 0) {
log.console("Usage: cell add <locator> [alias]") log.console("No packages found in " + locator)
$stop() return
}
if (locator)
locator = shop.resolve_locator(locator)
// Generate default alias from locator
if (!alias && locator) {
parts = array(locator, '/')
alias = parts[length(parts) - 1]
if (search(alias, '@') != null)
alias = array(alias, '@')[0]
}
// Check we're in a package directory
if (!fd.is_file(cwd + '/cell.toml')) {
log.error("Not in a package directory (no cell.toml found)")
$stop()
}
// Recursive mode
if (recursive) {
if (!locator) locator = '.'
locator = shop.resolve_locator(locator)
if (!fd.is_dir(locator)) {
log.error(`${locator} is not a directory`)
$stop()
}
locators = filter(pkg.find_packages(locator), function(p) {
return p != cwd
})
if (length(locators) == 0) {
log.console("No packages found in " + locator)
$stop()
}
log.console(`Found ${text(length(locators))} package(s) in ${locator}`)
added = 0
failed = 0
arrfor(locators, function(loc) {
var loc_parts = array(loc, '/')
var loc_alias = loc_parts[length(loc_parts) - 1]
log.console(" Adding " + loc + " as '" + loc_alias + "'...")
var _add = function() {
pkg.add_dependency(null, loc, loc_alias)
shop.sync(loc)
added = added + 1
} disruption {
log.console(` Warning: Failed to add ${loc}`)
failed = failed + 1
} }
_add() log.console(`Found ${text(length(locators))} package(s) in ${locator}`)
})
log.console("Added " + text(added) + " package(s)." + (failed > 0 ? " Failed: " + text(failed) + "." : "")) added = 0
$stop() failed = 0
arrfor(locators, function(loc) {
var loc_parts = array(loc, '/')
var loc_alias = loc_parts[length(loc_parts) - 1]
log.console(" Adding " + loc + " as '" + loc_alias + "'...")
var _add = function() {
pkg.add_dependency(null, loc, loc_alias)
shop.sync(loc)
added = added + 1
} disruption {
log.console(` Warning: Failed to add ${loc}`)
failed = failed + 1
}
_add()
})
log.console("Added " + text(added) + " package(s)." + (failed > 0 ? " Failed: " + text(failed) + "." : ""))
return
}
// Single package add
log.console("Adding " + locator + " as '" + alias + "'...")
_add_dep = function() {
pkg.add_dependency(null, locator, alias)
log.console(" Added to cell.toml")
} disruption {
log.error("Failed to update cell.toml")
return
}
_add_dep()
_install = function() {
shop.sync_with_deps(locator)
log.console(" Installed to shop")
} disruption {
log.error("Failed to install")
return
}
_install()
log.console("Added " + alias + " (" + locator + ")")
} }
run()
// Single package add
log.console("Adding " + locator + " as '" + alias + "'...")
_add_dep = function() {
pkg.add_dependency(null, locator, alias)
log.console(" Added to cell.toml")
} disruption {
log.error("Failed to update cell.toml")
$stop()
}
_add_dep()
_install = function() {
shop.sync_with_deps(locator)
log.console(" Installed to shop")
} disruption {
log.error("Failed to install")
$stop()
}
_install()
log.console("Added " + alias + " (" + locator + ")")
$stop() $stop()

View File

@@ -14,17 +14,18 @@ var pkg = use('package')
var target_package = null var target_package = null
var i = 0 var i = 0
for (i = 0; i < length(args); i++) { var run = function() {
if (args[i] == '--help' || args[i] == '-h') { for (i = 0; i < length(args); i++) {
log.console("Usage: cell audit [<locator>]") if (args[i] == '--help' || args[i] == '-h') {
log.console("") log.console("Usage: cell audit [<locator>]")
log.console("Test-compile all .ce and .cm scripts in package(s).") log.console("")
log.console("Reports all errors without stopping at the first failure.") log.console("Test-compile all .ce and .cm scripts in package(s).")
$stop() log.console("Reports all errors without stopping at the first failure.")
} else if (!starts_with(args[i], '-')) { return
target_package = args[i] } else if (!starts_with(args[i], '-')) {
target_package = args[i]
}
} }
}
// Resolve local paths // Resolve local paths
if (target_package) { if (target_package) {
@@ -68,5 +69,7 @@ if (length(all_failures) > 0) {
} }
log.console("Audit complete: " + text(total_ok) + "/" + text(total_scripts) + " scripts compiled" + (total_errors > 0 ? ", " + text(total_errors) + " failed" : "")) log.console("Audit complete: " + text(total_ok) + "/" + text(total_scripts) + " scripts compiled" + (total_errors > 0 ? ", " + text(total_errors) + " failed" : ""))
}
run()
$stop() $stop()

View File

@@ -27,51 +27,52 @@ var results = null
var success = 0 var success = 0
var failed = 0 var failed = 0
for (i = 0; i < length(args); i++) { var run = function() {
if (args[i] == '-t' || args[i] == '--target') { for (i = 0; i < length(args); i++) {
if (i + 1 < length(args)) { if (args[i] == '-t' || args[i] == '--target') {
target = args[++i] if (i + 1 < length(args)) {
} else { target = args[++i]
log.error('-t requires a target') } else {
$stop() log.error('-t requires a target')
} return
} else if (args[i] == '-p' || args[i] == '--package') {
// Legacy support for -p flag
if (i + 1 < length(args)) {
target_package = args[++i]
} else {
log.error('-p requires a package name')
$stop()
}
} else if (args[i] == '-b' || args[i] == '--buildtype') {
if (i + 1 < length(args)) {
buildtype = args[++i]
if (buildtype != 'release' && buildtype != 'debug' && buildtype != 'minsize') {
log.error('Invalid buildtype: ' + buildtype + '. Must be release, debug, or minsize')
$stop()
} }
} else { } else if (args[i] == '-p' || args[i] == '--package') {
log.error('-b requires a buildtype (release, debug, minsize)') // Legacy support for -p flag
$stop() if (i + 1 < length(args)) {
target_package = args[++i]
} else {
log.error('-p requires a package name')
return
}
} else if (args[i] == '-b' || args[i] == '--buildtype') {
if (i + 1 < length(args)) {
buildtype = args[++i]
if (buildtype != 'release' && buildtype != 'debug' && buildtype != 'minsize') {
log.error('Invalid buildtype: ' + buildtype + '. Must be release, debug, or minsize')
return
}
} else {
log.error('-b requires a buildtype (release, debug, minsize)')
return
}
} else if (args[i] == '--force') {
force_rebuild = true
} else if (args[i] == '--verbose' || args[i] == '-v') {
verbose = true
} else if (args[i] == '--dry-run') {
dry_run = true
} else if (args[i] == '--list-targets') {
log.console('Available targets:')
targets = build.list_targets()
for (t = 0; t < length(targets); t++) {
log.console(' ' + targets[t])
}
return
} else if (!starts_with(args[i], '-') && !target_package) {
// Positional argument - treat as package locator
target_package = args[i]
} }
} else if (args[i] == '--force') {
force_rebuild = true
} else if (args[i] == '--verbose' || args[i] == '-v') {
verbose = true
} else if (args[i] == '--dry-run') {
dry_run = true
} else if (args[i] == '--list-targets') {
log.console('Available targets:')
targets = build.list_targets()
for (t = 0; t < length(targets); t++) {
log.console(' ' + targets[t])
}
$stop()
} else if (!starts_with(args[i], '-') && !target_package) {
// Positional argument - treat as package locator
target_package = args[i]
} }
}
if (target_package) if (target_package)
target_package = shop.resolve_locator(target_package) target_package = shop.resolve_locator(target_package)
@@ -82,11 +83,11 @@ if (!target) {
if (target) log.console('Target: ' + target) if (target) log.console('Target: ' + target)
} }
if (target && !build.has_target(target)) { if (target && !build.has_target(target)) {
log.error('Invalid target: ' + target) log.error('Invalid target: ' + target)
log.console('Available targets: ' + text(build.list_targets(), ', ')) log.console('Available targets: ' + text(build.list_targets(), ', '))
$stop() return
} }
var packages = shop.list_packages() var packages = shop.list_packages()
arrfor(packages, function(package) { arrfor(packages, function(package) {
@@ -123,5 +124,7 @@ if (target_package) {
log.console(`Build complete: ${success} libraries built${failed > 0 ? `, ${failed} failed` : ''}`) log.console(`Build complete: ${success} libraries built${failed > 0 ? `, ${failed} failed` : ''}`)
} }
}
run()
$stop() $stop()

View File

@@ -26,39 +26,40 @@ var dry_run = false
var i = 0 var i = 0
var deps = null var deps = null
for (i = 0; i < length(args); i++) { var run = function() {
if (args[i] == '--build') { for (i = 0; i < length(args); i++) {
clean_build = true if (args[i] == '--build') {
} else if (args[i] == '--fetch') { clean_build = true
clean_fetch = true } else if (args[i] == '--fetch') {
} else if (args[i] == '--all') { clean_fetch = true
clean_build = true } else if (args[i] == '--all') {
clean_fetch = true clean_build = true
} else if (args[i] == '--deep') { clean_fetch = true
deep = true } else if (args[i] == '--deep') {
} else if (args[i] == '--dry-run') { deep = true
dry_run = true } else if (args[i] == '--dry-run') {
} else if (args[i] == '--help' || args[i] == '-h') { dry_run = true
log.console("Usage: cell clean [<scope>] [options]") } else if (args[i] == '--help' || args[i] == '-h') {
log.console("") log.console("Usage: cell clean [<scope>] [options]")
log.console("Remove cached material to force refetch/rebuild.") log.console("")
log.console("") log.console("Remove cached material to force refetch/rebuild.")
log.console("Scopes:") log.console("")
log.console(" <locator> Clean specific package") log.console("Scopes:")
log.console(" shop Clean entire shop") log.console(" <locator> Clean specific package")
log.console(" world Clean all world packages") log.console(" shop Clean entire shop")
log.console("") log.console(" world Clean all world packages")
log.console("Options:") log.console("")
log.console(" --build Remove build outputs only (default)") log.console("Options:")
log.console(" --fetch Remove fetched sources only") log.console(" --build Remove build outputs only (default)")
log.console(" --all Remove both build outputs and fetched sources") log.console(" --fetch Remove fetched sources only")
log.console(" --deep Apply to full dependency closure") log.console(" --all Remove both build outputs and fetched sources")
log.console(" --dry-run Show what would be deleted") log.console(" --deep Apply to full dependency closure")
$stop() log.console(" --dry-run Show what would be deleted")
} else if (!starts_with(args[i], '-')) { return
scope = args[i] } else if (!starts_with(args[i], '-')) {
scope = args[i]
}
} }
}
// Default to --build if nothing specified // Default to --build if nothing specified
if (!clean_build && !clean_fetch) { if (!clean_build && !clean_fetch) {
@@ -190,5 +191,7 @@ if (dry_run) {
log.console("Clean complete: " + text(deleted_count) + " item(s) deleted.") log.console("Clean complete: " + text(deleted_count) + " item(s) deleted.")
} }
} }
}
run()
$stop() $stop()

View File

@@ -7,11 +7,12 @@ var fd = use('fd')
var http = use('http') var http = use('http')
var miniz = use('miniz') var miniz = use('miniz')
if (length(args) < 2) { var run = function() {
log.console("Usage: cell clone <origin> <path>") if (length(args) < 2) {
log.console("Clones a cell package to a local path and links it.") log.console("Usage: cell clone <origin> <path>")
$stop() log.console("Clones a cell package to a local path and links it.")
} return
}
var origin = args[0] var origin = args[0]
var target_path = args[1] var target_path = args[1]
@@ -20,34 +21,34 @@ var target_path = args[1]
target_path = shop.resolve_locator(target_path) target_path = shop.resolve_locator(target_path)
// Check if target already exists // Check if target already exists
if (fd.is_dir(target_path)) { if (fd.is_dir(target_path)) {
log.console("Error: " + target_path + " already exists") log.console("Error: " + target_path + " already exists")
$stop() return
} }
log.console("Cloning " + origin + " to " + target_path + "...") log.console("Cloning " + origin + " to " + target_path + "...")
// Get the latest commit // Get the latest commit
var info = shop.resolve_package_info(origin) var info = shop.resolve_package_info(origin)
if (!info || info == 'local') { if (!info || info == 'local') {
log.console("Error: " + origin + " is not a remote package") log.console("Error: " + origin + " is not a remote package")
$stop() return
} }
// Update to get the commit hash // Update to get the commit hash
var update_result = shop.update(origin) var update_result = shop.update(origin)
if (!update_result) { if (!update_result) {
log.console("Error: Could not fetch " + origin) log.console("Error: Could not fetch " + origin)
$stop() return
} }
// Fetch and extract to the target path // Fetch and extract to the target path
var lock = shop.load_lock() var lock = shop.load_lock()
var entry = lock[origin] var entry = lock[origin]
if (!entry || !entry.commit) { if (!entry || !entry.commit) {
log.console("Error: No commit found for " + origin) log.console("Error: No commit found for " + origin)
$stop() return
} }
var download_url = shop.get_download_url(origin, entry.commit) var download_url = shop.get_download_url(origin, entry.commit)
log.console("Downloading from " + download_url) log.console("Downloading from " + download_url)
@@ -69,7 +70,7 @@ var _clone = function() {
zip = miniz.read(zip_blob) zip = miniz.read(zip_blob)
if (!zip) { if (!zip) {
log.console("Error: Failed to read zip archive") log.console("Error: Failed to read zip archive")
$stop() return
} }
// Create target directory // Create target directory
@@ -102,6 +103,8 @@ var _clone = function() {
} disruption { } disruption {
log.console("Error during clone") log.console("Error during clone")
} }
_clone() _clone()
}
run()
$stop() $stop()

View File

@@ -14,33 +14,36 @@ var i = 0
var packages = null var packages = null
var count = 0 var count = 0
for (i = 0; i < length(args); i++) { var run = function() {
if (args[i] == '--help' || args[i] == '-h') { for (i = 0; i < length(args); i++) {
log.console("Usage: cell fetch [package]") if (args[i] == '--help' || args[i] == '-h') {
log.console("Sync packages from remote sources.") log.console("Usage: cell fetch [package]")
log.console("") log.console("Sync packages from remote sources.")
log.console("Arguments:") log.console("")
log.console(" package Optional package to sync. If omitted, syncs all.") log.console("Arguments:")
$stop() log.console(" package Optional package to sync. If omitted, syncs all.")
} else if (!starts_with(args[i], '-')) { return
target_pkg = args[i] } else if (!starts_with(args[i], '-')) {
target_pkg = args[i]
}
}
if (target_pkg) {
target_pkg = shop.resolve_locator(target_pkg)
log.console("Syncing " + target_pkg + "...")
shop.sync(target_pkg)
log.console("Done.")
} else {
packages = shop.list_packages()
count = 0
arrfor(packages, function(pkg) {
if (pkg == 'core') return
shop.sync(pkg)
count = count + 1
})
log.console("Synced " + text(count) + " package(s).")
} }
} }
run()
if (target_pkg) {
target_pkg = shop.resolve_locator(target_pkg)
log.console("Syncing " + target_pkg + "...")
shop.sync(target_pkg)
log.console("Done.")
} else {
packages = shop.list_packages()
count = 0
arrfor(packages, function(pkg) {
if (pkg == 'core') return
shop.sync(pkg)
count = count + 1
})
log.console("Synced " + text(count) + " package(s).")
}
$stop() $stop()

View File

@@ -23,39 +23,40 @@ var show_locked = false
var show_world = false var show_world = false
var i = 0 var i = 0
for (i = 0; i < length(args); i++) { var run = function() {
if (args[i] == '--format' || args[i] == '-f') { for (i = 0; i < length(args); i++) {
if (i + 1 < length(args)) { if (args[i] == '--format' || args[i] == '-f') {
format = args[++i] if (i + 1 < length(args)) {
if (format != 'tree' && format != 'dot' && format != 'json') { format = args[++i]
log.error('Invalid format: ' + format + '. Must be tree, dot, or json') if (format != 'tree' && format != 'dot' && format != 'json') {
$stop() log.error('Invalid format: ' + format + '. Must be tree, dot, or json')
return
}
} else {
log.error('--format requires a format type')
return
} }
} else { } else if (args[i] == '--resolved') {
log.error('--format requires a format type') show_locked = false
$stop() } else if (args[i] == '--locked') {
show_locked = true
} else if (args[i] == '--world') {
show_world = true
} else if (args[i] == '--help' || args[i] == '-h') {
log.console("Usage: cell graph [<locator>] [options]")
log.console("")
log.console("Emit the dependency graph.")
log.console("")
log.console("Options:")
log.console(" --format <fmt> Output format: tree (default), dot, json")
log.console(" --resolved Show resolved view with links applied (default)")
log.console(" --locked Show lock view without links")
log.console(" --world Graph all packages in shop")
return
} else if (!starts_with(args[i], '-')) {
target_locator = args[i]
} }
} else if (args[i] == '--resolved') {
show_locked = false
} else if (args[i] == '--locked') {
show_locked = true
} else if (args[i] == '--world') {
show_world = true
} else if (args[i] == '--help' || args[i] == '-h') {
log.console("Usage: cell graph [<locator>] [options]")
log.console("")
log.console("Emit the dependency graph.")
log.console("")
log.console("Options:")
log.console(" --format <fmt> Output format: tree (default), dot, json")
log.console(" --resolved Show resolved view with links applied (default)")
log.console(" --locked Show lock view without links")
log.console(" --world Graph all packages in shop")
$stop()
} else if (!starts_with(args[i], '-')) {
target_locator = args[i]
} }
}
var links = show_locked ? {} : link.load() var links = show_locked ? {} : link.load()
@@ -236,5 +237,7 @@ if (format == 'tree') {
log.console(json.encode(output)) log.console(json.encode(output))
} }
}
run()
$stop() $stop()

View File

@@ -24,37 +24,38 @@ var lock = null
var installed = 0 var installed = 0
var failed = 0 var failed = 0
for (i = 0; i < length(args); i++) { var run = function() {
if (args[i] == '--target' || args[i] == '-t') { for (i = 0; i < length(args); i++) {
if (i + 1 < length(args)) { if (args[i] == '--target' || args[i] == '-t') {
target_triple = args[++i] if (i + 1 < length(args)) {
} else { target_triple = args[++i]
log.error('--target requires a triple') } else {
$stop() log.error('--target requires a triple')
return
}
} else if (args[i] == '--dry-run') {
dry_run = true
} else if (args[i] == '-r') {
recursive = true
} else if (args[i] == '--help' || args[i] == '-h') {
log.console("Usage: cell install <locator> [options]")
log.console("")
log.console("Install a package and its dependencies.")
log.console("")
log.console("Options:")
log.console(" --target <triple> Build for target platform")
log.console(" --dry-run Show what would be installed")
log.console(" -r Recursively find and install all packages in directory")
return
} else if (!starts_with(args[i], '-')) {
locator = args[i]
} }
} else if (args[i] == '--dry-run') {
dry_run = true
} else if (args[i] == '-r') {
recursive = true
} else if (args[i] == '--help' || args[i] == '-h') {
log.console("Usage: cell install <locator> [options]")
log.console("")
log.console("Install a package and its dependencies.")
log.console("")
log.console("Options:")
log.console(" --target <triple> Build for target platform")
log.console(" --dry-run Show what would be installed")
log.console(" -r Recursively find and install all packages in directory")
$stop()
} else if (!starts_with(args[i], '-')) {
locator = args[i]
} }
}
if (!locator && !recursive) { if (!locator && !recursive) {
log.console("Usage: cell install <locator> [options]") log.console("Usage: cell install <locator> [options]")
$stop() return
} }
if (locator) if (locator)
locator = shop.resolve_locator(locator) locator = shop.resolve_locator(locator)
@@ -65,14 +66,14 @@ if (recursive) {
locator = shop.resolve_locator(locator) locator = shop.resolve_locator(locator)
if (!fd.is_dir(locator)) { if (!fd.is_dir(locator)) {
log.error(`${locator} is not a directory`) log.error(`${locator} is not a directory`)
$stop() return
} }
locators = filter(pkg.find_packages(locator), function(p) { locators = filter(pkg.find_packages(locator), function(p) {
return p != cwd return p != cwd
}) })
if (length(locators) == 0) { if (length(locators) == 0) {
log.console("No packages found in " + locator) log.console("No packages found in " + locator)
$stop() return
} }
log.console(`Found ${text(length(locators))} package(s) in ${locator}`) log.console(`Found ${text(length(locators))} package(s) in ${locator}`)
@@ -82,35 +83,36 @@ if (recursive) {
lock = shop.load_lock() lock = shop.load_lock()
log.console(" " + loc + (lock[loc] ? " (already installed)" : "")) log.console(" " + loc + (lock[loc] ? " (already installed)" : ""))
}) })
$stop() } else {
installed = 0
failed = 0
arrfor(locators, function(loc) {
log.console(" Installing " + loc + "...")
var _inst = function() {
shop.sync(loc, {target: target_triple})
installed = installed + 1
} disruption {
failed = failed + 1
log.console(` Warning: Failed to install ${loc}`)
}
_inst()
})
log.console("Installed " + text(installed) + " package(s)." + (failed > 0 ? " Failed: " + text(failed) + "." : ""))
}
return
}
// Single package install with dependencies
if (dry_run) {
log.console("Would install: " + locator + " (and dependencies)")
return
} }
installed = 0 log.console("Installing " + locator + "...")
failed = 0 shop.sync_with_deps(locator, {refresh: true, target: target_triple})
arrfor(locators, function(loc) { log.console("Done.")
log.console(" Installing " + loc + "...")
var _inst = function() {
shop.sync(loc, {target: target_triple})
installed = installed + 1
} disruption {
failed = failed + 1
log.console(` Warning: Failed to install ${loc}`)
}
_inst()
})
log.console("Installed " + text(installed) + " package(s)." + (failed > 0 ? " Failed: " + text(failed) + "." : ""))
$stop()
} }
run()
// Single package install with dependencies
if (dry_run) {
log.console("Would install: " + locator + " (and dependencies)")
$stop()
}
log.console("Installing " + locator + "...")
shop.sync_with_deps(locator, {refresh: true, target: target_triple})
log.console("Done.")
$stop() $stop()

33
link.ce
View File

@@ -34,17 +34,18 @@ var _restore = null
var _read_toml = null var _read_toml = null
var _add_link = null var _add_link = null
if (length(args) < 1) { var run = function() {
log.console("Usage: link <command> [args] or link [package] <target>") if (length(args) < 1) {
log.console("Commands:") log.console("Usage: link <command> [args] or link [package] <target>")
log.console(" list List all active links") log.console("Commands:")
log.console(" sync Ensure all symlinks are in place") log.console(" list List all active links")
log.console(" delete <package> Remove a link and restore original") log.console(" sync Ensure all symlinks are in place")
log.console(" clear Remove all links") log.console(" delete <package> Remove a link and restore original")
log.console(" <path> Link the package in <path> to that path") log.console(" clear Remove all links")
log.console(" <package> <target> Link <package> to <target> (path or package)") log.console(" <path> Link the package in <path> to that path")
$stop() log.console(" <package> <target> Link <package> to <target> (path or package)")
} return
}
cmd = args[0] cmd = args[0]
@@ -71,7 +72,7 @@ if (cmd == 'list') {
} else if (cmd == 'delete' || cmd == 'rm') { } else if (cmd == 'delete' || cmd == 'rm') {
if (length(args) < 2) { if (length(args) < 2) {
log.console("Usage: link delete <package>") log.console("Usage: link delete <package>")
$stop() return
} }
pkg = args[1] pkg = args[1]
@@ -113,7 +114,7 @@ if (cmd == 'list') {
if (!arg1) { if (!arg1) {
log.console("Error: target or package required") log.console("Error: target or package required")
$stop() return
} }
if (arg2) { if (arg2) {
@@ -136,7 +137,7 @@ if (cmd == 'list') {
if (!fd.is_file(toml_path)) { if (!fd.is_file(toml_path)) {
log.console("Error: No cell.toml found at " + target) log.console("Error: No cell.toml found at " + target)
log.console("For linking to another package, use: link <package> <target>") log.console("For linking to another package, use: link <package> <target>")
$stop() return
} }
// Read package name from cell.toml // Read package name from cell.toml
@@ -159,7 +160,7 @@ if (cmd == 'list') {
if (starts_with(target, '/')) { if (starts_with(target, '/')) {
if (!fd.is_file(target + '/cell.toml')) { if (!fd.is_file(target + '/cell.toml')) {
log.console("Error: " + target + " is not a valid package (no cell.toml)") log.console("Error: " + target + " is not a valid package (no cell.toml)")
$stop() return
} }
} }
@@ -172,5 +173,7 @@ if (cmd == 'list') {
} }
_add_link() _add_link()
} }
}
run()
$stop() $stop()

45
list.ce
View File

@@ -18,31 +18,32 @@ var local_pkgs = null
var linked_pkgs = null var linked_pkgs = null
var remote_pkgs = null var remote_pkgs = null
if (args && length(args) > 0) { var run = function() {
if (args[0] == 'shop') { if (args && length(args) > 0) {
mode = 'shop' if (args[0] == 'shop') {
} else if (args[0] == '--help' || args[0] == '-h') { mode = 'shop'
log.console("Usage: cell list [<scope>]") } else if (args[0] == '--help' || args[0] == '-h') {
log.console("") log.console("Usage: cell list [<scope>]")
log.console("List packages and dependencies.") log.console("")
log.console("") log.console("List packages and dependencies.")
log.console("Scopes:") log.console("")
log.console(" (none) List dependencies of current package") log.console("Scopes:")
log.console(" shop List all packages in shop with status") log.console(" (none) List dependencies of current package")
log.console(" <locator> List dependency tree for a package") log.console(" shop List all packages in shop with status")
$stop() log.console(" <locator> List dependency tree for a package")
} else { return
mode = 'package' } else {
target_pkg = args[0] mode = 'package'
target_pkg = args[0]
target_pkg = shop.resolve_locator(target_pkg) target_pkg = shop.resolve_locator(target_pkg)
}
} }
}
var links = link.load() var links = link.load()
var lock = shop.load_lock() var lock = shop.load_lock()
function print_deps(ctx, raw_indent) { function print_deps(ctx, raw_indent) {
var aliases = null var aliases = null
var indent = raw_indent || "" var indent = raw_indent || ""
deps = null deps = null
@@ -173,5 +174,7 @@ if (mode == 'local') {
log.console("Total: " + text(length(packages)) + " package(s)") log.console("Total: " + text(length(packages)) + " package(s)")
} }
} }
}
run()
$stop() $stop()

View File

@@ -18,29 +18,30 @@ var prune = false
var dry_run = false var dry_run = false
var i = 0 var i = 0
for (i = 0; i < length(args); i++) { var run = function() {
if (args[i] == '--prune') { for (i = 0; i < length(args); i++) {
prune = true if (args[i] == '--prune') {
} else if (args[i] == '--dry-run') { prune = true
dry_run = true } else if (args[i] == '--dry-run') {
} else if (args[i] == '--help' || args[i] == '-h') { dry_run = true
log.console("Usage: cell remove <locator> [options]") } else if (args[i] == '--help' || args[i] == '-h') {
log.console("") log.console("Usage: cell remove <locator> [options]")
log.console("Remove a package from the shop.") log.console("")
log.console("") log.console("Remove a package from the shop.")
log.console("Options:") log.console("")
log.console(" --prune Also remove packages no longer needed by any root") log.console("Options:")
log.console(" --dry-run Show what would be removed") log.console(" --prune Also remove packages no longer needed by any root")
$stop() log.console(" --dry-run Show what would be removed")
} else if (!starts_with(args[i], '-')) { return
target_pkg = args[i] } else if (!starts_with(args[i], '-')) {
target_pkg = args[i]
}
} }
}
if (!target_pkg) { if (!target_pkg) {
log.console("Usage: cell remove <locator> [options]") log.console("Usage: cell remove <locator> [options]")
$stop() return
} }
target_pkg = shop.resolve_locator(target_pkg) target_pkg = shop.resolve_locator(target_pkg)
@@ -100,5 +101,7 @@ if (dry_run) {
log.console("Removed " + text(length(packages_to_remove)) + " package(s).") log.console("Removed " + text(length(packages_to_remove)) + " package(s).")
} }
}
run()
$stop() $stop()

View File

@@ -22,32 +22,33 @@ var show_locked = false
var refresh_first = false var refresh_first = false
var i = 0 var i = 0
for (i = 0; i < length(args); i++) { var run = function() {
if (args[i] == '--target' || args[i] == '-t') { for (i = 0; i < length(args); i++) {
if (i + 1 < length(args)) { if (args[i] == '--target' || args[i] == '-t') {
target_triple = args[++i] if (i + 1 < length(args)) {
} else { target_triple = args[++i]
log.error('--target requires a triple') } else {
$stop() log.error('--target requires a triple')
return
}
} else if (args[i] == '--locked') {
show_locked = true
} else if (args[i] == '--refresh') {
refresh_first = true
} else if (args[i] == '--help' || args[i] == '-h') {
log.console("Usage: cell resolve [<locator>] [options]")
log.console("")
log.console("Print the fully resolved dependency closure.")
log.console("")
log.console("Options:")
log.console(" --target <triple> Annotate builds for target platform")
log.console(" --locked Show lock state without applying links")
log.console(" --refresh Refresh floating refs before printing")
return
} else if (!starts_with(args[i], '-')) {
target_locator = args[i]
} }
} else if (args[i] == '--locked') {
show_locked = true
} else if (args[i] == '--refresh') {
refresh_first = true
} else if (args[i] == '--help' || args[i] == '-h') {
log.console("Usage: cell resolve [<locator>] [options]")
log.console("")
log.console("Print the fully resolved dependency closure.")
log.console("")
log.console("Options:")
log.console(" --target <triple> Annotate builds for target platform")
log.console(" --locked Show lock state without applying links")
log.console(" --refresh Refresh floating refs before printing")
$stop()
} else if (!starts_with(args[i], '-')) {
target_locator = args[i]
} }
}
// Default to current directory // Default to current directory
if (!target_locator) { if (!target_locator) {
@@ -57,16 +58,16 @@ if (!target_locator) {
// Resolve local paths // Resolve local paths
target_locator = shop.resolve_locator(target_locator) target_locator = shop.resolve_locator(target_locator)
// Check if it's a valid package // Check if it's a valid package
var pkg_dir = null var pkg_dir = null
if (!fd.is_file(target_locator + '/cell.toml')) { if (!fd.is_file(target_locator + '/cell.toml')) {
// Try to find it in the shop // Try to find it in the shop
pkg_dir = shop.get_package_dir(target_locator) pkg_dir = shop.get_package_dir(target_locator)
if (!fd.is_file(pkg_dir + '/cell.toml')) { if (!fd.is_file(pkg_dir + '/cell.toml')) {
log.error("Not a valid package: " + target_locator) log.error("Not a valid package: " + target_locator)
$stop() return
}
} }
}
// Detect target if not specified // Detect target if not specified
if (!target_triple) { if (!target_triple) {
@@ -210,7 +211,9 @@ for (i = 0; i < length(sorted); i++) {
} }
} }
log.console("") log.console("")
log.console("Total: " + text(length(sorted)) + " package(s)") log.console("Total: " + text(length(sorted)) + " package(s)")
}
run()
$stop() $stop()

View File

@@ -23,25 +23,26 @@ var i = 0
var updated = 0 var updated = 0
var packages = null var packages = null
for (i = 0; i < length(args); i++) { var run = function() {
if (args[i] == '--help' || args[i] == '-h') { for (i = 0; i < length(args); i++) {
log.console("Usage: cell update [<locator>] [options]") if (args[i] == '--help' || args[i] == '-h') {
log.console("") log.console("Usage: cell update [<locator>] [options]")
log.console("Update packages from remote sources.") log.console("")
log.console("") log.console("Update packages from remote sources.")
log.console("Options:") log.console("")
log.console(" --target <triple> Target platform for build") log.console("Options:")
log.console(" --follow-links Update link targets instead of origins") log.console(" --target <triple> Target platform for build")
log.console(" --git Run git pull on local packages") log.console(" --follow-links Update link targets instead of origins")
$stop() log.console(" --git Run git pull on local packages")
} else if (args[i] == '--target' || args[i] == '-t') { return
if (i + 1 < length(args)) { } else if (args[i] == '--target' || args[i] == '-t') {
target_triple = args[++i] if (i + 1 < length(args)) {
} else { target_triple = args[++i]
log.error('--target requires a triple') } else {
$stop() log.error('--target requires a triple')
} return
} else if (args[i] == '--follow-links') { }
} else if (args[i] == '--follow-links') {
follow_links = true follow_links = true
} else if (args[i] == '--git') { } else if (args[i] == '--git') {
git_pull = true git_pull = true
@@ -113,5 +114,7 @@ if (target_pkg) {
log.console("All packages are up to date.") log.console("All packages are up to date.")
} }
} }
}
run()
$stop() $stop()

View File

@@ -22,34 +22,35 @@ var deep = false
var target_triple = null var target_triple = null
var i = 0 var i = 0
for (i = 0; i < length(args); i++) { var run = function() {
if (args[i] == '--deep') { for (i = 0; i < length(args); i++) {
deep = true if (args[i] == '--deep') {
} else if (args[i] == '--target' || args[i] == '-t') { deep = true
if (i + 1 < length(args)) { } else if (args[i] == '--target' || args[i] == '-t') {
target_triple = args[++i] if (i + 1 < length(args)) {
} else { target_triple = args[++i]
log.error('--target requires a triple') } else {
$stop() log.error('--target requires a triple')
return
}
} else if (args[i] == '--help' || args[i] == '-h') {
log.console("Usage: cell verify [<scope>] [options]")
log.console("")
log.console("Verify integrity and consistency.")
log.console("")
log.console("Scopes:")
log.console(" <locator> Verify specific package")
log.console(" shop Verify entire shop")
log.console(" world Verify all world roots")
log.console("")
log.console("Options:")
log.console(" --deep Traverse full dependency closure")
log.console(" --target <triple> Verify builds for specific target")
return
} else if (!starts_with(args[i], '-')) {
scope = args[i]
} }
} else if (args[i] == '--help' || args[i] == '-h') {
log.console("Usage: cell verify [<scope>] [options]")
log.console("")
log.console("Verify integrity and consistency.")
log.console("")
log.console("Scopes:")
log.console(" <locator> Verify specific package")
log.console(" shop Verify entire shop")
log.console(" world Verify all world roots")
log.console("")
log.console("Options:")
log.console(" --deep Traverse full dependency closure")
log.console(" --target <triple> Verify builds for specific target")
$stop()
} else if (!starts_with(args[i], '-')) {
scope = args[i]
} }
}
// Default to current directory // Default to current directory
if (!scope) { if (!scope) {
@@ -250,5 +251,7 @@ if (length(errors) > 0) {
} else { } else {
log.console("Verification PASSED: " + text(checked) + " package(s) checked, " + text(length(warnings)) + " warning(s)") log.console("Verification PASSED: " + text(checked) + " package(s) checked, " + text(length(warnings)) + " warning(s)")
} }
}
run()
$stop() $stop()