import { posix as path } from 'path' ; import { AngularPackage } from './src/angular-package' ; import { AngularPackageReader } from './src/angular-package-reader' ; import { AngularPackageOrchestrator } from './src/angular-package-orchestrator' ; import { AngularPackageBuilder } from './src/angular-package-builder' ; import { flattenArray } from './src/utilities/flatten-array' ; import { AngularPackageLogger } from './src/logger/angular-package-logger' ; /**
 * Run Angular Package Builder
 */ export async function runAngularPackageBuilder ( angularPackageJsonPaths ) { AngularPackageLogger . logTitle ( 'Angular Package Builder' ) ; let angularPackages ; try { angularPackages = await AngularPackageReader . readAngularPackageJsonFiles ( angularPackageJsonPaths ) ; } catch ( error ) { AngularPackageLogger . logPreparationMessage ( error . message , 'error' ) ; throw new Error ( error . message ) ; } let buildOrchestration ; try { buildOrchestration = AngularPackageOrchestrator . orchestrateAngularPackagesBuild ( angularPackages ) ; } catch ( error ) { AngularPackageLogger . logPreparationMessage ( error . message , 'error' ) ; throw new Error ( error . message ) ; } const flattenedBuildOrchestration = flattenArray ( buildOrchestration ) ; AngularPackageLogger . configureNumberOfBuildSteps ( flattenedBuildOrchestration . length ) ; const builtAngularPackages = { } ; for ( const angularPackage of flattenedBuildOrchestration ) { AngularPackageLogger . logBuildStart ( angularPackage . packageName ) ; angularPackage . addCustomModulePaths ( builtAngularPackages ) ; try { await AngularPackageBuilder . package ( angularPackage ) ; } catch ( error ) { AngularPackageLogger . logBuildError ( ) ; throw new Error ( error . message ) ; } builtAngularPackages [ angularPackage . packageName ] = [ path . join ( angularPackage . root , angularPackage . outDir ) ] ; AngularPackageLogger . logBuildSuccess ( ) ; } }