mirror of
https://github.com/pnpm/pnpm.git
synced 2026-07-28 00:17:17 -04:00
## Summary - pnpm 11 reads project-structural settings (storeDir, hoist, nodeLinker, fetchRetries, …) from `pnpm-workspace.yaml` and limits `.npmrc` to auth/registry/network keys. The crate that holds pacquet's resolved runtime config was still named `pacquet-npmrc` with a `Npmrc` type and carried `serde_ini` deserializer wiring on every field, which no longer reflected how the config is actually loaded on this branch. - Two-commit refactor: rename the crate / type / imports, then drop the dead serde_ini machinery and the seven duplicate ini-based tests. ## Commits 1. **`refactor(config): rename pacquet-npmrc crate to pacquet-config`** — mechanical rename. `crates/npmrc/` → `crates/config/`, `Npmrc` → `Config`, `pacquet-npmrc`/`pacquet_npmrc` references updated workspace-wide. `NpmrcAuth` (the `.npmrc` auth-subset parser) keeps its name. 2. **`refactor(config): drop ini deserializer wiring from Config`** — removes `Deserialize` + `#[serde(rename_all = "kebab-case")]` from `Config`, every per-field `deserialize_with`/`default = "..."` attribute, the helper fns that backed them (`bool_true`, `deserialize_bool`/`u32`/`u64`/`pathbuf`/`store_dir`/`registry`), and the `serde_ini` workspace dep. Drops seven ini-based `lib.rs` tests that already had equivalent yaml/npmrc-auth coverage. Renames `custom_deserializer` → `defaults` (only default factories left), and the `npmrc: &mut Config` local in `apply_to` / `Config::current` becomes `config`. After the cleanup `Config` is purely a merged runtime struct: yaml deserializes into `WorkspaceSettings` and applies onto a `Config`, `.npmrc` is hand-parsed by `NpmrcAuth::from_ini`, and `Config` itself is no longer deserialized from any file.
47 lines
1.7 KiB
Rust
47 lines
1.7 KiB
Rust
use command_extra::CommandExtra;
|
|
use pacquet_testing_utils::bin::CommandTempCwd;
|
|
use pipe_trait::Pipe;
|
|
use pretty_assertions::assert_eq;
|
|
use std::{
|
|
fs,
|
|
path::{Path, PathBuf},
|
|
};
|
|
|
|
/// Canonicalize a path the same way the production CLI does. The CLI
|
|
/// runs `dunce::canonicalize` on `--dir` and threads that through to
|
|
/// `Config::current`, so on Windows the printed `storeDir` is the long
|
|
/// form (`C:\Users\runneradmin\...`) even when the surrounding test
|
|
/// runs in a `TEMP` directory whose env var resolves to the short DOS
|
|
/// form (`C:\Users\RUNNER~1\...`). Mirror that here so the expected
|
|
/// value matches what pacquet actually prints.
|
|
fn canonicalize(path: &Path) -> PathBuf {
|
|
dunce::canonicalize(path).expect("canonicalize path")
|
|
}
|
|
|
|
#[test]
|
|
fn store_path_should_return_store_dir_from_pnpm_workspace_yaml() {
|
|
// `storeDir` is a project-structural setting — in pnpm 11 (and now
|
|
// pacquet) it's only honoured from `pnpm-workspace.yaml`, not `.npmrc`.
|
|
let CommandTempCwd { pacquet, root, workspace, .. } = CommandTempCwd::init();
|
|
|
|
eprintln!("Creating pnpm-workspace.yaml...");
|
|
fs::write(workspace.join("pnpm-workspace.yaml"), "storeDir: foo/bar\n")
|
|
.expect("write to pnpm-workspace.yaml");
|
|
|
|
eprintln!("Executing pacquet store path...");
|
|
let output = pacquet.with_args(["store", "path"]).output().expect("run pacquet store path");
|
|
dbg!(&output);
|
|
|
|
eprintln!("Exit status code");
|
|
assert!(output.status.success());
|
|
|
|
eprintln!("Stdout");
|
|
let normalize = |path: &str| path.replace('\\', "/");
|
|
assert_eq!(
|
|
String::from_utf8_lossy(&output.stdout).trim_end().pipe(normalize),
|
|
canonicalize(&workspace).join("foo/bar").to_string_lossy().pipe_as_ref(normalize),
|
|
);
|
|
|
|
drop(root); // cleanup
|
|
}
|