untitledui 0.1.10 → 0.1.12

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.
@@ -12,7 +12,7 @@
12
12
  --tw-prose-captions: var(--color-text-tertiary);
13
13
  /* --tw-prose-kbd: color.gray[900]; */
14
14
  /* --tw-prose-kbd-shadows: hexToRgb(color.gray[900]); */
15
- --tw-prose-code: var(--color-text-primary);
15
+ --tw-prose-code: var(--color-text-tertiary);
16
16
  --tw-prose-pre-code: var(--color-text-tertiary);
17
17
  --tw-prose-pre-bg: var(--color-bg-primary);
18
18
  --tw-prose-th-borders: var(--color-border-primary);
@@ -235,9 +235,11 @@
235
235
 
236
236
  /* Inline code element */
237
237
  &:where(code:not(pre code)) {
238
- font-weight: 600;
238
+ font-size: 0.875rem;
239
+ line-height: 1.25rem;
240
+ font-weight: 700;
239
241
  border-radius: 6px;
240
- padding: 4px 8px;
242
+ padding: 2px 6px;
241
243
  margin: -2px 0px;
242
244
  background: var(--color-bg-secondary);
243
245
  box-shadow: 0 0 0 1px var(--color-border-secondary);
@@ -409,9 +411,11 @@
409
411
 
410
412
  /* Inline code element */
411
413
  &:where(code:not(pre code)) {
412
- font-weight: 600;
414
+ font-size: 0.875rem;
415
+ line-height: 1.25rem;
416
+ font-weight: 700;
413
417
  border-radius: 6px;
414
- padding: 4px 8px;
418
+ padding: 2px 6px;
415
419
  margin: -2px 0px;
416
420
  background: var(--color-bg-secondary);
417
421
  box-shadow: 0 0 0 1px var(--color-border-secondary);
package/dist/index.mjs CHANGED
@@ -1,17 +1,19 @@
1
1
  #!/usr/bin/env node
2
- import{Command as d1}from"commander";import P0 from"async-retry";import N from"chalk";import{Command as W1,Option as Y1}from"commander";import{execa as B0}from"execa";import*as y from"fs";import Q0 from"ora";import Z1 from"os";import*as u from"path";import q0 from"prompts";import{Project as $1}from"ts-morph";import s0 from"node-fetch";import{Readable as c1,pipeline as n0}from"stream";import{x as a1}from"tar";import{promisify as r0}from"util";var n1=r0(n0);async function r(W){let z=`https://untitledui-docs.vercel.app/api/validate-key?key=${W}`;try{return(await s0(z)).status===200}catch{return!1}}import i0 from"node-fetch";async function H0(W,z,Q){try{return await(await i0("https://untitledui-docs.vercel.app/api/components",{method:"POST",headers:{"Content-Type":"application/json",Accept:"application/json"},body:JSON.stringify({type:W,components:z,key:Q})})).json()}catch(Z){return console.error(Z),null}}import S0 from"node-fetch";async function C0(W,z=""){let Q=`https://untitledui-docs.vercel.app/api/components/list?key=${z}&type=${W}`;try{let Z=await(await S0(Q)).json();if(!Z?.components?.length)return null;return Z}catch(X){return console.error(X),null}}async function x0(W=""){let z=`https://untitledui-docs.vercel.app/api/components/list?key=${W}`;try{let X=await(await S0(z)).json();if(!X?.types?.length)return null;return X}catch(Q){return console.error(Q),null}}import z1 from"fast-glob";import*as v0 from"path";import{Project as q3}from"ts-morph";import{loadConfig as Q1}from"tsconfig-paths";import z3 from"prettier";import X0 from"fast-glob";import*as Z0 from"fs";import*as $0 from"path";import{loadConfig as p0}from"tsconfig-paths";var h=["**/node_modules/**",".next","public","dist","build"],k0={"next-app":"Next.js (App)","next-pages":"Next.js (Pages)",vite:"Vite",other:"Other"};async function i(W){let z=Z0.existsSync($0.resolve(W,"src")),Q=Z0.existsSync($0.resolve(W,`${z?"src/":""}app`)),[X,Z,U,L]=await Promise.all([X0.glob("**/{next,vite,astro}.config.*|gatsby-config.*",{cwd:W,deep:2,ignore:h}),o0(W),t0(W),e0(W)]),M={framework:"other",isTsx:Z,tailwindFile:U||null,aliasPrefix:L,isSrcDir:z,isUsingAppDir:Q};if(X.find((K)=>K.startsWith("next.config."))?.length)return M.framework=Q?"next-app":"next-pages",M;else if(X.find((K)=>K.startsWith("vite.config."))?.length)return M.framework="vite",M;else if(X?.length||Z0.existsSync($0.resolve(W,"package.json")))return M.framework="other",M;return null}async function o0(W){return(await X0.glob("tsconfig.*",{cwd:W,deep:2,ignore:h})).length>0}async function t0(W){let z=await X0.glob("tailwind.config.*",{cwd:W,deep:2,ignore:h});if(!z.length)return null;return z[0]}async function e0(W){let z=await p0(W);if(z?.resultType==="failed"||!Object.keys(z.paths).length)return null;let Q={};for(let[X,Z]of Object.entries(z.paths)){let U=X.replace(/\/\*$/,"/");if(Z.some((L)=>L.includes("/app/*")))Q.appPrefix=U;else if(Z.some((L)=>L.includes("/components/*")))Q.componentsPrefix=U;else if(Z.some((L)=>L.includes("/utils/*")))Q.utilsPrefix=U;else if(Z.some((L)=>L.includes("/styles/*")))Q.stylesPrefix=U;else if(Z.some((L)=>L.includes("./*")||L.includes("/src/*")))Q.srcPrefix=U}return Q||null}function p(W){let z=Q1(W),Q=z1.sync(["tailwind.config.*","**/globals.css","**/{layout,_app,main}.tsx","package.json"],{cwd:W,deep:4,absolute:!0,onlyFiles:!0,ignore:h}),X={tailwindFile:Q.find((Z)=>Z.includes("tailwind.config.")),cssFile:Q.find((Z)=>Z.includes("globals.css")),layoutFile:Q.find((Z)=>Z.includes("layout")),appFile:Q.find((Z)=>Z.includes("_app")),mainFile:Q.find((Z)=>Z.includes("main")),packageJson:Q.find((Z)=>Z.includes("package.json")),tsConfig:z?.resultType==="success"?z?.configFileAbsolutePath:void 0};if(z.resultType==="failed")throw new Error(`Failed to load tsconfig.json. ${z.message??""}`.trim());return X}function o(W,z,Q={},X=""){if(W.includes("components")){if(Q?.componentsPrefix)return W.replace(/@\/components\//,v0.posix.join(Q?.componentsPrefix,z?z.replace(/components\//,""):"","/"));if(z){let Z=Q?.srcPrefix?v0.posix.join(Q?.srcPrefix,z,"/"):X;return W.replace(/@\/components\//,Z)}}if(W.includes("app")&&Q?.appPrefix)return W.replace(/^@\/app\//,Q?.appPrefix);if(W.includes("utils")&&Q?.utilsPrefix)return W.replace(/^@\/utils\//,Q?.utilsPrefix);if(W.includes("styles")&&Q?.stylesPrefix)return W.replace(/^@\/styles\//,Q?.stylesPrefix);if(Q?.srcPrefix)return W.replace(/^@\//,Q?.srcPrefix);return W}function D(){if("bun/1.2.14 npm/? node/v22.6.0 darwin arm64".startsWith("yarn"))return"yarn";if("bun/1.2.14 npm/? node/v22.6.0 darwin arm64".startsWith("pnpm"))return"pnpm";if("bun/1.2.14 npm/? node/v22.6.0 darwin arm64".startsWith("bun"))return"bun";return"npm"}function c(){switch(D()){case"yarn":return"yarn";case"pnpm":return"pnpx";case"bun":return"bunx";default:return"npx"}}function F0(){switch(D()){case"yarn":return"yarn dev";case"pnpm":return"pnpm dev";case"bun":return"bun dev";default:return"npm run dev"}}var X1=u.join(Z1.homedir(),".untitledui"),l=u.join(X1,"config.json"),B={components:[],path:"",type:void 0,license:""};if(y.existsSync(l)){let W=JSON.parse(y.readFileSync(l,"utf-8"));B.license=W.license}var G0=(W)=>{if(W.aborted)process.stdout.write("\x1B[?25h"),process.stdout.write(`
3
- `),process.exit(1)},O0=new W1().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.").addOption(new Y1("-l, --license <license-key>","Add a license key for adding components.").hideHelp()).option("-t, --type <shared|marketing|shared-assets|application|foundations>","the type of the component to add.").action(async(W,z)=>{if(W)B.components=W;if(z)B.all=z.all,B.dir=z.dir,B.path=z.path,B.overwrite=z.overwrite,B.license=z.license||B.license;try{await B1(B)}catch(Q){console.error(N.red(Q))}});async function B1(W){let z=Q0().start(),Q=u.posix.join(process.cwd(),B.dir||"");if(!y.existsSync(u.resolve(Q,"package.json")))z.warn("This command should be run in a project directory."),process.exit(1);let Z=await i(Q);if(B.license){if(!await r(B.license))z.fail("Invalid license key"),process.exit(1);if(!y.existsSync(l)){let V=u.dirname(l);y.mkdirSync(V,{recursive:!0}),y.writeFileSync(l,JSON.stringify({license:B.license},null,2))}if(JSON.parse(y.readFileSync(l,"utf-8")).license!==B.license)y.writeFileSync(l,JSON.stringify({license:B.license},null,2),"utf-8")}z.stop();let U=[];if(B.components.length){let $=await H0(B.type,B.components,B.license);if($&&$.pro&&$.pro.length>0){if(console.log(),$.pro.length===1){let Y=$.pro[0]?.split("/")[1]||$.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:")),$.pro.forEach((Y)=>{let V=Y?.split("/")[1]||Y;console.log(` • ${N.cyan(V)}`)});console.log(),console.log("To access PRO components:"),console.log(` ${N.green("→")} If you've already purchased: ${N.cyan(`${c()} 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(!$?.components.length)console.log("No components found"),process.exit(1);U.push(...$.components)}if(!B?.type&&!B?.components.length){let $=await x0(B.license);if(!$)console.log("No component types found"),process.exit(1);let Y=await q0({type:"select",name:"type",onState:G0,message:`What type of ${N.cyan("component")} are you adding?`,choices:$?.types.map((V)=>({title:V,value:V}))});B.type=Y.type}if(!B?.path){let $=await q0({type:"text",name:"path",onState:G0,message:`Where would you like to add the ${N.cyan("components")}?`,initial:"components"});B.path=$.path}if(!B?.components.length){let $=await C0(B?.type,B.license);if(!$)console.log("No components found"),process.exit(1);let Y=await q0({type:"multiselect",name:"components",onState:G0,message:`Which ${N.cyan("components")} would you like to add?`,choices:$?.components?.map((V)=>({title:V||"example",value:V||"example",selected:B.components.includes(V)})),instructions:!1,hint:"- Space to select. Return to submit"});if(B.components=Y.components,!Y.components||Y.components.length===0)console.log("No option selected. Exiting..."),process.exit(1)}if(!B.components?.length)z.warn("No components selected. Exiting."),process.exit(1);let L=p(Q),M=new Set,K=new Set,R=new Set,C=new $1({tsConfigFilePath:L?.tsConfig});if(B.type&&B.components.length){let $=await H0(B.type,B.components,B.license);if(!$?.components.length)console.log("No components found"),process.exit(1);U.push(...$.components)}if(U.forEach(($)=>{let Y=Q0(`Adding ${$.name}...`).start(),V=$.files;$.dependencies.forEach((J)=>K.add(J)),$.devDependencies.forEach((J)=>R.add(J));try{if(V?.forEach(async({path:J,code:S})=>{let A=u.posix.join(Q,`${Z?.isSrcDir&&"src"}`,J.replace(/components\//,B.path+"/")),x=u.dirname(A);if(y.existsSync(A)&&!B.overwrite){if(y.readFileSync(A,"utf-8")!==S)M.add({code:S,path:A})}else{y.mkdirSync(x,{recursive:!0}),y.writeFileSync(A,S);let k=u.relative(u.resolve(Q,`${Z?.isSrcDir&&"src"}`,B.path),A).split("/").length,I=k===1?"./":"../".repeat(k-1),T=C.addSourceFileAtPath(u.resolve(A));T.getImportDeclarations().forEach((P)=>{let F=P.getModuleSpecifierValue();P.setModuleSpecifier(o(F,B.path,Z?.aliasPrefix,I))}),await T.save()}}),M.size)Y.warn(`Some files of ${N.yellow($.name)} already exist`);else Y.succeed(`${N.green($.name)} is added successfully`)}catch(J){Y.fail(`
4
- Failed to add the component ${N.red($.name)}`),console.error(N.red(J)),process.exit(1)}}),M.size&&!B?.overwrite)if(console.log(`
5
- Following files already exist in the directory.`),M.forEach((Y)=>{console.log(N.green(`- ${u.relative(Q,Y.path)}`))}),(await q0({type:"confirm",name:"overwrite",message:"Do you want to overwrite the existing files?",initial:!0})).overwrite){let Y=Q0("Overwriting files").start();M.forEach((V)=>{let J=u.relative(u.resolve(Q,`${Z?.isSrcDir&&"src"}`,B.path),V.path).split("/").length,S=J===1?"./":"../".repeat(J-1),A=C.addSourceFileAtPath(u.resolve(V.path));A.replaceWithText(V.code),A.getImportDeclarations().forEach((x)=>{let k=x.getModuleSpecifierValue();x.setModuleSpecifier(o(k,B.path,Z?.aliasPrefix,S))}),A.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://untitled.xyz/docs")} for manual installation. The rest of the files are added.`),process.exit(1);let b=D();if(K?.size){let $=Q0("Installing dependencies").start();await P0(()=>B0("sh",["-c",`${B?.dir?`cd ${B?.dir} && `:""}${b} ${b==="npm"?"install":"add"} ${Array.from(K).join(" ")}`]).catch(async(Y)=>{if(Y.message.includes("peer"))$.warn("Dependency conflict detected. Retrying with --legacy-peer-deps..."),$.start("Installing dependencies with --legacy-peer-deps flag"),await B0("sh",["-c",`${B?.dir?`cd ${B?.dir} && `:""}${b} ${b==="npm"?"install":"add"} ${Array.from(K).join(" ")} --legacy-peer-deps`])}),{retries:1}),$.succeed("Dependencies are installed")}if(R?.size){let $=Q0("Installing devDependencies").start();await P0(()=>B0("sh",["-c",`${B?.dir?`cd ${B?.dir} && `:""}${b} ${b==="npm"?"install":"add"} ${Array.from(R).join(" ")}`]).catch(async(Y)=>{if(Y.message.includes("peer"))$.warn("DevDependency conflict detected. Retrying with --legacy-peer-deps..."),$.start("Installing devDependencies with --legacy-peer-deps flag"),await B0("sh",["-c",`${B?.dir?`cd ${B?.dir} && `:""}${b} ${b==="npm"?"install":"add"} ${Array.from(R).join(" ")} --legacy-peer-deps`])}),{retries:1}),$.succeed("DevDependencies are installed")}process.exit(0)}import A0 from"chalk";import{Command as q1}from"commander";import*as f from"fs";import U1 from"http";import V1 from"open";import b1 from"ora";import J1 from"os";import*as R0 from"path";import{URL as K1}from"url";var E0=R0.join(J1.homedir(),".untitledui"),j0=R0.join(E0,"config.json"),g0=new q1().name("login").description("authenticate with Untitled UI to access PRO components").action(async()=>{let W=b1("Starting authentication...").start();try{await L1(W),W.succeed("Authentication completed successfully!"),console.log(A0.green(`
6
- You can now access PRO components with the CLI!`)),process.exit(0)}catch(z){W.fail(`Authentication failed: ${z instanceof Error?z.message:z}`),process.exit(1)}});async function L1(W){return new Promise((z,Q)=>{let X=U1.createServer((Z,U)=>{let L=new K1(Z.url,"http://localhost");if(L.pathname==="/callback"){let M=L.searchParams.get("apiKey"),K=L.searchParams.get("error");if(K){U.writeHead(400,{"Content-Type":"text/html"}),U.end(`
2
+ import{Command as h1}from"commander";import g0 from"async-retry";import N from"chalk";import{Command as Z1,Option as $1}from"commander";import{execa as B0}from"execa";import*as C from"fs";import W0 from"ora";import X1 from"os";import*as T from"path";import U0 from"prompts";import{Project as q1}from"ts-morph";import r0 from"node-fetch";import{Readable as l1,pipeline as i0}from"stream";import{x as a1}from"tar";import{promisify as p0}from"util";var r1=p0(i0);async function r(W){let Q=`https://untitledui-docs.vercel.app/api/validate-key?key=${W}`;try{return(await r0(Q)).status===200}catch{return!1}}import o0 from"node-fetch";async function H0(W,Q,z){try{return await(await o0("https://untitledui-docs.vercel.app/api/components",{method:"POST",headers:{"Content-Type":"application/json",Accept:"application/json"},body:JSON.stringify({type:W,components:Q,key:z})})).json()}catch($){return console.error($),null}}import x0 from"node-fetch";async function k0(W,Q=""){let z=`https://untitledui-docs.vercel.app/api/components/list?key=${Q}&type=${W}`;try{let $=await(await x0(z)).json();if(!$?.components?.length)return null;return $}catch(q){return console.error(q),null}}async function F0(W=""){let Q=`https://untitledui-docs.vercel.app/api/components/list?key=${W}`;try{let q=await(await x0(Q)).json();if(!q?.types?.length)return null;return q}catch(z){return console.error(z),null}}import W1 from"fast-glob";import*as v0 from"path";import{Project as U3}from"ts-morph";import{loadConfig as Y1}from"tsconfig-paths";import Q3 from"prettier";import q0 from"fast-glob";import*as $0 from"fs";import*as X0 from"path";import{loadConfig as t0}from"tsconfig-paths";var d=["**/node_modules/**",".next","public","dist","build"],P0={"next-app":"Next.js (App)","next-pages":"Next.js (Pages)",vite:"Vite",other:"Other"};async function i(W){let Q=$0.existsSync(X0.resolve(W,"src")),z=$0.existsSync(X0.resolve(W,`${Q?"src/":""}app`)),[q,$,U,b]=await Promise.all([q0.glob("**/{next,vite,astro}.config.*|gatsby-config.*",{cwd:W,deep:2,ignore:d}),e0(W),z1(W),Q1(W)]),L={framework:"other",isTsx:$,tailwindFile:U||null,aliasPrefix:b,isSrcDir:Q,isUsingAppDir:z};if(q.find((J)=>J.startsWith("next.config."))?.length)return L.framework=z?"next-app":"next-pages",L;else if(q.find((J)=>J.startsWith("vite.config."))?.length)return L.framework="vite",L;else if(q?.length||$0.existsSync(X0.resolve(W,"package.json")))return L.framework="other",L;return null}async function e0(W){return(await q0.glob("tsconfig.*",{cwd:W,deep:2,ignore:d})).length>0}async function z1(W){let Q=await q0.glob("tailwind.config.*",{cwd:W,deep:2,ignore:d});if(!Q.length)return null;return Q[0]}async function Q1(W){let Q=await t0(W);if(Q?.resultType==="failed"||!Object.keys(Q.paths).length)return null;let z={};for(let[q,$]of Object.entries(Q.paths)){let U=q.replace(/\/\*$/,"/");if($.some((b)=>b.includes("/app/*")))z.appPrefix=U;else if($.some((b)=>b.includes("/components/*")))z.componentsPrefix=U;else if($.some((b)=>b.includes("/utils/*")))z.utilsPrefix=U;else if($.some((b)=>b.includes("/styles/*")))z.stylesPrefix=U;else if($.some((b)=>b.includes("./*")||b.includes("/src/*")))z.srcPrefix=U}return z||null}function p(W){let Q=Y1(W),z=W1.sync(["tailwind.config.*","**/globals.css","**/{layout,_app,main}.tsx","package.json"],{cwd:W,deep:4,absolute:!0,onlyFiles:!0,ignore:d}),q={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 q}function o(W,Q,z={},q=""){if(W.includes("components")){if(z?.componentsPrefix)return W.replace(/@\/components\//,v0.posix.join(z?.componentsPrefix,Q?Q.replace(/components\//,""):"","/"));if(Q){let $=z?.srcPrefix?v0.posix.join(z?.srcPrefix,Q,"/"):q;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 S(){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 t(){switch(S()){case"yarn":return"yarn";case"pnpm":return"pnpx";case"bun":return"bunx";default:return"npx"}}function O0(){switch(S()){case"yarn":return"yarn dev";case"pnpm":return"pnpm dev";case"bun":return"bun dev";default:return"npm run dev"}}var B1=T.join(X1.homedir(),".untitledui"),c=T.join(B1,"config.json"),V={components:[],path:"",type:void 0,license:""};if(C.existsSync(c)){let W=JSON.parse(C.readFileSync(c,"utf-8"));V.license=W.license}var G0=(W)=>{if(W.aborted)process.stdout.write("\x1B[?25h"),process.stdout.write(`
3
+ `),process.exit(1)},d0=new Z1().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.").addOption(new $1("-l, --license <license-key>","Add a license key for adding components.").hideHelp()).option("-t, --type <shared|marketing|shared-assets|application|foundations>","the type of the component to add.").action(async(W,Q)=>{if(W)V.components=W;if(Q)V.all=Q.all,V.dir=Q.dir,V.path=Q.path,V.overwrite=Q.overwrite,V.license=Q.license||V.license;try{await j0(V)}catch(z){console.error(N.red(z))}});async function j0(W){if(W)V={...V,...W};let Q=W0().start(),z=T.posix.join(process.cwd(),V.dir||"");if(!C.existsSync(T.resolve(z,"package.json")))Q.warn("This command should be run in a project directory."),process.exit(1);let $=await i(z);if(V.license){if(!await r(V.license))Q.fail("Invalid license key"),process.exit(1);if(!C.existsSync(c)){let X=T.dirname(c);C.mkdirSync(X,{recursive:!0}),C.writeFileSync(c,JSON.stringify({license:V.license},null,2))}if(JSON.parse(C.readFileSync(c,"utf-8")).license!==V.license)C.writeFileSync(c,JSON.stringify({license:V.license},null,2),"utf-8")}Q.stop();let U=[];if(V.components.length){let Z=await H0(V.type,V.components,V.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 X=Y?.split("/")[1]||Y;console.log(` • ${N.cyan(X)}`)});console.log(),console.log("To access PRO components:"),console.log(` ${N.green("→")} If you've already purchased: ${N.cyan(`${t()} untitledui@latest login`)}`),console.log(` ${N.green("→")} To purchase PRO components: ${N.cyan("https://www.untitledui.com/buy/react")}`),console.log()}if(!Z?.components.length)console.log("No components found"),process.exit(1);U.push(...Z.components)}if(!V?.type&&!V?.components.length){let Z=await F0(V.license);if(!Z)console.log("No component types found"),process.exit(1);let Y=await U0({type:"select",name:"type",onState:G0,message:`What type of ${N.cyan("component")} are you adding?`,choices:Z?.types.map((X)=>({title:X,value:X}))});V.type=Y.type}if(!V?.path){let Z=await U0({type:"text",name:"path",onState:G0,message:`Where would you like to add the ${N.cyan("components")}?`,initial:"components"});V.path=Z.path}if(!V?.components.length){let Z=await k0(V?.type,V.license);if(!Z)console.log("No components found"),process.exit(1);let Y=await U0({type:"multiselect",name:"components",onState:G0,message:`Which ${N.cyan("components")} would you like to add?`,choices:Z?.components?.map((X)=>({title:X||"example",value:X||"example",selected:V.components.includes(X)})),instructions:!1,hint:"- Space to select. Return to submit"});if(V.components=Y.components,!Y.components||Y.components.length===0)console.log("No option selected. Exiting..."),process.exit(1)}if(!V.components?.length)Q.warn("No components selected. Exiting."),process.exit(1);let b=p(z),L=new Set,J=new Set,E=new Set,y=new q1({tsConfigFilePath:b?.tsConfig});if(V.type&&V.components.length){let Z=await H0(V.type,V.components,V.license);if(!Z?.components.length)console.log("No components found"),process.exit(1);U.push(...Z.components)}if(U.forEach((Z)=>{let Y=W0(`Adding ${Z.name}...`).start(),X=Z.files;Z.dependencies.forEach((K)=>J.add(K)),Z.devDependencies.forEach((K)=>E.add(K));try{if(X?.forEach(async({path:K,code:x})=>{let R=T.posix.join(z,`${$?.isSrcDir&&"src"}`,K.replace(/components\//,V.path+"/")),u=($?.framework==="vite"?x.replace(`"use client";
4
+
5
+ `,""):x).replaceAll(/^[ \t]*\/\/\s*(TODO:|collapse-(start|end)).*\r?\n?|[ \t]*{\s*\/\*\s*(TODO:|collapse-(start|end)).*?\*\/\s*}\r?\n?/gm,""),f=T.dirname(R);if(C.existsSync(R)&&!V.overwrite){if(C.readFileSync(R,"utf-8")!==u)L.add({code:u,path:R})}else{C.mkdirSync(f,{recursive:!0}),C.writeFileSync(R,u);let I=T.relative(T.resolve(z,`${$?.isSrcDir&&"src"}`,V.path),R).split("/").length,w=I===1?"./":"../".repeat(I-1),F=y.addSourceFileAtPath(T.resolve(R));F.getImportDeclarations().forEach((P)=>{let Q0=P.getModuleSpecifierValue();P.setModuleSpecifier(o(Q0,V.path,$?.aliasPrefix,w))}),await F.save()}}),L.size)Y.warn(`Some files of ${N.yellow(Z.name)} already exist`);else Y.succeed(`${N.green(Z.name)} is added successfully`)}catch(K){Y.fail(`
6
+ Failed to add the component ${N.red(Z.name)}`),console.error(N.red(K)),process.exit(1)}}),L.size&&!V?.overwrite)if(console.log(`
7
+ Following files already exist in the directory.`),L.forEach((Y)=>{console.log(N.green(`- ${T.relative(z,Y.path)}`))}),(await U0({type:"confirm",name:"overwrite",message:"Do you want to overwrite the existing files?",initial:!0})).overwrite){let Y=W0("Overwriting files").start();L.forEach((X)=>{let K=T.relative(T.resolve(z,`${$?.isSrcDir&&"src"}`,V.path),X.path).split("/").length,x=K===1?"./":"../".repeat(K-1),R=y.addSourceFileAtPath(T.resolve(X.path));R.replaceWithText(X.code),R.getImportDeclarations().forEach((k)=>{let u=k.getModuleSpecifierValue();k.setModuleSpecifier(o(u,V.path,$?.aliasPrefix,x))}),R.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://untitled.xyz/docs")} for manual installation. The rest of the files are added.`),process.exit(1);let j=S();if(J?.size){let Z=W0("Installing component dependencies").start();await g0(()=>B0(j,[j==="npm"?"install":"add",...J],{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(j,[j==="npm"?"install":"add",...J,"--legacy-peer-deps"],{cwd:z})}),{retries:1}),Z.succeed("Component dependencies are installed")}if(E?.size){let Z=W0("Installing component devDependencies").start();await g0(()=>B0(j,[j==="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(j,[j==="npm"?"install":"add","-D",...E,"--legacy-peer-deps"],{cwd:z})}),{retries:1}),Z.succeed("Component devDependencies are installed")}if(V.message)console.log(V.message);process.exit(0)}import E0 from"chalk";import{Command as U1}from"commander";import*as h from"fs";import V1 from"http";import J1 from"open";import K1 from"ora";import b1 from"os";import*as I0 from"path";import{URL as L1}from"url";var R0=I0.join(b1.homedir(),".untitledui"),A0=I0.join(R0,"config.json"),h0=new U1().name("login").description("authenticate with Untitled UI to access PRO components").action(async()=>{let W=K1("Starting authentication...").start();try{await M1(W),W.succeed("Authentication completed successfully!"),console.log(E0.green(`
8
+ ✨ You can now access PRO components with the CLI!`)),process.exit(0)}catch(Q){W.fail(`Authentication failed: ${Q instanceof Error?Q.message:Q}`),process.exit(1)}});async function M1(W){return new Promise((Q,z)=>{let q=V1.createServer(($,U)=>{let b=new L1($.url,"http://localhost");if(b.pathname==="/callback"){let L=b.searchParams.get("apiKey"),J=b.searchParams.get("error");if(J){U.writeHead(400,{"Content-Type":"text/html"}),U.end(`
7
9
  <html>
8
10
  <body style="font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif; text-align: center; padding: 50px;">
9
11
  <h1 style="color: #dc2626;">Authentication Failed</h1>
10
- <p>${decodeURIComponent(K)}</p>
12
+ <p>${decodeURIComponent(J)}</p>
11
13
  <p style="color: #6b7280;">You can close this tab and return to your terminal.</p>
12
14
  </body>
13
15
  </html>
14
- `),X.close(),Q(new Error(decodeURIComponent(K)));return}if(!M){U.writeHead(400,{"Content-Type":"text/html"}),U.end(`
16
+ `),q.close(),z(new Error(decodeURIComponent(J)));return}if(!L){U.writeHead(400,{"Content-Type":"text/html"}),U.end(`
15
17
  <html>
16
18
  <body style="font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif; text-align: center; padding: 50px;">
17
19
  <h1 style="color: #dc2626;">Authentication Failed</h1>
@@ -19,7 +21,7 @@ Following files already exist in the directory.`),M.forEach((Y)=>{console.log(N.
19
21
  <p style="color: #6b7280;">You can close this tab and return to your terminal.</p>
20
22
  </body>
21
23
  </html>
22
- `),X.close(),Q(new Error("No API key received"));return}try{M1(M),U.writeHead(200,{"Content-Type":"text/html"}),U.end(`
24
+ `),q.close(),z(new Error("No API key received"));return}try{H1(L),U.writeHead(200,{"Content-Type":"text/html"}),U.end(`
23
25
  <html>
24
26
  <body style="font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif; text-align: center; padding: 50px;">
25
27
  <h1 style="color: #16a34a;">Authentication Successful!</h1>
@@ -27,7 +29,7 @@ Following files already exist in the directory.`),M.forEach((Y)=>{console.log(N.
27
29
  <p style="color: #6b7280;">You can now close this tab and return to your terminal.</p>
28
30
  </body>
29
31
  </html>
30
- `),X.close(),z()}catch(R){U.writeHead(500,{"Content-Type":"text/html"}),U.end(`
32
+ `),q.close(),Q()}catch(E){U.writeHead(500,{"Content-Type":"text/html"}),U.end(`
31
33
  <html>
32
34
  <body style="font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif; text-align: center; padding: 50px;">
33
35
  <h1 style="color: #dc2626;">Authentication Failed</h1>
@@ -35,24 +37,28 @@ Following files already exist in the directory.`),M.forEach((Y)=>{console.log(N.
35
37
  <p style="color: #6b7280;">You can close this tab and return to your terminal.</p>
36
38
  </body>
37
39
  </html>
38
- `),X.close(),Q(R)}}else U.writeHead(404),U.end("Not found")});X.listen(0,"localhost",()=>{let L=`https://untitledui-docs.vercel.app/api/cli-auth?port=${X.address().port}`;W.text="Opening browser for authentication...",V1(L).catch((M)=>{console.log(A0.yellow(`
39
- Failed to open browser automatically: ${M.message}`)),console.log(A0.cyan(`Please manually open: ${L}
40
- `))}),W.text="Waiting for authentication in browser..."}),setTimeout(()=>{X.close(),Q(new Error("Authentication timeout. Please try again."))},300000)})}function M1(W){if(!f.existsSync(E0))f.mkdirSync(E0,{recursive:!0});let z={};if(f.existsSync(j0))try{z=JSON.parse(f.readFileSync(j0,"utf-8"))}catch{z={}}z.license=W,f.writeFileSync(j0,JSON.stringify(z,null,2),"utf-8")}import D0 from"async-retry";import H from"chalk";import{Command as C1,Option as x1}from"commander";import{execa as W0}from"execa";import*as w from"fs";import Y0 from"ora";import k1 from"os";import*as v from"path";import s from"prompts";import{Project as F1}from"ts-morph";import H1 from"node-fetch";async function U0(W,z){try{let X=await H1("https://untitledui-docs.vercel.app/api/components/example",{method:"POST",headers:{"Content-Type":"application/json",Accept:"application/json"},body:JSON.stringify({example:W,key:z})});if(!X.ok){if(X.status===401||X.status===403)return{type:"error",status:X.status,message:"PRO access required"};return console.error(`API error: ${X.status} - ${X.statusText}`),null}return await X.json()}catch(X){return console.error(X?.message||"Error fetching example data."),null}}import J0 from"async-retry";import E from"chalk";import{Command as I1}from"commander";import{execa as t}from"execa";import K0 from"fast-glob";import _ from"fs";import e from"ora";import _1 from"os";import*as j from"path";import L0 from"prompts";import{Project as N1}from"ts-morph";import{fileURLToPath as u1}from"url";import*as V0 from"fs";import*as d0 from"path";function I0(W,z){let Q=d0.join(W,"package.json");if(!V0.existsSync(Q))return z;let X=JSON.parse(V0.readFileSync(Q,"utf-8")),Z={...X.dependencies,...X.devDependencies},U=[];for(let L of z){let M=Z[L];if(!M){U.push(L);continue}if(L==="tailwindcss"){let K=M.match(/\d+/);if((K?parseInt(K[0],10):0)<4)U.push(L)}}return U}import v1 from"node-fetch";import{posix as f0,sep as G1}from"node:path";import{Readable as j1}from"node:stream";import{pipeline as A1}from"node:stream/promises";import{x as E1}from"tar";var h0=[".DS_Store",".git","node_modules","bun.lockb","yarn.lock","package-lock.json"];async function m0(W,{username:z,repo:Q,branch:X,template:Z}){try{let U=`https://codeload.github.com/${z}/${Q}/tar.gz/${X}`,L=await R1(U);await A1(L,E1({cwd:W,strip:1,filter:(M)=>{let K=M.split(f0.sep)?.pop()||"";if(h0.includes(K))return!1;if(Z)return M.split(G1).join(f0.sep).includes(Z);return!0}}))}catch(U){if(U instanceof Error)throw new Error(`Failed to download or extract repository: ${U.message}`);throw U}}async function R1(W){let z=await v1(W);if(!z.ok)throw new Error(`Failed to download: ${W} - Status: ${z.status} ${z.statusText}`);if(!z.body)throw new Error(`Failed to download: ${W} - No response body`);let Q=z.headers.get("content-type");if(Q&&!Q.includes("application/x-gzip")&&!Q.includes("application/octet-stream"))console.warn(`Warning: Unexpected content type: ${Q}. Expected application/x-gzip or application/octet-stream.`);return j1.from(z.body)}import _0 from"chalk";import*as m from"fs";import*as b0 from"path";function N0(W){if(!m.existsSync(b0.resolve(W)))console.log(_0.red(`Error: CSS file not found at ${W}`)),process.exit(1);let z=m.readFileSync(b0.resolve(W),"utf-8"),Q=/(--color-[a-zA-Z-]+-\d{1,3}):\s*(rgb\([^)]+\))/g,X={},Z;while((Z=Q.exec(z))!==null)if(Z[1]&&Z[2])X[Z[1]]=Z[2];return X}function u0(W,z,Q){let X=b0.resolve(Q);if(!m.existsSync(X)){console.log(_0.red(`Error: CSS file not found at ${X}`));return}let Z=m.readFileSync(X,"utf-8"),U=N0(Q),L={},M={};for(let[R,C]of Object.entries(U))if(R.startsWith(`--color-${W}-`)){let b=R.replace(`--color-${W}-`,"");L[b]=R}else if(R.startsWith(`--color-${z}-`)){let b=R.replace(`--color-${z}-`,"");M[b]=C}let K=!1;for(let[R,C]of Object.entries(L))if(M[R]){let b=M[R],$=new RegExp(`(${C}):\\s*rgb\\([^)]*\\);?`,"g");if($.test(Z))Z=Z.replace($,`$1: ${b};`),K=!0;else console.log(_0.yellow(`No match found for ${C}`))}if(K)m.writeFileSync(X,Z,"utf-8")}var w1=u1(import.meta.url),c0=j.dirname(w1),T1=j.join(_1.homedir(),".untitledui"),a=j.join(T1,"config.json"),D1={"nextjs-starter":"Next.js","vite-starter":"Vite"},y1="vite-starter",S1="nextjs-starter",O="",G={color:"",template:"",framework:void 0};if(_.existsSync(a)){let W=JSON.parse(_.readFileSync(a,"utf-8"));G.license=W.license}var w0=(W)=>{if(W.aborted)process.stdout.write("\x1B[?25h"),process.stdout.write(`
41
- `),process.exit(1)},l0=new I1().name("init").description("initialize a new project or adjust an existing one").argument("[directory]").usage("[directory] [options]").helpOption("-h, --help","Display this help message.").option("--vite","Initialize a Vite project.",!1).option("--next","Initialize a Next.js project.",!1).option("-c, --color <color-name>","Specify a color for the project.").option("-o, --overwrite","Overwrite existing files.",!1).option("-l, --license <license-key>","Add a license key to download the repository.").action(async(W,z)=>{if(W)O=W;if(z){if(G.color=z.color,G.template=z.template,G.overwrite=z.overwrite,G.license=z.license||G.license,G.vite=z.vite,G.next=z.next,z.vite)G.framework=y1;if(z.next)G.framework=S1}try{await T0(z),process.exit(0)}catch(Q){console.error(E.red(Q)),process.exit(1)}});async function T0(W,z=null){let Q=process.cwd(),X=_.existsSync(j.resolve(Q,"package.json")),Z=j.resolve(j.join(c0,"../config/styles","theme.css")),U=N0(Z??""),L=Array.from(new Set(Object.keys(U).map((b)=>b?.split("--color-")?.[1]?.replace(/-\d{1,3}/,"")))),M=e().start(),K=await i(Q);if(G.license){if(!await r(G.license))M.fail("Invalid license key"),process.exit(1);if(!_.existsSync(a)){let Y=j.dirname(a);_.mkdirSync(Y,{recursive:!0}),_.writeFileSync(a,JSON.stringify({license:G.license},null,2))}if(JSON.parse(_.readFileSync(a,"utf-8")).license!==G.license)_.writeFileSync(a,JSON.stringify({license:G.license},null,2))}if(!X){if(M.stop(),!O){let b=await L0({onState:w0,type:"text",name:"path",message:"What is your project named?",initial:"untitled-ui"});if(typeof b.path==="string")O=b.path.trim()}if(z)z.projectPath=O;if(_.existsSync(j.resolve(j.posix.join(Q,O))))M.fail(E.red("Directory already exists!")),process.exit(1);if(G.vite&&G.next||!G.framework){let b=await L0({type:"select",name:"framework",onState:w0,message:`Which ${E.cyan("framework")} would you like to use?`,choices:[{title:E.cyan("Next"),value:"nextjs-starter"},{title:E.yellow("Vite"),value:"vite-starter"}]});G.framework=b.framework}M.succeed("Framework is selected: "+E.green(D1[G.framework]))}else if(K?.framework==="other")M.fail("Unsupported project framework"),console.log(`Please refer to the documentation ${E.cyan("https://untitled.xyz/docs")} for supported frameworks or proceed with manual installation.`),process.exit(1);else if(K?.framework.startsWith("next")||K?.framework.startsWith("vite"))M.succeed(E.yellow(`Detected ${k0[K.framework]} project, proceeding with the setup...`));let R=K0.sync(["**/**/theme.css"],{cwd:Q,absolute:!0,onlyFiles:!0,ignore:h}),C=R?.[0]&&_.readFileSync(R[0],"utf-8").match(/(--color-brand+-\d{1,3}):\s*(rgb\([^)]+\))/g)?.[1]||void 0;if(!G.color&&X&&!C){let b=await L0({type:"select",name:"color",onState:w0,initial:W.color??"",message:`Which ${E.cyan("color")} would you like to use as the ${E.cyanBright("brand")} color?`,choices:L.map(($)=>({title:$,value:$}))});G.color=b.color}if(O&&!X){let b=j.resolve(O);console.log(`
42
- Creating a new project in ${E.blue(O)}`);let $=e("Downloading and extracting the repository...").start();try{_.mkdirSync(b,{recursive:!0}),await J0(()=>m0(b,{branch:"main",username:"a-peak-works",repo:G.framework}),{retries:2}),$.succeed("Files are downloaded and extracted successfully!");let Y=e({text:"Installing dependencies..."}).start(),V=K0.sync(["**/styles/theme.css"],{cwd:b,absolute:!0,onlyFiles:!0})[0];if(u0("brand",G.color||"",V??""),await J0(()=>t("sh",["-c",`cd ${O} && ${D()} install && git init`]).catch(async(J)=>{if(J.message.includes("peer"))Y.warn("Dependency conflict detected. Retrying with --legacy-peer-deps..."),Y.start("Installing dependencies with --legacy-peer-deps flag"),await t("sh",["-c",`cd ${O} && ${D()==="npm"?"npm --legacy-peer-deps":D()} install && git init`])}),{retries:1}),Y.succeed("Dependencies are installed"),!z)console.log(`
40
+ `),q.close(),z(E)}}else U.writeHead(404),U.end("Not found")});q.listen(0,"localhost",()=>{let b=`https://untitledui-docs.vercel.app/api/cli-auth?port=${q.address().port}`;W.text="Opening browser for authentication...",J1(b).catch((L)=>{console.log(E0.yellow(`
41
+ Failed to open browser automatically: ${L.message}`)),console.log(E0.cyan(`Please manually open: ${b}
42
+ `))}),W.text="Waiting for authentication in browser..."}),setTimeout(()=>{q.close(),z(new Error("Authentication timeout. Please try again."))},300000)})}function H1(W){if(!h.existsSync(R0))h.mkdirSync(R0,{recursive:!0});let Q={};if(h.existsSync(A0))try{Q=JSON.parse(h.readFileSync(A0,"utf-8"))}catch{Q={}}Q.license=W,h.writeFileSync(A0,JSON.stringify(Q,null,2),"utf-8")}import w0 from"async-retry";import M from"chalk";import{Command as x1,Option as k1}from"commander";import{execa as M0}from"execa";import*as D from"fs";import Z0 from"ora";import F1 from"os";import*as v from"path";import a from"prompts";import{Project as P1}from"ts-morph";import v1 from"node-fetch";async function V0(W,Q){try{let q=await v1("https://untitledui-docs.vercel.app/api/components/example",{method:"POST",headers:{"Content-Type":"application/json",Accept:"application/json"},body:JSON.stringify({example:W,key:Q})});if(!q.ok){if(q.status===401||q.status===403)return{type:"error",status:q.status,message:"PRO access required"};return console.error(`API error: ${q.status} - ${q.statusText}`),null}return await q.json()}catch(q){return console.error(q?.message||"Error fetching example data."),null}}import Y0 from"async-retry";import A from"chalk";import{Command as _1}from"commander";import{execa as l}from"execa";import b0 from"fast-glob";import _ from"fs";import e from"ora";import N1 from"os";import*as G from"path";import L0 from"prompts";import{Project as u1}from"ts-morph";import{fileURLToPath as T1}from"url";import*as J0 from"fs";import*as f0 from"path";function _0(W,Q){let z=f0.join(W,"package.json");if(!J0.existsSync(z))return Q;let q=JSON.parse(J0.readFileSync(z,"utf-8")),$={...q.dependencies,...q.devDependencies},U=[];for(let b of Q){let L=$[b];if(!L){U.push(b);continue}if(b==="tailwindcss"){let J=L.match(/\d+/);if((J?parseInt(J[0],10):0)<4)U.push(b)}}return U}import G1 from"node-fetch";import{posix as c0,sep as j1}from"node:path";import{Readable as A1}from"node:stream";import{pipeline as E1}from"node:stream/promises";import{x as R1}from"tar";var m0=[".DS_Store",".git","node_modules","bun.lockb","yarn.lock","package-lock.json"];async function l0(W,{username:Q,repo:z,branch:q,template:$}){try{let U=`https://codeload.github.com/${Q}/${z}/tar.gz/${q}`,b=await I1(U);await E1(b,R1({cwd:W,strip:1,filter:(L)=>{let J=L.split(c0.sep)?.pop()||"";if(m0.includes(J))return!1;if($)return L.split(j1).join(c0.sep).includes($);return!0}}))}catch(U){if(U instanceof Error)throw new Error(`Failed to download or extract repository: ${U.message}`);throw U}}async function I1(W){let Q=await G1(W);if(!Q.ok)throw new Error(`Failed to download: ${W} - Status: ${Q.status} ${Q.statusText}`);if(!Q.body)throw new Error(`Failed to download: ${W} - No response body`);let z=Q.headers.get("content-type");if(z&&!z.includes("application/x-gzip")&&!z.includes("application/octet-stream"))console.warn(`Warning: Unexpected content type: ${z}. Expected application/x-gzip or application/octet-stream.`);return A1.from(Q.body)}import N0 from"chalk";import*as m from"fs";import*as K0 from"path";function u0(W){if(!m.existsSync(K0.resolve(W)))console.log(N0.red(`Error: CSS file not found at ${W}`)),process.exit(1);let Q=m.readFileSync(K0.resolve(W),"utf-8"),z=/(--color-[a-zA-Z-]+-\d{1,3}):\s*(rgb\([^)]+\))/g,q={},$;while(($=z.exec(Q))!==null)if($[1]&&$[2])q[$[1]]=$[2];return q}function T0(W,Q,z){let q=K0.resolve(z);if(!m.existsSync(q)){console.log(N0.red(`Error: CSS file not found at ${q}`));return}let $=m.readFileSync(q,"utf-8"),U=u0(z),b={},L={};for(let[E,y]of Object.entries(U))if(E.startsWith(`--color-${W}-`)){let j=E.replace(`--color-${W}-`,"");b[j]=E}else if(E.startsWith(`--color-${Q}-`)){let j=E.replace(`--color-${Q}-`,"");L[j]=y}let J=!1;for(let[E,y]of Object.entries(b))if(L[E]){let j=L[E],Z=new RegExp(`(${y}):\\s*rgb\\([^)]*\\);?`,"g");if(Z.test($))$=$.replace(Z,`$1: ${j};`),J=!0;else console.log(N0.yellow(`No match found for ${y}`))}if(J)m.writeFileSync(q,$,"utf-8")}var D1=T1(import.meta.url),s0=G.dirname(D1),y1=G.join(N1.homedir(),".untitledui"),s=G.join(y1,"config.json"),w1={"nextjs-starter":"Next.js","vite-starter":"Vite"},S1="vite-starter",C1="nextjs-starter",g="",H={color:"",template:"",framework:void 0};if(_.existsSync(s)){let W=JSON.parse(_.readFileSync(s,"utf-8"));H.license=W.license}var D0=(W)=>{if(W.aborted)process.stdout.write("\x1B[?25h"),process.stdout.write(`
43
+ `),process.exit(1)},a0=new _1().name("init").description("initialize a new project or adjust an existing one").argument("[directory]").usage("[directory] [options]").helpOption("-h, --help","Display this help message.").option("--vite","Initialize a Vite project.",!1).option("--next","Initialize a Next.js project.",!1).option("-o, --overwrite","Overwrite existing files.",!1).option("--colors-list","Show the colors list.",!1).option("-c, --color <color-name>","Specify a color for the project.").option("-l, --license <license-key>","Add a license key to download the repository.").action(async(W,Q)=>{if(W)g=W;if(Q){if(H.color=Q.color,H.template=Q.template,H.overwrite=Q.overwrite,H.colorsList=Q.colorsList,H.license=Q.license||H.license,H.vite=Q.vite,H.next=Q.next,Q.vite)H.framework=S1;if(Q.next)H.framework=C1}try{await y0(Q),process.exit(0)}catch(z){console.error(A.red(z)),process.exit(1)}});async function y0(W,Q=null){let z=process.cwd(),q=_.existsSync(G.resolve(z,"package.json")),$=G.resolve(G.join(s0,"../config/styles","theme.css")),U=u0($??""),b=Array.from(new Set(Object.keys(U).map((Z)=>Z?.split("--color-")?.[1]?.replace(/-\d{1,3}/,"")))),L=e().start(),J=await i(z),E=q?b0.sync(["**/**/theme.css"],{cwd:z,absolute:!0,onlyFiles:!0,ignore:d}):[],y=E?.[0]&&_.readFileSync(E[0],"utf-8").match(/(--color-brand+-\d{1,3}):\s*(rgb\([^)]+\))/g)?.[1]||void 0;if(H.license){if(!await r(H.license))L.fail("Invalid license key"),process.exit(1);if(!_.existsSync(s)){let X=G.dirname(s);_.mkdirSync(X,{recursive:!0}),_.writeFileSync(s,JSON.stringify({license:H.license},null,2))}if(JSON.parse(_.readFileSync(s,"utf-8")).license!==H.license)_.writeFileSync(s,JSON.stringify({license:H.license},null,2))}if(!q){if(L.stop(),!g){let Z=await L0({onState:D0,type:"text",name:"path",message:"What is your project named?",initial:"untitled-ui"});if(typeof Z.path==="string")g=Z.path.trim()}if(Q)Q.projectPath=g;if(_.existsSync(G.resolve(G.posix.join(z,g))))L.fail(A.red("Directory already exists!")),process.exit(1);if(H.vite&&H.next||!H.framework){let Z=await L0({type:"select",name:"framework",onState:D0,message:`Which ${A.cyan("framework")} would you like to use?`,choices:[{title:A.cyan("Next"),value:"nextjs-starter"},{title:A.yellow("Vite"),value:"vite-starter"}]});H.framework=Z.framework}L.succeed("Framework is selected: "+A.green(w1[H.framework]))}else if(J?.framework==="other")L.fail("Unsupported project framework"),console.log(`Please refer to the documentation ${A.cyan("https://untitled.xyz/docs")} for supported frameworks or proceed with manual installation.`),process.exit(1);else if(J?.framework.startsWith("next")||J?.framework.startsWith("vite"))if(!Q&&!y)L.succeed(A.yellow(`Detected ${P0[J.framework]} project, proceeding with the setup...`));else L.stop();if(H.colorsList||!H.color&&!y){let Z=await L0({type:"select",name:"color",onState:D0,initial:W.color??"",message:`Which ${A.cyan("color")} would you like to use as the ${A.cyanBright("brand")} color?`,choices:b.map((Y)=>({title:Y,value:Y}))});H.color=Z.color}let j=G.posix.join(z,g||"");if(g&&!q){let Z=G.resolve(g);console.log(`
44
+ Creating a new project in ${A.blue(g)}`);let Y=e("Downloading and extracting the repository...").start();try{_.mkdirSync(Z,{recursive:!0}),await Y0(()=>l0(Z,{branch:"main",username:"a-peak-works",repo:H.framework}),{retries:2}),Y.succeed("Files are downloaded and extracted successfully!");let X=e({text:"Installing dependencies..."}).start(),K=b0.sync(["**/styles/theme.css"],{cwd:Z,absolute:!0,onlyFiles:!0})[0];if(T0("brand",H.color||"",K??""),await Y0(()=>l(S(),["install"],{cwd:j}).catch(async(x)=>{if(x.message.includes("peer"))X.warn("Dependency conflict detected. Retrying with --legacy-peer-deps..."),X.start("Installing dependencies with --legacy-peer-deps flag"),await l(S(),["install","--legacy-peer-deps"],{cwd:j})}),{retries:1}),await Y0(()=>l("git",["init"],{cwd:j}),{retries:1}),X.succeed("Dependencies are installed"),!Q)console.log(`
43
45
  Your project is ready, to get started run the following commands:
44
46
 
45
- cd ${E.cyan(O)}
46
- ${E.cyan(F0())}`)}catch(Y){if($.fail(E.red(`
47
- Failed to download and extract the repository`)),Y instanceof Error)console.error(Y.message);else console.error(`
48
- `);_.rmdirSync(b,{recursive:!0}),process.exit(1)}}else{let b=e("Copying files to the project directory").start(),$=new Set,Y=p(Q),V=j.resolve(j.join(c0,"../config")),J=K0.sync(["**"],{cwd:V,onlyFiles:!0,ignore:h}),S=I0(Q,["tailwindcss","tailwindcss-animate","@tailwindcss/typography","tailwindcss-react-aria-components"]),A=I0(Q,["@tailwindcss/postcss","postcss"]);if(J.forEach((I)=>{let T=I.includes("postcss.config"),P=j.resolve(j.posix.join(V),I),F=j.resolve(Q,T?I:`${K?.isSrcDir?"src":""}/${I}`);if(_.existsSync(F)){if(G?.overwrite)_.copyFileSync(P,F);else{let M0=_.readFileSync(F,"utf-8"),d=_.readFileSync(P,"utf-8");if(M0!==d)$.add({targetFile:F,sourceFile:P})}return}_.mkdirSync(j.dirname(F),{recursive:!0}),_.writeFileSync(F,""),_.copyFileSync(P,F)}),!$.size)b.succeed("Files are copied successfully!");if($.size&&!G?.overwrite)if(console.log(`
49
- `),b.fail("Following files already exist in the directory."),$.forEach((T)=>{console.log(`- ${E.green(T.targetFile)}`)}),(await L0({type:"confirm",name:"overwrite",message:"Do you want to overwrite the existing files?",initial:!0})).overwrite){let T=e("Overwriting files").start();$.forEach((P)=>{_.copyFileSync(P.sourceFile,P.targetFile)}),T.succeed("Files are overwritten")}else console.log(`Use ${E.cyan("--overwrite")} or ${E.cyan("-o")} to overwrite existing files, or refer to the documentation ${E.cyan("https://untitled.xyz/docs")} for manual installation. The rest of the files are added.`);if(Y?.tailwindFile)console.log(`
47
+ cd ${A.cyan(g)}
48
+ ${A.cyan(O0())}`)}catch(X){if(Y.fail(A.red(`
49
+ Failed to download and extract the repository`)),X instanceof Error)console.error(X.message);else console.error(`
50
+ `);_.rmdirSync(Z,{recursive:!0}),process.exit(1)}}else{let Z=e(),Y=new Set,X=p(z),K=G.resolve(G.join(s0,"../config")),x=b0.sync(["**"],{cwd:K,onlyFiles:!0,ignore:d}),R=_0(z,["tailwindcss","tailwindcss-animate","@tailwindcss/typography","tailwindcss-react-aria-components"]),k=_0(z,["@tailwindcss/postcss","postcss"]);if(!Q&&!y)Z.start("Copying files to the project directory");if(x.forEach((I)=>{let w=I.includes("postcss.config"),F=G.resolve(G.posix.join(K),I),P=G.resolve(z,w?I:`${J?.isSrcDir?"src":""}/${I}`);if(_.existsSync(P)){if(H?.overwrite)_.copyFileSync(F,P);else{let Q0=_.readFileSync(P,"utf-8"),O=_.readFileSync(F,"utf-8");if(Q0!==O){if(I.endsWith("theme.css")&&y)return;Y.add({targetFile:P,sourceFile:F})}}return}_.mkdirSync(G.dirname(P),{recursive:!0}),_.writeFileSync(P,""),_.copyFileSync(F,P)}),Z.stop(),Y.size&&!H?.overwrite)if(console.log(`
51
+ `),Z.fail("Following files already exist in the directory."),Y.forEach((w)=>{console.log(`- ${A.green(w.targetFile)}`)}),(await L0({type:"confirm",name:"overwrite",message:"Do you want to overwrite the existing files?",initial:!0})).overwrite){let w=e("Overwriting files").start();Y.forEach((F)=>{_.copyFileSync(F.sourceFile,F.targetFile)}),w.succeed("Files are overwritten")}else console.log(`Use ${A.cyan("--overwrite")} or ${A.cyan("-o")} to overwrite existing files, or refer to the documentation ${A.cyan("https://untitled.xyz/docs")} for manual installation. The rest of the files are added.`);if(X?.tailwindFile)console.log(`
50
52
  Tailwind config file exists in the project directory. You can add it to your globals.css as follows:`),console.log(`
51
- ${E.cyan(`@config "../${K?.isSrcDir&&"../"}${j.relative(Q,Y.tailwindFile)}";`)}
52
- `);let x=Y?.layoutFile||Y?.appFile||K?.framework==="vite"&&Y?.mainFile||"";if(!x)console.log(`Import following files to your main file:
53
- `),J.forEach((I)=>{console.log(E.cyan(I))});else{let T=new N1({tsConfigFilePath:j.resolve(Y?.tsConfig||"")}).addSourceFileAtPath(j.resolve(x)),P="globals.css";T.getImportDeclarations().filter((d)=>d.getModuleSpecifierValue().includes("globals.css")).forEach((d)=>d.remove());let F=j.relative(j.resolve(Q,`${K?.isSrcDir&&"src"}`),x).split("/").length,M0=K?.aliasPrefix?.stylesPrefix||K?.aliasPrefix?.srcPrefix||(F===1?"./":"../".repeat(F-1));T.addImportDeclarations(J.filter((d)=>d.includes("globals.css")).map((d)=>({moduleSpecifier:`${M0}${K?.aliasPrefix?.stylesPrefix?d?.split("styles/")[1]:d}`}))),T.saveSync()}let k=K0.sync(["**/styles/theme.css"],{cwd:Q,absolute:!0,onlyFiles:!0,ignore:h});if(!k?.length)return b.fail(`Failed to copy ${E.cyan("theme.css")} file.
54
- Ensure that the ${E.cyan("theme.css")} file exists in the project directory under ${E.yellow("styles/")} folder.`);if(!C&&u0("brand",G.color||"brand",k[0]??""),S.length||A.length){let I=e().start("Installing dependencies");S.length&&await J0(()=>t(D(),[D()==="npm"?"install":"add",...S]).catch(async(T)=>{if(T.message.includes("peer"))I.warn("Dependency conflict detected. Retrying with --legacy-peer-deps..."),I.start("Installing dependencies with --legacy-peer-deps flag"),await t(D(),[D()==="npm"?"install":"add",...S,"--legacy-peer-deps"])}),{retries:1}),A.length&&await J0(()=>t(D(),[D()==="npm"?"install":"add",...A]).catch(async(T)=>{if(T.message.includes("peer"))I.warn("DevDependency conflict detected. Retrying with --legacy-peer-deps..."),I.start("Installing dependencies with --legacy-peer-deps flag"),await t(D(),[D()==="npm"?"install":"add",...A,"--legacy-peer-deps"])}),{retries:1}),I.succeed("Dependencies are installed")}if(b.succeed(E.green("Project setup is completed!")),!z?.projectPath)console.log(`
55
- Your project is ready, you can now start adding components.`)}}var P1=v.join(k1.homedir(),".untitledui"),n=v.join(P1,"config.json"),q={path:"",example:"",license:"",components:[]},g={};if(w.existsSync(n)){let W=JSON.parse(w.readFileSync(n,"utf-8"));q.license=W.license}var z0=(W)=>{if(W.aborted)process.stdout.write("\x1B[?25h"),process.stdout.write(`
56
- `),process.exit(1)},a0=new C1().name("example").description("add an example to the project").argument("[example]","the example to add").option("-o, --overwrite","overwrite existing files.",!1).option("-p, --path <path>","the path to add the component to.").option("-e, --example-path <example-path>","the path to add the example file to.").addOption(new x1("-l, --license <license-key>","Add a license key for adding components.").hideHelp()).action(async(W,z)=>{if(W)q.example=W;if(z)q.path=z.path,q.overwrite=z.overwrite,q.examplePath=z.examplePath,q.license=z.license||q.license;try{await T0(z,g),await O1(q)}catch(Q){console.error(H.red(Q))}});async function O1(W){let z=Y0().start(),Q=v.posix.join(process.cwd(),g?.projectPath||"");if(!w.existsSync(v.posix.join(v.resolve(Q,"package.json"))))z.warn("This command should be run in a project directory."),process.exit(1);let Z=await i(Q);if(q.license){if(!await r(q.license))z.fail("Invalid license key"),process.exit(1);if(!w.existsSync(n)){let J=v.dirname(n);w.mkdirSync(J,{recursive:!0}),w.writeFileSync(n,JSON.stringify({license:q.license},null,2))}if(JSON.parse(w.readFileSync(n,"utf-8")).license!==q.license)w.writeFileSync(n,JSON.stringify({license:q.license},null,2),"utf-8")}if(z.stop(),!q.example){let Y=await s({type:"select",name:"example",onState:z0,message:"Select which type of example you want to add",choices:[{title:"Application",value:"application"},{title:"Marketing",value:"marketing"}]});q.example=Y.example}let U=null;if(q.example){let Y=await U0(q.example,q.license);if(Y?.type==="error"&&(Y.status===401||Y.status===403))console.log(),console.log(H.yellow(`\uD83D\uDD12 The ${H.cyan(q.example)} example requires PRO access.`)),console.log(),console.log("To access PRO examples:"),console.log(` ${H.green("→")} If you've already purchased: ${H.cyan(`${c()} untitledui@latest login`)}`),console.log(` ${H.green("→")} To purchase PRO examples: ${H.cyan("https://www.untitledui.com/buy/react")}`),console.log(),process.exit(1);if(Y?.type==="directory"){let V=await s({type:"select",name:"example",onState:z0,message:`Select a folder or file in "${q.example}"`,choices:Y.results.map((J)=>({title:J,value:J}))});if(!V.example)return;if(q.example=V.example,Y=await U0(V.example,q.license),Y?.type==="error"&&(Y.status===401||Y.status===403))console.log(),console.log(H.yellow(`\uD83D\uDD12 The ${H.cyan(V.example)} example requires PRO access.`)),console.log(),console.log("To access PRO examples:"),console.log(` ${H.green("→")} If you've already purchased: ${H.cyan(`${c()} untitledui@latest login`)}`),console.log(` ${H.green("→")} To purchase PRO examples: ${H.cyan("https://www.untitledui.com/buy/react")}`),console.log(),process.exit(1)}if(Y?.type==="json-files"){let V=await s({type:"select",name:"example",onState:z0,message:`Select a JSON file in "${q.example}"`,choices:Y.results.map((J)=>({title:J,value:`${q.example}/${J}`}))});if(!V.example)return;if(q.example=V.example,Y=await U0(V.example,q.license),Y?.type==="error"&&(Y.status===401||Y.status===403))console.log(),console.log(H.yellow(`\uD83D\uDD12 The ${H.cyan(V.example)} example requires PRO access.`)),console.log(),console.log("To access PRO examples:"),console.log(` ${H.green("→")} If you've already purchased: ${H.cyan(`${c()} untitledui@latest login`)}`),console.log(` ${H.green("→")} To purchase PRO examples: ${H.cyan("https://www.untitledui.com/buy/react")}`),console.log(),process.exit(1)}if(Y?.type==="json-file")U=Y.content}if(!U)z.fail("No example found"),process.exit(1);if(!q?.examplePath){let Y=Z?.isUsingAppDir?"app":"pages",V=Z?.isSrcDir?v.posix.join("src",Y):Y,J=await s({type:"text",name:"examplePath",onState:z0,message:`Where would you like to add the ${H.cyan(q?.example)} example?`,initial:V});q.examplePath=J.examplePath}else if(!w.existsSync(v.posix.join(Q,q.examplePath)))w.mkdirSync(v.posix.join(Q,q.examplePath),{recursive:!0}),console.log(H.green(`Created directory ${q.examplePath}`));if(!q?.path){let Y=await s({type:"text",name:"path",onState:z0,message:`Where would you like to add the ${H.cyan("components")}?`,initial:"components"});q.path=Y.path}let L=U.components.filter((Y)=>!w.existsSync(v.posix.join(Q,`${Z?.isSrcDir&&"src"}`,Y?.path?.replace(/components\//,q.path+"/"))));if(L?.length){let Y=await s({type:"multiselect",name:"components",onState:z0,message:`Select which components you want to add from ${H.cyan(U.name)} example`,choices:L.map((V)=>({title:V?.name,value:V?.name,selected:!0})),instructions:!1,hint:"- Space to select. Return to submit"});if(q.components=Y.components,!L.length&&!Y.components?.length)z.warn("No components selected")}let M=p(Q),K=new Set,R=new F1({tsConfigFilePath:M?.tsConfig}),C=Y0(`Adding ${q?.example}...`).start();try{if(U.files?.forEach(async({path:Y,code:V})=>{let J=v.posix.join(Q,`${Z?.isSrcDir&&"src"}`,Y.replace(/components\//,q.path+"/"));if(Y.includes("examples")){let A=v.basename(Y);J=v.posix.join(Q,q?.examplePath??"",A)}let S=v.dirname(J);if(w.existsSync(J)&&!q.overwrite){if(w.readFileSync(J,"utf-8")!==V)K.add({code:V,path:J})}else{w.mkdirSync(S,{recursive:!0}),w.writeFileSync(J,V);let A=v.relative(v.resolve(Q,`${Z?.isSrcDir&&"src"}`,q.path),J).split("/").length,x=A===1?"./":"../".repeat(A-1),k=R.addSourceFileAtPath(v.resolve(J));k.getImportDeclarations().forEach((I)=>{let T=I.getModuleSpecifierValue();I.setModuleSpecifier(o(T,q.path,Z?.aliasPrefix,x))}),await k.save()}}),K.size)C.warn(`Some files of ${H.yellow(q?.example)} already exist`);else C.succeed(`${H.green(q?.example)} is added successfully`)}catch(Y){C.fail(`
57
- Failed to add the component ${H.red(q?.example)}`),console.error(H.red(Y)),process.exit(1)}if(K.size&&!q?.overwrite)if(console.log(`
58
- Following files already exist in the directory.`),K.forEach((V)=>{console.log(H.green(`- ${v.relative(Q,V.path)}`))}),(await s({type:"confirm",name:"overwrite",message:"Do you want to overwrite the existing files?",initial:!0})).overwrite){let V=Y0("Overwriting files").start();K.forEach((J)=>{let S=v.relative(v.resolve(Q,`${Z?.isSrcDir&&"src"}`,q.path),J.path).split("/").length,A=S===1?"./":"../".repeat(S-1),x=R.addSourceFileAtPath(v.resolve(J.path));x.replaceWithText(J.code),x.getImportDeclarations().forEach((k)=>{let I=k.getModuleSpecifierValue();k.setModuleSpecifier(o(I,q.path,Z?.aliasPrefix,A))}),x.saveSync()}),V.succeed("Files are overwritten")}else console.log(`Use ${H.cyan("--overwrite")} or ${H.cyan("-o")} to overwrite existing files, or refer to the documentation ${H.cyan("https://untitled.xyz/docs")} for manual installation. The rest of the files are added.`),process.exit(1);let b=D();if(U?.dependencies?.length){let Y=Y0("Installing example dependencies").start();await D0(()=>W0("sh",["-c",`${g?.projectPath?`cd ${g?.projectPath} && `:""}${b} ${b==="npm"?"install":"add"} ${Array.from(U.dependencies).join(" ")}`]).catch(async(V)=>{if(V.message.includes("peer"))Y.warn("Dependency conflict detected. Retrying with --legacy-peer-deps..."),Y.start("Installing dependencies with --legacy-peer-deps flag"),await W0("sh",["-c",`${g?.projectPath?`cd ${g?.projectPath} && `:""}${b} ${b==="npm"?"install":"add"} ${Array.from(U.dependencies).join(" ")} --legacy-peer-deps`])}),{retries:1}),Y.succeed("Example dependencies are installed")}if(U?.devDependencies?.length){let Y=Y0("Installing example devDependencies").start();await D0(()=>W0("sh",["-c",`${g?.projectPath?`cd ${g?.projectPath} && `:""}${b} ${b==="npm"?"install":"add"} ${Array.from(U.devDependencies).join(" ")}`]).catch(async(V)=>{if(V.message.includes("peer"))Y.warn("DevDependency conflict detected. Retrying with --legacy-peer-deps..."),Y.start("Installing devDependencies with --legacy-peer-deps flag"),await W0("sh",["-c",`${g?.projectPath?`cd ${g?.projectPath} && `:""}${b} ${b==="npm"?"install":"add"} ${Array.from(U.devDependencies).join(" ")} --legacy-peer-deps`])}),{retries:1}),Y.succeed("Example devDependencies are installed")}let $=c();if(q?.components?.length)await D0(()=>W0($,["untitledui@latest","add",...q.components,"--path",q.path,"--dir",g?.projectPath||""],{stdio:"inherit"}),{retries:1});process.exit(0)}var y0={name:"untitledui",version:"0.1.10",main:"dist/index.mjs",description:"Untitled UI CLI",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/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://untitledui-docs.vercel.app/api","publish:npm":"bun run build && npm publish --access public",start:"node dist/index.mjs"},repository:{type:"git",url:"https://github.com/a-peak-works/untitledui-tailwind.git"},bugs:{url:"https://github.com/a-peak-works/untitledui-tailwind/issues"},homepage:"https://github.com/a-peak-works/untitledui-tailwind#readme",keywords:["untitled-ui","cli","tailwindcss","nextjs"],files:["dist","config"],author:"",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 h1(){let W=new d1().name(y0.name).version(y0.version);W.addCommand(l0).addCommand(O0).addCommand(a0).addCommand(g0),W.parse()}h1();
53
+ ${A.cyan(`@config "../${J?.isSrcDir&&"../"}${G.relative(z,X.tailwindFile)}";`)}
54
+ `);let u=X?.layoutFile||X?.appFile||J?.framework==="vite"&&X?.mainFile||"";if(!u)console.log(`Import following files to your main file:
55
+ `),x.forEach((I)=>{console.log(A.cyan(I))});else{let w=new u1({tsConfigFilePath:G.resolve(X?.tsConfig||"")}).addSourceFileAtPath(G.resolve(u)),F="globals.css";w.getImportDeclarations().filter((O)=>O.getModuleSpecifierValue().includes("globals.css")).forEach((O)=>O.remove());let P=G.relative(G.resolve(z,`${J?.isSrcDir&&"src"}`),u).split("/").length,Q0=J?.aliasPrefix?.stylesPrefix||J?.aliasPrefix?.srcPrefix||(P===1?"./":"../".repeat(P-1));w.addImportDeclarations(x.filter((O)=>O.includes("globals.css")).map((O)=>({moduleSpecifier:`${Q0}${J?.aliasPrefix?.stylesPrefix?O?.split("styles/")[1]:O}`}))),w.saveSync()}let f=b0.sync(["**/styles/theme.css"],{cwd:z,absolute:!0,onlyFiles:!0,ignore:d});if(!f?.length)return Z.fail(`Failed to copy ${A.cyan("theme.css")} file.
56
+ Ensure that the ${A.cyan("theme.css")} file exists in the project directory under ${A.yellow("styles/")} folder.`);if((H.color||!y)&&T0("brand",H.color||"brand",f[0]??""),R.length||k.length){let I=e().start("Installing dependencies");R.length&&await Y0(()=>l(S(),[S()==="npm"?"install":"add",...R],{cwd:j}).catch(async(w)=>{if(w.message.includes("peer"))I.warn("Dependency conflict detected. Retrying with --legacy-peer-deps..."),I.start("Installing dependencies with --legacy-peer-deps flag"),await l(S(),[S()==="npm"?"install":"add",...R,"--legacy-peer-deps"],{cwd:j})}),{retries:1}),k.length&&await Y0(()=>l(S(),[S()==="npm"?"install":"add","-D",...k],{cwd:j}).catch(async(w)=>{if(w.message.includes("peer"))I.warn("DevDependency conflict detected. Retrying with --legacy-peer-deps..."),I.start("Installing dependencies with --legacy-peer-deps flag"),await l(S(),[S()==="npm"?"install":"add","-D",...k,"--legacy-peer-deps"],{cwd:j})}),{retries:1}),I.succeed("Dependencies are installed")}if(!Q&&!y)Z.succeed(A.green("Project setup is completed!"));if(Q&&q)return;else console.log(`
57
+ Your project is ready, you can now start adding components.`)}}var O1=v.join(F1.homedir(),".untitledui"),n=v.join(O1,"config.json"),B={path:"",example:"",license:"",components:[]},S0={};if(D.existsSync(n)){let W=JSON.parse(D.readFileSync(n,"utf-8"));B.license=W.license}var z0=(W)=>{if(W.aborted)process.stdout.write("\x1B[?25h"),process.stdout.write(`
58
+ `),process.exit(1)},n0=new x1().name("example").description("add an example to the project").argument("[example]","the example to add").option("-o, --overwrite","overwrite existing files.",!1).option("-p, --path <path>","the path to add the component to.").option("-e, --example-path <example-path>","the path to add the example file to.").addOption(new k1("-l, --license <license-key>","Add a license key for adding components.").hideHelp()).action(async(W,Q)=>{if(W)B.example=W;if(Q)B.path=Q.path,B.overwrite=Q.overwrite,B.examplePath=Q.examplePath,B.license=Q.license||B.license;try{await y0(Q,S0),await g1(B)}catch(z){console.error(M.red(z))}});async function g1(W){let Q=Z0().start(),z=v.posix.join(process.cwd(),S0?.projectPath||"");if(!D.existsSync(v.posix.join(v.resolve(z,"package.json"))))Q.warn("This command should be run in a project directory."),process.exit(1);let $=await i(z);if(B.license){if(!await r(B.license))Q.fail("Invalid license key"),process.exit(1);if(!D.existsSync(n)){let K=v.dirname(n);D.mkdirSync(K,{recursive:!0}),D.writeFileSync(n,JSON.stringify({license:B.license},null,2))}if(JSON.parse(D.readFileSync(n,"utf-8")).license!==B.license)D.writeFileSync(n,JSON.stringify({license:B.license},null,2),"utf-8")}if(Q.stop(),!B.example){let Y=await a({type:"select",name:"example",onState:z0,message:"Select which type of example you want to add",choices:[{title:"Application",value:"application"},{title:"Marketing",value:"marketing"}]});B.example=Y.example}let U=null;if(B.example){let Y=await V0(B.example,B.license);if(Y?.type==="error"&&(Y.status===401||Y.status===403))console.log(),console.log(M.yellow(`\uD83D\uDD12 The ${M.cyan(B.example)} example requires PRO access.`)),console.log(),console.log("To access PRO examples:"),console.log(` ${M.green("→")} If you've already purchased: ${M.cyan(`${t()} untitledui@latest login`)}`),console.log(` ${M.green("→")} To purchase PRO examples: ${M.cyan("https://www.untitledui.com/buy/react")}`),console.log(),process.exit(1);if(Y?.type==="directory"){let X=await a({type:"select",name:"example",onState:z0,message:`Select a folder or file in "${B.example}"`,choices:Y.results.map((K)=>({title:K,value:K}))});if(!X.example)return;if(B.example=X.example,Y=await V0(X.example,B.license),Y?.type==="error"&&(Y.status===401||Y.status===403))console.log(),console.log(M.yellow(`\uD83D\uDD12 The ${M.cyan(X.example)} example requires PRO access.`)),console.log(),console.log("To access PRO examples:"),console.log(` ${M.green("→")} If you've already purchased: ${M.cyan(`${t()} untitledui@latest login`)}`),console.log(` ${M.green("→")} To purchase PRO examples: ${M.cyan("https://www.untitledui.com/buy/react")}`),console.log(),process.exit(1)}if(Y?.type==="json-files"){let X=await a({type:"select",name:"example",onState:z0,message:`Select a JSON file in "${B.example}"`,choices:Y.results.map((K)=>({title:K,value:`${B.example}/${K}`}))});if(!X.example)return;if(B.example=X.example,Y=await V0(X.example,B.license),Y?.type==="error"&&(Y.status===401||Y.status===403))console.log(),console.log(M.yellow(`\uD83D\uDD12 The ${M.cyan(X.example)} example requires PRO access.`)),console.log(),console.log("To access PRO examples:"),console.log(` ${M.green("→")} If you've already purchased: ${M.cyan(`${t()} untitledui@latest login`)}`),console.log(` ${M.green("→")} To purchase PRO examples: ${M.cyan("https://www.untitledui.com/buy/react")}`),console.log(),process.exit(1)}if(Y?.type==="json-file")U=Y.content}if(!U)Q.fail("No example found"),process.exit(1);if(!B?.examplePath){let Y=$?.isUsingAppDir?"app":"pages",X=$?.isSrcDir?v.posix.join("src",Y):Y,K=await a({type:"text",name:"examplePath",onState:z0,message:`Where would you like to add the ${M.cyan(B?.example)} example?`,initial:X});B.examplePath=K.examplePath}else if(!D.existsSync(v.posix.join(z,B.examplePath)))D.mkdirSync(v.posix.join(z,B.examplePath),{recursive:!0}),console.log(M.green(`Created directory ${B.examplePath}`));if(!B?.path){let Y=await a({type:"text",name:"path",onState:z0,message:`Where would you like to add the ${M.cyan("components")}?`,initial:"components"});B.path=Y.path}let b=U.components.filter((Y)=>!D.existsSync(v.posix.join(z,`${$?.isSrcDir&&"src"}`,Y?.path?.replace(/components\//,B.path+"/"))));if(b?.length){let Y=await a({type:"multiselect",name:"components",onState:z0,message:`Select which components you want to add from ${M.cyan(U.name)} example`,choices:b.map((X)=>({title:X?.name,value:X?.name,selected:!0})),instructions:!1,hint:"- Space to select. Return to submit"});if(B.components=Y.components,!b.length&&!Y.components?.length)Q.warn("No components selected")}let L=p(z),J=new Set,E=new P1({tsConfigFilePath:L?.tsConfig}),y=Z0(`Adding ${B?.example}...`).start(),j="";try{if(U.files?.forEach(async({path:Y,code:X})=>{let K=v.posix.join(z,`${$?.isSrcDir&&"src"}`,Y.replace(/components\//,B.path+"/")),R=($?.framework==="vite"?X.replace(`"use client";
59
+
60
+ `,""):X).replaceAll(/^[ \t]*\/\/\s*(TODO:|collapse-(start|end)).*\r?\n?|[ \t]*{\s*\/\*\s*(TODO:|collapse-(start|end)).*?\*\/\s*}\r?\n?/gm,"");if(Y.includes("examples")){let u=v.basename(Y);K=v.posix.join(z,B?.examplePath??"",u),j=v.posix.join(B?.examplePath??"",u)}let k=v.dirname(K);if(D.existsSync(K)&&!B.overwrite){if(D.readFileSync(K,"utf-8")!==R)J.add({code:R,path:K})}else{D.mkdirSync(k,{recursive:!0}),D.writeFileSync(K,R);let u=v.relative(v.resolve(z,`${$?.isSrcDir&&"src"}`,B.path),K).split("/").length,f=u===1?"./":"../".repeat(u-1),I=E.addSourceFileAtPath(v.resolve(K));I.getImportDeclarations().forEach((w)=>{let F=w.getModuleSpecifierValue();w.setModuleSpecifier(o(F,B.path,$?.aliasPrefix,f))}),await I.save()}}),J.size)y.warn(`Some files of ${M.yellow(B?.example)} already exist`);else y.succeed(`${M.green(B?.example)} is added successfully`)}catch(Y){y.fail(`
61
+ Failed to add the component ${M.red(B?.example)}`),console.error(M.red(Y)),process.exit(1)}if(J.size&&!B?.overwrite)if(console.log(`
62
+ Following files already exist in the directory.`),J.forEach((X)=>{console.log(M.green(`- ${v.relative(z,X.path)}`))}),(await a({type:"confirm",name:"overwrite",message:"Do you want to overwrite the existing files?",initial:!0})).overwrite){let X=Z0("Overwriting files").start();J.forEach((K)=>{let x=v.relative(v.resolve(z,`${$?.isSrcDir&&"src"}`,B.path),K.path).split("/").length,R=x===1?"./":"../".repeat(x-1),k=E.addSourceFileAtPath(v.resolve(K.path));k.replaceWithText(K.code),k.getImportDeclarations().forEach((u)=>{let f=u.getModuleSpecifierValue();u.setModuleSpecifier(o(f,B.path,$?.aliasPrefix,R))}),k.saveSync()}),X.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://untitled.xyz/docs")} for manual installation. The rest of the files are added.`),process.exit(1);let Z=S();if(U?.dependencies?.length){let Y=Z0("Installing example dependencies").start();await w0(()=>M0(Z,[Z==="npm"?"install":"add",...U.dependencies],{cwd:z}).catch(async(X)=>{if(X.message.includes("peer"))Y.warn("Dependency conflict detected. Retrying with --legacy-peer-deps..."),Y.start("Installing dependencies with --legacy-peer-deps flag"),await M0(Z,[Z==="npm"?"install":"add",...U.dependencies,"--legacy-peer-deps"],{cwd:z})}),{retries:1}),Y.succeed("Example dependencies are installed")}if(U?.devDependencies?.length){let Y=Z0("Installing example devDependencies").start();await w0(()=>M0(Z,[Z==="npm"?"install":"add","-D",...U.devDependencies],{cwd:z}).catch(async(X)=>{if(X.message.includes("peer"))Y.warn("DevDependency conflict detected. Retrying with --legacy-peer-deps..."),Y.start("Installing devDependencies with --legacy-peer-deps flag"),await M0(Z,[Z==="npm"?"install":"add","-D",...U.devDependencies,"--legacy-peer-deps"],{cwd:z})}),{retries:1}),Y.succeed("Example devDependencies are installed")}if(B?.components?.length)await w0(()=>j0({components:B.components,dir:S0?.projectPath||"",path:B.path,message:`
63
+ \uD83C\uDF89 Example ${M.green(B.example)} has been added to ${M.green(j)}`}),{retries:1});console.log(`
64
+ \uD83C\uDF89 Example ${M.green(B.example)} has been added to ${M.green(j)}`),process.exit(0)}var C0={name:"untitledui",version:"0.1.12",main:"dist/index.mjs",description:"Untitled UI CLI",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/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://untitledui-docs.vercel.app/api","publish:npm":"bun run build && npm publish --access public",start:"node dist/index.mjs"},repository:{type:"git",url:"https://github.com/a-peak-works/untitledui-tailwind.git"},bugs:{url:"https://github.com/a-peak-works/untitledui-tailwind/issues"},homepage:"https://github.com/a-peak-works/untitledui-tailwind#readme",keywords:["untitled-ui","cli","tailwindcss","nextjs"],files:["dist","config"],author:"",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 f1(){let W=new h1().name(C0.name).version(C0.version);W.addCommand(a0).addCommand(d0).addCommand(n0).addCommand(h0),W.parse()}f1();
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "untitledui",
3
- "version": "0.1.10",
3
+ "version": "0.1.12",
4
4
  "main": "dist/index.mjs",
5
5
  "description": "Untitled UI CLI",
6
6
  "type": "module",