shadcn 2.9.0 → 2.9.2
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.js +1 -1
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -79,6 +79,6 @@ Existing CSS variables and components will be overwritten. Continue?`)});l||(r.b
|
|
|
79
79
|
`).map(g=>{if(g.trim().startsWith("import "))return g;let b=g;return b=b.replace(/\b(asChild\s*\?\s*)Slot(\s*:)/g,"$1__SLOT_PLACEHOLDER__$2"),b=b.replace(/\bReact\.ComponentProps<typeof\s+Slot>/g,"React.ComponentProps<typeof __SLOT_PLACEHOLDER__>"),b=b.replace(/\bComponentProps<typeof\s+Slot>/g,"ComponentProps<typeof __SLOT_PLACEHOLDER__>"),b=b.replace(/(<\/?)Slot(\s*\/?>)/g,"$1__SLOT_PLACEHOLDER__$2"),b=b.replace(/\bSlot\b/g,(k,v,E)=>{let j=E.substring(0,v),_=(j.match(/"/g)||[]).length,oe=(j.match(/'/g)||[]).length;return _%2!==0||oe%2!==0?k:"__SLOT_PLACEHOLDER__"}),b=b.replace(/__SLOT_PLACEHOLDER__/g,"SlotPrimitive.Slot"),b}).join(`
|
|
80
80
|
`));let h=Array.from(new Set(o));return {content:s,replacedPackages:h}}async function mr(e){let t={};if(!Q.existsSync(e.cwd)||!Q.existsSync(x__default.resolve(e.cwd,"package.json")))return t[A]=!0,{errors:t,config:null};if(!Q.existsSync(x__default.resolve(e.cwd,"components.json")))return t[D]=!0,{errors:t,config:null};try{let r=await h(e.cwd);return {errors:t,config:r}}catch{r.break(),r.error(`An invalid ${a.info("components.json")} file was found at ${a.info(e.cwd)}.
|
|
81
81
|
Before you can run a migration, you must create a valid ${a.info("components.json")} file by running the ${a.info("init")} command.`),r.error(`Learn more at ${a.info("https://ui.shadcn.com/docs/components-json")}.`),r.break(),process.exit(1);}}var dr=[{name:"icons",description:"migrate your ui components to a different icon library."},{name:"radix",description:"migrate to radix-ui."}],po=z.object({cwd:z.string(),list:z.boolean(),yes:z.boolean(),migration:z.string().refine(e=>e&&dr.some(t=>t.name===e),{message:"You must specify a valid migration. Run `shadcn migrate --list` to see available migrations."}).optional()}),ur=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.",!1).option("-y, --yes","skip confirmation prompt.",!1).action(async(e,t)=>{try{let r$1=po.parse({cwd:x__default.resolve(t.cwd),migration:e,list:t.list,yes:t.yes});if(r$1.list||!r$1.migration){r.info("Available migrations:");for(let n of dr)r.info(`- ${n.name}: ${n.description}`);return}if(!r$1.migration)throw new Error("You must specify a migration. Run `shadcn migrate --list` to see available migrations.");let{errors:i,config:o}=await mr(r$1);if(i[A]||i[D])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.");r$1.migration==="icons"&&await lr(o),r$1.migration==="radix"&&await pr(o,{yes:r$1.yes});}catch(r$1){r.break(),x$1(r$1);}});async function gr(e){let t={},r$1={cwd:e.cwd,registryFile:x__default.resolve(e.cwd,e.registryFile),outputDir:x__default.resolve(e.cwd,e.outputDir)};if(!Q.existsSync(r$1.registryFile))return t[q]=!0,{errors:t,resolvePaths:null,config:null};if(!Q.existsSync(x__default.resolve(e.cwd,"components.json")))return t[D]=!0,{errors:t,resolvePaths:null,config:null};await Q.mkdir(r$1.outputDir,{recursive:!0});try{let i=await h(e.cwd);return {errors:t,config:i,resolvePaths:r$1}}catch{r.break(),r.error(`An invalid ${a.info("components.json")} file was found at ${a.info(e.cwd)}.
|
|
82
|
-
Before you can build the registry, you must create a valid ${a.info("components.json")} file by running the ${a.info("init")} command.`),r.break(),process.exit(1);}}var mo=z.object({cwd:z.string(),registryFile:z.string(),outputDir:z.string(),verbose:z.boolean().optional().default(!1)}),hr=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 uo({cwd:x.resolve(t.cwd),registryFile:e,outputDir:t.output,verbose:t.verbose});});async function uo(e){try{let t=mo.parse(e),[{errors:r$1,resolvePaths:i,config:o$1},n]=await Promise.all([gr(t),o(t.cwd)]);(r$1[D]||!o$1||!n)&&(r.error(`A ${a.info("components.json")} file is required to build the registry. Run ${a.info("shadcn init")} to create one.`),r.break(),process.exit(1)),(r$1[q]||!i)&&(r.error(`We could not find a registry file at ${a.info(x.resolve(t.cwd,t.registryFile))}.`),r.break(),process.exit(1));let a$1=await M.readFile(i.registryFile,"utf-8"),s$1=H$1.safeParse(JSON.parse(a$1));s$1.success||(r.error(`Invalid registry file found at ${a.info(i.registryFile)}.`),r.break(),process.exit(1));let c=s("Building registry..."),l=await go(s$1.data,o$1,n);for(let f of l.items)f.files=f.files?.filter((m,u,h)=>u===h.findIndex(y=>y.path===m.path)),f.dependencies&&(f.dependencies=f.dependencies.filter((m,u,h)=>u===h.findIndex(y=>y===m)));for(let f of l.items){if(!f.files)continue;c.start(`Building ${f.name}...`),f.$schema="https://ui.shadcn.com/schema/registry-item.json";for(let u of f.files){let h=x.resolve(i.cwd,u.path);try{if(!(await M.stat(h)).isFile())continue;u.content=await M.readFile(h,"utf-8");}catch(y){console.error("Error reading file in registry build:",h,y);continue}}let m=G.safeParse(f);if(!m.success){r.error(`Invalid registry item found for ${a.info(f.name)}.`);continue}await M.writeFile(x.resolve(i.outputDir,`${m.data.name}.json`),JSON.stringify(m.data,null,2));}if(await M.copyFile(i.registryFile,x.resolve(i.outputDir,"registry.json")),c.succeed("Building registry."),t.verbose){s(`The registry has ${a.info(l.items.length.toString())} items:`).succeed();for(let f of l.items){r.log(` - ${f.name} (${a.info(f.type)})`);for(let m of f.files??[])r.log(` - ${m.path}`);}}}catch(t){r.break(),x$1(t);}}async function go(e,t$1,r){for(let i of e.items)if(i.files?.length)for(let o of i.files){let n=await t(o.path,t$1,r);n.files=n.files?.filter(a=>a.path!==o.path),n.files&&i.files.push(...n.files),n.dependencies&&(i.dependencies=i.dependencies?i.dependencies.concat(n.dependencies):n.dependencies);}return e}var yr=new Command().name("registry:mcp").description("starts the registry MCP server [EXPERIMENTAL]").option("-c, --cwd <cwd>","the working directory. defaults to the current directory.",process.cwd()).action(async()=>{try{let e=new StdioServerTransport;await a$1.connect(e);}catch(e){r.break(),x$1(e);}});var wr={name:"shadcn",version:"2.9.
|
|
82
|
+
Before you can build the registry, you must create a valid ${a.info("components.json")} file by running the ${a.info("init")} command.`),r.break(),process.exit(1);}}var mo=z.object({cwd:z.string(),registryFile:z.string(),outputDir:z.string(),verbose:z.boolean().optional().default(!1)}),hr=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 uo({cwd:x.resolve(t.cwd),registryFile:e,outputDir:t.output,verbose:t.verbose});});async function uo(e){try{let t=mo.parse(e),[{errors:r$1,resolvePaths:i,config:o$1},n]=await Promise.all([gr(t),o(t.cwd)]);(r$1[D]||!o$1||!n)&&(r.error(`A ${a.info("components.json")} file is required to build the registry. Run ${a.info("shadcn init")} to create one.`),r.break(),process.exit(1)),(r$1[q]||!i)&&(r.error(`We could not find a registry file at ${a.info(x.resolve(t.cwd,t.registryFile))}.`),r.break(),process.exit(1));let a$1=await M.readFile(i.registryFile,"utf-8"),s$1=H$1.safeParse(JSON.parse(a$1));s$1.success||(r.error(`Invalid registry file found at ${a.info(i.registryFile)}.`),r.break(),process.exit(1));let c=s("Building registry..."),l=await go(s$1.data,o$1,n);for(let f of l.items)f.files=f.files?.filter((m,u,h)=>u===h.findIndex(y=>y.path===m.path)),f.dependencies&&(f.dependencies=f.dependencies.filter((m,u,h)=>u===h.findIndex(y=>y===m)));for(let f of l.items){if(!f.files)continue;c.start(`Building ${f.name}...`),f.$schema="https://ui.shadcn.com/schema/registry-item.json";for(let u of f.files){let h=x.resolve(i.cwd,u.path);try{if(!(await M.stat(h)).isFile())continue;u.content=await M.readFile(h,"utf-8");}catch(y){console.error("Error reading file in registry build:",h,y);continue}}let m=G.safeParse(f);if(!m.success){r.error(`Invalid registry item found for ${a.info(f.name)}.`);continue}await M.writeFile(x.resolve(i.outputDir,`${m.data.name}.json`),JSON.stringify(m.data,null,2));}if(await M.copyFile(i.registryFile,x.resolve(i.outputDir,"registry.json")),c.succeed("Building registry."),t.verbose){s(`The registry has ${a.info(l.items.length.toString())} items:`).succeed();for(let f of l.items){r.log(` - ${f.name} (${a.info(f.type)})`);for(let m of f.files??[])r.log(` - ${m.path}`);}}}catch(t){r.break(),x$1(t);}}async function go(e,t$1,r){for(let i of e.items)if(i.files?.length)for(let o of i.files){let n=await t(o.path,t$1,r);n.files=n.files?.filter(a=>a.path!==o.path),n.files&&i.files.push(...n.files),n.dependencies&&(i.dependencies=i.dependencies?i.dependencies.concat(n.dependencies):n.dependencies);}return e}var yr=new Command().name("registry:mcp").description("starts the registry MCP server [EXPERIMENTAL]").option("-c, --cwd <cwd>","the working directory. defaults to the current directory.",process.cwd()).action(async()=>{try{let e=new StdioServerTransport;await a$1.connect(e);}catch(e){r.break(),x$1(e);}});var wr={name:"shadcn",version:"2.9.2",description:"Add components to your apps.",publishConfig:{access:"public"},license:"MIT",author:{name:"shadcn",url:"https://twitter.com/shadcn"},repository:{type:"git",url:"https://github.com/shadcn/ui.git",directory:"packages/shadcn"},files:["dist"],keywords:["components","ui","tailwind","radix-ui","shadcn"],type:"module",exports:{".":{types:"./dist/index.d.ts",default:"./dist/index.js"},"./registry":{types:"./dist/registry/index.d.ts",default:"./dist/registry/index.js"},"./mcp":{types:"./dist/mcp/index.d.ts",default:"./dist/mcp/index.js"}},bin:"./dist/index.js",scripts:{dev:"tsup --watch",build:"tsup",typecheck:"tsc --noEmit",clean:"rimraf dist && rimraf components","start:dev":"cross-env REGISTRY_URL=http://localhost:4000/r node dist/index.js","start:prod":"cross-env REGISTRY_URL=https://ui.shadcn.com/r node dist/index.js",start:"node dist/index.js","format:write":'prettier --write "**/*.{ts,tsx,mdx}" --cache',"format:check":'prettier --check "**/*.{ts,tsx,mdx}" --cache',release:"changeset version","pub:beta":"pnpm build && pnpm publish --no-git-checks --access public --tag beta","pub:next":"pnpm build && pnpm publish --no-git-checks --access public --tag next","pub:release":"pnpm build && pnpm publish --access public",test:"vitest run","test:dev":"REGISTRY_URL=http://localhost:4000/r vitest run"},dependencies:{"@antfu/ni":"^23.2.0","@babel/core":"^7.22.1","@babel/parser":"^7.22.6","@babel/plugin-transform-typescript":"^7.22.5","@modelcontextprotocol/sdk":"^1.10.2",commander:"^10.0.0",cosmiconfig:"^8.1.3",deepmerge:"^4.3.1",diff:"^5.1.0",execa:"^7.0.0","fast-glob":"^3.3.2","fs-extra":"^11.1.0","https-proxy-agent":"^6.2.0",kleur:"^4.1.5",msw:"^2.7.1","node-fetch":"^3.3.0",ora:"^6.1.2",postcss:"^8.4.24",prompts:"^2.4.2",recast:"^0.23.2","stringify-object":"^5.0.0","ts-morph":"^18.0.0","tsconfig-paths":"^4.2.0",zod:"^3.20.2","zod-to-json-schema":"^3.24.5"},devDependencies:{"@types/babel__core":"^7.20.1","@types/diff":"^5.0.3","@types/fs-extra":"^11.0.1","@types/prompts":"^2.4.2","@types/stringify-object":"^4.0.5",rimraf:"^6.0.1",tsup:"^6.6.3","type-fest":"^3.8.0",typescript:"^4.9.3"}};process.on("SIGINT",()=>process.exit(0));process.on("SIGTERM",()=>process.exit(0));async function bo(){let e=new Command().name("shadcn").description("add components and dependencies to your project").version(wr.version,"-v, --version","display the version number");e.addCommand(Yt).addCommand(er).addCommand(sr).addCommand(ur).addCommand(ar).addCommand(or),e.addCommand(hr).addCommand(yr),e.parse();}bo();
|
|
83
83
|
//# sourceMappingURL=out.js.map
|
|
84
84
|
//# sourceMappingURL=index.js.map
|