Build with current MoonBit toolchain

Migrate to moon.mod/moon.pkg, update suberror and Json construction
syntax, import @json, annotate FFI params #borrow, and clear all
deprecation warnings. Builds cleanly, tests pass, and the CLI was
smoke-tested against a local registry:2.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01DPL5hhm28fFg1zAegJABvu
This commit is contained in:
Claude committed 2026-11-27 01:33:28 +00:00
1 parent efeaa326c8
commit 5a91e87d64
11 files changed
+236 -131

No files matched your search

+33 -9
View File
@@ -20,16 +20,27 @@ fn list_tags(ctx : Ctx, name : String) -> Array[String] raise OrbitError {
}
///|
fn resolve_digest(ctx : Ctx, name : String, tag : String) -> String raise OrbitError {
let d = trim(capture(oras(ctx, "resolve " + sq(repo_of(ctx, name) + ":" + tag))))
if not(has_prefix(d, "sha256:") || has_prefix(d, "sha512:")) {
fn resolve_digest(
ctx : Ctx,
name : String,
tag : String,
) -> String raise OrbitError {
let d = trim(
capture(oras(ctx, "resolve " + sq(repo_of(ctx, name) + ":" + tag))),
)
if !(has_prefix(d, "sha256:") || has_prefix(d, "sha512:")) {
raise OrbitError("unexpected digest for \{name}:\{tag}: '\{d}'")
}
d
}
///|
/// Fetch only the config blob (orbit.json); no layer download needed to plan.
fn fetch_manifest(ctx : Ctx, name : String, digest : String) -> Manifest raise OrbitError {
fn fetch_manifest(
ctx : Ctx,
name : String,
digest : String,
) -> Manifest raise OrbitError {
let text = capture(
oras(ctx, "manifest fetch-config " + sq(repo_of(ctx, name) + "@" + digest)),
)
@@ -42,10 +53,15 @@ fn fetch_manifest(ctx : Ctx, name : String, digest : String) -> Manifest raise O
m
}
///|
/// Pull a package layer by digest and unpack it into the store.
/// Unpacks into a temp dir first, then renames, so a store dir is either
/// complete or absent.
fn fetch_into_store(ctx : Ctx, name : String, digest : String) -> String raise OrbitError {
fn fetch_into_store(
ctx : Ctx,
name : String,
digest : String,
) -> String raise OrbitError {
let dir = store_dir(ctx, name, digest)
if exists(dir) {
return dir
@@ -53,10 +69,13 @@ fn fetch_into_store(ctx : Ctx, name : String, digest : String) -> String raise O
let tmp = ctx.root + "/tmp/" + name + "-" + store_id(digest)
sh_ok("rm -rf " + sq(tmp) + " && mkdir -p " + sq(tmp + "/root"))
sh_ok(
oras(ctx, "pull -o " + sq(tmp) + " " + sq(repo_of(ctx, name) + "@" + digest)) +
oras(
ctx,
"pull -o " + sq(tmp) + " " + sq(repo_of(ctx, name) + "@" + digest),
) +
" >/dev/null",
)
if not(exists(tmp + "/pkg.tar.gz")) {
if !(exists(tmp + "/pkg.tar.gz")) {
raise OrbitError("\{name}@\{digest} has no pkg.tar.gz layer")
}
sh_ok(
@@ -79,15 +98,20 @@ fn fetch_into_store(ctx : Ctx, name : String, digest : String) -> String raise O
dir
}
///|
/// Pack `<dir>/files` and push it with `<dir>/orbit.json` as the config blob.
fn publish(ctx : Ctx, dir : String, also_latest : Bool) -> Unit raise OrbitError {
fn publish(
ctx : Ctx,
dir : String,
also_latest : Bool,
) -> Unit raise OrbitError {
let text = match read_text(dir + "/orbit.json") {
Some(t) => t
None => raise OrbitError("\{dir}/orbit.json not found")
}
let m = parse_manifest(text)
let files = dir + "/files"
if not(exists(files)) {
if !(exists(files)) {
raise OrbitError("\{files} not found (package contents go in files/)")
}
for b in m.bins {