ls
This commit is contained in:
@@ -2,7 +2,7 @@
|
||||
|
||||
var fd = use('fd')
|
||||
|
||||
if (!fd.stat('.cell/build').isDirectory) {
|
||||
if (!fd.is_dir('.cell/build')) {
|
||||
log.console("No build directory found")
|
||||
$_.stop()
|
||||
return
|
||||
|
||||
@@ -23,6 +23,8 @@ function use_embed(name) {
|
||||
return load_internal(`js_${name}_use`)
|
||||
}
|
||||
|
||||
globalThis.use = use_embed
|
||||
|
||||
var qop = use_embed('qop')
|
||||
var core_qop = qop.open(hidden.core_qop_blob)
|
||||
var utf8 = use_embed('utf8')
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
// cell help - Display help information for cell commands
|
||||
|
||||
var fd = use('fd')
|
||||
var utf8 = use('utf8')
|
||||
|
||||
var command = args.length > 0 ? args[0] : null
|
||||
|
||||
@@ -10,7 +9,7 @@ if (command) {
|
||||
var man_file = 'scripts/man/' + command + '.man'
|
||||
var stat = fd.stat(man_file);
|
||||
if (stat && stat.isFile) {
|
||||
var content = utf8.decode(fd.slurp(man_file))
|
||||
var content = text(fd.slurp(man_file))
|
||||
log.console(content)
|
||||
} else {
|
||||
log.error("No help available for command: " + command)
|
||||
@@ -24,7 +23,7 @@ if (command) {
|
||||
var cell_man = 'scripts/man/cell.man'
|
||||
var stat = fd.stat(cell_man);
|
||||
if (stat && stat.isFile) {
|
||||
var content = utf8.decode(fd.slurp(cell_man))
|
||||
var content = text(fd.slurp(cell_man))
|
||||
log.console(content)
|
||||
} else {
|
||||
// Fallback if man file doesn't exist
|
||||
|
||||
@@ -426,13 +426,28 @@ Shop.verify = function(locator) {
|
||||
|
||||
var open_dls = {}
|
||||
|
||||
// for script forms, path is the canonical path of the module
|
||||
var script_forms = []
|
||||
|
||||
script_forms['.cm'] = function(path, script) {
|
||||
return `(function setup_module($_){${script}})`
|
||||
var display_path = path
|
||||
if (path && path.startsWith('.cell/modules/')) {
|
||||
display_path = path.substring('.cell/modules/'.length)
|
||||
var last_slash = display_path.lastIndexOf('/')
|
||||
if (last_slash != -1)
|
||||
display_path = display_path.substring(0, last_slash)
|
||||
}
|
||||
|
||||
// injecting a custom use function that passes the module path
|
||||
var fn = `(function setup_module($_){ var use = function(path) { return globalThis.use(path, '${display_path}'); }; ${script}})`
|
||||
return fn
|
||||
}
|
||||
|
||||
script_forms['.ce'] = function(path, script) {
|
||||
var display_path = path
|
||||
if (path && path.startsWith('.cell/modules/'))
|
||||
display_path = path.substring('.cell/modules/'.length)
|
||||
|
||||
return `(function start($_, arg) { var args = arg; ${script} ; })`
|
||||
}
|
||||
|
||||
@@ -461,7 +476,7 @@ function resolve_mod_fn(path)
|
||||
function resolve_locator(path, ext, ctx)
|
||||
{
|
||||
var local_path
|
||||
if (ctx)
|
||||
if (ctx)
|
||||
local_path = `.cell/modules/${ctx}/${path}${ext}`
|
||||
else
|
||||
local_path = path + ext
|
||||
@@ -494,7 +509,6 @@ function resolve_c_symbol(path, package_ctx)
|
||||
var local_path = package_ctx ? package_ctx : 'local'
|
||||
var local = `js_${local_path}_${path.replace('/', '_')}_use`
|
||||
var local_dl_name = `.cell/build/${local_path}/cellmod.dylib`
|
||||
|
||||
if (fd.is_file(local_dl_name)) {
|
||||
if (!open_dls[local_dl_name])
|
||||
open_dls[local_dl_name] = os.dylib_open(local_dl_name);
|
||||
@@ -1055,23 +1069,11 @@ Shop.compile_module = function(alias) {
|
||||
return true
|
||||
}
|
||||
|
||||
// Build all modules
|
||||
Shop.build = function() {
|
||||
var config = Shop.load_config()
|
||||
if (!config || !config.dependencies) {
|
||||
return true
|
||||
}
|
||||
|
||||
for (var alias in config.dependencies) {
|
||||
Shop.compile_module(alias)
|
||||
}
|
||||
|
||||
return true
|
||||
}
|
||||
|
||||
// Get all declared dependencies as a map of alias -> locator
|
||||
Shop.get_dependencies = function() {
|
||||
return Shop.dependencies(null)
|
||||
Shop.build_package = function(package)
|
||||
{
|
||||
var files = Shop.list_modules(package)
|
||||
log.console(`going to build package ${package}:`)
|
||||
log.console(files)
|
||||
}
|
||||
|
||||
// Get dependencies for a specific context (package canonical path)
|
||||
@@ -1084,6 +1086,43 @@ Shop.dependencies = function(ctx) {
|
||||
return config.dependencies
|
||||
}
|
||||
|
||||
Shop.list_packages = function(root)
|
||||
{
|
||||
var queue = []
|
||||
var processed = {}
|
||||
var result = []
|
||||
|
||||
var deps = Shop.dependencies(root)
|
||||
for (var alias in deps) {
|
||||
var locator = deps[alias]
|
||||
if (!processed[locator]) {
|
||||
queue.push(locator)
|
||||
}
|
||||
}
|
||||
|
||||
while (queue.length > 0) {
|
||||
var locator = queue.shift()
|
||||
if (processed[locator]) continue
|
||||
processed[locator] = true
|
||||
|
||||
result.push(locator)
|
||||
|
||||
var parsed = Shop.parse_locator(locator)
|
||||
var pkg_config = Shop.load_config(parsed.path)
|
||||
|
||||
if (pkg_config && pkg_config.dependencies) {
|
||||
for (var alias in pkg_config.dependencies) {
|
||||
var dep_locator = pkg_config.dependencies[alias]
|
||||
if (!processed[dep_locator]) {
|
||||
queue.push(dep_locator)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return result
|
||||
}
|
||||
|
||||
// List all .cm and .ce files in a package
|
||||
// If ctx is null, lists local files
|
||||
// If ctx is a canonical path, lists files in that module
|
||||
|
||||
@@ -303,12 +303,12 @@ JSC_CCALL(socket_send,
|
||||
JS_FreeCString(js, data);
|
||||
} else {
|
||||
unsigned char *data = js_get_blob_data(js, &len, argv[1]);
|
||||
if (data == (unsigned char *)-1) {
|
||||
if (data == -1)
|
||||
return JS_EXCEPTION;
|
||||
}
|
||||
if (len == 0) {
|
||||
|
||||
if (len == 0)
|
||||
return JS_ThrowReferenceError(js, "No data to send");
|
||||
}
|
||||
|
||||
sent = send(sockfd, (const char *)data, len, flags);
|
||||
}
|
||||
|
||||
|
||||
@@ -7,4 +7,11 @@ var alias = args.length > 0 ? args[0] : null
|
||||
log.console("Checking for updates...")
|
||||
shop.update_all(alias)
|
||||
|
||||
var packages = shop.list_packages()
|
||||
|
||||
log.console(packages)
|
||||
|
||||
for (var pack of packages)
|
||||
shop.build_package(pack)
|
||||
|
||||
$_.stop()
|
||||
@@ -68,7 +68,6 @@ DEF(super, "super")
|
||||
DEF(implements, "implements")
|
||||
DEF(interface, "interface")
|
||||
DEF(let, "let")
|
||||
DEF(package, "package")
|
||||
DEF(private, "private")
|
||||
DEF(protected, "protected")
|
||||
DEF(public, "public")
|
||||
|
||||
@@ -14862,7 +14862,6 @@ enum {
|
||||
TOK_IMPLEMENTS,
|
||||
TOK_INTERFACE,
|
||||
TOK_LET,
|
||||
TOK_PACKAGE,
|
||||
TOK_PRIVATE,
|
||||
TOK_PROTECTED,
|
||||
TOK_PUBLIC,
|
||||
@@ -24789,7 +24788,6 @@ static __exception int js_parse_directives(JSParseState *s)
|
||||
case TOK_IMPORT:
|
||||
case TOK_INTERFACE:
|
||||
case TOK_LET:
|
||||
case TOK_PACKAGE:
|
||||
/* automatic insertion of ';' */
|
||||
if (s->got_lf)
|
||||
has_semi = TRUE;
|
||||
|
||||
Reference in New Issue
Block a user