@@ -48,6 +48,15 @@ var cdkDevState = struct {
4848 Description string
4949}{}
5050
51+ var cdkGolangScaffoldingRequirements = map [string ]string {
52+ "go" : "https://go.dev/dl/" ,
53+ }
54+
55+ var cdkPythonScaffoldingRequirements = map [string ]string {
56+ "python3" : "https://www.python.org/downloads/" ,
57+ "poetry" : "https://python-poetry.org/docs/" ,
58+ }
59+
5160func init () {
5261 componentsDevModeCmd .Flags ().StringVar (
5362 & cdkDevState .Type ,
@@ -173,6 +182,10 @@ func runComponentsDevMode(_ *cobra.Command, args []string) error {
173182}
174183
175184func cdkGolangScaffolding (component * lwcomponent.Component ) error {
185+ if err := cdkScaffoldingPreflightCheck ("Golang" , cdkGolangScaffoldingRequirements ); err != nil {
186+ return err
187+ }
188+
176189 cli .OutputHuman ("\n Deploying %s scaffolding:\n " , color .HiMagentaString ("Golang" ))
177190 rootPath , err := component .RootPath ()
178191 if err != nil {
@@ -275,6 +288,10 @@ func cdkGolangScaffolding(component *lwcomponent.Component) error {
275288}
276289
277290func cdkPythonScaffolding (component * lwcomponent.Component ) error {
291+ if err := cdkScaffoldingPreflightCheck ("Python" , cdkPythonScaffoldingRequirements ); err != nil {
292+ return err
293+ }
294+
278295 cli .OutputHuman ("\n Deploying %s scaffolding:\n " , color .HiMagentaString ("Python" ))
279296 rootPath , err := component .RootPath ()
280297 if err != nil {
@@ -389,6 +406,21 @@ func cdkPythonScaffolding(component *lwcomponent.Component) error {
389406 return nil
390407}
391408
409+ func cdkScaffoldingPreflightCheck (scaffolding string , requirements map [string ]string ) error {
410+ errMessage := ""
411+ for file , site := range requirements {
412+ if _ , err := exec .LookPath (file ); err != nil {
413+ errMessage += fmt .Sprintf (`
414+ %s is required to create the %s scaffolding. Please install it before proceeding:
415+ %s: %s` , file , scaffolding , file , site )
416+ }
417+ }
418+ if errMessage != "" {
419+ return errors .New (errMessage )
420+ }
421+ return nil
422+ }
423+
392424func cdkExec (rootPath string , name string , args ... string ) error {
393425 var (
394426 vw = terminal .NewVerboseWriter (10 )
0 commit comments