shadcn 4.0.5 → 4.0.7-beta.1
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/{chunk-TVMYBJXJ.js → chunk-2QWB2ZQC.js} +1 -1
- package/dist/{chunk-IBHWVXMI.js → chunk-BRAYUB7V.js} +1 -1
- package/dist/{chunk-BFLSSWBX.js → chunk-HW2MEAJZ.js} +1 -1
- package/dist/index.d.ts +6 -0
- package/dist/index.js +79 -75
- package/dist/mcp/index.js +1 -1
- package/dist/registry/index.js +1 -1
- package/dist/schema/index.d.ts +27 -0
- package/dist/schema/index.js +1 -1
- package/package.json +20 -20
- package/LICENSE.md +0 -21
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {m,l,f,d as d$1,c as c$1,e,n,t,o,b as b$1,p,q as q$1,r,s,x,z as z$1,v as v$1,g}from'./chunk-
|
|
1
|
+
import {m,l,f,d as d$1,c as c$1,e,n,t,o,b as b$1,p,q as q$1,r,s,x,z as z$1,v as v$1,g}from'./chunk-HW2MEAJZ.js';import {a,d,c,b,f as f$1}from'./chunk-JPE2JKEP.js';import y,{basename}from'path';import {z}from'zod';import {promises,existsSync,statSync}from'fs';import {green,cyan,yellow,red}from'kleur/colors';import {loadConfig,createMatchPath}from'tsconfig-paths';import {cosmiconfig}from'cosmiconfig';import Ke from'fast-glob';import ne from'fs-extra';import {tmpdir,homedir}from'os';import Fr from'ora';import {Project,SyntaxKind,ScriptKind,QuoteKind}from'ts-morph';import {transformFromAstSync}from'@babel/core';import {parse}from'@babel/parser';import Vr from'@babel/plugin-transform-typescript';import*as We from'recast';import rs from'prompts';import pe from'deepmerge';import {HttpsProxyAgent}from'https-proxy-agent';import Is from'node-fetch';import {createHash}from'crypto';import ks from'stringify-object';import Zs from'fuzzysort';var G=process.env.REGISTRY_URL??"https://ui.shadcn.com/r",k=G.replace(/\/r\/?$/,""),Ae="new-york-v4",jt=[{name:"neutral",label:"Neutral"},{name:"zinc",label:"Zinc"},{name:"stone",label:"Stone"},{name:"mauve",label:"Mauve"},{name:"olive",label:"Olive"},{name:"mist",label:"Mist"},{name:"taupe",label:"Taupe"}],N={"@shadcn":`${G}/styles/{style}/{name}.json`};var sn=[{name:"toast",deprecatedBy:"sonner",message:"The toast component is deprecated. Use the sonner component instead."},{name:"toaster",deprecatedBy:"sonner",message:"The toaster component is deprecated. Use the sonner component instead."}];function ge(e){return e.replace(/\${(\w+)}/g,(t,r)=>process.env[r]||"")}function de(e){let t=[],r=/\${(\w+)}/g,s;for(;(s=r.exec(e))!==null;)t.push(s[1]);return t}var A={NOT_FOUND:"NOT_FOUND",GONE:"GONE",UNAUTHORIZED:"UNAUTHORIZED",FORBIDDEN:"FORBIDDEN",FETCH_ERROR:"FETCH_ERROR",NOT_CONFIGURED:"NOT_CONFIGURED",INVALID_CONFIG:"INVALID_CONFIG",MISSING_ENV_VARS:"MISSING_ENV_VARS",LOCAL_FILE_ERROR:"LOCAL_FILE_ERROR",PARSE_ERROR:"PARSE_ERROR",VALIDATION_ERROR:"VALIDATION_ERROR",UNKNOWN_ERROR:"UNKNOWN_ERROR"},I=class extends Error{code;statusCode;context;suggestion;timestamp;cause;constructor(t,r={}){super(t),this.name="RegistryError",this.code=r.code||A.UNKNOWN_ERROR,this.statusCode=r.statusCode,this.cause=r.cause,this.context=r.context,this.suggestion=r.suggestion,this.timestamp=new Date,Error.captureStackTrace&&Error.captureStackTrace(this,this.constructor);}toJSON(){return {name:this.name,message:this.message,code:this.code,statusCode:this.statusCode,context:this.context,suggestion:this.suggestion,timestamp:this.timestamp,stack:this.stack}}},J=class extends I{constructor(r,s){let n=`The item at ${r} was not found. It may not exist at the registry.`;super(n,{code:A.NOT_FOUND,statusCode:404,cause:s,context:{url:r},suggestion:"Check if the item name is correct and the registry URL is accessible."});this.url=r;this.name="RegistryNotFoundError";}},Oe=class extends I{constructor(r,s){let n=`The item at ${r} is no longer available. It may have been removed or expired.`;super(n,{code:A.GONE,statusCode:410,cause:s,context:{url:r},suggestion:"This resource was previously available but has been permanently removed. Check if a newer version exists or contact the registry maintainer."});this.url=r;this.name="RegistryGoneError";}},ue=class extends I{constructor(r,s){let n=`You are not authorized to access the item at ${r}. If this is a remote registry, you may need to authenticate.`;super(n,{code:A.UNAUTHORIZED,statusCode:401,cause:s,context:{url:r},suggestion:"Check your authentication credentials and environment variables."});this.url=r;this.name="RegistryUnauthorizedError";}},he=class extends I{constructor(r,s){let n=`You are not authorized to access the item at ${r}. If this is a remote registry, you may need to authenticate.`;super(n,{code:A.FORBIDDEN,statusCode:403,cause:s,context:{url:r},suggestion:"Check your authentication credentials and environment variables."});this.url=r;this.name="RegistryForbiddenError";}},ye=class extends I{constructor(r,s,n,i){let o=s?`Failed to fetch from registry (${s}): ${r}`:`Failed to fetch from registry: ${r}`,a=typeof i=="string"&&i?`${o} - ${i}`:o,l="Check your network connection and try again.";s===404?l="The requested resource was not found. Check the URL or item name.":s===500?l="The registry server encountered an error. Try again later.":s&&s>=400&&s<500&&(l="There was a client error. Check your request parameters.");super(a,{code:A.FETCH_ERROR,statusCode:s,cause:i,context:{url:r,responseBody:n},suggestion:l});this.url=r;this.responseBody=n;this.name="RegistryFetchError";}},W=class extends I{constructor(r){let s=r?`Unknown registry "${r}". Make sure it is defined in components.json as follows:
|
|
2
2
|
{
|
|
3
3
|
"registries": {
|
|
4
4
|
"${r}": "[URL_TO_REGISTRY]"
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {va,ba,f,da}from'./chunk-
|
|
1
|
+
import {va,ba,f,da}from'./chunk-2QWB2ZQC.js';import {Server}from'@modelcontextprotocol/sdk/server/index.js';import {ListToolsRequestSchema,CallToolRequestSchema}from'@modelcontextprotocol/sdk/types.js';import a from'dedent';import {z}from'zod';import {zodToJsonSchema}from'zod-to-json-schema';import {detect}from'@antfu/ni';async function k(n,{withFallback:e}={withFallback:false}){let r=await detect({programmatic:true,cwd:n});if(r==="yarn@berry")return "yarn";if(r==="pnpm@6")return "pnpm";if(r==="bun")return "bun";if(r==="deno")return "deno";if(!e)return r??"npm";let i=process.env.npm_config_user_agent||"";return i.startsWith("yarn")?"yarn":i.startsWith("pnpm")?"pnpm":i.startsWith("bun")?"bun":"npm"}async function b(n){let e=await k(n);return e==="pnpm"?"pnpm dlx":e==="bun"?"bunx":"npx"}var C="shadcn@latest";async function g(n){return `${await b(process.cwd())} ${C} ${n}`}async function u(n=process.cwd()){return {registries:(await da(n,{useCache:false})).registries}}function y(n,e){let{query:r,registries:i}=e||{},s=n.items.map(c=>{let f=[`- ${c.name}`];return c.type&&f.push(`(${c.type})`),c.description&&f.push(`- ${c.description}`),c.registry&&f.push(`[${c.registry}]`),f.push(`
|
|
2
2
|
Add command: \`${g(`add ${c.addCommandArgument}`)}\``),f.join(" ")}),o=`Found ${n.pagination.total} items`;r&&(o+=` matching "${r}"`),i&&i.length>0&&(o+=` in registries ${i.join(", ")}`),o+=":";let m=`Showing items ${n.pagination.offset+1}-${Math.min(n.pagination.offset+n.pagination.limit,n.pagination.total)} of ${n.pagination.total}:`,d=`${o}
|
|
3
3
|
|
|
4
4
|
${m}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import {z as z$1}from'zod';var c=z$1.union([z$1.string().refine(e=>e.includes("{name}"),{message:"Registry URL must include {name} placeholder"}),z$1.object({url:z$1.string().refine(e=>e.includes("{name}"),{message:"Registry URL must include {name} placeholder"}),params:z$1.record(z$1.string(),z$1.string()).optional(),headers:z$1.record(z$1.string(),z$1.string()).optional()})]),l=z$1.record(z$1.string().refine(e=>e.startsWith("@"),{message:"Registry names must start with @ (e.g., @v0, @acme)"}),c),i=z$1.object({$schema:z$1.string().optional(),style:z$1.string(),rsc:z$1.coerce.boolean().default(false),tsx:z$1.coerce.boolean().default(true),tailwind:z$1.object({config:z$1.string().optional(),css:z$1.string(),baseColor:z$1.string(),cssVariables:z$1.boolean().default(true),prefix:z$1.string().default("").optional()}),iconLibrary:z$1.string().optional(),rtl:z$1.coerce.boolean().default(false).optional(),menuColor:z$1.enum(["default","inverted","default-translucent","inverted-translucent"]).default("default").optional(),menuAccent:z$1.enum(["subtle","bold"]).default("subtle").optional(),aliases:z$1.object({components:z$1.string(),utils:z$1.string(),ui:z$1.string().optional(),lib:z$1.string().optional(),hooks:z$1.string().optional()}),registries:l.optional()}).strict(),p=i.extend({resolvedPaths:z$1.object({cwd:z$1.string(),tailwindConfig:z$1.string(),tailwindCss:z$1.string(),utils:z$1.string(),components:z$1.string(),lib:z$1.string(),hooks:z$1.string(),ui:z$1.string()})}),x=z$1.record(p),s=z$1.enum(["registry:lib","registry:block","registry:component","registry:ui","registry:hook","registry:page","registry:file","registry:theme","registry:style","registry:item","registry:base","registry:font","registry:example","registry:internal"]),m=z$1.discriminatedUnion("type",[z$1.object({path:z$1.string(),content:z$1.string().optional(),type:z$1.enum(["registry:file","registry:page"]),target:z$1.string()}),z$1.object({path:z$1.string(),content:z$1.string().optional(),type:s.exclude(["registry:file","registry:page"]),target:z$1.string().optional()})]),y=z$1.object({config:z$1.object({content:z$1.array(z$1.string()).optional(),theme:z$1.record(z$1.string(),z$1.any()).optional(),plugins:z$1.array(z$1.string()).optional()}).optional()}),n=z$1.object({theme:z$1.record(z$1.string(),z$1.string()).optional(),light:z$1.record(z$1.string(),z$1.string()).optional(),dark:z$1.record(z$1.string(),z$1.string()).optional()}),o=z$1.lazy(()=>z$1.union([z$1.string(),z$1.array(z$1.union([z$1.string(),z$1.record(z$1.string(),z$1.string())])),z$1.record(z$1.string(),o)])),d=z$1.record(z$1.string(),o),u=z$1.record(z$1.string(),z$1.string()),a=z$1.object({family:z$1.string(),provider:z$1.literal("google"),import:z$1.string(),variable:z$1.string(),weight:z$1.array(z$1.string()).optional(),subsets:z$1.array(z$1.string()).optional(),selector:z$1.string().optional()}),r=z$1.object({$schema:z$1.string().optional(),extends:z$1.string().optional(),name:z$1.string(),title:z$1.string().optional(),author:z$1.string().min(2).optional(),description:z$1.string().optional(),dependencies:z$1.array(z$1.string()).optional(),devDependencies:z$1.array(z$1.string()).optional(),registryDependencies:z$1.array(z$1.string()).optional(),files:z$1.array(m).optional(),tailwind:y.optional(),cssVars:n.optional(),css:d.optional(),envVars:u.optional(),meta:z$1.record(z$1.string(),z$1.any()).optional(),docs:z$1.string().optional(),categories:z$1.array(z$1.string()).optional()}),g=z$1.discriminatedUnion("type",[r.extend({type:z$1.literal("registry:base"),config:i.deepPartial().optional()}),r.extend({type:z$1.literal("registry:font"),font:a}),r.extend({type:s.exclude(["registry:base","registry:font"])})]),S=z$1.object({name:z$1.string(),homepage:z$1.string(),items:z$1.array(g)}),j=z$1.array(g),I=z$1.array(z$1.object({name:z$1.string(),label:z$1.string()})),C=z$1.record(z$1.string(),z$1.record(z$1.string(),z$1.string())),v=z$1.object({inlineColors:z$1.object({light:z$1.record(z$1.string(),z$1.string()),dark:z$1.record(z$1.string(),z$1.string())}),cssVars:n,cssVarsV4:n.optional(),inlineColorsTemplate:z$1.string(),cssVarsTemplate:z$1.string()}),R=r.pick({dependencies:true,devDependencies:true,files:true,tailwind:true,cssVars:true,css:true,envVars:true,docs:true}).extend({fonts:z$1.array(r.extend({type:z$1.literal("registry:font"),font:a})).optional()}),f=z$1.object({name:z$1.string(),type:z$1.string().optional(),description:z$1.string().optional(),registry:z$1.string(),addCommandArgument:z$1.string()}),V=z$1.object({pagination:z$1.object({total:z$1.number(),offset:z$1.number(),limit:z$1.number(),hasMore:z$1.boolean()}),items:z$1.array(f)}),w=z$1.record(z$1.string().regex(/^@[a-zA-Z0-9][a-zA-Z0-9-_]*$/),z$1.string()),z=z$1.array(z$1.object({name:z$1.string(),homepage:z$1.string().optional(),url:z$1.string(),description:z$1.string().optional()})),h=z$1.object({name:z$1.string(),title:z$1.string(),description:z$1.string(),base:z$1.string(),style:z$1.string(),baseColor:z$1.string(),theme:z$1.string(),iconLibrary:z$1.string(),font:z$1.string(),rtl:z$1.coerce.boolean().default(false),menuAccent:z$1.enum(["subtle","bold"]),menuColor:z$1.enum(["default","inverted","default-translucent","inverted-translucent"]),radius:z$1.string()}),k=z$1.object({presets:z$1.array(h)});export{c as a,l as b,i as c,p as d,x as e,s as f,m as g,y as h,n as i,d as j,u as k,a as l,r as m,g as n,S as o,j as p,I as q,C as r,v as s,R as t,f as u,V as v,w,z as x,h as y,k as z};
|
|
1
|
+
import {z as z$1}from'zod';var c=z$1.union([z$1.string().refine(e=>e.includes("{name}"),{message:"Registry URL must include {name} placeholder"}),z$1.object({url:z$1.string().refine(e=>e.includes("{name}"),{message:"Registry URL must include {name} placeholder"}),params:z$1.record(z$1.string(),z$1.string()).optional(),headers:z$1.record(z$1.string(),z$1.string()).optional()})]),l=z$1.record(z$1.string().refine(e=>e.startsWith("@"),{message:"Registry names must start with @ (e.g., @v0, @acme)"}),c),i=z$1.object({$schema:z$1.string().optional(),style:z$1.string(),rsc:z$1.coerce.boolean().default(false),tsx:z$1.coerce.boolean().default(true),tailwind:z$1.object({config:z$1.string().optional(),css:z$1.string(),baseColor:z$1.string(),cssVariables:z$1.boolean().default(true),prefix:z$1.string().default("").optional()}),iconLibrary:z$1.string().optional(),rtl:z$1.coerce.boolean().default(false).optional(),menuColor:z$1.enum(["default","inverted","default-translucent","inverted-translucent"]).default("default").optional(),menuAccent:z$1.enum(["subtle","bold"]).default("subtle").optional(),aliases:z$1.object({components:z$1.string(),utils:z$1.string(),ui:z$1.string().optional(),lib:z$1.string().optional(),hooks:z$1.string().optional()}),registries:l.optional()}).strict(),p=i.extend({resolvedPaths:z$1.object({cwd:z$1.string(),tailwindConfig:z$1.string(),tailwindCss:z$1.string(),utils:z$1.string(),components:z$1.string(),lib:z$1.string(),hooks:z$1.string(),ui:z$1.string()})}),x=z$1.record(p),s=z$1.enum(["registry:lib","registry:block","registry:component","registry:ui","registry:hook","registry:page","registry:file","registry:theme","registry:style","registry:item","registry:base","registry:font","registry:example","registry:internal"]),m=z$1.discriminatedUnion("type",[z$1.object({path:z$1.string(),content:z$1.string().optional(),type:z$1.enum(["registry:file","registry:page"]),target:z$1.string()}),z$1.object({path:z$1.string(),content:z$1.string().optional(),type:s.exclude(["registry:file","registry:page"]),target:z$1.string().optional()})]),y=z$1.object({config:z$1.object({content:z$1.array(z$1.string()).optional(),theme:z$1.record(z$1.string(),z$1.any()).optional(),plugins:z$1.array(z$1.string()).optional()}).optional()}),n=z$1.object({theme:z$1.record(z$1.string(),z$1.string()).optional(),light:z$1.record(z$1.string(),z$1.string()).optional(),dark:z$1.record(z$1.string(),z$1.string()).optional()}),o=z$1.lazy(()=>z$1.union([z$1.string(),z$1.array(z$1.union([z$1.string(),z$1.record(z$1.string(),z$1.string())])),z$1.record(z$1.string(),o)])),d=z$1.record(z$1.string(),o),u=z$1.record(z$1.string(),z$1.string()),a=z$1.object({family:z$1.string(),provider:z$1.literal("google"),import:z$1.string(),variable:z$1.string(),weight:z$1.array(z$1.string()).optional(),subsets:z$1.array(z$1.string()).optional(),selector:z$1.string().optional(),dependency:z$1.string().optional()}),r=z$1.object({$schema:z$1.string().optional(),extends:z$1.string().optional(),name:z$1.string(),title:z$1.string().optional(),author:z$1.string().min(2).optional(),description:z$1.string().optional(),dependencies:z$1.array(z$1.string()).optional(),devDependencies:z$1.array(z$1.string()).optional(),registryDependencies:z$1.array(z$1.string()).optional(),files:z$1.array(m).optional(),tailwind:y.optional(),cssVars:n.optional(),css:d.optional(),envVars:u.optional(),meta:z$1.record(z$1.string(),z$1.any()).optional(),docs:z$1.string().optional(),categories:z$1.array(z$1.string()).optional()}),g=z$1.discriminatedUnion("type",[r.extend({type:z$1.literal("registry:base"),config:i.deepPartial().optional()}),r.extend({type:z$1.literal("registry:font"),font:a}),r.extend({type:s.exclude(["registry:base","registry:font"])})]),S=z$1.object({name:z$1.string(),homepage:z$1.string(),items:z$1.array(g)}),j=z$1.array(g),I=z$1.array(z$1.object({name:z$1.string(),label:z$1.string()})),C=z$1.record(z$1.string(),z$1.record(z$1.string(),z$1.string())),v=z$1.object({inlineColors:z$1.object({light:z$1.record(z$1.string(),z$1.string()),dark:z$1.record(z$1.string(),z$1.string())}),cssVars:n,cssVarsV4:n.optional(),inlineColorsTemplate:z$1.string(),cssVarsTemplate:z$1.string()}),R=r.pick({dependencies:true,devDependencies:true,files:true,tailwind:true,cssVars:true,css:true,envVars:true,docs:true}).extend({fonts:z$1.array(r.extend({type:z$1.literal("registry:font"),font:a})).optional()}),f=z$1.object({name:z$1.string(),type:z$1.string().optional(),description:z$1.string().optional(),registry:z$1.string(),addCommandArgument:z$1.string()}),V=z$1.object({pagination:z$1.object({total:z$1.number(),offset:z$1.number(),limit:z$1.number(),hasMore:z$1.boolean()}),items:z$1.array(f)}),w=z$1.record(z$1.string().regex(/^@[a-zA-Z0-9][a-zA-Z0-9-_]*$/),z$1.string()),z=z$1.array(z$1.object({name:z$1.string(),homepage:z$1.string().optional(),url:z$1.string(),description:z$1.string().optional()})),h=z$1.object({name:z$1.string(),title:z$1.string(),description:z$1.string(),base:z$1.string(),style:z$1.string(),baseColor:z$1.string(),theme:z$1.string(),iconLibrary:z$1.string(),font:z$1.string(),rtl:z$1.coerce.boolean().default(false),menuAccent:z$1.enum(["subtle","bold"]),menuColor:z$1.enum(["default","inverted","default-translucent","inverted-translucent"]),radius:z$1.string()}),k=z$1.object({presets:z$1.array(h)});export{c as a,l as b,i as c,p as d,x as e,s as f,m as g,y as h,n as i,d as j,u as k,a as l,r as m,g as n,S as o,j as p,I as q,C as r,v as s,R as t,f as u,V as v,w,z as x,h as y,k as z};
|
package/dist/index.d.ts
CHANGED
|
@@ -88,6 +88,7 @@ declare function getRegistry(name: string, options?: {
|
|
|
88
88
|
weight?: string[] | undefined;
|
|
89
89
|
subsets?: string[] | undefined;
|
|
90
90
|
selector?: string | undefined;
|
|
91
|
+
dependency?: string | undefined;
|
|
91
92
|
};
|
|
92
93
|
tailwind?: {
|
|
93
94
|
config?: {
|
|
@@ -248,6 +249,7 @@ declare function getRegistryItems(items: string[], options?: {
|
|
|
248
249
|
weight?: string[] | undefined;
|
|
249
250
|
subsets?: string[] | undefined;
|
|
250
251
|
selector?: string | undefined;
|
|
252
|
+
dependency?: string | undefined;
|
|
251
253
|
};
|
|
252
254
|
tailwind?: {
|
|
253
255
|
config?: {
|
|
@@ -368,6 +370,7 @@ declare function resolveRegistryItems(items: string[], options?: {
|
|
|
368
370
|
weight?: string[] | undefined;
|
|
369
371
|
subsets?: string[] | undefined;
|
|
370
372
|
selector?: string | undefined;
|
|
373
|
+
dependency?: string | undefined;
|
|
371
374
|
};
|
|
372
375
|
tailwind?: {
|
|
373
376
|
config?: {
|
|
@@ -495,6 +498,7 @@ declare function getShadcnRegistryIndex(): Promise<({
|
|
|
495
498
|
weight?: string[] | undefined;
|
|
496
499
|
subsets?: string[] | undefined;
|
|
497
500
|
selector?: string | undefined;
|
|
501
|
+
dependency?: string | undefined;
|
|
498
502
|
};
|
|
499
503
|
tailwind?: {
|
|
500
504
|
config?: {
|
|
@@ -699,6 +703,7 @@ declare function resolveTree(index: z.infer<typeof registryIndexSchema>, names:
|
|
|
699
703
|
weight?: string[] | undefined;
|
|
700
704
|
subsets?: string[] | undefined;
|
|
701
705
|
selector?: string | undefined;
|
|
706
|
+
dependency?: string | undefined;
|
|
702
707
|
};
|
|
703
708
|
tailwind?: {
|
|
704
709
|
config?: {
|
|
@@ -858,6 +863,7 @@ declare function fetchTree(style: string, tree: z.infer<typeof registryIndexSche
|
|
|
858
863
|
weight?: string[] | undefined;
|
|
859
864
|
subsets?: string[] | undefined;
|
|
860
865
|
selector?: string | undefined;
|
|
866
|
+
dependency?: string | undefined;
|
|
861
867
|
};
|
|
862
868
|
tailwind?: {
|
|
863
869
|
config?: {
|