Commit 834408e
fix(pack): honor min-release-age-exclude (#9760)
Make `npm pack` honor `min-release-age-exclude` when resolving packages
from a registry.
Given:
```ini
min-release-age=7
min-release-age-exclude=@myscope/*
```
`npm pack @myscope/some-package@1.2.3` incorrectly failed with
ETARGET when the package was newer than seven days, despite matching
the exclusion.
Root cause
`min-release-age` is flattened into the `before` option consumed by
`pacote` . However, `pacote` does not interpret
`min-release-age-exclude` ; callers must remove before for matching
packages.
`npm pack` performs two manifest resolutions:
1. Directly through `pacote.manifest`
2. Internally through `libnpmpack`
Both resolutions received the unmodified `before` option, so the
exclusion was never applied.
Fix
Derive effective options for each package spec using the existing
Arborist release-age helpers:
• Clear `before` when the package matches `min-release-age-exclude`
• Preserve the cutoff for nonmatching packages
• Pass the same effective options to both manifest resolutions
Using the alias target prevents an excluded alias name from disabling
the release-age policy for an unrelated package.
Test coverage
Added regression coverage confirming that:
• A recently published scoped package matching an exclusion glob can be
packed
• An excluded alias name does not exempt its non-excluded registry
target
The original scenario was also reproduced against a local registry: it
failed with `ETARGET` before this change and successfully produced the
tarball afterward.
References
Fixes #9759
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Copilot-Session: dec204b6-ad66-45a5-8228-831e306f6ba61 parent ef6cfea commit 834408e
2 files changed
Lines changed: 68 additions & 4 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
2 | 2 | | |
3 | 3 | | |
4 | 4 | | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
5 | 9 | | |
6 | 10 | | |
7 | 11 | | |
| |||
35 | 39 | | |
36 | 40 | | |
37 | 41 | | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
38 | 46 | | |
39 | | - | |
| 47 | + | |
40 | 48 | | |
41 | 49 | | |
42 | 50 | | |
43 | 51 | | |
44 | 52 | | |
45 | 53 | | |
46 | 54 | | |
47 | | - | |
| 55 | + | |
48 | 56 | | |
49 | 57 | | |
50 | 58 | | |
51 | 59 | | |
52 | | - | |
| 60 | + | |
53 | 61 | | |
54 | | - | |
| 62 | + | |
55 | 63 | | |
56 | 64 | | |
57 | 65 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | 1 | | |
2 | 2 | | |
3 | 3 | | |
| 4 | + | |
4 | 5 | | |
5 | 6 | | |
6 | 7 | | |
| |||
162 | 163 | | |
163 | 164 | | |
164 | 165 | | |
| 166 | + | |
| 167 | + | |
| 168 | + | |
| 169 | + | |
| 170 | + | |
| 171 | + | |
| 172 | + | |
| 173 | + | |
| 174 | + | |
| 175 | + | |
| 176 | + | |
| 177 | + | |
| 178 | + | |
| 179 | + | |
| 180 | + | |
| 181 | + | |
| 182 | + | |
| 183 | + | |
| 184 | + | |
| 185 | + | |
| 186 | + | |
| 187 | + | |
| 188 | + | |
| 189 | + | |
| 190 | + | |
| 191 | + | |
| 192 | + | |
| 193 | + | |
| 194 | + | |
| 195 | + | |
| 196 | + | |
| 197 | + | |
| 198 | + | |
| 199 | + | |
| 200 | + | |
| 201 | + | |
| 202 | + | |
| 203 | + | |
| 204 | + | |
| 205 | + | |
| 206 | + | |
| 207 | + | |
| 208 | + | |
| 209 | + | |
| 210 | + | |
| 211 | + | |
| 212 | + | |
| 213 | + | |
| 214 | + | |
| 215 | + | |
| 216 | + | |
| 217 | + | |
| 218 | + | |
| 219 | + | |
| 220 | + | |
165 | 221 | | |
166 | 222 | | |
167 | 223 | | |
| |||
0 commit comments