3
3
4
4
// npm view [pkg [pkg ...]]
5
5
6
- const color = require ( 'ansicolors' )
7
6
const chalk = require ( 'chalk' )
8
7
const columns = require ( 'cli-columns' )
9
8
const fs = require ( 'fs' )
@@ -318,34 +317,34 @@ class View extends BaseCommand {
318
317
319
318
Object . keys ( packument [ 'dist-tags' ] ) . forEach ( ( t ) => {
320
319
const version = packument [ 'dist-tags' ] [ t ]
321
- tags . push ( `${ chalk . bold ( color . green ( t ) ) } : ${ version } ` )
320
+ tags . push ( `${ chalk . bold . green ( t ) } : ${ version } ` )
322
321
} )
323
322
const unpackedSize = manifest . dist . unpackedSize &&
324
323
formatBytes ( manifest . dist . unpackedSize , true )
325
324
const licenseField = manifest . license || 'Proprietary'
326
325
const info = {
327
- name : color . green ( manifest . name ) ,
328
- version : color . green ( manifest . version ) ,
329
- bins : Object . keys ( manifest . bin || { } ) . map ( color . yellow ) ,
330
- versions : color . yellow ( packument . versions . length + '' ) ,
326
+ name : chalk . green ( manifest . name ) ,
327
+ version : chalk . green ( manifest . version ) ,
328
+ bins : Object . keys ( manifest . bin || { } ) ,
329
+ versions : chalk . yellow ( packument . versions . length + '' ) ,
331
330
description : manifest . description ,
332
331
deprecated : manifest . deprecated ,
333
- keywords : ( packument . keywords || [ ] ) . map ( color . yellow ) ,
332
+ keywords : packument . keywords || [ ] ,
334
333
license : typeof licenseField === 'string'
335
334
? licenseField
336
335
: ( licenseField . type || 'Proprietary' ) ,
337
336
deps : Object . keys ( manifest . dependencies || { } ) . map ( ( dep ) => {
338
- return `${ color . yellow ( dep ) } : ${ manifest . dependencies [ dep ] } `
337
+ return `${ chalk . yellow ( dep ) } : ${ manifest . dependencies [ dep ] } `
339
338
} ) ,
340
339
publisher : manifest . _npmUser && unparsePerson ( {
341
- name : color . yellow ( manifest . _npmUser . name ) ,
342
- email : color . cyan ( manifest . _npmUser . email ) ,
340
+ name : chalk . yellow ( manifest . _npmUser . name ) ,
341
+ email : chalk . cyan ( manifest . _npmUser . email ) ,
343
342
} ) ,
344
343
modified : ! packument . time ? undefined
345
- : color . yellow ( relativeDate ( packument . time [ manifest . version ] ) ) ,
344
+ : chalk . yellow ( relativeDate ( packument . time [ manifest . version ] ) ) ,
346
345
maintainers : ( packument . maintainers || [ ] ) . map ( ( u ) => unparsePerson ( {
347
- name : color . yellow ( u . name ) ,
348
- email : color . cyan ( u . email ) ,
346
+ name : chalk . yellow ( u . name ) ,
347
+ email : chalk . cyan ( u . email ) ,
349
348
} ) ) ,
350
349
repo : (
351
350
manifest . bugs && ( manifest . bugs . url || manifest . bugs )
@@ -356,47 +355,47 @@ class View extends BaseCommand {
356
355
manifest . homepage && ( manifest . homepage . url || manifest . homepage )
357
356
) ,
358
357
tags,
359
- tarball : color . cyan ( manifest . dist . tarball ) ,
360
- shasum : color . yellow ( manifest . dist . shasum ) ,
358
+ tarball : chalk . cyan ( manifest . dist . tarball ) ,
359
+ shasum : chalk . yellow ( manifest . dist . shasum ) ,
361
360
integrity :
362
- manifest . dist . integrity && color . yellow ( manifest . dist . integrity ) ,
361
+ manifest . dist . integrity && chalk . yellow ( manifest . dist . integrity ) ,
363
362
fileCount :
364
- manifest . dist . fileCount && color . yellow ( manifest . dist . fileCount ) ,
365
- unpackedSize : unpackedSize && color . yellow ( unpackedSize ) ,
363
+ manifest . dist . fileCount && chalk . yellow ( manifest . dist . fileCount ) ,
364
+ unpackedSize : unpackedSize && chalk . yellow ( unpackedSize ) ,
366
365
}
367
366
if ( info . license . toLowerCase ( ) . trim ( ) === 'proprietary' ) {
368
- info . license = chalk . bold ( color . red ( info . license ) )
367
+ info . license = chalk . bold . red ( info . license )
369
368
} else {
370
- info . license = color . green ( info . license )
369
+ info . license = chalk . green ( info . license )
371
370
}
372
371
373
372
console . log ( '' )
374
373
console . log (
375
374
chalk . underline . bold ( `${ info . name } @${ info . version } ` ) +
376
375
' | ' + info . license +
377
- ' | deps: ' + ( info . deps . length ? color . cyan ( info . deps . length ) : color . green ( 'none' ) ) +
376
+ ' | deps: ' + ( info . deps . length ? chalk . cyan ( info . deps . length ) : chalk . green ( 'none' ) ) +
378
377
' | versions: ' + info . versions
379
378
)
380
379
info . description && console . log ( info . description )
381
380
if ( info . repo || info . site ) {
382
- info . site && console . log ( color . cyan ( info . site ) )
381
+ info . site && console . log ( chalk . cyan ( info . site ) )
383
382
}
384
383
385
384
const warningSign = unicode ? ' ⚠️ ' : '!!'
386
385
info . deprecated && console . log (
387
- `\n${ chalk . bold ( color . red ( 'DEPRECATED' ) ) } ${
386
+ `\n${ chalk . bold . red ( 'DEPRECATED' ) } ${
388
387
warningSign
389
388
} - ${ info . deprecated } `
390
389
)
391
390
392
391
if ( info . keywords . length ) {
393
392
console . log ( '' )
394
- console . log ( 'keywords:' , info . keywords . join ( ', ' ) )
393
+ console . log ( 'keywords:' , chalk . yellow ( info . keywords . join ( ', ' ) ) )
395
394
}
396
395
397
396
if ( info . bins . length ) {
398
397
console . log ( '' )
399
- console . log ( 'bin:' , info . bins . join ( ', ' ) )
398
+ console . log ( 'bin:' , chalk . yellow ( info . bins . join ( ', ' ) ) )
400
399
}
401
400
402
401
console . log ( '' )
0 commit comments