ui-thing 0.2.8 → 0.2.9
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/CHANGELOG.md +26 -0
- package/bun.lock +941 -0
- package/dist/index.js +12 -7
- package/dist/index.js.map +1 -1
- package/package.json +28 -27
- package/src/templates/css.ts +5 -0
- package/src/templates/vs-code.ts +0 -8
- package/src/utils/config.ts +2 -1
- package/tsup.config.ts +5 -1
package/dist/index.js
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
import{Command as Er}from"commander";var lo="0.2.
|
|
2
|
+
import{Command as Er}from"commander";var lo="0.2.8";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
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
5
|
${r}`:l},m=(o,r,e)=>{console.log(`
|
|
6
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
|
|
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
|
|
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 D 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 j=[],_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: ${D.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}j=await To();let a=j;n&&n!=="all"&&(a=j.filter(s=>s.category===n),a.length===0&&(E.warn(`No blocks found for category ${D.cyan(n)}. Falling back to all.`),a=j));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 ${D.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 ${D.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 Do from"fs-extra";import to from"kleur";import lr from"ora";var Ke=`@import "tailwindcss";
|
|
9
9
|
@import "tw-animate-css";
|
|
10
10
|
|
|
11
11
|
@plugin "@tailwindcss/forms" {
|
|
@@ -167,6 +167,11 @@ ${r}`:l},m=(o,r,e)=>{console.log(`
|
|
|
167
167
|
html.light {
|
|
168
168
|
color-scheme: light;
|
|
169
169
|
}
|
|
170
|
+
@media (prefers-color-scheme: dark) {
|
|
171
|
+
select {
|
|
172
|
+
background-color: var(--popover);
|
|
173
|
+
}
|
|
174
|
+
}
|
|
170
175
|
}
|
|
171
176
|
|
|
172
177
|
@utility no-scrollbar {
|
|
@@ -176,7 +181,7 @@ ${r}`:l},m=(o,r,e)=>{console.log(`
|
|
|
176
181
|
display: none;
|
|
177
182
|
}
|
|
178
183
|
}
|
|
179
|
-
`,B=o=>(Fo[o]||(o="ZINC"),`${Ke}${Fo[o]}${Ue}`),
|
|
184
|
+
`,B=o=>(Fo[o]||(o="ZINC"),`${Ke}${Fo[o]}${Ue}`),je=`
|
|
180
185
|
:root {
|
|
181
186
|
--radius: 0.65rem;
|
|
182
187
|
--background: oklch(1 0 0);
|
|
@@ -246,7 +251,7 @@ ${r}`:l},m=(o,r,e)=>{console.log(`
|
|
|
246
251
|
--sidebar-ring: oklch(0.556 0 0);
|
|
247
252
|
}
|
|
248
253
|
|
|
249
|
-
`,
|
|
254
|
+
`,De=`
|
|
250
255
|
:root {
|
|
251
256
|
--radius: 0.625rem;
|
|
252
257
|
--background: oklch(1 0 0);
|
|
@@ -1015,11 +1020,11 @@ ${r}`:l},m=(o,r,e)=>{console.log(`
|
|
|
1015
1020
|
--sidebar-ring: oklch(0.541 0.281 293.009);
|
|
1016
1021
|
}
|
|
1017
1022
|
|
|
1018
|
-
`,Fo={ZINC:
|
|
1023
|
+
`,Fo={ZINC:je,SLATE:De,STONE:Re,GRAY:Be,NEUTRAL:$e,RED:We,ROSE:Ge,ORANGE:He,GREEN:Ve,BLUE:ze,YELLOW:qe,VIOLET:Ye};var Oo=`/**
|
|
1019
1024
|
* Utility function to return Tailwind CSS classes.
|
|
1020
1025
|
*/
|
|
1021
1026
|
export const tw = <T extends TemplateStringsArray | string>(tailwindClasses: T) => tailwindClasses;
|
|
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"
|
|
1027
|
+
`;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"]},Uo={"editor.formatOnSave":!0,"editor.quickSuggestions":{strings:"on"},"files.associations":{"*.css":"tailwindcss"},"tailwindCSS.classFunctions":["tw","clsx","tw\\.[a-z-]+"],"tailwindCSS.experimental.classRegex":[["\\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 jo=(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..."),Do.writeFileSync(r.tailwindCSSLocation,B(r.theme.toUpperCase()),"utf-8"),e.succeed("Added initial Tailwind CSS file!"),e.start("Adding Autocomplete helper..."),Do.writeFileSync(r.utilsLocation+"/tw-helper.ts",Oo,"utf-8"),e.succeed("Added Autocomplete helper!"),e.start("Merging VS Code settings..."),jo(),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.")}
|
|
1023
1028
|
|
|
1024
1029
|
\u2705 Add tailwindcss to your project
|
|
1025
1030
|
\u2705 Update your nuxt.config file
|