import { Command } from "@enzsft/cli" ; import chalk from "chalk" ; import { EOL } from "os" ; import { includeOption } from "../options/include" ; import { filterPackages } from "../packages" ; import { MonoRepo , Package , ListCommandOptions } from "../types" ; import { createConsoleLogger } from "../logger" ; param { Object [ ] } packages param { Object } monoRepo returns { Object } export const createListCommand = ( packages , monoRepo ) : Command < ListCommandOptions > => { return { description : "List packages." , handler : async ( values , options ) : Promise < void > => { const logger = createConsoleLogger ( ) ; if ( ! monoRepo ) { logger . warn ( "Unable to locate your mono repo 😰" ) ; return ; } const foundPackages = filterPackages ( packages , options . include ) ; if ( foundPackages . length === 0 ) { logger . warn ( "No packages found 😰" ) ; return ; } const log = `${ chalk . greenBright ( `Found ${ foundPackages . length } packages:` ) }${ EOL }${ chalk . cyanBright ( foundPackages . map ( p => `${ p . name }@${ p . version }` ) . join ( EOL ) ) }` ; logger . log ( log ) ; } , name : "list" , options : [ includeOption ] } ; } ;