Show package details on install
Rolling Release / build (push) Successful in 1m39s
Rolling Release / publish (push) Successful in 8s

Installs, syncs and upgrades print each new build's paths, bins and
dependencies. orbit info prints the same, also for a project's packages.

Planning: y4x2r

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
nandiandClaude Opus 5.5 committed 2026-12-01 05:30:41 -08:00
1 parent cc47acb3e2
commit abd0dfca1e
6 files changed
+209 -32

No files matched your search

+118
View File
@@ -0,0 +1,118 @@
// What install and info print about a package.
///|
/// Label and values. Each value after the first gets its own line.
type Detail = (String, Array[String])
///|
/// Align details in columns, dropping empty ones. Values may come from a
/// registry, so control characters are blanked.
fn detail_lines(details : Array[Detail], indent : String) -> Array[String] {
let lines : Array[String] = []
for detail in details {
let (label, values) = detail
let mut head = label + ":"
for v in values {
if v != "" {
lines.push(indent + pad_right(head, 13) + printable(v))
head = ""
}
}
}
lines
}
///|
fn print_details(details : Array[Detail], indent : String) -> Unit {
for line in detail_lines(details, indent) {
println(line)
}
}
///|
/// The details of a build that install and info share. `bin_dir` is where its
/// commands are linked, `store` where its files are.
fn package_details(
m : Manifest,
channel~ : String,
digest~ : String,
store~ : String,
bin_dir~ : String,
) -> Array[Detail] {
let bins = m.bins.map(b => bin_dir + "/" + basename(b) + " -> " + b)
if bins.is_empty() {
bins.push("(none)")
}
let specs = fn(reqs : Map[String, String]) {
let out : Array[String] = []
for n, c in reqs {
out.push(n + "@" + c)
}
join(out, " ")
}
[
("description", [m.description]),
("channel", [channel]),
("digest", [digest]),
("path", [store]),
("bin", bins),
("depends", [specs(m.depends)]),
("conflicts", [specs(m.conflicts)]),
]
}
///|
fn installed_details(ctx : Ctx, p : Installed) -> Array[Detail] {
package_details(
manifest_of_installed(p),
channel=p.channel,
digest=p.digest,
store=store_dir(ctx, p.name, p.digest),
bin_dir=bin_dir(ctx),
)
}
///|
fn locked_details(
ctx : Ctx,
project_dir : String,
p : LockedPkg,
) -> Array[Detail] {
package_details(
manifest_of_locked(p),
channel=p.channel,
digest=p.digest,
store=store_dir(ctx, p.name, p.digest),
bin_dir=project_env_dir(project_dir) + "/bin",
)
}
///|
test "package details show paths and every bin" {
let m = parse_manifest(
"{\"name\":\"t\",\"version\":\"1.0.0\",\"description\":\"A\\u001btool\",\"bin\":[\"bin/a\",\"libexec/b\"],\"depends\":{\"x\":\"^1\"},\"conflicts\":{\"y\":\"*\"}}",
)
let details = package_details(
m,
channel="main",
digest="sha256:ab",
store="/o/store/t/ab",
bin_dir="/o/bin",
)
assert_eq(detail_lines(details, " "), [
" description: A tool", " channel: main", " digest: sha256:ab", " path: /o/store/t/ab",
" bin: /o/bin/a -> bin/a", " /o/bin/b -> libexec/b", " depends: x@^1",
" conflicts: y@*",
])
let bare = package_details(
parse_manifest("{\"name\":\"t\",\"version\":\"1.0.0\"}"),
channel="main",
digest="sha256:ab",
store="/o/store/t/ab",
bin_dir="/o/bin",
)
assert_eq(detail_lines(bare, ""), [
"channel: main", "digest: sha256:ab", "path: /o/store/t/ab",
"bin: (none)",
])
}