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