ui-thing 0.2.6 → 0.2.8

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.
@@ -10,10 +10,10 @@ jobs:
10
10
  runs-on: ubuntu-latest
11
11
  steps:
12
12
  - uses: actions/checkout@v4
13
- - name: Install dependencies
14
- run: npm install
15
13
  - uses: actions/setup-node@v4
16
14
  with:
17
- node-version: "18.x"
15
+ node-version: "22.x"
16
+ - name: Install dependencies
17
+ run: npm install
18
18
  - name: Test
19
- run: npm run test
19
+ run: npm run test -- --run
package/CHANGELOG.md CHANGED
@@ -1,5 +1,58 @@
1
1
  # Changelog
2
2
 
3
+ ## v0.2.8
4
+
5
+ [compare changes](https://github.com/BayBreezy/ui-thing-cli/compare/v0.2.7...v0.2.8)
6
+
7
+ ### 🚀 Enhancements
8
+
9
+ - Enhance CSS styles with color-scheme support and scrollbar utility ([d61751c](https://github.com/BayBreezy/ui-thing-cli/commit/d61751c))
10
+ - Add additional regex patterns for Tailwind CSS class detection in VS Code settings ([7a2793e](https://github.com/BayBreezy/ui-thing-cli/commit/7a2793e))
11
+
12
+ ### 🏡 Chore
13
+
14
+ - **release:** V0.2.7 ([59f052e](https://github.com/BayBreezy/ui-thing-cli/commit/59f052e))
15
+ - Update dependencies and devDependencies in package.json ([af6d501](https://github.com/BayBreezy/ui-thing-cli/commit/af6d501))
16
+
17
+ ### ❤️ Contributors
18
+
19
+ - Behon Baker ([@BayBreezy](https://github.com/BayBreezy))
20
+
21
+ ## v0.2.7
22
+
23
+ [compare changes](https://github.com/BayBreezy/ui-thing-cli/compare/v0.2.6...v0.2.7)
24
+
25
+ ### 🚀 Enhancements
26
+
27
+ - Update tailwindFunctions in Prettier configuration to include 'tw' ([273f00a](https://github.com/BayBreezy/ui-thing-cli/commit/273f00a))
28
+ - Update VS Code recommendations ([898dc3d](https://github.com/BayBreezy/ui-thing-cli/commit/898dc3d))
29
+ - Add docsPath property to Component type ([7eb5fb4](https://github.com/BayBreezy/ui-thing-cli/commit/7eb5fb4))
30
+ - Simplify DEFINE_SHORTCUT import statement in shortcuts.ts ([2cb48c7](https://github.com/BayBreezy/ui-thing-cli/commit/2cb48c7))
31
+ - Add unit tests for various utility functions and components ([9b9067a](https://github.com/BayBreezy/ui-thing-cli/commit/9b9067a))
32
+ - Enhance test configuration in vite.config.ts for improved coverage reporting ([051541f](https://github.com/BayBreezy/ui-thing-cli/commit/051541f))
33
+ - Update dependencies in package.json and package-lock.json for improved functionality ([4b5a43c](https://github.com/BayBreezy/ui-thing-cli/commit/4b5a43c))
34
+ - Enhance promptUserForComponents to support ProseComponent type ([aa77801](https://github.com/BayBreezy/ui-thing-cli/commit/aa77801))
35
+ - Add fetchProseComponents utility to retrieve prose components from UI Thing API ([78acc6a](https://github.com/BayBreezy/ui-thing-cli/commit/78acc6a))
36
+ - Add fetchBlocks utility to retrieve block components from UI Thing API ([8bffb9e](https://github.com/BayBreezy/ui-thing-cli/commit/8bffb9e))
37
+ - Add fetchBlockCategories utility to retrieve block categories from UI Thing API ([cb5bde0](https://github.com/BayBreezy/ui-thing-cli/commit/cb5bde0))
38
+ - Implement prose command to add prose components to the project ([1f5c532](https://github.com/BayBreezy/ui-thing-cli/commit/1f5c532))
39
+ - Implement block command to add UI Thing blocks with category filtering ([23aa9e4](https://github.com/BayBreezy/ui-thing-cli/commit/23aa9e4))
40
+ - Update types to include TemplateFile and enhance ProseComponent and BlockComponent definitions ([1563080](https://github.com/BayBreezy/ui-thing-cli/commit/1563080))
41
+ - Add block and prose commands to the CLI ([d35e3b7](https://github.com/BayBreezy/ui-thing-cli/commit/d35e3b7))
42
+
43
+ ### 🩹 Fixes
44
+
45
+ - Update test mocking for CI compatibility ([9bc7a32](https://github.com/BayBreezy/ui-thing-cli/commit/9bc7a32))
46
+
47
+ ### 🏡 Chore
48
+
49
+ - Update dependencies to latest versions ([f70d2d5](https://github.com/BayBreezy/ui-thing-cli/commit/f70d2d5))
50
+ - Remove unused devDependencies from package.json and package-lock.json ([ba2d7cf](https://github.com/BayBreezy/ui-thing-cli/commit/ba2d7cf))
51
+
52
+ ### ❤️ Contributors
53
+
54
+ - Behon Baker ([@BayBreezy](https://github.com/BayBreezy))
55
+
3
56
  ## v0.2.6
4
57
 
5
58
  [compare changes](https://github.com/BayBreezy/ui-thing-cli/compare/v0.2.5...v0.2.6)
package/dist/index.js CHANGED
@@ -1,10 +1,11 @@
1
1
  #!/usr/bin/env node
2
- import{Command as je}from"commander";var V="0.2.5";import T from"path";import{updateConfig as io}from"c12/update";import{Command as qo}from"commander";import{consola as I}from"consola";import p from"kleur";import b from"lodash";import U from"prompts";import{join as oo}from"path";import{loadConfig as Lo}from"c12";import g from"fs-extra";import Uo from"lodash";import{loadFile as Po,writeFile as Ro}from"magicast";import{addNuxtModule as jo}from"magicast/helpers";import Do from"prompts";var w="ui-thing.config.ts",W={theme:"zinc",tailwindCSSLocation:"assets/css/tailwind.css",componentsLocation:"components/Ui",composablesLocation:"composables",pluginsLocation:"plugins",utilsLocation:"utils",force:!0,useDefaultFilename:!0,packageManager:"npm"},z={theme:"zinc",tailwindCSSLocation:"app/assets/css/tailwind.css",componentsLocation:"app/components/Ui",composablesLocation:"app/composables",pluginsLocation:"app/plugins",utilsLocation:"app/utils",force:!0,useDefaultFilename:!0,packageManager:"npm"},Y=["tailwindcss","motion-v","@tailwindcss/vite","reka-ui","tailwind-variants","tailwind-merge","@nuxt/fonts","@nuxtjs/color-mode","@nuxt/icon","@vueuse/nuxt","@tailwindcss/forms"],J=["typescript","tw-animate-css"],C=["prettier-plugin-tailwindcss","prettier","@ianvs/prettier-plugin-sort-imports"],X=["@nuxtjs/color-mode","motion-v/nuxt","@vueuse/nuxt","@nuxt/icon","@nuxt/fonts"],f=[{title:"Npm",value:"npm"},{title:"Yarn",value:"yarn"},{title:"Pnpm",value:"pnpm"},{title:"Bun",value:"bun"}],y=[{title:"Zinc",value:"zinc"},{title:"Slate",value:"slate"},{title:"Stone",value:"stone"},{title:"Gray",value:"gray"},{title:"Neutral",value:"neutral"},{title:"Red",value:"red"},{title:"Rose",value:"rose"},{title:"Orange",value:"orange"},{title:"Green",value:"green"},{title:"Blue",value:"blue"},{title:"Yellow",value:"yellow"},{title:"Violet",value:"violet"}];import Ko from"fs";function Z(){try{let o=JSON.parse(Ko.readFileSync("package.json","utf-8")),r=o.dependencies?.nuxt||o.devDependencies?.nuxt;if(r)return/^[~^>=<\s]*4/.test(r)?4:3}catch{return 4}return 4}import q from"kleur";import Ao from"prompts";var Q=async o=>{let r=await Ao([{name:"theme",type:"autocomplete",message:"Which theme do you want to start with?",choices:y},{name:"tailwindCSSLocation",type:"text",message:"Where is your tailwind.css file located?",initial:(e,t)=>o==3?"assets/css/tailwind.css":"app/assets/css/tailwind.css"},{name:"componentsLocation",type:"text",message:"Where should your components be stored?",initial:(e,t)=>o==3?"components/Ui":"app/components/Ui"},{name:"composablesLocation",type:"text",message:"Where should your composables be stored?",initial:(e,t)=>o==3?"composables":"app/composables"},{name:"pluginsLocation",type:"text",message:"Where should your plugins be stored?",initial:(e,t)=>o==3?"plugins":"app/plugins"},{name:"utilsLocation",type:"text",message:"Where should your utils be stored?",initial:(e,t)=>o==3?"utils":"app/utils"},{name:"force",type:"confirm",message:"Should we just replace component files if they already exist?",initial:!0},{name:"useDefaultFilename",type:"confirm",message:"Would you like to use the default filename when adding components?",initial:!0},{name:"packageManager",type:"select",message:"Which package manager do you use?",choices:f}]);return!r||Object.keys(r).length<9?(console.log(q.red(q.bold("Incomplete configuration submitted. Exiting..."))),process.exit(0)):r};var eo=process.cwd(),l=async o=>{let r=g.existsSync(w),e={},t=Number(o?.nuxtVersion)||Z();if(!r||o?.force){if(e=o?.yes?t===4?z:W:await Q(t),await g.writeFile(w,`export default ${JSON.stringify(e,null,2)}`),e.packageManager==="pnpm"){let c=g.existsSync(".npmrc"),n=!0;if(c){let{confirmCreateNpmrc:i}=await Do({type:"confirm",name:"confirmCreateNpmrc",message:"A .npmrc file already exists. Overwrite it?",initial:!1});n=i}n&&await g.writeFile(".npmrc",`shamefully-hoist=true
2
+ import{Command as Er}from"commander";var lo="0.2.7";import U from"path";import{updateConfig as xo}from"c12/update";import{Command as we}from"commander";import{consola as K}from"consola";import k from"kleur";import N from"lodash";import X from"prompts";import{join as bo}from"path";import{loadConfig as ce}from"c12";import x from"fs-extra";import ne from"lodash";import{loadFile as ae,writeFile as ie}from"magicast";import{addNuxtModule as se}from"magicast/helpers";import le from"prompts";var F="ui-thing.config.ts",ho={theme:"zinc",tailwindCSSLocation:"assets/css/tailwind.css",componentsLocation:"components/Ui",composablesLocation:"composables",pluginsLocation:"plugins",utilsLocation:"utils",force:!0,useDefaultFilename:!0,packageManager:"npm"},po={theme:"zinc",tailwindCSSLocation:"app/assets/css/tailwind.css",componentsLocation:"app/components/Ui",composablesLocation:"app/composables",pluginsLocation:"app/plugins",utilsLocation:"app/utils",force:!0,useDefaultFilename:!0,packageManager:"npm"},uo=["tailwindcss","motion-v","@tailwindcss/vite","reka-ui","tailwind-variants","tailwind-merge","@nuxt/fonts","@nuxtjs/color-mode","@nuxt/icon","@vueuse/nuxt","@tailwindcss/forms"],mo=["typescript","tw-animate-css"],O=["prettier-plugin-tailwindcss","prettier","@ianvs/prettier-plugin-sort-imports"],fo=["@nuxtjs/color-mode","motion-v/nuxt","@vueuse/nuxt","@nuxt/icon","@nuxt/fonts"],C=[{title:"Npm",value:"npm"},{title:"Yarn",value:"yarn"},{title:"Pnpm",value:"pnpm"},{title:"Bun",value:"bun"}],T=[{title:"Zinc",value:"zinc"},{title:"Slate",value:"slate"},{title:"Stone",value:"stone"},{title:"Gray",value:"gray"},{title:"Neutral",value:"neutral"},{title:"Red",value:"red"},{title:"Rose",value:"rose"},{title:"Orange",value:"orange"},{title:"Green",value:"green"},{title:"Blue",value:"blue"},{title:"Yellow",value:"yellow"},{title:"Violet",value:"violet"}];import re from"fs";function ko(){try{let o=JSON.parse(re.readFileSync("package.json","utf-8")),r=o.dependencies?.nuxt||o.devDependencies?.nuxt;if(r)return/^[~^>=<\s]*4/.test(r)?4:3}catch{return 4}return 4}import go from"kleur";import te from"prompts";var yo=async o=>{let r=await te([{name:"theme",type:"autocomplete",message:"Which theme do you want to start with?",choices:T},{name:"tailwindCSSLocation",type:"text",message:"Where is your tailwind.css file located?",initial:(e,t)=>o==3?"assets/css/tailwind.css":"app/assets/css/tailwind.css"},{name:"componentsLocation",type:"text",message:"Where should your components be stored?",initial:(e,t)=>o==3?"components/Ui":"app/components/Ui"},{name:"composablesLocation",type:"text",message:"Where should your composables be stored?",initial:(e,t)=>o==3?"composables":"app/composables"},{name:"pluginsLocation",type:"text",message:"Where should your plugins be stored?",initial:(e,t)=>o==3?"plugins":"app/plugins"},{name:"utilsLocation",type:"text",message:"Where should your utils be stored?",initial:(e,t)=>o==3?"utils":"app/utils"},{name:"force",type:"confirm",message:"Should we just replace component files if they already exist?",initial:!0},{name:"useDefaultFilename",type:"confirm",message:"Would you like to use the default filename when adding components?",initial:!0},{name:"packageManager",type:"select",message:"Which package manager do you use?",choices:C}]);return!r||Object.keys(r).length<9?(console.log(go.red(go.bold("Incomplete configuration submitted. Exiting..."))),process.exit(0)):r};var vo=process.cwd(),u=async o=>{let r=x.existsSync(F),e={},t=Number(o?.nuxtVersion)||ko();if(!r||o?.force){if(e=o?.yes?t===4?po:ho:await yo(t),await x.writeFile(F,`export default ${JSON.stringify(e,null,2)}`),e.packageManager==="pnpm"){let n=x.existsSync(".npmrc"),a=!0;if(n){let{confirmCreateNpmrc:i}=await le({type:"confirm",name:"confirmCreateNpmrc",message:"A .npmrc file already exists. Overwrite it?",initial:!1});a=i}a&&await x.writeFile(".npmrc",`shamefully-hoist=true
3
3
  strict-peer-dependencies=false
4
- `)}}else e=(await Lo({configFile:w.replace(".ts","")})).config;return Uo.isEmpty(e)?l({force:!0}):($o(e),e)},$o=o=>{let r=(e,t=!1)=>{e&&(t?g.ensureDirSync(e):g.ensureFileSync(e))};r(o.tailwindCSSLocation),r(o.pluginsLocation,!0),r(o.componentsLocation,!0),r(o.composablesLocation,!0),r(o.utilsLocation,!0)},ro=async o=>{if(!o)return;let r=typeof o=="string"?[o]:o,e=await Po(oo(eo,"nuxt.config.ts"));r.forEach(t=>jo(e,t)),await Ro(e,oo(eo,"nuxt.config.ts"))};var x=async()=>{let o=await l(),r={nuxtVersion:3,theme:"string",tailwindCSSLocation:"string",componentsLocation:"string",composablesLocation:"string",utilsLocation:"string",force:!0,useDefaultFilename:!0,packageManager:"string"},e=[];for(let t of Object.keys(r))o[t]===void 0&&e.push(t);return!(e.length>1)};import Go from"axios";import Bo from"dotenv";import Ho from"ora";Bo.config();var to=async()=>{let o=Ho("Fetching components...").start(),{data:r}=await Go.get(process.env.COMPONENTS_API||"https://uithing.com/api/components");return o.succeed("Components fetched."),r};import O from"fs";var S=async o=>{try{return await O.promises.access(o,O.constants.F_OK||O.constants.W_OK),!0}catch{return!1}};import{execa as F}from"execa";import E from"lodash";import Vo from"ora";var u=async(o,r,e)=>{typeof r=="string"&&(r=[r]),typeof e=="string"&&(e=[e]);let t=Vo("Installing dependencies...").start();!E.isUndefined(r)&&!E.isEmpty(r)&&await F(o,[o==="yarn"?"add":"install",...r]),t.text="Installing dev dependencies...",!E.isUndefined(e)&&!E.isEmpty(e)&&await F(o,[o==="yarn"?"add":"install","-D",...e]),t.text="Running nuxt prepare...",await F`npx -y nuxt prepare`,t.succeed("Installed dependencies!")};import Wo from"prompts";var co=async o=>{let r={yup:["yup","@vee-validate/yup"],zod:["zod","@vee-validate/zod"],joi:["joi","@vee-validate/joi"],valibot:["valibot","@vee-validate/valibot"]},{validator:e}=await Wo({type:"select",name:"validator",message:"Choose the validator package to use with Vee Validate: ",choices:[{title:"Yup",value:"yup"},{title:"Zod",value:"zod"},{title:"Joi",value:"joi"},{title:"Valibot",value:"valibot"}]});if(!e){console.log("No validator package selected");return}return console.log(`Selected ${e} as the validator package`),r[e]&&await u(o,r[e]),e};import zo from"boxen";import Yo from"figlet";var Jo=(o,r,e={})=>{let{box:t,figletFont:c}=e,n=Yo.textSync(o,{font:c||"Standard"}),h=zo(n,{...{borderColor:"greenBright",padding:1,borderStyle:"round",titleAlignment:"center"},...t});return r?`${h}
5
- ${r}`:h},d=(o,r,e)=>{console.log(`
6
- `+Jo(o,r,e))};import Xo from"prompts";var ao=async(o,r=[])=>{if(o)return r.map(t=>t.value);let{components:e}=await Xo({type:"autocompleteMultiselect",name:"components",message:"Select the components you want to add",choices:r.map(t=>({title:t.name,value:t.value}))});return e};import K from"fs";import Zo from"path";var no=async(o,r)=>{if(!await S(o)){let t=Zo.dirname(o);K.existsSync(t)||K.mkdirSync(t,{recursive:!0})}K.writeFileSync(o,r)};var P=[],v=process.cwd(),A=o=>P.find(r=>r.value.toLowerCase()===o.toLowerCase());async function so(o,r,e,t){if(await S(o)&&!e){let{value:n}=await U({type:"confirm",name:"value",message:t,initial:!1});if(!n)return I.info(`Skipped: ${p.cyan(T.basename(o))}`),!1}return await no(o,r),!0}async function L(o,r,e,t){for(let c of r){let n=T.join(v,e,c.fileName);await so(n,c.fileContent,t,`The ${o} file ${p.bold(c.fileName)} already exists. Overwrite?`)}}var Qo=async(o,r)=>{let e=await l();await x()||(e=await l({force:!0})),b.isEmpty(e)&&(I.info("Config file not set. Exiting..."),process.exit(0)),P=await to();let t=o;if(t.length===0){let a=await ao(r.all,P);(!a||a.length===0)&&(I.info("No components selected. Exiting..."),process.exit(0)),t=a}let c=t.filter(a=>!A(a));c.length>0&&I.error(`Not found: ${p.bgRed(c.join(", "))}`);let n=t.map(a=>A(a)).filter(Boolean);for(let a of[...n])a.components&&a.components.forEach(k=>{n.find(m=>m.value===k)||n.push(A(k))});for(let a of n)for(let k of a.files){let m=e.componentsLocation,B=T.join(v,m,k.fileName);if(!e.useDefaultFilename){let{value:H}=await U({type:"text",name:"value",message:`Where should we add the file ${p.cyan(k.fileName)}?`,initial:m});H&&(m=H,B=T.join(v,m,k.fileName))}await so(B,k.fileContent,e.force,`The file ${p.bold(k.fileName)} already exists. Overwrite?`)&&((a.value==="vue-sonner"||a.value==="sonner")&&await oe(),a.value==="datatable"&&await ee(),await L("utils",a.utils,e.utilsLocation,e.force),await L("composables",a.composables,e.composablesLocation,e.force),await L("plugins",a.plugins,e.pluginsLocation??"",e.force))}await ro(b.uniq(n.flatMap(a=>a.nuxtModules||[])));let i=b.uniq(n.flatMap(a=>a.deps||[])),h=b.uniq(n.flatMap(a=>a.devDeps||[]));if(i.length>0||h.length>0)if(r.all)await u(e.packageManager,i,h);else{let{confirmInstall:a}=await U({type:"confirm",name:"confirmInstall",message:`Install packages: ${p.cyan([...i,...h].join(", "))}?`,initial:!0});a&&await u(e.packageManager,i,h)}n.some(a=>a.askValidator)&&await co(e.packageManager),d("All Done!",`Run the ${p.cyan("ui-thing@latest --help")} command to learn more.
7
- `,{box:{title:"Components Added"}});let s=b.compact(n.flatMap(a=>a.instructions));s.length>0&&(console.log(""),console.log(p.bgCyan(" Instructions ")),s.forEach(a=>console.log(`${p.cyan("-")} ${a}`)))},lo=new qo().name("add").command("add").description("Add a list of components to your project.").option("-a --all","Add all components to your project.",!1).argument("[componentNames...]","Components that you want to add.").action(Qo);async function oe(){await io({configFile:"nuxt.config",cwd:v,onUpdate(o){o.imports||={imports:[]},o.imports.imports.find(r=>r.from==="vue-sonner"&&r.name==="toast")||o.imports.imports.push({from:"vue-sonner",name:"toast",as:"useSonner"})}})}async function ee(){await io({configFile:"nuxt.config",cwd:v,onUpdate(o){o.app||={head:{script:[]}},["https://cdnjs.cloudflare.com/ajax/libs/pdfmake/0.2.12/pdfmake.min.js","https://cdnjs.cloudflare.com/ajax/libs/pdfmake/0.2.12/vfs_fonts.min.js"].forEach(e=>{o.app.head.script.find(t=>t.src===e)||o.app.head.script.push({src:e,defer:!0})})}})}import Ie from"path";import{updateConfig as Te}from"c12/update";import{Command as _e}from"commander";import bo from"fs-extra";import $ from"kleur";import Ne from"ora";var re=`@import "tailwindcss";
4
+ `)}}else e=(await ce({configFile:F.replace(".ts","")})).config;return ne.isEmpty(e)?u({force:!0}):(de(e),e)},de=o=>{let r=(e,t=!1)=>{e&&(t?x.ensureDirSync(e):x.ensureFileSync(e))};r(o.tailwindCSSLocation),r(o.pluginsLocation,!0),r(o.componentsLocation,!0),r(o.composablesLocation,!0),r(o.utilsLocation,!0)},A=async o=>{if(!o)return;let r=typeof o=="string"?[o]:o,e=await ae(bo(vo,"nuxt.config.ts"));r.forEach(t=>se(e,t)),await ie(e,bo(vo,"nuxt.config.ts"))};var g=async()=>{let o=await u(),r={nuxtVersion:3,theme:"string",tailwindCSSLocation:"string",componentsLocation:"string",composablesLocation:"string",utilsLocation:"string",force:!0,useDefaultFilename:!0,packageManager:"string"},e=[];for(let t of Object.keys(r))o[t]===void 0&&e.push(t);return!(e.length>1)};import he from"axios";import pe from"dotenv";import ue from"ora";pe.config();var wo=async()=>{let o=ue("Fetching components...").start(),{data:r}=await he.get(process.env.COMPONENTS_API||"https://uithing.com/api/components");return o.succeed("Components fetched."),r};import V from"fs";var y=async o=>{try{return await V.promises.access(o,V.constants.F_OK||V.constants.W_OK),!0}catch{return!1}};import{execa as z}from"execa";import P from"lodash";import me from"ora";var f=async(o,r,e)=>{typeof r=="string"&&(r=[r]),typeof e=="string"&&(e=[e]);let t=me("Installing dependencies...").start();!P.isUndefined(r)&&!P.isEmpty(r)&&await z(o,[o==="yarn"?"add":"install",...r]),t.text="Installing dev dependencies...",!P.isUndefined(e)&&!P.isEmpty(e)&&await z(o,[o==="yarn"?"add":"install","-D",...e]),t.text="Running nuxt prepare...",await z`npx -y nuxt prepare`,t.succeed("Installed dependencies!")};import fe from"prompts";var Co=async o=>{let r={yup:["yup","@vee-validate/yup"],zod:["zod","@vee-validate/zod"],joi:["joi","@vee-validate/joi"],valibot:["valibot","@vee-validate/valibot"]},{validator:e}=await fe({type:"select",name:"validator",message:"Choose the validator package to use with Vee Validate: ",choices:[{title:"Yup",value:"yup"},{title:"Zod",value:"zod"},{title:"Joi",value:"joi"},{title:"Valibot",value:"valibot"}]});if(!e){console.log("No validator package selected");return}return console.log(`Selected ${e} as the validator package`),r[e]&&await f(o,r[e]),e};import ke from"boxen";import ge from"figlet";var ye=(o,r,e={})=>{let{box:t,figletFont:n}=e,a=ge.textSync(o,{font:n||"Standard"}),l=ke(a,{...{borderColor:"greenBright",padding:1,borderStyle:"round",titleAlignment:"center"},...t});return r?`${l}
5
+ ${r}`:l},m=(o,r,e)=>{console.log(`
6
+ `+ye(o,r,e))};import be from"prompts";var L=async(o,r=[])=>{if(o)return r.map(t=>t.value);let{components:e}=await be({type:"autocompleteMultiselect",name:"components",message:"Select the components you want to add",choices:r.map(t=>({title:t.name,value:t.value}))});return e};import q from"fs";import ve from"path";var S=async(o,r)=>{if(!await y(o)){let t=ve.dirname(o);q.existsSync(t)||q.mkdirSync(t,{recursive:!0})}q.writeFileSync(o,r)};var Z=[],_=process.cwd(),Y=o=>Z.find(r=>r.value.toLowerCase()===o.toLowerCase());async function So(o,r,e,t){if(await y(o)&&!e){let{value:a}=await X({type:"confirm",name:"value",message:t,initial:!1});if(!a)return K.info(`Skipped: ${k.cyan(U.basename(o))}`),!1}return await S(o,r),!0}async function J(o,r,e,t){for(let n of r){let a=U.join(_,e,n.fileName);await So(a,n.fileContent,t,`The ${o} file ${k.bold(n.fileName)} already exists. Overwrite?`)}}var Ce=async(o,r)=>{let e=await u();await g()||(e=await u({force:!0})),N.isEmpty(e)&&(K.info("Config file not set. Exiting..."),process.exit(0)),Z=await wo();let t=o;if(t.length===0){let c=await L(r.all,Z);(!c||c.length===0)&&(K.info("No components selected. Exiting..."),process.exit(0)),t=c}let n=t.filter(c=>!Y(c));n.length>0&&K.error(`Not found: ${k.bgRed(n.join(", "))}`);let a=t.map(c=>Y(c)).filter(Boolean);for(let c of[...a])c.components&&c.components.forEach(p=>{a.find(h=>h.value===p)||a.push(Y(p))});for(let c of a)for(let p of c.files){let h=e.componentsLocation,s=U.join(_,h,p.fileName);if(!e.useDefaultFilename){let{value:b}=await X({type:"text",name:"value",message:`Where should we add the file ${k.cyan(p.fileName)}?`,initial:h});b&&(h=b,s=U.join(_,h,p.fileName))}await So(s,p.fileContent,e.force,`The file ${k.bold(p.fileName)} already exists. Overwrite?`)&&((c.value==="vue-sonner"||c.value==="sonner")&&await xe(),c.value==="datatable"&&await Se(),await J("utils",c.utils,e.utilsLocation,e.force),await J("composables",c.composables,e.composablesLocation,e.force),await J("plugins",c.plugins,e.pluginsLocation??"",e.force))}await A(N.uniq(a.flatMap(c=>c.nuxtModules||[])));let i=N.uniq(a.flatMap(c=>c.deps||[])),l=N.uniq(a.flatMap(c=>c.devDeps||[]));if(i.length>0||l.length>0)if(r.all)await f(e.packageManager,i,l);else{let{confirmInstall:c}=await X({type:"confirm",name:"confirmInstall",message:`Install packages: ${k.cyan([...i,...l].join(", "))}?`,initial:!0});c&&await f(e.packageManager,i,l)}a.some(c=>c.askValidator)&&await Co(e.packageManager),m("All Done!",`Run the ${k.cyan("ui-thing@latest --help")} command to learn more.
7
+ `,{box:{title:"Components Added"}});let d=N.compact(a.flatMap(c=>c.instructions));d.length>0&&(console.log(""),console.log(k.bgCyan(" Instructions ")),d.forEach(c=>console.log(`${k.cyan("-")} ${c}`)))},Eo=new we().name("add").command("add").description("Add a list of components to your project.").option("-a --all","Add all components to your project.",!1).argument("[componentNames...]","Components that you want to add.").action(Ce);async function xe(){await xo({configFile:"nuxt.config",cwd:_,onUpdate(o){o.imports||={imports:[]},o.imports.imports.find(r=>r.from==="vue-sonner"&&r.name==="toast")||o.imports.imports.push({from:"vue-sonner",name:"toast",as:"useSonner"})}})}async function Se(){await xo({configFile:"nuxt.config",cwd:_,onUpdate(o){o.app||={head:{script:[]}},["https://cdnjs.cloudflare.com/ajax/libs/pdfmake/0.2.12/pdfmake.min.js","https://cdnjs.cloudflare.com/ajax/libs/pdfmake/0.2.12/vfs_fonts.min.js"].forEach(e=>{o.app.head.script.find(t=>t.src===e)||o.app.head.script.push({src:e,defer:!0})})}})}import{spawnSync as Fe}from"child_process";import Q from"path";import{Command as Oe}from"commander";import{consola as E}from"consola";import j from"kleur";import No from"lodash";import R from"prompts";import Ee from"axios";import Ie from"dotenv";import Te from"ora";Ie.config();var Io=async()=>{let o=Te("Fetching block categories...").start(),{data:r}=await Ee.get(process.env.BLOCK_CATEGORIES_API||"https://uithing.com/api/blocks/categories");return o.succeed("Block categories fetched."),r};import Ne from"axios";import _e from"dotenv";import Me from"ora";_e.config();var To=async()=>{let o=Me("Fetching blocks...").start(),{data:r}=await Ne.get(process.env.BLOCKS_API||"https://uithing.com/api/blocks");return o.succeed("Blocks fetched."),r};var D=[],_o=process.cwd();function Ae(o){return o.componentsLocation?.startsWith("app/")?"app/components/Blocks":"components/Blocks"}async function Pe(o,r,e,t){if(await y(o)&&!e){let{value:a}=await R({type:"confirm",name:"value",message:t,initial:!1});if(!a)return E.info(`Skipped: ${j.cyan(Q.basename(o))}`),!1}return await S(o,r),!0}var Le=async(o,r)=>{let e=await u();await g()||(e=await u({force:!0})),No.isEmpty(e)&&(E.info("Config file not set. Exiting..."),process.exit(0));let t=await Io(),n=r.category;if(!n&&t?.length){let{category:s}=await R({type:"select",name:"category",message:"Choose a block category",choices:[{title:"All",value:"all"},...t.map(w=>({title:w,value:w}))],initial:0});n=s}D=await To();let a=D;n&&n!=="all"&&(a=D.filter(s=>s.category===n),a.length===0&&(E.warn(`No blocks found for category ${j.cyan(n)}. Falling back to all.`),a=D));let{selectedBlocks:i}=await R({type:"autocompleteMultiselect",name:"selectedBlocks",message:"Select the blocks you want to add",choices:a.map(s=>({title:s.name,value:s}))});(!i||i.length===0)&&(E.info("No blocks selected. Exiting..."),process.exit(0));let l=i,d=Ae(e),{blocksDir:c}=await R({type:"text",name:"blocksDir",message:"Where should we add the blocks?",initial:d}),p=c||d;for(let s of l){let w=Q.join(p,s.path),b=Q.join(_o,w);await Pe(b,s.file,e.force,`The block file ${j.bold(s.fileName)} already exists. Overwrite?`)}let h=No.uniq(l.flatMap(s=>s.components||[]));if(h.length>0){E.info(`Adding ${h.length} component(s) required by blocks...`);let s=Fe("npx",["ui-thing@latest","add",...h],{cwd:_o,stdio:"inherit"});s.error&&E.error("Failed to add components:",s.error.message)}m("Blocks added!",`Run the ${j.cyan("ui-thing@latest --help")} command to learn more.
8
+ `,{box:{title:"Blocks Added"}})},Mo=new Oe().name("block").command("block").description("Add UI Thing blocks to your project.").option("-c --category <category>","Filter blocks by category before selection").action(Le);import ar from"path";import{updateConfig as ir}from"c12/update";import{Command as sr}from"commander";import jo from"fs-extra";import to from"kleur";import lr from"ora";var Ke=`@import "tailwindcss";
8
9
  @import "tw-animate-css";
9
10
 
10
11
  @plugin "@tailwindcss/forms" {
@@ -129,7 +130,7 @@ ${r}`:h},d=(o,r,e)=>{console.log(`
129
130
  --gradient-rust: oklch(55.695% 0.19944 34.155);
130
131
  }
131
132
 
132
- `,te=`@layer base {
133
+ `,Ue=`@layer base {
133
134
  * {
134
135
  @apply border-border outline-ring/50;
135
136
  }
@@ -157,8 +158,25 @@ ${r}`:h},d=(o,r,e)=>{console.log(`
157
158
  [role="button"]:not(:disabled) {
158
159
  cursor: pointer;
159
160
  }
161
+ html {
162
+ color-scheme: light dark;
163
+ }
164
+ html.dark {
165
+ color-scheme: dark;
166
+ }
167
+ html.light {
168
+ color-scheme: light;
169
+ }
170
+ }
171
+
172
+ @utility no-scrollbar {
173
+ -ms-overflow-style: none;
174
+ scrollbar-width: none;
175
+ &::-webkit-scrollbar {
176
+ display: none;
177
+ }
160
178
  }
161
- `,_=o=>(ho[o]||(o="ZINC"),`${re}${ho[o]}${te}`),ce=`
179
+ `,B=o=>(Fo[o]||(o="ZINC"),`${Ke}${Fo[o]}${Ue}`),De=`
162
180
  :root {
163
181
  --radius: 0.65rem;
164
182
  --background: oklch(1 0 0);
@@ -228,7 +246,7 @@ ${r}`:h},d=(o,r,e)=>{console.log(`
228
246
  --sidebar-ring: oklch(0.556 0 0);
229
247
  }
230
248
 
231
- `,ae=`
249
+ `,je=`
232
250
  :root {
233
251
  --radius: 0.625rem;
234
252
  --background: oklch(1 0 0);
@@ -298,7 +316,7 @@ ${r}`:h},d=(o,r,e)=>{console.log(`
298
316
  --sidebar-ring: oklch(0.551 0.027 264.364);
299
317
  }
300
318
 
301
- `,ne=`
319
+ `,Re=`
302
320
  :root {
303
321
  --radius: 0.625rem;
304
322
  --background: oklch(1 0 0);
@@ -367,7 +385,7 @@ ${r}`:h},d=(o,r,e)=>{console.log(`
367
385
  --sidebar-ring: oklch(0.553 0.013 58.071);
368
386
  }
369
387
 
370
- `,ie=`
388
+ `,Be=`
371
389
  :root {
372
390
  --radius: 0.625rem;
373
391
  --background: oklch(1 0 0);
@@ -437,7 +455,7 @@ ${r}`:h},d=(o,r,e)=>{console.log(`
437
455
  --sidebar-ring: oklch(0.551 0.027 264.364);
438
456
  }
439
457
 
440
- `,se=`
458
+ `,$e=`
441
459
  :root {
442
460
  --radius: 0.625rem;
443
461
  --background: oklch(1 0 0);
@@ -507,7 +525,7 @@ ${r}`:h},d=(o,r,e)=>{console.log(`
507
525
  --sidebar-ring: oklch(0.556 0 0);
508
526
  }
509
527
 
510
- `,le=`
528
+ `,We=`
511
529
  :root {
512
530
  --radius: 0.65rem;
513
531
  --background: oklch(1 0 0);
@@ -577,7 +595,7 @@ ${r}`:h},d=(o,r,e)=>{console.log(`
577
595
  --sidebar-ring: oklch(0.637 0.237 25.331);
578
596
  }
579
597
 
580
- `,de=`
598
+ `,Ge=`
581
599
  :root {
582
600
  --radius: 0.65rem;
583
601
  --background: oklch(1 0 0);
@@ -647,7 +665,7 @@ ${r}`:h},d=(o,r,e)=>{console.log(`
647
665
  --sidebar-ring: oklch(0.645 0.246 16.439);
648
666
  }
649
667
 
650
- `,he=`
668
+ `,He=`
651
669
  :root {
652
670
  --radius: 0.65rem;
653
671
  --background: oklch(1 0 0);
@@ -717,7 +735,7 @@ ${r}`:h},d=(o,r,e)=>{console.log(`
717
735
  --sidebar-ring: oklch(0.646 0.222 41.116);
718
736
  }
719
737
 
720
- `,ue=`
738
+ `,Ve=`
721
739
  :root {
722
740
  --radius: 0.65rem;
723
741
  --background: oklch(1 0 0);
@@ -787,7 +805,7 @@ ${r}`:h},d=(o,r,e)=>{console.log(`
787
805
  --sidebar-ring: oklch(0.527 0.154 150.069);
788
806
  }
789
807
 
790
- `,pe=`
808
+ `,ze=`
791
809
  :root {
792
810
  --radius: 0.65rem;
793
811
  --background: oklch(1 0 0);
@@ -831,7 +849,7 @@ ${r}`:h},d=(o,r,e)=>{console.log(`
831
849
  --popover: oklch(0.21 0.006 285.885);
832
850
  --popover-foreground: oklch(0.985 0 0);
833
851
  --primary: oklch(0.546 0.245 262.881);
834
- --primary-foreground: oklch(0.379 0.146 265.522);
852
+ --primary-foreground: oklch(0.98 0.0067 277.16);
835
853
  --secondary: oklch(0.274 0.006 286.033);
836
854
  --secondary-foreground: oklch(0.985 0 0);
837
855
  --muted: oklch(0.274 0.006 286.033);
@@ -857,7 +875,7 @@ ${r}`:h},d=(o,r,e)=>{console.log(`
857
875
  --sidebar-ring: oklch(0.488 0.243 264.376);
858
876
  }
859
877
 
860
- `,ke=`
878
+ `,qe=`
861
879
  :root {
862
880
  --radius: 0.65rem;
863
881
  --background: oklch(1 0 0);
@@ -927,7 +945,7 @@ ${r}`:h},d=(o,r,e)=>{console.log(`
927
945
  --sidebar-ring: oklch(0.554 0.135 66.442);
928
946
  }
929
947
 
930
- `,me=`
948
+ `,Ye=`
931
949
  :root {
932
950
  --radius: 0.65rem;
933
951
  --background: oklch(1 0 0);
@@ -997,22 +1015,17 @@ ${r}`:h},d=(o,r,e)=>{console.log(`
997
1015
  --sidebar-ring: oklch(0.541 0.281 293.009);
998
1016
  }
999
1017
 
1000
- `,ho={ZINC:ce,SLATE:ae,STONE:ne,GRAY:ie,NEUTRAL:se,RED:le,ROSE:de,ORANGE:he,GREEN:ue,BLUE:pe,YELLOW:ke,VIOLET:me};var uo=`/**
1018
+ `,Fo={ZINC:De,SLATE:je,STONE:Re,GRAY:Be,NEUTRAL:$e,RED:We,ROSE:Ge,ORANGE:He,GREEN:Ve,BLUE:ze,YELLOW:qe,VIOLET:Ye};var Oo=`/**
1001
1019
  * Utility function to return Tailwind CSS classes.
1002
1020
  */
1003
1021
  export const tw = <T extends TemplateStringsArray | string>(tailwindClasses: T) => tailwindClasses;
1004
- `;import{join as fe}from"path";import{$ as ge}from"execa";import R from"fs-extra";import ye from"ora";import po from"prompts";var N={arrowParens:"always",endOfLine:"lf",plugins:["@ianvs/prettier-plugin-sort-imports","prettier-plugin-tailwindcss"],printWidth:100,semi:!0,singleQuote:!1,tabWidth:2,trailingComma:"es5",useTabs:!1,vueIndentScriptAndStyle:!0,tailwindFunctions:["tv"],importOrder:["<BUILTIN_MODULES>","<THIRD_PARTY_MODULES>","<TYPES>","","^[.]"]};var M=async(o=process.cwd(),r=!0)=>{let e=fe(o,".prettierrc"),t=N;if(R.existsSync(e)){let n=await R.readFile(e,"utf-8"),i={};try{i=JSON.parse(n)}catch{console.warn("\u26A0\uFE0F Existing .prettierrc is not valid JSON \u2014 will prompt for overwrite.")}let h=await po({name:"merge",type:"select",message:"A prettier config file already exists. What would you like to do?",choices:[{title:"Merge configs",value:"merge"},{title:"Overwrite with new config",value:"overwrite"},{title:"Cancel",value:"cancel"}],initial:0});if(h.merge==="merge")t={...i,...N};else if(h.merge==="overwrite")t=N;else return!1}if(await R.writeFile(e,JSON.stringify(t,null,2),"utf-8"),!r)return!0;let c=ye("Formatting files with prettier...").start();return await ge`npx prettier --write .`,c.succeed("Files formatted with prettier"),!0},ko=async()=>{let{addPrettier:o}=await po({name:"addPrettier",type:"confirm",message:"Would you like to add a Prettier configuration to your project?",initial:!0});return o};import{join as be}from"path";import{builders as ve,loadFile as we,writeFile as Ce}from"magicast";import{getDefaultExportOptions as xe}from"magicast/helpers";var mo=async()=>{let o=be(process.cwd(),"nuxt.config.ts"),r=await we(o);if(!r.$code.includes("tailwindcss()")){let e=xe(r);e.vite||={},e.vite.plugins||=[],e.vite.plugins.push(ve.functionCall("tailwindcss"))}r.imports.$items.find(e=>e.local==="tailwindcss")||r.imports.$prepend({from:"@tailwindcss/vite",local:"tailwindcss",imported:"default"}),await Ce(r,o)};import Ee from"fs-extra";var fo={recommendations:["vue.volar","bradlc.vscode-tailwindcss","esbenp.prettier-vscode","antfu.iconify","formulahendry.auto-close-tag","formulahendry.auto-rename-tag"]},go={"editor.formatOnSave":!0,"editor.quickSuggestions":{strings:"on"},"files.associations":{"*.css":"tailwindcss"},"tailwindCSS.classFunctions":["tw","clsx","tw\\.[a-z-]+"],"tailwindCSS.experimental.classRegex":[["([\"'`][^\"'`]*.*?[\"'`])","[\"'`]([^\"'`]*)[\"'`]"]]};import{merge as Se}from"es-toolkit";import j from"fs-extra";function D(o,r){let e={};if(j.existsSync(o))try{e=j.readJsonSync(o)}catch{console.warn(`\u26A0\uFE0F Could not parse ${o}, starting fresh.`)}let t=Se(e,r);j.writeJsonSync(o,t,{spaces:2})}var yo=(o=".vscode")=>{Ee.ensureDirSync(o),D(`${o}/extensions.json`,fo),D(`${o}/settings.json`,go)};var Me=async o=>{let r=await l(o),e=Ne("Updating nuxt.config...").start();await Te({cwd:process.cwd(),configFile:"nuxt.config",async onUpdate(c){c.modules||(c.modules=[]),c.imports||(c.imports={imports:[]});for(let s of X)c.modules.includes(s)||c.modules.push(s);if(!c.colorMode){let s=Ie.basename(process.cwd());c.colorMode={storageKey:`${s}-color-mode`,classSuffix:""}}c.icon||(c.icon={clientBundle:{scan:!0,sizeLimitKb:0},mode:"svg",class:"shrink-0",fetchTimeout:2e3,serverBundle:"local"}),c.imports.imports.find(s=>s.from==="tailwind-variants"&&s.name==="tv")||c.imports.imports.push({from:"tailwind-variants",name:"tv"}),c.imports.imports.find(s=>s.from==="tailwind-variants"&&s.name==="VariantProps")||c.imports.imports.push({from:"tailwind-variants",name:"VariantProps",type:!0}),c.css||=[];let n=r.tailwindCSSLocation?.split("app/")[1],i=`~/${n}`,h=`@/${n}`;!c.css.includes(i)&&!c.css.includes(h)&&c.css.push(i)}}),await mo(),e.succeed("Updated nuxt.config!"),e.start("Adding initial Tailwind CSS file..."),bo.writeFileSync(r.tailwindCSSLocation,_(r.theme.toUpperCase()),"utf-8"),e.succeed("Added initial Tailwind CSS file!"),e.start("Adding Autocomplete helper..."),bo.writeFileSync(r.utilsLocation+"/tw-helper.ts",uo,"utf-8"),e.succeed("Added Autocomplete helper!"),e.start("Merging VS Code settings..."),yo(),e.succeed("Merged VS Code settings!"),await u(r.packageManager,Y,J),await ko()&&(await u(r.packageManager,[],C),await M()),d("Initialized",`Feel free to start adding components with the ${$.bgWhite(" add ")} command.`,{box:{title:"Complete"}})},vo=new _e().command("init").name("init").summary("Initialize UI Thing in your Nuxt project.").description(`${$.bold("Initialize UI Thing in your Nuxt project.")}
1022
+ `;import{join as Je}from"path";import{$ as Xe}from"execa";import oo from"fs-extra";import Ze from"ora";import Ao from"prompts";var $={arrowParens:"always",endOfLine:"lf",plugins:["@ianvs/prettier-plugin-sort-imports","prettier-plugin-tailwindcss"],printWidth:100,semi:!0,singleQuote:!1,tabWidth:2,trailingComma:"es5",useTabs:!1,vueIndentScriptAndStyle:!0,tailwindFunctions:["tv","tw"],importOrder:["<BUILTIN_MODULES>","<THIRD_PARTY_MODULES>","<TYPES>","","^[.]"]};var W=async(o=process.cwd(),r=!0)=>{let e=Je(o,".prettierrc"),t=$;if(oo.existsSync(e)){let a=await oo.readFile(e,"utf-8"),i={};try{i=JSON.parse(a)}catch{console.warn("\u26A0\uFE0F Existing .prettierrc is not valid JSON \u2014 will prompt for overwrite.")}let l=await Ao({name:"merge",type:"select",message:"A prettier config file already exists. What would you like to do?",choices:[{title:"Merge configs",value:"merge"},{title:"Overwrite with new config",value:"overwrite"},{title:"Cancel",value:"cancel"}],initial:0});if(l.merge==="merge")t={...i,...$};else if(l.merge==="overwrite")t=$;else return!1}if(await oo.writeFile(e,JSON.stringify(t,null,2),"utf-8"),!r)return!0;let n=Ze("Formatting files with prettier...").start();return await Xe`npx prettier --write .`,n.succeed("Files formatted with prettier"),!0},Po=async()=>{let{addPrettier:o}=await Ao({name:"addPrettier",type:"confirm",message:"Would you like to add a Prettier configuration to your project?",initial:!0});return o};import{join as Qe}from"path";import{builders as or,loadFile as er,writeFile as rr}from"magicast";import{getDefaultExportOptions as tr}from"magicast/helpers";var Lo=async()=>{let o=Qe(process.cwd(),"nuxt.config.ts"),r=await er(o);if(!r.$code.includes("tailwindcss()")){let e=tr(r);e.vite||={},e.vite.plugins||=[],e.vite.plugins.push(or.functionCall("tailwindcss"))}r.imports.$items.find(e=>e.local==="tailwindcss")||r.imports.$prepend({from:"@tailwindcss/vite",local:"tailwindcss",imported:"default"}),await rr(r,o)};import nr from"fs-extra";var Ko={recommendations:["vue.volar","bradlc.vscode-tailwindcss","antfu.iconify","formulahendry.auto-close-tag","formulahendry.auto-rename-tag","prettier.prettier-vscode"]},Uo={"editor.formatOnSave":!0,"editor.quickSuggestions":{strings:"on"},"files.associations":{"*.css":"tailwindcss"},"tailwindCSS.classFunctions":["tw","clsx","tw\\.[a-z-]+"],"tailwindCSS.experimental.classRegex":[["tv\\(([^)(]*(?:\\([^)(]*(?:\\([^)(]*(?:\\([^)(]*\\)[^)(]*)*\\)[^)(]*)*\\)[^)(]*)*)\\)",'"(.*?)"'],"tw`(.*?)`","tw\\('(.*?)'\\)",`tw\\(\\s*('(.*?)'|"(.*?)")\\s*\\)`,["\\btv\\(\\s*((?:\"(?:\\\\.|[^\"\\\\])*\"|'(?:\\\\.|[^'\\\\])*'|`(?:\\\\.|[^`\\\\])*`|[^)]*)*)\\)",`["']([^"']*)["']`],["\\btv\\(\\s*((?:\"(?:\\\\.|[^\"\\\\])*\"|'(?:\\\\.|[^'\\\\])*'|`(?:\\\\.|[^`\\\\])*`|[^)]*)*)\\)","`([^`]*)`"]]};import{merge as cr}from"es-toolkit";import eo from"fs-extra";function ro(o,r){let e={};if(eo.existsSync(o))try{e=eo.readJsonSync(o)}catch{console.warn(`\u26A0\uFE0F Could not parse ${o}, starting fresh.`)}let t=cr(e,r);eo.writeJsonSync(o,t,{spaces:2})}var Do=(o=".vscode")=>{nr.ensureDirSync(o),ro(`${o}/extensions.json`,Ko),ro(`${o}/settings.json`,Uo)};var dr=async o=>{let r=await u(o),e=lr("Updating nuxt.config...").start();await ir({cwd:process.cwd(),configFile:"nuxt.config",async onUpdate(n){n.modules||(n.modules=[]),n.imports||(n.imports={imports:[]});for(let d of fo)n.modules.includes(d)||n.modules.push(d);if(!n.colorMode){let d=ar.basename(process.cwd());n.colorMode={storageKey:`${d}-color-mode`,classSuffix:""}}n.icon||(n.icon={clientBundle:{scan:!0,sizeLimitKb:0},mode:"svg",class:"shrink-0",fetchTimeout:2e3,serverBundle:"local"}),n.imports.imports.find(d=>d.from==="tailwind-variants"&&d.name==="tv")||n.imports.imports.push({from:"tailwind-variants",name:"tv"}),n.imports.imports.find(d=>d.from==="tailwind-variants"&&d.name==="VariantProps")||n.imports.imports.push({from:"tailwind-variants",name:"VariantProps",type:!0}),n.css||=[];let a=r.tailwindCSSLocation?.split("app/")[1],i=`~/${a}`,l=`@/${a}`;!n.css.includes(i)&&!n.css.includes(l)&&n.css.push(i)}}),await Lo(),e.succeed("Updated nuxt.config!"),e.start("Adding initial Tailwind CSS file..."),jo.writeFileSync(r.tailwindCSSLocation,B(r.theme.toUpperCase()),"utf-8"),e.succeed("Added initial Tailwind CSS file!"),e.start("Adding Autocomplete helper..."),jo.writeFileSync(r.utilsLocation+"/tw-helper.ts",Oo,"utf-8"),e.succeed("Added Autocomplete helper!"),e.start("Merging VS Code settings..."),Do(),e.succeed("Merged VS Code settings!"),await f(r.packageManager,uo,mo),await Po()&&(await f(r.packageManager,[],O),await W()),m("Initialized",`Feel free to start adding components with the ${to.bgWhite(" add ")} command.`,{box:{title:"Complete"}})},Ro=new sr().command("init").name("init").summary("Initialize UI Thing in your Nuxt project.").description(`${to.bold("Initialize UI Thing in your Nuxt project.")}
1005
1023
 
1006
1024
  \u2705 Add tailwindcss to your project
1007
1025
  \u2705 Update your nuxt.config file
1008
1026
  \u2705 Add the necessary dependencies
1009
- \u2705 Create a ${$.bold("ui-thing.config")} file with the default configuration`).option("-f --force","Overwrite config file if it exists.",!1).option("-y --yes","Skip prompts and use default values.",!1).option("-n --nuxtVersion <number>","Specify the Nuxt version you are using.").action(Me);import{Command as Oe}from"commander";import Fe from"prompts";var wo=new Oe().command("prettier").name("prettier").description("Adds prettier config to your project.").action(async()=>{if(!await M(void 0,!1)){d("Not Added","Prettier config was not added.",{box:{title:"Prettier Not Added",borderColor:"red"}});return}let{pkgManager:r}=await Fe({name:"pkgManager",type:"select",message:"Which package manager are you using?",choices:f});if(!r)return process.exit(0);await u(r,void 0,C),d("All Done!","A .prettierrc file has been added to your project and the code formatted. Enjoy!",{box:{title:"Prettier Added"}})});import{Command as Ke}from"commander";import{execa as Ae}from"execa";import Le from"ora";import Ue from"prompts";import{join as xo}from"path";import So from"fs-extra";var Co=`import {
1010
- createSharedComposable,
1011
- useActiveElement,
1012
- useDebounceFn,
1013
- useEventListener,
1014
- } from "@vueuse/core";
1015
- import type { MaybeRef } from "vue";
1027
+ \u2705 Create a ${to.bold("ui-thing.config")} file with the default configuration`).option("-f --force","Overwrite config file if it exists.",!1).option("-y --yes","Skip prompts and use default values.",!1).option("-n --nuxtVersion <number>","Specify the Nuxt version you are using.").action(dr);import{Command as hr}from"commander";import pr from"prompts";var Bo=new hr().command("prettier").name("prettier").description("Adds prettier config to your project.").action(async()=>{if(!await W(void 0,!1)){m("Not Added","Prettier config was not added.",{box:{title:"Prettier Not Added",borderColor:"red"}});return}let{pkgManager:r}=await pr({name:"pkgManager",type:"select",message:"Which package manager are you using?",choices:C});if(!r)return process.exit(0);await f(r,void 0,O),m("All Done!","A .prettierrc file has been added to your project and the code formatted. Enjoy!",{box:{title:"Prettier Added"}})});import{spawnSync as kr}from"child_process";import H from"path";import{Command as gr}from"commander";import{consola as I}from"consola";import v from"kleur";import M from"lodash";import ao from"prompts";import ur from"axios";import mr from"dotenv";import fr from"ora";mr.config();var $o=async()=>{let o=fr("Fetching prose components...").start(),{data:r}=await ur.get(process.env.PROSE_COMPONENTS_API||"https://uithing.com/api/prose");return o.succeed("Prose components fetched."),r};var io=[],G=process.cwd(),co=o=>io.find(r=>r.value.toLowerCase()===o.toLowerCase());async function Wo(o,r,e,t){if(await y(o)&&!e){let{value:a}=await ao({type:"confirm",name:"value",message:t,initial:!1});if(!a)return I.info(`Skipped: ${v.cyan(H.basename(o))}`),!1}return await S(o,r),!0}async function no(o,r,e,t){if(!(!r||r.length===0))for(let n of r){let a=H.join(G,e,n.fileName);await Wo(a,n.fileContent,t,`The ${o} file ${v.bold(n.fileName)} already exists. Overwrite?`)}}var yr=async(o,r)=>{let e=await u();await g()||(e=await u({force:!0})),M.isEmpty(e)&&(I.info("Config file not set. Exiting..."),process.exit(0)),io=await $o();let t=o;if(t.length===0){let c=await L(r.all,io);(!c||c.length===0)&&(I.info("No components selected. Exiting..."),process.exit(0)),t=c}let n=t.filter(c=>!co(c));n.length>0&&I.error(`Not found: ${v.bgRed(n.join(", "))}`);let a=t.map(c=>co(c)).filter(Boolean);for(let c of[...a])c.prose&&c.prose.length>0&&c.prose.forEach(p=>{if(!a.find(h=>h.value===p)){let h=co(p);h&&a.push(h)}});for(let c of a){let p=c.file,h=e.componentsLocation,s=H.join(G,h,p.fileName);if(!e.useDefaultFilename){let{value:b}=await ao({type:"text",name:"value",message:`Where should we add the file ${v.cyan(p.fileName)}?`,initial:h});b&&(h=b,s=H.join(G,h,p.fileName))}await Wo(s,p.fileContent,e.force,`The file ${v.bold(p.fileName)} already exists. Overwrite?`)&&(await no("utils",c.utils,e.utilsLocation,e.force),await no("composables",c.composables,e.composablesLocation,e.force),await no("plugins",c.plugins,e.pluginsLocation??"",e.force))}await A(M.uniq(a.flatMap(c=>c.modules||[])));let i=M.uniq(a.flatMap(c=>c.deps||[])),l=M.uniq(a.flatMap(c=>c.devDeps||[]));if(i.length>0||l.length>0)if(r.all)await f(e.packageManager,i,l);else{let{confirmInstall:c}=await ao({type:"confirm",name:"confirmInstall",message:`Install packages: ${v.cyan([...i,...l].join(", "))}?`,initial:!0});c&&await f(e.packageManager,i,l)}let d=M.uniq(a.flatMap(c=>c.components||[]));if(d.length>0){I.info(`Adding ${d.length} component(s) required by prose...`);let c=kr("npx",["ui-thing@latest","add",...d],{cwd:G,stdio:"inherit"});c.error&&I.error("Failed to add components:",c.error.message)}m("Prose added!",`Run the ${v.cyan("ui-thing@latest --help")} command to learn more.
1028
+ `,{box:{title:"Prose Components Added"}})},Go=new gr().name("prose").command("prose").description("Add prose components to your project.").option("-a --all","Add all prose components to your project.",!1).argument("[componentNames...]").action(yr);import{Command as br}from"commander";import{execa as vr}from"execa";import wr from"ora";import Cr from"prompts";import{join as Vo}from"path";import zo from"fs-extra";var Ho=`import type { MaybeRef } from "vue";
1016
1029
 
1017
1030
  type KbdKeysSpecificMap = {
1018
1031
  meta: string;
@@ -1326,5 +1339,5 @@ export function defineShortcuts(config: MaybeRef<ShortcutsConfig>, options: Shor
1326
1339
  return useEventListener("keydown", onKeyDown);
1327
1340
  }
1328
1341
 
1329
- `;var Eo=async(o=process.cwd())=>{let r=await l(),e=xo(o,r.composablesLocation);await So.ensureDir(e),await So.writeFile(xo(e,"shortcuts.ts"),Co,"utf-8")};var Io=new Ke().command("shortcuts").name("shortcuts").description("Add the shortcuts composables to your project.").action(async()=>{await Eo();let{pkgManager:o}=await Ue({name:"pkgManager",type:"select",message:"Which package manager are you using?",choices:f});if(!o)return process.exit(0);let r=Le("Installing vueuse module...").start();await Ae`npx -y nuxi@latest module add vueuse`,r.succeed("VueUse module installed successfully!"),d("All Done!","Check the composables folder for the shortcuts composables.",{box:{title:"Composable Added"}})});import{Command as Pe}from"commander";import To from"fs-extra";import _o from"kleur";import G from"lodash";import No from"prompts";var Re=o=>y.some(r=>r.value===o?.toLowerCase()),Mo=new Pe().command("theme").name("theme").description("Add a new theme to your project.").argument("[themeName]","The name of the theme you would like to add").action(async o=>{let r=await l();await x()||(r=await l({force:!0})),G.isEmpty(r)&&(console.log(_o.red("Config file not set. Exiting...")),process.exit(0));let t=o&&Re(o)?o.toLowerCase():void 0;if(!t){let{theme:c}=await No([{name:"theme",type:"autocomplete",message:"Which theme do you want to add?",choices:y}]);c||(console.log(_o.red("No theme selected. Exiting...")),process.exit(0)),t=c}if(To.existsSync(r.tailwindCSSLocation)){let{force:c}=await No([{name:"force",type:"confirm",message:"The Tailwind CSS file already exists. Overwrite?",initial:!1}]);if(!c)return console.log("Exiting..."),process.exit(0)}To.writeFileSync(r.tailwindCSSLocation,_(t.toUpperCase()),"utf-8"),d(`${G.capitalize(t)}`,`${G.capitalize(t)} theme has been added to ${r.tailwindCSSLocation}`,{box:{title:"New Theme Added"}})});process.on("SIGINT",()=>process.exit(0));process.on("SIGTERM",()=>process.exit(0));process.on("SIGTSTP",()=>process.exit(0));var Oo=new je;console.clear();d("UI Thing",void 0,{box:{title:"Welcome"}});console.log();Oo.name("ui-thing").description("CLI for adding ui-thing components to your Nuxt application").version(V).addCommand(vo).addCommand(lo).addCommand(Mo).addCommand(Io).addCommand(wo);Oo.parse(process.argv);
1342
+ `;var qo=async(o=process.cwd())=>{let r=await u(),e=Vo(o,r.composablesLocation);await zo.ensureDir(e),await zo.writeFile(Vo(e,"shortcuts.ts"),Ho,"utf-8")};var Yo=new br().command("shortcuts").name("shortcuts").description("Add the shortcuts composables to your project.").action(async()=>{await qo();let{pkgManager:o}=await Cr({name:"pkgManager",type:"select",message:"Which package manager are you using?",choices:C});if(!o)return process.exit(0);let r=wr("Installing vueuse module...").start();await vr`npx -y nuxi@latest module add vueuse`,r.succeed("VueUse module installed successfully!"),m("All Done!","Check the composables folder for the shortcuts composables.",{box:{title:"Composable Added"}})});import{Command as xr}from"commander";import Jo from"fs-extra";import Xo from"kleur";import so from"lodash";import Zo from"prompts";var Sr=o=>T.some(r=>r.value===o?.toLowerCase()),Qo=new xr().command("theme").name("theme").description("Add a new theme to your project.").argument("[themeName]","The name of the theme you would like to add").action(async o=>{let r=await u();await g()||(r=await u({force:!0})),so.isEmpty(r)&&(console.log(Xo.red("Config file not set. Exiting...")),process.exit(0));let t=o&&Sr(o)?o.toLowerCase():void 0;if(!t){let{theme:n}=await Zo([{name:"theme",type:"autocomplete",message:"Which theme do you want to add?",choices:T}]);n||(console.log(Xo.red("No theme selected. Exiting...")),process.exit(0)),t=n}if(Jo.existsSync(r.tailwindCSSLocation)){let{force:n}=await Zo([{name:"force",type:"confirm",message:"The Tailwind CSS file already exists. Overwrite?",initial:!1}]);if(!n)return console.log("Exiting..."),process.exit(0)}Jo.writeFileSync(r.tailwindCSSLocation,B(t.toUpperCase()),"utf-8"),m(`${so.capitalize(t)}`,`${so.capitalize(t)} theme has been added to ${r.tailwindCSSLocation}`,{box:{title:"New Theme Added"}})});process.on("SIGINT",()=>process.exit(0));process.on("SIGTERM",()=>process.exit(0));process.on("SIGTSTP",()=>process.exit(0));var oe=new Er;console.clear();m("UI Thing",void 0,{box:{title:"Welcome"}});console.log();oe.name("ui-thing").description("CLI for adding ui-thing components to your Nuxt application").version(lo).addCommand(Ro).addCommand(Eo).addCommand(Go).addCommand(Mo).addCommand(Qo).addCommand(Yo).addCommand(Bo);oe.parse(process.argv);
1330
1343
  //# sourceMappingURL=index.js.map