This commit is contained in:
2026-02-20 15:33:46 -06:00
parent 11fb213a74
commit 5af76bce9b
40 changed files with 284 additions and 314 deletions

View File

@@ -153,7 +153,7 @@ function package_in_shop(package) {
function abs_path_to_package(package_dir)
{
if (!fd.is_file(package_dir + '/cell.toml')) {
print('Not a valid package directory (no cell.toml): ' + package_dir)
log.error('Not a valid package directory (no cell.toml): ' + package_dir)
disrupt
}
@@ -352,12 +352,12 @@ Shop.resolve_package_info = function(pkg) {
// Verify if a package name is valid and return status
Shop.verify_package_name = function(pkg) {
if (!pkg) { print("Empty package name"); disrupt }
if (pkg == 'local') { print("local is not a valid package name"); disrupt }
if (pkg == 'core') { print("core is not a valid package name"); disrupt }
if (!pkg) { log.error("Empty package name"); disrupt }
if (pkg == 'local') { log.error("local is not a valid package name"); disrupt }
if (pkg == 'core') { log.error("core is not a valid package name"); disrupt }
if (search(pkg, '://') != null) {
print(`Invalid package name: ${pkg}; did you mean ${array(pkg, '://')[1]}?`)
log.error(`Invalid package name: ${pkg}; did you mean ${array(pkg, '://')[1]}?`)
disrupt
}
}
@@ -661,10 +661,10 @@ var _streamline_mod = null
// Compile a module and return its bytecode blob.
// The bytecode is cached on disk by content hash.
function resolve_mod_fn(path, pkg) {
if (!fd.is_file(path)) { print(`path ${path} is not a file`); disrupt }
if (!fd.is_file(path)) { log.error(`path ${path} is not a file`); disrupt }
var content = text(fd.slurp(path))
if (length(content) == 0) { print(`${path}: empty file`); disrupt }
if (length(content) == 0) { log.error(`${path}: empty file`); disrupt }
var content_key = stone(blob(content))
var native_result = null
var cached = null
@@ -739,7 +739,7 @@ function resolve_mod_fn(path, pkg) {
if (!_mcode_mod) _mcode_mod = use_cache['core/mcode'] || use_cache['mcode']
if (!_streamline_mod) _streamline_mod = use_cache['core/streamline'] || use_cache['streamline']
if (!_mcode_mod || !_streamline_mod) {
print(`error: compiler modules not loaded (mcode=${_mcode_mod != null}, streamline=${_streamline_mod != null})`)
log.error(`error: compiler modules not loaded (mcode=${_mcode_mod != null}, streamline=${_streamline_mod != null})`)
disrupt
}
ast = analyze(content, path)
@@ -758,7 +758,7 @@ function resolve_mod_fn(path, pkg) {
return compiled
}
print(`Module ${path} could not be loaded: no artifact found or all methods blocked by policy`)
log.error(`Module ${path} could not be loaded: no artifact found or all methods blocked by policy`)
disrupt
}
@@ -1223,7 +1223,7 @@ function execute_module(info)
log.shop(`Module could not be found (c_resolve scope=${info.c_resolve.scope}, mod_resolve scope=${info.mod_resolve.scope}, cache_key=${info.cache_key})`); disrupt
}
if (!used) { print(`Module ${info} returned null`); disrupt }
if (!used) { log.error(`Module ${info} returned null`); disrupt }
return used
}
@@ -1481,7 +1481,7 @@ Shop.extract = function(pkg) {
var zip_blob = get_package_zip(pkg)
if (!zip_blob) {
print("No zip blob available for " + pkg)
log.error("No zip blob available for " + pkg)
disrupt
}
@@ -1569,7 +1569,7 @@ Shop.update = function(pkg) {
function install_zip(zip_blob, target_dir) {
var zip = miniz.read(zip_blob)
if (!zip) { print("Failed to read zip archive"); disrupt }
if (!zip) { log.error("Failed to read zip archive"); disrupt }
if (fd.is_link(target_dir)) fd.unlink(target_dir)
if (fd.is_dir(target_dir)) fd.rmdir(target_dir, 1)
@@ -1641,14 +1641,14 @@ Shop.get = function(pkg) {
if (!lock[pkg]) {
info = Shop.resolve_package_info(pkg)
if (!info) {
print("Invalid package: " + pkg); disrupt
log.error("Invalid package: " + pkg); disrupt
}
commit = null
if (info != 'local') {
commit = fetch_remote_hash(pkg)
if (!commit) {
print("Could not resolve commit for " + pkg); disrupt
log.error("Could not resolve commit for " + pkg); disrupt
}
}
@@ -1813,7 +1813,7 @@ Shop.load_as_mach = function(path, pkg) {
var inject = null
var env = null
if (!locator) { print('Module ' + path + ' not found'); disrupt }
if (!locator) { log.error('Module ' + path + ' not found'); disrupt }
file_path = locator.path
content = text(fd.slurp(file_path))
@@ -1838,7 +1838,7 @@ Shop.load_as_mach = function(path, pkg) {
if (!_mcode_mod) _mcode_mod = use_cache['core/mcode'] || use_cache['mcode']
if (!_streamline_mod) _streamline_mod = use_cache['core/streamline'] || use_cache['streamline']
if (!_mcode_mod || !_streamline_mod) {
print('error: compiler modules not loaded')
log.error('error: compiler modules not loaded')
disrupt
}
ast = analyze(content, file_path)
@@ -1874,7 +1874,7 @@ Shop.load_as_dylib = function(path, pkg) {
var inject = null
var env = null
if (!locator) { print('Module ' + path + ' not found'); disrupt }
if (!locator) { log.error('Module ' + path + ' not found'); disrupt }
file_path = locator.path
if (!real_pkg) {
@@ -1942,7 +1942,7 @@ Shop.use_native = function(path, package_context) {
var src_path = path
if (!starts_with(path, '/'))
src_path = fd.realpath(path)
if (!fd.is_file(src_path)) { print('File not found: ' + path); disrupt }
if (!fd.is_file(src_path)) { log.error('File not found: ' + path); disrupt }
var file_info = Shop.file_info(src_path)
var pkg = file_info.package || package_context
@@ -1955,7 +1955,7 @@ Shop.use_native = function(path, package_context) {
var dylib_path = build.compile_native(src_path, null, null, pkg)
var handle = os.dylib_open(dylib_path)
if (!handle) { print('Failed to open native dylib: ' + dylib_path); disrupt }
if (!handle) { log.error('Failed to open native dylib: ' + dylib_path); disrupt }
// Build env with runtime functions and capabilities
var inject = Shop.script_inject_for(file_info)