Show package details on install
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:
1 parent
cc47acb3e2
commit
abd0dfca1e
6 files changed
+209
-32
No files matched your search
@@ -277,6 +277,7 @@ src/main/
|
|||||||
registry.mbt OCI registry ops: tags, resolve, cached manifests, fetch, publish, login
|
registry.mbt OCI registry ops: tags, resolve, cached manifests, fetch, publish, login
|
||||||
index.mbt channel index: build, publish, read (+ tests)
|
index.mbt channel index: build, publish, read (+ tests)
|
||||||
index_cache.mbt local copies of channel listings for search (+ tests)
|
index_cache.mbt local copies of channel listings for search (+ tests)
|
||||||
|
details.mbt package details shown by install and info (+ tests)
|
||||||
solver.mbt lazy Resolvo-style CDCL SAT solver & UNSAT explainer (+ tests)
|
solver.mbt lazy Resolvo-style CDCL SAT solver & UNSAT explainer (+ tests)
|
||||||
ops.mbt SAT-backed global install/upgrade, remove/rollback/gc/search
|
ops.mbt SAT-backed global install/upgrade, remove/rollback/gc/search
|
||||||
project.mbt orbit.toml, orbit.lock, .orbit/ environments, project CLI (+ tests)
|
project.mbt orbit.toml, orbit.lock, .orbit/ environments, project CLI (+ tests)
|
||||||
@@ -305,5 +306,5 @@ Fixes needed for current MoonBit, kept here in case you build with an older comp
|
|||||||
|
|
||||||
- There's no lock file for concurrent runs, and no install hooks, by design.
|
- There's no lock file for concurrent runs, and no install hooks, by design.
|
||||||
- `orbit gc` only preserves global current and rollback builds (run `orbit install` / `orbit sync` in a project to re-populate missing store entries from its `orbit.lock`).
|
- `orbit gc` only preserves global current and rollback builds (run `orbit install` / `orbit sync` in a project to re-populate missing store entries from its `orbit.lock`).
|
||||||
- `orbit info <name>` reads globally installed package details without contacting the registry. Use `orbit versions <name>` to check published versions.
|
- `orbit info <name>` reads installed package details (the project's, then the global ones) without contacting the registry. Use `orbit versions <name>` to check published versions.
|
||||||
- `search` needs a channel index or the registry's catalog API (Gitea has it, also without a login). Otherwise use `orbit versions <name>`.
|
- `search` needs a channel index or the registry's catalog API (Gitea has it, also without a login). Otherwise use `orbit versions <name>`.
|
||||||
@@ -0,0 +1,11 @@
|
|||||||
|
---
|
||||||
|
data:
|
||||||
|
priority: normal
|
||||||
|
status: done
|
||||||
|
type: feature
|
||||||
|
id: y4x2r
|
||||||
|
title: Show package details on install
|
||||||
|
---
|
||||||
|
Installing a package should show its paths and the commands it exposes, and `orbit info` should show the same.
|
||||||
|
|
||||||
|
Outcome: `install`, `add`, `sync` and `upgrade` print each new build's description, channel, digest, store path, linked bins, dependencies and conflicts (`src/main/details.mbt`). `orbit info` prints the same, and in a project also covers the locked packages. `orbit run` still syncs silently.
|
||||||
@@ -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)",
|
||||||
|
])
|
||||||
|
}
|
||||||
+6
-2
@@ -41,7 +41,8 @@ let usage : String =
|
|||||||
#| orbit upgrade [-g] [name...] jointly upgrade within constraints
|
#| orbit upgrade [-g] [name...] jointly upgrade within constraints
|
||||||
#| orbit rollback <name> switch to the previous global build
|
#| orbit rollback <name> switch to the previous global build
|
||||||
#| orbit list [-g] installed global packages
|
#| orbit list [-g] installed global packages
|
||||||
#| orbit info [channel::]<name> installed package details (local only)
|
#| orbit info [-g] [channel::]<name> details of an installed package: paths,
|
||||||
|
#| bins, dependencies (local only)
|
||||||
#| orbit versions <name> published versions
|
#| orbit versions <name> published versions
|
||||||
#| orbit search [--refresh] [term] list packages (cached for an hour)
|
#| orbit search [--refresh] [term] list packages (cached for an hour)
|
||||||
#| orbit gc delete unused builds from the store
|
#| orbit gc delete unused builds from the store
|
||||||
@@ -349,7 +350,10 @@ async fn dispatch(args : Array[String]) -> Unit raise OrbitError {
|
|||||||
}
|
}
|
||||||
"info" => {
|
"info" => {
|
||||||
need(pos, 1, "info [channel::]<name>")
|
need(pos, 1, "info [channel::]<name>")
|
||||||
cmd_info(load_ctx(), pos[0])
|
match resolve_project_or_none(force_global, manifest_path) {
|
||||||
|
Some(mf) => cmd_project_info(load_ctx(), mf, pos[0])
|
||||||
|
None => cmd_info(load_ctx(), pos[0])
|
||||||
|
}
|
||||||
}
|
}
|
||||||
"versions" => {
|
"versions" => {
|
||||||
need(pos, 1, "versions <name>")
|
need(pos, 1, "versions <name>")
|
||||||
|
|||||||
+10
-26
@@ -384,6 +384,7 @@ async fn activate(ctx : Ctx, st : Step) -> Unit raise OrbitError {
|
|||||||
link_bins(ctx, dir, st.manifest.bins)
|
link_bins(ctx, dir, st.manifest.bins)
|
||||||
// Persist after each package so a later failure leaves accurate state.
|
// Persist after each package so a later failure leaves accurate state.
|
||||||
save_state(ctx)
|
save_state(ctx)
|
||||||
|
print_details(installed_details(ctx, ctx.state[st.name]), " ")
|
||||||
}
|
}
|
||||||
|
|
||||||
///|
|
///|
|
||||||
@@ -765,32 +766,15 @@ fn cmd_info(ctx : Ctx, spec : String) -> Unit raise OrbitError {
|
|||||||
raise OrbitError("\{spec} is not installed (installed from '\{p.channel}')")
|
raise OrbitError("\{spec} is not installed (installed from '\{p.channel}')")
|
||||||
}
|
}
|
||||||
println("\{name} \{p.version} (installed)")
|
println("\{name} \{p.version} (installed)")
|
||||||
if p.description != "" {
|
print_details(installed_details(ctx, p), " ")
|
||||||
println(" description: \{p.description}")
|
print_details(
|
||||||
}
|
[
|
||||||
println(" channel: \{p.channel}")
|
("constraint", [p.constraint]),
|
||||||
println(" digest: \{p.digest}")
|
("needed by", [join(reverse_deps(ctx, name), " ")]),
|
||||||
println(" constraint: \{p.constraint}")
|
("rollback", [join(p.history.map(g => g.version), " ")]),
|
||||||
println(" bin: \{join(p.bins, " ")}")
|
],
|
||||||
let deps : Array[String] = []
|
" ",
|
||||||
for d, c in p.depends {
|
)
|
||||||
deps.push(d + "@" + c)
|
|
||||||
}
|
|
||||||
println(" depends: \{join(deps, " ")}")
|
|
||||||
if !p.conflicts.is_empty() {
|
|
||||||
let cs : Array[String] = []
|
|
||||||
for n, c in p.conflicts {
|
|
||||||
cs.push(n + "@" + c)
|
|
||||||
}
|
|
||||||
println(" conflicts: \{join(cs, " ")}")
|
|
||||||
}
|
|
||||||
let rd = reverse_deps(ctx, name)
|
|
||||||
println(" needed by: \{join(rd, " ")}")
|
|
||||||
let hist : Array[String] = []
|
|
||||||
for g in p.history {
|
|
||||||
hist.push(g.version)
|
|
||||||
}
|
|
||||||
println(" rollback: \{join(hist, " ")}")
|
|
||||||
}
|
}
|
||||||
|
|
||||||
///|
|
///|
|
||||||
|
|||||||
+62
-3
@@ -1065,6 +1065,7 @@ async fn sync_project_env(
|
|||||||
root : String,
|
root : String,
|
||||||
project_dir : String,
|
project_dir : String,
|
||||||
lock : Lockfile,
|
lock : Lockfile,
|
||||||
|
show? : Bool = false,
|
||||||
) -> Int32 raise OrbitError {
|
) -> Int32 raise OrbitError {
|
||||||
let bin_owners : Map[String, String] = Map([])
|
let bin_owners : Map[String, String] = Map([])
|
||||||
for lp in lock.packages {
|
for lp in lock.packages {
|
||||||
@@ -1155,6 +1156,14 @@ async fn sync_project_env(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
write_text_atomic(env_path, env_json_text(desired_pkgs))
|
write_text_atomic(env_path, env_json_text(desired_pkgs))
|
||||||
|
if show {
|
||||||
|
for lp in lock.packages {
|
||||||
|
if prev_pkgs.get(lp.name) != Some(lp.digest) {
|
||||||
|
println(" \{lp.name} \{lp.version} installed")
|
||||||
|
print_details(locked_details(store_ctx, project_dir, lp), " ")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
if changed == 0 {
|
if changed == 0 {
|
||||||
1
|
1
|
||||||
} else {
|
} else {
|
||||||
@@ -1272,7 +1281,7 @@ async fn ensure_project_synced(
|
|||||||
solved
|
solved
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
let synced = sync_project_env(ctx.root, project_dir, lock)
|
let synced = sync_project_env(ctx.root, project_dir, lock, show=!quiet)
|
||||||
if !quiet {
|
if !quiet {
|
||||||
if synced == 0 {
|
if synced == 0 {
|
||||||
println("environment is up to date")
|
println("environment is up to date")
|
||||||
@@ -1351,7 +1360,7 @@ async fn cmd_project_add(
|
|||||||
ignore(parse_project_manifest(updated_toml, m.name))
|
ignore(parse_project_manifest(updated_toml, m.name))
|
||||||
write_text_atomic(manifest_file, updated_toml)
|
write_text_atomic(manifest_file, updated_toml)
|
||||||
write_text_atomic(lock_path, lockfile_to_toml(lock))
|
write_text_atomic(lock_path, lockfile_to_toml(lock))
|
||||||
ignore(sync_project_env(ctx.root, project_dir, lock))
|
ignore(sync_project_env(ctx.root, project_dir, lock, show=true))
|
||||||
for name in added_names {
|
for name in added_names {
|
||||||
match solved_by_name.get(name) {
|
match solved_by_name.get(name) {
|
||||||
Some(lp) =>
|
Some(lp) =>
|
||||||
@@ -1426,7 +1435,7 @@ async fn cmd_project_update(
|
|||||||
upgrade_all,
|
upgrade_all,
|
||||||
)
|
)
|
||||||
write_text_atomic(lock_path, lockfile_to_toml(lock))
|
write_text_atomic(lock_path, lockfile_to_toml(lock))
|
||||||
let synced = sync_project_env(ctx.root, project_dir, lock)
|
let synced = sync_project_env(ctx.root, project_dir, lock, show=true)
|
||||||
if synced == 0 {
|
if synced == 0 {
|
||||||
println("already up to date")
|
println("already up to date")
|
||||||
} else {
|
} else {
|
||||||
@@ -1557,6 +1566,56 @@ async fn cmd_project_list(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
///|
|
||||||
|
/// Details of a package in the project's lockfile, or else of a global one.
|
||||||
|
async fn cmd_project_info(
|
||||||
|
ctx : Ctx,
|
||||||
|
manifest_file : String,
|
||||||
|
spec : String,
|
||||||
|
) -> Unit raise OrbitError {
|
||||||
|
let (project_dir, m, _) = load_project(manifest_file, ctx.channels)
|
||||||
|
let (pin, name) = split_channel(spec)
|
||||||
|
let packages = match read_existing_lock(project_dir + "/orbit.lock") {
|
||||||
|
Some(lock) => lock.packages
|
||||||
|
None => []
|
||||||
|
}
|
||||||
|
for p in packages {
|
||||||
|
if p.name != name || (pin is Some(channel) && channel != p.channel) {
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
let env = match read_text(project_env_dir(project_dir) + "/env.json") {
|
||||||
|
Some(t) => read_env_packages(t)
|
||||||
|
None => Map([])
|
||||||
|
}
|
||||||
|
let status = if env.get(name) == Some(p.digest) {
|
||||||
|
"installed in \{m.name}"
|
||||||
|
} else {
|
||||||
|
"locked in \{m.name}, not installed"
|
||||||
|
}
|
||||||
|
println("\{name} \{p.version} (\{status})")
|
||||||
|
print_details(locked_details(ctx, project_dir, p), " ")
|
||||||
|
let constraint = match m.dependencies.get(name) {
|
||||||
|
Some(d) => d.constraint
|
||||||
|
None => ""
|
||||||
|
}
|
||||||
|
let users : Array[String] = []
|
||||||
|
for other in packages {
|
||||||
|
for dep, _ in other.depends {
|
||||||
|
if parse_dep_key(dep).1 == name {
|
||||||
|
users.push(other.name)
|
||||||
|
break
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
print_details(
|
||||||
|
[("constraint", [constraint]), ("needed by", [join(users, " ")])],
|
||||||
|
" ",
|
||||||
|
)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
cmd_info(ctx, spec)
|
||||||
|
}
|
||||||
|
|
||||||
///|
|
///|
|
||||||
fn cmd_project_env(ctx : Ctx, manifest_file : String) -> Unit {
|
fn cmd_project_env(ctx : Ctx, manifest_file : String) -> Unit {
|
||||||
let project_dir = path_dirname(manifest_file)
|
let project_dir = path_dirname(manifest_file)
|
||||||
|
|||||||
Reference in new issue
Block a user