Skip to content

feat(packaging): promote shipper-cli to real library adapter (#95 PR 2)#141

Merged
EffortlessSteven merged 1 commit into
mainfrom
feat/95-pr2-shipper-cli-adapter
Apr 18, 2026
Merged

feat(packaging): promote shipper-cli to real library adapter (#95 PR 2)#141
EffortlessSteven merged 1 commit into
mainfrom
feat/95-pr2-shipper-cli-adapter

Conversation

@EffortlessSteven

Copy link
Copy Markdown
Member

Summary

Second step of the #95 three-crate split. shipper-cli was a 9-line compat shim after PR 1 (#140); this PR makes it the real CLI adapter.

Architecture after this PR

shipper (install façade, library re-export)
  -> shipper-cli (CLI: clap, subcommands, output, exposes pub fn run())
       -> shipper-core (engine — no CLI deps)

The old dependency arrow shipper-cli -> shipper is inverted: shipper-cli no longer depends on shipper. The shipper package depends on shipper-cli (binary) + shipper-core (re-exports).

What moved

  • crates/shipper/src/cli/mod.rscrates/shipper-cli/src/lib.rs
  • crates/shipper/src/cli/output/crates/shipper-cli/src/output/
  • 22 insta snapshots renamed to match new shipper_cli::output::... module path
  • Duplicate stale snapshot copies removed

Import rewrites

Inside the moved CLI: all crate::<core-module>::X now point at shipper_core::<module>::X. In crates/shipper-cli/tests/, the four bdd_* files that reached directly into shipper::X now reach into shipper_core::X.

Cargo.toml

shipper-cli: drops shipper.workspace = true; adds shipper-core.workspace = true + clap + clap_complete + indicatif + serde/serde_json/toml/chrono.

shipper: runtime deps shrink from 20+ to three: shipper-core, shipper-cli, anyhow. All engine deps and all CLI-only deps drop out (transitive via the downstream crates). Dev-deps shrink to what crates/shipper/tests/ actually reaches for directly.

Binaries

  • crates/shipper/src/bin/shipper.rsshipper_cli::run()
  • crates/shipper-cli/src/main.rsshipper_cli::run()

Both install paths (cargo install shipper, cargo install shipper-cli) produce working CLIs that run the same code.

Library surface

crates/shipper/src/lib.rs drops pub mod cli;. The engine re-exports (shipper::engine, shipper::plan, etc.) stay so integration tests in crates/shipper/tests/ keep working. PR 3 will tighten this to a curated list.

Verification

  • cargo check --workspace --all-targets — clean
  • cargo clippy --workspace --all-targets --all-features -- -D warnings — clean
  • cargo test --workspace --doc — clean
  • cargo test -p shipper-cli --lib — 106 passed
  • Full cargo test --workspace — passed except pre-existing Windows-only preflight_command_* temp-dir flakes

Test plan

  • cargo check --workspace --all-targets
  • cargo clippy --workspace --all-targets --all-features -- -D warnings
  • cargo test -p shipper-cli --lib
  • cargo test --workspace --doc
  • CI green on all matrices
  • shipper binary still functional after install

Part of #95. PR 3 (shrink shipper README + finalize façade) and PR 4 (docs/examples/imports sweep) to follow.

Second step of the #95 three-crate split. `shipper-cli` was a 9-line
compat shim after PR 1; this PR makes it the real CLI adapter.

## Architecture after this PR

    shipper (install façade, library re-export)
      -> shipper-cli (CLI: clap, subcommands, output, exposes pub fn run())
           -> shipper-core (engine — no CLI deps)

The old arrow `shipper-cli -> shipper` is inverted: `shipper-cli` no
longer depends on `shipper`. The `shipper` package now depends on
`shipper-cli` (for the binary) and `shipper-core` (for the re-export
surface).

## What moved

- `crates/shipper/src/cli/mod.rs` -> `crates/shipper-cli/src/lib.rs`
- `crates/shipper/src/cli/output/` -> `crates/shipper-cli/src/output/`
- 22 insta snapshots renamed `shipper__cli__output__*.snap` ->
  `shipper_cli__output__*.snap` (new module_path: `shipper_cli::output::...`)
- Duplicate `shipper__output__*.snap` files (without the `cli::`
  segment) removed — they were stale copies from a previous rename.

## Import rewrites

Inside the moved CLI:

- `crate::engine::X`        -> `shipper_core::engine::X`
- `crate::plan`             -> `shipper_core::plan`
- `crate::types::X`         -> `shipper_core::types::X`
- `crate::config::X`        -> `shipper_core::config::X`
- `crate::cargo`            -> `shipper_core::cargo`
- `crate::state::X`         -> `shipper_core::state::X`
- `crate::lock::X`          -> `shipper_core::lock::X`
- `crate::webhook::X`       -> `shipper_core::webhook::X`
- `crate::encryption::X`    -> `shipper_core::encryption::X`
- `crate::auth::X`          -> `shipper_core::auth::X`
- `crate::registry::X`      -> `shipper_core::registry::X`
- `crate::retry::X`         -> `shipper_core::retry::X`
- `crate::git::X`            -> `shipper_core::git::X`
- `crate::cli::output::X`    -> `crate::output::X` (cli flattened)

And in `crates/shipper-cli/tests/` (bdd_publish, bdd_parallel,
bdd_error_recovery, bdd_error_handling):

- `shipper::cargo_failure::X` -> `shipper_core::cargo_failure::X`
- `shipper::types::X`         -> `shipper_core::types::X`
- `shipper::plan::X`          -> `shipper_core::plan::X`
- `shipper::state::X`         -> `shipper_core::state::X`
- `shipper::store::X`         -> `shipper_core::store::X`

## Cargo.toml changes

- **`crates/shipper-cli/Cargo.toml`**: drops `shipper.workspace = true`,
  adds `shipper-core.workspace = true` + `clap` + `clap_complete` +
  `indicatif` + `serde`/`serde_json`/`toml`/`chrono` (CLI-local deps).
- **`crates/shipper/Cargo.toml`**: shrinks massively. Runtime deps go
  from 20+ to just `shipper-core` + `shipper-cli` + `anyhow`. All engine
  and CLI-only dependencies drop out (they're now transitive). The
  dev-dep set shrinks to what the integration tests in
  `crates/shipper/tests/` actually reach for directly.

## Binaries

- `crates/shipper/src/bin/shipper.rs` — now forwards to
  `shipper_cli::run()` (was `shipper::cli::run()`).
- `crates/shipper-cli/src/main.rs` — now forwards to
  `shipper_cli::run()` (same-crate call; was `shipper::cli::run()`).

Both binaries end up calling the same `pub fn run()` in
`shipper-cli/src/lib.rs`. `cargo install shipper` and
`cargo install shipper-cli` both produce working CLIs.

## Library surface

`crates/shipper/src/lib.rs` drops `pub mod cli;` — the CLI is no
longer part of the `shipper` library's public surface. Programmatic
callers who wanted the CLI entrypoint should depend on `shipper-cli`
directly and call `shipper_cli::run()`.

The engine re-exports (`shipper::engine`, `shipper::plan`, etc.) stay
in place, so integration tests in `crates/shipper/tests/` that use
`shipper::X` paths keep working. PR 3 tightens this to a curated
re-export list.

## Verification

- `cargo check --workspace --all-targets` — clean
- `cargo clippy --workspace --all-targets --all-features -- -D warnings` — clean
- `cargo test --workspace --doc` — all doc tests pass
- `cargo test -p shipper-cli --lib` — 106 passed
- Full `cargo test --workspace` — passed except pre-existing Windows-only
  `preflight_command_*` temp-dir flakes (unrelated).
@coderabbitai

coderabbitai Bot commented Apr 18, 2026

Copy link
Copy Markdown

Warning

Rate limit exceeded

@EffortlessSteven has exceeded the limit for the number of commits that can be reviewed per hour. Please wait 8 minutes and 14 seconds before requesting another review.

Your organization is not enrolled in usage-based pricing. Contact your admin to enable usage-based pricing to continue reviews beyond the rate limit, or try again in 8 minutes and 14 seconds.

⌛ How to resolve this issue?

After the wait time has elapsed, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

We recommend that you space out your commits to avoid hitting the rate limit.

🚦 How do rate limits work?

CodeRabbit enforces hourly rate limits for each developer per organization.

Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout.

Please see our FAQ for further information.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: ASSERTIVE

Plan: Pro

Run ID: 09a298c4-273e-42b2-9034-bd522a2dd755

📥 Commits

Reviewing files that changed from the base of the PR and between 64d9edf and 9bb5dad.

⛔ Files ignored due to path filters (45)
  • Cargo.lock is excluded by !**/*.lock
  • crates/shipper-cli/src/output/progress/snapshots/shipper_cli__output__progress__snapshot_tests__display_empty_name_and_version.snap is excluded by !**/*.snap
  • crates/shipper-cli/src/output/progress/snapshots/shipper_cli__output__progress__snapshot_tests__display_multi_package_sequence.snap is excluded by !**/*.snap
  • crates/shipper-cli/src/output/progress/snapshots/shipper_cli__output__progress__snapshot_tests__display_prerelease_version.snap is excluded by !**/*.snap
  • crates/shipper-cli/src/output/progress/snapshots/shipper_cli__output__progress__snapshot_tests__display_single_package.snap is excluded by !**/*.snap
  • crates/shipper-cli/src/output/progress/snapshots/shipper_cli__output__progress__snapshot_tests__percentage_large_workspace.snap is excluded by !**/*.snap
  • crates/shipper-cli/src/output/progress/snapshots/shipper_cli__output__progress__snapshot_tests__percentage_milestones.snap is excluded by !**/*.snap
  • crates/shipper-cli/src/output/progress/snapshots/shipper_cli__output__progress__snapshot_tests__percentage_single_package.snap is excluded by !**/*.snap
  • crates/shipper-cli/src/output/progress/snapshots/shipper_cli__output__progress__snapshot_tests__percentage_three_packages.snap is excluded by !**/*.snap
  • crates/shipper-cli/src/output/progress/snapshots/shipper_cli__output__progress__snapshot_tests__percentage_zero_total.snap is excluded by !**/*.snap
  • crates/shipper-cli/src/output/progress/snapshots/shipper_cli__output__progress__snapshot_tests__state_after_first_package.snap is excluded by !**/*.snap
  • crates/shipper-cli/src/output/progress/snapshots/shipper_cli__output__progress__snapshot_tests__state_fresh_reporter.snap is excluded by !**/*.snap
  • crates/shipper-cli/src/output/progress/snapshots/shipper_cli__output__progress__snapshot_tests__state_full_lifecycle.snap is excluded by !**/*.snap
  • crates/shipper-cli/src/output/progress/snapshots/shipper_cli__output__progress__snapshot_tests__state_overwrite_same_index.snap is excluded by !**/*.snap
  • crates/shipper-cli/src/output/progress/snapshots/shipper_cli__output__progress__snapshot_tests__state_zero_packages.snap is excluded by !**/*.snap
  • crates/shipper-cli/src/output/progress/snapshots/shipper_cli__output__progress__tests__snapshot_display_format_edge_cases.snap is excluded by !**/*.snap
  • crates/shipper-cli/src/output/progress/snapshots/shipper_cli__output__progress__tests__snapshot_failed_midway_state.snap is excluded by !**/*.snap
  • crates/shipper-cli/src/output/progress/snapshots/shipper_cli__output__progress__tests__snapshot_progress_at_0_percent.snap is excluded by !**/*.snap
  • crates/shipper-cli/src/output/progress/snapshots/shipper_cli__output__progress__tests__snapshot_progress_at_100_percent.snap is excluded by !**/*.snap
  • crates/shipper-cli/src/output/progress/snapshots/shipper_cli__output__progress__tests__snapshot_progress_at_25_percent.snap is excluded by !**/*.snap
  • crates/shipper-cli/src/output/progress/snapshots/shipper_cli__output__progress__tests__snapshot_progress_at_50_percent.snap is excluded by !**/*.snap
  • crates/shipper-cli/src/output/progress/snapshots/shipper_cli__output__progress__tests__snapshot_progress_at_75_percent.snap is excluded by !**/*.snap
  • crates/shipper-cli/src/output/progress/snapshots/shipper_cli__output__progress__tests__snapshot_single_package_lifecycle.snap is excluded by !**/*.snap
  • crates/shipper/src/cli/output/progress/snapshots/shipper__output__progress__snapshot_tests__display_empty_name_and_version.snap is excluded by !**/*.snap
  • crates/shipper/src/cli/output/progress/snapshots/shipper__output__progress__snapshot_tests__display_multi_package_sequence.snap is excluded by !**/*.snap
  • crates/shipper/src/cli/output/progress/snapshots/shipper__output__progress__snapshot_tests__display_prerelease_version.snap is excluded by !**/*.snap
  • crates/shipper/src/cli/output/progress/snapshots/shipper__output__progress__snapshot_tests__display_single_package.snap is excluded by !**/*.snap
  • crates/shipper/src/cli/output/progress/snapshots/shipper__output__progress__snapshot_tests__percentage_large_workspace.snap is excluded by !**/*.snap
  • crates/shipper/src/cli/output/progress/snapshots/shipper__output__progress__snapshot_tests__percentage_milestones.snap is excluded by !**/*.snap
  • crates/shipper/src/cli/output/progress/snapshots/shipper__output__progress__snapshot_tests__percentage_single_package.snap is excluded by !**/*.snap
  • crates/shipper/src/cli/output/progress/snapshots/shipper__output__progress__snapshot_tests__percentage_three_packages.snap is excluded by !**/*.snap
  • crates/shipper/src/cli/output/progress/snapshots/shipper__output__progress__snapshot_tests__percentage_zero_total.snap is excluded by !**/*.snap
  • crates/shipper/src/cli/output/progress/snapshots/shipper__output__progress__snapshot_tests__state_after_first_package.snap is excluded by !**/*.snap
  • crates/shipper/src/cli/output/progress/snapshots/shipper__output__progress__snapshot_tests__state_fresh_reporter.snap is excluded by !**/*.snap
  • crates/shipper/src/cli/output/progress/snapshots/shipper__output__progress__snapshot_tests__state_full_lifecycle.snap is excluded by !**/*.snap
  • crates/shipper/src/cli/output/progress/snapshots/shipper__output__progress__snapshot_tests__state_overwrite_same_index.snap is excluded by !**/*.snap
  • crates/shipper/src/cli/output/progress/snapshots/shipper__output__progress__snapshot_tests__state_zero_packages.snap is excluded by !**/*.snap
  • crates/shipper/src/cli/output/progress/snapshots/shipper__output__progress__tests__snapshot_display_format_edge_cases.snap is excluded by !**/*.snap
  • crates/shipper/src/cli/output/progress/snapshots/shipper__output__progress__tests__snapshot_failed_midway_state.snap is excluded by !**/*.snap
  • crates/shipper/src/cli/output/progress/snapshots/shipper__output__progress__tests__snapshot_progress_at_0_percent.snap is excluded by !**/*.snap
  • crates/shipper/src/cli/output/progress/snapshots/shipper__output__progress__tests__snapshot_progress_at_100_percent.snap is excluded by !**/*.snap
  • crates/shipper/src/cli/output/progress/snapshots/shipper__output__progress__tests__snapshot_progress_at_25_percent.snap is excluded by !**/*.snap
  • crates/shipper/src/cli/output/progress/snapshots/shipper__output__progress__tests__snapshot_progress_at_50_percent.snap is excluded by !**/*.snap
  • crates/shipper/src/cli/output/progress/snapshots/shipper__output__progress__tests__snapshot_progress_at_75_percent.snap is excluded by !**/*.snap
  • crates/shipper/src/cli/output/progress/snapshots/shipper__output__progress__tests__snapshot_single_package_lifecycle.snap is excluded by !**/*.snap
📒 Files selected for processing (18)
  • crates/shipper-cli/Cargo.toml
  • crates/shipper-cli/src/lib.rs
  • crates/shipper-cli/src/main.rs
  • crates/shipper-cli/src/output/CLAUDE.md
  • crates/shipper-cli/src/output/mod.rs
  • crates/shipper-cli/src/output/progress/CLAUDE.md
  • crates/shipper-cli/src/output/progress/bdd_tests.rs
  • crates/shipper-cli/src/output/progress/mod.rs
  • crates/shipper-cli/src/output/progress/proptests.rs
  • crates/shipper-cli/src/output/progress/snapshot_tests.rs
  • crates/shipper-cli/src/output/progress/tests.rs
  • crates/shipper-cli/tests/bdd_error_handling.rs
  • crates/shipper-cli/tests/bdd_error_recovery.rs
  • crates/shipper-cli/tests/bdd_parallel.rs
  • crates/shipper-cli/tests/bdd_publish.rs
  • crates/shipper/Cargo.toml
  • crates/shipper/src/bin/shipper.rs
  • crates/shipper/src/lib.rs
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch feat/95-pr2-shipper-cli-adapter

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request implements a major architectural refactor by splitting the project into three crates: a facade (shipper), a CLI adapter (shipper-cli), and a core engine (shipper-core). While the restructuring is comprehensive, several critical issues were identified. A high-severity bug exists in the receipt inspection logic where references to temporary strings are returned, which will cause a compilation error. Additionally, there are significant inconsistencies across the Yank, PlanYank, and FixForward commands regarding the resolution of the state directory relative to the workspace root, as well as issues with registry defaulting and workspace root usage in the Yank command implementation.

Comment on lines +1689 to 1700
shipper_core::types::PackageState::Published => "\x1b[32mPublished\x1b[0m",
shipper_core::types::PackageState::Pending => "Pending",
shipper_core::types::PackageState::Uploaded => "\x1b[33mUploaded\x1b[0m",
shipper_core::types::PackageState::Skipped { reason } => {
&format!("Skipped: {}", reason)
}
shipper_core::types::PackageState::Failed { class, message } => {
&format!("\x1b[31mFailed ({:?}): {}\x1b[0m", class, message)
}
crate::types::PackageState::Ambiguous { message } => {
shipper_core::types::PackageState::Ambiguous { message } => {
&format!("\x1b[33mAmbiguous: {}\x1b[0m", message)
}

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

high

This code contains a critical bug: it attempts to return references to temporary String objects created by format!. These temporaries are dropped at the end of the match expression, leaving state_str as a dangling pointer when it is used in the subsequent println! call. This will cause a compilation error.

To fix this, you should ensure that all arms of the match return an owned String. While slightly less efficient than using &str for static constants, it is safe and correct for a CLI reporting tool.

            shipper_core::types::PackageState::Published => "\x1b[32mPublished\x1b[0m".to_string(),
            shipper_core::types::PackageState::Pending => "Pending".to_string(),
            shipper_core::types::PackageState::Uploaded => "\x1b[33mUploaded\x1b[0m".to_string(),
            shipper_core::types::PackageState::Skipped { reason } => format!("Skipped: {}", reason),
            shipper_core::types::PackageState::Failed { class, message } => {
                format!("\x1b[31mFailed ({:?}): {}\x1b[0m", class, message)
            }
            shipper_core::types::PackageState::Ambiguous { message } => {
                format!("\x1b[33mAmbiguous: {}\x1b[0m", message)
            }

let receipt_path = from_receipt.unwrap_or_else(|| {
opts.state_dir
.join(crate::state::execution_state::RECEIPT_FILE)
.join(shipper_core::state::execution_state::RECEIPT_FILE)

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

The opts.state_dir is used here directly without being resolved against planned.workspace_root. This is inconsistent with other commands like publish or inspect-events, which correctly handle relative state directory paths by joining them with the workspace root. If a user runs this command from a subdirectory with a relative --manifest-path, this command will likely fail to find the receipt file. Consider resolving the state directory path before joining the file name.

let receipt_path = from_receipt.unwrap_or_else(|| {
opts.state_dir
.join(crate::state::execution_state::RECEIPT_FILE)
.join(shipper_core::state::execution_state::RECEIPT_FILE)

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

Similar to the PlanYank command, FixForward uses opts.state_dir directly without resolving it against planned.workspace_root. This inconsistency can lead to file-not-found errors when running the tool from outside the workspace root with the default relative state directory.

Comment on lines +789 to +793
use shipper_core::cargo;
use shipper_core::engine::plan_yank;
use shipper_core::state::events::{EventLog, events_path};
use shipper_core::state::execution_state::{load_receipt, receipt_path, write_receipt};
use shipper_core::types::{EventType, PublishEvent};

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

In the Yank command implementation below these imports, there are two issues related to consistency and robustness:

  1. State Directory Resolution: The code uses opts.state_dir directly (e.g., for events_path and load_receipt) without resolving it against planned.workspace_root. This differs from the publish command logic.
  2. Registry Defaulting: In single-yank mode, the code defaults to "crates-io" if opts.registries is empty, ignoring the resolved registry name stored in planned.plan.registry.name. This means global flags like --registry might be ignored for this specific command.
  3. Workspace Root: The code uses std::env::current_dir() as the workspace root for cargo_yank, but it should use planned.workspace_root to ensure consistency with the provided manifest path.

@codecov

codecov Bot commented Apr 18, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 87.09677% with 12 lines in your changes missing coverage. Please review.

Files with missing lines Patch % Lines
crates/shipper-cli/src/lib.rs 87.91% 11 Missing ⚠️
crates/shipper/src/bin/shipper.rs 0.00% 1 Missing ⚠️

📢 Thoughts on this report? Let us know!

@EffortlessSteven EffortlessSteven merged commit 8f2f9ae into main Apr 18, 2026
20 of 21 checks passed
@EffortlessSteven EffortlessSteven deleted the feat/95-pr2-shipper-cli-adapter branch April 18, 2026 13:19
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant