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

+8 -9
View File
@@ -2,7 +2,7 @@
A small package manager written in MoonBit that uses any OCI registry (Gitea, GHCR, Harbor, `registry:2`, ...) as its repository, with [ORAS](https://github.com/oras-project/oras) as the transport.
> **Status: not compiled yet.** This was written without access to a MoonBit toolchain. Expect a few compile fixes on first build. The likeliest spots are listed under *First build* below.
> **Status:** builds cleanly (no warnings) with MoonBit `moonc v1.0.0-rc1` / `moon 0.1.20261126`, and the unit tests pass. publish, install (with dependencies), upgrade, rollback, remove and gc have been exercised end to end against a local `registry:2` with ORAS 1.2.3.
## What it does
@@ -71,7 +71,7 @@ orbit init localhost:5000/pkgs --plain-http
```sh
moon build --target native --release
moon test --target native # semver / manifest unit tests
# the binary is under target/native/release/build/main/
# the binary is _build/native/release/build/main/main.exe
```
Linux only for now: arguments come from `/proc/self/cmdline`. It needs `oras`, `tar` and `/bin/sh` on `PATH`.
@@ -89,15 +89,14 @@ src/main/
main.mbt CLI
```
## First build: likely fix-ups
## Toolchain notes
The code avoids most of the standard library (string helpers are built on `for c in s` only), but a few calls depend on the compiler version:
Fixes needed for current MoonBit, kept here in case you build with an older compiler:
- `suberror OrbitError String` and `raise` in signatures. Older compilers use `type! OrbitError String` and `!` call syntax.
- `Bytes::makei`, `Int::unsafe_to_char`, `StringBuilder::write_char`.
- `@json.parse(String)`, which may want a `StringView`, and `Json::Object` / `Json::String` patterns.
- `Json::stringify(indent=2)`.
- C FFI argument ownership. The stub never decrefs, so the worst case is a small leak.
- The project uses `moon.mod` / `moon.pkg` (the `.json` forms are no longer accepted).
- `suberror OrbitError { OrbitError(String) }`, and `@json` is imported explicitly in `moon.pkg`.
- `Json` values are built with `Json::string`, `Json::array`, `Json::object`, `Json::boolean`; the uppercase constructors are only used in patterns.
- C FFI parameters are annotated `#borrow(...)`, matching `stub.c`, which never decrefs its arguments.
## Known limits