mukan-ignite/docs/versioned_docs/version-v29/07-packages/cosmosgen.md
Mukan Erkin Törük 26b204bd04
Some checks are pending
Docs Deploy / build_and_deploy (push) Waiting to run
Generate Docs / cli (push) Waiting to run
Generate Config Doc / cli (push) Waiting to run
Go formatting / go-formatting (push) Waiting to run
Check links / markdown-link-check (push) Waiting to run
Integration / pre-test (push) Waiting to run
Integration / test on (push) Blocked by required conditions
Integration / status (push) Blocked by required conditions
Lint / Lint Go code (push) Waiting to run
Test / test (ubuntu-latest) (push) Waiting to run
feat: fork Ignite CLI v29 as Mukan Ignite — remove cosmos-sdk restrictions
2026-05-11 03:31:37 +03:00

1.4 KiB

sidebar_position title slug
15 Code Generation (cosmosgen) /packages/cosmosgen

Code Generation (cosmosgen)

The cosmosgen package orchestrates multi-target code generation from protobuf sources, including Go code, TS clients, composables, and OpenAPI output.

For full API details, see the cosmosgen Go package documentation.

When to use

  • Run full generation pipelines from application services.
  • Configure selective outputs (Go only, TS only, OpenAPI only, etc.).
  • Check tool availability and maintain buf-related configuration.

Key APIs

  • Generate(ctx, cacheStorage, appPath, protoDir, goModPath, frontendPath, options...)
  • WithGoGeneration()
  • WithTSClientGeneration(out, tsClientRootPath, useCache)
  • WithOpenAPIGeneration(out, excludeList)
  • DepTools() []string

Example

package main

import (
	"context"
	"log"
	"os"
	"path/filepath"

	"github.com/ignite/cli/v29/ignite/pkg/cache"
	"github.com/ignite/cli/v29/ignite/pkg/cosmosgen"
)

func main() {
	storage, err := cache.NewStorage(filepath.Join(os.TempDir(), "ignite-cache.db"))
	if err != nil {
		log.Fatal(err)
	}

	err = cosmosgen.Generate(
		context.Background(),
		storage,
		".",
		"proto",
		"github.com/acme/my-chain",
		"./web",
		cosmosgen.WithGoGeneration(),
		cosmosgen.WithOpenAPIGeneration("./api/openapi.yml", nil),
	)
	if err != nil {
		log.Fatal(err)
	}
}