remove some scripts

This commit is contained in:
2025-12-03 15:34:01 -06:00
parent 1769d7f456
commit ac718fdb13
5 changed files with 0 additions and 274 deletions

View File

@@ -1,63 +0,0 @@
var fd = use('fd')
var js = use('js')
var time = use('time')
var qop = use('qop')
var build_root = '.cell/build'
log.console("Building scripts...")
var now = time.number()
var compiled_count = 0
var error_count = 0
function compile_file(src_path, dest_path, is_core) {
try {
var src_content
if (is_core) {
return
} else {
src_content = fd.slurp(src_path)
}
fd.mkdir(dest_path.substring(0, dest_path.lastIndexOf('/')))
var mod_name = src_path
.replace(/\.(cm|ce)$/, '')
.replace(/[\/\-.]/g, '_')
var wrapped = '(function ' + mod_name + '(arg){' + src_content + '})'
var compiled = js.compile(src_path, wrapped)
var blob = js.compile_blob(compiled)
fd.slurpwrite(dest_path, blob)
compiled_count++
// log.console("Compiled " + src_path + " -> " + dest_path)
} catch(e) {
log.console(`Failed to compile ${src_path}: ${e.message}`);
error_count++
}
}
// 1. Local files
var local_files = fd.globfs(['**/*.cm', '**/*.ce', '!**/*.git', '!**/*.cell', '!**/subprojects'], '')
for (var file of local_files) {
var dest = build_root + '/local/' + file + '.o'
compile_file(file, dest, false)
}
// 2. Modules
var module_files = fd.globfs(['**/*.cm', '**/*.ce'], '.cell/modules')
for (var file of module_files) {
// file is relative to .cell/modules, e.g. "prosperon/draw2d.cm"
var dest = build_root + '/modules/' + file + '.o'
var src = '.cell/modules/' + file
compile_file(src, dest, false)
}
log.console("Build complete: " + compiled_count + " files compiled in " + (time.number()-now) + " seconds")
if (error_count > 0) {
log.console(" " + error_count + " errors")
}
$_.stop()

View File

@@ -1,22 +0,0 @@
// cell fetch - Install dependencies
var shop = use('shop')
log.console("Fetching dependencies...")
if (!shop.init()) {
log.error("Failed to initialize .cell directory")
$_.stop()
return
}
var deps = shop.get_dependencies()
var count = 0
for (var alias in deps) {
if (shop.install(alias)) {
count++
}
}
log.console(`Fetched ${count} dependencies.`)
$_.stop()

View File

@@ -1,177 +0,0 @@
var shop = use('shop')
var http = use('http')
var miniz = use('miniz')
var fd = use('fd')
var crypto = use('crypto')
var text = use('text')
var toml = use('toml')
var time = use('time')
function slurpwrite(path, data) {
var f = fd.open(path, "w")
f.write(data)
f.close()
}
var uses = {}
uses.download = function()
{
var mods = shop.load_config().dependencies
var cache_dir = '.cell/cache'
var modules_dir = '.cell/modules'
var lock_path = '.cell/lock.toml'
// Ensure directories exist
if (!fd.stat(cache_dir).isDirectory)
fd.mkdir(cache_dir)
if (!fd.stat(modules_dir).isDirectory)
fd.mkdir(modules_dir)
// Load or create lock file
var lock = {}
if (fd.stat(lock_path).isFile) {
var lock_content = fd.slurp(lock_path)
lock = toml.decode(lock_content)
}
if (!lock.modules) lock.modules = {}
for (var mod in mods) {
var cache_path = cache_dir + '/' + mod + '.zip'
var module_path = modules_dir + '/' + mod
var zip
var need_download = false
var remote_commit = null
// Check remote commit if this is a git repository
var api_url = shop.get_api_url(mods[mod])
if (api_url) {
log.console(`${mod}: checking remote commit...`)
try {
var api_response = http.fetch(api_url)
remote_commit = shop.extract_commit_hash(mods[mod], text(api_response))
if (remote_commit) {
log.console(`${mod}: remote commit = ${remote_commit}`)
}
} catch (e) {
log.console(`${mod}: failed to check remote commit`)
}
}
// Check if module exists in lock file
if (!lock.modules[mod] || !lock.modules[mod].hash) {
log.console(`${mod}: not in lock file, will download`)
need_download = true
} else if (!fd.stat(cache_path).isDirectory) {
log.console(`${mod}: cache missing, will download`)
need_download = true
} else if (remote_commit && (!lock.modules[mod].commit || lock.modules[mod].commit != remote_commit)) {
log.console(`${mod}: remote has new commit`)
log.console(` local: ${lock.modules[mod].commit || 'unknown'}`)
log.console(` remote: ${remote_commit}`)
need_download = true
}
if (!need_download) {
// Verify cached file hash
log.console(`${mod}: verifying cached version`)
zip = fd.slurp(cache_path)
var hash = crypto.hash(zip)
var hash_b32 = text(hash, "t")
if (hash_b32 != lock.modules[mod].hash) {
log.console(`${mod}: hash mismatch, will redownload`)
log.console(` expected: ${lock.modules[mod].hash}`)
log.console(` actual: ${hash_b32}`)
need_download = true
} else {
log.console(`${mod}: hash verified`)
}
}
if (need_download) {
// Download the module
log.console(`downloading ${mod} at ${mods[mod]}`)
log.console(shop.get_download_url(mods[mod]))
zip = http.fetch(shop.get_download_url(mods[mod]))
slurpwrite(cache_path, zip)
log.console(`${mod}: downloaded ${zip.length} bytes`)
// Calculate and store hash
var hash = crypto.hash(zip)
var hash_b32 = text(hash, "t")
lock.modules[mod] = {
hash: hash_b32,
url: mods[mod],
downloaded: time.text()
}
// Store commit hash if available
if (remote_commit) {
lock.modules[mod].commit = remote_commit
}
log.console(`${mod}: hash = ${hash_b32}`)
// Save updated lock file
slurpwrite(lock_path, toml.encode(lock))
}
// Extract the module
var reader = miniz.read(zip)
var count = reader.count()
log.console(`extracting ${mod} (${count} files)...`)
// Remove existing module directory if it exists (for clean updates)
if (fd.stat(module_path).isDirectory) {
log.console(`${mod}: removing old version...`)
fd.rmdir(module_path)
}
// Create module directory
fd.mkdir(module_path)
// Extract each file
for (var i = 0; i < count; i++) {
if (reader.is_directory(i))
continue
var filename = reader.get_filename(i)
// Strip the module name prefix if present
var prefix = mod + '/'
if (filename.indexOf(prefix) == 0)
filename = filename.substring(prefix.length)
// Skip if filename is empty after stripping
if (!filename)
continue
var filepath = module_path + '/' + filename
// Create subdirectories if needed
var parts = filename.split('/')
if (parts.length > 1) {
var dir = module_path
for (var j = 0; j < parts.length - 1; j++) {
dir = dir + '/' + parts[j]
if (!fd.stat(dir).isDirectory)
fd.mkdir(dir)
}
}
// Extract and write file
var data = reader.slurp(reader.get_filename(i))
slurpwrite(filepath, data)
}
log.console(`${mod}: extracted to ${module_path}`)
}
}
if (uses[arg[0]])
uses[arg[0]]()
else
log.console(`Command ${arg[0]} not understood.`)

View File

@@ -1,12 +0,0 @@
// cell verify - Verify dependencies
var shop = use('shop')
log.console("Verifying dependencies...")
if (shop.verify()) {
log.console("All dependencies are present.")
} else {
log.error("Some dependencies are missing.")
}
$_.stop()