fix(view): sort and truncate dist-tags (#7808) · npm/cli@70cd88d · GitHub
Skip to content

Commit 70cd88d

Browse files
authored
fix(view): sort and truncate dist-tags (#7808)
This sorts dist-tags by publish date so that newer tags show first, giving top priority to the `latest` tag. It also truncates the list in a similar manner to how dependencies are truncated. Needs tests. Before: ![dist-tags list in npm view showing every tag shorted by version](https://github.com/user-attachments/assets/9a8b094f-f466-439c-927b-21dbeb896322) After: ![dist-tags list in npm view showing a truncated list sorted by publish date](https://github.com/user-attachments/assets/8727c387-21ed-4fe3-8f09-dc8b93bfe75f)
1 parent feb54f7 commit 70cd88d

3 files changed

Lines changed: 105 additions & 4 deletions

File tree

lib/commands/view.js

Lines changed: 17 additions & 3 deletions

tap-snapshots/test/lib/commands/view.js.test.cjs

Lines changed: 73 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -102,6 +102,18 @@ dist
102102
103103
dist-tags:
104104
[34mlatest[39m: 1.0.0
105+
[34mz[39m: 1.0.0
106+
[34my[39m: 1.0.0
107+
[34mv1[39m: 1.0.0
108+
[34mprev[39m: 1.0.0
109+
[34md[39m: 1.0.0
110+
[34mc[39m: 1.0.0
111+
[34mb[39m: 1.0.0
112+
[34ma[39m: 1.0.0
113+
[34mx[39m: 1.0.1
114+
[34mnext[39m: 1.0.1
115+
[34mh[39m: 1.0.1
116+
[2m(...and 3 more.)[22m
105117
106118
published {TIME} ago[39m
107119
`
@@ -116,6 +128,18 @@ dist
116128
117129
dist-tags:
118130
[34mlatest[39m: 1.0.0
131+
[34mz[39m: 1.0.0
132+
[34my[39m: 1.0.0
133+
[34mv1[39m: 1.0.0
134+
[34mprev[39m: 1.0.0
135+
[34md[39m: 1.0.0
136+
[34mc[39m: 1.0.0
137+
[34mb[39m: 1.0.0
138+
[34ma[39m: 1.0.0
139+
[34mx[39m: 1.0.1
140+
[34mnext[39m: 1.0.1
141+
[34mh[39m: 1.0.1
142+
[2m(...and 3 more.)[22m
119143
120144
published {TIME} ago[39m
121145
`
@@ -130,6 +154,18 @@ dist
130154
131155
dist-tags:
132156
[34mlatest[39m: 1.0.0
157+
[34mz[39m: 1.0.0
158+
[34my[39m: 1.0.0
159+
[34mv1[39m: 1.0.0
160+
[34mprev[39m: 1.0.0
161+
[34md[39m: 1.0.0
162+
[34mc[39m: 1.0.0
163+
[34mb[39m: 1.0.0
164+
[34ma[39m: 1.0.0
165+
[34mx[39m: 1.0.1
166+
[34mnext[39m: 1.0.1
167+
[34mh[39m: 1.0.1
168+
[2m(...and 3 more.)[22m
133169
134170
published {TIME} ago[39m
135171
`
@@ -269,6 +305,18 @@ dist
269305
270306
dist-tags:
271307
[34mlatest[39m: 1.0.0
308+
[34mz[39m: 1.0.0
309+
[34my[39m: 1.0.0
310+
[34mv1[39m: 1.0.0
311+
[34mprev[39m: 1.0.0
312+
[34md[39m: 1.0.0
313+
[34mc[39m: 1.0.0
314+
[34mb[39m: 1.0.0
315+
[34ma[39m: 1.0.0
316+
[34mx[39m: 1.0.1
317+
[34mnext[39m: 1.0.1
318+
[34mh[39m: 1.0.1
319+
[2m(...and 3 more.)[22m
272320
273321
published {TIME} ago[39m
274322
`
@@ -283,6 +331,18 @@ dist
283331
284332
dist-tags:
285333
[34mlatest[39m: 1.0.0
334+
[34mz[39m: 1.0.0
335+
[34my[39m: 1.0.0
336+
[34mv1[39m: 1.0.0
337+
[34mprev[39m: 1.0.0
338+
[34md[39m: 1.0.0
339+
[34mc[39m: 1.0.0
340+
[34mb[39m: 1.0.0
341+
[34ma[39m: 1.0.0
342+
[34mx[39m: 1.0.1
343+
[34mnext[39m: 1.0.1
344+
[34mh[39m: 1.0.1
345+
[2m(...and 3 more.)[22m
286346
287347
published {TIME} ago[39m
288348
@@ -296,8 +356,20 @@ dist
296356
297357
dist-tags:
298358
[34mlatest[39m: 1.0.0
359+
[34mz[39m: 1.0.0
360+
[34my[39m: 1.0.0
361+
[34mv1[39m: 1.0.0
362+
[34mprev[39m: 1.0.0
363+
[34md[39m: 1.0.0
364+
[34mc[39m: 1.0.0
365+
[34mb[39m: 1.0.0
366+
[34ma[39m: 1.0.0
367+
[34mx[39m: 1.0.1
368+
[34mnext[39m: 1.0.1
369+
[34mh[39m: 1.0.1
370+
[2m(...and 3 more.)[22m
299371
300-
published [36mover a year from now[39m
372+
published {TIME} ago[39m
301373
`
302374

303375
exports[`test/lib/commands/view.js TAP package with single version full json > must match snapshot 1`] = `

test/lib/commands/view.js

Lines changed: 15 additions & 0 deletions

0 commit comments

Comments
 (0)