import { table } from 'table' ; import * as chalk from 'chalk' ; import { concat } from 'lodash' ; import { isMatchingVersion } from '../deps' ; export const render = ( depMap ) => { let rows = [ [ chalk . bold ( 'Name' ) , chalk . bold ( 'Package Version' ) , chalk . bold ( 'Installed Version' ) , chalk . bold ( 'Status' ) , chalk . bold ( 'Locked' ) ] ] ; rows = concat ( rows , createRows ( depMap . deps ) , createRows ( depMap . devDeps ) ) ; console . log ( table ( rows ) ) ; } ; param { IPackageDescriptor [ ] } pkgDescriptor returns let createRows = ( pkgDescriptor ) : string [ ] [ ] => pkgDescriptor . map ( pkg => ( [ pkg . name , pkg . parsedDefinedVersion , pkg . installedVersion , ( ! isMatchingVersion ( pkg . parsedDefinedVersion , pkg . installedVersion ) ? chalk . bold . bgRed ( ' Mismatch ' ) : chalk . bold . bgGreen ( ' Matching ' ) ) , ( pkg . locked ? chalk . bold . bgGreen ( '  Locked  ' ) : chalk . bold . bgRed ( ' Unlocked ' ) ) ] ) ) ;