This commit is contained in:
2025-12-03 08:28:33 -06:00
parent 76bdccc4ee
commit ee3a890d4a
3 changed files with 9 additions and 42 deletions

View File

@@ -2,8 +2,6 @@
var fd = use('fd') var fd = use('fd')
var shop = use('shop') var shop = use('shop')
var miniz = use('miniz')
var http = use('http')
if (args.length < 1) { if (args.length < 1) {
log.console("Usage: cell get <locator> [alias]") log.console("Usage: cell get <locator> [alias]")
@@ -17,42 +15,15 @@ if (args.length < 1) {
var locator = args[0] var locator = args[0]
var parsed = shop.parse_locator(locator) 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 // Use the module name as the default alias
var alias = parsed.name var alias = parsed.name
if (args.length > 1) if (args.length > 1)
alias = args[1] alias = args[1]
if (!alias) { if (!alias)
log.error("Failed to determine alias") throw new Error("Failed to determine alias");
$_.stop()
return
}
// 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) log.console("Adding dependency: " + alias + " = " + locator)
shop.add_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() $_.stop()

View File

@@ -36,7 +36,6 @@ Shop.set_os = function(o)
var config = null var config = null
var shop_path = '.cell/cell.toml' var shop_path = '.cell/cell.toml'
var lock_path = '.cell/lock.toml'
var open_dl = {} var open_dl = {}
@@ -144,6 +143,7 @@ Shop.load_config = function(module) {
content = fd.slurp(module_path) content = fd.slurp(module_path)
} }
if (!content.length) return {}
return toml.decode(text(content)) return toml.decode(text(content))
} }
@@ -275,14 +275,14 @@ Shop.get_download_url = function(locator) {
// Add a dependency // Add a dependency
Shop.add_dependency = function(alias, locator) { Shop.add_dependency = function(alias, locator) {
var config = Shop.load_config() var config = Shop.load_config()
if (!config) { if (!config)
log.error("No cell.toml found") throw new Error("No cell.toml found");
return false
}
if (!config.dependencies) { if (!config.dependencies)
config.dependencies = {} config.dependencies = {}
}
if (config.dependencies[alias] == locator)
throw new Error("Dependency '" + alias + "' already exists with the same version");
config.dependencies[alias] = locator config.dependencies[alias] = locator
Shop.save_config(config) Shop.save_config(config)
@@ -508,8 +508,6 @@ var open_dls = {}
function resolve_locator(path, ext, ctx) function resolve_locator(path, ext, ctx)
{ {
var deps = Shop.load_config(ctx).dependencies || {}
var local_path var local_path
if (ctx) if (ctx)
local_path = `.cell/modules/${ctx}/${path}${ext}` local_path = `.cell/modules/${ctx}/${path}${ext}`

View File

@@ -1,6 +1,4 @@
// cell update - Check for updates
var shop = use('shop') var shop = use('shop')
log.console("Checking for updates...") log.console("Checking for updates...")
shop.update() shop.update()
$_.stop() $_.stop()