untitledui 0.1.37 → 0.1.38
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 +2 -2
- package/package.json +1 -1
package/dist/index.mjs
CHANGED
|
@@ -54,7 +54,7 @@ Following files already exist in the directory.`),H.forEach((Y)=>{console.log(N.
|
|
|
54
54
|
✨ 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 k3(W){return new Promise((Q,z)=>{let q=T3.createServer((Z,K)=>{let L=new F3(Z.url,"http://localhost");if(L.pathname==="/callback"){let H=L.searchParams.get("apiKey"),V=L.searchParams.get("error");if(V){K.writeHead(400,{"Content-Type":"text/html"}),K.end(M0(decodeURIComponent(V))),q.close(),z(new Error(decodeURIComponent(V)));return}if(!H){K.writeHead(400,{"Content-Type":"text/html"}),K.end(M0("No Access Token received")),q.close(),z(new Error("No Access Token received"));return}try{P3(H),K.writeHead(200,{"Content-Type":"text/html"}),K.end(z3()),q.close(),Q()}catch(E){K.writeHead(500,{"Content-Type":"text/html"}),K.end(M0("Failed to save authentication data")),q.close(),z(E)}}else K.writeHead(404),K.end("Not found")});q.listen(0,"localhost",()=>{let L=`https://www.untitledui.com/react/api/cli-auth?port=${q.address().port}`;W.text="Opening browser for authentication...",S3(L).catch((H)=>{console.log(w0.yellow(`
|
|
55
55
|
Failed to open browser automatically: ${H.message}`)),console.log(w0.cyan(`Please manually open: ${L}
|
|
56
56
|
`))}),W.text="Waiting for authentication in browser..."}),setTimeout(()=>{q.close(),z(new Error("Authentication timeout. Please try again."))},300000)})}function P3(W){if(!f.existsSync(T0))f.mkdirSync(T0,{recursive:!0});let Q={};if(f.existsSync(D0))try{Q=JSON.parse(f.readFileSync(D0,"utf-8"))}catch{Q={}}Q.license=W,f.writeFileSync(D0,JSON.stringify(Q,null,2),"utf-8")}import g0 from"async-retry";import M from"chalk";import{Command as l3}from"commander";import{execa as I0}from"execa";import*as w from"fs";import q0 from"ora";import a3 from"os";import*as G from"path";import n from"prompts";import{Project as s3}from"ts-morph";import O3 from"node-fetch";async function H0(W,Q){try{let q=await O3("https://www.untitledui.com/react/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 $0 from"async-retry";import A from"chalk";import{Command as g3}from"commander";import{execa as a}from"execa";import v0 from"fast-glob";import _ from"fs";import z0 from"ora";import d3 from"os";import*as v from"path";import R0 from"prompts";import{Project as h3}from"ts-morph";import{fileURLToPath as f3}from"url";import*as j0 from"fs";import*as W3 from"path";function x0(W,Q){let z=W3.join(W,"package.json");if(!j0.existsSync(z))return Q;let q=JSON.parse(j0.readFileSync(z,"utf-8")),Z={...q.dependencies,...q.devDependencies},K=[];for(let L of Q){let H=Z[L];if(!H){K.push(L);continue}if(L==="tailwindcss"){let V=H.match(/\d+/);if((V?parseInt(V[0],10):0)<4)K.push(L)}}return K}import C0 from"chalk";import*as m from"fs";import*as G0 from"path";function F0(W){if(!m.existsSync(G0.resolve(W)))console.log(C0.red(`Error: CSS file not found at ${W}`)),process.exit(1);let Q=m.readFileSync(G0.resolve(W),"utf-8"),z=/(--color-[a-zA-Z-]+-\d{1,3}):\s*(rgb\([^)]+\))/g,q={},Z;while((Z=z.exec(Q))!==null)if(Z[1]&&Z[2])q[Z[1]]=Z[2];return q}function k0(W,Q,z){let q=G0.resolve(z);if(!m.existsSync(q)){console.log(C0.red(`Error: CSS file not found at ${q}`));return}let Z=m.readFileSync(q,"utf-8"),K=F0(z),L={},H={};for(let[E,T]of Object.entries(K))if(E.startsWith(`--color-${W}-`)){let R=E.replace(`--color-${W}-`,"");L[R]=E}else if(E.startsWith(`--color-${Q}-`)){let R=E.replace(`--color-${Q}-`,"");H[R]=T}let V=!1;for(let[E,T]of Object.entries(L))if(H[E]){let R=H[E],$=new RegExp(`(${T}):\\s*rgb\\([^)]*\\);?`,"g");if($.test(Z))Z=Z.replace($,`$1: ${R};`),V=!0;else console.log(C0.yellow(`No match found for ${T}`))}if(V)m.writeFileSync(q,Z,"utf-8")}var m3=f3(import.meta.url),Y3=v.dirname(m3),c3=v.join(d3.homedir(),".untitledui"),s=v.join(c3,"config.json"),$3="vite",q3="nextjs",Z3={[q3]:"Next.js",[$3]:"Vite"},h="",j={color:"",template:"",framework:void 0};if(_.existsSync(s)){let W=JSON.parse(_.readFileSync(s,"utf-8"));j.license=W.license}var P0=(W)=>{if(W.aborted)process.stdout.write("\x1B[?25h"),process.stdout.write(`
|
|
57
|
-
`),process.exit(1)},X3=new g3().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("--nextjs","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.").action(async(W,Q)=>{if(W)h=W;if(Q){if(j.color=Q.color,j.template=Q.template,j.overwrite=Q.overwrite,j.colorsList=Q.colorsList,j.license=Q.license||j.license,j.vite=Q.vite,j.
|
|
57
|
+
`),process.exit(1)},X3=new g3().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("--nextjs","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.").action(async(W,Q)=>{if(W)h=W;if(Q){if(j.color=Q.color,j.template=Q.template,j.overwrite=Q.overwrite,j.colorsList=Q.colorsList,j.license=Q.license||j.license,j.vite=Q.vite,j.nextjs=Q.nextjs,Q.vite)j.framework=$3;if(Q.nextjs)j.framework=q3}try{await O0(Q),process.exit(0)}catch(z){console.error(A.red(z)),process.exit(1)}});async function O0(W,Q=null){let z=process.cwd(),q=_.existsSync(v.resolve(z,"package.json")),Z=v.resolve(v.join(Y3,"../config/styles","theme.css")),K=F0(Z??""),L=Array.from(new Set(Object.keys(K).map(($)=>$?.split("--color-")?.[1]?.replace(/-\d{1,3}/,"")))),H=z0().start(),V=await p(z),E=q?v0.sync(["**/**/theme.css"],{cwd:z,absolute:!0,onlyFiles:!0,ignore:d}):[],T=E?.[0]&&_.readFileSync(E[0],"utf-8").match(/(--color-brand+-\d{1,3}):\s*(rgb\([^)]+\))/g)?.[1]||void 0;if(j.license){if(!_.existsSync(s)){let Y=v.dirname(s);_.mkdirSync(Y,{recursive:!0}),_.writeFileSync(s,JSON.stringify({license:j.license},null,2))}if(JSON.parse(_.readFileSync(s,"utf-8")).license!==j.license)_.writeFileSync(s,JSON.stringify({license:j.license},null,2))}if(!q){if(H.stop(),!h){let $=await R0({onState:P0,type:"text",name:"path",message:"What is your project named?",initial:"untitled-ui"});if(typeof $.path==="string")h=$.path.trim()}if(Q)Q.projectPath=h;if(_.existsSync(v.resolve(v.posix.join(z,h))))H.fail(A.red("Directory already exists!")),process.exit(1);if(j.vite&&j.nextjs||!j.framework){let $=await R0({type:"select",name:"framework",onState:P0,message:`Which ${A.cyan("framework")} would you like to use?`,choices:Object.entries(Z3).map(([Y,X])=>({title:X,value:Y}))});j.framework=$.framework}H.succeed("Framework is selected: "+A.green(Z3[j.framework]))}else if(V?.framework==="other")H.fail("Unsupported project framework"),console.log(`Please refer to the documentation ${A.cyan("https://www.untitled.com/docs")} for supported frameworks or proceed with manual installation.`),process.exit(1);else if(V?.framework.startsWith("nextjs")||V?.framework.startsWith("vite"))if(!Q&&!T)H.succeed(A.yellow(`Detected ${n0[V.framework]} project, proceeding with the setup...`));else H.stop();if(j.colorsList||!j.color&&!T){let $=await R0({type:"select",name:"color",onState:P0,initial:W.color??"",message:`Which ${A.cyan("color")} would you like to use as the ${A.cyanBright("brand")} color?`,choices:L.map((Y)=>({title:Y,value:Y}))});j.color=$.color}let R=v.posix.join(z,h||"");if(h&&!q){let $=v.resolve(h);console.log(`
|
|
58
58
|
Creating a new project in ${A.blue(h)}`);let Y=z0("Downloading and extracting the repository...").start();try{_.mkdirSync($,{recursive:!0}),await $0(()=>m0($,{template:j.framework}),{retries:2}),Y.succeed("Files are downloaded and extracted successfully!");let X=z0({text:"Installing dependencies..."}).start(),b=v0.sync(["**/styles/theme.css"],{cwd:$,absolute:!0,onlyFiles:!0})[0];if(k0("brand",j.color||"",b??""),await $0(()=>a(C(),["install"],{cwd:R}).catch(async(S)=>{if(S.message.includes("peer"))X.warn("Dependency conflict detected. Retrying with --legacy-peer-deps..."),X.start("Installing dependencies with --legacy-peer-deps flag"),await a(C(),["install","--legacy-peer-deps"],{cwd:R})}),{retries:1}),await $0(()=>a("git",["init"],{cwd:R}),{retries:1}),X.succeed("Dependencies are installed"),!Q)console.log(`
|
|
59
59
|
Your project is ready, to get started run the following commands:
|
|
60
60
|
|
|
@@ -77,4 +77,4 @@ Your project is ready, you can now start adding components.`)}}var n3=G.join(a3.
|
|
|
77
77
|
Failed to add the component ${M.red(B?.example)}`),console.error(M.red(Y)),process.exit(1)}if(V.size&&!B?.overwrite)if(console.log(`
|
|
78
78
|
Following files already exist in the directory.`),V.forEach((X)=>{console.log(M.green(`- ${G.relative(z,X.path)}`))}),(await n({type:"confirm",name:"overwrite",message:"Do you want to overwrite the existing files?",initial:!0})).overwrite){let X=q0("Overwriting files").start();V.forEach((b)=>{let S=G.relative(G.resolve(z,`${Z?.isSrcDir?"src":""}`,B.path),b.path).split("/").length,J=S===1?"./":"../".repeat(S-1),x=E.addSourceFileAtPath(G.resolve(b.path));x.replaceWithText(b.code),x.getImportDeclarations().forEach((u)=>{let O=u.getModuleSpecifierValue();u.setModuleSpecifier(t(O,B.path,Z?.aliasPrefix,J))}),x.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://www.untitled.com/docs")} for manual installation. The rest of the files are added.`),process.exit(1);let $=C();if(K?.dependencies?.length){let Y=q0("Installing example dependencies").start();await g0(()=>I0($,[$==="npm"?"install":"add",...K.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 I0($,[$==="npm"?"install":"add",...K.dependencies,"--legacy-peer-deps"],{cwd:z})}),{retries:1}),Y.succeed("Example dependencies are installed")}if(K?.devDependencies?.length){let Y=q0("Installing example devDependencies").start();await g0(()=>I0($,[$==="npm"?"install":"add","-D",...K.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 I0($,[$==="npm"?"install":"add","-D",...K.devDependencies,"--legacy-peer-deps"],{cwd:z})}),{retries:1}),Y.succeed("Example devDependencies are installed")}if(B?.components?.length)await g0(()=>y0({components:B.components,dir:d0?.projectPath||"",path:B.path,message:`
|
|
79
79
|
\uD83C\uDF89 Example ${M.green(B.example)} has been added to ${M.green(R)}`}),{retries:1});console.log(`
|
|
80
|
-
\uD83C\uDF89 Example ${M.green(B.example)} has been added to ${M.green(R)}`),process.exit(0)}var h0={name:"untitledui",version:"0.1.
|
|
80
|
+
\uD83C\uDF89 Example ${M.green(B.example)} has been added to ${M.green(R)}`),process.exit(0)}var h0={name:"untitledui",version:"0.1.38",main:"dist/index.mjs",description:"The Untitled UI CLI tool helps you quickly scaffold projects with Untitled UI React and add components and page examples to your existing projects with an interactive interface in seconds.",type:"module",publishConfig:{access:"public"},scripts:{test:'echo "Error: no test specified" && exit 1',dev:"bun build --entrypoints ./index.ts --entry-naming=[name].mjs --outdir=dist --target=node --minify --packages=external --env=inline --define=process.env.API_URL=http://localhost:3000/react/api --watch",build:"bun build --entrypoints ./index.ts --entry-naming=[name].mjs --outdir=dist --target=node --minify --packages=external --env=inline --define=process.env.API_URL=https://www.untitledui.com/react/api","publish:npm":"bun run build && npm publish --access public",start:"node dist/index.mjs"},bugs:{url:"https://github.com/untitleduico/react/issues"},homepage:"https://github.com/untitleduico/react#readme",keywords:["untitledui","untitled-ui","untitledui","untitledui-cli","untitledui-react","untitledui-components","untitledui-examples","untitledui-vite","untitledui-nextjs","cli","tailwindcss","nextjs","react","components","examples","vite"],files:["dist","config","templates","README.md"],author:{name:"Untitled UI",url:"https://www.untitledui.com/react"},contributors:[{name:"Dilshod Turobov",url:"https://x.com/deebovv"},{name:"Jordan Hughes",url:"https://x.com/jordanphughes"}],license:"MIT",bin:{untitledui:"dist/index.mjs"},exports:"./dist/index.mjs",dependencies:{"async-retry":"^1.3.3",chalk:"^5.4.1",commander:"^13.1.0",execa:"^7.0.0","fast-glob":"^3.3.3","node-fetch":"^3.3.2",open:"^10.1.0",ora:"^8.2.0",prettier:"^3.5.3",prompts:"^2.4.2",tar:"^7.4.3","ts-morph":"^25.0.1","tsconfig-paths":"^4.2.0","update-check":"^1.5.4"},devDependencies:{"@types/async-retry":"^1.4.9","@types/prompts":"^2.4.9","@types/tar":"^6.1.13","type-fest":"^4.37.0",typescript:"^5.8.2"}};process.on("SIGINT",()=>process.exit(0));process.on("SIGTERM",()=>process.exit(0));async function o3(){let W=new p3().name(h0.name).version(h0.version);W.addCommand(X3).addCommand(t0).addCommand(B3).addCommand(Q3),W.parse()}o3();
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "untitledui",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.38",
|
|
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",
|