hghcn 3.6.23 → 3.6.24
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.d.ts +323 -323
- package/dist/index.js +1 -1
- package/dist/index.js.map +1 -1
- package/dist/registry/index.d.ts +2 -2
- package/dist/schema/index.d.ts +681 -681
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -83,5 +83,5 @@ args = ["shadcn@${ce}", "mcp"]`),r.break(),r.info("3. Restart Codex to load the
|
|
|
83
83
|
`).map(k=>{if(k.trim().startsWith("import "))return k;let S=k;return S=S.replace(/\b(asChild\s*\?\s*)Slot(\s*:)/g,"$1__SLOT_PLACEHOLDER__$2"),S=S.replace(/\bReact\.ComponentProps<typeof\s+Slot>/g,"React.ComponentProps<typeof __SLOT_PLACEHOLDER__>"),S=S.replace(/\bComponentProps<typeof\s+Slot>/g,"ComponentProps<typeof __SLOT_PLACEHOLDER__>"),S=S.replace(/(<\/?)Slot(\s*\/?>)/g,"$1__SLOT_PLACEHOLDER__$2"),S=S.replace(/\bSlot\b/g,(B,T,Y)=>{let O=Y.substring(0,T),Fe=(O.match(/"/g)||[]).length,Dr=(O.match(/'/g)||[]).length;return Fe%2!==0||Dr%2!==0?B:"__SLOT_PLACEHOLDER__"}),S=S.replace(/__SLOT_PLACEHOLDER__/g,"SlotPrimitive.Slot"),S}).join(`
|
|
84
84
|
`));let g=Array.from(new Set(o));return {content:s,replacedPackages:g}}async function Sr(e){let t={};if(!v.existsSync(e.cwd)||!v.existsSync(E__default.resolve(e.cwd,"package.json")))return t["1"]=true,{errors:t,config:null};if(!v.existsSync(E__default.resolve(e.cwd,"components.json")))return t["3"]=true,{errors:t,config:null};try{let i$1=await i(e.cwd);return {errors:t,config:i$1}}catch{r.break(),r.error(`An invalid ${d.info("components.json")} file was found at ${d.info(e.cwd)}.
|
|
85
85
|
Before you can run a migration, you must create a valid ${d.info("components.json")} file by running the ${d.info("init")} command.`),r.error(`Learn more at ${d.info("https://ui.shadcn.com/docs/components-json")}.`),r.break(),process.exit(1);}}var Rr=[{name:"icons",description:"migrate your ui components to a different icon library."},{name:"radix",description:"migrate to radix-ui."}],$o=z$1.object({cwd:z$1.string(),list:z$1.boolean(),yes:z$1.boolean(),migration:z$1.string().refine(e=>e&&Rr.some(t=>t.name===e),{message:"You must specify a valid migration. Run `shadcn migrate --list` to see available migrations."}).optional()}),Cr=new Command().name("migrate").description("run a migration.").argument("[migration]","the migration to run.").option("-c, --cwd <cwd>","the working directory. defaults to the current directory.",process.cwd()).option("-l, --list","list all migrations.",false).option("-y, --yes","skip confirmation prompt.",false).action(async(e,t)=>{try{let i=$o.parse({cwd:E__default.resolve(t.cwd),migration:e,list:t.list,yes:t.yes});if(i.list||!i.migration){r.info("Available migrations:");for(let n of Rr)r.info(`- ${n.name}: ${n.description}`);return}if(!i.migration)throw new Error("You must specify a migration. Run `shadcn migrate --list` to see available migrations.");let{errors:r$1,config:o}=await Sr(i);if(r$1["1"]||r$1["3"])throw new Error("No `components.json` file found. Ensure you are at the root of your project.");if(!o)throw new Error("Something went wrong reading your `components.json` file. Please ensure you have a valid `components.json` file.");i.migration==="icons"&&await br(o),i.migration==="radix"&&await xr(o,{yes:i.yes});}catch(i){r.break(),V$1(i);}});async function Ir(e){let t={},i$1={cwd:e.cwd,registryFile:E__default.resolve(e.cwd,e.registryFile),outputDir:E__default.resolve(e.cwd,e.outputDir)};if(!v.existsSync(i$1.registryFile))return t["13"]=true,{errors:t,resolvePaths:null,config:null};if(!v.existsSync(E__default.resolve(e.cwd,"components.json")))return t["3"]=true,{errors:t,resolvePaths:null,config:null};await v.mkdir(i$1.outputDir,{recursive:true});try{let r=await i(e.cwd);return {errors:t,config:r,resolvePaths:i$1}}catch{r.break(),r.error(`An invalid ${d.info("components.json")} file was found at ${d.info(e.cwd)}.
|
|
86
|
-
Before you can build the registry, you must create a valid ${d.info("components.json")} file by running the ${d.info("init")} command.`),r.break(),process.exit(1);}}var Oo=z$1.object({cwd:z$1.string(),registryFile:z$1.string(),outputDir:z$1.string(),verbose:z$1.boolean().optional().default(false)}),kr=new Command().name("registry:build").description("builds the registry [EXPERIMENTAL]").argument("[registry]","path to registry.json file","./registry.json").option("-o, --output <path>","destination directory for json files","./public/r").option("-c, --cwd <cwd>","the working directory. defaults to the current directory.",process.cwd()).option("-v, --verbose","verbose output").action(async(e,t)=>{await Fo({cwd:E.resolve(t.cwd),registryFile:e,outputDir:t.output,verbose:t.verbose});});async function Fo(e){try{let t=Oo.parse(e),[{errors:i,resolvePaths:r$1,config:o$2},n$1]=await Promise.all([Ir(t),o(t.cwd)]);(i["3"]||!o$2||!n$1)&&(r.error(`A ${d.info("components.json")} file is required to build the registry. Run ${d.info("shadcn init")} to create one.`),r.break(),process.exit(1)),(i["13"]||!r$1)&&(r.error(`We could not find a registry file at ${d.info(E.resolve(t.cwd,t.registryFile))}.`),r.break(),process.exit(1));let a=await z.readFile(r$1.registryFile,"utf-8"),s$1=o$1.safeParse(JSON.parse(a));s$1.success||(r.error(`Invalid registry file found at ${d.info(r$1.registryFile)}.`),r.break(),process.exit(1));let c=s("Building registry..."),m=await Ao(s$1.data,o$2,n$1);for(let l of m.items)l.files=l.files?.filter((p,u,g)=>u===g.findIndex(h=>h.path===p.path)),l.dependencies&&(l.dependencies=l.dependencies.filter((p,u,g)=>u===g.findIndex(h=>h===p)));for(let l of m.items){if(!l.files)continue;c.start(`Building ${l.name}...`),l.$schema="https://ui.shadcn.com/schema/registry-item.json";for(let u of l.files){let g=E.resolve(r$1.cwd,u.path);try{if(!(await z.stat(g)).isFile())continue;u.content=await z.readFile(g,"utf-8");}catch(h){console.error("Error reading file in registry build:",g,h);continue}}let p=n.safeParse(l);if(!p.success){r.error(`Invalid registry item found for ${d.info(l.name)}.`);continue}await z.writeFile(E.resolve(r$1.outputDir,`${p.data.name}.json`),JSON.stringify(p.data,null,2));}if(await z.copyFile(r$1.registryFile,E.resolve(r$1.outputDir,"registry.json")),c.succeed("Building registry."),t.verbose){s(`The registry has ${d.info(m.items.length.toString())} items:`).succeed();for(let l of m.items){r.log(` - ${l.name} (${d.info(l.type)})`);for(let p of l.files??[])r.log(` - ${p.path}`);}}}catch(t){r.break(),V$1(t);}}async function Ao(e,t,i){for(let r of e.items)if(r.files?.length)for(let o of r.files){let n=await K(o.path,t,i);n.files=n.files?.filter(a=>a.path!==o.path),n.files&&r.files.push(...n.files),n.dependencies&&(r.dependencies=r.dependencies?r.dependencies.concat(n.dependencies):n.dependencies);}return e}var Pr=new Command().name("registry:mcp").description("starts the registry MCP server [DEPRECATED]").option("-c, --cwd <cwd>","the working directory. defaults to the current directory.",process.cwd()).action(async()=>{r.warn(`The ${d.info("shadcn registry:mcp")} command is deprecated. Use the ${d.info("shadcn mcp")} command instead.`),r.break();});var Lo=z$1.object({cwd:z$1.string(),query:z$1.string().optional(),limit:z$1.number().optional(),offset:z$1.number().optional()}),Nr=new Command().name("search").alias("list").description("search items from registries").argument("<registries...>","the registry names or urls to search items from. Names must be prefixed with @.").option("-c, --cwd <cwd>","the working directory. defaults to the current directory.",process.cwd()).option("-q, --query <query>","query string").option("-l, --limit <number>","maximum number of items to display per registry","100").option("-o, --offset <number>","number of items to skip","0").action(async(e,t)=>{try{let i$1=Lo.parse({cwd:E__default.resolve(t.cwd),query:t.query,limit:t.limit?parseInt(t.limit,10):void 0,offset:t.offset?parseInt(t.offset,10):void 0});await L(i$1.cwd);let r=m({style:"new-york",resolvedPaths:{cwd:i$1.cwd}}),o=N(r),n=E__default.resolve(i$1.cwd,"components.json");if(v.existsSync(n)){let l=await v.readJson(n),p=c.partial().parse(l);o=N({...r,...p});}let a=o;try{let l=await i(i$1.cwd);l&&(a=N(l));}catch{}let{config:s,newRegistries:c$1}=await V(e.map(l=>`${l}/registry`),a,{silent:!0,writeFile:!1});c$1.length>0&&(a.registries=s.registries),P(e,a);let m$1=await ja(e,{query:i$1.query,limit:i$1.limit,offset:i$1.offset,config:a});console.log(JSON.stringify(m$1,null,2)),process.exit(0);}catch(i){V$1(i);}finally{O();}});var Wo=z$1.object({cwd:z$1.string()}),Fr=new Command().name("view").description("view items from the registry").argument("<items...>","the item names or URLs to view").option("-c, --cwd <cwd>","the working directory. defaults to the current directory.",process.cwd()).action(async(e,t)=>{try{let i$1=Wo.parse({cwd:E__default.resolve(t.cwd)});await L(i$1.cwd);let r=N({}),o=E__default.resolve(i$1.cwd,"components.json");if(v.existsSync(o)){let m=await v.readJson(o),l=c.partial().parse(m);r=N(l);}let n=r;try{let m=await i(i$1.cwd);m&&(n=N(m));}catch{}let{config:a,newRegistries:s}=await V(e,n,{silent:!0,writeFile:!1});s.length>0&&(n.registries=a.registries),P(e,n);let c$1=await X(e,{config:n});console.log(JSON.stringify(c$1,null,2)),process.exit(0);}catch(i){V$1(i);}finally{O();}});var Ar={version:"3.6.
|
|
86
|
+
Before you can build the registry, you must create a valid ${d.info("components.json")} file by running the ${d.info("init")} command.`),r.break(),process.exit(1);}}var Oo=z$1.object({cwd:z$1.string(),registryFile:z$1.string(),outputDir:z$1.string(),verbose:z$1.boolean().optional().default(false)}),kr=new Command().name("registry:build").description("builds the registry [EXPERIMENTAL]").argument("[registry]","path to registry.json file","./registry.json").option("-o, --output <path>","destination directory for json files","./public/r").option("-c, --cwd <cwd>","the working directory. defaults to the current directory.",process.cwd()).option("-v, --verbose","verbose output").action(async(e,t)=>{await Fo({cwd:E.resolve(t.cwd),registryFile:e,outputDir:t.output,verbose:t.verbose});});async function Fo(e){try{let t=Oo.parse(e),[{errors:i,resolvePaths:r$1,config:o$2},n$1]=await Promise.all([Ir(t),o(t.cwd)]);(i["3"]||!o$2||!n$1)&&(r.error(`A ${d.info("components.json")} file is required to build the registry. Run ${d.info("shadcn init")} to create one.`),r.break(),process.exit(1)),(i["13"]||!r$1)&&(r.error(`We could not find a registry file at ${d.info(E.resolve(t.cwd,t.registryFile))}.`),r.break(),process.exit(1));let a=await z.readFile(r$1.registryFile,"utf-8"),s$1=o$1.safeParse(JSON.parse(a));s$1.success||(r.error(`Invalid registry file found at ${d.info(r$1.registryFile)}.`),r.break(),process.exit(1));let c=s("Building registry..."),m=await Ao(s$1.data,o$2,n$1);for(let l of m.items)l.files=l.files?.filter((p,u,g)=>u===g.findIndex(h=>h.path===p.path)),l.dependencies&&(l.dependencies=l.dependencies.filter((p,u,g)=>u===g.findIndex(h=>h===p)));for(let l of m.items){if(!l.files)continue;c.start(`Building ${l.name}...`),l.$schema="https://ui.shadcn.com/schema/registry-item.json";for(let u of l.files){let g=E.resolve(r$1.cwd,u.path);try{if(!(await z.stat(g)).isFile())continue;u.content=await z.readFile(g,"utf-8");}catch(h){console.error("Error reading file in registry build:",g,h);continue}}let p=n.safeParse(l);if(!p.success){r.error(`Invalid registry item found for ${d.info(l.name)}.`);continue}await z.writeFile(E.resolve(r$1.outputDir,`${p.data.name}.json`),JSON.stringify(p.data,null,2));}if(await z.copyFile(r$1.registryFile,E.resolve(r$1.outputDir,"registry.json")),c.succeed("Building registry."),t.verbose){s(`The registry has ${d.info(m.items.length.toString())} items:`).succeed();for(let l of m.items){r.log(` - ${l.name} (${d.info(l.type)})`);for(let p of l.files??[])r.log(` - ${p.path}`);}}}catch(t){r.break(),V$1(t);}}async function Ao(e,t,i){for(let r of e.items)if(r.files?.length)for(let o of r.files){let n=await K(o.path,t,i);n.files=n.files?.filter(a=>a.path!==o.path),n.files&&r.files.push(...n.files),n.dependencies&&(r.dependencies=r.dependencies?r.dependencies.concat(n.dependencies):n.dependencies);}return e}var Pr=new Command().name("registry:mcp").description("starts the registry MCP server [DEPRECATED]").option("-c, --cwd <cwd>","the working directory. defaults to the current directory.",process.cwd()).action(async()=>{r.warn(`The ${d.info("shadcn registry:mcp")} command is deprecated. Use the ${d.info("shadcn mcp")} command instead.`),r.break();});var Lo=z$1.object({cwd:z$1.string(),query:z$1.string().optional(),limit:z$1.number().optional(),offset:z$1.number().optional()}),Nr=new Command().name("search").alias("list").description("search items from registries").argument("<registries...>","the registry names or urls to search items from. Names must be prefixed with @.").option("-c, --cwd <cwd>","the working directory. defaults to the current directory.",process.cwd()).option("-q, --query <query>","query string").option("-l, --limit <number>","maximum number of items to display per registry","100").option("-o, --offset <number>","number of items to skip","0").action(async(e,t)=>{try{let i$1=Lo.parse({cwd:E__default.resolve(t.cwd),query:t.query,limit:t.limit?parseInt(t.limit,10):void 0,offset:t.offset?parseInt(t.offset,10):void 0});await L(i$1.cwd);let r=m({style:"new-york",resolvedPaths:{cwd:i$1.cwd}}),o=N(r),n=E__default.resolve(i$1.cwd,"components.json");if(v.existsSync(n)){let l=await v.readJson(n),p=c.partial().parse(l);o=N({...r,...p});}let a=o;try{let l=await i(i$1.cwd);l&&(a=N(l));}catch{}let{config:s,newRegistries:c$1}=await V(e.map(l=>`${l}/registry`),a,{silent:!0,writeFile:!1});c$1.length>0&&(a.registries=s.registries),P(e,a);let m$1=await ja(e,{query:i$1.query,limit:i$1.limit,offset:i$1.offset,config:a});console.log(JSON.stringify(m$1,null,2)),process.exit(0);}catch(i){V$1(i);}finally{O();}});var Wo=z$1.object({cwd:z$1.string()}),Fr=new Command().name("view").description("view items from the registry").argument("<items...>","the item names or URLs to view").option("-c, --cwd <cwd>","the working directory. defaults to the current directory.",process.cwd()).action(async(e,t)=>{try{let i$1=Wo.parse({cwd:E__default.resolve(t.cwd)});await L(i$1.cwd);let r=N({}),o=E__default.resolve(i$1.cwd,"components.json");if(v.existsSync(o)){let m=await v.readJson(o),l=c.partial().parse(m);r=N(l);}let n=r;try{let m=await i(i$1.cwd);m&&(n=N(m));}catch{}let{config:a,newRegistries:s}=await V(e,n,{silent:!0,writeFile:!1});s.length>0&&(n.registries=a.registries),P(e,n);let c$1=await X(e,{config:n});console.log(JSON.stringify(c$1,null,2)),process.exit(0);}catch(i){V$1(i);}finally{O();}});var Ar={version:"3.6.23"};process.on("SIGINT",()=>process.exit(0));process.on("SIGTERM",()=>process.exit(0));async function Bo(){let e=new Command().name("shadcn").description("add items from registries to your project").version(Ar.version,"-v, --version","display the version number");e.addCommand(zt).addCommand(mr).addCommand(ir).addCommand(dr).addCommand(Fr).addCommand(Nr).addCommand(Cr).addCommand(ur).addCommand(ar).addCommand(Qe),e.addCommand(kr).addCommand(Pr),e.parse();}Bo();//# sourceMappingURL=index.js.map
|
|
87
87
|
//# sourceMappingURL=index.js.map
|