untitledui 0.1.38 → 0.1.39

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. package/dist/index.mjs +1 -1
  2. package/package.json +1 -1
package/dist/index.mjs CHANGED
@@ -69,7 +69,7 @@ ${A.cyan(`@config "../${V?.isSrcDir?"../":""}${v.relative(z,X.tailwindFile)}";`)
69
69
  Tailwind CSS is not configured in your Vite project. Please refer to the documentation ${A.cyan("https://www.untitled.com/react/integrations/vite")} for manual installation.
70
70
  `)}let u=X?.layoutFile||X?.appFile||V?.framework==="vite"&&X?.mainFile||"";if(!u)console.log(`Import following files to your main file:
71
71
  `),S.forEach((I)=>{console.log(A.cyan(I))});else{let y=new h3({tsConfigFilePath:v.resolve(X?.tsConfig||"")}).addSourceFileAtPath(v.resolve(u)),k="globals.css";y.getImportDeclarations().filter((g)=>g.getModuleSpecifierValue().includes("globals.css")).forEach((g)=>g.remove());let P=v.relative(v.resolve(z,`${V?.isSrcDir?"src":""}`),u).split("/").length,W0=V?.aliasPrefix?.stylesPrefix||V?.aliasPrefix?.srcPrefix||(P===1?"./":"../".repeat(P-1));y.addImportDeclarations(S.filter((g)=>g.includes("globals.css")).map((g)=>({moduleSpecifier:`${W0}${V?.aliasPrefix?.stylesPrefix?g?.split("styles/")[1]:g}`}))),y.saveSync()}let O=v0.sync(["**/styles/theme.css"],{cwd:z,absolute:!0,onlyFiles:!0,ignore:d});if(!O?.length)return $.fail(`Failed to copy ${A.cyan("theme.css")} file.
72
- Ensure that the ${A.cyan("theme.css")} file exists in the project directory under ${A.yellow("styles/")} folder.`);if((j.color||!T)&&k0("brand",j.color||"brand",O[0]??""),J.length||x.length){let I=z0().start("Installing dependencies");J.length&&await $0(()=>a(C(),[C()==="npm"?"install":"add",...J],{cwd:R}).catch(async(y)=>{if(y.message.includes("peer"))I.warn("Dependency conflict detected. Retrying with --legacy-peer-deps..."),I.start("Installing dependencies with --legacy-peer-deps flag"),await a(C(),[C()==="npm"?"install":"add",...J,"--legacy-peer-deps"],{cwd:R})}),{retries:1}),x.length&&await $0(()=>a(C(),[C()==="npm"?"install":"add","-D",...x],{cwd:R}).catch(async(y)=>{if(y.message.includes("peer"))I.warn("DevDependency conflict detected. Retrying with --legacy-peer-deps..."),I.start("Installing dependencies with --legacy-peer-deps flag"),await a(C(),[C()==="npm"?"install":"add","-D",...x,"--legacy-peer-deps"],{cwd:R})}),{retries:1}),I.succeed("Dependencies are installed")}if(!Q&&!T)$.succeed(A.green("Project setup is completed!"));if(Q&&q)return;else console.log(`
72
+ Ensure that the ${A.cyan("theme.css")} file exists in the project directory under ${A.yellow("styles/")} folder.`);if((j.color||!T)&&k0("brand",j.color||"brand",O[0]??""),J.length||x.length){let I=z0().start("Installing dependencies");J.length&&await $0(()=>a(C(),[C()==="npm"?"install":"add",...J],{cwd:R}).catch(async(y)=>{if(y.message.includes("peer"))I.warn("Dependency conflict detected. Retrying with --legacy-peer-deps..."),I.start("Installing dependencies with --legacy-peer-deps flag"),await a(C(),[C()==="npm"?"install":"add",...J,"--legacy-peer-deps"],{cwd:R})}),{retries:1}),x.length&&await $0(()=>a(C(),[C()==="npm"?"install":"add","-D",...x],{cwd:R}).catch(async(y)=>{if(y.message.includes("peer"))I.warn("DevDependency conflict detected. Retrying with --legacy-peer-deps..."),I.start("Installing dependencies with --legacy-peer-deps flag"),await a(C(),[C()==="npm"?"install":"add","-D",...x,"--legacy-peer-deps"],{cwd:R})}),{retries:1}),I.succeed("Dependencies are installed")}if(!Q&&!T)$.succeed(A.green("Project setup is completed!"));if(Q&&q){H.stop(),$.stop();return}else console.log(`
73
73
  Your project is ready, you can now start adding components.`)}}var n3=G.join(a3.homedir(),".untitledui"),r=G.join(n3,"config.json"),B={path:"",example:"",license:"",components:[]},d0={};if(w.existsSync(r)){let W=JSON.parse(w.readFileSync(r,"utf-8"));B.license=W.license}var Q0=(W)=>{if(W.aborted)process.stdout.write("\x1B[?25h"),process.stdout.write(`
74
74
  `),process.exit(1)},B3=new l3().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.").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 O0(Q,d0),await r3(B)}catch(z){console.error(M.red(z))}});async function r3(W){let Q=q0().start(),z=G.posix.join(process.cwd(),d0?.projectPath||"");if(!w.existsSync(G.posix.join(G.resolve(z,"package.json"))))Q.warn("This command should be run in a project directory."),process.exit(1);let Z=await p(z);if(B.license){if(!await X0(B.license))Q.fail("Invalid license key"),process.exit(1);if(!w.existsSync(r)){let b=G.dirname(r);w.mkdirSync(b,{recursive:!0}),w.writeFileSync(r,JSON.stringify({license:B.license},null,2))}if(JSON.parse(w.readFileSync(r,"utf-8")).license!==B.license)w.writeFileSync(r,JSON.stringify({license:B.license},null,2),"utf-8")}if(Q.stop(),!B.example){let Y=await n({type:"select",name:"example",onState:Q0,message:"Select which type of example you want to add",choices:[{title:"Application",value:"application"},{title:"Marketing",value:"marketing"}]});B.example=Y.example}let K=null;if(B.example){let Y=await H0(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(`${e()} 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 n({type:"select",name:"example",onState:Q0,message:`Select a folder or file in "${B.example}"`,choices:Y.results.map((b)=>({title:b,value:b}))});if(!X.example)return;if(B.example=X.example,Y=await H0(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(`${e()} 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 n({type:"select",name:"example",onState:Q0,message:`Select which example you want to add from "${B.example}"`,choices:Y.results.map((b)=>({title:b,value:`${B.example}/${b}`}))});if(!X.example)return;if(B.example=X.example,Y=await H0(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(`${e()} 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")K=Y.content}if(!K)Q.fail("No example found"),process.exit(1);if(!B?.examplePath){let Y=Z?.isUsingAppDir?"app":"pages",X=Z?.isSrcDir?G.posix.join("src",Y):Y,b=await n({type:"text",name:"examplePath",onState:Q0,message:`Where would you like to add the ${M.cyan(B?.example)} example?`,initial:X});B.examplePath=b.examplePath}else if(!w.existsSync(G.posix.join(z,B.examplePath)))w.mkdirSync(G.posix.join(z,B.examplePath),{recursive:!0}),console.log(M.green(`Created directory ${B.examplePath}`));if(!B?.path){let Y=await n({type:"text",name:"path",onState:Q0,message:`Where would you like to add the ${M.cyan("components")}?`,initial:"components"});B.path=Y.path}let L=K.components.filter((Y)=>!w.existsSync(G.posix.join(z,`${Z?.isSrcDir?"src":""}`,Y?.path?.replace(/components\//,B.path+"/"))));if(L?.length){let Y=await n({type:"multiselect",name:"components",onState:Q0,message:`Select which components you want to add from ${M.cyan(K.name)} example`,choices:L.map((X)=>({title:X?.name,value:X?.name,selected:!0})),instructions:!1,hint:"- Space to select. Return to submit"});if(B.components=Y.components,!L.length&&!Y.components?.length)Q.warn("No components selected")}let H=o(z),V=new Set,E=new s3({tsConfigFilePath:H?.tsConfig}),T=q0(`Adding ${B?.example}...`).start(),R="";try{if(K.files?.forEach(async({path:Y,code:X})=>{let b=G.posix.join(z,`${Z?.isSrcDir?"src":""}`,Y.replace(/components\//,B.path+"/")),S=Z?.framework==="vite"?X.replace(`"use client";
75
75
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "untitledui",
3
- "version": "0.1.38",
3
+ "version": "0.1.39",
4
4
  "main": "dist/index.mjs",
5
5
  "description": "The Untitled UI CLI tool helps you quickly scaffold projects with Untitled UI React and add components and page examples to your existing projects with an interactive interface in seconds.",
6
6
  "type": "module",