import Path from 'path' ; import { pipeline } from 'stream' ; import { promisify } from 'util' ; import del from 'del' ; import vfs from 'vinyl-fs' ; import zip from 'gulp-zip' ; import { BuildContext } from '../build_context' ; const asyncPipeline = promisify ( pipeline ) ; export async function createArchive ( { kibanaVersion , plugin , log } ) { const { manifest : { id } , directory , } = plugin ; const zipName = `${ id }-${ kibanaVersion }.zip` ; log . info ( `compressing plugin into [${ zipName }]` ) ; const buildDir = Path . resolve ( directory , 'build' ) ; await asyncPipeline ( vfs . src ( [ `kibana/${ id }/**/*` ] , { cwd : buildDir , base : buildDir , dot : true , } ) , zip ( zipName ) , vfs . dest ( buildDir ) ) ; await del ( Path . resolve ( buildDir , 'kibana' ) ) ; }