refactor(workspace): extract crates/youtrack-config + client bridge (YT-18) #61

Merged
nrupard merged 1 commit from refactor/extract-youtrack-config-YT-18 into main 2026-05-27 18:04:16 +02:00
Member

Subtask 3 of the workspace refactor epic (YT-15). Depends on the merged youtrack-client extraction (YT-17).

What

Extract the config + multi-instance store into a new reusable library crate crates/youtrack-config, and collapse the ~23 duplicated per-command client_from_cfg helpers into a single Config::client() bridge. No behavior change to the yt binary: command surface, output, and instance resolution are unchanged.

How

Moved into the crate via git mv (history preserved): config/mod.rs -> lib.rs (Config, ConfigSource, load / save, XDG path logic, secure 0700/0600 writes, token()) and config/instances.rs (the Instances store, resolve, derive_instance_from_url).

Config::client() -> Result<youtrack_client::Client> is the one bridge. It reproduces the exact validation every call site already performed (error when url or token is unset, otherwise construct the client), so every client_from_cfg(cfg)? and the inline Client::new(&cfg.url, cfg.token()) in board.rs / search.rs / auth/verify.rs collapse to cfg.client()? with identical behavior.

Presentation moved to the CLI: print_masked / print_raw are gone from the library. config show formats and masks the token inline (carrying the mask_token unit tests with it), config view serializes inline. All crate::config::... references across the bin crate are now youtrack_config::....

Library purity

crates/youtrack-config is publish = false and depends only on youtrack-client, anyhow, secrecy, serde, serde_yml, url (tempfile as a dev-dependency). No clap, comfy-table, or rpassword. Dropped the now-dead secrecy and url deps from yt-cli (both moved with the config core).

Acceptance criteria

  • crates/youtrack-config builds and tests pass (25 tests, run as part of the workspace).
  • A single bridge converts a loaded Config into a youtrack_client::Client; no command defines its own client_from_cfg, and board.rs / search.rs use the bridge.
  • print_masked / print_raw live in the CLI, not the library.
  • crate::config::... references replaced with youtrack_config::....
  • just pre-commit green (fmt, clippy -D warnings, build, 121 tests); config show / view, auth login, and instance resolution behave unchanged.

🤖 Generated with Claude Code

Subtask 3 of the workspace refactor epic (YT-15). Depends on the merged `youtrack-client` extraction (YT-17). ## What Extract the config + multi-instance store into a new reusable library crate `crates/youtrack-config`, and collapse the ~23 duplicated per-command `client_from_cfg` helpers into a single `Config::client()` bridge. No behavior change to the `yt` binary: command surface, output, and instance resolution are unchanged. ## How Moved into the crate via `git mv` (history preserved): `config/mod.rs` -> `lib.rs` (`Config`, `ConfigSource`, load / save, XDG path logic, secure 0700/0600 writes, `token()`) and `config/instances.rs` (the `Instances` store, `resolve`, `derive_instance_from_url`). `Config::client() -> Result<youtrack_client::Client>` is the one bridge. It reproduces the exact validation every call site already performed (error when url or token is unset, otherwise construct the client), so every `client_from_cfg(cfg)?` and the inline `Client::new(&cfg.url, cfg.token())` in `board.rs` / `search.rs` / `auth/verify.rs` collapse to `cfg.client()?` with identical behavior. Presentation moved to the CLI: `print_masked` / `print_raw` are gone from the library. `config show` formats and masks the token inline (carrying the `mask_token` unit tests with it), `config view` serializes inline. All `crate::config::...` references across the bin crate are now `youtrack_config::...`. ## Library purity `crates/youtrack-config` is `publish = false` and depends only on youtrack-client, anyhow, secrecy, serde, serde_yml, url (tempfile as a dev-dependency). No clap, comfy-table, or rpassword. Dropped the now-dead `secrecy` and `url` deps from yt-cli (both moved with the config core). ## Acceptance criteria - [x] `crates/youtrack-config` builds and tests pass (25 tests, run as part of the workspace). - [x] A single bridge converts a loaded `Config` into a `youtrack_client::Client`; no command defines its own `client_from_cfg`, and `board.rs` / `search.rs` use the bridge. - [x] `print_masked` / `print_raw` live in the CLI, not the library. - [x] `crate::config::...` references replaced with `youtrack_config::...`. - [x] `just pre-commit` green (fmt, clippy -D warnings, build, 121 tests); `config show` / `view`, `auth login`, and instance resolution behave unchanged. 🤖 Generated with [Claude Code](https://claude.com/claude-code)
refactor(workspace): extract crates/youtrack-config + client bridge (YT-18)
All checks were successful
Check / fmt + clippy + build + tests (pull_request) Successful in 15s
Create release / Create release from merged PR (pull_request) Has been skipped
8c1be2defc
Move the config + multi-instance store out of the binary crate into a new reusable library crate `crates/youtrack-config`, and collapse the ~23 duplicated per-command `client_from_cfg` helpers into a single `Config::client()` bridge. No behavior change to the `yt` binary; command surface, output, and instance resolution are unchanged.

Moved into the crate via `git mv` (history preserved): `config/mod.rs` -> `lib.rs` (`Config`, `ConfigSource`, load / save, XDG path logic, secure 0700/0600 writes, `token()`) and `config/instances.rs` (the `Instances` store, `resolve`, `derive_instance_from_url`). The crate is `publish = false` and depends on youtrack-client, anyhow, secrecy, serde, serde_yml, url: no clap, comfy-table, or rpassword.

`Config::client() -> Result<youtrack_client::Client>` is the one bridge. It reproduces the exact validation every call site already performed (error when url or token is unset, otherwise construct the transport client), so every `client_from_cfg(cfg)?` and the inline `Client::new(&cfg.url, cfg.token())` in `board.rs` / `search.rs` / `auth/verify.rs` collapse to `cfg.client()?` with identical behavior.

Presentation moved to the CLI: `print_masked` / `print_raw` are gone from the library; `config show` formats and masks the token inline (with the `mask_token` unit tests), `config view` serializes inline. `crate::config::...` references across the bin crate are now `youtrack_config::...`.

Dropped now-dead `secrecy` and `url` deps from yt-cli (both moved with the config core).

`just pre-commit` green: fmt, clippy -D warnings, build, 121 tests (96 yt-cli + 25 youtrack-config).

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
nrupard deleted branch refactor/extract-youtrack-config-YT-18 2026-05-27 18:04:17 +02:00
Sign in to join this conversation.
No reviewers
No labels
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
pandoras-box/youtrack-cli!61
No description provided.