(path: &Path, expected_minimum_release_age: u64)
| 150 | } |
| 151 | |
| 152 | fn npmrc_minimum_release_age(path: &Path, expected_minimum_release_age: u64) -> Result<u64> { |
| 153 | let contents = fs::read_to_string(path).map_err(|err| { |
| 154 | if err.kind() == std::io::ErrorKind::NotFound { |
| 155 | anyhow::anyhow!( |
| 156 | "{} is tracked but missing from the working tree. Restore it with:\nminimum-release-age={}", |
| 157 | path.display(), |
| 158 | expected_minimum_release_age |
| 159 | ) |
| 160 | } else { |
| 161 | anyhow::anyhow!( |
| 162 | "failed to read {} while checking pnpm minimum package age: {err}", |
| 163 | path.display() |
| 164 | ) |
| 165 | } |
| 166 | })?; |
| 167 | contents |
| 168 | .lines() |
| 169 | .find_map(|line| { |
| 170 | let line = line.trim(); |
| 171 | let value = line.strip_prefix("minimum-release-age=")?.trim(); |
| 172 | value.parse::<u64>().ok() |
| 173 | }) |
| 174 | .ok_or_else(|| { |
| 175 | anyhow::anyhow!( |
| 176 | "{} must contain `minimum-release-age={}` to match root pnpm-workspace.yaml", |
| 177 | path.display(), |
| 178 | expected_minimum_release_age |
| 179 | ) |
| 180 | }) |
| 181 | } |
| 182 | |
| 183 | fn check_pnpm_release_age_policy() -> Result<()> { |
| 184 | ensure_repo_root()?; |
no test coverage detected
searching dependent graphs…