1"use strict";(globalThis.webpackChunkmy_website=globalThis.webpackChunkmy_website||[]).push([[2292],{15680(e,n,t){t.d(n,{xA:()=>p,yg:()=>m});var o=t(96540);function r(e,n,t){return n in e?Object.defineProperty(e,n,{value:t,enumerable:!0,configurable:!0,writable:!0}):e[n]=t,e}function a(e,n){var t=Object.keys(e);if(Object.getOwnPropertySymbols){var o=Object.getOwnPropertySymbols(e);n&&(o=o.filter((function(n){return Object.getOwnPropertyDescriptor(e,n).enumerable}))),t.push.apply(t,o)}return t}function i(e){for(var n=1;n<arguments.length;n++){var t=null!=arguments[n]?arguments[n]:{};n%2?a(Object(t),!0).forEach((function(n){r(e,n,t[n])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(t)):a(Object(t)).forEach((function(n){Object.defineProperty(e,n,Object.getOwnPropertyDescriptor(t,n))}))}return e}function l(e,n){if(null==e)return{};var t,o,r=function(e,n){if(null==e)return{};var t,o,r={},a=Object.keys(e);for(o=0;o<a.length;o++)t=a[o],n.indexOf(t)>=0||(r[t]=e[t]);return r}(e,n);if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(e);for(o=0;o<a.length;o++)t=a[o],n.indexOf(t)>=0||Object.prototype.propertyIsEnumerable.call(e,t)&&(r[t]=e[t])}return r}var s=o.createContext({}),c=function(e){var n=o.useContext(s),t=n;return e&&(t="function"==typeof e?e(n):i(i({},n),e)),t},p=function(e){var n=c(e.components);return o.createElement(s.Provider,{value:n},e.children)},g={inlineCode:"code",wrapper:function(e){var n=e.children;return o.createElement(o.Fragment,{},n)}},u=o.forwardRef((function(e,n){var t=e.components,r=e.mdxType,a=e.originalType,s=e.parentName,p=l(e,["components","mdxType","originalType","parentName"]),u=c(t),m=r,y=u["".concat(s,".").concat(m)]||u[m]||g[m]||a;return t?o.createElement(y,i(i({ref:n},p),{},{components:t})):o.createElement(y,i({ref:n},p))}));function m(e,n){var t=arguments,r=n&&n.mdxType;if("string"==typeof e||r){var a=t.length,i=new Array(a);i[0]=u;var l={};for(var s in n)hasOwnProperty.call(n,s)&&(l[s]=n[s]);l.originalType=e,l.mdxType="string"==typeof e?e:r,i[1]=l;for(var c=2;c<a;c++)i[c]=t[c];return o.createElement.apply(null,i)}return o.createElement.apply(null,t)}u.displayName="MDXCreateElement"},87147(e,n,t){t.r(n),t.d(n,{assets:()=>s,contentTitle:()=>i,default:()=>g,frontMatter:()=>a,metadata:()=>l,toc:()=>c});var o=t(58168),r=(t(96540),t(15680));const a={sidebar_position:15,title:"Code Generation (cosmosgen)",slug:"/packages/cosmosgen"},i="Code Generation (cosmosgen)",l={unversionedId:"packages/cosmosgen",id:"version-v30/packages/cosmosgen",title:"Code Generation (cosmosgen)",description:"The cosmosgen package orchestrates multi-target code generation from protobuf sources, including Go code, TS clients, composables, and OpenAPI output.",source:"@site/versioned_docs/version-v30/07-packages/cosmosgen.md",sourceDirName:"07-packages",slug:"/packages/cosmosgen",permalink:"/packages/cosmosgen",draft:!1,tags:[],version:"v30",sidebarPosition:15,frontMatter:{sidebar_position:15,title:"Code Generation (cosmosgen)",slug:"/packages/cosmosgen"},sidebar:"tutorialSidebar",previous:{title:"Buf Integration (cosmosbuf)",permalink:"/packages/cosmosbuf"},next:{title:"Using IGNITE\xae Apps",permalink:"/apps/using-apps"}},s={},c=[{value:"When to use",id:"when-to-use",level:2},{value:"Key APIs",id:"key-apis",level:2},{value:"Example",id:"example",level:2}],p={toc:c};function g(e){let{components:n,...t}=e;return(0,r.yg)("wrapper",(0,o.A)({},p,t,{components:n,mdxType:"MDXLayout"}),(0,r.yg)("h1",{id:"code-generation-cosmosgen"},"Code Generation (cosmosgen)"),(0,r.yg)("p",null,"The ",(0,r.yg)("inlineCode",{parentName:"p"},"cosmosgen")," package orchestrates multi-target code generation from protobuf sources, including Go code, TS clients, composables, and OpenAPI output."),(0,r.yg)("p",null,"For full API details, see the\n",(0,r.yg)("a",{parentName:"p",href:"https://pkg.go.dev/github.com/ignite/cli/v30/ignite/pkg/cosmosgen"},(0,r.yg)("inlineCode",{parentName:"a"},"cosmosgen")," Go package documentation"),"."),(0,r.yg)("h2",{id:"when-to-use"},"When to use"),(0,r.yg)("ul",null,(0,r.yg)("li",{parentName:"ul"},"Run full generation pipelines from application services."),(0,r.yg)("li",{parentName:"ul"},"Configure selective outputs (Go only, TS only, OpenAPI only, etc.)."),(0,r.yg)("li",{parentName:"ul"},"Check tool availability and maintain buf-related configuration.")),(0,r.yg)("h2",{id:"key-apis"},"Key APIs"),(0,r.yg)("ul",null,(0,r.yg)("li",{parentName:"ul"},(0,r.yg)("inlineCode",{parentName:"li"},"Generate(ctx, cacheStorage, appPath, protoDir, goModPath, frontendPath, options...)")),(0,r.yg)("li",{parentName:"ul"},(0,r.yg)("inlineCode",{parentName:"li"},"WithGoGeneration()")),(0,r.yg)("li",{parentName:"ul"},(0,r.yg)("inlineCode",{parentName:"li"},"WithTSClientGeneration(out, tsClientRootPath, useCache)")),(0,r.yg)("li",{parentName:"ul"},(0,r.yg)("inlineCode",{parentName:"li"},"WithOpenAPIGeneration(out, excludeList)")),(0,r.yg)("li",{parentName:"ul"},(0,r.yg)("inlineCode",{parentName:"li"},"DepTools() []string"))),(0,r.yg)("h2",{id:"example"},"Example"),(0,r.yg)("pre",null,(0,r.yg)("code",{parentName:"pre",className:"language-go"},'package main\n\nimport (\n "context"\n "log"\n "os"\n "path/filepath"\n\n "github.com/ignite/cli/v30/ignite/pkg/cache"\n "github.com/ignite/cli/v30/ignite/pkg/cosmosgen"\n)\n\nfunc main() {\n storage, err := cache.NewStorage(filepath.Join(os.TempDir(), "ignite-cache.db"))\n if err != nil {\n log.Fatal(err)\n }
1\n\n err = cosmosgen.Generate(\n context.Background(),\n storage,\n ".",\n "proto",\n "github.com/acme/my-chain",\n "./web",\n cosmosgen.WithGoGeneration(),\n cosmosgen.WithOpenAPIGeneration("./api/openapi.yml", nil),\n )\n if err != nil {\n log.Fatal(err)\n }\n}\n')))}g.isMDXComponent=!0}}]);
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.