diff --git a/changelog.md b/changelog.md index 9192137bf0..54cc5b6c16 100644 --- a/changelog.md +++ b/changelog.md @@ -23,6 +23,7 @@ - [#3953](https://github.com/ignite/cli/pull/3953) Fix apps `Stdout` is redirected to `Stderr` - [#3863](https://github.com/ignite/cli/pull/3963) Fix breaking issue for app client API when reading app chain info - [#3969](https://github.com/ignite/cli/pull/3969) Get first config validator using a getter to avoid index errors +- [#4000](https://github.com/ignite/cli/pull/4000) Run all dry runners before the wet run in the `xgenny` pkg ## [`v28.2.0`](https://github.com/ignite/cli/releases/tag/v28.2.0) diff --git a/ignite/pkg/xgenny/run.go b/ignite/pkg/xgenny/run.go index 00133d6024..a12fcc63d6 100644 --- a/ignite/pkg/xgenny/run.go +++ b/ignite/pkg/xgenny/run.go @@ -38,49 +38,51 @@ func RunWithValidation( gens ...*genny.Generator, ) (sm SourceModification, err error) { // run executes the provided runner with the provided generator - run := func(runner *genny.Runner, gen *genny.Generator) error { - err := runner.With(gen) - if err != nil { - return err - } - return runner.Run() - } - for _, gen := range gens { - // check with a dry runner the generators - dryRunner := DryRunner(context.Background()) - if err := run(dryRunner, gen); err != nil { - if errors.Is(err, os.ErrNotExist) { - return sm, &dryRunError{err} + run := func(runner *genny.Runner, gens []*genny.Generator) error { + for _, gen := range gens { + if err := runner.With(gen); err != nil { + return err + } + if err := runner.Run(); err != nil { + return err } - return sm, err } - if err := tracer.Err(); err != nil { - return sm, err + return nil + } + // check with a dry runner the generators + dryRunner := DryRunner(context.Background()) + if err := run(dryRunner, gens); err != nil { + if errors.Is(err, os.ErrNotExist) { + return sm, &dryRunError{err} } + return sm, err + } + if err := tracer.Err(); err != nil { + return sm, err + } - // fetch the source modification - sm = NewSourceModification() - for _, file := range dryRunner.Results().Files { - fileName := file.Name() - _, err := os.Stat(fileName) - - //nolint:gocritic - if os.IsNotExist(err) { - // if the file doesn't exist in the source, it means it has been created by the runner - sm.AppendCreatedFiles(fileName) - } else if err != nil { - return sm, err - } else { - // the file has been modified by the runner - sm.AppendModifiedFiles(fileName) - } - } + // fetch the source modification + sm = NewSourceModification() + for _, file := range dryRunner.Results().Files { + fileName := file.Name() + _, err := os.Stat(fileName) - // execute the modification with a wet runner - if err := run(genny.WetRunner(context.Background()), gen); err != nil { + //nolint:gocritic + if os.IsNotExist(err) { + // if the file doesn't exist in the source, it means it has been created by the runner + sm.AppendCreatedFiles(fileName) + } else if err != nil { return sm, err + } else { + // the file has been modified by the runner + sm.AppendModifiedFiles(fileName) } } + + // execute the modification with a wet runner + if err := run(genny.WetRunner(context.Background()), gens); err != nil { + return sm, err + } return sm, nil }