Files
cell/scripts/update.js
John Alanbrook 939269b060
Some checks failed
Build and Deploy / build-macos (push) Failing after 7s
Build and Deploy / build-linux (push) Has been cancelled
Build and Deploy / build-windows (CLANG64) (push) Has been cancelled
Build and Deploy / package-dist (push) Has been cancelled
Build and Deploy / deploy-itch (push) Has been cancelled
Build and Deploy / deploy-gitea (push) Has been cancelled
initial modules attempt
2025-05-29 18:48:19 -05:00

51 lines
1.3 KiB
JavaScript

// cell update <alias> - Update a dependency to a new version
var io = use('io')
var shop = use('shop')
if (args.length < 1) {
log.console("Usage: cell update <alias> [new-version]")
log.console("Example: cell update jj_mod v0.7.0")
$_.stop()
return
}
var alias = args[0]
if (!io.exists('.cell/shop.toml')) {
log.error("No shop.toml found. Run 'cell init' first.")
$_.stop()
return
}
var config = shop.load_config()
if (!config || !config.dependencies || !config.dependencies[alias]) {
log.error("Dependency '" + alias + "' not found")
$_.stop()
return
}
var current_version = config.dependencies[alias]
log.console("Current version: " + current_version)
if (args.length > 1) {
// Update to specific version
var new_version = args[1]
// Parse the current locator to keep the host/path
var parsed = shop.parse_locator(current_version)
if (parsed) {
var new_locator = parsed.path + '@' + new_version
config.dependencies[alias] = new_locator
shop.save_config(config)
log.console("Updated " + alias + " to " + new_locator)
log.console("Run 'cell get " + new_locator + "' to fetch the new version")
}
} else {
// TODO: Check for latest version
log.console("TODO: Check for latest version of " + alias)
log.console("For now, specify version: cell update " + alias + " <version>")
}
$_.stop()