import { REPO_ROOT } from '@kbn/utils' ; import { run } from '@kbn/dev-utils' ; import { getInstalledPackages } from '../npm' ; import { LICENSE_ALLOWED , DEV_ONLY_LICENSE_ALLOWED , LICENSE_OVERRIDES } from './config' ; import { assertLicensesValid } from './valid' ; run ( async ( { log , flags } ) => { const packages = await getInstalledPackages ( { directory : REPO_ROOT , licenseOverrides : LICENSE_OVERRIDES , includeDev : ! ! flags . dev , } ) ; assertLicensesValid ( { packages : packages . filter ( ( pkg ) => ! pkg . isDevOnly ) , validLicenses : LICENSE_ALLOWED , } ) ; log . success ( 'All production dependency licenses are allowed' ) ; if ( flags . dev ) { assertLicensesValid ( { packages : packages . filter ( ( pkg ) => pkg . isDevOnly ) , validLicenses : LICENSE_ALLOWED . concat ( DEV_ONLY_LICENSE_ALLOWED ) , } ) ; log . success ( 'All development dependency licenses are allowed' ) ; } } , { flags : { boolean : [ 'dev' ] , help : `
        --dev              Also check dev dependencies
      ` , } , } ) ;