Skip to content

fix(view): Show the correct publish date for versions selected by range #3739

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Sep 13, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion lib/view.js
Original file line number Diff line number Diff line change
Expand Up @@ -336,7 +336,7 @@ class View extends BaseCommand {
email: color.cyan(manifest._npmUser.email),
}),
modified: !packument.time ? undefined
: color.yellow(relativeDate(packument.time[packument.version])),
: color.yellow(relativeDate(packument.time[manifest.version])),
maintainers: (packument.maintainers || []).map((u) => unparsePerson({
name: color.yellow(u.name),
email: color.cyan(u.email),
Expand Down
23 changes: 20 additions & 3 deletions tap-snapshots/test/lib/view.js.test.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ dist
dist-tags:
latest: 1.0.0

published {TIME} ago
published yesterday
`

exports[`test/lib/view.js TAP should log info of package in current working dir specific version > must match snapshot 1`] = `
Expand All @@ -99,7 +99,7 @@ dist
dist-tags:
latest: 1.0.0

published {TIME} ago
published yesterday
`

exports[`test/lib/view.js TAP should log package info package from git > must match snapshot 1`] = `
Expand Down Expand Up @@ -302,7 +302,24 @@ dist
dist-tags:
latest: 1.0.0

published {TIME} ago
published yesterday
`

exports[`test/lib/view.js TAP should log package info package with semver range > must match snapshot 1`] = `


blue@1.0.0 | Proprietary | deps: none | versions: 2

dist
.tarball:http://hm.blue.com/1.0.0.tgz
.shasum:123
.integrity:---
.unpackedSize:1 B

dist-tags:
latest: 1.0.0

published yesterday
`

exports[`test/lib/view.js TAP workspaces all workspaces --json > must match snapshot 1`] = `
Expand Down
12 changes: 11 additions & 1 deletion test/lib/view.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,9 @@ const cleanLogs = () => {
console.log = fn
}

// 25 hours ago
const yesterday = new Date(Date.now() - 1000 * 60 * 60 * 25)

const packument = (nv, opts) => {
if (!opts.fullMetadata)
throw new Error('must fetch fullMetadata')
Expand All @@ -40,7 +43,7 @@ const packument = (nv, opts) => {
latest: '1.0.0',
},
time: {
'1.0.0': '2019-08-06T16:21:09.842Z',
'1.0.0': yesterday,
},
versions: {
'1.0.0': {
Expand Down Expand Up @@ -332,6 +335,13 @@ t.test('should log package info', t => {
})
})

t.test('package with semver range', t => {
view.exec(['blue@^1.0.0'], () => {
t.matchSnapshot(logs)
t.end()
})
})

t.test('package with no modified time', t => {
viewUnicode.exec(['[email protected]'], () => {
t.matchSnapshot(logs)
Expand Down