untitledui 0.1.41 → 0.1.42

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.
@@ -112,7 +112,7 @@
112
112
  }
113
113
 
114
114
  /* BASE COLOR */
115
- --color-transparent: 255 rgb(255 255 0);
115
+ --color-transparent: rgb(0 0 0 / 0);
116
116
 
117
117
  --color-white: rgb(255 255 255);
118
118
  --color-black: rgb(0 0 0);
package/dist/index.mjs CHANGED
@@ -1,10 +1,10 @@
1
1
  #!/usr/bin/env node
2
- import{Command as p1}from"commander";import o0 from"async-retry";import N from"chalk";import{Command as I1}from"commander";import{execa as b0}from"execa";import*as F from"fs";import Y0 from"ora";import N1 from"os";import*as D from"path";import Z0 from"prompts";import{Project as A1}from"ts-morph";import f0 from"node-fetch";import{Readable as J1,pipeline as K1}from"stream";import{x as U1}from"tar";import{promisify as b1}from"util";var V1=b1(K1);async function m0(W,Q){try{let z=await L1(Q);await V1(z,U1({cwd:W,strip:1}))}catch(z){throw new Error(`Failed to download or extract repository from API: ${z instanceof Error?z.message:z}`)}}async function L1(W){let Q=`https://www.untitledui.com/react/api/download-repo?template=${W.template}`;try{let z=await f0(Q,{method:"GET",headers:{"Content-Type":"application/json",Accept:"application/octet-stream"}});if(z.status===403||z.status===404)throw new Error("Repository not found");if(!z.ok)throw new Error(`Failed to download from API. Status: ${z.status} ${z.statusText}`);if(!z.body)throw new Error("Response body is empty");return J1.from(z.body)}catch(z){throw new Error(`Error downloading tarball: ${z instanceof Error?z.message:z}`)}}async function X0(W){let Q=`https://www.untitledui.com/react/api/validate-key?key=${W}`;try{return(await f0(Q)).status===200}catch{return!1}}import M1 from"node-fetch";var c0={invalid_key:"Invalid key provided",no_components_found:"No components found",no_components_provided:"No components provided"};async function I0(W,Q,z){let $=Q.map((q)=>{if(q.includes("modals/"))if(q.includes("-modal"))return q;else return q+"-modal";return q});try{let q=await M1("https://www.untitledui.com/react/api/components",{method:"POST",headers:{"Content-Type":"application/json",Accept:"application/json"},body:JSON.stringify({type:W,components:$,key:z})});if(!q.ok)console.log(c0?.[q.statusText]||c0.no_components_found),process.exit(1);return await q.json()}catch(q){return null}}import N0 from"node-fetch";var i={invalid_key:"Invalid key provided",no_components_found:"No components found",no_components_provided:"No components provided"};async function l0(W,Q=""){let z=`https://www.untitledui.com/react/api/components/list?key=${Q}&type=${W}`;try{let X=await N0(z),$=await X.json();if(!X.ok)console.log(i?.[X.statusText]||i.no_components_found),process.exit(1);if(!$?.components?.length)return null;return $}catch(X){return console.error(X),null}}async function a0(W,Q="",z){let X=`https://www.untitledui.com/react/api/components/list?key=${Q}&type=${W}&subfolders=${z.join(",")}`;try{let $=await N0(X);if(!$.ok)console.log(i?.[$.statusText]||i.no_components_found),process.exit(1);let q=await $.json();if(!q?.components?.length)return null;return q}catch($){return console.error($),null}}async function s0(W=""){let Q=`https://www.untitledui.com/react/api/components/list?key=${W}`;try{let z=await N0(Q);if(!z.ok)console.log(i?.[z.statusText]||i.no_components_found),process.exit(1);let X=await z.json();if(!X?.types?.length)return null;return X}catch(z){return console.error(z),null}}import r0 from"fast-glob";import*as E0 from"fs";import*as A0 from"path";import{Project as H3}from"ts-morph";import{loadConfig as R1}from"tsconfig-paths";import B3 from"prettier";import K0 from"fast-glob";import*as B0 from"fs";import*as J0 from"path";import{loadConfig as H1}from"tsconfig-paths";var d=["**/node_modules/**",".next","public","dist","build"],n0={"next-app":"Next.js (App)","next-pages":"Next.js (Pages)",vite:"Vite",other:"Other"};async function p(W){let Q=B0.existsSync(J0.resolve(W,"src")),z=B0.existsSync(J0.resolve(W,`${Q?"src/":""}app`)),[X,$,q,L]=await Promise.all([K0.glob("**/{next,vite,astro}.config.*|gatsby-config.*",{cwd:W,deep:2,ignore:d}),j1(W),G1(W),v1(W)]),H={framework:"other",isTsx:$,tailwindFile:q||null,aliasPrefix:L,isSrcDir:Q,isUsingAppDir:z};if(X.find((V)=>V.startsWith("next.config."))?.length)return H.framework=z?"next-app":"next-pages",H;else if(X.find((V)=>V.startsWith("vite.config."))?.length)return H.framework="vite",H;else if(X?.length||B0.existsSync(J0.resolve(W,"package.json")))return H.framework="other",H;return null}async function j1(W){return(await K0.glob("tsconfig.*",{cwd:W,deep:2,ignore:d})).length>0}async function G1(W){let Q=await K0.glob("tailwind.config.*",{cwd:W,deep:2,ignore:d});if(!Q.length)return null;return Q[0]}async function v1(W){let Q=await H1(W);if(Q?.resultType==="failed"||!Object.keys(Q.paths).length)return null;let z={};for(let[X,$]of Object.entries(Q.paths)){let q=X.replace(/\/\*$/,"/");if($.some((L)=>L.includes("/app/*")))z.appPrefix=q;else if($.some((L)=>L.includes("/components/*")))z.componentsPrefix=q;else if($.some((L)=>L.includes("/utils/*")))z.utilsPrefix=q;else if($.some((L)=>L.includes("/styles/*")))z.stylesPrefix=q;else if($.some((L)=>L.includes("./*")||L.includes("/src/*")))z.srcPrefix=q}return z||null}function o(W){let Q=R1(W),z=r0.sync(["tailwind.config.*","**/globals.css","**/{layout,_app,main}.tsx","package.json"],{cwd:W,deep:4,absolute:!0,onlyFiles:!0,ignore:d}),X={tailwindFile:z.find(($)=>$.includes("tailwind.config.")),cssFile:z.find(($)=>$.includes("globals.css")),layoutFile:z.find(($)=>$.includes("layout")),appFile:z.find(($)=>$.includes("_app")),mainFile:z.find(($)=>$.includes("main")),packageJson:z.find(($)=>$.includes("package.json")),tsConfig:Q?.resultType==="success"?Q?.configFileAbsolutePath:void 0};if(Q.resultType==="failed")throw new Error(`Failed to load tsconfig.json. ${Q.message??""}`.trim());return X}function t(W,Q,z={},X=""){if(W.includes("components")){if(z?.componentsPrefix)return W.replace(/@\/components\//,A0.posix.join(z?.componentsPrefix,Q?Q.replace(/components\//,""):"","/"));if(Q){let $=z?.srcPrefix?A0.posix.join(z?.srcPrefix,Q,"/"):X;return W.replace(/@\/components\//,$)}}if(W.includes("app")&&z?.appPrefix)return W.replace(/^@\/app\//,z?.appPrefix);if(W.includes("utils")&&z?.utilsPrefix)return W.replace(/^@\/utils\//,z?.utilsPrefix);if(W.includes("styles")&&z?.stylesPrefix)return W.replace(/^@\/styles\//,z?.stylesPrefix);if(z?.srcPrefix)return W.replace(/^@\//,z?.srcPrefix);return W}function i0(W){let Q=r0.sync(["vite.config.*"],{cwd:W,absolute:!0,onlyFiles:!0,ignore:d})?.[0];if(!Q)return!1;try{let z=E0.readFileSync(Q,"utf-8");return u1(z)}catch{return!1}}function u1(W){let Q=W.replace(/\/\/.*$/gm,"").replace(/\/\*[\s\S]*?\*\//g,"");if(!["tailwindcss","@tailwindcss/vite","tailwind("].some((q)=>Q.includes(q)))return!1;return["plugins:","postcss:","css:"].some((q)=>Q.includes(q))}function C(){if("bun/1.2.18 npm/? node/v24.3.0 darwin arm64".startsWith("yarn"))return"yarn";if("bun/1.2.18 npm/? node/v24.3.0 darwin arm64".startsWith("pnpm"))return"pnpm";if("bun/1.2.18 npm/? node/v24.3.0 darwin arm64".startsWith("bun"))return"bun";return"npm"}function e(){switch(C()){case"yarn":return"yarn";case"pnpm":return"pnpx";case"bun":return"bunx";default:return"npx"}}function p0(){switch(C()){case"yarn":return"yarn dev";case"pnpm":return"pnpm dev";case"bun":return"bun dev";default:return"npm run dev"}}function U0(W){return W.replace(/^[ \t]*\/\/\s*(TODO:|collapse-(start|end)).*\r?\n?|[ \t]*{\s*\/\*\s*(TODO:|collapse-(start|end)).*?\*\/\s*}\r?\n?/gm,"")}var E1=D.join(N1.homedir(),".untitledui"),c=D.join(E1,"config.json"),K={components:[],path:"",type:void 0,license:""};if(F.existsSync(c)){let W=JSON.parse(F.readFileSync(c,"utf-8"));K.license=W.license}var V0=(W)=>{if(W.aborted)process.stdout.write("\x1B[?25h"),process.stdout.write(`
2
+ import{Command as p1}from"commander";import o0 from"async-retry";import N from"chalk";import{Command as I1}from"commander";import{execa as b0}from"execa";import*as F from"fs";import Y0 from"ora";import N1 from"os";import*as D from"path";import Z0 from"prompts";import{Project as A1}from"ts-morph";import f0 from"node-fetch";import{Readable as J1,pipeline as K1}from"stream";import{x as U1}from"tar";import{promisify as b1}from"util";var V1=b1(K1);async function m0(W,Q){try{let z=await L1(Q);await V1(z,U1({cwd:W,strip:1}))}catch(z){throw new Error(`Failed to download or extract repository from API: ${z instanceof Error?z.message:z}`)}}async function L1(W){let Q=`https://www.untitledui.com/react/api/download-repo?template=${W.template}`;try{let z=await f0(Q,{method:"GET",headers:{"Content-Type":"application/json",Accept:"application/octet-stream"}});if(z.status===403||z.status===404)throw new Error("Repository not found");if(!z.ok)throw new Error(`Failed to download from API. Status: ${z.status} ${z.statusText}`);if(!z.body)throw new Error("Response body is empty");return J1.from(z.body)}catch(z){throw new Error(`Error downloading tarball: ${z instanceof Error?z.message:z}`)}}async function X0(W){let Q=`https://www.untitledui.com/react/api/validate-key?key=${W}`;try{return(await f0(Q)).status===200}catch{return!1}}import M1 from"node-fetch";var c0={invalid_key:"Invalid key provided",no_components_found:"No components found",no_components_provided:"No components provided"};async function I0(W,Q,z){let $=Q.map((q)=>{if(q.includes("modals/"))if(q.includes("-modal"))return q;else return q+"-modal";return q});try{let q=await M1("https://www.untitledui.com/react/api/components",{method:"POST",headers:{"Content-Type":"application/json",Accept:"application/json"},body:JSON.stringify({type:W,components:$,key:z})});if(!q.ok)console.log(c0?.[q.statusText]||c0.no_components_found),process.exit(1);return await q.json()}catch(q){return null}}import N0 from"node-fetch";var i={invalid_key:"Invalid key provided",no_components_found:"No components found",no_components_provided:"No components provided"};async function l0(W,Q=""){let z=`https://www.untitledui.com/react/api/components/list?key=${Q}&type=${W}`;try{let X=await N0(z),$=await X.json();if(!X.ok)console.log(i?.[X.statusText]||i.no_components_found),process.exit(1);if(!$?.components?.length)return null;return $}catch(X){return console.error(X),null}}async function a0(W,Q="",z){let X=`https://www.untitledui.com/react/api/components/list?key=${Q}&type=${W}&subfolders=${z.join(",")}`;try{let $=await N0(X);if(!$.ok)console.log(i?.[$.statusText]||i.no_components_found),process.exit(1);let q=await $.json();if(!q?.components?.length)return null;return q}catch($){return console.error($),null}}async function s0(W=""){let Q=`https://www.untitledui.com/react/api/components/list?key=${W}`;try{let z=await N0(Q);if(!z.ok)console.log(i?.[z.statusText]||i.no_components_found),process.exit(1);let X=await z.json();if(!X?.types?.length)return null;return X}catch(z){return console.error(z),null}}import r0 from"fast-glob";import*as E0 from"fs";import*as A0 from"path";import{Project as H3}from"ts-morph";import{loadConfig as R1}from"tsconfig-paths";import B3 from"prettier";import K0 from"fast-glob";import*as B0 from"fs";import*as J0 from"path";import{loadConfig as H1}from"tsconfig-paths";var d=["**/node_modules/**",".next","public","dist","build"],n0={"next-app":"Next.js (App)","next-pages":"Next.js (Pages)",vite:"Vite",other:"Other"};async function p(W){let Q=B0.existsSync(J0.resolve(W,"src")),z=B0.existsSync(J0.resolve(W,`${Q?"src/":""}app`)),[X,$,q,L]=await Promise.all([K0.glob("**/{next,vite,astro}.config.*|gatsby-config.*",{cwd:W,deep:2,ignore:d}),j1(W),G1(W),v1(W)]),H={framework:"other",isTsx:$,tailwindFile:q||null,aliasPrefix:L,isSrcDir:Q,isUsingAppDir:z};if(X.find((V)=>V.startsWith("next.config."))?.length)return H.framework=z?"next-app":"next-pages",H;else if(X.find((V)=>V.startsWith("vite.config."))?.length)return H.framework="vite",H;else if(X?.length||B0.existsSync(J0.resolve(W,"package.json")))return H.framework="other",H;return null}async function j1(W){return(await K0.glob("tsconfig.*",{cwd:W,deep:2,ignore:d})).length>0}async function G1(W){let Q=await K0.glob("tailwind.config.*",{cwd:W,deep:2,ignore:d});if(!Q.length)return null;return Q[0]}async function v1(W){let Q=await H1(W);if(Q?.resultType==="failed"||!Object.keys(Q.paths).length)return null;let z={};for(let[X,$]of Object.entries(Q.paths)){let q=X.replace(/\/\*$/,"/");if($.some((L)=>L.includes("/app/*")))z.appPrefix=q;else if($.some((L)=>L.includes("/components/*")))z.componentsPrefix=q;else if($.some((L)=>L.includes("/utils/*")))z.utilsPrefix=q;else if($.some((L)=>L.includes("/styles/*")))z.stylesPrefix=q;else if($.some((L)=>L.includes("./*")||L.includes("/src/*")))z.srcPrefix=q}return z||null}function o(W){let Q=R1(W),z=r0.sync(["tailwind.config.*","**/globals.css","**/{layout,_app,main}.tsx","package.json"],{cwd:W,deep:4,absolute:!0,onlyFiles:!0,ignore:d}),X={tailwindFile:z.find(($)=>$.includes("tailwind.config.")),cssFile:z.find(($)=>$.includes("globals.css")),layoutFile:z.find(($)=>$.includes("layout")),appFile:z.find(($)=>$.includes("_app")),mainFile:z.find(($)=>$.includes("main")),packageJson:z.find(($)=>$.includes("package.json")),tsConfig:Q?.resultType==="success"?Q?.configFileAbsolutePath:void 0};if(Q.resultType==="failed")throw new Error(`Failed to load tsconfig.json. ${Q.message??""}`.trim());return X}function t(W,Q,z={},X=""){if(W.includes("components")){if(z?.componentsPrefix)return W.replace(/@\/components\//,A0.posix.join(z?.componentsPrefix,Q?Q.replace(/components\//,""):"","/"));if(Q){let $=z?.srcPrefix?A0.posix.join(z?.srcPrefix,Q,"/"):X;return W.replace(/@\/components\//,$)}}if(W.includes("app")&&z?.appPrefix)return W.replace(/^@\/app\//,z?.appPrefix);if(W.includes("utils")&&z?.utilsPrefix)return W.replace(/^@\/utils\//,z?.utilsPrefix);if(W.includes("styles")&&z?.stylesPrefix)return W.replace(/^@\/styles\//,z?.stylesPrefix);if(z?.srcPrefix)return W.replace(/^@\//,z?.srcPrefix);return W}function i0(W){let Q=r0.sync(["vite.config.*"],{cwd:W,absolute:!0,onlyFiles:!0,ignore:d})?.[0];if(!Q)return!1;try{let z=E0.readFileSync(Q,"utf-8");return u1(z)}catch{return!1}}function u1(W){let Q=W.replace(/\/\/.*$/gm,"").replace(/\/\*[\s\S]*?\*\//g,"");if(!["tailwindcss","@tailwindcss/vite","tailwind("].some((q)=>Q.includes(q)))return!1;return["plugins:","postcss:","css:"].some((q)=>Q.includes(q))}function C(){if("bun/1.2.15 npm/? node/v22.6.0 darwin arm64".startsWith("yarn"))return"yarn";if("bun/1.2.15 npm/? node/v22.6.0 darwin arm64".startsWith("pnpm"))return"pnpm";if("bun/1.2.15 npm/? node/v22.6.0 darwin arm64".startsWith("bun"))return"bun";return"npm"}function e(){switch(C()){case"yarn":return"yarn";case"pnpm":return"pnpx";case"bun":return"bunx";default:return"npx"}}function p0(){switch(C()){case"yarn":return"yarn dev";case"pnpm":return"pnpm dev";case"bun":return"bun dev";default:return"npm run dev"}}function U0(W){return W.replace(/^[ \t]*\/\/\s*(TODO:|collapse-(start|end)).*\r?\n?|[ \t]*{\s*\/\*\s*(TODO:|collapse-(start|end)).*?\*\/\s*}\r?\n?/gm,"")}var E1=D.join(N1.homedir(),".untitledui"),c=D.join(E1,"config.json"),K={components:[],path:"",type:void 0,license:""};if(F.existsSync(c)){let W=JSON.parse(F.readFileSync(c,"utf-8"));K.license=W.license}var V0=(W)=>{if(W.aborted)process.stdout.write("\x1B[?25h"),process.stdout.write(`
3
3
  `),process.exit(1)},t0=new I1().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.").action(async(W,Q)=>{if(W)K.components=W;if(Q)K.all=Q.all,K.dir=Q.dir,K.path=Q.path,K.overwrite=Q.overwrite,K.license=Q.license||K.license;try{await y0(K)}catch(z){console.error(N.red(z))}});async function y0(W){if(W)K={...K,...W};let Q=Y0().start(),z=D.posix.join(process.cwd(),K.dir||"");if(!F.existsSync(D.resolve(z,"package.json")))Q.warn("This command should be run in a project directory."),process.exit(1);let $=await p(z);if(K.license){if(!await X0(K.license))Q.fail("Invalid license key"),process.exit(1);if(!F.existsSync(c)){let B=D.dirname(c);F.mkdirSync(B,{recursive:!0}),F.writeFileSync(c,JSON.stringify({license:K.license},null,2))}if(JSON.parse(F.readFileSync(c,"utf-8")).license!==K.license)F.writeFileSync(c,JSON.stringify({license:K.license},null,2),"utf-8")}Q.stop();let q=[];if(K.components.length){let Z=await I0(K.type,K.components,K.license);if(Z&&Z.pro&&Z.pro.length>0){if(console.log(),Z.pro.length===1){let Y=Z.pro[0]?.split("/")[1]||Z.pro[0];console.log(N.yellow(`\uD83D\uDD12 The ${N.cyan(Y)} component requires PRO access.`))}else console.log(N.yellow("\uD83D\uDD12 The following components require PRO access:")),Z.pro.forEach((Y)=>{let B=Y?.split("/")[1]||Y;console.log(` • ${N.cyan(B)}`)});console.log(),console.log("To access PRO components:"),console.log(` ${N.green("→")} If you've already purchased: ${N.cyan(`${e()} untitledui@latest login`)}`),console.log(` ${N.green("→")} To purchase PRO components: ${N.cyan("https://www.untitledui.com/buy/react")}`),console.log(),process.exit(1)}if(!Z?.components.length)console.log("No components found"),process.exit(1);q.push(...Z.components)}if(!K?.type&&!K?.components.length){let Z=await s0(K.license);if(!Z)console.log("No component types found"),process.exit(1);let Y=await Z0({type:"select",name:"type",onState:V0,message:`What type of ${N.cyan("component")} are you adding?`,choices:Z?.types.map((B)=>({title:B,value:B}))});K.type=Y.type}if(!K?.path){let Z=await Z0({type:"text",name:"path",onState:V0,message:`Where would you like to add the ${N.cyan("components")}?`,initial:"components"});K.path=Z.path}if(!K?.components.length){let Z=await l0(K?.type,K.license);if(!Z)console.log("No components found"),process.exit(1);let Y=await Z0({type:"multiselect",name:"components",onState:V0,message:`Which ${N.cyan("components")} would you like to add?`,choices:Z?.components?.map((b)=>({title:b?.name+(b?.count?` (${b?.count} variants)`:"")||"example",value:b||"example",selected:K.components.includes(b.name)})),instructions:!1,hint:"- Space to select. Return to submit"});if(!Y.components||!Y.components.length)console.log("No option selected. Exiting..."),process.exit(1);let B=Y.components.filter((b)=>b?.type==="file").map((b)=>b.name),U=Y.components.filter((b)=>b?.type==="dir").map((b)=>b.name),S=[];if(U.length){let b=await a0(K?.type,K.license,U);if(b&&b.components.length)for(let x of b.components){let[I,O]=Object.entries(x)[0]||[],u=await Z0({type:"select",name:"component",onState:V0,message:`Which ${N.cyan("variant")} from ${N.cyan(I)} would you like to add?`,choices:O?.map((y)=>({title:y?.name.replace(/-modal/g,"")||"example",value:y?.name||"example",selected:K.components.includes(y.name)})),instructions:!1,hint:"- Space to select. Return to submit"});if(!u.component)console.log("No variant selected for "+N.cyan(I));S.push(I+"/"+u.component)}else console.log("No variants found")}K.components=[...S,...B]}if(!K.components?.length)Q.warn("No components selected. Exiting."),process.exit(1);let L=o(z),H=new Set,V=new Set,E=new Set,T=new A1({tsConfigFilePath:L?.tsConfig});if(K.type&&K.components.length){let Z=await I0(K.type,K.components,K.license);if(!Z?.components.length)console.log("No components found"),process.exit(1);q.push(...Z.components)}if(q.forEach((Z)=>{let Y=Y0(`Adding ${Z.name}...`).start(),B=Z.files;Z.dependencies.forEach((U)=>V.add(U)),Z.devDependencies.forEach((U)=>E.add(U));try{if(B?.forEach(async({path:U,code:S})=>{let b=D.posix.join(z,`${$?.isSrcDir?"src":""}`,U.replace(/components\//,K.path+"/")),x=$?.framework==="vite"?S.replace(`"use client";
4
4
 
5
5
  `,""):S,I=U0(x),O=D.dirname(b);if(F.existsSync(b)&&!K.overwrite){if(F.readFileSync(b,"utf-8")!==I)H.add({code:I,path:b})}else{F.mkdirSync(O,{recursive:!0}),F.writeFileSync(b,I);let u=D.relative(D.posix.join(z,`${$?.isSrcDir?"src":""}`),b).split("/").length,y=u===1?"./":"../".repeat(u-1),k=T.addSourceFileAtPath(D.resolve(b));k.getImportDeclarations().forEach((P)=>{let W0=P.getModuleSpecifierValue();P.setModuleSpecifier(t(W0,K.path,$?.aliasPrefix,y))}),await k.save()}}),H.size)Y.warn(`Some files of ${N.yellow(Z.name)} already exist`);else Y.succeed(`${N.green(Z.name)} is added successfully`)}catch(U){Y.fail(`
6
6
  Failed to add the component ${N.red(Z.name)}`),console.error(N.red(U)),process.exit(1)}}),H.size&&!K?.overwrite)if(console.log(`
7
- Following files already exist in the directory.`),H.forEach((Y)=>{console.log(N.green(`- ${D.relative(z,Y.path)}`))}),(await Z0({type:"confirm",name:"overwrite",message:"Do you want to overwrite the existing files?",initial:!0})).overwrite){let Y=Y0("Overwriting files").start();H.forEach((B)=>{let U=D.relative(D.resolve(z,`${$?.isSrcDir?"src":""}`,K.path),B.path).split("/").length,S=U===1?"./":"../".repeat(U-1),b=T.addSourceFileAtPath(D.resolve(B.path));b.replaceWithText(B.code),b.getImportDeclarations().forEach((x)=>{let I=x.getModuleSpecifierValue();x.setModuleSpecifier(t(I,K.path,$?.aliasPrefix,S))}),b.saveSync()}),Y.succeed("Files are overwritten")}else console.log(`Use ${N.cyan("--overwrite")} or ${N.cyan("-o")} to overwrite existing files, or refer to the documentation ${N.cyan("https://www.untitled.com/docs")} for manual installation. The rest of the files are added.`),process.exit(1);let R=C();if(V?.size){let Z=Y0("Installing component dependencies").start();await o0(()=>b0(R,[R==="npm"?"install":"add",...V],{cwd:z}).catch(async(Y)=>{if(Y.message.includes("peer"))Z.warn("Component dependencies conflict detected. Retrying with --legacy-peer-deps..."),Z.start("Installing component dependencies with --legacy-peer-deps flag"),await b0(R,[R==="npm"?"install":"add",...V,"--legacy-peer-deps"],{cwd:z})}),{retries:1}),Z.succeed("Component dependencies are installed")}if(E?.size){let Z=Y0("Installing component devDependencies").start();await o0(()=>b0(R,[R==="npm"?"install":"add","-D",...E],{cwd:z}).catch(async(Y)=>{if(Y.message.includes("peer"))Z.warn("Component devDependencies conflict detected. Retrying with --legacy-peer-deps..."),Z.start("Installing component devDependencies with --legacy-peer-deps flag"),await b0(R,[R==="npm"?"install":"add","-D",...E,"--legacy-peer-deps"],{cwd:z})}),{retries:1}),Z.succeed("Component devDependencies are installed")}if(K.message)console.log(K.message);process.exit(0)}import w0 from"chalk";import{Command as w1}from"commander";import*as f from"fs";import T1 from"http";import S1 from"open";import x1 from"ora";import C1 from"os";import*as S0 from"path";import{URL as F1}from"url";import*as L0 from"fs";import*as l from"path";import{fileURLToPath as y1}from"url";var _1=y1(import.meta.url),_0=l.dirname(_1);function D1(){let W=[l.join(_0,"..","templates","auth-template.html"),l.join(_0,"templates","auth-template.html"),l.join(process.cwd(),"node_modules","untitledui","templates","auth-template.html"),l.join(_0,"..","..","templates","auth-template.html")];for(let Q of W)if(L0.existsSync(Q))return Q;throw new Error("Auth template file not found. Please ensure the CLI package is properly installed.")}function e0(){try{let W=D1();return L0.readFileSync(W,"utf-8")}catch(W){return console.warn("Warning: Using fallback auth template. Some styling may be missing."),`<!doctype html>
7
+ Following files already exist in the directory.`),H.forEach((Y)=>{console.log(N.green(`- ${D.relative(z,Y.path)}`))}),(await Z0({type:"confirm",name:"overwrite",message:"Do you want to overwrite the existing files?",initial:!0})).overwrite){let Y=Y0("Overwriting files").start();H.forEach((B)=>{let U=D.relative(D.resolve(z,`${$?.isSrcDir?"src":""}`,K.path),B.path).split("/").length,S=U===1?"./":"../".repeat(U-1),b=T.addSourceFileAtPath(D.resolve(B.path));b.replaceWithText(B.code),b.getImportDeclarations().forEach((x)=>{let I=x.getModuleSpecifierValue();x.setModuleSpecifier(t(I,K.path,$?.aliasPrefix,S))}),b.saveSync()}),Y.succeed("Files are overwritten")}else console.log(`Use ${N.cyan("--overwrite")} or ${N.cyan("-o")} to overwrite existing files, or refer to the documentation ${N.cyan("https://www.untitled.com/docs")} for manual installation. The rest of the files are added.`);let R=C();if(V?.size){let Z=Y0("Installing component dependencies").start();await o0(()=>b0(R,[R==="npm"?"install":"add",...V],{cwd:z}).catch(async(Y)=>{if(Y.message.includes("peer"))Z.warn("Component dependencies conflict detected. Retrying with --legacy-peer-deps..."),Z.start("Installing component dependencies with --legacy-peer-deps flag"),await b0(R,[R==="npm"?"install":"add",...V,"--legacy-peer-deps"],{cwd:z})}),{retries:1}),Z.succeed("Component dependencies are installed")}if(E?.size){let Z=Y0("Installing component devDependencies").start();await o0(()=>b0(R,[R==="npm"?"install":"add","-D",...E],{cwd:z}).catch(async(Y)=>{if(Y.message.includes("peer"))Z.warn("Component devDependencies conflict detected. Retrying with --legacy-peer-deps..."),Z.start("Installing component devDependencies with --legacy-peer-deps flag"),await b0(R,[R==="npm"?"install":"add","-D",...E,"--legacy-peer-deps"],{cwd:z})}),{retries:1}),Z.succeed("Component devDependencies are installed")}if(K.message)console.log(K.message);process.exit(0)}import w0 from"chalk";import{Command as w1}from"commander";import*as f from"fs";import T1 from"http";import S1 from"open";import x1 from"ora";import C1 from"os";import*as S0 from"path";import{URL as F1}from"url";import*as L0 from"fs";import*as l from"path";import{fileURLToPath as y1}from"url";var _1=y1(import.meta.url),_0=l.dirname(_1);function D1(){let W=[l.join(_0,"..","templates","auth-template.html"),l.join(_0,"templates","auth-template.html"),l.join(process.cwd(),"node_modules","untitledui","templates","auth-template.html"),l.join(_0,"..","..","templates","auth-template.html")];for(let Q of W)if(L0.existsSync(Q))return Q;throw new Error("Auth template file not found. Please ensure the CLI package is properly installed.")}function e0(){try{let W=D1();return L0.readFileSync(W,"utf-8")}catch(W){return console.warn("Warning: Using fallback auth template. Some styling may be missing."),`<!doctype html>
8
8
  <html lang="en">
9
9
  <head>
10
10
  <meta charset="UTF-8" />
@@ -75,6 +75,6 @@ Your project is ready, you can now start adding components.`)}}var n1=G.join(a1.
75
75
 
76
76
  `,""):B,b=U0(S);if(Y.includes("examples")){let I=G.basename(Y);U=G.posix.join(z,J?.examplePath??"",I),R=G.posix.join(J?.examplePath??"",I)}let x=G.dirname(U);if(w.existsSync(U)&&!J.overwrite){if(w.readFileSync(U,"utf-8")!==b)V.add({code:b,path:U})}else{w.mkdirSync(x,{recursive:!0}),w.writeFileSync(U,b);let I=G.relative(G.posix.join(z,`${$?.isSrcDir?"src":""}`),U).split("/").length,O=I===1?"./":"../".repeat(I-1),u=E.addSourceFileAtPath(G.resolve(U));u.getImportDeclarations().forEach((y)=>{let k=y.getModuleSpecifierValue();y.setModuleSpecifier(t(k,J.path,$?.aliasPrefix,O))}),await u.save()}}),V.size)T.warn(`Some files of ${M.yellow(J?.example)} already exist`);else T.succeed(`${M.green(J?.example)} is added successfully`)}catch(Y){T.fail(`
77
77
  Failed to add the component ${M.red(J?.example)}`),console.error(M.red(Y)),process.exit(1)}if(V.size&&!J?.overwrite)if(console.log(`
78
- Following files already exist in the directory.`),V.forEach((B)=>{console.log(M.green(`- ${G.relative(z,B.path)}`))}),(await n({type:"confirm",name:"overwrite",message:"Do you want to overwrite the existing files?",initial:!0})).overwrite){let B=q0("Overwriting files").start();V.forEach((U)=>{let S=G.relative(G.resolve(z,`${$?.isSrcDir?"src":""}`,J.path),U.path).split("/").length,b=S===1?"./":"../".repeat(S-1),x=E.addSourceFileAtPath(G.resolve(U.path));x.replaceWithText(U.code),x.getImportDeclarations().forEach((I)=>{let O=I.getModuleSpecifierValue();I.setModuleSpecifier(t(O,J.path,$?.aliasPrefix,b))}),x.saveSync()}),B.succeed("Files are overwritten")}else console.log(`Use ${M.cyan("--overwrite")} or ${M.cyan("-o")} to overwrite existing files, or refer to the documentation ${M.cyan("https://www.untitled.com/docs")} for manual installation. The rest of the files are added.`),process.exit(1);let Z=C();if(q?.dependencies?.length){let Y=q0("Installing example dependencies").start();await g0(()=>u0(Z,[Z==="npm"?"install":"add",...q.dependencies],{cwd:z}).catch(async(B)=>{if(B.message.includes("peer"))Y.warn("Dependency conflict detected. Retrying with --legacy-peer-deps..."),Y.start("Installing dependencies with --legacy-peer-deps flag"),await u0(Z,[Z==="npm"?"install":"add",...q.dependencies,"--legacy-peer-deps"],{cwd:z})}),{retries:1}),Y.succeed("Example dependencies are installed")}if(q?.devDependencies?.length){let Y=q0("Installing example devDependencies").start();await g0(()=>u0(Z,[Z==="npm"?"install":"add","-D",...q.devDependencies],{cwd:z}).catch(async(B)=>{if(B.message.includes("peer"))Y.warn("DevDependency conflict detected. Retrying with --legacy-peer-deps..."),Y.start("Installing devDependencies with --legacy-peer-deps flag"),await u0(Z,[Z==="npm"?"install":"add","-D",...q.devDependencies,"--legacy-peer-deps"],{cwd:z})}),{retries:1}),Y.succeed("Example devDependencies are installed")}if(J?.components?.length)await g0(()=>y0({components:J.components,dir:d0?.projectPath||"",path:J.path,message:`
78
+ Following files already exist in the directory.`),V.forEach((B)=>{console.log(M.green(`- ${G.relative(z,B.path)}`))}),(await n({type:"confirm",name:"overwrite",message:"Do you want to overwrite the existing files?",initial:!0})).overwrite){let B=q0("Overwriting files").start();V.forEach((U)=>{let S=G.relative(G.resolve(z,`${$?.isSrcDir?"src":""}`,J.path),U.path).split("/").length,b=S===1?"./":"../".repeat(S-1),x=E.addSourceFileAtPath(G.resolve(U.path));x.replaceWithText(U.code),x.getImportDeclarations().forEach((I)=>{let O=I.getModuleSpecifierValue();I.setModuleSpecifier(t(O,J.path,$?.aliasPrefix,b))}),x.saveSync()}),B.succeed("Files are overwritten")}else console.log(`Use ${M.cyan("--overwrite")} or ${M.cyan("-o")} to overwrite existing files, or refer to the documentation ${M.cyan("https://www.untitled.com/docs")} for manual installation. The rest of the files are added.`);let Z=C();if(q?.dependencies?.length){let Y=q0("Installing example dependencies").start();await g0(()=>u0(Z,[Z==="npm"?"install":"add",...q.dependencies],{cwd:z}).catch(async(B)=>{if(B.message.includes("peer"))Y.warn("Dependency conflict detected. Retrying with --legacy-peer-deps..."),Y.start("Installing dependencies with --legacy-peer-deps flag"),await u0(Z,[Z==="npm"?"install":"add",...q.dependencies,"--legacy-peer-deps"],{cwd:z})}),{retries:1}),Y.succeed("Example dependencies are installed")}if(q?.devDependencies?.length){let Y=q0("Installing example devDependencies").start();await g0(()=>u0(Z,[Z==="npm"?"install":"add","-D",...q.devDependencies],{cwd:z}).catch(async(B)=>{if(B.message.includes("peer"))Y.warn("DevDependency conflict detected. Retrying with --legacy-peer-deps..."),Y.start("Installing devDependencies with --legacy-peer-deps flag"),await u0(Z,[Z==="npm"?"install":"add","-D",...q.devDependencies,"--legacy-peer-deps"],{cwd:z})}),{retries:1}),Y.succeed("Example devDependencies are installed")}if(J?.components?.length)await g0(()=>y0({components:J.components,dir:d0?.projectPath||"",path:J.path,message:`
79
79
  \uD83C\uDF89 Example ${M.green(J.example)} has been added to ${M.green(R)}`}),{retries:1});console.log(`
80
80
  \uD83C\uDF89 Example ${M.green(J.example)} has been added to ${M.green(R)}`),process.exit(0)}var h0={name:"untitledui",version:"0.1.41",main:"dist/index.mjs",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.",type:"module",publishConfig:{access:"public"},scripts:{test:'echo "Error: no test specified" && exit 1',dev:"bun build --entrypoints ./index.ts --entry-naming=[name].mjs --outdir=dist --target=node --minify --packages=external --env=inline --define=process.env.API_URL=http://localhost:3000/react/api --watch",build:"bun build --entrypoints ./index.ts --entry-naming=[name].mjs --outdir=dist --target=node --minify --packages=external --env=inline --define=process.env.API_URL=https://www.untitledui.com/react/api","publish:npm":"bun run build && npm publish --access public",start:"node dist/index.mjs"},bugs:{url:"https://github.com/untitleduico/react/issues"},homepage:"https://github.com/untitleduico/react#readme",keywords:["untitledui","untitled-ui","untitledui","untitledui-cli","untitledui-react","untitledui-components","untitledui-examples","untitledui-vite","untitledui-nextjs","cli","tailwindcss","nextjs","react","components","examples","vite"],files:["dist","config","templates","README.md"],author:{name:"Untitled UI",url:"https://www.untitledui.com/react"},contributors:[{name:"Dilshod Turobov",url:"https://x.com/deebovv"},{name:"Jordan Hughes",url:"https://x.com/jordanphughes"}],license:"MIT",bin:{untitledui:"dist/index.mjs"},exports:"./dist/index.mjs",dependencies:{"async-retry":"^1.3.3",chalk:"^5.4.1",commander:"^13.1.0",execa:"^7.0.0","fast-glob":"^3.3.3","node-fetch":"^3.3.2",open:"^10.1.0",ora:"^8.2.0",prettier:"^3.5.3",prompts:"^2.4.2",tar:"^7.4.3","ts-morph":"^25.0.1","tsconfig-paths":"^4.2.0","update-check":"^1.5.4"},devDependencies:{"@types/async-retry":"^1.4.9","@types/prompts":"^2.4.9","@types/tar":"^6.1.13","type-fest":"^4.37.0",typescript:"^5.8.2"}};process.on("SIGINT",()=>process.exit(0));process.on("SIGTERM",()=>process.exit(0));async function o1(){let W=new p1().name(h0.name).version(h0.version);W.addCommand(X1).addCommand(t0).addCommand(B1).addCommand(Q1),W.parse()}o1();
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "untitledui",
3
- "version": "0.1.41",
3
+ "version": "0.1.42",
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",