From ee3a890d4a3a95e4c69a4b9e1b2d3fb772460e21 Mon Sep 17 00:00:00 2001 From: John Alanbrook Date: Wed, 3 Dec 2025 08:28:33 -0600 Subject: [PATCH] fix --- scripts/get.ce | 33 ++------------------------------- scripts/shop.cm | 16 +++++++--------- scripts/update.ce | 2 -- 3 files changed, 9 insertions(+), 42 deletions(-) diff --git a/scripts/get.ce b/scripts/get.ce index 7af54cfd..12f7d249 100644 --- a/scripts/get.ce +++ b/scripts/get.ce @@ -2,8 +2,6 @@ var fd = use('fd') var shop = use('shop') -var miniz = use('miniz') -var http = use('http') if (args.length < 1) { log.console("Usage: cell get [alias]") @@ -17,42 +15,15 @@ if (args.length < 1) { var locator = args[0] var parsed = shop.parse_locator(locator) -var config = shop.load_config() -if (!config) { - log.error("Failed to load cell.toml") - $_.stop() - return -} - // Use the module name as the default alias var alias = parsed.name if (args.length > 1) alias = args[1] -if (!alias) { - log.error("Failed to determine alias") - $_.stop() - return -} +if (!alias) + throw new Error("Failed to determine alias"); -// Check if already exists -if (config.dependencies && config.dependencies[alias]) { - log.console("Dependency '" + alias + "' already exists with version: " + config.dependencies[alias]) - log.console("Use 'cell update " + alias + "' to change version") - $_.stop() - return -} - -// Add to dependencies log.console("Adding dependency: " + alias + " = " + locator) shop.add_dependency(alias, locator) -// Create module directory -var module_dir = '.cell/modules/' + alias + '@' + parsed.version -if (!fd.is_directory(module_dir)) - fd.mkdir(module_dir) - -// TODO: Actually fetch the module from the repository -log.console("Module directory created at: " + module_dir) - $_.stop() \ No newline at end of file diff --git a/scripts/shop.cm b/scripts/shop.cm index a02ed97c..f5178257 100644 --- a/scripts/shop.cm +++ b/scripts/shop.cm @@ -36,7 +36,6 @@ Shop.set_os = function(o) var config = null var shop_path = '.cell/cell.toml' -var lock_path = '.cell/lock.toml' var open_dl = {} @@ -144,6 +143,7 @@ Shop.load_config = function(module) { content = fd.slurp(module_path) } + if (!content.length) return {} return toml.decode(text(content)) } @@ -275,14 +275,14 @@ Shop.get_download_url = function(locator) { // Add a dependency Shop.add_dependency = function(alias, locator) { var config = Shop.load_config() - if (!config) { - log.error("No cell.toml found") - return false - } + if (!config) + throw new Error("No cell.toml found"); - if (!config.dependencies) { + if (!config.dependencies) config.dependencies = {} - } + + if (config.dependencies[alias] == locator) + throw new Error("Dependency '" + alias + "' already exists with the same version"); config.dependencies[alias] = locator Shop.save_config(config) @@ -508,8 +508,6 @@ var open_dls = {} function resolve_locator(path, ext, ctx) { - var deps = Shop.load_config(ctx).dependencies || {} - var local_path if (ctx) local_path = `.cell/modules/${ctx}/${path}${ext}` diff --git a/scripts/update.ce b/scripts/update.ce index c9175930..4e4a3e7f 100644 --- a/scripts/update.ce +++ b/scripts/update.ce @@ -1,6 +1,4 @@ -// cell update - Check for updates var shop = use('shop') - log.console("Checking for updates...") shop.update() $_.stop() \ No newline at end of file