untitledui 0.1.4 → 0.1.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.mjs +15 -15
- package/package.json +1 -1
package/dist/index.mjs
CHANGED
|
@@ -1,19 +1,19 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
import{Command as $0}from"commander";import
|
|
3
|
-
"paths": ${JSON.stringify(Y.paths)},`);else
|
|
4
|
-
`),process.exit(1)},
|
|
5
|
-
Failed to add component`),console.error(v.red(
|
|
6
|
-
Following files already exist in the directory.`),
|
|
7
|
-
`),process.exit(1)},
|
|
8
|
-
Creating a new project in ${
|
|
2
|
+
import{Command as $0}from"commander";import N3 from"async-retry";import v from"chalk";import{Command as s3}from"commander";import{execa as p}from"execa";import*as E from"fs";import g from"ora";import n3 from"os";import*as u from"path";import h from"prompts";import{Project as a3}from"ts-morph";import V3 from"node-fetch";import{posix as w3,sep as x3}from"path";import{Readable as T3,pipeline as y3}from"stream";import{x as S3}from"tar";import{promisify as C3}from"util";var k3=C3(y3);async function L3(z,W){try{let Q=await F3(W);await k3(Q,S3({cwd:z,strip:2,filter:(Y)=>{return Y.split(x3).join(w3.sep).includes(W.template||"basic-form")}}))}catch(Q){throw new Error(`Failed to download or extract repository from API: ${Q instanceof Error?Q.message:Q}`)}}async function F3(z){try{let Q=await V3("https://untitledui-docs.vercel.app/api/download-repo",{method:"POST",headers:{"Content-Type":"application/json",Accept:"application/octet-stream"},body:JSON.stringify(z)});if(Q.status===403||Q.status===404)throw new Error(z.key?"License key is invalid or expired":"Repository not found");if(!Q.ok)throw new Error(`Failed to download from API. Status: ${Q.status} ${Q.statusText}`);if(!Q.body)throw new Error("Response body is empty");return T3.from(Q.body)}catch(Q){throw new Error(`Error downloading tarball: ${Q instanceof Error?Q.message:Q}`)}}async function P(z){let W=`https://untitledui-docs.vercel.app/api/validate-key?key=${z}`;try{return(await V3(W)).status===200}catch{return!1}}import O3 from"node-fetch";async function z3(z,W,Q){try{return await(await O3("https://untitledui-docs.vercel.app/api/components",{method:"POST",headers:{"Content-Type":"application/json",Accept:"application/json"},body:JSON.stringify({type:z,components:W,key:Q})})).json()}catch(X){return console.error(X),null}}import J3 from"node-fetch";async function M3(z,W=""){let Q=`https://untitledui-docs.vercel.app/api/components/list?key=${W}&type=${z}`;try{let X=await(await J3(Q)).json();if(!X?.components?.length)return null;return X}catch(Y){return console.error(Y),null}}async function G3(z=""){let W=`https://untitledui-docs.vercel.app/api/components/list?key=${z}`;try{let Y=await(await J3(W)).json();if(!Y?.types?.length)return null;return Y}catch(Q){return console.error(Q),null}}import f3 from"fast-glob";import*as I3 from"fs";import*as Q3 from"path";import{Project as l3}from"ts-morph";import{loadConfig as j3}from"tsconfig-paths";import P3 from"prettier";async function H3(z,W="typescript"){try{return await P3.format(z,{parser:W})}catch(Q){return console.error("Error formatting with Prettier:",Q),z}}import r from"fast-glob";import*as l from"fs";import*as c from"path";import{loadConfig as g3}from"tsconfig-paths";var S=["**/node_modules/**",".next","public","dist","build"];async function s(z){let W=l.existsSync(c.resolve(z,"src")),Q=l.existsSync(c.resolve(z,`${W?"src/":""}app`)),[Y,X,V,Z]=await Promise.all([r.glob("**/{next,vite,astro}.config.*|gatsby-config.*",{cwd:z,deep:2,ignore:S}),h3(z),m3(z),d3(z)]),L={framework:"other",isTsx:X,tailwindFile:V||null,aliasPrefix:Z,isSrcDir:W,isUsingAppDir:Q};if(Y.find((B)=>B.startsWith("next.config."))?.length)return L.framework=Q?"next-app":"next-pages",L;else if(Y?.length||l.existsSync(c.resolve(z,"package.json")))return L.framework="other",L;return null}async function h3(z){return(await r.glob("tsconfig.*",{cwd:z,deep:2,ignore:S})).length>0}async function m3(z){let W=await r.glob("tailwind.config.*",{cwd:z,deep:2,ignore:S});if(!W.length)return null;return W[0]}async function d3(z){let W=await g3(z);if(W?.resultType==="failed"||!Object.keys(W.paths).length)return null;let Q={};for(let[Y,X]of Object.entries(W.paths)){let V=Y.replace(/\/\*$/,"/");if(X.some((Z)=>Z.includes("/app/*")))Q.appPrefix=V;else if(X.some((Z)=>Z.includes("/components/*")))Q.componentsPrefix=V;else if(X.some((Z)=>Z.includes("/utils/*")))Q.utilsPrefix=V;else if(X.some((Z)=>Z.includes("/styles/*")))Q.stylesPrefix=V;else if(X.some((Z)=>Z.includes("./*")||Z.includes("/src/*")))Q.srcPrefix=V}return Q||null}function n(z){let W=j3(z),Q=f3.sync(["tailwind.config.*","**/globals.css","**/{layout,_app}.tsx","package.json"],{cwd:z,deep:4,absolute:!0,onlyFiles:!0,ignore:S}),Y={tailwindFile:Q.find((X)=>X.includes("tailwind.config.")),cssFile:Q.find((X)=>X.includes("globals.css")),layoutFile:Q.find((X)=>X.includes("layout")),appFile:Q.find((X)=>X.includes("_app")),packageJson:Q.find((X)=>X.includes("package.json")),tsConfig:W?.resultType==="success"?W?.configFileAbsolutePath:void 0};if(W.resultType==="failed")throw new Error(`Failed to load tsconfig.json. ${W.message??""}`.trim());return Y}function X3(z,W,Q){if(z.includes("components")){if(W?.componentsPrefix)return z.replace(/@\/components\//,Q3.join(W?.componentsPrefix,Q?Q.replace(/components\//,""):"","/"));if(Q)return z.replace(/@\/components\//,Q3.join(W?.srcPrefix||"@/",Q,"/"))}if(z.includes("app")&&W?.appPrefix)return z.replace(/^@\/app\//,W?.appPrefix);if(z.includes("utils")&&W?.utilsPrefix)return z.replace(/^@\/utils\//,W?.utilsPrefix);if(z.includes("styles")&&W?.stylesPrefix)return z.replace(/^@\/styles\//,W?.stylesPrefix);if(W?.srcPrefix)return z.replace(/^@\//,W?.srcPrefix);return z}async function R3(z,W,Q="@/*"){let Y=await j3(z);if(Y?.resultType==="failed")return null;let X={};if(!Object.keys(Y.paths).length){Y.paths={[Q]:[`./${W?"src/":""}*`]},X.srcPrefix=Q.replace(/\/\*$/,"");let V=await I3.promises.readFile(Y.configFileAbsolutePath,"utf-8"),Z;if(!V.includes('"paths":'))Z=V.replace(/"compilerOptions":\s*{/,`"compilerOptions": {
|
|
3
|
+
"paths": ${JSON.stringify(Y.paths)},`);else Z=V.replace(/"paths":\s*{[^}]*}/,`"paths": ${JSON.stringify(Y.paths)}`);let L=new l3,B=await H3(Z,"json");return L.createSourceFile(Y.configFileAbsolutePath,B,{overwrite:!0}),await L.save(),X}return X||null}import c3 from"node-fetch";async function r3(){try{return await(await c3("https://untitledui-docs.vercel.app/api/get-pkg")).json()}catch(W){return console.error(W),null}}async function a({dependencies:z,devDependencies:W,shouldThrow:Q=!0}){let Y=await r3();if(!Y)if(Q)throw new Error("package.json not found");else return null;let X=[],V=[];if(z)z.forEach((Z)=>{if(Y.dependencies?.[Z])X.push(`${Z}@${Y.dependencies[Z]}`)});if(W)W.forEach((Z)=>{if(Y.devDependencies?.[Z])V.push(`${Z}@${Y.devDependencies[Z]}`)});return{dependencies:X,devDependencies:V}}function D(){if("bun/1.2.4 npm/? node/v22.6.0 darwin arm64".startsWith("yarn"))return"yarn";if("bun/1.2.4 npm/? node/v22.6.0 darwin arm64".startsWith("pnpm"))return"pnpm";if("bun/1.2.4 npm/? node/v22.6.0 darwin arm64".startsWith("bun"))return"bun";return"npm"}var p3=u.join(n3.homedir(),".untitledui"),F=u.join(p3,"config.json"),$={components:[],path:"",type:void 0,license:""};if(E.existsSync(F)){let z=JSON.parse(E.readFileSync(F,"utf-8"));$.license=z.license}var i=(z)=>{if(z.aborted)process.stdout.write("\x1B[?25h"),process.stdout.write(`
|
|
4
|
+
`),process.exit(1)},E3=new s3().name("add").description("add a component to your project").argument("[components...]","the components to add").option("-o, --overwrite","overwrite existing files.",!1).option("-a, --all","add all available components",!1).option("-p, --path <path>","the path to add the component to.").option("-t, --type <shared|marketing|shared-assets|application|foundations>","the type of the component to add.").option("-l, --license <license-key>","Add a license key for adding components.").action(async(z,W)=>{if(z)$.components=z;if(W)$.overwrite=W.overwrite,$.all=W.all,$.path=W.path,$.license=W.license||$.license;try{await i3($)}catch(Q){console.error(v.red(Q))}});async function i3(z){let W=g().start(),Q=process.cwd();if(!E.existsSync(u.resolve(Q,"package.json")))W.warn("This command should be run in a project directory."),process.exit(0);let X=await s(Q);if($.license){let q=await P($.license);if(console.log(q,$),!q)W.fail("Invalid license key"),process.exit(0);if(!E.existsSync(F)){let H=u.dirname(F);E.mkdirSync(H,{recursive:!0}),E.writeFileSync(F,JSON.stringify({license:$.license},null,2))}if(JSON.parse(E.readFileSync(F,"utf-8")).license!==$.license)E.writeFileSync(F,JSON.stringify({license:$.license},null,2))}W.stop();let V=[];if($.components.length){let q=await z3($.type,$.components,$.license);if(q?.pro?.length)q?.pro?.forEach((J)=>console.log(`The ${v.yellowBright(J.split("/")[1])} component is only available for PRO users. Get access to the PRO at ${v.cyan("https://www.untitledui.com/buy/untitled-ui")}`)),process.exit(0);if(!q?.components.length)console.log("No components found"),process.exit(0);V.push(...q.components)}if(!$?.type&&!$?.components.length){let q=await G3($.license);if(!q)console.log("No component types found"),process.exit(0);let J=await h({type:"select",name:"type",onState:i,message:`What type of ${v.cyan("component")} are you adding?`,choices:q?.types.map((H)=>({title:H,value:H}))});$.type=J.type}if(!$?.path){let q=await h({type:"text",name:"path",onState:i,message:`Where would you like to add the ${v.cyan("components")}?`,initial:"components"});$.path=q.path}if(X&&!X?.aliasPrefix){let q=/^[^*"]+\/\*\s*$/,J=await h({type:"text",name:"aliasPrefix",onState:i,initial:"@/*",message:`What is the ${v.cyan("import alias")} for your project?`,validate:(H)=>q.test(H)?!0:"Import alias must follow the pattern <prefix>/*"});X.aliasPrefix=await R3(Q,X?.isSrcDir,J?.aliasPrefix)}if(!$?.components.length){let q=await M3($?.type,$.license);if(!q)console.log("No components found"),process.exit(0);let J=await h({type:"multiselect",name:"components",onState:i,message:`Which ${v.cyan("components")} would you like to add?`,choices:q?.components?.map((H)=>({title:H||"example",value:H||"example",selected:$.components.includes(H)})),instructions:!1,hint:"- Space to select. Return to submit"});if($.components=J.components,!J.components||J.components.length===0)console.log("No option selected. Exiting..."),process.exit(0)}if(!$.components?.length)W.warn("No components selected. Exiting."),process.exit(0);let Z=n(Q),L=new Set,B=new Set,b=new Set,M=new a3({tsConfigFilePath:Z?.tsConfig});if($.type&&$.components.length){let q=await z3($.type,$.components,$.license);if(!q?.components.length)console.log("No components found"),process.exit(0);V.push(...q.components)}V.forEach((q)=>{let J=g(`Adding ${q.name}`).start(),H=q.files;q.dependencies.forEach((_)=>B.add(_)),q.devDependencies.forEach((_)=>b.add(_));try{H?.forEach(async({path:_,code:x})=>{let A=u.join(process.cwd(),`${X?.isSrcDir&&"src"}`,_.replace(/components\//,$.path+"/")),f=u.dirname(A);if(E.existsSync(A)&&!$.overwrite){if(E.readFileSync(A,"utf-8")!==x)L.add({code:x,path:A})}else{E.mkdirSync(f,{recursive:!0}),E.writeFileSync(A,x);let G=M.addSourceFileAtPath(u.resolve(A));G.getImportDeclarations().forEach((T)=>{let y=T.getModuleSpecifierValue();T.setModuleSpecifier(X3(y,X?.aliasPrefix,$.path))}),await G.save()}}),J.succeed(`${v.green(q.name)} is added`)}catch(_){J.fail(`
|
|
5
|
+
Failed to add component`),console.error(v.red(_)),process.exit(0)}});let N=await a({dependencies:Array.from(B),devDependencies:Array.from(b),shouldThrow:!0}),j=D();if(N?.dependencies?.length){let q=g("Installing dependencies").start();await N3(()=>p(j,[j==="npm"?"install":"add",...Array.from(N.dependencies)]).catch(async(J)=>{if(J.message.includes("peer"))q.warn("Dependency conflict detected. Retrying with --legacy-peer-deps..."),q.start("Installing dependencies with --legacy-peer-deps flag"),await p(j,[j==="npm"?"install":"add",...Array.from(N.dependencies),"--legacy-peer-deps"])}),{retries:1}),q.succeed("Dependencies are installed")}if(N?.devDependencies?.length){let q=g("Installing devDependencies").start();await N3(()=>p(j,[j==="npm"?"install":"add",...Array.from(N.devDependencies)]).catch(async(J)=>{if(J.message.includes("peer"))q.warn("DevDependency conflict detected. Retrying with --legacy-peer-deps..."),q.start("Installing devDependencies with --legacy-peer-deps flag"),await p(j,[j==="npm"?"install":"add",...Array.from(N.devDependencies),"--legacy-peer-deps"])}),{retries:1}),q.succeed("DevDependencies are installed")}if(L.size&&!$?.overwrite)if(console.log(`
|
|
6
|
+
Following files already exist in the directory.`),L.forEach((J)=>{console.log(v.green(`- ${u.relative(process.cwd(),J.path)}`))}),(await h({type:"confirm",name:"overwrite",message:"Do you want to overwrite the existing files?",initial:!0})).overwrite){let J=g("Overwriting files").start();L.forEach(async(H)=>{E.writeFileSync(H.path,H.code);let _=M.addSourceFileAtPath(u.resolve(H.path));_.getImportDeclarations().forEach((x)=>{let A=x.getModuleSpecifierValue();x.setModuleSpecifier(X3(A,X?.aliasPrefix,$.path))}),await _.save()}),J.succeed("Files are overwritten"),process.exit(1)}else console.log(`Use ${v.cyan("--overwrite")} or ${v.cyan("-o")} to overwrite existing files, or refer to the documentation ${v.cyan("https://untitled.xyz/docs")} for manual installation. The rest of the files are added.`),process.exit(0)}import u3 from"async-retry";import R from"chalk";import{Command as o3}from"commander";import{execa as e}from"execa";import B3 from"fast-glob";import I from"fs";import m from"ora";import t3 from"os";import*as K from"path";import d from"prompts";import{Project as e3}from"ts-morph";import{fileURLToPath as W0}from"url";import o from"fs";import v3 from"path";function Y3(z,W){if(!o.existsSync(W))o.mkdirSync(W,{recursive:!0});let Q=o.readdirSync(z,{withFileTypes:!0});for(let Y of Q){let X=v3.join(z,Y.name),V=v3.join(W,Y.name);if(Y.isDirectory())Y3(X,V);else o.copyFileSync(X,V)}}import Z3 from"chalk";import*as C from"fs";import*as t from"path";function $3(z){if(!C.existsSync(t.resolve(z)))console.log(Z3.red(`Error: CSS file not found at ${z}`)),process.exit(1);let W=C.readFileSync(t.resolve(z),"utf-8"),Q=/(--color-[a-zA-Z-]+-\d{1,3}):\s*(rgb\([^)]+\))/g,Y={},X;while((X=Q.exec(W))!==null)if(X[1]&&X[2])Y[X[1]]=X[2];return Y}function q3(z,W,Q){let Y=t.resolve(Q);if(!C.existsSync(Y)){console.log(Z3.red(`Error: CSS file not found at ${Y}`));return}let X=C.readFileSync(Y,"utf-8"),V=$3(Q),Z={},L={};for(let[b,M]of Object.entries(V))if(b.startsWith(`--color-${z}-`)){let N=b.replace(`--color-${z}-`,"");Z[N]=b}else if(b.startsWith(`--color-${W}-`)){let N=b.replace(`--color-${W}-`,"");L[N]=M}let B=!1;for(let[b,M]of Object.entries(Z))if(L[b]){let N=L[b],j=new RegExp(`(${M}):\\s*rgb\\([^)]*\\);?`,"g");if(j.test(X))X=X.replace(j,`$1: ${N};`),B=!0;else console.log(Z3.yellow(`No match found for ${M}`))}if(B)C.writeFileSync(Y,X,"utf-8")}var z0=W0(import.meta.url),K3=K.dirname(z0),Q0=K.join(t3.homedir(),".untitledui"),O=K.join(Q0,"config.json"),b3="default",X0=["with-stripe","otp","magic-link"],w="",U={template:"",color:""};if(I.existsSync(O)){let z=JSON.parse(I.readFileSync(O,"utf-8"));U.license=z.license}var W3=(z)=>{if(z.aborted)process.stdout.write("\x1B[?25h"),process.stdout.write(`
|
|
7
|
+
`),process.exit(1)},_3=new o3().name("init").description("initialize a new project").argument("[directory]").usage("[directory] [options]").helpOption("-h, --help","Display this help message.").option("-t, --template <starter-kit>","Specify a template for the project.").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(z,W)=>{if(z)w=z;if(W)U.color=W.color,U.template=W.template,U.overwrite=W.overwrite,U.license=W.license||U.license;try{await Y0(W)}catch(Q){console.error(R.red(Q))}});async function Y0(z){let W=process.cwd(),Q=I.existsSync(K.resolve(W,"package.json")),Y=K.resolve(K.join(K3,"../templates/default","src/styles/theme.css")),X=$3(Y??""),V=Array.from(new Set(Object.keys(X).map((B)=>B?.split("--color-")?.[1]?.replace(/-\d{1,3}/,"")))),Z=m().start(),L=await s(W);if(U.license){if(!await P(U.license))Z.fail("Invalid license key"),process.exit(0);if(!I.existsSync(O)){let M=K.dirname(O);I.mkdirSync(M,{recursive:!0}),I.writeFileSync(O,JSON.stringify({license:U.license},null,2))}if(JSON.parse(I.readFileSync(O,"utf-8")).license!==U.license)I.writeFileSync(O,JSON.stringify({license:U.license},null,2))}if(!Q){if(Z.stop(),!w){let B=await d({onState:W3,type:"text",name:"path",message:"What is your project named?",initial:"untitled-ui"});if(typeof B.path==="string")w=B.path.trim()}if(I.existsSync(K.resolve(K.join(W,w))))Z.fail(R.red("Directory already exists!")),process.exit(1);if(!U.template){let B=await d({type:"select",name:"template",onState:W3,message:`Which ${R.cyan("starter kit")} would you like to use?`,choices:[{title:"default-template",value:b3},{title:"basic-form",value:"basic-form"},{title:"magic-link",value:"magic-link"},{title:"next-intl",value:"next-intl"},{title:"otp",value:"otp"},{title:"react-hook-form",value:"react-hook-form"},{title:"with-stripe",value:"with-stripe"}]});if(U.template=B.template,X0.includes(U.template)&&!U.license){let b=await d({type:"text",name:"license",onState:W3,message:`Enter the license key to download the ${R.cyan(U.template)} template:`});if(U.license=b.license,!await P(b.license))Z.fail("Invalid license key"),process.exit(0)}}Z.succeed("Template is selected: "+R.green(U.template))}else if(L?.framework==="other")Z.fail("Unsupported project framework"),console.log(`Please refer to the documentation ${R.cyan("https://untitled.xyz/docs")} for supported frameworks or proceed with manual installation.`),process.exit(1);else Z.succeed(R.yellow("Detected Next.js project, proceeding with the setup..."));if(!U.color){let B=await d({type:"select",name:"color",onState:W3,initial:z.color??"",message:`Which ${R.cyan("color")} would you like to use as the ${R.cyanBright("brand")} color?`,choices:V.map((b)=>({title:b,value:b}))});U.color=B.color}if(w&&!Q){let B=K.resolve(w);console.log(`
|
|
8
|
+
Creating a new project in ${R.blue(w)}`);let b=m("Downloading and extracting the repository...").start();try{if(I.mkdirSync(B,{recursive:!0}),U.template===b3){let j=K.resolve(K.join(K3,"../templates/",b3));Y3(j,B)}else await u3(()=>L3(B,{username:"a-peak-works",repo:"starter-kits",branch:"master",template:U.template,key:U.license}),{retries:2});b.succeed("Files are downloaded and extracted successfully!");let M=m({text:"Installing dependencies..."}).start(),N=B3.sync(["**/styles/theme.css"],{cwd:B,absolute:!0,onlyFiles:!0})[0];q3("brand",U.color,N??""),await u3(()=>e("sh",["-c",`cd ${w} && ${D()} install && git init`]).catch(async(j)=>{if(j.message.includes("peer"))M.warn("Dependency conflict detected. Retrying with --legacy-peer-deps..."),M.start("Installing dependencies with --legacy-peer-deps flag"),await e("sh",["-c",`cd ${w} && ${D()==="npm"?"npm --legacy-peer-deps":D()} install && git init`])}),{retries:1}),M.succeed("Dependencies installed"),console.log(`
|
|
9
9
|
Your project is ready, to get staretd run the following commands:
|
|
10
10
|
|
|
11
|
-
cd ${
|
|
12
|
-
${
|
|
13
|
-
Failed to download and extract the repository`)),
|
|
14
|
-
`);
|
|
15
|
-
`),
|
|
11
|
+
cd ${R.cyan(w)}
|
|
12
|
+
${R.cyan(D())} run dev`),process.exit(1)}catch(M){if(b.fail(R.red(`
|
|
13
|
+
Failed to download and extract the repository`)),M instanceof Error)console.error(M.message);else console.error(`
|
|
14
|
+
`);I.rmdirSync(B,{recursive:!0}),process.exit(0)}}else{let B=new Set,b=n(W),M=K.resolve(K.join(K3,"../templates/default")),N=B3.sync(["**/{styles,plugins}/**","postcss.config.*"],{cwd:K.join(M,"src"),onlyFiles:!0,ignore:S.filter((G)=>!G.includes("public"))}),j=await a({dependencies:["tailwindcss","tailwindcss-animate","@tailwindcss/typography","tailwindcss-react-aria-components","@designbycode/tailwindcss-mask-image"],devDependencies:["@tailwindcss/postcss","postcss"]});if(N.forEach((G)=>{let T=G.includes("postcss.config"),y=K.resolve(K.join(M,"src"),G),k=K.resolve(process.cwd(),T?G:`${L?.isSrcDir?"src":""}/${G}`);if(I.existsSync(k)){if(U?.overwrite)I.copyFileSync(y,k);else{let A3=I.readFileSync(k,"utf-8"),D3=I.readFileSync(y,"utf-8");if(A3!==D3)B.add({targetFile:k,sourceFile:y})}return}I.mkdirSync(K.dirname(k),{recursive:!0}),I.writeFileSync(k,""),I.copyFileSync(K.resolve(K.join(M,"src"),G),k)}),B.size&&!U?.overwrite)if(console.log(`
|
|
15
|
+
`),Z.fail("Following files already exist in the directory."),B.forEach((T)=>{console.log(`- ${R.green(T.targetFile)}`)}),(await d({type:"confirm",name:"overwrite",message:"Do you want to overwrite the existing files?",initial:!0})).overwrite){let T=m("Overwriting files").start();B.forEach((y)=>{I.copyFileSync(y.sourceFile,y.targetFile)}),T.succeed("Files are overwritten"),process.exit(1)}else console.log(`Use ${R.cyan("--overwrite")} or ${R.cyan("-o")} to overwrite existing files, or refer to the documentation ${R.cyan("https://untitled.xyz/docs")} for manual installation. The rest of the files are added.`),process.exit(0);if(b?.tailwindFile)console.log(`
|
|
16
16
|
Tailwind config file exists in the project directory. You can add it to your globals.css as follows:`),console.log(`
|
|
17
|
-
${
|
|
18
|
-
`);let
|
|
19
|
-
Your project is ready, you can now start adding components.`),process.exit(1)}}var
|
|
17
|
+
${R.cyan(`@config "../${L?.isSrcDir&&"../"}${K.relative(process.cwd(),b.tailwindFile)}";`)}
|
|
18
|
+
`);let q=b?.layoutFile||b?.appFile||"",H=new e3({tsConfigFilePath:K.resolve(b?.tsConfig||"")}).addSourceFileAtPath(K.resolve(q)),_=["colors.css","globals.css","inter.css","text-styles.css","theme.css","typography.css"];H.getImportDeclarations().filter((G)=>_.includes(G.getModuleSpecifierValue())).forEach((G)=>G.remove());let x=K.relative(K.resolve(process.cwd(),`${L?.isSrcDir&&"src"}`),q).split("/").length;H.addImportDeclarations(N.filter((G)=>G.includes("styles")).map((G)=>({moduleSpecifier:`${L?.aliasPrefix?.stylesPrefix||L?.aliasPrefix?.srcPrefix||"../".repeat(x-1)}${L?.aliasPrefix?.stylesPrefix?G?.split("styles/")[1]:G}`}))),H.saveSync();let A=m(),f=B3.sync(["**/styles/theme.css"],{cwd:W,absolute:!0,onlyFiles:!0,ignore:S});if(!f?.length)return Z.fail("Failed to copy theme.css file");if(q3("brand",U.color,f[0]??""),!j)A.fail("Failed to get dependencies from package.json"),process.exit(1);A.start("Installing dependencies"),await e(D(),[D()==="npm"?"install":"add",...j.dependencies],{}),await e(D(),[D()==="npm"?"install":"add","-D",...j.devDependencies],{}),A.succeed("Dependencies installed"),Z.succeed(R.green("Files are extracted successfully!")),console.log(`
|
|
19
|
+
Your project is ready, you can now start adding components.`),process.exit(1)}}var U3={name:"untitledui",version:"0.1.5",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.js"},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","templates"],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",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 q0(){let z=new $0().name(U3.name).version(U3.version);z.addCommand(_3).addCommand(E3),z.parse()}q0();
|