untitledui 0.1.57 → 0.1.58

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.
Files changed (2) hide show
  1. package/dist/index.mjs +2 -2
  2. package/package.json +1 -1
package/dist/index.mjs CHANGED
@@ -9,9 +9,9 @@ import{Command as r1}from"commander";import C from"chalk";import{Command as s0}f
9
9
  These aliases will be used for imports but files will be placed in default locations.`)),console.log(zy.dim(` To fix this, add matching paths to your tsconfig.json.
10
10
  `));return $}async function O$(y){let[$,j]=await Promise.all([Vy.glob("next.config.*",{cwd:y,deep:1,ignore:l}),Vy.glob("vite.config.*",{cwd:y,deep:1,ignore:l})]),z=$.length>0,Y=j.length>0,W=null;if(z)W=gy(y);else if(Y){if(W=gy(y),W?.resultType==="failed"||!Object.keys(W.paths||{}).length){let Z=await Vy.glob(["tsconfig.app.*","*/tsconfig.app.*"],{cwd:y,deep:1,onlyFiles:!0,absolute:!0,ignore:l}),[X]=Z;if(X)try{let V=function(q){return q.replace(/\/\*[\s\S]*?\*\//g,"").replace(/\/\/.*$/gm,"").replace(/,(\s*[}\]])/g,"$1")},U=Qy.readFileSync(X,"utf-8"),B=V(U),b=JSON.parse(B);if(b.compilerOptions?.paths)W={resultType:"success",paths:b?.compilerOptions?.paths,baseUrl:b.compilerOptions.baseUrl||".",configFileAbsolutePath:X,absoluteBaseUrl:Yy.resolve(y,b.compilerOptions.baseUrl||".")}}catch{}}}else W=gy(y);if(!W||W?.resultType==="failed"||!Object.keys(W.paths).length)return null;return W}async function C0(y){let $=await Vy.glob("tailwind.config.*",{cwd:y,deep:2,ignore:l});if(!$.length)return null;return $[0]}async function u0(y){let $=await O$(y);if(!$)return null;let j={},z={app:/\/?app\/\*$/,components:/\/?components\/\*$/,utils:/\/?utils\/\*$/,styles:/\/?styles\/\*$/,hooks:/\/?hooks\/\*$/,src:/^(\.\/src\/\*|\.\/\*|\/src\/\*|src\/\*|\/\*|\*)$/};for(let[Y,W]of Object.entries($.paths)){let Z=Y.replace(/\/\*$/,"/");for(let[X,U]of Object.entries(z))if(W.some((V)=>U.test(V))){j[X]=Z;break}}return j||null}function wy(y,$){let j=k$(y),z=y$.sync(["tailwind.config.*","**/globals.css","package.json"],{cwd:y,deep:4,absolute:!0,onlyFiles:!0,ignore:l}),Y=y$.sync("**/{layout,_app,main}.tsx",{cwd:$?Wy.posix.join(y,$):y,deep:4,absolute:!0,onlyFiles:!0,ignore:l});return{tailwindFile:z.find((Z)=>Z.includes("tailwind.config.")),cssFile:z.find((Z)=>Z.includes("globals.css")),packageJson:z.find((Z)=>Z.includes("package.json")),tsConfig:j?.resultType==="success"?j?.configFileAbsolutePath:void 0,layoutFile:Y.find((Z)=>Z.includes("layout")),appFile:Y.find((Z)=>Z.includes("_app")),mainFile:Y.find((Z)=>Z.includes("main"))}}function Ay(y,$,j={}){if(y.startsWith("@/components/")){if(j?.components)return y.replace(/^@\/components\//,Wy.posix.join(j.components,"/"));if($)return y.replace(/^@\/components\//,Wy.posix.join("@",$,"/"))}if(y.startsWith("@/app/")&&j?.app)return y.replace(/^@\/app\//,Wy.posix.join(j.app,"/"));if(y.startsWith("@/utils/")&&j?.utils)return y.replace(/^@\/utils\//,Wy.posix.join(j.utils,"/"));if(y.startsWith("@/hooks/")&&j?.hooks)return y.replace(/^@\/hooks\//,Wy.posix.join(j.hooks,"/"));if(y.startsWith("@/styles/")&&j?.styles)return y.replace(/^@\/styles\//,Wy.posix.join(j.styles,"/"));if(y.startsWith("@/")&&j?.src)return y.replace(/^@\//,Wy.posix.join(j.src,"/"));return y}async function P$(y,$,j="@/*"){let z=await k$(y);if(z?.resultType==="failed")return null;let Y={};if(!Object.keys(z.paths).length){z.paths={[j]:[`./${$?"src/":""}*`]},Y.src=j.replace(/\/\*$/,"");let W=await dy.promises.readFile(z.configFileAbsolutePath,"utf-8"),Z,X=/(?:\/\/\s*)?"paths":\s*\{(?:[^{}]|\{[^}]*\})*\}/;if(!X.test(W))Z=W.replace(/"compilerOptions":\s*{/,`"compilerOptions": {
11
11
  "paths": ${JSON.stringify(z.paths)},`);else Z=W.replace(X,`"paths": ${JSON.stringify(z.paths)}`);let V=new O0,B=await T$(Z,"json");return V.createSourceFile(z.configFileAbsolutePath,B,{overwrite:!0}),await V.save(),Y}return Y||null}function g$(y){let $=y$.sync(["vite.config.*"],{cwd:y,absolute:!0,onlyFiles:!0,ignore:l})?.[0];if(!$)return!1;try{let j=dy.readFileSync($,"utf-8");return k0(j)}catch{return!1}}function k0(y){let $=y.replace(/\/\/.*$/gm,"").replace(/\/\*[\s\S]*?\*\//g,"");if(!["tailwindcss","@tailwindcss/vite","tailwind("].some((W)=>$.includes(W)))return!1;return["plugins:","postcss:","css:"].some((W)=>$.includes(W))}var P0=["npm","config","user","agent"].join("_");function qy(y){if(y===void 0)y=process.env[P0]||"";if(y.startsWith("yarn"))return"yarn";if(y.startsWith("pnpm"))return"pnpm";if(y.startsWith("bun"))return"bun";return"npm"}function Zy(){switch(qy()){case"yarn":return"yarn";case"pnpm":return"pnpx";case"bun":return"bunx";default:return"npx"}}function d$(){switch(qy()){case"yarn":return"yarn dev";case"pnpm":return"pnpm dev";case"bun":return"bun dev";default:return"npm run dev"}}import g0 from"async-retry";import{execa as f$}from"execa";async function Uy(y,$){let j=Array.isArray(y)?y:Array.from(y);if(!j.length)return;let{cwd:z,dev:Y=!1,spinner:W,label:Z=Y?"devDependencies":"dependencies"}=$,X=qy(),V=[X==="npm"?"install":"add",...Y?["-D"]:[],...j];W.start(`Installing ${Z}`),await g0(()=>f$(X,V,{cwd:z}).catch(async(B)=>{if(B.message.includes("peer"))W.warn(`${Z} conflict detected. Retrying with --legacy-peer-deps...`),W.start(`Installing ${Z} with --legacy-peer-deps flag`),await f$(X,[...V,"--legacy-peer-deps"],{cwd:z});else throw B}),{retries:1}),W.succeed(`${Z} installed`)}var f=(y)=>{if(y.aborted)process.stdout.write("\x1B[?25h"),process.stdout.write(`
12
- `),process.exit(1)};function fy(y){return y.replace(/^[ \t]*\/\/\s*(TODO:|collapse-(start|end)).*\r?\n?|[ \t]*{\s*\/\*\s*(TODO:|collapse-(start|end)).*?\*\/\s*}\r?\n?/gm,"")}import Xy from"path";function cy(y,$,j){let z=y.replace(/^(components|utils|hooks|styles)\//,"");if(y.includes("components")&&$?.components)return Xy.relative(process.cwd(),Xy.posix.join($.components,z));if(y.includes("utils")&&$?.utils)return Xy.relative(process.cwd(),Xy.posix.join($.utils,z));if(y.includes("hooks")&&$?.hooks)return Xy.relative(process.cwd(),Xy.posix.join($.hooks,z));if(y.includes("styles")&&$?.styles)return Xy.relative(process.cwd(),Xy.posix.join($.styles,z));return Xy.posix.join(j?"src":"",y)}import c$ from"node-fetch";import{Readable as d0,pipeline as f0}from"stream";import{x as c0}from"tar";import{promisify as h0}from"util";var m0=h0(f0);async function h$(y,$){try{let j=await l0($);await m0(j,c0({cwd:y,strip:1}))}catch(j){throw Error(`Failed to download or extract repository from API: ${j instanceof Error?j.message:j}`)}}async function l0(y){let $=`https://www.untitledui.com/react/api/download-repo?template=${y.template}`;try{let j=await c$($,{method:"GET",headers:{"Content-Type":"application/json",Accept:"application/octet-stream"}});if(j.status===403||j.status===404)throw Error("Repository not found");if(!j.ok)throw Error(`Failed to download from API. Status: ${j.status} ${j.statusText}`);if(!j.body)throw Error("Response body is empty");return d0.from(j.body)}catch(j){throw Error(`Error downloading tarball: ${j instanceof Error?j.message:j}`)}}async function m$(y){let $=`https://www.untitledui.com/react/api/validate-key?key=${y}`;try{return(await c$($)).status===200}catch{return!1}}async function hy(y,$){if(!await m$(y))$.fail("Invalid license key"),process.exit(1);Oy(y)}var G={components:[],path:"",type:void 0,license:My()},l$=new s0().name("add").description("add a component to your project").argument("[components...]","the components to add").option("-a, --all","add all available components",!1).option("-o, --overwrite","overwrite existing files.",!1).option("-p, --path <path>","the path to add the component to.").option("-d, --dir <directory>","the directory where the project is located.").option("-t, --type <base|marketing|shared-assets|application|foundations>","the type of the component to add.").option("--include-all-components","automatically include all base components without prompting.",!1).option("-y, --yes","non-interactive mode - use defaults for all prompts (for AI agents/CI).",!1).action(async(y,$)=>{if(y)G.components=y;if($){if(G.all=$.all,G.dir=$.dir,G.path=$.path,G.overwrite=$.overwrite,G.includeAllComponents=$.includeAllComponents,G.license=$.license||G.license,G.yes=$.yes,$.yes)G.includeAllComponents=!0,G.overwrite=!0}try{await $$(G)}catch(j){console.error(C.red(j))}});async function $$(y){if(y)G={...G,...y};let $=vy().start(),j=h.posix.join(process.cwd(),G.dir||"");if(!i.existsSync(h.resolve(j,"package.json")))$.warn("This command should be run in a project directory."),process.exit(1);let Y=await By(j);if(G.license)await hy(G.license,$);$.stop();let W=[];if(G.components.length){let Q=await ky(G.type,G.components,G.license);if(Q&&Q.pro&&Q.pro.length>0){if(console.log(),Q.pro.length===1){let L=Q.pro[0]?.split("/")[1]||Q.pro[0];console.log(C.yellow(`\uD83D\uDD12 The ${C.cyan(L)} component requires PRO access.`))}else console.log(C.yellow("\uD83D\uDD12 The following components require PRO access:")),Q.pro.forEach((L)=>{let D=L?.split("/")[1]||L;console.log(` • ${C.cyan(D)}`)});console.log(),console.log("To access PRO components:"),console.log(` ${C.green("→")} If you've already purchased: ${C.cyan(`${Zy()} untitledui@latest login`)}`),console.log(` ${C.green("→")} To purchase PRO components: ${C.cyan("https://www.untitledui.com/buy/react")}`),console.log(),process.exit(1)}if(!Q?.components.length)console.log("No components found"),process.exit(1);W.push(...Q.components)}if(!G?.type&&!G?.components.length){if(G.yes)console.log(C.red("Error: In non-interactive mode (--yes), you must specify components as arguments.")),process.exit(1);let Q=await I$(G.license);if(!Q)console.log("No component types found"),process.exit(1);let L=await Jy({type:"select",name:"type",onState:f,message:`What type of ${C.cyan("component")} are you adding?`,choices:Q?.types.map((D)=>({title:D,value:D}))});G.type=L.type}if(!G?.path&&!Y?.paths?.components)if(G.yes)G.path="components";else{let Q=await Jy({type:"text",name:"path",onState:f,message:`Where would you like to add the ${C.cyan("components")}?`,initial:"components"});G.path=Q.path}if(G?.path&&Y&&Y.paths)Y.paths.components=h.posix.join(Y?.isSrcDir?"src":"",G.path);if(Y&&!Object.keys(Y?.aliases).length){let Q="@/*";if(!G.yes){let L=/^[^*"]+\/\*\s*$/;Q=(await Jy({type:"text",name:"aliasPrefix",onState:f,initial:"@/*",message:`What is the ${C.cyan("import alias")} for your project?`,validate:(_)=>L.test(_)?!0:"Import alias must follow the pattern <prefix>/*"}))?.aliasPrefix}Y.aliases=await P$(j,Y?.isSrcDir,Q)}if(!G?.components.length){if(G.yes)console.log(C.red("Error: In non-interactive mode (--yes), you must specify components as arguments.")),process.exit(1);let Q=await E$(G?.type,G.license);if(!Q)console.log("No components found"),process.exit(1);let L=await Jy({type:"multiselect",name:"components",onState:f,message:`Which ${C.cyan("components")} would you like to add?`,choices:Q?.components?.map((x)=>({title:x?.name+(x?.count?` (${x?.count} variants)`:"")||"example",value:x||"example",selected:G.components.includes(x.name)})),instructions:!1,hint:"- Space to select. Return to submit"});if(!L.components||!L.components.length)console.log("No option selected. Exiting..."),process.exit(1);let D=L.components.filter((x)=>x?.type==="file").map((x)=>x.name),_=L.components.filter((x)=>x?.type==="dir").map((x)=>x.name),E=[];if(_.length){let x=await x$(G?.type,G.license,_);if(x&&x.components.length)for(let v of x.components){let[F,I]=Object.entries(v)[0]||[],T=await Jy({type:"select",name:"component",onState:f,message:`Which ${C.cyan("variant")} from ${C.cyan(F)} would you like to add?`,choices:I?.map((R)=>({title:R?.name.replace(/-modal/g,"")||"example",value:R?.name||"example",selected:G.components.includes(R.name)})),instructions:!1,hint:"- Space to select. Return to submit"});if(!T.component)console.log("No variant selected for "+C.cyan(F));E.push(F+"/"+T.component)}else console.log("No variants found")}G.components=[...E,...D]}if(!G.components?.length)$.warn("No components selected. Exiting."),process.exit(1);let Z=wy(j),X=new Set,U=new Set,V=new Set,B=new r0({tsConfigFilePath:Z?.tsConfig});if($.start(),G.type&&G.components.length){let Q=await ky(G.type,G.components,G.license);if(!Q?.components.length)console.log("No components found"),process.exit(1);W.push(...Q.components)}let b=new Set;if(W.forEach((Q)=>{Q?.components?.forEach((L)=>{b.add({name:L.name,path:L.path})})}),$.stop(),b.size){let Q=Array.from(b).filter((L)=>!i.existsSync(h.posix.join(j,`${Y?.isSrcDir?"src":""}`,L?.path?.replace(/components\//,G.path+"/"))));if(Q?.length)if(G.includeAllComponents)G.baseComponents=Q.map((L)=>L.name);else{let L=await Jy({type:"multiselect",name:"baseComponents",onState:f,message:"Select which base components you want to add",choices:Q.map((D)=>({title:D?.name,value:D?.name,selected:!0})),instructions:!1,hint:"- Space to select. Return to submit"});if(G.baseComponents=L.baseComponents,!Q.length&&!L.baseComponents?.length)$.warn("No components selected")}}if($.start(),G?.baseComponents?.length){let Q=await ky("",G.baseComponents,G.license);if(!Q||!Q?.components.length)console.log("No base components found");else W.push(...Q.components)}$.stop();let q=new Set;for(let Q of W){let L=vy(`Adding ${Q.name}...`).start(),D=Q.files;Q?.dependencies?.forEach((E)=>U.add(E)),Q?.devDependencies?.forEach((E)=>V.add(E));let _=!1;try{for(let{path:E,code:x}of D||[]){let v=h.posix.join(j,cy(E,Y?.paths,Y?.isSrcDir)),F=Y?.framework==="vite"?x.replace(`"use client";
12
+ `),process.exit(1)};function fy(y){return y.replace(/^[ \t]*\/\/\s*(TODO:|collapse-(start|end)).*\r?\n?|[ \t]*{\s*\/\*\s*(TODO:|collapse-(start|end)).*?\*\/\s*}\r?\n?/gm,"")}import Xy from"path";function cy(y,$,j){let z=y.replace(/^(components|utils|hooks|styles)\//,"");if(y.includes("components")&&$?.components)return Xy.relative(process.cwd(),Xy.posix.join($.components,z));if(y.includes("utils")&&$?.utils)return Xy.relative(process.cwd(),Xy.posix.join($.utils,z));if(y.includes("hooks")&&$?.hooks)return Xy.relative(process.cwd(),Xy.posix.join($.hooks,z));if(y.includes("styles")&&$?.styles)return Xy.relative(process.cwd(),Xy.posix.join($.styles,z));return Xy.posix.join(j?"src":"",y)}import c$ from"node-fetch";import{Readable as d0,pipeline as f0}from"stream";import{x as c0}from"tar";import{promisify as h0}from"util";var m0=h0(f0);async function h$(y,$){try{let j=await l0($);await m0(j,c0({cwd:y,strip:1}))}catch(j){throw Error(`Failed to download or extract repository from API: ${j instanceof Error?j.message:j}`)}}async function l0(y){let $=`https://www.untitledui.com/react/api/download-repo?template=${y.template}`;try{let j=await c$($,{method:"GET",headers:{"Content-Type":"application/json",Accept:"application/octet-stream"}});if(j.status===403||j.status===404)throw Error("Repository not found");if(!j.ok)throw Error(`Failed to download from API. Status: ${j.status} ${j.statusText}`);if(!j.body)throw Error("Response body is empty");return d0.from(j.body)}catch(j){throw Error(`Error downloading tarball: ${j instanceof Error?j.message:j}`)}}async function m$(y){let $=`https://www.untitledui.com/react/api/validate-key?key=${y}`;try{return(await c$($)).status===200}catch{return!1}}async function hy(y,$){if(!await m$(y))$.fail("Invalid license key"),process.exit(1);Oy(y)}var G={components:[],path:"",type:void 0,license:My()},l$=new s0().name("add").description("add a component to your project").argument("[components...]","the components to add").option("-a, --all","add all available components",!1).option("-o, --overwrite","overwrite existing files.",!1).option("-p, --path <path>","the path to add the component to.").option("-d, --dir <directory>","the directory where the project is located.").option("-t, --type <base|marketing|shared-assets|application|foundations>","the type of the component to add.").option("--include-all-components","automatically include all base components without prompting.",!1).option("-y, --yes","non-interactive mode - use defaults for all prompts (for AI agents/CI).",!1).action(async(y,$)=>{if(y)G.components=y;if($){if(G.all=$.all,G.dir=$.dir,G.path=$.path,G.overwrite=$.overwrite,G.includeAllComponents=$.includeAllComponents,G.license=$.license||G.license,G.yes=$.yes,$.yes)G.includeAllComponents=!0,G.overwrite=!0}try{await $$(G)}catch(j){console.error(C.red(j))}});async function $$(y){if(y)G={...G,...y};let $=vy().start(),j=h.posix.join(process.cwd(),G.dir||"");if(!i.existsSync(h.resolve(j,"package.json")))$.warn("This command should be run in a project directory."),process.exit(1);let Y=await By(j);if(G.license)await hy(G.license,$);$.stop();let W=[];if(G.components.length){let Q=await ky(G.type,G.components,G.license);if(Q&&Q.pro&&Q.pro.length>0){if(console.log(),Q.pro.length===1){let L=Q.pro[0]?.split("/")[1]||Q.pro[0];console.log(C.yellow(`\uD83D\uDD12 The ${C.cyan(L)} component requires PRO access.`))}else console.log(C.yellow("\uD83D\uDD12 The following components require PRO access:")),Q.pro.forEach((L)=>{let D=L?.split("/")[1]||L;console.log(` • ${C.cyan(D)}`)});console.log(),console.log("To access PRO components:"),console.log(` ${C.green("→")} If you've already purchased: ${C.cyan(`${Zy()} untitledui@latest login`)}`),console.log(` ${C.green("→")} To purchase PRO components: ${C.cyan("https://www.untitledui.com/buy/react")}`),console.log(),process.exit(1)}if(!Q?.components.length)console.log("No components found"),process.exit(1);W.push(...Q.components)}if(!G?.type&&!G?.components.length){if(G.yes)console.log(C.red("Error: In non-interactive mode (--yes), you must specify components as arguments.")),process.exit(1);let Q=await I$(G.license);if(!Q)console.log("No component types found"),process.exit(1);let L=await Jy({type:"select",name:"type",onState:f,message:`What type of ${C.cyan("component")} are you adding?`,choices:Q?.types.map((D)=>({title:D,value:D}))});G.type=L.type}if(!G?.path&&!Y?.paths?.components)if(G.yes)G.path="components";else{let Q=await Jy({type:"text",name:"path",onState:f,message:`Where would you like to add the ${C.cyan("components")}?`,initial:"components"});G.path=Q.path}if(G?.path&&Y&&Y.paths)Y.paths.components=h.posix.join(Y?.isSrcDir?"src":"",G.path);if(Y&&!Object.keys(Y?.aliases).length){let Q="@/*";if(!G.yes){let L=/^[^*"]+\/\*\s*$/;Q=(await Jy({type:"text",name:"aliasPrefix",onState:f,initial:"@/*",message:`What is the ${C.cyan("import alias")} for your project?`,validate:(_)=>L.test(_)?!0:"Import alias must follow the pattern <prefix>/*"}))?.aliasPrefix}Y.aliases=await P$(j,Y?.isSrcDir,Q)}if(!G?.components.length){if(G.yes)console.log(C.red("Error: In non-interactive mode (--yes), you must specify components as arguments.")),process.exit(1);let Q=await E$(G?.type,G.license);if(!Q)console.log("No components found"),process.exit(1);let L=await Jy({type:"multiselect",name:"components",onState:f,message:`Which ${C.cyan("components")} would you like to add?`,choices:Q?.components?.map((x)=>({title:x?.name+(x?.count?` (${x?.count} variants)`:"")||"example",value:x||"example",selected:G.components.includes(x.name)})),instructions:!1,hint:"- Space to select. Return to submit"});if(!L.components||!L.components.length)console.log("No option selected. Exiting..."),process.exit(1);let D=L.components.filter((x)=>x?.type==="file").map((x)=>x.name),_=L.components.filter((x)=>x?.type==="dir").map((x)=>x.name),E=[];if(_.length){let x=await x$(G?.type,G.license,_);if(x&&x.components.length)for(let v of x.components){let[F,I]=Object.entries(v)[0]||[],T=await Jy({type:"select",name:"component",onState:f,message:`Which ${C.cyan("variant")} from ${C.cyan(F)} would you like to add?`,choices:I?.map((R)=>({title:R?.name.replace(/-modal/g,"")||"example",value:R?.name||"example",selected:G.components.includes(R.name)})),instructions:!1,hint:"- Space to select. Return to submit"});if(!T.component)console.log("No variant selected for "+C.cyan(F));E.push(F+"/"+T.component)}else console.log("No variants found")}G.components=[...E,...D]}if(!G.components?.length)$.warn("No components selected. Exiting."),process.exit(1);let Z=wy(j),X=new Map,U=new Set,V=new Set,B=new r0({tsConfigFilePath:Z?.tsConfig});if($.start(),G.type&&G.components.length){let Q=await ky(G.type,G.components,G.license);if(!Q?.components.length)console.log("No components found"),process.exit(1);W.push(...Q.components)}let b=new Set;if(W.forEach((Q)=>{Q?.components?.forEach((L)=>{b.add({name:L.name,path:L.path})})}),$.stop(),b.size){let Q=Array.from(b).filter((L)=>!i.existsSync(h.posix.join(j,`${Y?.isSrcDir?"src":""}`,L?.path?.replace(/components\//,G.path+"/"))));if(Q?.length)if(G.includeAllComponents)G.baseComponents=Q.map((L)=>L.name);else{let L=await Jy({type:"multiselect",name:"baseComponents",onState:f,message:"Select which base components you want to add",choices:Q.map((D)=>({title:D?.name,value:D?.name,selected:!0})),instructions:!1,hint:"- Space to select. Return to submit"});if(G.baseComponents=L.baseComponents,!Q.length&&!L.baseComponents?.length)$.warn("No components selected")}}if($.start(),G?.baseComponents?.length){let Q=await ky("",G.baseComponents,G.license);if(!Q||!Q?.components.length)console.log("No base components found");else W.push(...Q.components)}$.stop();let q=new Set;for(let Q of W){let L=vy(`Adding ${Q.name}...`).start(),D=Q.files;Q?.dependencies?.forEach((E)=>U.add(E)),Q?.devDependencies?.forEach((E)=>V.add(E));let _=!1;try{for(let{path:E,code:x}of D||[]){let v=h.posix.join(j,cy(E,Y?.paths,Y?.isSrcDir)),F=Y?.framework==="vite"?x.replace(`"use client";
13
13
 
14
- `,""):x,I=fy(F),T=h.dirname(v);if(i.existsSync(v)&&!G.overwrite&&!q.has(v)){if(i.readFileSync(v,"utf-8")!==I)X.add({code:I,path:v}),_=!0}else if(!q.has(v)){let R=T.split(h.sep),M="";for(let J of R)if(M=M?h.join(M,J):J,M&&i.existsSync(M)&&i.statSync(M).isFile())throw Error(`Cannot create directory '${T}' because '${M}' is an existing file.
14
+ `,""):x,I=fy(F),T=h.dirname(v);if(i.existsSync(v)&&!G.overwrite&&!q.has(v)){if(i.readFileSync(v,"utf-8")!==I)X.set(v,{code:I,path:v}),_=!0}else if(!q.has(v)){let R=T.split(h.sep),M="";for(let J of R)if(M=M?h.join(M,J):J,M&&i.existsSync(M)&&i.statSync(M).isFile())throw Error(`Cannot create directory '${T}' because '${M}' is an existing file.
15
15
  Please check your path aliases in components.json and tsconfig.json.`);i.mkdirSync(T,{recursive:!0}),i.writeFileSync(v,I),q.add(v);let H=B.getSourceFile(h.resolve(v));if(H)H.replaceWithText(I);else H=B.addSourceFileAtPath(h.resolve(v));H.getImportDeclarations().forEach((J)=>{let A=J.getModuleSpecifierValue();J.setModuleSpecifier(Ay(A,G.path,Y?.aliases))}),await H.save()}}if(_)L.warn(`Some files of ${C.yellow(Q.name)} already exist`);else L.succeed(`${C.green(Q.name)} is added successfully`)}catch(E){L.fail(`
16
16
  Failed to add the component ${C.red(Q.name)}`),console.error(C.red(E)),process.exit(1)}}if(X.size&&!G?.overwrite){console.log(`
17
17
  Following files already exist in the directory.`),X.forEach((L)=>{console.log(C.green(`- ${h.relative(j,L.path)}`))});let Q=!1;if(G.yes)Q=!0;else{let L=await Jy({type:"confirm",name:"overwrite",message:"Do you want to overwrite the existing files?",initial:!0});if(L.overwrite===void 0)console.log(`
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "untitledui",
3
- "version": "0.1.57",
3
+ "version": "0.1.58",
4
4
  "main": "dist/index.mjs",
5
5
  "description": "The Untitled UI CLI tool helps you quickly scaffold projects with Untitled UI React and add components and page examples to your existing projects with an interactive interface in seconds.",
6
6
  "type": "module",