Add Orbit package channels #2

Merged
nandi merged 4 commits from package-orbit into main 2026-11-27 02:57:50 +00:00
Showing only changes of commit 32714325a7 - Show all commits
+17 -8
View File
@@ -5,7 +5,7 @@ let usage : String =
#|orbit - packages as OCI artifacts (via oras) #|orbit - packages as OCI artifacts (via oras)
#| #|
#|usage: #|usage:
#| orbit init <registry> [--plain-http] save a different default registry #| orbit init [registry] [--plain-http] set up; optionally save a registry
#| orbit publish <dir> [--no-latest] push <dir>/orbit.json + <dir>/files/ #| orbit publish <dir> [--no-latest] push <dir>/orbit.json + <dir>/files/
#| orbit install <name>[@constraint]... install with dependencies #| orbit install <name>[@constraint]... install with dependencies
#| orbit remove <name>... [--force] remove, then drop unused dependencies #| orbit remove <name>... [--force] remove, then drop unused dependencies
@@ -24,7 +24,12 @@ let usage : String =
#|authentication: run `oras login <registry-host>` once. #|authentication: run `oras login <registry-host>` once.
///| ///|
/// With no registry, only create the directories: any saved config is left
/// alone and the built-in default is not written to disk.
fn cmd_init(registry : String, plain_http : Bool) -> Unit raise OrbitError { fn cmd_init(registry : String, plain_http : Bool) -> Unit raise OrbitError {
if registry == "" && plain_http {
raise OrbitError("usage: orbit init <registry> --plain-http")
}
let root = orbit_root() let root = orbit_root()
sh_ok( sh_ok(
"mkdir -p " + "mkdir -p " +
@@ -34,12 +39,14 @@ fn cmd_init(registry : String, plain_http : Bool) -> Unit raise OrbitError {
" " + " " +
sq(root + "/tmp"), sq(root + "/tmp"),
) )
write_text_atomic( if registry != "" {
root + "/config.json", write_text_atomic(
config_to_text(Config::{ registry, plain_http, }), root + "/config.json",
) config_to_text(Config::{ registry, plain_http, }),
)
}
println("orbit root: \{root}") println("orbit root: \{root}")
println("registry: \{registry}") println("registry: \{load_ctx().cfg.registry}")
println("add to your shell profile:") println("add to your shell profile:")
println(" export PATH=\"\{root}/bin:$PATH\"") println(" export PATH=\"\{root}/bin:$PATH\"")
} }
@@ -70,8 +77,10 @@ fn dispatch(args : Array[String]) -> Unit raise OrbitError {
match cmd { match cmd {
"help" | "-h" | "--help" => println(usage) "help" | "-h" | "--help" => println(usage)
"init" => { "init" => {
need(pos, 1, "init <registry> [--plain-http]") cmd_init(
cmd_init(pos[0], flags.contains("--plain-http")) if pos.length() > 0 { pos[0] } else { "" },
flags.contains("--plain-http"),
)
} }
"env" => println("export PATH=\"\{orbit_root()}/bin:$PATH\"") "env" => println("export PATH=\"\{orbit_root()}/bin:$PATH\"")
"publish" => { "publish" => {