Skip to content

Commit

Permalink
Merge branch 'develop' into chore/hide-flutter
Browse files Browse the repository at this point in the history
  • Loading branch information
Alex Johnson authored Oct 26, 2022
2 parents cab65e2 + 70106bc commit 8db4472
Show file tree
Hide file tree
Showing 4 changed files with 49 additions and 17 deletions.
3 changes: 2 additions & 1 deletion changelog.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,9 @@

- [#2957](https://github.com/ignite/cli/pull/2957) Change generate commands to print the path to the generated code.
- [#2981](https://github.com/ignite/cli/issues/2981) Change CLI to also search chain binary in Go binary path.
- [#2991](https://github.com/ignite/cli/pull/2991) Hide `ignite scaffold flutter` command and remove functionality.
- [#2958](https://github.com/ignite/cli/pull/2958) Support absolute paths for client code generation config paths.
- [#2993](https://github.com/ignite/cli/pull/2993) Hide `ignite scaffold band` command and deprecate functionality.
- [#2991](https://github.com/ignite/cli/pull/2991) Hide `ignite scaffold flutter` command and remove functionality.

## [`v0.25.1`](https://github.com/ignite/cli/releases/tag/v0.25.1)

Expand Down
4 changes: 2 additions & 2 deletions ignite/pkg/cosmosgen/generate_openapi.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,6 @@ var openAPIOut = []string{
const specCacheNamespace = "generate.openapi.spec"

func generateOpenAPISpec(g *generator) error {
out := filepath.Join(g.appPath, g.o.specOut)

var (
specDirs []string
conf = swaggercombine.Config{
Expand Down Expand Up @@ -125,6 +123,8 @@ func generateOpenAPISpec(g *generator) error {
}
}

out := g.o.specOut

if !hasAnySpecChanged {
// In case the generated output has been changed
changed, err := dirchange.HasDirChecksumChanged(specCache, out, g.appPath, out)
Expand Down
25 changes: 21 additions & 4 deletions ignite/services/chain/generate.go
Original file line number Diff line number Diff line change
Expand Up @@ -138,8 +138,12 @@ func (c *Chain) Generate(
if targetOptions.isTSClientEnabled {
tsClientPath = targetOptions.tsClientPath
if tsClientPath == "" {
// TODO: Change to allow full paths in case TS client dir is not inside the app's dir?
tsClientPath = filepath.Join(c.app.Path, chainconfig.TSClientPath(conf))
tsClientPath = chainconfig.TSClientPath(conf)
}

// Non absolute TS client output paths must be treated as relative to the app directory
if !filepath.IsAbs(tsClientPath) {
tsClientPath = filepath.Join(c.app.Path, tsClientPath)
}

if err := os.MkdirAll(tsClientPath, 0o766); err != nil {
Expand All @@ -160,7 +164,7 @@ func (c *Chain) Generate(
vuexPath = defaultVuexPath
}

vuexPath = filepath.Join(c.app.Path, vuexPath, "generated")
vuexPath = c.joinGeneratedPath(vuexPath)
if err := os.MkdirAll(vuexPath, 0o766); err != nil {
return err
}
Expand All @@ -180,7 +184,7 @@ func (c *Chain) Generate(
dartPath = defaultDartPath
}

dartPath = filepath.Join(c.app.Path, dartPath, "generated")
dartPath = c.joinGeneratedPath(dartPath)
if err := os.MkdirAll(dartPath, 0o766); err != nil {
return err
}
Expand All @@ -200,6 +204,11 @@ func (c *Chain) Generate(
openAPIPath = defaultOpenAPIPath
}

// Non absolute OpenAPI paths must be treated as relative to the app directory
if !filepath.IsAbs(openAPIPath) {
openAPIPath = filepath.Join(c.app.Path, openAPIPath)
}

options = append(options, cosmosgen.WithOpenAPIGeneration(openAPIPath))
}

Expand Down Expand Up @@ -245,3 +254,11 @@ func (c *Chain) Generate(

return nil
}

func (c Chain) joinGeneratedPath(rootPath string) string {
if filepath.IsAbs(rootPath) {
return filepath.Join(rootPath, "generated")
}

return filepath.Join(c.app.Path, rootPath, "generated")
}
34 changes: 24 additions & 10 deletions ignite/services/scaffolder/scaffolder.go
Original file line number Diff line number Diff line change
Expand Up @@ -96,35 +96,49 @@ func protoc(ctx context.Context, cacheStorage cache.Storage, projectPath, gomodP
cosmosgen.IncludeDirs(conf.Build.Proto.ThirdPartyPaths),
}

// generate Typescript Client code as well if it is enabled or when the vuex store is being generated
// Generate Typescript client code if it's enabled or when Vuex stores are generated
if conf.Client.Typescript.Path != "" || conf.Client.Vuex.Path != "" {
tsClientRootPath := filepath.Join(projectPath, chainconfig.TSClientPath(conf))
if err := os.MkdirAll(tsClientRootPath, 0o766); err != nil {
tsClientPath := chainconfig.TSClientPath(conf)
if !filepath.IsAbs(tsClientPath) {
tsClientPath = filepath.Join(projectPath, tsClientPath)
}

if err := os.MkdirAll(tsClientPath, 0o766); err != nil {
return err
}

options = append(options,
cosmosgen.WithTSClientGeneration(
cosmosgen.TypescriptModulePath(tsClientRootPath),
tsClientRootPath,
cosmosgen.TypescriptModulePath(tsClientPath),
tsClientPath,
),
)
}

// generate Vuex code as well if it is enabled.
if conf.Client.Vuex.Path != "" {
storeRootPath := filepath.Join(projectPath, conf.Client.Vuex.Path, "generated")
vuexPath := conf.Client.Vuex.Path
if filepath.IsAbs(vuexPath) {
vuexPath = filepath.Join(vuexPath, "generated")
} else {
vuexPath = filepath.Join(projectPath, vuexPath, "generated")
}

options = append(options,
cosmosgen.WithVuexGeneration(
false,
cosmosgen.TypescriptModulePath(storeRootPath),
storeRootPath,
cosmosgen.TypescriptModulePath(vuexPath),
vuexPath,
),
)
}

if conf.Client.OpenAPI.Path != "" {
options = append(options, cosmosgen.WithOpenAPIGeneration(conf.Client.OpenAPI.Path))
openAPIPath := conf.Client.OpenAPI.Path
if !filepath.IsAbs(openAPIPath) {
openAPIPath = filepath.Join(projectPath, openAPIPath)
}

options = append(options, cosmosgen.WithOpenAPIGeneration(openAPIPath))
}

return cosmosgen.Generate(ctx, cacheStorage, projectPath, conf.Build.Proto.Path, options...)
Expand Down

0 comments on commit 8db4472

Please sign in to comment.