@nest-arch/tui 0.1.37 → 0.1.39

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/cli.js CHANGED
@@ -1,2 +1,2 @@
1
1
  #!/usr/bin/env node
2
- import"./index-BPbtxfGB.js";import"react/jsx-runtime";import"ink";import"react";import"ink-text-input";import"@t3-oss/env-nextjs";import"zod";import"node:fs";import"node:os";import"node:path";import"node:child_process";import"node:util";import"node:fs/promises";import"handlebars";import"ts-morph";import"open";
2
+ import"./index-DuMVjfjC.js";import"react/jsx-runtime";import"ink";import"react";import"ink-text-input";import"@t3-oss/env-nextjs";import"zod";import"node:fs";import"node:os";import"node:path";import"node:child_process";import"node:fs/promises";import"node:util";import"handlebars";import"ts-morph";import"open";
@@ -1,4 +1,4 @@
1
- var i=Object.defineProperty;var r=(e,a)=>i(e,"name",{value:a,configurable:!0});import{e as t}from"./index-BPbtxfGB.js";import"react/jsx-runtime";import"ink";import"react";import"ink-text-input";import"@t3-oss/env-nextjs";import"zod";import"node:fs";import"node:os";import"node:path";import"node:child_process";import"node:util";import"node:fs/promises";import"handlebars";import"ts-morph";import"open";function s(e){return[`pnpm create nest-arch@latest ${e.projectName}`,`--package-manager ${e.packageManager}`,`--http-provider ${e.httpProvider}`,`--project-type ${e.projectType}`,`--architecture ${e.architecture}`,`--database ${e.database.length>0?e.database.join(" "):"none"}`,`--orm ${e.orm.length>0?e.orm.join(" "):"none"}`,`--api ${e.api.length>0?e.api.join(" "):"none"}`,`--auth ${e.auth}`,`--extras ${e.extras.length>0?e.extras.join(" "):"none"}`,`--microservices ${e.microservices.length>0?e.microservices.join(" "):"none"}`,`--addons ${e.addons.length>0?e.addons.join(" "):"none"}`,e.initGit?"--git":"--no-git"].join(" ")}r(s,"buildReproducibleCommand");function p(e){return{$schema:t.NEST_ARCH_SCHEMA_URL,addons:e.addons,api:e.api,architecture:e.architecture,auth:e.auth,createdAt:new Date().toISOString(),database:e.database,description:e.description,extras:e.extras,httpProvider:e.httpProvider,initGit:e.initGit,microservices:e.microservices,orm:e.orm,packageManager:e.packageManager,projectName:e.projectName,projectType:e.projectType,reproducibleCommand:s(e),version:t.NEST_ARCH_VERSION}}r(p,"buildMetadata");function o(e){return`${["// nest-arch","//","// Project scaffolding tool for NestJS applications","//","// This file records the options used to generate this project.","// It can be used to reproduce the exact same project setup.","// This file is safe to delete.",""].join(`
1
+ var i=Object.defineProperty;var r=(e,a)=>i(e,"name",{value:a,configurable:!0});import{e as t}from"./index-DuMVjfjC.js";import"react/jsx-runtime";import"ink";import"react";import"ink-text-input";import"@t3-oss/env-nextjs";import"zod";import"node:fs";import"node:os";import"node:path";import"node:child_process";import"node:fs/promises";import"node:util";import"handlebars";import"ts-morph";import"open";function s(e){return[`pnpm create nest-arch@latest ${e.projectName}`,`--package-manager ${e.packageManager}`,`--http-provider ${e.httpProvider}`,`--project-type ${e.projectType}`,`--architecture ${e.architecture}`,`--database ${e.database.length>0?e.database.join(" "):"none"}`,`--orm ${e.orm.length>0?e.orm.join(" "):"none"}`,`--api ${e.api.length>0?e.api.join(" "):"none"}`,`--auth ${e.auth}`,`--extras ${e.extras.length>0?e.extras.join(" "):"none"}`,`--microservices ${e.microservices.length>0?e.microservices.join(" "):"none"}`,`--addons ${e.addons.length>0?e.addons.join(" "):"none"}`,e.initGit?"--git":"--no-git"].join(" ")}r(s,"buildReproducibleCommand");function p(e){return{$schema:t.NEST_ARCH_SCHEMA_URL,addons:e.addons,api:e.api,architecture:e.architecture,auth:e.auth,createdAt:new Date().toISOString(),database:e.database,description:e.description,extras:e.extras,httpProvider:e.httpProvider,initGit:e.initGit,microservices:e.microservices,orm:e.orm,packageManager:e.packageManager,projectName:e.projectName,projectType:e.projectType,reproducibleCommand:s(e),version:t.NEST_ARCH_VERSION}}r(p,"buildMetadata");function o(e){return`${["// nest-arch","//","// Project scaffolding tool for NestJS applications","//","// This file records the options used to generate this project.","// It can be used to reproduce the exact same project setup.","// This file is safe to delete.",""].join(`
2
2
  `)+JSON.stringify(e,null,2)}
3
3
  `}r(o,"serializeMetadata");function n(){return`${JSON.stringify({$schema:"http://json-schema.org/draft-07/schema#",description:"NestArch project configuration metadata file schema",properties:{$schema:{type:"string"},addons:{items:{enum:["agent-skills","husky","ultracite","nestjs-zod","scalar-ui"]},type:"array"},api:{items:{enum:["rest","trpc","graphql"]},type:"array"},architecture:{enum:["nest-api","nest-gateway","nest-microservice"]},auth:{enum:["jwt","passport","better-auth","none"]},createdAt:{format:"date-time",type:"string"},database:{items:{enum:["postgresql","mysql","sqlite","mongodb"]},type:"array"},description:{type:"string"},extras:{items:{enum:["docker","health-check","rate-limiting","swagger","packages/shared"]},type:"array"},httpProvider:{enum:["express","fastify"]},initGit:{type:"boolean"},microservices:{items:{enum:["redis","mqtt","nats","rabbitmq","kafka","grpc"]},type:"array"},orm:{items:{enum:["prisma","typeorm","drizzle"]},type:"array"},packageManager:{enum:["pnpm","npm","yarn","bun"]},projectName:{type:"string"},projectType:{enum:["single","monorepo"]},reproducibleCommand:{type:"string"},version:{type:"string"}},required:["version","createdAt","reproducibleCommand","projectName","packageManager","httpProvider","projectType","architecture","database","orm","api","auth","extras","microservices","addons","initGit"],title:"NestArchMetadata",type:"object"},null,2)}
4
4
  `}r(n,"buildSchemaContent");export{p as buildMetadata,n as buildSchemaContent,o as serializeMetadata};
@@ -0,0 +1,51 @@
1
+ var Ot=Object.defineProperty;var p=(t,e)=>Ot(t,"name",{value:e,configurable:!0});import{jsx as i,jsxs as g,Fragment as D}from"react/jsx-runtime";import{Box as f,Text as c,useInput as ie,useStdout as rt,render as Dt,useApp as Mt}from"ink";import{useState as N,useEffect as ue,useRef as Me,useMemo as V,useCallback as v}from"react";import It from"ink-text-input";import{createEnv as Gt}from"@t3-oss/env-nextjs";import{z as ce}from"zod";import{existsSync as je,readFileSync as $t,mkdirSync as Ft,writeFileSync as Lt}from"node:fs";import{homedir as st}from"node:os";import I,{join as Y}from"node:path";import{execFile as Ut,exec as zt}from"node:child_process";import W,{readFile as ve,writeFile as de,rm as Ht}from"node:fs/promises";import{promisify as nt}from"node:util";import L from"handlebars";import"ts-morph";import Wt from"open";const it="Nest Arch",we="v0.1.39",ke="The comfy way to build NestJS projects",S="#e54545",P="#A0A0A0",Se="#6B6B6B",R="#E5E5E5",U="#61AFEF",me="#3A3A3A",Bt="#7FD99A",Ee="#E8C468",Pe="#e96142ff",he=p(({borderTop:t=!0})=>i(f,{borderStyle:"single",borderBottom:!t,borderLeft:!1,borderRight:!1,borderTop:t,borderColor:me,height:1,width:"full"}),"Divider"),Jt=` \uFF0Fl\u3001
2
+ \uFF08\uFF9F\uFF64 \uFF61\uFF17
3
+ l\u3001\uFF9E ~\u30FD
4
+ \u3058\u3057(_,)\u30CE
5
+ `,Ie=` ,-. _,---._ __ /\\
6
+ / ) .-' \`./ / \\
7
+ ( ( ,' \` / /|
8
+ \\ \`-" \\'\\ / |
9
+ \`. , \\ \\ / |
10
+ /\`. ,'-\`----Y |
11
+ ( ; | '
12
+ | ,-. ,-' Angel's | /
13
+ | | ( | Stuff | /
14
+ ) | \\ \`.___________|/
15
+ \`--' \`--'
16
+ `,qt=p(t=>t>=4352&&t<=4447||t>=9001&&t<=9002||t>=11904&&t<=42191&&t!==12351||t>=44032&&t<=55203||t>=63744&&t<=64255||t>=65040&&t<=65049||t>=65072&&t<=65135||t>=65281&&t<=65376||t>=65504&&t<=65510||t>=131072&&t<=196605||t>=196608&&t<=262141,"isFullwidthCodePoint"),at=p(t=>{let e=0;for(const r of t){const s=r.codePointAt(0)??0;e+=qt(s)?2:1}return e},"getDisplayWidth"),Vt=2,ot=[0,1,2,3,2,1],ct=["",".","..","..."],lt=p(({message:t,isError:e})=>{const[r,s]=N(0),[o,n]=N(0);ue(()=>{const m=setInterval(()=>{s(w=>(w+1)%ot.length)},200),y=setInterval(()=>{n(w=>(w+1)%ct.length)},400);return()=>{clearInterval(m),clearInterval(y)}},[]);const a=Jt.trimEnd().split(`
17
+ `),l=Math.max(...a.map(at)),u=ot[r];return g(f,{flexDirection:"column",paddingX:2,children:[i(f,{flexDirection:"column",children:a.map((m,y)=>{const w=at(m),E=y===0||y===a.length-1,M=l-w+Vt-(E?1:0),j=y===u;return g(c,{color:S,children:[m," ".repeat(M),j?i(c,{color:Ee,children:"\u25CF"}):" "]},y)})}),g(c,{color:e?R:P,children:[t,e?"":ct[o]]})]})},"ScaffoldingAnimation"),Ge=p(({action:t="select",showBack:e=!1})=>g(c,{children:[t==="select"||t==="multi-select"?i(c,{color:P,children:"Use \u2191/\u2193 to navigate \u2022 "}):null,i(c,{color:P,children:t==="confirm"?g(D,{children:[i(c,{color:R,children:"Enter "}),"to confirm"]}):t==="multi-select"?g(D,{children:[i(c,{color:R,children:"Space "}),"to toggle \u2022",i(c,{color:R,children:" Enter "}),"to confirm"]}):g(D,{children:[i(c,{color:R,children:"Enter "}),"to select"]})}),g(c,{color:P,children:[e?g(D,{children:[" ","\u2022",i(c,{color:R,children:" Ctrl+B "}),"to go back"]}):"",g(D,{children:[" ","\u2022",i(c,{color:R,children:" Ctrl+C "}),"to exit"]})]})]}),"StatusBar"),pt=p(({architecture:t,projectName:e,packageManager:r,isGitInitialized:s,outputDir:o})=>i(f,{flexDirection:"column",children:g(f,{flexDirection:"column",marginTop:1,children:[i(c,{color:Bt,bold:!0,children:"\u2714 Project scaffold completed successfully!"}),g(f,{marginTop:1,children:[i(c,{color:R,children:"Project: "}),i(c,{color:U,bold:!0,children:e})]}),g(f,{children:[i(c,{color:R,children:"Architecture: "}),i(c,{color:U,bold:!0,children:t})]}),o?g(f,{children:[i(c,{color:R,children:"Location: "}),i(c,{color:U,bold:!0,children:o})]}):null,s?i(f,{marginTop:1,children:i(c,{color:P,children:"Git repository initialized"})}):null,g(f,{flexDirection:"column",borderStyle:"round",borderColor:S,paddingX:2,paddingY:1,marginTop:1,width:void 0,children:[i(c,{color:R,bold:!0,children:"\u{1F680} NEXT STEPS"}),i(f,{height:1}),i(c,{color:R,children:"1. Move into the project directory:"}),i(c,{color:U,bold:!0,children:` cd ${e}`}),i(f,{height:1}),i(c,{color:R,children:"2. Install dependencies:"}),i(c,{color:U,bold:!0,children:` ${r} install`}),i(f,{height:1}),i(c,{color:R,children:"3. Start development server:"}),i(c,{color:U,bold:!0,children:` ${r} run dev`})]}),i(f,{marginTop:1,children:i(c,{color:P,children:"(Press enter to exit)"})})]})}),"DoneStep"),Yt=100,Ae=p(t=>{const e=Me(0);ie((r,s)=>{if(s.upArrow||s.downArrow||s.leftArrow||s.rightArrow||r==="k"||r==="j"||r==="h"||r==="l"){const n=Date.now();if(n-e.current<Yt)return;e.current=n}t(r,s)})},"useArrowSelect"),Z=p(({initialSelected:t,onConfirm:e,onChange:r,options:s,prompt:o,minified:n=!1})=>{const a=V(()=>new Set(s.map(k=>k.value)),[s]),l=v(k=>k.filter(A=>a.has(A)),[a]),[u,m]=N(0),[y,w]=N(()=>l(t)),E=Me(y);E.current=y;const M=Me(r);M.current=r,ue(()=>{const k=l(t);w(k),m(0),M.current?.(k)},[t,l]);const j=v(k=>y.includes(k),[y]),se=v(k=>{const A=s[k];A&&w(C=>{const H=C.includes(A.value)?C.filter(B=>B!==A.value):[...C,A.value];return E.current=H,r?.(H),H})},[s,r]),z=v(()=>{e(E.current)},[e]),$=s.length>16,F=$?Math.ceil(s.length/2):s.length;Ae((k,A)=>{A.upArrow||k==="k"?m(C=>(C-1+s.length)%s.length):A.downArrow||k==="j"?m(C=>(C+1)%s.length):$&&(A.leftArrow||k==="h")?m(C=>(C-F+s.length)%s.length):$&&(A.rightArrow||k==="l")?m(C=>(C+F)%s.length):A.return?z():(k===" "||k==="x")&&se(u)});const K=y.length,X=p((k,A)=>{const C=j(k.value),H=A===u,B=C?"\u25CF":"\u25CB";return g(f,{flexDirection:"column",children:[i(c,{children:H?g(D,{children:[i(c,{color:S,children:"> "}),i(c,{color:C?S:P,children:`${B} `}),i(c,{color:C?S:R,children:k.label})]}):g(D,{children:[i(c,{color:C?S:P,children:` ${B}`}),i(c,{color:Se,children:` ${k.label}`})]})}),H&&!$?g(c,{color:P,children:[" ",k.description]}):null]},k.value)},"renderOption");let te;return $||(te=n?0:1),g(f,{flexDirection:"column",children:[i(c,{color:P,children:o}),i(c,{color:Ee,children:K===0?"No options selected yet \u2014 pick what you need":`${K} selected`}),i(f,{marginTop:1,flexDirection:$?"row":"column",rowGap:te,columnGap:$?4:void 0,overflow:"hidden",children:$?g(D,{children:[i(f,{flexDirection:"column",rowGap:n?0:1,flexGrow:1,flexBasis:0,children:s.slice(0,F).map((k,A)=>X(k,A))}),i(f,{flexDirection:"column",rowGap:n?0:1,flexGrow:1,flexBasis:0,children:s.slice(F).map((k,A)=>X(k,A+F))})]}):s.map((k,A)=>X(k,A))})]})},"MultiSelectStep"),ut="my-nest-app",dt=64,Kt=/^[a-z][a-z0-9-]*$/u;function ae(t){return t.trim()||ut}p(ae,"resolveProjectName");function Te(t){const e=t.trim();return e?e.length>dt?`Project name must be at most ${dt} characters`:Kt.test(e)?null:"Use lowercase letters, numbers, and hyphens; must start with a letter":null}p(Te,"validateProjectName");const mt=p(({error:t,onChange:e,onSubmit:r,value:s})=>(ie((o,n)=>{n.return&&r()}),g(f,{flexDirection:"column",children:[i(c,{color:P,children:"Enter a name for your project"}),g(f,{marginTop:1,flexDirection:"row",alignItems:"center",columnGap:1,children:[i(c,{color:R,children:"Project name:"}),i(It,{placeholder:ut,value:s,onChange:e})]}),t?i(c,{color:S,children:t}):null]})),"ProjectNameStep"),ee=p(({onConfirm:t,options:e,prompt:r})=>{const[s,o]=N(0),n=v(()=>{const a=e[s];a&&t(a.value)},[t,e,s]);return Ae((a,l)=>{l.upArrow||a==="k"?o(u=>(u-1+e.length)%e.length):l.downArrow||a==="j"?o(u=>(u+1)%e.length):l.return&&n()}),g(f,{flexDirection:"column",children:[i(c,{color:P,children:r}),i(f,{marginTop:1,flexDirection:"column",rowGap:1,children:e.map((a,l)=>{const u=l===s;return g(f,{flexDirection:"column",children:[i(c,{children:u?g(D,{children:[i(c,{color:S,children:"> "}),i(c,{color:S,children:a.label})]}):i(c,{color:Se,children:` ${a.label}`})}),u?i(c,{color:P,children:a.description}):null]},a.value)})})]})},"SingleSelectStep"),ht=[{description:"Fast, disk-efficient package manager (recommended)",label:"pnpm",value:"pnpm"},{description:"Default Node.js package manager",label:"npm",value:"npm"},{description:"Classic alternative with workspaces support",label:"yarn",value:"yarn"},{description:"A superfast Node.js-compatible package manager",label:"bun",value:"bun"}],$e=[{description:"The modern, all-in-one toolchain written in Rust",label:"Biome",value:"biome"},{description:"The fastest linter available, 50-100x faster than ESLint",label:"Oxlint + Oxfmt",value:"oxlint-oxfmt"},{description:"No formatter and no linter. Welcome to the jungle",label:"(None)",value:"none"}],gt=[{description:"Default NestJS HTTP adapter",label:"Express",value:"express"},{description:"High-performance HTTP adapter",label:"Fastify",value:"fastify"}],ft=[{description:"Standalone NestJS application",label:"Single project",value:"single"},{description:"Multiple apps and shared packages",label:"Monorepo (Turborepo)",value:"monorepo"}],yt=[{description:"Standard REST or GraphQL API application",label:"NestJS API",value:"nest-api"},{description:"Gateway routing for microservices (monorepo only)",label:"NestJS API Gateway",value:"nest-gateway"},{description:"Message-based or RPC microservice",label:"NestJS Microservice",value:"nest-microservice"}],bt=[{description:"Relational database with strong ecosystem",label:"PostgreSQL",value:"postgresql"},{description:"Popular relational database",label:"MySQL",value:"mysql"},{description:"Embedded database for local development",label:"SQLite",value:"sqlite"},{description:"Document database",label:"MongoDB",value:"mongodb"}],Fe=[{description:"Type-safe ORM with schema and migrations",label:"Prisma",value:"prisma"},{description:"Decorator-based ORM for TypeScript",label:"TypeORM",value:"typeorm"},{description:"Lightweight SQL ORM (not available with MongoDB)",label:"Drizzle",value:"drizzle"}],jt=[{description:"RESTful HTTP endpoints",label:"REST",value:"rest"},{description:"End-to-end typesafe APIs",label:"tRPC",value:"trpc"},{description:"GraphQL schema and resolvers",label:"GraphQL",value:"graphql"}],vt=[{description:"No authentication scaffolding",label:"None",value:"none"},{description:"JSON Web Token authentication",label:"JWT",value:"jwt"},{description:"Flexible authentication middleware",label:"Passport",value:"passport"},{description:"Modern auth library integration",label:"Better Auth",value:"better-auth"}],Le=[{description:"Dockerfile and docker-compose setup",label:"Docker",value:"docker"},{description:"Terminus health check endpoints",label:"Health Check",value:"health-check"},{description:"Request throttling middleware",label:"Rate Limiting",value:"rate-limiting"},{description:"OpenAPI documentation",label:"Swagger",value:"swagger"},{description:"Shared packages for API types in a monorepo",label:"packages/shared",value:"packages/shared"}],Ue=[{description:"Cursor agent skills library (.agents/skills)",label:"Agent Skills",value:"agent-skills"},{description:"Git hooks for pre-commit checks",label:"Husky",value:"husky"},{description:"Configurate ultracite for your developer tools",label:"Ultracite",value:"ultracite"},{description:"Zod-based DTO validation",label:"NestJS-Zod",value:"nestjs-zod"},{description:"Modern OpenAPI documentation UI",label:"Scalar UI (Recommended)",value:"scalar-ui"}],Qt=[{description:"Pub/sub or streaming protocol",label:"Redis",value:"redis"},{description:"Lightweight MQTT messaging",label:"MQTT",value:"mqtt"},{description:"Cloud-native messaging broker",label:"NATS",value:"nats"},{description:"Enterprise messaging with RabbitMQ",label:"RabbitMQ",value:"rabbitmq"},{description:"Highly scalable Kafka streaming",label:"Kafka",value:"kafka"},{description:"RPC-style gRPC communication",label:"gRPC",value:"grpc"}],wt=[{description:"Run git init and create initial commit",label:"Yes",value:"yes"},{description:"Skip git initialization",label:"No",value:"no"}],Xt=[{description:"Universal (creates .vscode/settings.json for Visual Studio Code, Cursor, Windsurf, and more)",label:"Universal",value:"universal"},{description:"Zed (creates .zed/settings.json)",label:"Zed",value:"zed"}],Zt=[{description:"Universal (creates AGENTS.md for Codex, Jules, Devin, and more)",label:".agents (Universal)",value:"universal"},{description:"Claude (creates .claude/CLAUDE.md)",label:"Claude",value:"claude"},{description:"Replit (creates replit.md)",label:"Replit",value:"replit"},{description:"Aider (creates ultracite.md)",label:"Aider",value:"aider"},{description:"Gemini (creates GEMINI.md)",label:"Gemini",value:"gemini"},{description:"Roo (creates .roo/rules/ultracite.md)",label:"Roo",value:"roo-code"},{description:"Amazon Q CLI (creates .amazonq/rules/ultracite.md)",label:"Amazon Q CLI",value:"amazon-q-cli"},{description:"Firebender (creates firebender.json)",label:"Firebender",value:"firebender"}],er=[{description:"Cursor agent hooks",label:"Cursor",value:"cursor"},{description:"Windsurf agent hooks",label:"Windsurf",value:"windsurf"},{description:"CodeBuddy agent hooks",label:"CodeBuddy",value:"codebuddy"},{description:"Claude agent hooks",label:"Claude",value:"claude"}],tr=[{description:"Install the reusable Ultracite skill after setup",label:"Yes",value:"yes"},{description:"Skip installing the Ultracite skill",label:"No",value:"no"}],rr={addons:"Addons",apiLayer:"API layer",architecture:"Architecture",auth:"Authentication",database:"Database",done:"Done",extras:"Extras",formatter:"Formatter",httpProvider:"HTTP provider",initGit:"Git repository",installing:"Installing",microservices:"Microservices communication",orm:"ORM",packageManager:"Package manager",projectName:"Project name",projectType:"Project type",summary:"Summary",ultraciteAgents:"Ultracite agents",ultraciteEditors:"Ultracite editors",ultraciteHooks:"Ultracite hooks",ultraciteInstallSkill:"Ultracite skill",ultraciteSetup:"Ultracite setup"},sr=["projectName","packageManager","formatter","httpProvider","projectType","architecture","database","orm","apiLayer","auth","extras","microservices","addons","ultraciteEditors","ultraciteAgents","ultraciteHooks","ultraciteInstallSkill","initGit","summary","ultraciteSetup","installing","done"];function nr(t){return t.includes("mongodb")}p(nr,"databaseIncludesMongodb");function ir(t){return t.length===0}p(ir,"databaseIsEmpty");function xe(t){return ir(t)}p(xe,"shouldSkipOrmStep");function ge(t){return sr.filter(e=>!(e==="orm"&&xe(t.database)||e==="microservices"&&t.architecture!=="nest-gateway"||(e==="ultraciteEditors"||e==="ultraciteAgents"||e==="ultraciteHooks"||e==="ultraciteInstallSkill"||e==="ultraciteSetup")&&(!t.addons.includes("ultracite")||t.formatter==="none")))}p(ge,"getVisibleSteps");const kt=["ultraciteEditors","ultraciteAgents","ultraciteHooks","ultraciteInstallSkill"];function fe(t){return kt.includes(t)}p(fe,"isUltraciteSubStep");function ar(t,e){if(!fe(t))return null;const r=kt.filter(l=>ge(e).includes(l)),s=r.indexOf(t);if(s===-1)return null;const o=r.length,n=s+1,a=Math.round(n/o*100);return{current:n,percent:a,total:o}}p(ar,"getUltraciteSubStepInfo");function ze(t){return ge(t).filter(e=>e!=="installing"&&e!=="done"&&!fe(e)).length}p(ze,"getTotalSteps");function or(t,e){const r=ge(e).filter(n=>n!=="installing"&&n!=="done");if(t==="installing"||t==="done")return ze(e);if(fe(t)){const n=r.indexOf("addons");return n===-1?1:n+2}const o=r.filter(n=>!fe(n)).indexOf(t);return o===-1?1:o+1}p(or,"getDisplayStepNumber");function cr(t,e){const r=ge(e),s=r.indexOf(t);return s===-1||s>=r.length-1?null:r[s+1]??null}p(cr,"getNextStepId");function lr(t,e){const r=ge(e),s=r.indexOf(t);return s<=0?null:r[s-1]??null}p(lr,"getPreviousStepId");function pr(t){return t==="monorepo"?yt:yt.filter(e=>e.value!=="nest-gateway")}p(pr,"filterArchitectureOptions");function St(t){return nr(t)?Fe.filter(e=>e.value!=="drizzle"):Fe}p(St,"filterOrmOptions");function Et(t){return"nest-api"}p(Et,"defaultArchitecture");function Pt(t,e){if(xe(e))return[];const r=new Set(St(e).map(s=>s.value));return t.filter(s=>r.has(s))}p(Pt,"sanitizeOrmForDatabase");function le(t,e){return t.find(r=>r.value===e)?.label??e}p(le,"labelFor$1");function pe(t,e){return e.length===0?"None":e.map(r=>le(t,r)).join(", ")}p(pe,"labelsFor");const ur=p(({onConfirm:t,state:e})=>{ie((o,n)=>{n.return&&t()});const r={"nest-api":"NestJS API","nest-gateway":"NestJS API Gateway","nest-microservice":"NestJS Microservice"},s=[{label:"Project",value:ae(e.projectName)},{label:"Package manager",value:e.packageManager?le(ht,e.packageManager):"\u2014"},{label:"Formatter",value:e.formatter?le($e,e.formatter):"\u2014"},{label:"HTTP provider",value:e.httpProvider?le(gt,e.httpProvider):"\u2014"},{label:"Project type",value:e.projectType?le(ft,e.projectType):"\u2014"},{label:"Architecture",value:e.architecture?r[e.architecture]??e.architecture:"\u2014"},{label:"Database",value:pe(bt,e.database)}];return xe(e.database)||s.push({label:"ORM",value:pe(Fe,e.orm)}),s.push({label:"API layer",value:pe(jt,e.api)}),e.architecture==="nest-gateway"&&s.push({label:"Microservices",value:pe([{label:"Redis",value:"redis"},{label:"MQTT",value:"mqtt"},{label:"NATS",value:"nats"},{label:"RabbitMQ",value:"rabbitmq"},{label:"Kafka",value:"kafka"},{label:"gRPC",value:"grpc"}],e.microservices)}),s.push({label:"Auth",value:e.auth?le(vt,e.auth):"\u2014"},{label:"Extras",value:pe(Le,e.extras)},{label:"Addons",value:pe(Ue,e.addons)},{label:"Git",value:e.initGit==="yes"?"Initialize repository":"Skip"}),g(D,{children:[i(f,{flexDirection:"column",marginBottom:1,children:g(c,{children:[i(c,{color:S,children:"\u2726 "}),i(c,{color:U,children:"Review your selections"})]})}),i(f,{flexDirection:"column",rowGap:1,overflow:"hidden",children:s.map(o=>g(f,{flexDirection:"row",columnGap:1,children:[i(c,{color:Pe,children:`${o.label}:`}),i(c,{color:Ee,children:o.value})]},o.label))})]})},"SummaryStep");function dr(t,e){return t.find(r=>r.value===e)?.label??e}p(dr,"labelFor");const mr=p(({onConfirm:t,state:e})=>{ie((n,a)=>{a.return&&t()});const r=(()=>{switch(e.formatter){case"biome":return"biome";case"eslint-prettier-stylelint":case"eslint-prettier-no-stylelint":return"eslint";default:return"oxlint"}})(),s=[];e.addons.includes("husky")&&s.push("husky");const o=[{label:"Linter",value:`${r} (from ${dr($e,e.formatter??"oxlint-oxfmt")})`},{label:"Package manager",value:e.packageManager??"pnpm"},{label:"Frameworks",value:"nestjs"},{label:"Integrations",value:s.length>0?s.join(", "):"none"},{label:"Flags",value:"--quiet"}];return g(D,{children:[g(f,{flexDirection:"column",marginBottom:1,children:[g(c,{children:[i(c,{color:S,children:"\u2726 "}),i(c,{color:U,children:"Ultracite Configuration"})]}),i(c,{color:Pe,children:"The following configuration will be applied:"})]}),g(f,{flexDirection:"column",rowGap:1,overflow:"hidden",children:[o.map(n=>g(f,{flexDirection:"row",columnGap:1,children:[i(c,{color:Pe,children:`${n.label}:`}),i(c,{color:Ee,children:n.value})]},n.label)),i(f,{marginTop:1,children:g(c,{color:Pe,children:["Command: npx ultracite init --quiet --pm ",e.packageManager," ","--linter ",r," --frameworks nestjs",s.length>0?` --integrations ${s.join(",")}`:""]})})]})]})},"UltraciteSetupStep"),He=Gt({emptyStringAsUndefined:!0,runtimeEnv:process.env,server:{APP_MAX_WIDTH:ce.string().pipe(ce.coerce.number()).default(95),NEST_ARCH_BETA_MODE:ce.enum(["true","false"]).default("false").transform(t=>t==="true"),NEST_ARCH_SCHEMA_URL:ce.string().default("./schema.json"),NEST_ARCH_VERSION:ce.string().default("0.0.1"),NODE_ENV:ce.enum(["development","production","test"]).default("development")}});function We(t){return t.length===0?"\u2014":t.join(", ")}p(We,"formatList");const hr=p(({state:t,stepId:e})=>{const r=[];if(e!=="projectName"&&t.projectName.trim()&&r.push(ae(t.projectName)),t.packageManager&&r.push(t.packageManager),t.httpProvider&&r.push(t.httpProvider),t.projectType&&r.push(t.projectType==="monorepo"?"Monorepo":"Single"),t.architecture){const n={"nest-api":"Nest API","nest-gateway":"API Gateway","nest-microservice":"Microservice"};r.push(n[t.architecture]??t.architecture)}if(t.database.length>0&&r.push(We(t.database)),t.orm.length>0&&r.push(We(t.orm)),t.api.length>0&&r.push(We(t.api)),t.auth&&r.push(t.auth),t.extras.length>0&&r.push(`+${t.extras.length} extras`),t.addons.length>0&&!fe(e)&&r.push(`+${t.addons.length} addons`),t.initGit&&r.push(t.initGit==="yes"?"git init":"no git"),r.length===0)return g(c,{children:[i(c,{color:S,children:"\u25C6 "}),i(c,{color:S,children:"Create a new NestJS project"})]});const[s,...o]=r;return g(D,{children:[g(c,{children:[i(c,{color:S,children:"\u25C6 "}),i(c,{color:S,children:"Create a new NestJS project"})]}),e!=="summary"&&i(f,{borderStyle:"single",borderColor:me,width:He.APP_MAX_WIDTH,children:g(c,{children:[i(c,{children:"Project Name: "}),i(c,{color:S,children:s}),i(c,{color:P,children:" Selected: "}),o.length>0?i(c,{color:P,children:`${o.filter(n=>n!=="none").join(" \xB7 ")}`}):null]})})]})},"WizardContextBar"),gr=p(({displayStep:t,stepId:e,subProgress:r,totalSteps:s})=>g(f,{paddingLeft:2,paddingTop:e==="summary"?2:1,marginBottom:1,children:[i(c,{color:R,children:"Create project"}),i(c,{color:P,children:` \u2014 step ${t}/${s}`}),r?i(c,{color:U,children:` \xB7 Ultracite configuration (${r.current}/${r.total} \xB7 ${r.percent}%)`}):i(c,{color:U,children:` \xB7 ${rr[e]}`})]}),"WizardTitle$1"),Be=Y(st(),".nestarch"),Je=Y(Be,"last-used.json");function fr(){try{if(!je(Je))return null;const t=$t(Je,"utf-8");return JSON.parse(t)}catch{return null}}p(fr,"getLastUsedConfig");function At(t){try{je(Be)||Ft(Be,{recursive:!0}),Lt(Je,JSON.stringify(t,null,2),"utf-8")}catch{}}p(At,"saveLastUsedConfig");function yr(t){const e=[t.packageManager];t.httpProvider&&e.push(t.httpProvider),t.api.length>0&&e.push(t.api.join(", ")),t.projectType&&e.push(t.projectType);const r=new Date,s=r.toLocaleString("en-US",{month:"short"}),o=r.getDate(),n=r.getFullYear(),a=`${s} ${o}, ${n}`;return`${e.join(", ")} (last used ${a})`}p(yr,"buildLastUsedDescription");class Ze{static{p(this,"TemplateEngine")}cache={};cacheEnabled;templatesDir;constructor(e,r={}){this.templatesDir=e,this.cacheEnabled=r.cache??!0,Ze.registerHelpers(r.helpers)}static registerHelpers(e){if(L.registerHelper("eq",(r,s)=>r===s),L.registerHelper("ne",(r,s)=>r!==s),L.registerHelper("lt",(r,s)=>r<s),L.registerHelper("gt",(r,s)=>r>s),L.registerHelper("and",(r,s)=>r&&s),L.registerHelper("or",(r,s)=>r||s),L.registerHelper("uppercase",r=>r?.toUpperCase?.()),L.registerHelper("lowercase",r=>r?.toLowerCase?.()),L.registerHelper("capitalize",r=>r?r.charAt(0).toUpperCase()+r.slice(1):""),L.registerHelper("camelCase",r=>r?.split("-").map((s,o)=>o===0?s.toLowerCase():s.charAt(0).toUpperCase()+s.slice(1).toLowerCase()).join("")),L.registerHelper("pascalCase",r=>r?.split("-").map(s=>s.charAt(0).toUpperCase()+s.slice(1).toLowerCase()).join("")),L.registerHelper("snakeCase",r=>r?.replaceAll(/([A-Z])/gu,"_$1").toLowerCase()),e)for(const[r,s]of Object.entries(e))L.registerHelper(r,s)}async loadTemplate(e){const r=e;if(this.cacheEnabled&&this.cache[r])return this.cache[r];const s=I.join(this.templatesDir,e),o=await W.readFile(s,"utf-8"),n=L.compile(o);return this.cacheEnabled&&(this.cache[r]=n),n}async renderTemplate(e,r){return(await this.loadTemplate(e))(r.context)}async renderToFile(e,r,s){return{content:await this.renderTemplate(e,s),filePath:r,isBinary:!1}}clearCache(){this.cache={}}getCacheStats(){return{enabled:this.cacheEnabled,size:Object.keys(this.cache).length}}}class br{static{p(this,"FileWriter")}baseDir;writtenFiles=new Set;constructor(e){this.baseDir=e}getBaseDir(){return this.baseDir}async writeFile(e,r={}){const s=I.join(this.baseDir,e.filePath),o=I.dirname(s);try{await W.mkdir(o,{recursive:!0});let n=!1;try{await W.stat(s),n=!0}catch{n=!1}if(n&&!r.overwrite)return{backed:!1,error:"File already exists and overwrite is disabled",filePath:s,written:!1};let a=!1;if(n&&r.createBackups&&!r.dryRun){const l=`${s}.bak`;await W.copyFile(s,l),a=!0}return r.dryRun||(await W.writeFile(s,e.content,"utf-8"),this.writtenFiles.add(s)),{backed:a,filePath:s,written:!r.dryRun}}catch(n){return{backed:!1,error:n instanceof Error?n.message:"Unknown error",filePath:s,written:!1}}}writeFiles(e,r={}){return Promise.all(e.map(s=>this.writeFile(s,r)))}async fileExists(e){const r=I.join(this.baseDir,e);try{return await W.stat(r),!0}catch{return!1}}getWrittenFiles(){return[...this.writtenFiles]}clearWrittenFiles(){this.writtenFiles.clear()}async copyDirectory(e,r){const s=[],o=I.join(this.baseDir,e),n=I.join(this.baseDir,r);await W.mkdir(n,{recursive:!0});const a=await W.readdir(o,{withFileTypes:!0});for(const l of a){const u=I.join(o,l.name),m=I.join(n,l.name);if(l.isDirectory()){const y=await this.copyDirectory(I.relative(this.baseDir,u),I.relative(this.baseDir,m));s.push(...y)}else{const y=await W.readFile(u,"utf-8");await W.writeFile(m,y,"utf-8"),s.push(m),this.writtenFiles.add(m)}}return s}}const qe=nt(Ut);class jr{static{p(this,"GitInitializer")}baseDir;constructor(e){this.baseDir=e}async initGit(){try{const e=I.join(this.baseDir,".git");try{return await W.access(e),{success:!0}}catch{}return await qe("git",["init"],{cwd:this.baseDir}),await qe("git",["add","."],{cwd:this.baseDir}),await qe("git",["commit","-m","init"],{cwd:this.baseDir}),{success:!0}}catch(e){return{error:e instanceof Error?e.message:String(e),success:!1}}}}class vr{static{p(this,"TemplateRegistry")}templates=new Map;groups=new Map;registerTemplate(e){this.templates.set(e.id,e)}registerTemplates(e){for(const r of e)this.registerTemplate(r)}registerGroup(e){this.groups.set(e.id,e);for(const r of e.templates)this.registerTemplate(r)}getTemplate(e){return this.templates.get(e)}getGroup(e){return this.groups.get(e)}getAllTemplates(){return[...this.templates.values()]}getAllGroups(){return[...this.groups.values()]}getTemplatesByGroup(e){return this.groups.get(e)?.templates||[]}getTemplatesByFormat(e){return[...this.templates.values()].filter(r=>r.format===e)}async loadFromDirectory(e,r){const s=[];try{const o=await W.readdir(e,{withFileTypes:!0});for(const n of o){if(!n.isFile())continue;const{name:a}=n,l=I.extname(a);if(l===".hbs"){const u=I.basename(a,l),m={description:`Template: ${u}`,format:"handlebars",id:u,name:u.replaceAll(/[-_]/gu," "),optional:a.startsWith("_"),path:I.join(I.relative(I.dirname(e),e),a)};s.push(m),this.registerTemplate(m)}}if(r&&s.length>0){const n={description:`Templates from ${e}`,id:r,name:r,templates:s};this.registerGroup(n)}}catch(o){console.error(`Failed to load templates from ${e}:`,o)}return s}clear(){this.templates.clear(),this.groups.clear()}getStats(){return{groupCount:this.groups.size,templateCount:this.templates.size}}}function _(t,e,r){const s="[ultracite-inject]";if(r){const o=r instanceof Error?r.message:String(r);console.error(`${s} ${t}: ${e} \u2014 ${o}`)}else console.error(`${s} ${t}: ${e}`)}p(_,"log");const Ve={biome:{complexity:{noStaticOnlyClass:"off",noUselessConstructor:"off"},style:{noParameterProperties:"off",useImportType:"off"}},eslint:{"@typescript-eslint/consistent-type-imports":"off","@typescript-eslint/no-extraneous-class":"off","@typescript-eslint/parameter-properties":"off","class-methods-use-this":"off","func-style":["off"],"no-useless-constructor":"off","unicorn/no-static-only-class":"off","vitest/consistent-test-filename":"off"},oxlint:{"class-methods-use-this":"off","func-style":["off"],"no-useless-constructor":"off","oxc/no-const-enum":"off","typescript/consistent-type-imports":"off","typescript/no-extraneous-class":"off","typescript/parameter-properties":"off","unicorn/no-static-only-class":"off","vitest/consistent-test-filename":"off"}};async function wr(t){const e=Y(t,"oxlint.config.ts");let r;try{r=await ve(e,"utf-8"),_("read",`Read ${e}`)}catch(n){_("error",`Cannot read ${e}`,n);return}let s=r;/import vitest from "ultracite\/oxlint\/vitest"/u.test(r)||(s=s.replace(/(import nestjs from "ultracite\/oxlint\/nestjs";)/u,`$1
18
+ import vitest from "ultracite/oxlint/vitest";`),_("add-import","Added vitest import"));const o=Object.entries(Ve.oxlint).map(([n,a])=>{const l=Array.isArray(a)?JSON.stringify(a):`"${a}"`;return` "${n}": ${l}`}).join(`,
19
+ `);s=s.replace(/export default defineConfig\(\{([\s\S]*?)\}\);/u,(n,a)=>{const l=a.includes("vitest"),u=a.includes("ignorePatterns"),m=a.includes("rules:");let y=a;return l||(y=y.replace(/(extends:\s*\[[\s\S]*?)(\],)/u,`$1 vitest,
20
+ $2`),_("add-extends","Added vitest to extends array")),u||(y=y.replace(/(extends:\s*\[[\s\S]*?\],?)/u,`$1
21
+ ignorePatterns: core.ignorePatterns,`),_("add-ignorePatterns","Added ignorePatterns")),m||(y=`${y} rules: {
22
+ ${o},
23
+ },
24
+ `,_("add-rules","Added custom NestJS rules")),`export default defineConfig({${y}});`});try{await de(e,s,"utf-8"),_("write",`Written ${e}`)}catch(n){_("error",`Cannot write ${e}`,n)}}p(wr,"injectOxlintRules");async function kr(t){const e=Y(t,"biome.jsonc");let r;try{r=await ve(e,"utf-8"),_("read",`Read ${e}`)}catch(a){_("error",`Cannot read ${e}`,a);return}const s=Ve.biome,o=r.includes('"linter"'),n=r.includes('"rules"');if(o&&n){const a=Object.entries(s).flatMap(([u,m])=>Object.entries(m).map(([y,w])=>` "${u}": {
25
+ "${y}": "${w}"
26
+ }`)).join(`,
27
+ `),l=r.replace(/("linter"\s*:\s*\{[\s\S]*?"rules"\s*:\s*\{)([\s\S]*?)(\})/u,(u,m,y,w)=>{const E=y.trim().endsWith(",")?"":",";return`${m}${y}${E}
28
+ ${a}
29
+ ${w}`});try{await de(e,l,"utf-8"),_("write",`Written ${e} (existing linter block)`)}catch(u){_("error",`Cannot write ${e}`,u)}}else{const l=` "linter": {
30
+ "rules": {
31
+ ${Object.entries(s).map(([m,y])=>{const w=Object.entries(y).map(([E,M])=>` "${E}": "${M}"`).join(`,
32
+ `);return` "${m}": {
33
+ ${w}
34
+ }`}).join(`,
35
+ `)}
36
+ }
37
+ }`,u=r.replace(/(\}\s*)$/u,m=>`,
38
+ ${l}
39
+ ${m}`);try{await de(e,u,"utf-8"),_("write",`Written ${e} (new linter block)`)}catch(m){_("error",`Cannot write ${e}`,m)}}}p(kr,"injectBiomeRules");async function Sr(t){const e=Y(t,"eslint.config.mjs");let r;try{r=await ve(e,"utf-8"),_("read",`Read ${e}`)}catch(n){_("error",`Cannot read ${e}`,n);return}if(r.includes("rules:")){_("skip","Rules already present in eslint.config.mjs");return}const s=Object.entries(Ve.eslint).map(([n,a])=>{const l=Array.isArray(a)?JSON.stringify(a):`"${a}"`;return` "${n}": ${l}`}).join(`,
40
+ `),o=r.replace(/\];?$/u,` {
41
+ rules: {
42
+ ${s},
43
+ },
44
+ },
45
+ ];`);try{await de(e,o,"utf-8"),_("write",`Written ${e}`)}catch(n){_("error",`Cannot write ${e}`,n)}}p(Sr,"injectEslintRules");async function Er(t,e){switch(_("start",`Injecting rules for formatter: ${e}`),e){case"oxlint-oxfmt":return await wr(t),_("done","Oxlint configuration updated"),{success:!0};case"biome":return await kr(t),_("done","Biome configuration updated"),{success:!0};case"eslint-prettier-stylelint":case"eslint-prettier-no-stylelint":return await Sr(t),_("done","ESLint configuration updated"),{success:!0};default:return _("skip",`No injection for formatter: ${e}`),{message:"No injection needed",success:!0}}}p(Er,"injectUltraciteRules");const Pr="single-project/architecture/nest-api",Ar="single-project/architecture/nest-gateway",Tr="single-project/architecture/nest-microservice",xr="monorepo/root",_r="monorepo/apps/api-gateway",Cr="monorepo/packages",Nr="addons/husky",Rr="extras/docker",Or="extras/swagger",Dr=[{conditions:{architecture:"nest-api",projectType:"single"},id:"single-nest-api",name:"Single NestJS API",priority:10,templateGroups:[Pr]},{conditions:{architecture:"nest-gateway",projectType:"single"},id:"single-nest-gateway",name:"Single NestJS Gateway",priority:10,templateGroups:[Ar]},{conditions:{architecture:"nest-microservice",projectType:"single"},id:"single-nest-microservice",name:"Single NestJS Microservice",priority:10,templateGroups:[Tr]},{conditions:{projectType:"monorepo"},id:"monorepo-root",name:"Monorepo Root",priority:10,templateGroups:[xr,_r,Cr]},{conditions:{addons:["husky"]},id:"addon-husky",name:"Husky Git Hooks",priority:5,templateGroups:[Nr]},{conditions:{extras:["docker"]},id:"extra-docker",name:"Docker Support",priority:5,templateGroups:[Rr]},{conditions:{extras:["swagger"]},id:"extra-swagger",name:"Swagger Documentation",priority:5,templateGroups:[Or]}];function Mr(t){t.registerAll(Dr)}p(Mr,"initializeTemplateMappings");class Ce{static{p(this,"TemplateMapper")}mappings=[];register(e){this.mappings.push(e),this.mappings.sort((r,s)=>(s.priority??0)-(r.priority??0))}registerAll(e){for(const r of e)this.register(r)}resolve(e){const r=[];for(const a of this.mappings)Ce.matches(a.conditions,e)&&r.push(a);const s=[],o={},n=[];for(const a of r){for(const l of a.templateGroups)s.includes(l)||s.push(l);Object.assign(o,a.extraVariables),n.push(a.id)}return{extraVariables:o,matchedMappings:n,templateGroups:s}}findFirst(e){return this.mappings.find(r=>Ce.matches(r.conditions,e))}getAll(){return[...this.mappings]}getById(e){return this.mappings.find(r=>r.id===e)}clear(){this.mappings=[]}static matches(e,r){return!(e.architecture!==void 0&&e.architecture!==r.architecture||e.projectType!==void 0&&e.projectType!==r.projectType||e.database!==void 0&&!e.database.some(s=>r.database.includes(s))||e.orm!==void 0&&!e.orm.some(s=>r.orm.includes(s))||e.api!==void 0&&!e.api.some(s=>r.api.includes(s))||e.extras!==void 0&&!e.extras.some(s=>r.extras.includes(s))||e.addons!==void 0&&!e.addons.some(s=>r.addons.includes(s))||e.microservices!==void 0&&!e.microservices.some(s=>r.microservices.includes(s)))}}function Ir(t){return t.replaceAll(/([a-z])([A-Z])/gu,"$1-$2").replaceAll(/\s+/gu,"-").toLowerCase()}p(Ir,"toKebabCase");function Gr(t){return t.replaceAll(/[-_\s](.)/gu,(e,r)=>r.toUpperCase()).replace(/^(.)/u,e=>e.toLowerCase())}p(Gr,"toCamelCase");function $r(t){return t.replaceAll(/[-_\s](.)/gu,(e,r)=>r.toUpperCase()).replace(/^(.)/u,e=>e.toUpperCase())}p($r,"toPascalCase");function Fr(t){return{addons:[...t.addons],apiType:t.api[0]??null,apis:[...t.api],architecture:t.architecture,auth:t.auth,databaseType:t.database[0]??null,databases:[...t.database],description:t.description||"A NestJS application",docker:t.extras.includes("docker"),extras:[...t.extras],hasAuth:t.auth!=="none",hasDatabase:t.database.length>0,hasOrm:t.orm.length>0,httpProvider:t.httpProvider,initGit:t.initGit,isBun:t.packageManager==="bun",isMonorepo:t.projectType==="monorepo",isNpm:t.packageManager==="npm",isPnpm:t.packageManager==="pnpm",isSingle:t.projectType==="single",isYarn:t.packageManager==="yarn",microservices:[...t.microservices],ormType:t.orm[0]??null,orms:[...t.orm],packageManager:t.packageManager,projectName:t.projectName,projectNameCamelCase:Gr(t.projectName),projectNameKebab:Ir(t.projectName),projectNamePascalCase:$r(t.projectName),projectType:t.projectType,supportsCatalog:["pnpm","yarn","bun"].includes(t.packageManager),swagger:t.extras.includes("swagger"),year:new Date().getFullYear()}}p(Fr,"buildTemplateVariables");function Lr(t,e){return{...t,...e}}p(Lr,"mergeTemplateExtras");const Ur={name:"@nest-arch/dependencies-reference",version:"0.0.0",private:!0,description:"Single source of truth for dependency versions used across all generated templates. Do not install this package.",dependencies:{"@grpc/grpc-js":"^1.12.0","@grpc/proto-loader":"^0.7.13","@nestjs/apollo":"^13.0.0","@nestjs/common":"next","@nestjs/core":"next","@nestjs/graphql":"^13.0.0","@nestjs/jwt":"next","@nestjs/microservices":"next","@nestjs/passport":"next","@nestjs/platform-express":"next","@nestjs/platform-fastify":"next","@nestjs/swagger":"next","@nestjs/terminus":"next","@nestjs/throttler":"next","@nestjs/typeorm":"next","@prisma/client":"^6.5.0","@scalar/nestjs":"^0.3.0","@t3-oss/env-core":"^0.13.11","@trpc/client":"^11.0.0","@trpc/server":"^11.0.0",amqplib:"^0.10.5","apollo-server-express":"^3.13.0","apollo-server-fastify":"^3.13.0","better-auth":"^1.2.0",dotenv:"^17.2.2","drizzle-orm":"^0.41.0",graphql:"^16.10.0",ioredis:"^5.6.0",kafkajs:"^2.2.4",mqtt:"^5.10.0",nats:"^2.28.0","nestjs-zod":"^3.1.0",passport:"^0.7.0","passport-jwt":"^5.0.0","passport-local":"^1.0.0",pg:"^8.13.0","reflect-metadata":"^0.2.2",rxjs:"^7.8.1",typeorm:"^0.3.20",zod:"^4.4.3"},devDependencies:{"@nestjs/cli":"next","@nestjs/schematics":"next","@nestjs/testing":"next","@types/amqplib":"^0.10.6","@types/express":"^5.0.0","@types/node":"^22.13.14","@types/passport-jwt":"^4.0.1","@types/passport-local":"^1.0.38","@types/pg":"^8.11.11","@types/supertest":"^7.0.0","@vitest/coverage-v8":"4.1.6","drizzle-kit":"^0.30.0",husky:"^9.1.7",oxfmt:"^0.52.0",oxlint:"^1.67.0",prisma:"^6.5.0","source-map-support":"^0.5.21",supertest:"^7.0.0",turbo:"^2.8.12",typescript:"^6.0.2",ultracite:"7.8.0",vitest:"^4.1.2"},catalog:{"@types/node":"^22.13.14",dotenv:"^17.2.2",typescript:"^6.0.2",zod:"^4.4.3"}};function Tt(){return Ur}p(Tt,"loadReference");function d(t){const e=Tt(),r=e.dependencies[t]??e.devDependencies[t];if(!r)throw new Error(`Dependency "${t}" not found in reference package.json`);return r}p(d,"getDependencyVersion");function zr(){return{...Tt().catalog}}p(zr,"getCatalogDependencies");const Hr=[{dest:"tsconfig.json",src:"base/tsconfig.json.hbs"},{dest:"tsconfig.build.json",src:"base/tsconfig.build.json.hbs"},{dest:"nest-cli.json",src:"base/nest-cli.json.hbs"},{dest:".gitignore",src:"base/.gitignore.hbs"},{dest:".env",src:"base/.env.hbs"},{dest:"README.md",src:"base/README.md.hbs"},{dest:"vitest.config.ts",src:"base/vitest.config.ts.hbs"},{dest:"vitest.config.e2e.ts",src:"base/vitest.config.e2e.ts.hbs"},{dest:"src/main.ts",src:"base/src/main.ts.hbs"},{dest:"src/app.module.ts",src:"base/src/app.module.ts.hbs"},{dest:"src/app.service.ts",src:"base/src/app.service.ts.hbs"},{dest:"src/app.controller.ts",src:"base/src/app.controller.ts.hbs"},{dest:"src/app.controller.spec.ts",src:"base/src/app.controller.spec.ts.hbs"},{dest:"src/config/env.ts",src:"single-project/shared/config/env.ts.hbs"},{dest:"test/app.e2e-spec.ts",src:"base/test/app.e2e-spec.ts.hbs"}],Wr={dest:"pnpm-workspace.yaml",src:"base/pnpm-workspace.yaml.hbs"},Br={dest:".yarnrc.yml",src:"base/.yarnrc.yml.hbs"},Jr=[{dest:".husky/pre-commit",src:"addons/husky/pre-commit.hbs"}],qr=[{dest:"Dockerfile",src:"extras/docker/Dockerfile.hbs"},{dest:"docker-compose.yml",src:"extras/docker/docker-compose.yml.hbs"},{dest:".dockerignore",src:"extras/docker/.dockerignore.hbs"}],Vr={"single-project/architecture/nest-api":[{dest:"src/main.ts",src:"single-project/architecture/nest-api/src/main.ts.hbs"},{dest:".env",src:"single-project/architecture/nest-api/.env.hbs"},{dest:"package.json",src:"single-project/architecture/nest-api/package.json.hbs"},{dest:"pnpm-workspace.yaml",src:"single-project/architecture/nest-api/pnpm-workspace.yaml.hbs"}],"single-project/architecture/nest-gateway":[{dest:"src/main.ts",src:"single-project/architecture/nest-gateway/src/main.ts.hbs"},{dest:"src/app.module.ts",src:"single-project/architecture/nest-gateway/src/app.module.ts.hbs"},{dest:"src/app.controller.ts",src:"single-project/architecture/nest-gateway/src/app.controller.ts.hbs"},{dest:"src/app.service.ts",src:"single-project/architecture/nest-gateway/src/app.service.ts.hbs"},{dest:"package.json",src:"single-project/architecture/nest-api/package.json.hbs"},{dest:"pnpm-workspace.yaml",src:"single-project/architecture/nest-api/pnpm-workspace.yaml.hbs"}],"single-project/architecture/nest-microservice":[{dest:"src/main.ts",src:"single-project/architecture/nest-microservice/src/main.ts.hbs"},{dest:"src/app.module.ts",src:"single-project/architecture/nest-microservice/src/app.module.ts.hbs"},{dest:"src/app.controller.ts",src:"single-project/architecture/nest-microservice/src/app.controller.ts.hbs"},{dest:"src/app.service.ts",src:"single-project/architecture/nest-microservice/src/app.service.ts.hbs"},{dest:".env",src:"single-project/architecture/nest-microservice/.env.hbs"},{dest:"package.json",src:"single-project/architecture/nest-api/package.json.hbs"},{dest:"pnpm-workspace.yaml",src:"single-project/architecture/nest-api/pnpm-workspace.yaml.hbs"}]},xt=[{dest:"turbo.json",src:"monorepo/root/turbo.json.hbs"},{dest:"tsconfig.json",src:"monorepo/root/tsconfig.json.hbs"},{dest:".gitignore",src:"monorepo/root/.gitignore.hbs"},{dest:"README.md",src:"monorepo/root/README.md.hbs"}],Yr="package.json",Kr=[{dest:"apps/api-gateway/src/main.ts",src:"monorepo/apps/api-gateway/src/main.ts.hbs"},{dest:"apps/api-gateway/src/app.module.ts",src:"monorepo/apps/api-gateway/src/app.module.ts.hbs"},{dest:"apps/api-gateway/src/app.controller.ts",src:"monorepo/apps/api-gateway/src/app.controller.ts.hbs"},{dest:"apps/api-gateway/src/app.service.ts",src:"monorepo/apps/api-gateway/src/app.service.ts.hbs"},{dest:"apps/api-gateway/src/app.controller.spec.ts",src:"monorepo/apps/api-gateway/src/app.controller.spec.ts.hbs"},{dest:"apps/api-gateway/test/app.e2e-spec.ts",src:"monorepo/apps/api-gateway/test/app.e2e-spec.ts.hbs"},{dest:"apps/api-gateway/tsconfig.json",src:"monorepo/apps/api-gateway/tsconfig.json.hbs"},{dest:"apps/api-gateway/tsconfig.build.json",src:"monorepo/apps/api-gateway/tsconfig.build.json.hbs"},{dest:"apps/api-gateway/nest-cli.json",src:"monorepo/apps/api-gateway/nest-cli.json.hbs"},{dest:"apps/api-gateway/vitest.config.ts",src:"monorepo/apps/api-gateway/vitest.config.ts.hbs"},{dest:"apps/api-gateway/vitest.config.e2e.ts",src:"monorepo/apps/api-gateway/vitest.config.e2e.ts.hbs"}],Qr=[{dest:"packages/config/package.json",src:"monorepo/packages/config/package.json.hbs"},{dest:"packages/config/tsconfig.base.json",src:"monorepo/packages/config/tsconfig.base.json.hbs"},{dest:"packages/config/tsconfig.nestjs.json",src:"monorepo/packages/config/tsconfig.nestjs.json.hbs"},{dest:"packages/env/package.json",src:"monorepo/packages/env/package.json.hbs"},{dest:"packages/env/src/api-gateway.ts",src:"monorepo/packages/env/src/api-gateway.ts.hbs"},{dest:"packages/env/tsconfig.json",src:"monorepo/packages/env/tsconfig.json.hbs"},{dest:"packages/shared/package.json",src:"monorepo/packages/shared/package.json.hbs"},{dest:"packages/shared/tsconfig.json",src:"monorepo/packages/shared/tsconfig.json.hbs"}],Ye={"addons/husky":Jr,"extras/docker":qr,"extras/swagger":[],"monorepo/apps/api-gateway":Kr,"monorepo/packages":Qr,"monorepo/root":xt};function _t(t,e,r){t.auth==="jwt"||t.auth==="passport"?(e["@nestjs/jwt"]=d("@nestjs/jwt"),e["@nestjs/passport"]=d("@nestjs/passport"),e.passport=d("passport"),e["passport-jwt"]=d("passport-jwt"),r["@types/passport-jwt"]=d("@types/passport-jwt"),t.auth==="passport"&&(e["passport-local"]=d("passport-local"),r["@types/passport-local"]=d("@types/passport-local"))):t.auth==="better-auth"&&(e["better-auth"]=d("better-auth"));for(const s of t.orm)s==="prisma"?(e["@prisma/client"]=d("@prisma/client"),r.prisma=d("prisma")):s==="typeorm"?(e.typeorm=d("typeorm"),e["@nestjs/typeorm"]=d("@nestjs/typeorm"),e.pg=d("pg")):s==="drizzle"&&(e["drizzle-orm"]=d("drizzle-orm"),r["drizzle-kit"]=d("drizzle-kit"),e.pg=d("pg"));for(const s of t.api)if(s==="graphql"){e["@nestjs/graphql"]=d("@nestjs/graphql"),e["@nestjs/apollo"]=d("@nestjs/apollo"),e.graphql=d("graphql");const o=t.httpProvider==="fastify"?"apollo-server-fastify":"apollo-server-express";e[o]=d(o)}else s==="trpc"&&(e["@trpc/server"]=d("@trpc/server"),e["@trpc/client"]=d("@trpc/client"));t.extras.includes("swagger")&&(e["@nestjs/swagger"]=d("@nestjs/swagger")),t.extras.includes("health-check")&&(e["@nestjs/terminus"]=d("@nestjs/terminus")),t.extras.includes("rate-limiting")&&(e["@nestjs/throttler"]=d("@nestjs/throttler"));for(const s of t.microservices)s==="redis"?e.ioredis=d("ioredis"):s==="mqtt"?e.mqtt=d("mqtt"):s==="nats"?e.nats=d("nats"):s==="rabbitmq"?(e.amqplib=d("amqplib"),r["@types/amqplib"]=d("@types/amqplib")):s==="kafka"?e.kafkajs=d("kafkajs"):s==="grpc"&&(e["@grpc/grpc-js"]=d("@grpc/grpc-js"),e["@grpc/proto-loader"]=d("@grpc/proto-loader"));t.addons.includes("nestjs-zod")&&(e["nestjs-zod"]=d("nestjs-zod")),t.addons.includes("scalar-ui")&&(e["@scalar/nestjs"]=d("@scalar/nestjs"))}p(_t,"addConditionalDependencies");async function Xr(t,e,r,s,o,n){try{const a=t.httpProvider==="fastify"?"@nestjs/platform-fastify":"@nestjs/platform-express",l={"@nestjs/common":d("@nestjs/common"),"@nestjs/core":d("@nestjs/core"),[a]:d(a),"@t3-oss/env-core":d("@t3-oss/env-core"),dotenv:d("dotenv"),"reflect-metadata":d("reflect-metadata"),rxjs:d("rxjs"),zod:d("zod")},u={"@nestjs/cli":d("@nestjs/cli"),"@nestjs/schematics":d("@nestjs/schematics"),"@nestjs/testing":d("@nestjs/testing"),"@types/node":d("@types/node"),"@types/supertest":d("@types/supertest"),"@vitest/coverage-v8":d("@vitest/coverage-v8"),"source-map-support":d("source-map-support"),supertest:d("supertest"),typescript:d("typescript"),vitest:d("vitest")};t.httpProvider==="express"&&(u["@types/express"]=d("@types/express"));const m={build:"nest build",dev:"nest start --watch",start:"nest start","start:debug":"nest start --debug --watch","start:dev":"nest start --watch","start:prod":"node dist/main",test:"vitest run","test:cov":"vitest run --coverage","test:debug":"vitest --inspect-brk --no-file-parallelism","test:e2e":"vitest run --config ./vitest.config.e2e.ts","test:watch":"vitest"};_t(t,l,u),t.addons.includes("ultracite")&&(u.ultracite=d("ultracite"),m.check="ultracite check",m.fix="ultracite fix"),t.addons.includes("husky")&&(u.husky=d("husky"),m.prepare="husky");const y={name:e.projectName,version:"0.0.1",description:e.description,author:"",license:"UNLICENSED",private:!0,type:"module",scripts:m,dependencies:l,devDependencies:u},w=JSON.stringify(y,null,2),E=await r.writeFile({content:w,filePath:"package.json",isBinary:!1},{dryRun:s.dryRun,overwrite:s.overwrite});E.written&&o.push(E.filePath)}catch(a){const l=a instanceof Error?a.message:String(a);n.push(`Failed to generate package.json: ${l}`),console.error("Failed to generate package.json:",a)}}p(Xr,"generateSingleProjectPackageJson");async function Zr(t,e,r,s,o,n){try{const a={build:"turbo build","check-types":"turbo check-types",dev:"turbo dev"},l={"@repo/env":"workspace:*",dotenv:"catalog:",zod:"catalog:"},u={"@repo/config":"workspace:*","@types/node":"catalog:",turbo:d("turbo"),typescript:"catalog:"};t.addons.includes("ultracite")&&(a.check="ultracite check"),t.addons.includes("husky")&&(u.husky=d("husky"),a.prepare="husky");const y={bun:"bun@1.3.14",npm:void 0,pnpm:"pnpm@11.5.0",yarn:"yarn@4.6.0"}[t.packageManager],w={name:e.projectName,version:"0.0.1",description:e.description,author:"",license:"UNLICENSED",private:!0,workspaces:["apps/*","packages/*"],type:"module",...y?{packageManager:y}:{},...t.packageManager==="bun"?{catalog:zr()}:{},scripts:a,dependencies:l,devDependencies:u},E=JSON.stringify(w,null,2),M=await r.writeFile({content:E,filePath:Yr,isBinary:!1},{dryRun:s.dryRun,overwrite:s.overwrite});M.written&&o.push(M.filePath)}catch(a){const l=a instanceof Error?a.message:String(a);n.push(`Failed to generate monorepo root package.json: ${l}`),console.error("Failed to generate monorepo root package.json:",a)}}p(Zr,"generateMonorepoRootPackageJson");async function es(t,e,r,s,o,n){try{const a=t.httpProvider==="fastify"?"@nestjs/platform-fastify":"@nestjs/platform-express",l={"@nestjs/common":d("@nestjs/common"),"@nestjs/core":d("@nestjs/core"),[a]:d(a),"@repo/env":"workspace:*","reflect-metadata":d("reflect-metadata"),rxjs:d("rxjs"),zod:"catalog:"},u={"@nestjs/cli":d("@nestjs/cli"),"@nestjs/schematics":d("@nestjs/schematics"),"@nestjs/testing":d("@nestjs/testing"),"@repo/config":"workspace:*","@types/node":"catalog:","@types/supertest":d("@types/supertest"),"@vitest/coverage-v8":d("@vitest/coverage-v8"),"source-map-support":d("source-map-support"),supertest:d("supertest"),typescript:"catalog:",vitest:d("vitest")};t.httpProvider==="express"&&(u["@types/express"]=d("@types/express"));const m={build:"nest build",dev:"nest start --watch",start:"nest start","start:debug":"nest start --debug --watch","start:dev":"nest start --watch","start:prod":"node dist/main",test:"vitest run","test:cov":"vitest run --coverage","test:debug":"vitest --inspect-brk --no-file-parallelism","test:e2e":"vitest run --config ./vitest.config.e2e.ts","test:watch":"vitest"};_t(t,l,u),t.addons.includes("ultracite")&&(u.ultracite=d("ultracite"),m.check="ultracite check",m.fix="ultracite fix"),t.addons.includes("husky")&&(u.husky=d("husky"),m.prepare="husky");const y={name:e.projectName,version:"0.0.1",description:e.description,author:"",license:"UNLICENSED",private:!0,type:"module",scripts:m,dependencies:l,devDependencies:u},w=JSON.stringify(y,null,2),E=await r.writeFile({content:w,filePath:"apps/api-gateway/package.json",isBinary:!1},{dryRun:s.dryRun,overwrite:s.overwrite});E.written&&o.push(E.filePath)}catch(a){const l=a instanceof Error?a.message:String(a);n.push(`Failed to generate monorepo app package.json: ${l}`),console.error("Failed to generate monorepo app package.json:",a)}}p(es,"generateMonorepoAppPackageJson");class ts{static{p(this,"ProjectGenerator")}templateEngine;fileWriter;registry;options;mapper;constructor(e,r){this.options=r,this.fileWriter=new br(e),this.templateEngine=new Ze(r.templatesDir,{cache:r.cacheTemplates??!0}),this.registry=new vr,this.mapper=new Ce,Mr(this.mapper)}getMapper(){return this.mapper}async generate(e){const r=Date.now(),s=[],o=[];try{const n=this.mapper.resolve(e);let a=Fr(e);a=Lr(a,n.extraVariables),a.hasUltracite=e.addons.includes("ultracite"),a.hasHusky=e.addons.includes("husky"),await(e.projectType==="monorepo"?this.generateMonorepo(e,a,n.templateGroups,s,o):this.generateSingleProject(e,a,n.templateGroups,s,o));const l=Date.now()-r,u=o.length===0;if(u&&await this.generateMetadata(e,a,s,o),e.initGit){const y=await new jr(this.fileWriter.getBaseDir()).initGit();y.success||o.push(`Failed to initialize git: ${y.error}`)}return console.log(`\u2705 Project generated in ${l}ms`),{error:u&&o.length===0?void 0:o.join(`
46
+ `),filesCount:s.length,generatedFiles:s,success:u&&o.length===0}}catch(n){return{error:n instanceof Error?n.message:"Unknown error",filesCount:0,generatedFiles:s,success:!1}}}async generateSingleProject(e,r,s,o,n){const a={dryRun:this.options.dryRun,overwrite:this.options.overwrite},l=[...Hr];r.packageManager==="pnpm"?l.push(Wr):r.packageManager==="yarn"&&l.push(Br),await Xr(e,r,this.fileWriter,a,o,n);for(const u of l)await this.renderAndWrite(u.src,u.dest,r,o,n);for(const u of s){const m=Vr[u];if(m){for(const w of m)w.dest==="package.json"||w.dest==="pnpm-workspace.yaml"||w.dest===".yarnrc.yml"||await this.renderAndWrite(w.src,w.dest,r,o,n);continue}const y=Ye[u];if(y)for(const w of y)await this.renderAndWrite(w.src,w.dest,r,o,n)}e.extras.includes("swagger")&&console.log("Swagger support added to project")}async generateMonorepo(e,r,s,o,n){const a={dryRun:this.options.dryRun,overwrite:this.options.overwrite};await Zr(e,r,this.fileWriter,a,o,n),await es(e,r,this.fileWriter,a,o,n);for(const l of s){if(l==="monorepo/root"){for(const m of xt)await this.renderAndWrite(m.src,m.dest,r,o,n);r.packageManager==="pnpm"?await this.renderAndWrite("monorepo/root/pnpm-workspace.yaml.hbs","pnpm-workspace.yaml",r,o,n):r.packageManager==="yarn"&&await this.renderAndWrite("monorepo/root/.yarnrc.yml.hbs",".yarnrc.yml",r,o,n);continue}const u=Ye[l];if(u)for(const m of u)await this.renderAndWrite(m.src,m.dest,r,o,n)}for(const l of s){const u=Ye[l];if(u)for(const m of u)await this.renderAndWrite(m.src,m.dest,r,o,n)}}async generateMetadata(e,r,s,o){try{const{buildMetadata:n,serializeMetadata:a,buildSchemaContent:l}=await import("./index--w1UOCDp.js"),u=n(e),m=a(u),y=await this.fileWriter.writeFile({content:m,filePath:"nest-arch.jsonc",isBinary:!1},{dryRun:this.options.dryRun,overwrite:this.options.overwrite});y.written&&s.push(y.filePath);const w=l(),E=await this.fileWriter.writeFile({content:w,filePath:"schema.json",isBinary:!1},{dryRun:this.options.dryRun,overwrite:this.options.overwrite});E.written&&s.push(E.filePath)}catch(n){const a=n instanceof Error?n.message:String(n);o.push(`Failed to generate nest-arch.jsonc/schema.json: ${a}`)}}async renderAndWrite(e,r,s,o,n){try{const a=await this.templateEngine.renderToFile(e,r,{context:s}),l=await this.fileWriter.writeFile(a,{dryRun:this.options.dryRun,overwrite:this.options.overwrite});l.written&&o.push(l.filePath)}catch(a){const l=a instanceof Error?a.message:String(a);n.push(`Failed to generate ${r}: ${l}`),console.error(`Failed to generate ${r}:`,a)}}clearCaches(){this.templateEngine.clearCache(),this.registry.clear()}}function rs(t){return{addons:t.addons,api:t.api,architecture:t.architecture,auth:t.auth,database:t.database,description:`${t.projectName} NestJS application`,extras:t.extras,formatter:t.formatter,httpProvider:t.httpProvider,initGit:t.initGit==="yes",microservices:t.microservices,orm:t.orm,packageManager:t.packageManager,projectName:t.projectName,projectType:t.projectType,ultraciteAgents:t.ultraciteAgents,ultraciteEditors:t.ultraciteEditors,ultraciteHooks:t.ultraciteHooks,ultraciteInstallSkill:t.ultraciteInstallSkill}}p(rs,"buildGeneratorContext");function Ke(t){return He.NEST_ARCH_BETA_MODE?Y(st(),"test-projects",t):Y(process.cwd(),t)}p(Ke,"getOutputDir");function ss(t){switch(t){case"biome":return"biome";case"eslint-prettier-stylelint":case"eslint-prettier-no-stylelint":return"eslint";case"oxlint-oxfmt":return"oxlint";case"none":return"none";default:return"oxlint"}}p(ss,"mapFormatterToLinter");async function ns(t){const e=Y(t,"package.json");try{const s=await ve(e,"utf-8"),o=JSON.parse(s);o.devDependencies&&(o.devDependencies=Object.fromEntries(Object.entries(o.devDependencies).filter(([n])=>!n.startsWith("stylelint")))),await de(e,`${JSON.stringify(o,null,2)}
47
+ `,"utf-8"),console.error("[ultracite-cleanup] Removed stylelint packages from package.json")}catch{console.error("[ultracite-cleanup] Could not clean package.json")}const r=[".stylelintrc",".stylelintrc.json",".stylelintrc.js",".stylelintrc.yaml",".stylelintrc.yml","stylelint.config.js","stylelint.config.mjs","stylelint.config.cjs"];for(const s of r){const o=Y(t,s);je(o)&&(await Ht(o,{force:!0}),console.error(`[ultracite-cleanup] Removed ${s}`))}}p(ns,"removeStylelint");async function is(t,e){const r=ss(e.formatter);if(r==="none")return{message:"Skipping ultracite init (no formatter selected)",success:!0};const s=[];e.addons.includes("husky")&&s.push("husky");const o=["ultracite","init","--quiet","--skip-install","--pm",e.packageManager,"--linter",r,"--frameworks","nestjs"];s.length>0&&o.push("--integrations",...s),e.addons.includes("ultracite")&&(e.ultraciteEditors.length>0&&o.push("--editors",...e.ultraciteEditors),e.ultraciteAgents.length>0&&o.push("--agents",...e.ultraciteAgents),e.ultraciteHooks.length>0&&o.push("--hooks",...e.ultraciteHooks),e.ultraciteInstallSkill==="yes"&&o.push("--install-skill"));const n=`npx ${o.join(" ")}`,a=nt(zt);try{const{stderr:l}=await a(n,{cwd:t,timeout:12e4});return l?.trim()&&console.error(`[ultracite-init] stderr: ${l.trim()}`),e.formatter==="eslint-prettier-no-stylelint"&&await ns(t),{message:"Ultracite setup completed",success:!0}}catch(l){let u=l instanceof Error?l.message:String(l);if(l&&typeof l=="object"&&"stderr"in l){const m=l.stderr?.trim();m&&(u=`${u}
48
+ ${m}`)}return console.error(`[ultracite-init] Failed: ${u}`),{message:`Ultracite setup failed: ${u}`,success:!1}}}p(is,"runUltraciteSetup");function as(){const t=import.meta.dirname;if(t){const r=Y(t,"templates");if(je(r))return r}return Y(t??process.cwd(),"..","..","..","..","packages","core","templates")}p(as,"getTemplatesDir");async function Ct(t){const e=Ke(t.projectName),r=rs(t),s=as(),o=new ts(e,{cacheTemplates:!0,templatesDir:s});try{const n=await o.generate(r);if(!n.success)return{message:n.error||"Unknown error",outputDir:e,success:!1};if(t.formatter!=="none"){const a=await is(e,t);if(!a.success)return{message:a.message,outputDir:e,success:!1};const l=await Er(e,t.formatter);if(!l.success)return{message:l.message??"Rule injection failed",outputDir:e,success:!1}}return{message:`Project created with ${n.generatedFiles.length} files`,outputDir:e,success:!0}}catch(n){return{message:`Failed to generate project: ${n instanceof Error?n.message:String(n)}`,outputDir:e,success:!1}}}p(Ct,"generateProject");const os=p(()=>({addons:[],api:[],architecture:null,auth:null,database:[],extras:[],formatter:null,httpProvider:null,initGit:null,microservices:[],orm:[],packageManager:null,projectName:"",projectType:null,ultraciteAgents:[],ultraciteEditors:[],ultraciteHooks:[],ultraciteInstallSkill:null}),"initialState");function cs(t){return!t.packageManager||!t.formatter||!t.httpProvider||!t.projectType||!t.architecture||!t.auth||!t.initGit?null:{addons:t.addons,api:t.api,architecture:t.architecture,auth:t.auth,database:t.database,extras:t.extras,formatter:t.formatter,httpProvider:t.httpProvider,initGit:t.initGit,microservices:t.architecture==="nest-gateway"?t.microservices:[],orm:xe(t.database)?[]:t.orm,packageManager:t.packageManager,projectName:ae(t.projectName),projectType:t.projectType,ultraciteAgents:t.ultraciteAgents,ultraciteEditors:t.ultraciteEditors,ultraciteHooks:t.ultraciteHooks,ultraciteInstallSkill:t.ultraciteInstallSkill??"no"}}p(cs,"buildResult");const ls=p(({onBack:t,onExit:e,onStepChange:r})=>{const[s,o]=N("projectName"),[n,a]=N(os),[l,u]=N(null),[m,y]=N(null),w=V(()=>ze(n),[n]),E=V(()=>or(s,n),[s,n]),M=V(()=>ar(s,n),[s,n]),j=v(b=>{const h=cr(s,b);h&&(o(h),r?.(h))},[s,r]),se=v(()=>{const b=lr(s,n);if(b){o(b),r?.(b);return}t()},[t,n,s,r]),z=v(()=>{const b=Te(n.projectName);if(b){u(b);return}const h={...n,projectName:ae(n.projectName)};a(h),j(h)},[j,n]),$=v(b=>{const h={...n,packageManager:b};a(h),j(h)},[j,n]),F=v(b=>{const h={...n,formatter:b};a(h),j(h)},[j,n]),K=v(b=>{const h={...n,httpProvider:b};a(h),j(h)},[j,n]),X=v(b=>{const h=b==="single"&&n.architecture==="nest-gateway"?Et():n.architecture??Et(),ne={...n,architecture:h,extras:b==="single"?n.extras.filter(De=>De!=="packages/shared"):n.extras,microservices:h==="nest-gateway"?n.microservices:[],projectType:b};a(ne),j(ne)},[j,n]),te=v(b=>{const h={...n,architecture:b,microservices:b==="nest-gateway"?n.microservices:[]};a(h),j(h)},[j,n]),k=v(b=>{const h=Pt(n.orm,b),ne={...n,database:b,orm:h};a(ne),j(ne)},[j,n]),A=v(b=>{const h={...n,orm:Pt(b,n.database)};a(h),j(h)},[j,n]),C=v(b=>{const h={...n,api:b};a(h),j(h)},[j,n]),H=v(b=>{const h={...n,auth:b};a(h),j(h)},[j,n]),B=v(b=>{const h={...n,extras:b};a(h),j(h)},[j,n]),ye=V(()=>n.projectType==="monorepo"?Le:Le.filter(b=>b.value!=="packages/shared"),[n.projectType]),x=v(b=>{const h={...n,microservices:b};a(h),j(h)},[j,n]),J=v(b=>{const h={...n,addons:b};a(h),j(h)},[j,n]),oe=v(b=>{const h={...n,ultraciteEditors:b};a(h),j(h)},[j,n]),re=v(b=>{const h={...n,ultraciteAgents:b};a(h),j(h)},[j,n]),q=v(b=>{const h={...n,ultraciteHooks:b};a(h),j(h)},[j,n]),Ne=v(b=>{const h={...n,ultraciteInstallSkill:b};a(h),j(h)},[j,n]),G=v(b=>{const h={...n,initGit:b};a(h),j(h)},[j,n]),Re=v(()=>{j(n)},[j,n]),Oe=v(async()=>{const b=cs(n);if(b){o("installing"),r?.("installing"),y({isError:!1,message:"Scaffolding your project"});try{const h=await Ct(b);y({isError:!h.success,message:h.message}),h.success&&(At(b),setTimeout(()=>{o("done"),r?.("done")},1e3))}catch(h){y({isError:!0,message:`Error: ${h instanceof Error?h.message:String(h)}`})}}},[n,r]),T=v(()=>{o("summary"),r?.("summary"),y(null)},[r]),be=V(()=>s==="projectName"||s==="summary"||s==="ultraciteSetup"?"confirm":s==="database"||s==="orm"||s==="apiLayer"||s==="extras"||s==="microservices"||s==="addons"||s==="ultraciteEditors"||s==="ultraciteAgents"||s==="ultraciteHooks"?"multi-select":s==="installing"&&m?.isError?"confirm":"select",[s,m?.isError]);return{architectureOpts:V(()=>pr(n.projectType),[n.projectType]),displayStep:E,extrasStepOptions:ye,generationStatus:m,goBack:se,handleAddons:J,handleApi:C,handleArchitecture:te,handleAuth:H,handleDatabase:k,handleExtras:B,handleFormatter:F,handleHttpProvider:K,handleInitGit:G,handleMicroservices:x,handleOrm:A,handlePackageManager:$,handleProjectNameSubmit:z,handleProjectType:X,handleRetry:T,handleSummaryConfirm:Oe,handleUltraciteAgents:re,handleUltraciteEditors:oe,handleUltraciteHooks:q,handleUltraciteInstallSkill:Ne,handleUltraciteSetupConfirm:Re,projectNameError:l,setProjectNameError:u,setState:a,state:n,statusAction:be,stepId:s,subProgress:M,totalSteps:w}},"useCreateProjectWizard"),ps=p(({onBack:t,onDone:e,onExit:r,onStepChange:s})=>{const{architectureOpts:o,displayStep:n,extrasStepOptions:a,generationStatus:l,goBack:u,handleProjectNameSubmit:m,handlePackageManager:y,handleFormatter:w,handleHttpProvider:E,handleProjectType:M,handleArchitecture:j,handleDatabase:se,handleOrm:z,handleApi:$,handleAuth:F,handleExtras:K,handleMicroservices:X,handleAddons:te,handleUltraciteEditors:k,handleUltraciteAgents:A,handleUltraciteHooks:C,handleUltraciteInstallSkill:H,handleInitGit:B,handleRetry:ye,handleSummaryConfirm:x,handleUltraciteSetupConfirm:J,projectNameError:oe,setProjectNameError:re,setState:q,statusAction:Ne,stepId:G,subProgress:Re,totalSteps:Oe,state:T}=ls({onBack:t,onExit:r,onStepChange:s}),[be,et]=N([]),[b,h]=N([]),ne=V(()=>{let O=T;return G==="addons"&&(O={...O,addons:be}),G==="database"&&(O={...O,database:b}),ze(O)},[G,T,be,b,Oe]);ue(()=>{G==="done"&&e()},[G,e]),ie((O,Q)=>{if(Q.ctrl&&O==="c"){r();return}if(Q.ctrl&&O==="b"&&G!=="done"){u();return}if(G==="done"&&Q.return){r();return}G==="installing"&&l?.isError&&Q.return&&ye()});const De=p(()=>{switch(G){case"projectName":return i(mt,{error:oe,onChange:p(O=>{q(Q=>({...Q,projectName:O})),re(Te(O))},"onChange"),onSubmit:m,value:T.projectName});case"packageManager":return i(ee,{onConfirm:y,options:ht,prompt:"Choose a package manager"},"packageManager");case"formatter":return i(ee,{onConfirm:w,options:$e,prompt:"Choose a formatter-linter (with ultracite preset) setup"},"formatter");case"httpProvider":return i(ee,{onConfirm:E,options:gt,prompt:"Choose an HTTP provider"},"httpProvider");case"projectType":return i(ee,{onConfirm:M,options:ft,prompt:"Choose a project layout"},"projectType");case"architecture":return i(ee,{onConfirm:j,options:o,prompt:"Choose an application architecture"},"architecture");case"database":return i(Z,{initialSelected:T.database,onConfirm:se,onChange:h,options:bt,prompt:"Select databases for your project (optional)"},"database");case"orm":return i(Z,{initialSelected:T.orm,onConfirm:z,options:St(T.database),prompt:"Select ORMs to include"},"orm");case"apiLayer":{const O=T.architecture==="nest-api"&&T.api.length===0?["rest"]:T.api;return i(Z,{initialSelected:O,onConfirm:$,options:jt,prompt:"Select API layers (optional)"},"apiLayer")}case"auth":return i(ee,{onConfirm:F,options:vt,prompt:"Choose an authentication strategy"},"auth");case"extras":return i(Z,{initialSelected:T.extras,onConfirm:K,options:a,prompt:"Select extras (optional)"},"extras");case"microservices":return i(Z,{initialSelected:T.microservices,onConfirm:X,options:Qt,prompt:"Select microservice communication protocols"},"microservices");case"addons":{const O=T.formatter==="none"?Ue.filter(Q=>Q.value!=="ultracite"):Ue;return i(Z,{initialSelected:T.addons,onConfirm:te,onChange:et,options:O,prompt:"Select addons (optional)"},"addons")}case"ultraciteEditors":return i(Z,{initialSelected:T.ultraciteEditors,onConfirm:k,options:Xt,prompt:"Select Ultracite editors",minified:!0},"ultraciteEditors");case"ultraciteAgents":return i(Z,{initialSelected:T.ultraciteAgents,onConfirm:A,options:Zt,prompt:"Select Ultracite agents",minified:!0},"ultraciteAgents");case"ultraciteHooks":return i(Z,{initialSelected:T.ultraciteHooks,onConfirm:C,options:er,prompt:"Select Ultracite hooks"},"ultraciteHooks");case"ultraciteInstallSkill":return i(ee,{onConfirm:H,options:tr,prompt:"Install Ultracite skill?"},"ultraciteInstallSkill");case"initGit":return i(ee,{onConfirm:B,options:wt,prompt:"Initialize a git repository?"},"initGit");case"summary":return i(ur,{onConfirm:x,state:T});case"ultraciteSetup":return i(mr,{onConfirm:J,state:T});case"installing":return g(f,{flexDirection:"column",children:[i(lt,{message:l?.message||"Scaffolding your project",isError:l?.isError??!1}),l?.isError?i(f,{marginTop:1,children:g(c,{color:P,children:["Press ",i(c,{color:S,children:"Enter"})," to go back to Summary and retry, or ",i(c,{color:P,children:"Ctrl+B"})," to go back"]})}):null]});case"done":{const O=ae(T.projectName),Q=T.initGit==="yes",Rt=Ke(O);return i(pt,{architecture:T.architecture||"nest-api",projectName:O,packageManager:T.packageManager||"pnpm",isGitInitialized:Q,outputDir:Rt})}default:return null}},"renderStep"),tt=G!=="installing"&&G!=="done";return g(f,{flexDirection:"column",flexGrow:1,paddingX:2,paddingY:1,children:[tt?g(D,{children:[i(hr,{state:T,stepId:G}),i(f,{height:0}),i(gr,{displayStep:n,stepId:G,subProgress:Re??void 0,totalSteps:ne}),i(f,{height:2})]}):null,De(),i(f,{flexGrow:1}),tt?g(D,{children:[i(he,{}),i(f,{height:1}),i(Ge,{action:Ne,showBack:!0})]}):null]})},"CreateProjectWizardScreen"),Qe=` _ _ ___ ___ _____ _ ___ ___ _ _
49
+ | \\| | __/ __|_ _| /_\\ | _ \\/ __| || |
50
+ | .\` | _|\\__ \\ | | / _ \\| / (__| __ |
51
+ |_|\\_|___|___/ |_| /_/ \\_\\_|_\\\\___|_||_|`,us=12,ds=4,Nt=p(({onlyCat:t=!1})=>{const{stdout:e}=rt(),r=e.columns||e.getWindowSize?.()[0]||80,s=e.rows||e.getWindowSize?.()[1]||24;return t?s<15||r<20?i(f,{flexDirection:"column",alignItems:"center",children:i(c,{bold:!0,color:S,children:it})}):i(f,{flexDirection:"column",alignItems:"center",children:i(c,{color:S,children:Ie})}):s<15||r<38?g(f,{flexDirection:"column",alignItems:"center",rowGap:0,children:[i(c,{bold:!0,color:S,children:it}),i(c,{color:P,children:ke}),i(c,{color:U,children:we})]}):s<15+ds||r<55?g(f,{flexDirection:"column",alignItems:"center",rowGap:0,children:[i(c,{color:S,children:Qe}),i(c,{color:P,children:ke}),i(c,{color:U,children:we})]}):s<15+us||r<80?g(f,{flexDirection:"column",alignItems:"center",rowGap:0,children:[i(c,{color:S,children:Ie}),i(c,{color:S,children:Qe}),i(c,{color:P,children:ke}),i(c,{color:U,children:we})]}):g(f,{flexDirection:"row",columnGap:2,alignItems:"flex-start",children:[i(c,{color:S,children:Ie}),g(f,{flexDirection:"column",children:[i(c,{color:S,children:Qe}),g(c,{color:P,children:[" ",ke]}),g(c,{color:U,children:[" ",we]})]})]})},"Header"),Xe={addons:["ultracite","husky"],api:["rest"],architecture:"nest-api",auth:"none",database:[],extras:[],formatter:"oxlint-oxfmt",httpProvider:"express",microservices:[],orm:[],packageManager:"pnpm",projectType:"single",ultraciteAgents:[],ultraciteEditors:[],ultraciteHooks:[],ultraciteInstallSkill:"no"},ms=p(({onSelect:t,options:e})=>{const[r,s]=N(0),o=v(()=>{const n=e[r];n&&!n.disabled&&t(n)},[t,e,r]);return Ae((n,a)=>{a.upArrow||n==="k"?s(l=>Math.max(0,l-1)):a.downArrow||n==="j"?s(l=>Math.min(e.length-1,l+1)):a.return&&o()}),g(f,{flexDirection:"column",children:[i(c,{color:P,children:"Choose a project preset"}),i(f,{marginTop:1,flexDirection:"column",rowGap:1,children:e.map((n,a)=>g(f,{flexDirection:"column",children:[i(c,{children:a===r?g(D,{children:[i(c,{color:n.disabled?me:S,children:"> "}),i(c,{color:n.disabled?me:S,children:n.name})]}):i(c,{color:n.disabled?me:Se,children:` ${n.name}`})}),a===r&&n.description?i(c,{color:P,children:n.description}):null]},n.name))})]})},"PresetStep"),hs={done:"Done",initGit:"Git repository",installing:"Installing",preset:"Project preset",projectName:"Project name"},gs=p(({step:t})=>g(c,{children:[i(c,{color:S,children:"\u2727 "}),i(c,{color:R,children:hs[t]})]}),"WizardTitle"),fs=p(({onBack:t,onDone:e,onExit:r,onStepChange:s})=>{const[o,n]=N("preset"),[a,l]=N(""),[u,m]=N(null),[y,w]=N(null),[E,M]=N(null),[j,se]=N("");ue(()=>{o==="done"&&e()},[o,e]);const z=V(()=>fr(),[]),$=V(()=>{const x=[{description:"REST API with standard NestJS modules and structure",name:"Basic NestJS API"},{description:"Microservice support with gateway routing",name:"API Gateway"}];return z?x.push({description:yr(z),name:"Last Used"}):x.push({description:"",disabled:!0,name:"Last Used"}),x},[z]),[F,K]=N(Xe),X=v(()=>{switch(o){case"projectName":{n("preset"),s?.("preset"),m(null);return}case"initGit":{n("projectName"),s?.("projectName");return}default:t()}},[t,o,s]),te=v(x=>{if(x.name==="Last Used"&&z){const{projectName:J,initGit:oe,...re}=z;K(re)}else x.name==="API Gateway"?K({...Xe,architecture:"nest-gateway",projectType:"monorepo"}):K(Xe);n("projectName"),s?.("projectName")},[z,s]),k=v(x=>{l(x),m(Te(x))},[]),A=v(()=>{const x=Te(a);if(x){m(x);return}n("initGit"),s?.("initGit")},[a,s]),C=v(async x=>{w(x);const J=ae(a),oe=Ke(J);se(oe),n("installing"),s?.("installing");const re={...F,initGit:x,projectName:J};try{const q=await Ct(re);M({isError:!q.success,message:q.message}),q.success&&(At(re),setTimeout(()=>{n("done"),s?.("done")},1e3))}catch(q){M({isError:!0,message:`Error: ${q instanceof Error?q.message:String(q)}`})}},[a,F,s]);ie((x,J)=>{if(J.ctrl&&x==="c"){r();return}if(J.ctrl&&x==="b"&&o!=="done"){X();return}o==="done"&&J.return&&r()});const H=V(()=>o==="projectName"?"confirm":"select",[o]),B=o!=="installing"&&o!=="done";return g(f,{flexDirection:"column",flexGrow:1,paddingX:2,paddingY:1,children:[B?g(D,{children:[i(Nt,{}),i(he,{}),i(f,{height:1}),i(gs,{step:o}),i(f,{height:2})]}):null,p(()=>{switch(o){case"preset":return i(ms,{onSelect:te,options:$});case"projectName":return i(mt,{error:u,onChange:k,onSubmit:A,value:a});case"initGit":return i(ee,{onConfirm:C,options:wt,prompt:"Initialize a git repository?"});case"installing":return g(f,{flexDirection:"column",children:[i(lt,{message:E?.message||"Scaffolding your project",isError:E?.isError??!1}),E?.isError?i(f,{marginTop:1,children:g(c,{color:P,children:["Press ",i(c,{color:S,children:"Enter"})," to go back to Summary and retry, or ",i(c,{color:P,children:"Ctrl+B"})," to go back"]})}):null]});case"done":{const x=ae(a);return i(pt,{architecture:F.architecture||"nest-api",projectName:x,packageManager:F.packageManager||"pnpm",isGitInitialized:y==="yes",outputDir:j})}default:return null}},"renderStep")(),i(f,{flexGrow:1}),B?g(D,{children:[i(he,{}),i(f,{height:1}),i(Ge,{action:H,showBack:!0})]}):null]})},"ProjectPresetWizardScreen"),_e=[{description:"Scaffold a new project with best practices",name:"Create a new NestJS project"},{description:"Choose from predefined configurations",name:"Use a project preset"},{description:"Browse the Nest Arch docs",name:"View documentation"},{description:"Close Nest Arch",name:"Exit"}],ys=p(({onSelect:t})=>{const[e,r]=N(0),s=v(()=>{const a=_e[e]??null;a?.disabled||t(e,a)},[t,e]),o=[];for(let a=0;a<_e.length;a+=1)_e[a].disabled||o.push(a);const n=o.indexOf(e);return Ae((a,l)=>{if(l.upArrow||a==="k"){const u=o[n-1];u!==void 0&&r(u)}else if(l.downArrow||a==="j"){const u=o[n+1];u!==void 0&&r(u)}else l.return&&s()}),g(f,{flexDirection:"column",children:[i(c,{color:P,children:" What would you like to do?"}),i(f,{marginTop:1,flexDirection:"column",rowGap:1,children:_e.map((a,l)=>i(c,{children:l===e&&!a.disabled?g(D,{children:[i(c,{color:S,children:"> "}),i(c,{color:S,children:a.name})]}):i(c,{color:Se,children:` ${a.name}`})},a.name))})]})},"MainMenu"),bs=p(()=>g(c,{children:[i(c,{color:S,children:"\u2727 "}),i(c,{color:R,children:" Welcome to "}),i(c,{color:S,children:"Nest Arch"}),i(c,{color:R,children:" \u2013 Let's build something amazing."})]}),"WelcomeMessage"),js=p(({onCreateProject:t,onExit:e,onUsePreset:r})=>{const s=v(async()=>{const n="https://github.com/Angel-Mario";try{await Wt(n,{wait:!1})}catch{}},[]),o=v((n,a)=>{a?.name==="Exit"?e():a?.name==="Create a new NestJS project"?t():a?.name==="Use a project preset"?r():a?.name==="View documentation"&&s()},[t,e,r,s]);return ie((n,a)=>{a.ctrl&&n==="c"&&e()}),g(f,{flexDirection:"column",flexGrow:1,paddingX:2,paddingY:1,children:[i(Nt,{}),i(he,{}),i(f,{height:1}),i(bs,{}),i(f,{height:2}),i(ys,{onSelect:o}),i(f,{flexGrow:1}),i(he,{borderTop:!1}),i(f,{height:1}),i(Ge,{})]})},"WelcomeScreen"),vs=p(({onDone:t})=>{const[e,r]=N("welcome"),{stdout:s}=rt(),{exit:o}=Mt(),[n,a]=N(s?.rows??24);ue(()=>{if(!s)return;const E=p(()=>{a(s.rows)},"handleResize");return s.on("resize",E),()=>{s.off("resize",E)}},[s]);const l=v(()=>{o()},[o]),u=v(()=>{r("preset-wizard")},[]),m=v(()=>{r("create-wizard")},[]),y=v(()=>{r("welcome")},[]);return i(f,{height:n,flexDirection:"column",children:p(()=>e==="create-wizard"?i(ps,{onBack:y,onDone:t,onExit:l}):e==="preset-wizard"?i(fs,{onBack:y,onDone:t,onExit:l}):i(js,{onCreateProject:m,onExit:l,onUsePreset:u}),"renderScreen")()})},"App");async function ws(){process.stdout.write("\x1B[?1049h");let t=!1;try{await Dt(i(vs,{onDone:p(()=>{process.stdout.write("\x1B[?1049l"),t=!0},"onDone")})).waitUntilExit()}finally{t||process.stdout.write("\x1B[?1049l")}}p(ws,"main");try{await ws()}catch(t){console.error("Error:",t),process.exit(1)}export{He as e};
package/dist/index.js CHANGED
@@ -1 +1 @@
1
- import"react/jsx-runtime";import"ink";import"react";import"./index-BPbtxfGB.js";import"ink-text-input";import"@t3-oss/env-nextjs";import"zod";import"node:fs";import"node:os";import"node:path";import"node:child_process";import"node:util";import"node:fs/promises";import"handlebars";import"ts-morph";import"open";
1
+ import"react/jsx-runtime";import"ink";import"react";import"./index-DuMVjfjC.js";import"ink-text-input";import"@t3-oss/env-nextjs";import"zod";import"node:fs";import"node:os";import"node:path";import"node:child_process";import"node:fs/promises";import"node:util";import"handlebars";import"ts-morph";import"open";
@@ -1,10 +1,13 @@
1
1
  import { NestFactory } from "@nestjs/core";
2
+ {{#if (eq httpProvider "fastify")}}
3
+ import { FastifyAdapter, NestFastifyApplication } from "@nestjs/platform-fastify";
4
+ {{/if}}
2
5
 
3
6
  import { AppModule } from "./app.module.js";
4
7
  import { env } from "./config/env.js";
5
8
 
6
9
  async function bootstrap() {
7
- const app = await NestFactory.create(AppModule);
10
+ const app = await NestFactory.create{{#if (eq httpProvider "fastify")}}<NestFastifyApplication>(AppModule, new FastifyAdapter()){{else}}(AppModule){{/if}};
8
11
  app.enableCors({
9
12
  origin: env.CORS_ORIGIN,
10
13
  });
@@ -1,10 +1,13 @@
1
1
  import { NestFactory } from "@nestjs/core";
2
+ {{#if (eq httpProvider "fastify")}}
3
+ import { FastifyAdapter, NestFastifyApplication } from "@nestjs/platform-fastify";
4
+ {{/if}}
2
5
  import { env } from "@repo/env/api-gateway";
3
6
 
4
7
  import { AppModule } from "./app.module.js";
5
8
 
6
9
  async function bootstrap() {
7
- const app = await NestFactory.create(AppModule);
10
+ const app = await NestFactory.create{{#if (eq httpProvider "fastify")}}<NestFastifyApplication>(AppModule, new FastifyAdapter()){{else}}(AppModule){{/if}};
8
11
  app.enableCors({
9
12
  origin: env.CORS_ORIGIN,
10
13
  });
@@ -1,10 +1,13 @@
1
1
  import { NestFactory } from "@nestjs/core";
2
+ {{#if (eq httpProvider "fastify")}}
3
+ import { FastifyAdapter, NestFastifyApplication } from "@nestjs/platform-fastify";
4
+ {{/if}}
2
5
 
3
6
  import { AppModule } from "./app.module.js";
4
7
  import { env } from "./config/env.js";
5
8
 
6
9
  async function bootstrap() {
7
- const app = await NestFactory.create(AppModule);
10
+ const app = await NestFactory.create{{#if (eq httpProvider "fastify")}}<NestFastifyApplication>(AppModule, new FastifyAdapter()){{else}}(AppModule){{/if}};
8
11
  app.enableCors({
9
12
  origin: env.CORS_ORIGIN,
10
13
  });
@@ -1,5 +1,9 @@
1
1
  import { Controller, Get, Req, Res } from "@nestjs/common";
2
+ {{#if (eq httpProvider "fastify")}}
3
+ import type { FastifyRequest as Request, FastifyReply as Response } from "fastify";
4
+ {{else}}
2
5
  import type { Request, Response } from "express";
6
+ {{/if}}
3
7
 
4
8
  import { AppService } from "./app.service.js";
5
9
 
@@ -1,6 +1,10 @@
1
1
  import { Injectable } from "@nestjs/common";
2
2
  import { HttpService } from "@nestjs/axios";
3
+ {{#if (eq httpProvider "fastify")}}
4
+ import type { FastifyRequest as Request, FastifyReply as Response } from "fastify";
5
+ {{else}}
3
6
  import type { Request, Response } from "express";
7
+ {{/if}}
4
8
 
5
9
  @Injectable()
6
10
  export class AppService {
@@ -1,10 +1,13 @@
1
1
  import { NestFactory } from "@nestjs/core";
2
+ {{#if (eq httpProvider "fastify")}}
3
+ import { FastifyAdapter, NestFastifyApplication } from "@nestjs/platform-fastify";
4
+ {{/if}}
2
5
 
3
6
  import { AppModule } from "./app.module.js";
4
7
  import { env } from "./config/env.js";
5
8
 
6
9
  async function bootstrap() {
7
- const app = await NestFactory.create(AppModule);
10
+ const app = await NestFactory.create{{#if (eq httpProvider "fastify")}}<NestFastifyApplication>(AppModule, new FastifyAdapter()){{else}}(AppModule){{/if}};
8
11
  app.enableCors({
9
12
  origin: env.CORS_ORIGIN,
10
13
  });
@@ -1,11 +1,14 @@
1
1
  import { NestFactory } from "@nestjs/core";
2
+ {{#if (eq httpProvider "fastify")}}
3
+ import { FastifyAdapter, NestFastifyApplication } from "@nestjs/platform-fastify";
4
+ {{/if}}
2
5
  import { Transport, type MicroserviceOptions } from "@nestjs/microservices";
3
6
 
4
7
  import { AppModule } from "./app.module.js";
5
8
  import { env } from "./config/env.js";
6
9
 
7
10
  async function bootstrap() {
8
- const app = await NestFactory.create(AppModule);
11
+ const app = await NestFactory.create{{#if (eq httpProvider "fastify")}}<NestFastifyApplication>(AppModule, new FastifyAdapter()){{else}}(AppModule){{/if}};
9
12
 
10
13
  app.connectMicroservice<MicroserviceOptions>({
11
14
  transport: Transport.TCP,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@nest-arch/tui",
3
- "version": "0.1.37",
3
+ "version": "0.1.39",
4
4
  "private": false,
5
5
  "description": "Interactive terminal UI for generating NestJS projects",
6
6
  "keywords": [
@@ -48,7 +48,7 @@
48
48
  "pkgroll": "^2.5.2",
49
49
  "tsx": "^4.19.2",
50
50
  "vitest": "^4.1.7",
51
- "@nest-arch/core": "0.1.37",
51
+ "@nest-arch/core": "0.1.39",
52
52
  "@nest-arch/env": "0.0.0",
53
53
  "@nest-arch/shared": "0.0.0"
54
54
  },
@@ -1,50 +0,0 @@
1
- var Pt=Object.defineProperty;var p=(t,e)=>Pt(t,"name",{value:e,configurable:!0});import{jsx as i,jsxs as f,Fragment as N}from"react/jsx-runtime";import{Box as g,Text as c,useInput as B,useStdout as Ve,render as Ct,useApp as Tt}from"ink";import{useState as I,useEffect as le,useCallback as j,useMemo as J}from"react";import xt from"ink-text-input";import{createEnv as _t}from"@t3-oss/env-nextjs";import{z as re}from"zod";import{existsSync as xe,readFileSync as It,mkdirSync as Ot,writeFileSync as Nt}from"node:fs";import{homedir as Ke}from"node:os";import R,{join as q}from"node:path";import{execFile as Mt,exec as Rt}from"node:child_process";import{promisify as Qe}from"node:util";import F,{readFile as _e,writeFile as ge}from"node:fs/promises";import D from"handlebars";import"ts-morph";import Dt from"open";const Ye="Nest Arch",fe="v0.1.37",be="The comfy way to build NestJS projects",S="#e54545",P="#A0A0A0",ye="#6B6B6B",O="#E5E5E5",G="#61AFEF",pe="#3A3A3A",Gt="#7FD99A",ve="#E8C468",je="#e96142ff",ue=p(({borderTop:t=!0})=>i(g,{borderStyle:"single",borderBottom:!t,borderLeft:!1,borderRight:!1,borderTop:t,borderColor:pe,height:1,width:"full"}),"Divider"),$t=` \uFF0Fl\u3001
2
- \uFF08\uFF9F\uFF64 \uFF61\uFF17
3
- l\u3001\uFF9E ~\u30FD
4
- \u3058\u3057(_,)\u30CE
5
- `,Ie=` ,-. _,---._ __ /\\
6
- / ) .-' \`./ / \\
7
- ( ( ,' \` / /|
8
- \\ \`-" \\'\\ / |
9
- \`. , \\ \\ / |
10
- /\`. ,'-\`----Y |
11
- ( ; | '
12
- | ,-. ,-' Angel's | /
13
- | | ( | Stuff | /
14
- ) | \\ \`.___________|/
15
- \`--' \`--'
16
- `,Xe=[{col:14,row:0},{col:16,row:1},{col:15,row:2},{col:13,row:3},{col:11,row:2},{col:10,row:1}],Ze=["",".","..","..."],et=p(({message:t,isError:e})=>{const[r,s]=I(0),[o,n]=I(0);le(()=>{const u=setInterval(()=>{s(y=>(y+1)%Xe.length)},200),h=setInterval(()=>{n(y=>(y+1)%Ze.length)},400);return()=>{clearInterval(u),clearInterval(h)}},[]);const a=$t.trimEnd().split(`
17
- `),l=Xe[r];return f(g,{flexDirection:"column",paddingX:2,children:[i(g,{flexDirection:"column",children:a.map((u,h)=>{if(l&&h===l.row){const y=l.col,k=u.slice(0,y),w=u.slice(y+1);return f(g,{flexDirection:"row",children:[i(c,{children:k}),i(c,{color:ve,children:"\u25CF"}),i(c,{children:w})]},h)}return i(c,{color:S,children:u},h)})}),f(c,{color:e?O:P,children:[t,e?"":Ze[o]]})]})},"ScaffoldingAnimation"),Oe=p(({action:t="select",showBack:e=!1})=>f(c,{children:[t==="select"||t==="multi-select"?i(c,{color:P,children:"Use \u2191/\u2193 to navigate \u2022 "}):null,i(c,{color:P,children:t==="confirm"?f(N,{children:[i(c,{color:O,children:"Enter "}),"to confirm"]}):t==="multi-select"?f(N,{children:[i(c,{color:O,children:"Space "}),"to toggle \u2022",i(c,{color:O,children:" Enter "}),"to confirm"]}):f(N,{children:[i(c,{color:O,children:"Enter "}),"to select"]})}),f(c,{color:P,children:[e?f(N,{children:[" ","\u2022",i(c,{color:O,children:" Ctrl+B "}),"to go back"]}):"",f(N,{children:[" ","\u2022",i(c,{color:O,children:" Ctrl+C "}),"to exit"]})]})]}),"StatusBar"),tt=p(({architecture:t,projectName:e,packageManager:r,isGitInitialized:s,outputDir:o})=>i(g,{flexDirection:"column",children:f(g,{flexDirection:"column",marginTop:1,children:[i(c,{color:Gt,bold:!0,children:"\u2714 Project scaffold completed successfully!"}),f(g,{marginTop:1,children:[i(c,{color:O,children:"Project: "}),i(c,{color:G,bold:!0,children:e})]}),f(g,{children:[i(c,{color:O,children:"Architecture: "}),i(c,{color:G,bold:!0,children:t})]}),o?f(g,{children:[i(c,{color:O,children:"Location: "}),i(c,{color:G,bold:!0,children:o})]}):null,s?i(g,{marginTop:1,children:i(c,{color:P,children:"Git repository initialized"})}):null,f(g,{flexDirection:"column",borderStyle:"round",borderColor:S,paddingX:2,paddingY:1,marginTop:1,width:void 0,children:[i(c,{color:O,bold:!0,children:"\u{1F680} NEXT STEPS"}),i(g,{height:1}),i(c,{color:O,children:"1. Move into the project directory:"}),i(c,{color:G,bold:!0,children:` cd ${e}`}),i(g,{height:1}),i(c,{color:O,children:"2. Install dependencies:"}),i(c,{color:G,bold:!0,children:` ${r} install`}),i(g,{height:1}),i(c,{color:O,children:"3. Start development server:"}),i(c,{color:G,bold:!0,children:` ${r} run dev`})]}),i(g,{marginTop:1,children:i(c,{color:P,children:"(Press enter to exit)"})})]})}),"DoneStep"),V=p(({initialSelected:t,onConfirm:e,options:r,prompt:s,minified:o=!1})=>{const[n,a]=I(0),[l,u]=I(t);le(()=>{u(t),a(0)},[t]);const h=j(A=>l.includes(A),[l]),y=j(A=>{const E=r[A];E&&u(C=>C.includes(E.value)?C.filter(H=>H!==E.value):[...C,E.value])},[r]),k=j(()=>{e(l)},[e,l]),w=r.length>16,M=w?Math.ceil(r.length/2):r.length;B((A,E)=>{E.upArrow||A==="k"?a(C=>Math.max(0,C-1)):E.downArrow||A==="j"?a(C=>Math.min(r.length-1,C+1)):w&&(E.leftArrow||A==="h")?a(C=>Math.max(0,C-M)):w&&(E.rightArrow||A==="l")?a(C=>Math.min(r.length-1,C+M)):E.return?k():(A===" "||A==="x")&&y(n)});const v=l.length,W=p((A,E)=>{const C=h(A.value),H=E===n,Q=C?"\u25CF":"\u25CB";return f(g,{flexDirection:"column",children:[i(c,{children:H?f(N,{children:[i(c,{color:S,children:"> "}),i(c,{color:C?S:P,children:`${Q} `}),i(c,{color:C?S:O,children:A.label})]}):f(N,{children:[i(c,{color:C?S:P,children:` ${Q}`}),i(c,{color:ye,children:` ${A.label}`})]})}),H&&!o?i(c,{color:P,children:A.description}):null]},A.value)},"renderOption");let $;return w||($=o?0:1),f(g,{flexDirection:"column",children:[i(c,{color:P,children:s}),i(c,{color:ve,children:v===0?"No options selected yet \u2014 pick what you need":`${v} selected`}),i(g,{marginTop:1,flexDirection:w?"row":"column",rowGap:$,columnGap:w?4:void 0,overflow:"hidden",children:w?f(N,{children:[i(g,{flexDirection:"column",rowGap:o?0:1,flexGrow:1,flexBasis:0,children:r.slice(0,M).map((A,E)=>W(A,E))}),i(g,{flexDirection:"column",rowGap:o?0:1,flexGrow:1,flexBasis:0,children:r.slice(M).map((A,E)=>W(A,E+M))})]}):r.map((A,E)=>W(A,E))})]})},"MultiSelectStep"),rt="my-nest-app",st=64,Ft=/^[a-z][a-z0-9-]*$/u;function Z(t){return t.trim()||rt}p(Z,"resolveProjectName");function we(t){const e=t.trim();return e?e.length>st?`Project name must be at most ${st} characters`:Ft.test(e)?null:"Use lowercase letters, numbers, and hyphens; must start with a letter":null}p(we,"validateProjectName");const nt=p(({error:t,onChange:e,onSubmit:r,value:s})=>(B((o,n)=>{n.return&&r()}),f(g,{flexDirection:"column",children:[i(c,{color:P,children:"Enter a name for your project"}),f(g,{marginTop:1,flexDirection:"row",alignItems:"center",columnGap:1,children:[i(c,{color:O,children:"Project name:"}),i(xt,{placeholder:rt,value:s,onChange:e})]}),t?i(c,{color:S,children:t}):null]})),"ProjectNameStep"),K=p(({onConfirm:t,options:e,prompt:r})=>{const[s,o]=I(0),n=j(()=>{const a=e[s];a&&t(a.value)},[t,e,s]);return B((a,l)=>{l.upArrow||a==="k"?o(u=>Math.max(0,u-1)):l.downArrow||a==="j"?o(u=>Math.min(e.length-1,u+1)):l.return&&n()}),f(g,{flexDirection:"column",children:[i(c,{color:P,children:r}),i(g,{marginTop:1,flexDirection:"column",rowGap:1,children:e.map((a,l)=>{const u=l===s;return f(g,{flexDirection:"column",children:[i(c,{children:u?f(N,{children:[i(c,{color:S,children:"> "}),i(c,{color:S,children:a.label})]}):i(c,{color:ye,children:` ${a.label}`})}),u?i(c,{color:P,children:a.description}):null]},a.value)})})]})},"SingleSelectStep"),it=[{description:"Fast, disk-efficient package manager (recommended)",label:"pnpm",value:"pnpm"},{description:"Default Node.js package manager",label:"npm",value:"npm"},{description:"Classic alternative with workspaces support",label:"yarn",value:"yarn"},{description:"A superfast Node.js-compatible package manager",label:"bun",value:"bun"}],Ne=[{description:"The modern, all-in-one toolchain written in Rust",label:"Biome",value:"biome"},{description:"The most mature and comprehensive linting ecosystem",label:"ESLint + Prettier",value:"eslint-prettier"},{description:"The fastest linter available, 50-100x faster than ESLint",label:"Oxlint + Oxfmt",value:"oxlint-oxfmt"},{description:"No formatter and no linter. Welcome to the jungle",label:"(None)",value:"none"}],at=[{description:"Default NestJS HTTP adapter",label:"Express",value:"express"},{description:"High-performance HTTP adapter",label:"Fastify",value:"fastify"}],ot=[{description:"Standalone NestJS application",label:"Single project",value:"single"},{description:"Multiple apps and shared packages",label:"Monorepo (Turborepo)",value:"monorepo"}],ct=[{description:"Standard REST or GraphQL API application",label:"NestJS API",value:"nest-api"},{description:"Gateway routing for microservices (monorepo only)",label:"NestJS API Gateway",value:"nest-gateway"},{description:"Message-based or RPC microservice",label:"NestJS Microservice",value:"nest-microservice"}],lt=[{description:"Relational database with strong ecosystem",label:"PostgreSQL",value:"postgresql"},{description:"Popular relational database",label:"MySQL",value:"mysql"},{description:"Embedded database for local development",label:"SQLite",value:"sqlite"},{description:"Document database",label:"MongoDB",value:"mongodb"}],Me=[{description:"Type-safe ORM with schema and migrations",label:"Prisma",value:"prisma"},{description:"Decorator-based ORM for TypeScript",label:"TypeORM",value:"typeorm"},{description:"Lightweight SQL ORM (not available with MongoDB)",label:"Drizzle",value:"drizzle"}],pt=[{description:"RESTful HTTP endpoints",label:"REST",value:"rest"},{description:"End-to-end typesafe APIs",label:"tRPC",value:"trpc"},{description:"GraphQL schema and resolvers",label:"GraphQL",value:"graphql"}],ut=[{description:"No authentication scaffolding",label:"None",value:"none"},{description:"JSON Web Token authentication",label:"JWT",value:"jwt"},{description:"Flexible authentication middleware",label:"Passport",value:"passport"},{description:"Modern auth library integration",label:"Better Auth",value:"better-auth"}],Re=[{description:"Dockerfile and docker-compose setup",label:"Docker",value:"docker"},{description:"Terminus health check endpoints",label:"Health Check",value:"health-check"},{description:"Request throttling middleware",label:"Rate Limiting",value:"rate-limiting"},{description:"OpenAPI documentation",label:"Swagger",value:"swagger"},{description:"Shared packages for API types in a monorepo",label:"packages/shared",value:"packages/shared"}],dt=[{description:"Cursor agent skills library (.agents/skills)",label:"Agent Skills",value:"agent-skills"},{description:"Git hooks for pre-commit checks",label:"Husky",value:"husky"},{description:"Configurate ultracite for your developer tools",label:"Ultracite",value:"ultracite"},{description:"Zod-based DTO validation",label:"NestJS-Zod",value:"nestjs-zod"},{description:"Modern OpenAPI documentation UI",label:"Scalar UI (Recommended)",value:"scalar-ui"}],Lt=[{description:"Pub/sub or streaming protocol",label:"Redis",value:"redis"},{description:"Lightweight MQTT messaging",label:"MQTT",value:"mqtt"},{description:"Cloud-native messaging broker",label:"NATS",value:"nats"},{description:"Enterprise messaging with RabbitMQ",label:"RabbitMQ",value:"rabbitmq"},{description:"Highly scalable Kafka streaming",label:"Kafka",value:"kafka"},{description:"RPC-style gRPC communication",label:"gRPC",value:"grpc"}],mt=[{description:"Run git init and create initial commit",label:"Yes",value:"yes"},{description:"Skip git initialization",label:"No",value:"no"}],Ut=[{description:"Write .vscode/settings.json for every VS Code-based editor",label:"Universal",value:"universal"},{description:"Antigravity code editor",label:"Antigravity",value:"antigravity"},{description:"Bob code editor",label:"Bob",value:"bob"},{description:"CodeBuddy code editor",label:"CodeBuddy",value:"codebuddy"},{description:"Cursor AI code editor",label:"Cursor",value:"cursor"},{description:"Kiro AI IDE",label:"Kiro",value:"kiro"},{description:"Trae AI IDE",label:"Trae",value:"trae"},{description:"Visual Studio Code",label:"VS Code",value:"vscode"},{description:"Windsurf AI code editor",label:"Windsurf",value:"windsurf"},{description:"Void code editor",label:"Void",value:"void"},{description:"Zed code editor",label:"Zed",value:"zed"}],zt=[{description:"Configure for all AI agents",label:".agents (Universal)",value:"universal"},{description:"Adal AI",label:"Adal",value:"adal"},{description:"Aider AI",label:"Aider",value:"aider"},{description:"Amazon Q CLI",label:"Amazon Q",value:"amazon-q-cli"},{description:"Amp AI",label:"Amp",value:"amp"},{description:"Augment Code",label:"Augment",value:"augmentcode"},{description:"Anthropic Claude",label:"Claude",value:"claude"},{description:"Cline AI",label:"Cline",value:"cline"},{description:"OpenAI Codex",label:"Codex",value:"codex"},{description:"GitHub Copilot",label:"Copilot",value:"copilot"},{description:"Continue AI",label:"Continue",value:"continue"},{description:"Crush AI",label:"Crush",value:"crush"},{description:"Cursor CLI",label:"Cursor CLI",value:"cursor-cli"},{description:"DeepAgents AI",label:"DeepAgents",value:"deepagents"},{description:"Devin AI",label:"Devin",value:"devin"},{description:"Droid AI",label:"Droid",value:"droid"},{description:"Firebender AI",label:"Firebender",value:"firebender"},{description:"Firebase Studio",label:"Firebase Studio",value:"firebase-studio"},{description:"Google Gemini",label:"Gemini",value:"gemini"},{description:"Goose AI",label:"Goose",value:"goose"},{description:"JetBrains Junie",label:"Junie",value:"junie"},{description:"Google Jules",label:"Jules",value:"jules"},{description:"Kilo Code",label:"Kilo Code",value:"kilo-code"},{description:"Kimi CLI",label:"Kimi CLI",value:"kimi-cli"},{description:"Lovable AI",label:"Lovable",value:"lovable"},{description:"MCPJam AI",label:"MCPJam",value:"mcpjam"},{description:"Mistral Vibe",label:"Mistral Vibe",value:"mistral-vibe"},{description:"Mux AI",label:"Mux",value:"mux"},{description:"Ona AI",label:"Ona",value:"ona"},{description:"OpenClaw AI",label:"OpenClaw",value:"openclaw"},{description:"OpenCode AI",label:"OpenCode",value:"opencode"},{description:"OpenHands AI",label:"OpenHands",value:"open-hands"},{description:"Pi AI",label:"Pi",value:"pi"},{description:"Qoder AI",label:"Qoder",value:"qoder"},{description:"Qwen AI",label:"Qwen",value:"qwen"},{description:"Replit AI",label:"Replit",value:"replit"},{description:"Roo Code",label:"Roo Code",value:"roo-code"},{description:"Snowflake Cortex",label:"Snowflake Cortex",value:"snowflake-cortex"},{description:"Vercel AI",label:"Vercel",value:"vercel"},{description:"Warp AI",label:"Warp",value:"warp"},{description:"Zencoder AI",label:"Zencoder",value:"zencoder"}],Ht=[{description:"Cursor agent hooks",label:"Cursor",value:"cursor"},{description:"Windsurf agent hooks",label:"Windsurf",value:"windsurf"},{description:"CodeBuddy agent hooks",label:"CodeBuddy",value:"codebuddy"},{description:"Claude agent hooks",label:"Claude",value:"claude"}],Bt=[{description:"Install the reusable Ultracite skill after setup",label:"Yes",value:"yes"},{description:"Skip installing the Ultracite skill",label:"No",value:"no"}],Wt={addons:"Addons",apiLayer:"API layer",architecture:"Architecture",auth:"Authentication",database:"Database",done:"Done",extras:"Extras",formatter:"Formatter",httpProvider:"HTTP provider",initGit:"Git repository",installing:"Installing",microservices:"Microservices communication",orm:"ORM",packageManager:"Package manager",projectName:"Project name",projectType:"Project type",summary:"Summary",ultraciteAgents:"Ultracite agents",ultraciteEditors:"Ultracite editors",ultraciteHooks:"Ultracite hooks",ultraciteInstallSkill:"Ultracite skill",ultraciteSetup:"Ultracite setup"},Jt=["projectName","packageManager","formatter","httpProvider","projectType","architecture","database","orm","apiLayer","auth","extras","microservices","addons","ultraciteEditors","ultraciteAgents","ultraciteHooks","ultraciteInstallSkill","initGit","summary","ultraciteSetup","installing","done"];function qt(t){return t.includes("mongodb")}p(qt,"databaseIncludesMongodb");function Vt(t){return t.length===0}p(Vt,"databaseIsEmpty");function ke(t){return Vt(t)}p(ke,"shouldSkipOrmStep");function de(t){return Jt.filter(e=>!(e==="orm"&&ke(t.database)||e==="microservices"&&t.architecture!=="nest-gateway"||(e==="ultraciteEditors"||e==="ultraciteAgents"||e==="ultraciteHooks"||e==="ultraciteInstallSkill"||e==="ultraciteSetup")&&!t.addons.includes("ultracite")))}p(de,"getVisibleSteps");const ht=["ultraciteEditors","ultraciteAgents","ultraciteHooks","ultraciteInstallSkill"];function me(t){return ht.includes(t)}p(me,"isUltraciteSubStep");function Kt(t,e){if(!me(t))return null;const r=ht.filter(l=>de(e).includes(l)),s=r.indexOf(t);if(s===-1)return null;const o=r.length,n=s+1,a=Math.round(n/o*100);return{current:n,percent:a,total:o}}p(Kt,"getUltraciteSubStepInfo");function gt(t){return de(t).filter(e=>!(e==="installing"||e==="done"||me(e))).length+(t.addons.includes("ultracite")?1:0)}p(gt,"getTotalSteps");function Qt(t,e){const r=de(e).filter(n=>n!=="installing"&&n!=="done");if(t==="installing"||t==="done")return gt(e);if(me(t)){const n=r.indexOf("addons");return n===-1?1:n+1}const o=r.filter(n=>!me(n)).indexOf(t);return o===-1?1:o+1}p(Qt,"getDisplayStepNumber");function Yt(t,e){const r=de(e),s=r.indexOf(t);return s===-1||s>=r.length-1?null:r[s+1]??null}p(Yt,"getNextStepId");function Xt(t,e){const r=de(e),s=r.indexOf(t);return s<=0?null:r[s-1]??null}p(Xt,"getPreviousStepId");function Zt(t){return t==="monorepo"?ct:ct.filter(e=>e.value!=="nest-gateway")}p(Zt,"filterArchitectureOptions");function ft(t){return qt(t)?Me.filter(e=>e.value!=="drizzle"):Me}p(ft,"filterOrmOptions");function bt(t){return"nest-api"}p(bt,"defaultArchitecture");function yt(t,e){if(ke(e))return[];const r=new Set(ft(e).map(s=>s.value));return t.filter(s=>r.has(s))}p(yt,"sanitizeOrmForDatabase");function se(t,e){return t.find(r=>r.value===e)?.label??e}p(se,"labelFor$1");function ne(t,e){return e.length===0?"None":e.map(r=>se(t,r)).join(", ")}p(ne,"labelsFor");const er=p(({onConfirm:t,state:e})=>{B((o,n)=>{n.return&&t()});const r={"nest-api":"NestJS API","nest-gateway":"NestJS API Gateway","nest-microservice":"NestJS Microservice"},s=[{label:"Project",value:Z(e.projectName)},{label:"Package manager",value:e.packageManager?se(it,e.packageManager):"\u2014"},{label:"Formatter",value:e.formatter?se(Ne,e.formatter):"\u2014"},{label:"HTTP provider",value:e.httpProvider?se(at,e.httpProvider):"\u2014"},{label:"Project type",value:e.projectType?se(ot,e.projectType):"\u2014"},{label:"Architecture",value:e.architecture?r[e.architecture]??e.architecture:"\u2014"},{label:"Database",value:ne(lt,e.database)}];return ke(e.database)||s.push({label:"ORM",value:ne(Me,e.orm)}),s.push({label:"API layer",value:ne(pt,e.api)}),e.architecture==="nest-gateway"&&s.push({label:"Microservices",value:ne([{label:"Redis",value:"redis"},{label:"MQTT",value:"mqtt"},{label:"NATS",value:"nats"},{label:"RabbitMQ",value:"rabbitmq"},{label:"Kafka",value:"kafka"},{label:"gRPC",value:"grpc"}],e.microservices)}),s.push({label:"Auth",value:e.auth?se(ut,e.auth):"\u2014"},{label:"Extras",value:ne(Re,e.extras)},{label:"Addons",value:ne(dt,e.addons)},{label:"Git",value:e.initGit==="yes"?"Initialize repository":"Skip"}),f(N,{children:[i(g,{flexDirection:"column",marginBottom:1,children:f(c,{children:[i(c,{color:S,children:"\u2726 "}),i(c,{color:G,children:"Review your selections"})]})}),i(g,{flexDirection:"column",rowGap:1,overflow:"hidden",children:s.map(o=>f(g,{flexDirection:"row",columnGap:1,children:[i(c,{color:je,children:`${o.label}:`}),i(c,{color:ve,children:o.value})]},o.label))})]})},"SummaryStep");function tr(t,e){return t.find(r=>r.value===e)?.label??e}p(tr,"labelFor");const rr=p(({onConfirm:t,state:e})=>{B((n,a)=>{a.return&&t()});const r=(()=>{switch(e.formatter){case"biome":return"biome";case"eslint-prettier":return"eslint";default:return"oxlint"}})(),s=[];e.addons.includes("husky")&&s.push("husky");const o=[{label:"Linter",value:`${r} (from ${tr(Ne,e.formatter??"oxlint-oxfmt")})`},{label:"Package manager",value:e.packageManager??"pnpm"},{label:"Frameworks",value:"nestjs"},{label:"Integrations",value:s.length>0?s.join(", "):"none"},{label:"Flags",value:"--quiet"}];return f(N,{children:[f(g,{flexDirection:"column",marginBottom:1,children:[f(c,{children:[i(c,{color:S,children:"\u2726 "}),i(c,{color:G,children:"Ultracite Configuration"})]}),i(c,{color:je,children:"The following configuration will be applied:"})]}),f(g,{flexDirection:"column",rowGap:1,overflow:"hidden",children:[o.map(n=>f(g,{flexDirection:"row",columnGap:1,children:[i(c,{color:je,children:`${n.label}:`}),i(c,{color:ve,children:n.value})]},n.label)),i(g,{marginTop:1,children:f(c,{color:je,children:["Command: npx ultracite init --quiet --pm ",e.packageManager," ","--linter ",r," --frameworks nestjs",s.length>0?` --integrations ${s.join(",")}`:""]})})]})]})},"UltraciteSetupStep"),De=_t({emptyStringAsUndefined:!0,runtimeEnv:process.env,server:{APP_MAX_WIDTH:re.string().pipe(re.coerce.number()).default(95),NEST_ARCH_BETA_MODE:re.enum(["true","false"]).default("false").transform(t=>t==="true"),NEST_ARCH_SCHEMA_URL:re.string().default("./schema.json"),NEST_ARCH_VERSION:re.string().default("0.0.1"),NODE_ENV:re.enum(["development","production","test"]).default("development")}});function Ge(t){return t.length===0?"\u2014":t.join(", ")}p(Ge,"formatList");const sr=p(({state:t,stepId:e})=>{const r=[];if(e!=="projectName"&&t.projectName.trim()&&r.push(Z(t.projectName)),t.packageManager&&r.push(t.packageManager),t.httpProvider&&r.push(t.httpProvider),t.projectType&&r.push(t.projectType==="monorepo"?"Monorepo":"Single"),t.architecture){const n={"nest-api":"Nest API","nest-gateway":"API Gateway","nest-microservice":"Microservice"};r.push(n[t.architecture]??t.architecture)}if(t.database.length>0&&r.push(Ge(t.database)),t.orm.length>0&&r.push(Ge(t.orm)),t.api.length>0&&r.push(Ge(t.api)),t.auth&&r.push(t.auth),t.extras.length>0&&r.push(`+${t.extras.length} extras`),t.addons.length>0&&!me(e)&&r.push(`+${t.addons.length} addons`),t.initGit&&r.push(t.initGit==="yes"?"git init":"no git"),r.length===0)return f(c,{children:[i(c,{color:S,children:"\u25C6 "}),i(c,{color:S,children:"Create a new NestJS project"})]});const[s,...o]=r;return f(N,{children:[f(c,{children:[i(c,{color:S,children:"\u25C6 "}),i(c,{color:S,children:"Create a new NestJS project"})]}),e!=="summary"&&i(g,{borderStyle:"single",borderColor:pe,width:De.APP_MAX_WIDTH,children:f(c,{children:[i(c,{children:"Project Name: "}),i(c,{color:S,children:s}),i(c,{color:P,children:" Selected: "}),o.length>0?i(c,{color:P,children:`${o.filter(n=>n!=="none").join(" \xB7 ")}`}):null]})})]})},"WizardContextBar"),nr=p(({displayStep:t,stepId:e,subProgress:r,totalSteps:s})=>f(g,{paddingLeft:2,paddingTop:e==="summary"?2:1,marginBottom:1,children:[i(c,{color:O,children:"Create project"}),i(c,{color:P,children:` \u2014 step ${t}/${s}`}),r?i(c,{color:G,children:` \xB7 Ultracite configuration (${r.current}/${r.total} \xB7 ${r.percent}%)`}):i(c,{color:G,children:` \xB7 ${Wt[e]}`})]}),"WizardTitle$1"),$e=q(Ke(),".nestarch"),Fe=q($e,"last-used.json");function ir(){try{if(!xe(Fe))return null;const t=It(Fe,"utf-8");return JSON.parse(t)}catch{return null}}p(ir,"getLastUsedConfig");function vt(t){try{xe($e)||Ot($e,{recursive:!0}),Nt(Fe,JSON.stringify(t,null,2),"utf-8")}catch{}}p(vt,"saveLastUsedConfig");function ar(t){const e=[t.packageManager];t.httpProvider&&e.push(t.httpProvider),t.api.length>0&&e.push(t.api.join(", ")),t.projectType&&e.push(t.projectType);const r=new Date,s=r.toLocaleString("en-US",{month:"short"}),o=r.getDate(),n=r.getFullYear(),a=`${s} ${o}, ${n}`;return`${e.join(", ")} (last used ${a})`}p(ar,"buildLastUsedDescription");class qe{static{p(this,"TemplateEngine")}cache={};cacheEnabled;templatesDir;constructor(e,r={}){this.templatesDir=e,this.cacheEnabled=r.cache??!0,qe.registerHelpers(r.helpers)}static registerHelpers(e){if(D.registerHelper("eq",(r,s)=>r===s),D.registerHelper("ne",(r,s)=>r!==s),D.registerHelper("lt",(r,s)=>r<s),D.registerHelper("gt",(r,s)=>r>s),D.registerHelper("and",(r,s)=>r&&s),D.registerHelper("or",(r,s)=>r||s),D.registerHelper("uppercase",r=>r?.toUpperCase?.()),D.registerHelper("lowercase",r=>r?.toLowerCase?.()),D.registerHelper("capitalize",r=>r?r.charAt(0).toUpperCase()+r.slice(1):""),D.registerHelper("camelCase",r=>r?.split("-").map((s,o)=>o===0?s.toLowerCase():s.charAt(0).toUpperCase()+s.slice(1).toLowerCase()).join("")),D.registerHelper("pascalCase",r=>r?.split("-").map(s=>s.charAt(0).toUpperCase()+s.slice(1).toLowerCase()).join("")),D.registerHelper("snakeCase",r=>r?.replaceAll(/([A-Z])/gu,"_$1").toLowerCase()),e)for(const[r,s]of Object.entries(e))D.registerHelper(r,s)}async loadTemplate(e){const r=e;if(this.cacheEnabled&&this.cache[r])return this.cache[r];const s=R.join(this.templatesDir,e),o=await F.readFile(s,"utf-8"),n=D.compile(o);return this.cacheEnabled&&(this.cache[r]=n),n}async renderTemplate(e,r){return(await this.loadTemplate(e))(r.context)}async renderToFile(e,r,s){return{content:await this.renderTemplate(e,s),filePath:r,isBinary:!1}}clearCache(){this.cache={}}getCacheStats(){return{enabled:this.cacheEnabled,size:Object.keys(this.cache).length}}}class or{static{p(this,"FileWriter")}baseDir;writtenFiles=new Set;constructor(e){this.baseDir=e}getBaseDir(){return this.baseDir}async writeFile(e,r={}){const s=R.join(this.baseDir,e.filePath),o=R.dirname(s);try{await F.mkdir(o,{recursive:!0});let n=!1;try{await F.stat(s),n=!0}catch{n=!1}if(n&&!r.overwrite)return{backed:!1,error:"File already exists and overwrite is disabled",filePath:s,written:!1};let a=!1;if(n&&r.createBackups&&!r.dryRun){const l=`${s}.bak`;await F.copyFile(s,l),a=!0}return r.dryRun||(await F.writeFile(s,e.content,"utf-8"),this.writtenFiles.add(s)),{backed:a,filePath:s,written:!r.dryRun}}catch(n){return{backed:!1,error:n instanceof Error?n.message:"Unknown error",filePath:s,written:!1}}}writeFiles(e,r={}){return Promise.all(e.map(s=>this.writeFile(s,r)))}async fileExists(e){const r=R.join(this.baseDir,e);try{return await F.stat(r),!0}catch{return!1}}getWrittenFiles(){return[...this.writtenFiles]}clearWrittenFiles(){this.writtenFiles.clear()}async copyDirectory(e,r){const s=[],o=R.join(this.baseDir,e),n=R.join(this.baseDir,r);await F.mkdir(n,{recursive:!0});const a=await F.readdir(o,{withFileTypes:!0});for(const l of a){const u=R.join(o,l.name),h=R.join(n,l.name);if(l.isDirectory()){const y=await this.copyDirectory(R.relative(this.baseDir,u),R.relative(this.baseDir,h));s.push(...y)}else{const y=await F.readFile(u,"utf-8");await F.writeFile(h,y,"utf-8"),s.push(h),this.writtenFiles.add(h)}}return s}}const Le=Qe(Mt);class cr{static{p(this,"GitInitializer")}baseDir;constructor(e){this.baseDir=e}async initGit(){try{const e=R.join(this.baseDir,".git");try{return await F.access(e),{success:!0}}catch{}return await Le("git",["init"],{cwd:this.baseDir}),await Le("git",["add","."],{cwd:this.baseDir}),await Le("git",["commit","-m","init"],{cwd:this.baseDir}),{success:!0}}catch(e){return{error:e instanceof Error?e.message:String(e),success:!1}}}}class lr{static{p(this,"TemplateRegistry")}templates=new Map;groups=new Map;registerTemplate(e){this.templates.set(e.id,e)}registerTemplates(e){for(const r of e)this.registerTemplate(r)}registerGroup(e){this.groups.set(e.id,e);for(const r of e.templates)this.registerTemplate(r)}getTemplate(e){return this.templates.get(e)}getGroup(e){return this.groups.get(e)}getAllTemplates(){return[...this.templates.values()]}getAllGroups(){return[...this.groups.values()]}getTemplatesByGroup(e){return this.groups.get(e)?.templates||[]}getTemplatesByFormat(e){return[...this.templates.values()].filter(r=>r.format===e)}async loadFromDirectory(e,r){const s=[];try{const o=await F.readdir(e,{withFileTypes:!0});for(const n of o){if(!n.isFile())continue;const{name:a}=n,l=R.extname(a);if(l===".hbs"){const u=R.basename(a,l),h={description:`Template: ${u}`,format:"handlebars",id:u,name:u.replaceAll(/[-_]/gu," "),optional:a.startsWith("_"),path:R.join(R.relative(R.dirname(e),e),a)};s.push(h),this.registerTemplate(h)}}if(r&&s.length>0){const n={description:`Templates from ${e}`,id:r,name:r,templates:s};this.registerGroup(n)}}catch(o){console.error(`Failed to load templates from ${e}:`,o)}return s}clear(){this.templates.clear(),this.groups.clear()}getStats(){return{groupCount:this.groups.size,templateCount:this.templates.size}}}function x(t,e,r){const s="[ultracite-inject]";if(r){const o=r instanceof Error?r.message:String(r);console.error(`${s} ${t}: ${e} \u2014 ${o}`)}else console.error(`${s} ${t}: ${e}`)}p(x,"log");const Ue={biome:{complexity:{noStaticOnlyClass:"off",noUselessConstructor:"off"},style:{noParameterProperties:"off",useImportType:"off"}},eslint:{"@typescript-eslint/consistent-type-imports":"off","@typescript-eslint/no-extraneous-class":"off","@typescript-eslint/parameter-properties":"off","class-methods-use-this":"off","func-style":["off"],"no-useless-constructor":"off","unicorn/no-static-only-class":"off","vitest/consistent-test-filename":"off"},oxlint:{"class-methods-use-this":"off","func-style":["off"],"no-useless-constructor":"off","oxc/no-const-enum":"off","typescript/consistent-type-imports":"off","typescript/no-extraneous-class":"off","typescript/parameter-properties":"off","unicorn/no-static-only-class":"off","vitest/consistent-test-filename":"off"}};async function pr(t){const e=q(t,"oxlint.config.ts");let r;try{r=await _e(e,"utf-8"),x("read",`Read ${e}`)}catch(n){x("error",`Cannot read ${e}`,n);return}let s=r;/import vitest from "ultracite\/oxlint\/vitest"/u.test(r)||(s=s.replace(/(import nestjs from "ultracite\/oxlint\/nestjs";)/u,`$1
18
- import vitest from "ultracite/oxlint/vitest";`),x("add-import","Added vitest import"));const o=Object.entries(Ue.oxlint).map(([n,a])=>{const l=Array.isArray(a)?JSON.stringify(a):`"${a}"`;return` "${n}": ${l}`}).join(`,
19
- `);s=s.replace(/export default defineConfig\(\{([\s\S]*?)\}\);/u,(n,a)=>{const l=a.includes("vitest"),u=a.includes("ignorePatterns"),h=a.includes("rules:");let y=a;return l||(y=y.replace(/(extends:\s*\[[\s\S]*?)(\],)/u,`$1 vitest,
20
- $2`),x("add-extends","Added vitest to extends array")),u||(y=y.replace(/(extends:\s*\[[\s\S]*?\],?)/u,`$1
21
- ignorePatterns: core.ignorePatterns,`),x("add-ignorePatterns","Added ignorePatterns")),h||(y=`${y} rules: {
22
- ${o},
23
- },
24
- `,x("add-rules","Added custom NestJS rules")),`export default defineConfig({${y}});`});try{await ge(e,s,"utf-8"),x("write",`Written ${e}`)}catch(n){x("error",`Cannot write ${e}`,n)}}p(pr,"injectOxlintRules");async function ur(t){const e=q(t,"biome.jsonc");let r;try{r=await _e(e,"utf-8"),x("read",`Read ${e}`)}catch(a){x("error",`Cannot read ${e}`,a);return}const s=Ue.biome,o=r.includes('"linter"'),n=r.includes('"rules"');if(o&&n){const a=Object.entries(s).flatMap(([u,h])=>Object.entries(h).map(([y,k])=>` "${u}": {
25
- "${y}": "${k}"
26
- }`)).join(`,
27
- `),l=r.replace(/("linter"\s*:\s*\{[\s\S]*?"rules"\s*:\s*\{)([\s\S]*?)(\})/u,(u,h,y,k)=>{const w=y.trim().endsWith(",")?"":",";return`${h}${y}${w}
28
- ${a}
29
- ${k}`});try{await ge(e,l,"utf-8"),x("write",`Written ${e} (existing linter block)`)}catch(u){x("error",`Cannot write ${e}`,u)}}else{const l=` "linter": {
30
- "rules": {
31
- ${Object.entries(s).map(([h,y])=>{const k=Object.entries(y).map(([w,M])=>` "${w}": "${M}"`).join(`,
32
- `);return` "${h}": {
33
- ${k}
34
- }`}).join(`,
35
- `)}
36
- }
37
- }`,u=r.replace(/(\}\s*)$/u,h=>`,
38
- ${l}
39
- ${h}`);try{await ge(e,u,"utf-8"),x("write",`Written ${e} (new linter block)`)}catch(h){x("error",`Cannot write ${e}`,h)}}}p(ur,"injectBiomeRules");async function dr(t){const e=q(t,"eslint.config.mjs");let r;try{r=await _e(e,"utf-8"),x("read",`Read ${e}`)}catch(n){x("error",`Cannot read ${e}`,n);return}if(r.includes("rules:")){x("skip","Rules already present in eslint.config.mjs");return}const s=Object.entries(Ue.eslint).map(([n,a])=>{const l=Array.isArray(a)?JSON.stringify(a):`"${a}"`;return` "${n}": ${l}`}).join(`,
40
- `),o=r.replace(/\];?$/u,` {
41
- rules: {
42
- ${s},
43
- },
44
- },
45
- ];`);try{await ge(e,o,"utf-8"),x("write",`Written ${e}`)}catch(n){x("error",`Cannot write ${e}`,n)}}p(dr,"injectEslintRules");async function mr(t,e){switch(x("start",`Injecting rules for formatter: ${e}`),e){case"oxlint-oxfmt":return await pr(t),x("done","Oxlint configuration updated"),{success:!0};case"biome":return await ur(t),x("done","Biome configuration updated"),{success:!0};case"eslint-prettier":return await dr(t),x("done","ESLint configuration updated"),{success:!0};default:return x("skip",`No injection for formatter: ${e}`),{message:"No injection needed",success:!0}}}p(mr,"injectUltraciteRules");const hr="single-project/architecture/nest-api",gr="single-project/architecture/nest-gateway",fr="single-project/architecture/nest-microservice",br="monorepo/root",yr="monorepo/apps/api-gateway",vr="monorepo/packages",jr="addons/husky",wr="extras/docker",kr="extras/swagger",Sr=[{conditions:{architecture:"nest-api",projectType:"single"},id:"single-nest-api",name:"Single NestJS API",priority:10,templateGroups:[hr]},{conditions:{architecture:"nest-gateway",projectType:"single"},id:"single-nest-gateway",name:"Single NestJS Gateway",priority:10,templateGroups:[gr]},{conditions:{architecture:"nest-microservice",projectType:"single"},id:"single-nest-microservice",name:"Single NestJS Microservice",priority:10,templateGroups:[fr]},{conditions:{projectType:"monorepo"},id:"monorepo-root",name:"Monorepo Root",priority:10,templateGroups:[br,yr,vr]},{conditions:{addons:["husky"]},id:"addon-husky",name:"Husky Git Hooks",priority:5,templateGroups:[jr]},{conditions:{extras:["docker"]},id:"extra-docker",name:"Docker Support",priority:5,templateGroups:[wr]},{conditions:{extras:["swagger"]},id:"extra-swagger",name:"Swagger Documentation",priority:5,templateGroups:[kr]}];function Ar(t){t.registerAll(Sr)}p(Ar,"initializeTemplateMappings");class Se{static{p(this,"TemplateMapper")}mappings=[];register(e){this.mappings.push(e),this.mappings.sort((r,s)=>(s.priority??0)-(r.priority??0))}registerAll(e){for(const r of e)this.register(r)}resolve(e){const r=[];for(const a of this.mappings)Se.matches(a.conditions,e)&&r.push(a);const s=[],o={},n=[];for(const a of r){for(const l of a.templateGroups)s.includes(l)||s.push(l);Object.assign(o,a.extraVariables),n.push(a.id)}return{extraVariables:o,matchedMappings:n,templateGroups:s}}findFirst(e){return this.mappings.find(r=>Se.matches(r.conditions,e))}getAll(){return[...this.mappings]}getById(e){return this.mappings.find(r=>r.id===e)}clear(){this.mappings=[]}static matches(e,r){return!(e.architecture!==void 0&&e.architecture!==r.architecture||e.projectType!==void 0&&e.projectType!==r.projectType||e.database!==void 0&&!e.database.some(s=>r.database.includes(s))||e.orm!==void 0&&!e.orm.some(s=>r.orm.includes(s))||e.api!==void 0&&!e.api.some(s=>r.api.includes(s))||e.extras!==void 0&&!e.extras.some(s=>r.extras.includes(s))||e.addons!==void 0&&!e.addons.some(s=>r.addons.includes(s))||e.microservices!==void 0&&!e.microservices.some(s=>r.microservices.includes(s)))}}function Er(t){return t.replaceAll(/([a-z])([A-Z])/gu,"$1-$2").replaceAll(/\s+/gu,"-").toLowerCase()}p(Er,"toKebabCase");function Pr(t){return t.replaceAll(/[-_\s](.)/gu,(e,r)=>r.toUpperCase()).replace(/^(.)/u,e=>e.toLowerCase())}p(Pr,"toCamelCase");function Cr(t){return t.replaceAll(/[-_\s](.)/gu,(e,r)=>r.toUpperCase()).replace(/^(.)/u,e=>e.toUpperCase())}p(Cr,"toPascalCase");function Tr(t){return{addons:[...t.addons],apiType:t.api[0]??null,apis:[...t.api],architecture:t.architecture,auth:t.auth,databaseType:t.database[0]??null,databases:[...t.database],description:t.description||"A NestJS application",docker:t.extras.includes("docker"),extras:[...t.extras],hasAuth:t.auth!=="none",hasDatabase:t.database.length>0,hasOrm:t.orm.length>0,httpProvider:t.httpProvider,initGit:t.initGit,isBun:t.packageManager==="bun",isMonorepo:t.projectType==="monorepo",isNpm:t.packageManager==="npm",isPnpm:t.packageManager==="pnpm",isSingle:t.projectType==="single",isYarn:t.packageManager==="yarn",microservices:[...t.microservices],ormType:t.orm[0]??null,orms:[...t.orm],packageManager:t.packageManager,projectName:t.projectName,projectNameCamelCase:Pr(t.projectName),projectNameKebab:Er(t.projectName),projectNamePascalCase:Cr(t.projectName),projectType:t.projectType,supportsCatalog:["pnpm","yarn","bun"].includes(t.packageManager),swagger:t.extras.includes("swagger"),year:new Date().getFullYear()}}p(Tr,"buildTemplateVariables");function xr(t,e){return{...t,...e}}p(xr,"mergeTemplateExtras");const _r={name:"@nest-arch/dependencies-reference",version:"0.0.0",private:!0,description:"Single source of truth for dependency versions used across all generated templates. Do not install this package.",dependencies:{"@grpc/grpc-js":"^1.12.0","@grpc/proto-loader":"^0.7.13","@nestjs/apollo":"^13.0.0","@nestjs/common":"next","@nestjs/core":"next","@nestjs/graphql":"^13.0.0","@nestjs/jwt":"next","@nestjs/microservices":"next","@nestjs/passport":"next","@nestjs/platform-express":"next","@nestjs/platform-fastify":"next","@nestjs/swagger":"next","@nestjs/terminus":"next","@nestjs/throttler":"next","@nestjs/typeorm":"next","@prisma/client":"^6.5.0","@scalar/nestjs":"^0.3.0","@t3-oss/env-core":"^0.13.11","@trpc/client":"^11.0.0","@trpc/server":"^11.0.0",amqplib:"^0.10.5","apollo-server-express":"^3.13.0","better-auth":"^1.2.0",dotenv:"^17.2.2","drizzle-orm":"^0.41.0",graphql:"^16.10.0",ioredis:"^5.6.0",kafkajs:"^2.2.4",mqtt:"^5.10.0",nats:"^2.28.0","nestjs-zod":"^3.1.0",passport:"^0.7.0","passport-jwt":"^5.0.0","passport-local":"^1.0.0",pg:"^8.13.0","reflect-metadata":"^0.2.2",rxjs:"^7.8.1",typeorm:"^0.3.20",zod:"^4.4.3"},devDependencies:{"@nestjs/cli":"next","@nestjs/schematics":"next","@nestjs/testing":"next","@types/amqplib":"^0.10.6","@types/express":"^5.0.0","@types/node":"^22.13.14","@types/passport-jwt":"^4.0.1","@types/passport-local":"^1.0.38","@types/pg":"^8.11.11","@types/supertest":"^7.0.0","@vitest/coverage-v8":"4.1.6","drizzle-kit":"^0.30.0",husky:"^9.1.7",oxfmt:"^0.52.0",oxlint:"^1.67.0",prisma:"^6.5.0","source-map-support":"^0.5.21",supertest:"^7.0.0",turbo:"^2.8.12",typescript:"^6.0.2",ultracite:"7.8.0",vitest:"^4.1.2"},catalog:{"@types/node":"^22.13.14",dotenv:"^17.2.2",typescript:"^6.0.2",zod:"^4.4.3"}};function jt(){return _r}p(jt,"loadReference");function d(t){const e=jt(),r=e.dependencies[t]??e.devDependencies[t];if(!r)throw new Error(`Dependency "${t}" not found in reference package.json`);return r}p(d,"getDependencyVersion");function Ir(){return{...jt().catalog}}p(Ir,"getCatalogDependencies");const Or=[{dest:"tsconfig.json",src:"base/tsconfig.json.hbs"},{dest:"tsconfig.build.json",src:"base/tsconfig.build.json.hbs"},{dest:"nest-cli.json",src:"base/nest-cli.json.hbs"},{dest:".gitignore",src:"base/.gitignore.hbs"},{dest:".env",src:"base/.env.hbs"},{dest:"README.md",src:"base/README.md.hbs"},{dest:"vitest.config.ts",src:"base/vitest.config.ts.hbs"},{dest:"vitest.config.e2e.ts",src:"base/vitest.config.e2e.ts.hbs"},{dest:"src/main.ts",src:"base/src/main.ts.hbs"},{dest:"src/app.module.ts",src:"base/src/app.module.ts.hbs"},{dest:"src/app.service.ts",src:"base/src/app.service.ts.hbs"},{dest:"src/app.controller.ts",src:"base/src/app.controller.ts.hbs"},{dest:"src/app.controller.spec.ts",src:"base/src/app.controller.spec.ts.hbs"},{dest:"src/config/env.ts",src:"single-project/shared/config/env.ts.hbs"},{dest:"test/app.e2e-spec.ts",src:"base/test/app.e2e-spec.ts.hbs"}],Nr={dest:"pnpm-workspace.yaml",src:"base/pnpm-workspace.yaml.hbs"},Mr={dest:".yarnrc.yml",src:"base/.yarnrc.yml.hbs"},Rr=[{dest:".husky/pre-commit",src:"addons/husky/pre-commit.hbs"}],Dr=[{dest:"Dockerfile",src:"extras/docker/Dockerfile.hbs"},{dest:"docker-compose.yml",src:"extras/docker/docker-compose.yml.hbs"},{dest:".dockerignore",src:"extras/docker/.dockerignore.hbs"}],Gr={"single-project/architecture/nest-api":[{dest:"src/main.ts",src:"single-project/architecture/nest-api/src/main.ts.hbs"},{dest:".env",src:"single-project/architecture/nest-api/.env.hbs"},{dest:"package.json",src:"single-project/architecture/nest-api/package.json.hbs"},{dest:"pnpm-workspace.yaml",src:"single-project/architecture/nest-api/pnpm-workspace.yaml.hbs"}],"single-project/architecture/nest-gateway":[{dest:"src/main.ts",src:"single-project/architecture/nest-gateway/src/main.ts.hbs"},{dest:"src/app.module.ts",src:"single-project/architecture/nest-gateway/src/app.module.ts.hbs"},{dest:"src/app.controller.ts",src:"single-project/architecture/nest-gateway/src/app.controller.ts.hbs"},{dest:"src/app.service.ts",src:"single-project/architecture/nest-gateway/src/app.service.ts.hbs"},{dest:"package.json",src:"single-project/architecture/nest-api/package.json.hbs"},{dest:"pnpm-workspace.yaml",src:"single-project/architecture/nest-api/pnpm-workspace.yaml.hbs"}],"single-project/architecture/nest-microservice":[{dest:"src/main.ts",src:"single-project/architecture/nest-microservice/src/main.ts.hbs"},{dest:"src/app.module.ts",src:"single-project/architecture/nest-microservice/src/app.module.ts.hbs"},{dest:"src/app.controller.ts",src:"single-project/architecture/nest-microservice/src/app.controller.ts.hbs"},{dest:"src/app.service.ts",src:"single-project/architecture/nest-microservice/src/app.service.ts.hbs"},{dest:".env",src:"single-project/architecture/nest-microservice/.env.hbs"},{dest:"package.json",src:"single-project/architecture/nest-api/package.json.hbs"},{dest:"pnpm-workspace.yaml",src:"single-project/architecture/nest-api/pnpm-workspace.yaml.hbs"}]},wt=[{dest:"turbo.json",src:"monorepo/root/turbo.json.hbs"},{dest:"tsconfig.json",src:"monorepo/root/tsconfig.json.hbs"},{dest:".gitignore",src:"monorepo/root/.gitignore.hbs"},{dest:"README.md",src:"monorepo/root/README.md.hbs"}],$r="package.json",Fr=[{dest:"apps/api-gateway/src/main.ts",src:"monorepo/apps/api-gateway/src/main.ts.hbs"},{dest:"apps/api-gateway/src/app.module.ts",src:"monorepo/apps/api-gateway/src/app.module.ts.hbs"},{dest:"apps/api-gateway/src/app.controller.ts",src:"monorepo/apps/api-gateway/src/app.controller.ts.hbs"},{dest:"apps/api-gateway/src/app.service.ts",src:"monorepo/apps/api-gateway/src/app.service.ts.hbs"},{dest:"apps/api-gateway/src/app.controller.spec.ts",src:"monorepo/apps/api-gateway/src/app.controller.spec.ts.hbs"},{dest:"apps/api-gateway/test/app.e2e-spec.ts",src:"monorepo/apps/api-gateway/test/app.e2e-spec.ts.hbs"},{dest:"apps/api-gateway/tsconfig.json",src:"monorepo/apps/api-gateway/tsconfig.json.hbs"},{dest:"apps/api-gateway/tsconfig.build.json",src:"monorepo/apps/api-gateway/tsconfig.build.json.hbs"},{dest:"apps/api-gateway/nest-cli.json",src:"monorepo/apps/api-gateway/nest-cli.json.hbs"},{dest:"apps/api-gateway/vitest.config.ts",src:"monorepo/apps/api-gateway/vitest.config.ts.hbs"},{dest:"apps/api-gateway/vitest.config.e2e.ts",src:"monorepo/apps/api-gateway/vitest.config.e2e.ts.hbs"}],Lr=[{dest:"packages/config/package.json",src:"monorepo/packages/config/package.json.hbs"},{dest:"packages/config/tsconfig.base.json",src:"monorepo/packages/config/tsconfig.base.json.hbs"},{dest:"packages/config/tsconfig.nestjs.json",src:"monorepo/packages/config/tsconfig.nestjs.json.hbs"},{dest:"packages/env/package.json",src:"monorepo/packages/env/package.json.hbs"},{dest:"packages/env/src/api-gateway.ts",src:"monorepo/packages/env/src/api-gateway.ts.hbs"},{dest:"packages/env/tsconfig.json",src:"monorepo/packages/env/tsconfig.json.hbs"},{dest:"packages/shared/package.json",src:"monorepo/packages/shared/package.json.hbs"},{dest:"packages/shared/tsconfig.json",src:"monorepo/packages/shared/tsconfig.json.hbs"}],ze={"addons/husky":Rr,"extras/docker":Dr,"extras/swagger":[],"monorepo/apps/api-gateway":Fr,"monorepo/packages":Lr,"monorepo/root":wt};function kt(t,e,r){t.auth==="jwt"||t.auth==="passport"?(e["@nestjs/jwt"]=d("@nestjs/jwt"),e["@nestjs/passport"]=d("@nestjs/passport"),e.passport=d("passport"),e["passport-jwt"]=d("passport-jwt"),r["@types/passport-jwt"]=d("@types/passport-jwt"),t.auth==="passport"&&(e["passport-local"]=d("passport-local"),r["@types/passport-local"]=d("@types/passport-local"))):t.auth==="better-auth"&&(e["better-auth"]=d("better-auth"));for(const s of t.orm)s==="prisma"?(e["@prisma/client"]=d("@prisma/client"),r.prisma=d("prisma")):s==="typeorm"?(e.typeorm=d("typeorm"),e["@nestjs/typeorm"]=d("@nestjs/typeorm"),e.pg=d("pg")):s==="drizzle"&&(e["drizzle-orm"]=d("drizzle-orm"),r["drizzle-kit"]=d("drizzle-kit"),e.pg=d("pg"));for(const s of t.api)s==="graphql"?(e["@nestjs/graphql"]=d("@nestjs/graphql"),e["@nestjs/apollo"]=d("@nestjs/apollo"),e.graphql=d("graphql"),e["apollo-server-express"]=d("apollo-server-express")):s==="trpc"&&(e["@trpc/server"]=d("@trpc/server"),e["@trpc/client"]=d("@trpc/client"));t.extras.includes("swagger")&&(e["@nestjs/swagger"]=d("@nestjs/swagger")),t.extras.includes("health-check")&&(e["@nestjs/terminus"]=d("@nestjs/terminus")),t.extras.includes("rate-limiting")&&(e["@nestjs/throttler"]=d("@nestjs/throttler"));for(const s of t.microservices)s==="redis"?e.ioredis=d("ioredis"):s==="mqtt"?e.mqtt=d("mqtt"):s==="nats"?e.nats=d("nats"):s==="rabbitmq"?(e.amqplib=d("amqplib"),r["@types/amqplib"]=d("@types/amqplib")):s==="kafka"?e.kafkajs=d("kafkajs"):s==="grpc"&&(e["@grpc/grpc-js"]=d("@grpc/grpc-js"),e["@grpc/proto-loader"]=d("@grpc/proto-loader"));t.addons.includes("nestjs-zod")&&(e["nestjs-zod"]=d("nestjs-zod")),t.addons.includes("scalar-ui")&&(e["@scalar/nestjs"]=d("@scalar/nestjs"))}p(kt,"addConditionalDependencies");async function Ur(t,e,r,s,o,n){try{const a=t.httpProvider==="fastify"?"@nestjs/platform-fastify":"@nestjs/platform-express",l={"@nestjs/common":d("@nestjs/common"),"@nestjs/core":d("@nestjs/core"),[a]:d(a),"@t3-oss/env-core":d("@t3-oss/env-core"),dotenv:d("dotenv"),"reflect-metadata":d("reflect-metadata"),rxjs:d("rxjs"),zod:d("zod")},u={"@nestjs/cli":d("@nestjs/cli"),"@nestjs/schematics":d("@nestjs/schematics"),"@nestjs/testing":d("@nestjs/testing"),"@types/express":d("@types/express"),"@types/node":d("@types/node"),"@types/supertest":d("@types/supertest"),"@vitest/coverage-v8":d("@vitest/coverage-v8"),"source-map-support":d("source-map-support"),supertest:d("supertest"),typescript:d("typescript"),vitest:d("vitest")},h={build:"nest build",dev:"nest start --watch",start:"nest start","start:debug":"nest start --debug --watch","start:dev":"nest start --watch","start:prod":"node dist/main",test:"vitest run","test:cov":"vitest run --coverage","test:debug":"vitest --inspect-brk --no-file-parallelism","test:e2e":"vitest run --config ./vitest.config.e2e.ts","test:watch":"vitest"};kt(t,l,u),t.addons.includes("ultracite")&&(u.ultracite=d("ultracite"),h.check="ultracite check",h.fix="ultracite fix"),t.addons.includes("husky")&&(u.husky=d("husky"),h.prepare="husky");const y={name:e.projectName,version:"0.0.1",description:e.description,author:"",license:"UNLICENSED",private:!0,type:"module",scripts:h,dependencies:l,devDependencies:u},k=JSON.stringify(y,null,2),w=await r.writeFile({content:k,filePath:"package.json",isBinary:!1},{dryRun:s.dryRun,overwrite:s.overwrite});w.written&&o.push(w.filePath)}catch(a){const l=a instanceof Error?a.message:String(a);n.push(`Failed to generate package.json: ${l}`),console.error("Failed to generate package.json:",a)}}p(Ur,"generateSingleProjectPackageJson");async function zr(t,e,r,s,o,n){try{const a={build:"turbo build","check-types":"turbo check-types",dev:"turbo dev"},l={"@repo/env":"workspace:*",dotenv:"catalog:",zod:"catalog:"},u={"@repo/config":"workspace:*","@types/node":"catalog:",turbo:d("turbo"),typescript:"catalog:"};t.addons.includes("ultracite")&&(a.check="ultracite check"),t.addons.includes("husky")&&(u.husky=d("husky"),a.prepare="husky");const y={bun:"bun@1.3.14",npm:void 0,pnpm:"pnpm@11.5.0",yarn:"yarn@4.6.0"}[t.packageManager],k={name:e.projectName,version:"0.0.1",description:e.description,author:"",license:"UNLICENSED",private:!0,workspaces:["apps/*","packages/*"],type:"module",...y?{packageManager:y}:{},...t.packageManager==="bun"?{catalog:Ir()}:{},scripts:a,dependencies:l,devDependencies:u},w=JSON.stringify(k,null,2),M=await r.writeFile({content:w,filePath:$r,isBinary:!1},{dryRun:s.dryRun,overwrite:s.overwrite});M.written&&o.push(M.filePath)}catch(a){const l=a instanceof Error?a.message:String(a);n.push(`Failed to generate monorepo root package.json: ${l}`),console.error("Failed to generate monorepo root package.json:",a)}}p(zr,"generateMonorepoRootPackageJson");async function Hr(t,e,r,s,o,n){try{const a=t.httpProvider==="fastify"?"@nestjs/platform-fastify":"@nestjs/platform-express",l={"@nestjs/common":d("@nestjs/common"),"@nestjs/core":d("@nestjs/core"),[a]:d(a),"@repo/env":"workspace:*","reflect-metadata":d("reflect-metadata"),rxjs:d("rxjs"),zod:"catalog:"},u={"@nestjs/cli":d("@nestjs/cli"),"@nestjs/schematics":d("@nestjs/schematics"),"@nestjs/testing":d("@nestjs/testing"),"@repo/config":"workspace:*","@types/express":d("@types/express"),"@types/node":"catalog:","@types/supertest":d("@types/supertest"),"@vitest/coverage-v8":d("@vitest/coverage-v8"),"source-map-support":d("source-map-support"),supertest:d("supertest"),typescript:"catalog:",vitest:d("vitest")},h={build:"nest build",dev:"nest start --watch",start:"nest start","start:debug":"nest start --debug --watch","start:dev":"nest start --watch","start:prod":"node dist/main",test:"vitest run","test:cov":"vitest run --coverage","test:debug":"vitest --inspect-brk --no-file-parallelism","test:e2e":"vitest run --config ./vitest.config.e2e.ts","test:watch":"vitest"};kt(t,l,u),t.addons.includes("ultracite")&&(u.ultracite=d("ultracite"),h.check="ultracite check",h.fix="ultracite fix"),t.addons.includes("husky")&&(u.husky=d("husky"),h.prepare="husky");const y={name:e.projectName,version:"0.0.1",description:e.description,author:"",license:"UNLICENSED",private:!0,type:"module",scripts:h,dependencies:l,devDependencies:u},k=JSON.stringify(y,null,2),w=await r.writeFile({content:k,filePath:"apps/api-gateway/package.json",isBinary:!1},{dryRun:s.dryRun,overwrite:s.overwrite});w.written&&o.push(w.filePath)}catch(a){const l=a instanceof Error?a.message:String(a);n.push(`Failed to generate monorepo app package.json: ${l}`),console.error("Failed to generate monorepo app package.json:",a)}}p(Hr,"generateMonorepoAppPackageJson");class Br{static{p(this,"ProjectGenerator")}templateEngine;fileWriter;registry;options;mapper;constructor(e,r){this.options=r,this.fileWriter=new or(e),this.templateEngine=new qe(r.templatesDir,{cache:r.cacheTemplates??!0}),this.registry=new lr,this.mapper=new Se,Ar(this.mapper)}getMapper(){return this.mapper}async generate(e){const r=Date.now(),s=[],o=[];try{const n=this.mapper.resolve(e);let a=Tr(e);a=xr(a,n.extraVariables),a.hasUltracite=e.addons.includes("ultracite"),a.hasHusky=e.addons.includes("husky"),await(e.projectType==="monorepo"?this.generateMonorepo(e,a,n.templateGroups,s,o):this.generateSingleProject(e,a,n.templateGroups,s,o));const l=Date.now()-r,u=o.length===0;if(u&&await this.generateMetadata(e,a,s,o),e.initGit){const y=await new cr(this.fileWriter.getBaseDir()).initGit();y.success||o.push(`Failed to initialize git: ${y.error}`)}return console.log(`\u2705 Project generated in ${l}ms`),{error:u&&o.length===0?void 0:o.join(`
46
- `),filesCount:s.length,generatedFiles:s,success:u&&o.length===0}}catch(n){return{error:n instanceof Error?n.message:"Unknown error",filesCount:0,generatedFiles:s,success:!1}}}async generateSingleProject(e,r,s,o,n){const a={dryRun:this.options.dryRun,overwrite:this.options.overwrite},l=[...Or];r.packageManager==="pnpm"?l.push(Nr):r.packageManager==="yarn"&&l.push(Mr),await Ur(e,r,this.fileWriter,a,o,n);for(const u of l)await this.renderAndWrite(u.src,u.dest,r,o,n);for(const u of s){const h=Gr[u];if(h){for(const k of h)k.dest==="package.json"||k.dest==="pnpm-workspace.yaml"||k.dest===".yarnrc.yml"||await this.renderAndWrite(k.src,k.dest,r,o,n);continue}const y=ze[u];if(y)for(const k of y)await this.renderAndWrite(k.src,k.dest,r,o,n)}e.extras.includes("swagger")&&console.log("Swagger support added to project")}async generateMonorepo(e,r,s,o,n){const a={dryRun:this.options.dryRun,overwrite:this.options.overwrite};await zr(e,r,this.fileWriter,a,o,n),await Hr(e,r,this.fileWriter,a,o,n);for(const l of s){if(l==="monorepo/root"){for(const h of wt)await this.renderAndWrite(h.src,h.dest,r,o,n);r.packageManager==="pnpm"?await this.renderAndWrite("monorepo/root/pnpm-workspace.yaml.hbs","pnpm-workspace.yaml",r,o,n):r.packageManager==="yarn"&&await this.renderAndWrite("monorepo/root/.yarnrc.yml.hbs",".yarnrc.yml",r,o,n);continue}const u=ze[l];if(u)for(const h of u)await this.renderAndWrite(h.src,h.dest,r,o,n)}for(const l of s){const u=ze[l];if(u)for(const h of u)await this.renderAndWrite(h.src,h.dest,r,o,n)}}async generateMetadata(e,r,s,o){try{const{buildMetadata:n,serializeMetadata:a,buildSchemaContent:l}=await import("./index-BTR_l9Vl.js"),u=n(e),h=a(u),y=await this.fileWriter.writeFile({content:h,filePath:"nest-arch.jsonc",isBinary:!1},{dryRun:this.options.dryRun,overwrite:this.options.overwrite});y.written&&s.push(y.filePath);const k=l(),w=await this.fileWriter.writeFile({content:k,filePath:"schema.json",isBinary:!1},{dryRun:this.options.dryRun,overwrite:this.options.overwrite});w.written&&s.push(w.filePath)}catch(n){const a=n instanceof Error?n.message:String(n);o.push(`Failed to generate nest-arch.jsonc/schema.json: ${a}`)}}async renderAndWrite(e,r,s,o,n){try{const a=await this.templateEngine.renderToFile(e,r,{context:s}),l=await this.fileWriter.writeFile(a,{dryRun:this.options.dryRun,overwrite:this.options.overwrite});l.written&&o.push(l.filePath)}catch(a){const l=a instanceof Error?a.message:String(a);n.push(`Failed to generate ${r}: ${l}`),console.error(`Failed to generate ${r}:`,a)}}clearCaches(){this.templateEngine.clearCache(),this.registry.clear()}}function Wr(t){return{addons:t.addons,api:t.api,architecture:t.architecture,auth:t.auth,database:t.database,description:`${t.projectName} NestJS application`,extras:t.extras,formatter:t.formatter,httpProvider:t.httpProvider,initGit:t.initGit==="yes",microservices:t.microservices,orm:t.orm,packageManager:t.packageManager,projectName:t.projectName,projectType:t.projectType,ultraciteAgents:t.ultraciteAgents,ultraciteEditors:t.ultraciteEditors,ultraciteHooks:t.ultraciteHooks,ultraciteInstallSkill:t.ultraciteInstallSkill}}p(Wr,"buildGeneratorContext");function He(t){return De.NEST_ARCH_BETA_MODE?q(Ke(),"test-projects",t):q(process.cwd(),t)}p(He,"getOutputDir");function Jr(t){switch(t){case"biome":return"biome";case"eslint-prettier":return"eslint";case"oxlint-oxfmt":return"oxlint";case"none":return"none";default:return"oxlint"}}p(Jr,"mapFormatterToLinter");async function qr(t,e){const r=Jr(e.formatter);if(r==="none")return{message:"Skipping ultracite init (no formatter selected)",success:!0};const s=[];e.addons.includes("husky")&&s.push("husky");const o=["ultracite","init","--quiet","--skip-install","--pm",e.packageManager,"--linter",r,"--frameworks","nestjs"];s.length>0&&o.push("--integrations",...s),e.addons.includes("ultracite")&&(e.ultraciteEditors.length>0&&o.push("--editors",...e.ultraciteEditors),e.ultraciteAgents.length>0&&o.push("--agents",...e.ultraciteAgents),e.ultraciteHooks.length>0&&o.push("--hooks",...e.ultraciteHooks),e.ultraciteInstallSkill==="yes"&&o.push("--install-skill"));const n=`npx ${o.join(" ")}`,a=Qe(Rt);try{const{stderr:l}=await a(n,{cwd:t,timeout:12e4});return l?.trim()&&console.error(`[ultracite-init] stderr: ${l.trim()}`),{message:"Ultracite setup completed",success:!0}}catch(l){let u=l instanceof Error?l.message:String(l);if(l&&typeof l=="object"&&"stderr"in l){const h=l.stderr?.trim();h&&(u=`${u}
47
- ${h}`)}return console.error(`[ultracite-init] Failed: ${u}`),{message:`Ultracite setup failed: ${u}`,success:!1}}}p(qr,"runUltraciteSetup");function Vr(){const t=import.meta.dirname;if(t){const r=q(t,"templates");if(xe(r))return r}return q(t??process.cwd(),"..","..","..","..","packages","core","templates")}p(Vr,"getTemplatesDir");async function St(t){const e=He(t.projectName),r=Wr(t),s=Vr(),o=new Br(e,{cacheTemplates:!0,templatesDir:s});try{const n=await o.generate(r);if(!n.success)return{message:n.error||"Unknown error",outputDir:e,success:!1};if(t.formatter!=="none"){const a=await qr(e,t);if(!a.success)return{message:a.message,outputDir:e,success:!1};const l=await mr(e,t.formatter);if(!l.success)return{message:l.message??"Rule injection failed",outputDir:e,success:!1}}return{message:`Project created with ${n.generatedFiles.length} files`,outputDir:e,success:!0}}catch(n){return{message:`Failed to generate project: ${n instanceof Error?n.message:String(n)}`,outputDir:e,success:!1}}}p(St,"generateProject");const Kr=p(()=>({addons:[],api:[],architecture:null,auth:null,database:[],extras:[],formatter:null,httpProvider:null,initGit:null,microservices:[],orm:[],packageManager:null,projectName:"",projectType:null,ultraciteAgents:[],ultraciteEditors:[],ultraciteHooks:[],ultraciteInstallSkill:null}),"initialState");function Qr(t){return!t.packageManager||!t.formatter||!t.httpProvider||!t.projectType||!t.architecture||!t.auth||!t.initGit?null:{addons:t.addons,api:t.api,architecture:t.architecture,auth:t.auth,database:t.database,extras:t.extras,formatter:t.formatter,httpProvider:t.httpProvider,initGit:t.initGit,microservices:t.architecture==="nest-gateway"?t.microservices:[],orm:ke(t.database)?[]:t.orm,packageManager:t.packageManager,projectName:Z(t.projectName),projectType:t.projectType,ultraciteAgents:t.ultraciteAgents,ultraciteEditors:t.ultraciteEditors,ultraciteHooks:t.ultraciteHooks,ultraciteInstallSkill:t.ultraciteInstallSkill??"no"}}p(Qr,"buildResult");const Yr=p(({onBack:t,onExit:e,onStepChange:r})=>{const[s,o]=I("projectName"),[n,a]=I(Kr),[l,u]=I(null),[h,y]=I(null),k=J(()=>gt(n),[n]),w=J(()=>Qt(s,n),[s,n]),M=J(()=>Kt(s,n),[s,n]),v=j(b=>{const m=Yt(s,b);m&&(o(m),r?.(m))},[s,r]),W=j(()=>{const b=Xt(s,n);if(b){o(b),r?.(b);return}t()},[t,n,s,r]),$=j(()=>{const b=we(n.projectName);if(b){u(b);return}const m={...n,projectName:Z(n.projectName)};a(m),v(m)},[v,n]),A=j(b=>{const m={...n,packageManager:b};a(m),v(m)},[v,n]),E=j(b=>{const m={...n,formatter:b};a(m),v(m)},[v,n]),C=j(b=>{const m={...n,httpProvider:b};a(m),v(m)},[v,n]),H=j(b=>{const m=b==="single"&&n.architecture==="nest-gateway"?bt():n.architecture??bt(),X={...n,architecture:m,extras:b==="single"?n.extras.filter(Et=>Et!=="packages/shared"):n.extras,microservices:m==="nest-gateway"?n.microservices:[],projectType:b};a(X),v(X)},[v,n]),Q=j(b=>{const m={...n,architecture:b,microservices:b==="nest-gateway"?n.microservices:[]};a(m),v(m)},[v,n]),ie=j(b=>{const m=yt(n.orm,b),X={...n,database:b,orm:m};a(X),v(X)},[v,n]),ae=j(b=>{const m={...n,orm:yt(b,n.database)};a(m),v(m)},[v,n]),oe=j(b=>{const m={...n,api:b};a(m),v(m)},[v,n]),ce=j(b=>{const m={...n,auth:b};a(m),v(m)},[v,n]),ee=j(b=>{const m={...n,extras:b};a(m),v(m)},[v,n]),he=J(()=>n.projectType==="monorepo"?Re:Re.filter(b=>b.value!=="packages/shared"),[n.projectType]),T=j(b=>{const m={...n,microservices:b};a(m),v(m)},[v,n]),L=j(b=>{const m={...n,addons:b};a(m),v(m)},[v,n]),te=j(b=>{const m={...n,ultraciteEditors:b};a(m),v(m)},[v,n]),Y=j(b=>{const m={...n,ultraciteAgents:b};a(m),v(m)},[v,n]),U=j(b=>{const m={...n,ultraciteHooks:b};a(m),v(m)},[v,n]),Ae=j(b=>{const m={...n,ultraciteInstallSkill:b};a(m),v(m)},[v,n]),z=j(b=>{const m={...n,initGit:b};a(m),v(m)},[v,n]),Ee=j(()=>{v(n)},[v,n]),Pe=j(async()=>{const b=Qr(n);if(b){o("installing"),r?.("installing"),y({isError:!1,message:"Scaffolding your project\u2026"});try{const m=await St(b);y({isError:!m.success,message:m.message}),m.success&&(vt(b),setTimeout(()=>{o("done"),r?.("done")},1e3))}catch(m){y({isError:!0,message:`Error: ${m instanceof Error?m.message:String(m)}`})}}},[n,r]),_=j(()=>{o("summary"),r?.("summary"),y(null)},[r]),Ce=J(()=>s==="projectName"||s==="summary"||s==="ultraciteSetup"?"confirm":s==="database"||s==="orm"||s==="apiLayer"||s==="extras"||s==="microservices"||s==="addons"||s==="ultraciteEditors"||s==="ultraciteAgents"||s==="ultraciteHooks"?"multi-select":s==="installing"&&h?.isError?"confirm":"select",[s,h?.isError]);return{architectureOpts:J(()=>Zt(n.projectType),[n.projectType]),displayStep:w,extrasStepOptions:he,generationStatus:h,goBack:W,handleAddons:L,handleApi:oe,handleArchitecture:Q,handleAuth:ce,handleDatabase:ie,handleExtras:ee,handleFormatter:E,handleHttpProvider:C,handleInitGit:z,handleMicroservices:T,handleOrm:ae,handlePackageManager:A,handleProjectNameSubmit:$,handleProjectType:H,handleRetry:_,handleSummaryConfirm:Pe,handleUltraciteAgents:Y,handleUltraciteEditors:te,handleUltraciteHooks:U,handleUltraciteInstallSkill:Ae,handleUltraciteSetupConfirm:Ee,projectNameError:l,setProjectNameError:u,setState:a,state:n,statusAction:Ce,stepId:s,subProgress:M,totalSteps:k}},"useCreateProjectWizard"),Xr=p(({onBack:t,onDone:e,onExit:r,onStepChange:s})=>{const{architectureOpts:o,displayStep:n,extrasStepOptions:a,generationStatus:l,goBack:u,handleProjectNameSubmit:h,handlePackageManager:y,handleFormatter:k,handleHttpProvider:w,handleProjectType:M,handleArchitecture:v,handleDatabase:W,handleOrm:$,handleApi:A,handleAuth:E,handleExtras:C,handleMicroservices:H,handleAddons:Q,handleUltraciteEditors:ie,handleUltraciteAgents:ae,handleUltraciteHooks:oe,handleUltraciteInstallSkill:ce,handleInitGit:ee,handleRetry:he,handleSummaryConfirm:T,handleUltraciteSetupConfirm:L,projectNameError:te,setProjectNameError:Y,setState:U,statusAction:Ae,stepId:z,subProgress:Ee,totalSteps:Pe,state:_}=Yr({onBack:t,onExit:r,onStepChange:s});le(()=>{z==="done"&&e()},[z,e]),B((b,m)=>{if(m.ctrl&&b==="c"){r();return}if(m.ctrl&&b==="b"){u();return}if(z==="done"&&m.return){r();return}z==="installing"&&l?.isError&&m.return&&he()});const Ce=p(()=>{switch(z){case"projectName":return i(nt,{error:te,onChange:p(b=>{U(m=>({...m,projectName:b})),Y(we(b))},"onChange"),onSubmit:h,value:_.projectName});case"packageManager":return i(K,{onConfirm:y,options:it,prompt:"Choose a package manager"},"packageManager");case"formatter":return i(K,{onConfirm:k,options:Ne,prompt:"Choose a formatter-linter setup"},"formatter");case"httpProvider":return i(K,{onConfirm:w,options:at,prompt:"Choose an HTTP provider"},"httpProvider");case"projectType":return i(K,{onConfirm:M,options:ot,prompt:"Choose a project layout"},"projectType");case"architecture":return i(K,{onConfirm:v,options:o,prompt:"Choose an application architecture"},"architecture");case"database":return i(V,{initialSelected:_.database,onConfirm:W,options:lt,prompt:"Select databases for your project"},"database");case"orm":return i(V,{initialSelected:_.orm,onConfirm:$,options:ft(_.database),prompt:"Select ORMs to include"},"orm");case"apiLayer":return i(V,{initialSelected:_.api,onConfirm:A,options:pt,prompt:"Select API layers"},"apiLayer");case"auth":return i(K,{onConfirm:E,options:ut,prompt:"Choose an authentication strategy"},"auth");case"extras":return i(V,{initialSelected:_.extras,onConfirm:C,options:a,prompt:"Select extras"},"extras");case"microservices":return i(V,{initialSelected:_.microservices,onConfirm:H,options:Lt,prompt:"Select microservice communication protocols"},"microservices");case"addons":return i(V,{initialSelected:_.addons,onConfirm:Q,options:dt,prompt:"Select addons"},"addons");case"ultraciteEditors":return i(V,{initialSelected:_.ultraciteEditors,onConfirm:ie,options:Ut,prompt:"Select Ultracite editors",minified:!0},"ultraciteEditors");case"ultraciteAgents":return i(V,{initialSelected:_.ultraciteAgents,onConfirm:ae,options:zt,prompt:"Select Ultracite agents",minified:!0},"ultraciteAgents");case"ultraciteHooks":return i(V,{initialSelected:_.ultraciteHooks,onConfirm:oe,options:Ht,prompt:"Select Ultracite hooks"},"ultraciteHooks");case"ultraciteInstallSkill":return i(K,{onConfirm:ce,options:Bt,prompt:"Install Ultracite skill?"},"ultraciteInstallSkill");case"initGit":return i(K,{onConfirm:ee,options:mt,prompt:"Initialize a git repository?"},"initGit");case"summary":return i(er,{onConfirm:T,state:_});case"ultraciteSetup":return i(rr,{onConfirm:L,state:_});case"installing":return f(g,{flexDirection:"column",children:[i(et,{message:l?.message||"Scaffolding your project",isError:l?.isError??!1}),l?.isError?i(g,{marginTop:1,children:f(c,{color:P,children:["Press ",i(c,{color:S,children:"Enter"})," to go back to Summary and retry, or ",i(c,{color:P,children:"Ctrl+B"})," to go back"]})}):null]});case"done":{const b=Z(_.projectName),m=_.initGit==="yes",X=He(b);return i(tt,{architecture:_.architecture||"nest-api",projectName:b,packageManager:_.packageManager||"pnpm",isGitInitialized:m,outputDir:X})}default:return null}},"renderStep"),Te=z!=="installing"&&z!=="done";return f(g,{flexDirection:"column",flexGrow:1,paddingX:2,paddingY:1,children:[Te?f(N,{children:[i(sr,{state:_,stepId:z}),i(g,{height:0}),i(nr,{displayStep:n,stepId:z,subProgress:Ee??void 0,totalSteps:Pe}),i(g,{height:2})]}):null,Ce(),i(g,{flexGrow:1}),Te?f(N,{children:[i(ue,{}),i(g,{height:1}),i(Oe,{action:Ae,showBack:!0})]}):null]})},"CreateProjectWizardScreen"),Be=` _ _ ___ ___ _____ _ ___ ___ _ _
48
- | \\| | __/ __|_ _| /_\\ | _ \\/ __| || |
49
- | .\` | _|\\__ \\ | | / _ \\| / (__| __ |
50
- |_|\\_|___|___/ |_| /_/ \\_\\_|_\\\\___|_||_|`,Zr=12,es=4,At=p(({onlyCat:t=!1})=>{const{stdout:e}=Ve(),r=e.columns||e.getWindowSize?.()[0]||80,s=e.rows||e.getWindowSize?.()[1]||24;return t?s<15||r<20?i(g,{flexDirection:"column",alignItems:"center",children:i(c,{bold:!0,color:S,children:Ye})}):i(g,{flexDirection:"column",alignItems:"center",children:i(c,{color:S,children:Ie})}):s<15||r<38?f(g,{flexDirection:"column",alignItems:"center",rowGap:0,children:[i(c,{bold:!0,color:S,children:Ye}),i(c,{color:P,children:be}),i(c,{color:G,children:fe})]}):s<15+es||r<55?f(g,{flexDirection:"column",alignItems:"center",rowGap:0,children:[i(c,{color:S,children:Be}),i(c,{color:P,children:be}),i(c,{color:G,children:fe})]}):s<15+Zr||r<80?f(g,{flexDirection:"column",alignItems:"center",rowGap:0,children:[i(c,{color:S,children:Ie}),i(c,{color:S,children:Be}),i(c,{color:P,children:be}),i(c,{color:G,children:fe})]}):f(g,{flexDirection:"row",columnGap:2,alignItems:"flex-start",children:[i(c,{color:S,children:Ie}),f(g,{flexDirection:"column",children:[i(c,{color:S,children:Be}),f(c,{color:P,children:[" ",be]}),f(c,{color:G,children:[" ",fe]})]})]})},"Header"),We={addons:["ultracite","husky"],api:["rest"],architecture:"nest-api",auth:"none",database:[],extras:[],formatter:"oxlint-oxfmt",httpProvider:"express",microservices:[],orm:[],packageManager:"pnpm",projectType:"single",ultraciteAgents:[],ultraciteEditors:[],ultraciteHooks:[],ultraciteInstallSkill:"no"},ts=p(({onSelect:t,options:e})=>{const[r,s]=I(0),o=j(()=>{const n=e[r];n&&!n.disabled&&t(n)},[t,e,r]);return B((n,a)=>{a.upArrow||n==="k"?s(l=>Math.max(0,l-1)):a.downArrow||n==="j"?s(l=>Math.min(e.length-1,l+1)):a.return&&o()}),f(g,{flexDirection:"column",children:[i(c,{color:P,children:"Choose a project preset"}),i(g,{marginTop:1,flexDirection:"column",rowGap:1,children:e.map((n,a)=>f(g,{flexDirection:"column",children:[i(c,{children:a===r?f(N,{children:[i(c,{color:n.disabled?pe:S,children:"> "}),i(c,{color:n.disabled?pe:S,children:n.name})]}):i(c,{color:n.disabled?pe:ye,children:` ${n.name}`})}),a===r&&n.description?i(c,{color:P,children:n.description}):null]},n.name))})]})},"PresetStep"),rs={done:"Done",initGit:"Git repository",installing:"Installing",preset:"Project preset",projectName:"Project name"},ss=p(({step:t})=>f(c,{children:[i(c,{color:S,children:"\u2727 "}),i(c,{color:O,children:rs[t]})]}),"WizardTitle"),ns=p(({onBack:t,onDone:e,onExit:r,onStepChange:s})=>{const[o,n]=I("preset"),[a,l]=I(""),[u,h]=I(null),[y,k]=I(null),[w,M]=I(null),[v,W]=I("");le(()=>{o==="done"&&e()},[o,e]);const $=J(()=>ir(),[]),A=J(()=>{const T=[{description:"REST API with standard NestJS modules and structure",name:"Basic NestJS API"},{description:"Microservice support with gateway routing",name:"API Gateway"}];return $?T.push({description:ar($),name:"Last Used"}):T.push({description:"",disabled:!0,name:"Last Used"}),T},[$]),[E,C]=I(We),H=j(()=>{switch(o){case"projectName":{n("preset"),s?.("preset"),h(null);return}case"initGit":{n("projectName"),s?.("projectName");return}default:t()}},[t,o,s]),Q=j(T=>{if(T.name==="Last Used"&&$){const{projectName:L,initGit:te,...Y}=$;C(Y)}else T.name==="API Gateway"?C({...We,architecture:"nest-gateway",projectType:"monorepo"}):C(We);n("projectName"),s?.("projectName")},[$,s]),ie=j(T=>{l(T),h(we(T))},[]),ae=j(()=>{const T=we(a);if(T){h(T);return}n("initGit"),s?.("initGit")},[a,s]),oe=j(async T=>{k(T);const L=Z(a),te=He(L);W(te),n("installing"),s?.("installing");const Y={...E,initGit:T,projectName:L};try{const U=await St(Y);M({isError:!U.success,message:U.message}),U.success&&(vt(Y),setTimeout(()=>{n("done"),s?.("done")},1e3))}catch(U){M({isError:!0,message:`Error: ${U instanceof Error?U.message:String(U)}`})}},[a,E,s]);B((T,L)=>{if(L.ctrl&&T==="c"){r();return}if(L.ctrl&&T==="b"){H();return}o==="done"&&L.return&&r()});const ce=J(()=>o==="projectName"?"confirm":"select",[o]),ee=o!=="installing"&&o!=="done";return f(g,{flexDirection:"column",flexGrow:1,paddingX:2,paddingY:1,children:[ee?f(N,{children:[i(At,{}),i(ue,{}),i(g,{height:1}),i(ss,{step:o}),i(g,{height:2})]}):null,p(()=>{switch(o){case"preset":return i(ts,{onSelect:Q,options:A});case"projectName":return i(nt,{error:u,onChange:ie,onSubmit:ae,value:a});case"initGit":return i(K,{onConfirm:oe,options:mt,prompt:"Initialize a git repository?"});case"installing":return f(g,{flexDirection:"column",children:[i(et,{message:w?.message||"Scaffolding your project",isError:w?.isError??!1}),w?.isError?i(g,{marginTop:1,children:f(c,{color:P,children:["Press ",i(c,{color:S,children:"Enter"})," to go back to Summary and retry, or ",i(c,{color:P,children:"Ctrl+B"})," to go back"]})}):null]});case"done":{const T=Z(a);return i(tt,{architecture:E.architecture||"nest-api",projectName:T,packageManager:E.packageManager||"pnpm",isGitInitialized:y==="yes",outputDir:v})}default:return null}},"renderStep")(),i(g,{flexGrow:1}),ee?f(N,{children:[i(ue,{}),i(g,{height:1}),i(Oe,{action:ce,showBack:!0})]}):null]})},"ProjectPresetWizardScreen"),Je=[{description:"Scaffold a new project with best practices",name:"Create a new NestJS project"},{description:"Choose from predefined configurations",name:"Use a project preset"},{description:"Load and manage an existing project",name:"Open an existing project"},{description:"Browse the Nest Arch docs",name:"View documentation"},{description:"Close Nest Arch",name:"Exit"}],is=p(({onSelect:t})=>{const[e,r]=I(0),s=j(()=>{t(e,Je[e]??null)},[t,e]);return B((o,n)=>{n.upArrow||o==="k"?r(a=>Math.max(0,a-1)):n.downArrow||o==="j"?r(a=>Math.min(Je.length-1,a+1)):n.return&&s()}),f(g,{flexDirection:"column",children:[i(c,{color:P,children:" What would you like to do?"}),i(g,{marginTop:1,flexDirection:"column",rowGap:1,children:Je.map((o,n)=>i(c,{children:n===e?f(N,{children:[i(c,{color:S,children:"> "}),i(c,{color:S,children:o.name})]}):i(c,{color:ye,children:` ${o.name}`})},o.name))})]})},"MainMenu"),as=p(()=>f(c,{children:[i(c,{color:S,children:"\u2727 "}),i(c,{color:O,children:" Welcome to "}),i(c,{color:S,children:"Nest Arch"}),i(c,{color:O,children:" \u2013 Let's build something amazing."})]}),"WelcomeMessage"),os=p(({onCreateProject:t,onExit:e,onUsePreset:r})=>{const s=j(async()=>{const n="https://github.com/Angel-Mario";try{await Dt(n,{wait:!1})}catch{}},[]),o=j((n,a)=>{a?.name==="Exit"?e():a?.name==="Create a new NestJS project"?t():a?.name==="Use a project preset"?r():a?.name==="View documentation"&&s()},[t,e,r,s]);return B((n,a)=>{a.ctrl&&n==="c"&&e()}),f(g,{flexDirection:"column",flexGrow:1,paddingX:2,paddingY:1,children:[i(At,{}),i(ue,{}),i(g,{height:1}),i(as,{}),i(g,{height:2}),i(is,{onSelect:o}),i(g,{flexGrow:1}),i(ue,{borderTop:!1}),i(g,{height:1}),i(Oe,{})]})},"WelcomeScreen"),cs=p(({onDone:t})=>{const[e,r]=I("welcome"),{stdout:s}=Ve(),{exit:o}=Tt(),[n,a]=I(s?.rows??24);le(()=>{if(!s)return;const w=p(()=>{a(s.rows)},"handleResize");return s.on("resize",w),()=>{s.off("resize",w)}},[s]);const l=j(()=>{o()},[o]),u=j(()=>{r("preset-wizard")},[]),h=j(()=>{r("create-wizard")},[]),y=j(()=>{r("welcome")},[]);return i(g,{height:n,flexDirection:"column",children:p(()=>e==="create-wizard"?i(Xr,{onBack:y,onDone:t,onExit:l}):e==="preset-wizard"?i(ns,{onBack:y,onDone:t,onExit:l}):i(os,{onCreateProject:h,onExit:l,onUsePreset:u}),"renderScreen")()})},"App");async function ls(){process.stdout.write("\x1B[?1049h");let t=!1;try{await Ct(i(cs,{onDone:p(()=>{process.stdout.write("\x1B[?1049l"),t=!0},"onDone")})).waitUntilExit()}finally{t||process.stdout.write("\x1B[?1049l")}}p(ls,"main");try{await ls()}catch(t){console.error("Error:",t),process.exit(1)}export{De as e};