import { ToolingLog } from '@kbn/dev-utils' ; import { Config , createRunner , Task , GlobalTask } from './lib' ; import * as Tasks from './tasks' ; export interface BuildOptions { isRelease : boolean ; dockerPush : boolean ; dockerTagQualifier : string | null ; downloadFreshNode : boolean ; downloadCloudDependencies : boolean ; initialize : boolean ; createGenericFolders : boolean ; createPlatformFolders : boolean ; createArchives : boolean ; createRpmPackage : boolean ; createDebPackage : boolean ; createDockerUBI : boolean ; createDockerUbuntu : boolean ; createDockerCloud : boolean ; createDockerContexts : boolean ; versionQualifier : string | undefined ; targetAllPlatforms : boolean ; createExamplePlugins : boolean ; } export async function buildDistributables ( log , options ) { log . verbose ( 'building distributables with options:' , options ) ; const config = await Config . create ( options ) ; const run = createRunner ( { config , log , } ) ; /**
     * verify, reset, and initialize the build environment
     */ if ( options . initialize ) { await run ( Tasks . VerifyEnv ) ; await run ( Tasks . Clean ) ; await run ( options . downloadFreshNode ? Tasks . DownloadNodeBuilds : Tasks . VerifyExistingNodeBuilds ) ; await run ( Tasks . ExtractNodeBuilds ) ; } /**
     * build example plugins
     */ if ( options . createExamplePlugins ) { await run ( Tasks . BuildKibanaExamplePlugins ) ; } /**
     * run platform-generic build tasks
     */ if ( options . createGenericFolders ) { await run ( Tasks . CopySource ) ; await run ( Tasks . CopyBinScripts ) ; await run ( Tasks . ReplaceFavicon ) ; await run ( Tasks . CreateEmptyDirsAndFiles ) ; await run ( Tasks . CreateReadme ) ; await run ( Tasks . BuildBazelPackages ) ; await run ( Tasks . BuildPackages ) ; await run ( Tasks . BuildKibanaPlatformPlugins ) ; await run ( Tasks . TranspileBabel ) ; await run ( Tasks . CreatePackageJson ) ; await run ( Tasks . InstallDependencies ) ; await run ( Tasks . GeneratePackagesOptimizedAssets ) ; await run ( Tasks . CleanPackages ) ; await run ( Tasks . CreateNoticeFile ) ; await run ( Tasks . UpdateLicenseFile ) ; await run ( Tasks . RemovePackageJsonDeps ) ; await run ( Tasks . CleanTypescript ) ; await run ( Tasks . CleanExtraFilesFromModules ) ; await run ( Tasks . CleanEmptyFolders ) ; } /**
     * copy generic build outputs into platform-specific build
     * directories and perform platform/architecture-specific steps
     */ if ( options . createPlatformFolders ) { await run ( Tasks . CreateArchivesSources ) ; await run ( Tasks . PatchNativeModules ) ; await run ( Tasks . InstallChromium ) ; await run ( Tasks . CleanExtraBinScripts ) ; await run ( Tasks . CleanNodeBuilds ) ; await run ( Tasks . PathLength ) ; await run ( Tasks . UuidVerification ) ; } /**
     * package platform-specific builds into archives
     * or os-specific packages in the target directory
     */ if ( options . createArchives ) { await run ( Tasks . CreateArchives ) ; } if ( options . createDebPackage || options . createRpmPackage ) { await run ( Tasks . CreatePackageConfig ) ; } if ( options . createDebPackage ) { await run ( Tasks . CreateDebPackage ) ; } if ( options . createRpmPackage ) { await run ( Tasks . CreateRpmPackage ) ; } if ( options . createDockerUBI ) { await run ( Tasks . CreateDockerUBI ) ; } if ( options . createDockerUbuntu ) { await run ( Tasks . CreateDockerUbuntu ) ; } if ( options . createDockerCloud ) { if ( options . downloadCloudDependencies ) { await run ( Tasks . DownloadCloudDependencies ) ; } await run ( Tasks . CreateDockerCloud ) ; } if ( options . createDockerContexts ) { await run ( Tasks . CreateDockerContexts ) ; } /**
     * finalize artifacts by writing sha1sums of each into the target directory
     */ await run ( Tasks . WriteShaSums ) ; }