(packu, manifest)
| 258 | } |
| 259 | |
| 260 | #prettyView (packu, manifest) { |
| 261 | // More modern, pretty printing of default view |
| 262 | const unicode = this.npm.config.get('unicode') |
| 263 | const chalk = this.npm.chalk |
| 264 | const deps = Object.entries(manifest.dependencies || {}).map(([k, dep]) => |
| 265 | `${chalk.blue(k)}: ${dep}` |
| 266 | ) |
| 267 | |
| 268 | // Sort dist-tags by publish time when available, then by tag name, keeping `latest` at the top of the list. |
| 269 | const distTags = Object.entries(packu['dist-tags']) |
| 270 | .sort(([aTag, aVer], [bTag, bVer]) => { |
| 271 | const timeMap = packu.time || {} |
| 272 | const aTime = aTag === 'latest' ? Infinity : Date.parse(timeMap[aVer] || 0) |
| 273 | const bTime = bTag === 'latest' ? Infinity : Date.parse(timeMap[bVer] || 0) |
| 274 | if (aTime === bTime) { |
| 275 | return aTag > bTag ? -1 : 1 |
| 276 | } |
| 277 | return aTime > bTime ? -1 : 1 |
| 278 | }) |
| 279 | .map(([k, t]) => `${chalk.blue(k)}: ${t}`) |
| 280 | |
| 281 | const site = manifest.homepage?.url || manifest.homepage |
| 282 | const bins = Object.keys(manifest.bin || {}) |
| 283 | const licenseField = manifest.license || 'Proprietary' |
| 284 | const license = typeof licenseField === 'string' |
| 285 | ? licenseField |
| 286 | : (licenseField.type || 'Proprietary') |
| 287 | |
| 288 | const res = [] |
| 289 | |
| 290 | res.push('') |
| 291 | res.push([ |
| 292 | chalk.underline.cyan(`${manifest.name}@${manifest.version}`), |
| 293 | license.toLowerCase().trim() === 'proprietary' |
| 294 | ? chalk.red(license) |
| 295 | : chalk.green(license), |
| 296 | `deps: ${deps.length ? chalk.cyan(deps.length) : chalk.cyan('none')}`, |
| 297 | `versions: ${chalk.cyan(packu.versions.length + '')}`, |
| 298 | ].join(' | ')) |
| 299 | |
| 300 | manifest.description && res.push(manifest.description) |
| 301 | if (site) { |
| 302 | res.push(chalk.blue(site)) |
| 303 | } |
| 304 | |
| 305 | manifest.deprecated && res.push( |
| 306 | `\n${chalk.redBright('DEPRECATED')}${unicode ? ' ⚠️ ' : '!!'} - ${manifest.deprecated}` |
| 307 | ) |
| 308 | |
| 309 | if (packu.keywords?.length) { |
| 310 | res.push(`\nkeywords: ${ |
| 311 | packu.keywords.map(k => chalk.cyan(k)).join(', ') |
| 312 | }`) |
| 313 | } |
| 314 | |
| 315 | if (bins.length) { |
| 316 | res.push(`\nbin: ${chalk.cyan(bins.join(', '))}`) |
| 317 | } |
no test coverage detected