import * as helmexec from '../../helm.exec' ; import { kubeChannel } from '../../kubeChannel' ; import { create as kubectlCreate } from '../../kubectl' ; import { create as minikubeCreate , CheckPresentMode as MinikubeCheckPresentMode } from '../clusterprovider/minikube/minikube' ; import { fs } from '../../fs' ; import { host } from '../../host' ; import { shell , Shell } from '../../shell' ; import * as config from '../config/config' ; import { installHelm , installKubectl , installMinikube } from './installer' ; import { failed , Errorable } from '../../errorable' ; const kubectl = kubectlCreate ( config . getKubectlVersioning ( ) , host , fs , shell ) ; const minikube = minikubeCreate ( host , fs , shell ) ; export async function installDependencies ( ) { const gotKubectl = await kubectl . ensurePresent ( { silent : true } ) ; const gotHelm = helmexec . ensureHelm ( helmexec . EnsureMode . Silent ) ; const gotMinikube = await minikube . checkPresent ( MinikubeCheckPresentMode . Silent ) ; const warn = ( m ) => kubeChannel . showOutput ( m ) ; const installPromises = [ installDependency ( "kubectl" , gotKubectl , installKubectl ) , installDependency ( "Helm" , gotHelm , ( sh ) => installHelm ( sh , warn ) ) , ] ; if ( ! config . getUseWsl ( ) ) { installPromises . push ( installDependency ( "Minikube" , gotMinikube , ( sh ) => installMinikube ( sh , null ) ) ) ; } await Promise . all ( installPromises ) ; kubeChannel . showOutput ( "Done" ) ; } async function installDependency ( name , alreadyGot , installFunc ) { if ( alreadyGot ) { kubeChannel . showOutput ( `Already got ${ name }...` ) ; } else { kubeChannel . showOutput ( `Installing ${ name }...` ) ; const result = await installFunc ( shell ) ; if ( failed ( result ) ) { kubeChannel . showOutput ( `Unable to install ${ name }: ${ result . error [ 0 ] }` ) ; } } }