Add Pixi-style project environments and SAT dependency solver
- Add orbit.toml project manifests, deterministic orbit.lock files, [tasks], and `orbit run` - Add per-project .orbit/bin environments; `-g`/`--global` targets the global environment - Replace greedy global resolution with a lazy CDCL SAT solver that explains conflicts - Support channel::pkg dependency pins and comma-separated, comparison, and wildcard constraints - Cache immutable sha256 manifests under ~/.orbit/cache/manifests - Validate dependency keys and constraints in orbit.json
This commit is contained in:
1 parent
0919ce105c
commit
13aa7d7f77
9 files changed
+4563
-266
No files matched your search
+53
-3
@@ -179,6 +179,21 @@ fn valid_rel_path(p : String) -> Bool {
|
||||
true
|
||||
}
|
||||
|
||||
///|
|
||||
/// Split a dependency key "[channel::]name" into (channel_pin, package_name).
|
||||
fn parse_dep_key(key : String) -> (String?, String) {
|
||||
split_channel(key)
|
||||
}
|
||||
|
||||
///|
|
||||
fn valid_dep_key(key : String) -> Bool {
|
||||
let (ch, name) = parse_dep_key(key)
|
||||
match ch {
|
||||
Some(c) => valid_name(c) && valid_name(name)
|
||||
None => valid_name(name)
|
||||
}
|
||||
}
|
||||
|
||||
///|
|
||||
fn parse_manifest(text : String) -> Manifest raise OrbitError {
|
||||
let o = parse_object(text, "orbit.json")
|
||||
@@ -203,10 +218,15 @@ fn parse_manifest(text : String) -> Manifest raise OrbitError {
|
||||
raise OrbitError("orbit.json: bin path '\{b}' must be relative")
|
||||
}
|
||||
}
|
||||
for dep, _ in m.depends {
|
||||
if !valid_name(dep) {
|
||||
for dep, constraint in m.depends {
|
||||
if !valid_dep_key(dep) {
|
||||
raise OrbitError("orbit.json: invalid dependency name '\{dep}'")
|
||||
}
|
||||
if !valid_constraint(constraint) {
|
||||
raise OrbitError(
|
||||
"orbit.json: invalid version constraint '\{constraint}' for '\{dep}'",
|
||||
)
|
||||
}
|
||||
}
|
||||
m
|
||||
}
|
||||
@@ -367,15 +387,45 @@ fn bin_dir(ctx : Ctx) -> String {
|
||||
ctx.root + "/bin"
|
||||
}
|
||||
|
||||
///|
|
||||
fn cache_dir(root : String) -> String {
|
||||
root + "/cache/manifests"
|
||||
}
|
||||
|
||||
///|
|
||||
test "manifest roundtrip" {
|
||||
let m = parse_manifest(
|
||||
"{\"name\":\"hello\",\"version\":\"1.0.0\",\"bin\":[\"bin/hello\"],\"depends\":{\"lib\":\"^1\"}}",
|
||||
"{\"name\":\"hello\",\"version\":\"1.0.0\",\"bin\":[\"bin/hello\"],\"depends\":{\"lib\":\"^1\",\"example::greet\":\">=1.0.0, <2.0.0\"}}",
|
||||
)
|
||||
assert_eq(m.name, "hello")
|
||||
assert_eq(m.bins, ["bin/hello"])
|
||||
assert_eq(m.depends.get("lib"), Some("^1"))
|
||||
assert_eq(m.depends.get("example::greet"), Some(">=1.0.0, <2.0.0"))
|
||||
assert_eq(parse_dep_key("example::greet"), (Some("example"), "greet"))
|
||||
assert_eq(parse_dep_key("lib"), (None, "lib"))
|
||||
assert_true(!valid_rel_path("../x"))
|
||||
assert_true(!valid_rel_path("/bin/sh"))
|
||||
assert_eq(store_id("sha256:0123456789abcdef0123"), "0123456789abcdef")
|
||||
|
||||
let bad_dep = try {
|
||||
parse_manifest(
|
||||
"{\"name\":\"hello\",\"version\":\"1.0.0\",\"depends\":{\"BadName\":\"^1\"}}",
|
||||
)
|
||||
|> ignore
|
||||
false
|
||||
} catch {
|
||||
OrbitError(_) => true
|
||||
}
|
||||
assert_true(bad_dep)
|
||||
|
||||
let bad_con = try {
|
||||
parse_manifest(
|
||||
"{\"name\":\"hello\",\"version\":\"1.0.0\",\"depends\":{\"lib\":\">=abc\"}}",
|
||||
)
|
||||
|> ignore
|
||||
false
|
||||
} catch {
|
||||
OrbitError(_) => true
|
||||
}
|
||||
assert_true(bad_con)
|
||||
}
|
||||
Reference in new issue
Block a user