Use moonbitlang/async for process and file IO
Process execution and file access go through @process and @fs. The spinner is a background task in a task group, and the C stub keeps only getenv, exit, isatty, symlink and stderr output. orbit info reads installed state only, and it records and restores package descriptions. just install adds Orbit's bin directory to ~/.bashrc once. Co-Authored-By: Claude Haiku 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
65e5dc966f
commit
ec21287549
11 files changed
+236
-213
No files matched your search
+19
-2
@@ -23,6 +23,7 @@ struct Gen {
|
||||
channel : String
|
||||
version : String
|
||||
digest : String
|
||||
description : String
|
||||
bins : Array[String]
|
||||
depends : Map[String, String]
|
||||
}
|
||||
@@ -33,6 +34,7 @@ struct Installed {
|
||||
mut channel : String
|
||||
mut version : String
|
||||
mut digest : String
|
||||
mut description : String
|
||||
mut explicit : Bool
|
||||
mut constraint : String
|
||||
mut bins : Array[String]
|
||||
@@ -213,6 +215,7 @@ fn gen_json(g : Gen) -> Json {
|
||||
o["channel"] = Json::string(g.channel)
|
||||
o["version"] = Json::string(g.version)
|
||||
o["digest"] = Json::string(g.digest)
|
||||
o["description"] = Json::string(g.description)
|
||||
o["bin"] = strs_json(g.bins)
|
||||
o["depends"] = map_json(g.depends)
|
||||
Json::object(o)
|
||||
@@ -224,6 +227,7 @@ fn installed_json(p : Installed) -> Json {
|
||||
o["channel"] = Json::string(p.channel)
|
||||
o["version"] = Json::string(p.version)
|
||||
o["digest"] = Json::string(p.digest)
|
||||
o["description"] = Json::string(p.description)
|
||||
o["explicit"] = bool_json(p.explicit)
|
||||
o["constraint"] = Json::string(p.constraint)
|
||||
o["bin"] = strs_json(p.bins)
|
||||
@@ -267,6 +271,7 @@ fn state_from_text(text : String) -> Map[String, Installed] raise OrbitError {
|
||||
channel: jstr(h, "channel", MAIN_CHANNEL),
|
||||
version: jstr(h, "version", ""),
|
||||
digest: jstr(h, "digest", ""),
|
||||
description: jstr(h, "description", ""),
|
||||
bins: jstrs(h, "bin"),
|
||||
depends: jmap(h, "depends"),
|
||||
})
|
||||
@@ -280,6 +285,7 @@ fn state_from_text(text : String) -> Map[String, Installed] raise OrbitError {
|
||||
channel: jstr(o, "channel", MAIN_CHANNEL),
|
||||
version: jstr(o, "version", ""),
|
||||
digest: jstr(o, "digest", ""),
|
||||
description: jstr(o, "description", ""),
|
||||
explicit: jbool(o, "explicit", false),
|
||||
constraint: jstr(o, "constraint", "*"),
|
||||
bins: jstrs(o, "bin"),
|
||||
@@ -295,6 +301,17 @@ fn state_from_text(text : String) -> Map[String, Installed] raise OrbitError {
|
||||
out
|
||||
}
|
||||
|
||||
///|
|
||||
test "installed and rollback descriptions round trip with legacy entries" {
|
||||
let text =
|
||||
#|{"packages":{"tool":{"description":"Current build","history":[{"description":"Previous build"},{}]}}}
|
||||
let state = state_from_text(state_to_text(state_from_text(text)))
|
||||
guard state.get("tool") is Some(p) else { fail("missing installed package") }
|
||||
assert_eq(p.description, "Current build")
|
||||
assert_eq(p.history[0].description, "Previous build")
|
||||
assert_eq(p.history[1].description, "")
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------- context
|
||||
|
||||
///|
|
||||
@@ -309,7 +326,7 @@ fn orbit_root() -> String {
|
||||
|
||||
///|
|
||||
/// Load channels and state.
|
||||
fn load_ctx() -> Ctx raise OrbitError {
|
||||
async fn load_ctx() -> Ctx raise OrbitError {
|
||||
let root = orbit_root()
|
||||
let channels = resolve_channels(
|
||||
load_listed_channels(root),
|
||||
@@ -324,7 +341,7 @@ fn load_ctx() -> Ctx raise OrbitError {
|
||||
}
|
||||
|
||||
///|
|
||||
fn save_state(ctx : Ctx) -> Unit raise OrbitError {
|
||||
async fn save_state(ctx : Ctx) -> Unit raise OrbitError {
|
||||
write_text_atomic(ctx.root + "/state.json", state_to_text(ctx.state))
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user