[{"data":1,"prerenderedAt":596,"buildId":597},["ShallowReactive",2],{"page:\u002Fdocs\u002F5.x\u002Freference\u002Fcommands\u002Finit":3},{"id":4,"title":5,"body":6,"description":579,"extension":580,"frontmatter":581,"heading":15,"meta":587,"navigation":589,"order":584,"path":590,"seo":591,"sitemap":592,"source":593,"stem":594,"__hash__":595},"docs\u002Fdocs\u002F5.x\u002Freference\u002Fcommands\u002Finit.md","kubb init - Set up Kubb in a project",{"type":7,"value":8,"toc":561},"minimark",[9,21,43,48,224,228,344,352,356,359,371,374,392,421,425,475,479,482,488,552],[10,11,12,16,17,20],"p",{},[13,14,15],"code",{},"kubb init"," sets up Kubb in your project. It asks three questions, shows you the config, then installs Kubb, writes ",[13,18,19],{},"kubb.config.ts",", and runs the first generation.",[22,23,28],"pre",{"language":24,"filename":25,"code":26,"class":27},"shell","Terminal","npx kubb init","highlights",[13,29,31],{"class":30},"language-shell",[32,33,36,40],"span",{"class":34,"style":35},"line","display: inline",[32,37,39],{"style":38},"color:#6f42c1;--hls-dark:#b392f0","npx ",[32,41,15],{"style":42},"color:#24292e;--hls-dark:#e1e4e8",[44,45,47],"h2",{"id":46},"what-the-wizard-does","What the wizard does",[49,50,52,57,70,98,102,170,173,177,189,203,207],"steps",{"level":51},"3",[53,54,56],"h3",{"id":55},"detect-the-project","Detect the project",[10,58,59,60,65,66,69],{},"Kubb finds your package manager by the rules in ",[61,62,64],"a",{"href":63},"\u002Fdocs\u002F5.x\u002Freference\u002Fcommands#project-files","Project files",". Without a ",[13,67,68],{},"package.json",", it offers to create one.",[10,71,72,73,76,77,80,81,84,85,88,89,92,93,97],{},"It looks for ",[13,74,75],{},"openapi*"," or ",[13,78,79],{},"swagger*"," files (",[13,82,83],{},".yaml",", ",[13,86,87],{},".yml",", or ",[13,90,91],{},".json",") up to three folders deep. See ",[61,94,96],{"href":95},"#init-spec-detection","Spec detection in kubb init",".",[53,99,101],{"id":100},"ask-three-questions","Ask three questions",[103,104,105,121],"table",{},[106,107,108],"thead",{},[109,110,111,115,118],"tr",{},[112,113,114],"th",{},"Question",[112,116,117],{},"Choices",[112,119,120],{},"Default",[122,123,124,139,157],"tbody",{},[109,125,126,130,133],{},[127,128,129],"td",{},"Which spec to read",[127,131,132],{},"A file it found, a URL, or another file",[127,134,135,136],{},"The first file found, else ",[13,137,138],{},".\u002Fopenapi.yaml",[109,140,141,149,152],{},[127,142,143,144,148],{},"Which ",[61,145,147],{"href":146},"\u002Fextensions\u002Fkind\u002Fplugins","plugins"," to add",[127,150,151],{},"The registry plugins that support your Kubb and Node.js versions",[127,153,154],{},[13,155,156],{},"plugin-ts",[109,158,159,162,165],{},[127,160,161],{},"Output folder",[127,163,164],{},"Any path",[127,166,167],{},[13,168,169],{},".\u002Fsrc\u002Fgen",[10,171,172],{},"Kubb does not pick plugins from your framework or installed libraries.",[53,174,176],{"id":175},"review-the-config","Review the config",[10,178,179,180,184,185,188],{},"Kubb checks each plugin's ",[61,181,183],{"href":182},"\u002Fdocs\u002F5.x\u002Freference\u002Fkit\u002Fmanifest","extension manifest",". When a plugin needs another one you did not pick, such as a client plugin next to ",[13,186,187],{},"plugin-react-query",", the wizard names it and asks again.",[10,190,191,192,194,195,199,200,202],{},"Then it shows you ",[13,193,19],{}," and the packages to install. Pick ",[196,197,198],"strong",{},"Change a choice"," to answer again. If ",[13,201,19],{}," exists, Kubb asks before it overwrites it.",[53,204,206],{"id":205},"install-write-and-generate","Install, write, and generate",[10,208,209,210,213,214,216,217,220,221,223],{},"Kubb installs ",[13,211,212],{},"kubb"," at the CLI version and each plugin at its registry pin. It writes ",[13,215,19],{},", adds a ",[13,218,219],{},"\"generate\": \"kubb generate\""," script when ",[13,222,68],{}," has none, and runs the first generation.",[44,225,227],{"id":226},"options","Options",[103,229,230,245],{},[106,231,232],{},[109,233,234,237,240,242],{},[112,235,236],{},"Flag",[112,238,239],{},"Alias",[112,241,120],{},[112,243,244],{},"What it does",[122,246,247,269,286,303,328],{},[109,248,249,254,259,264],{},[127,250,251],{},[13,252,253],{},"--yes",[127,255,256],{},[13,257,258],{},"-y",[127,260,261],{},[13,262,263],{},"false",[127,265,266,267,97],{},"Skip every prompt and the review, and use the defaults. Overwrites an existing ",[13,268,19],{},[109,270,271,276,281,283],{},[127,272,273],{},[13,274,275],{},"--input \u003Cpath>",[127,277,278],{},[13,279,280],{},"-i",[127,282],{},[127,284,285],{},"Spec path or URL. Skips the spec question.",[109,287,288,293,298,300],{},[127,289,290],{},[13,291,292],{},"--output \u003Cpath>",[127,294,295],{},[13,296,297],{},"-o",[127,299],{},[127,301,302],{},"Output folder. Skips the output question.",[109,304,305,310,312,314],{},[127,306,307],{},[13,308,309],{},"--plugins \u003Cids>",[127,311],{},[127,313],{},[127,315,316,317,321,322,325,326,97],{},"Comma-separated ",[61,318,320],{"href":319},"\u002Fdocs\u002F5.x\u002Freference\u002Fcommands#ids","registry ids"," or short names, such as ",[13,323,324],{},"ts,zod",". Skips the plugin question. An id the registry does not list stops ",[13,327,15],{},[109,329,330,335,337,341],{},[127,331,332],{},[13,333,334],{},"--dry-run",[127,336],{},[127,338,339],{},[13,340,263],{},[127,342,343],{},"Run the wizard without installing packages, writing files, or generating.",[10,345,346,347,349,350,97],{},"Each value flag skips only its own question. Pass all three to also skip the review. Without ",[13,348,253],{},", Kubb still asks before it overwrites ",[13,351,19],{},[44,353,355],{"id":354},"examples","Examples",[10,357,358],{},"Run with the defaults and no prompts:",[22,360,362],{"language":24,"filename":25,"code":361,"class":27},"npx kubb init --yes",[13,363,364],{"class":30},[32,365,366,368],{"class":34,"style":35},[32,367,39],{"style":38},[32,369,370],{"style":42},"kubb init --yes",[10,372,373],{},"Set the spec, output folder, and plugins, with no prompts:",[22,375,377],{"language":24,"filename":25,"code":376,"class":27},"npx kubb init --yes --input .\u002Fopenapi.yaml --plugins ts,zod --output src\u002Fapi",[13,378,379],{"class":30},[32,380,381,383,386,389],{"class":34,"style":35},[32,382,39],{"style":38},[32,384,385],{"style":42},"kubb init --yes --input .\u002Fopenapi.yaml --plugins ts",[32,387,388],{"style":42},",",[32,390,391],{"style":42},"zod --output src\u002Fapi",[22,393,397],{"language":394,"filename":395,"code":396,"class":27},"text","Output","✓ Installed kubb @kubb\u002Fplugin-ts @kubb\u002Fplugin-zod with npm\n✓ Wrote kubb.config.ts\n✓ Generated 84 files in src\u002Fapi\nKubb is set up. Run npm run generate after changing the spec.",[13,398,400,405,406,405,411,405,416],{"class":399},"language-text",[32,401,402],{"class":34,"style":35},[32,403,404],{"style":42},"✓ Installed kubb @kubb\u002Fplugin-ts @kubb\u002Fplugin-zod with npm","\n",[32,407,408],{"class":34,"style":35},[32,409,410],{"style":42},"✓ Wrote kubb.config.ts",[32,412,413],{"class":34,"style":35},[32,414,415],{"style":42},"✓ Generated 84 files in src\u002Fapi",[32,417,418],{"class":34,"style":35},[32,419,420],{"style":42},"Kubb is set up. Run npm run generate after changing the spec.",[44,422,424],{"id":423},"exit-codes","Exit codes",[103,426,427,437],{},[106,428,429],{},[109,430,431,434],{},[112,432,433],{},"Code",[112,435,436],{},"When",[122,438,439,449,459],{},[109,440,441,446],{},[127,442,443],{},[13,444,445],{},"0",[127,447,448],{},"Kubb is set up, or you canceled a prompt.",[109,450,451,456],{},[127,452,453],{},[13,454,455],{},"1",[127,457,458],{},"The first generation fails. The setup stays.",[109,460,461,465],{},[127,462,463],{},[13,464,455],{},[127,466,467,468,470,471,474],{},"A plugin misses a dependency (with ",[13,469,253],{}," or all three value flags), a ",[13,472,473],{},"--plugins"," id is not in the registry, the registry cannot be read, or the install fails.",[44,476,478],{"id":477},"less-common-cases","Less common cases",[53,480,96],{"id":481},"init-spec-detection",[10,483,484,485,487],{},"On start, ",[13,486,15],{}," detects the package manager and looks for a spec.",[489,490,491,514,519,533,549],"ul",{},[492,493,494,495,84,498,84,501,88,504,507,508,511,512,97],"li",{},"It reads the package manager (",[13,496,497],{},"npm",[13,499,500],{},"pnpm",[13,502,503],{},"yarn",[13,505,506],{},"bun",") from the ",[13,509,510],{},"packageManager"," field or a lockfile, else ",[13,513,497],{},[492,515,516,517,69],{},"Without a ",[13,518,68],{},[492,520,521,522,76,524,526,527,84,529,88,531,97],{},"It looks up to three folders deep for ",[13,523,75],{},[13,525,79],{}," files ending in ",[13,528,83],{},[13,530,87],{},[13,532,91],{},[492,534,535,536,84,539,84,542,84,545,548],{},"It skips ",[13,537,538],{},"node_modules",[13,540,541],{},"dist",[13,543,544],{},"build",[13,546,547],{},"coverage",", and hidden folders.",[492,550,551],{},"It shows the version and operation count of the first one.",[10,553,554,555,97],{},"For a spec with another name or a deeper path, pass it with ",[61,556,558],{"href":557},"#options",[13,559,560],{},"--input",{"title":562,"searchDepth":563,"depth":563,"links":564},"",5,[565,573,574,575,576],{"id":46,"depth":566,"text":47,"children":567},2,[568,570,571,572],{"id":55,"depth":569,"text":56},3,{"id":100,"depth":569,"text":101},{"id":175,"depth":569,"text":176},{"id":205,"depth":569,"text":206},{"id":226,"depth":566,"text":227},{"id":354,"depth":566,"text":355},{"id":423,"depth":566,"text":424},{"id":477,"depth":566,"text":478,"children":577},[578],{"id":481,"depth":569,"text":96},"The init command detects your spec and package manager, asks for plugins and an output folder, then installs Kubb and writes kubb.config.ts.","md",{"layout":582,"title":5,"description":579,"outline":583,"order":584,"navigation":585},"doc",[566,569],1,{"title":15,"icon":586},"i-iconoir-magic-wand",{"layout":582,"outline":588},[566,569],{"title":15,"icon":586},"\u002Fdocs\u002F5.x\u002Freference\u002Fcommands\u002Finit",{"title":5,"description":579},{"loc":590},"kubb-labs\u002Fkubb\u002Fdocs\u002F5.x\u002Freference\u002Fcommands\u002Finit.md","docs\u002F5.x\u002Freference\u002Fcommands\u002Finit","M4kMntAKRrGrpSbPbF9ri0xcg6VuSJNMq--zpZU_oqA",1795727676852,"1b64b1eb-29b7-4f90-ad41-6f24721e1669"]