shadcn 4.0.6 → 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 +12 -12
- 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?: {
|
package/dist/index.js
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
import {b as b$1,a as a$1}from'./chunk-
|
|
2
|
+
import {b as b$1,a as a$1}from'./chunk-BRAYUB7V.js';import {o,n}from'./chunk-ISTYEIAA.js';import {b,a,G,ra,ua,c as c$1,$,V,sa,N,O,w,d,P,M,fa,ha,K as K$1,L,I,J,ta as ta$1,T,ba,H,e,ea,ka,ia,la,B as B$1,S,ma,U as U$1,W,va,_ as _$1,X as X$1,na,ga,qa,q as q$1,Z,k,R,Y as Y$1,Q,D as D$1,E,F,s,x,y,A as A$1,C,z as z$1,r,t,v,u}from'./chunk-2QWB2ZQC.js';export{ka as fetchTree,la as getItemTargetPath,pa as getPreset,oa as getPresets,ma as getRegistries,da as getRegistriesConfig,na as getRegistriesIndex,aa as getRegistry,ia as getRegistryBaseColor,ha as getRegistryBaseColors,ga as getRegistryIcons,ba as getRegistryItems,fa as getRegistryStyles,ea as getShadcnRegistryIndex,ca as resolveRegistryItems,ja as resolveTree}from'./chunk-2QWB2ZQC.js';import {c,o as o$1,n as n$1}from'./chunk-HW2MEAJZ.js';import {e as e$1,a as a$3,c as c$2,f,d as d$1}from'./chunk-JPE2JKEP.js';import {a as a$2}from'./chunk-CHWMSXYA.js';import*as te from'path';import te__default,{join}from'path';import {promises,existsSync}from'fs';import Qt from'fast-glob';import A from'fs-extra';import So from'open';import pe from'prompts';import cn from'dedent';import Io,{tmpdir}from'os';import {execa}from'execa';import k$1 from'postcss';import Oo from'postcss/lib/at-rule';import qt,{z}from'zod';import {twMerge}from'tailwind-merge';import {Project,ScriptKind,SyntaxKind,VariableDeclarationKind}from'ts-morph';import an from'deepmerge';import {Command}from'commander';import {diffLines,structuredPatch,diffWords}from'diff';import {dim,yellow,bold,green,cyan,red}from'kleur/colors';import*as ve from'fs/promises';import ve__default from'fs/promises';import {StdioServerTransport}from'@modelcontextprotocol/sdk/server/stdio.js';import {randomBytes}from'crypto';var bo=["next.config.*","vite.config.*","astro.config.*","remix.config.*","nuxt.config.*","svelte.config.*","gatsby-config.*","angular.json"];async function Y(e){if(A.existsSync(te__default.resolve(e,"pnpm-workspace.yaml")))return true;let t=te__default.resolve(e,"package.json");if(A.existsSync(t))try{if((await A.readJson(t)).workspaces)return !0}catch{}return !!(A.existsSync(te__default.resolve(e,"lerna.json"))||A.existsSync(te__default.resolve(e,"nx.json")))}async function K(e){let t=await xo(e);if(!t.length)return [];let r=await Qt(t,{cwd:e,onlyDirectories:true,ignore:["**/node_modules/**"]}),n=[];for(let i of r){let o=te__default.resolve(e,i);if(!A.existsSync(te__default.resolve(o,"package.json")))continue;let s=A.existsSync(te__default.resolve(o,"components.json")),c=bo.some(a=>Qt.sync(a,{cwd:o,dot:true}).length>0);(s||c)&&n.push({name:i,hasConfig:s});}return n}function q(e,t){b.break(),b.log(`It looks like you are running ${a.info(e)} from a monorepo root.`),b.log(`To use shadcn in a specific workspace, use the ${a.info("-c")} flag:`),b.break();for(let r of t)b.log(` shadcn ${e} -c ${r.name}`);b.break();}async function xo(e){let t=[],r=te__default.resolve(e,"pnpm-workspace.yaml");if(A.existsSync(r)){let i=await A.readFile(r,"utf8"),o=Array.from(i.matchAll(/^\s*-\s*["']?([^"'\n#]+)["']?\s*$/gm));for(let s of o)t.push(s[1].trim());}let n=te__default.resolve(e,"package.json");if(A.existsSync(n))try{let i=await A.readJson(n),o=Array.isArray(i.workspaces)?i.workspaces:i.workspaces?.packages;Array.isArray(o)&&t.push(...o.filter(s=>!s.startsWith("!")));}catch{}return Array.from(new Set(t))}async function Jr(e){let t={};if(!A.existsSync(e.cwd)||!A.existsSync(te__default.resolve(e.cwd,"package.json")))return t["1"]=true,{errors:t,projectInfo:null};let r=w("Preflight checks.",{silent:e.silent}).start();A.existsSync(te__default.resolve(e.cwd,"components.json"))&&!e.force&&(r?.fail(),b.break(),b.error(`A ${a.info("components.json")} file already exists at ${a.info(e.cwd)}.
|
|
3
3
|
To start over, remove the ${a.info("components.json")} file and run ${a.info("init")} again.`),b.break(),process.exit(1)),r?.succeed();let n=w("Verifying framework.",{silent:e.silent}).start(),i=e.existingConfig?.tailwind,o=await ra(e.cwd,{configCssFile:typeof i?.css=="string"?i.css:void 0});if(!o||o?.framework.name==="manual"){if(t["7"]=true,n?.fail(),!e.monorepo&&await Y(e.cwd)){let f=await K(e.cwd);f.length>0&&(q("init",f),process.exit(1));}b.break(),o?.framework.links.installation&&b.error(`We could not detect a supported framework at ${a.info(e.cwd)}.
|
|
4
4
|
Visit ${a.info(o?.framework.links.installation)} to manually configure your project.
|
|
5
5
|
Once configured, you can use the cli to add components.`),b.break(),process.exit(1);}n?.succeed(`Verifying framework. Found ${a.info(o.framework.label)}.`);let s="Validating Tailwind CSS.";o.tailwindVersion==="v4"&&(s=`Validating Tailwind CSS. Found ${a.info("v4")}.`);let c=w(s,{silent:e.silent}).start();o.tailwindVersion==="v3"&&(!o?.tailwindConfigFile||!o?.tailwindCssFile)?(t["5"]=true,c?.fail()):o.tailwindVersion==="v4"&&!o?.tailwindCssFile?(t["5"]=true,c?.fail()):o.tailwindVersion?c?.succeed():(t["5"]=true,c?.fail());let a$1=w("Validating import alias.",{silent:e.silent}).start();return o?.aliasPrefix?a$1?.succeed():(t["6"]=true,a$1?.fail()),Object.keys(t).length>0&&(t["5"]&&(b.break(),b.error(`No Tailwind CSS configuration found at ${a.info(e.cwd)}.`),b.error("It is likely you do not have Tailwind CSS installed or have an invalid configuration."),b.error("Install Tailwind CSS then try again."),o?.framework.links.tailwind&&b.error(`Visit ${a.info(o?.framework.links.tailwind)} to get started.`)),t["6"]&&(b.break(),b.error("No import alias found in your tsconfig.json file."),o?.framework.links.installation&&b.error(`Visit ${a.info(o?.framework.links.installation)} to learn how to set an import alias.`)),b.break(),process.exit(1)),{errors:t,projectInfo:o}}async function Gr(e,t){let r=new Set,n=new Set,i=[...e];for(;i.length>0;){let o=i.shift();if(n.has(o))continue;n.add(o);let{registry:s}=q$1(o);s&&!d[s]&&r.add(s);try{let[c]=await Z([o],t,{useCache:!0});if(c?.registryDependencies)for(let a of c.registryDependencies){let{registry:f}=q$1(a);f&&!d[f]&&r.add(f),n.has(a)||i.push(a);}}catch(c){if(c instanceof k){let{registry:a}=q$1(o);a&&!d[a]&&r.add(a);continue}continue}}return Array.from(r)}async function _(e,t,r={}){r={silent:false,writeFile:true,...r};let i=(await Gr(e,t)).filter(f=>!t.registries?.[f]&&!Object.keys(d).includes(f));if(i.length===0)return {config:t,newRegistries:[]};let o=await na({useCache:process.env.NODE_ENV!=="development"});if(!o)return {config:t,newRegistries:[]};let s={};for(let f of i)o[f]&&(s[f]=o[f]);if(Object.keys(s).length===0)return {config:t,newRegistries:[]};let c$1=Object.fromEntries(Object.entries(t.registries||{}).filter(([f])=>!Object.keys(d).includes(f))),a={...t,registries:{...c$1,...s}};if(r.writeFile){let{resolvedPaths:f,...l}=a,m=w("Updating components.json.",{silent:r.silent}).start(),d=c.parse(l);await A.writeFile(te__default.resolve(t.resolvedPaths.cwd,"components.json"),JSON.stringify(d,null,2)+`
|
|
6
|
-
`,"utf-8"),m.succeed();}return {config:a,newRegistries:Object.keys(s)}}var _e={nova:{title:"Nova",description:"Lucide / Geist",style:"nova",baseColor:"neutral",theme:"neutral",iconLibrary:"lucide",font:"geist",menuAccent:"subtle",menuColor:"default",radius:"default",rtl:false},vega:{title:"Vega",description:"Lucide / Inter",style:"vega",baseColor:"neutral",theme:"neutral",iconLibrary:"lucide",font:"inter",menuAccent:"subtle",menuColor:"default",radius:"default",rtl:false},maia:{title:"Maia",description:"Hugeicons / Figtree",style:"maia",baseColor:"neutral",theme:"neutral",iconLibrary:"hugeicons",font:"figtree",menuAccent:"subtle",menuColor:"default",radius:"default",rtl:false},lyra:{title:"Lyra",description:"Phosphor / JetBrains Mono",style:"lyra",baseColor:"neutral",theme:"neutral",iconLibrary:"phosphor",font:"jetbrains-mono",menuAccent:"subtle",menuColor:"default",radius:"default",rtl:false},mira:{title:"Mira",description:"Hugeicons / Inter",style:"mira",baseColor:"neutral",theme:"neutral",iconLibrary:"hugeicons",font:"inter",menuAccent:"subtle",menuColor:"default",radius:"default",rtl:false}};function ko(e){let t=new URL(`${c$1}/create`),{rtl:r,...n}=e??{};for(let[i,o]of Object.entries(n))o!==void 0&&t.searchParams.set(i,String(o));return r&&t.searchParams.set("rtl","true"),t.toString()}function Ve(e,t){let r=new URLSearchParams({base:e.base,style:e.style,baseColor:e.baseColor,theme:e.theme,iconLibrary:e.iconLibrary,font:e.font,rtl:String(e.rtl??false),menuAccent:e.menuAccent,menuColor:e.menuColor,radius:e.radius});return t?.template&&r.set("template",t.template),r.set("track","1"),`${c$1}/init?${r.toString()}`}async function Ie(){let{base:e}=await pe({type:"select",name:"base",message:`Select a ${a.info("component library")}`,choices:[{title:"Radix",value:"radix"},{title:"Base",value:"base"}]});return e||process.exit(1),e}async function We(e){let t=Object.entries(_e),{selectedPreset:r}=await pe({type:"select",name:"selectedPreset",message:`Which ${a.info("preset")} would you like to use?`,choices:[...t.map(([i,o])=>({title:o.title,description:o.description,value:i})),{title:"Custom",description:`Build your own at ${a.info(`${c$1}/create`)}`,value:"custom"}]});if(r||process.exit(1),r==="custom"){let i=ko({command:"init",rtl:e.rtl,base:e.base,...e.template&&{template:e.template}});b.break(),b.log(` Build your custom preset on ${a.info(i)}`),b.log(` Then ${a.info("copy and run the command")} from ui.shadcn.com.`),b.break();let{proceed:o}=await pe({type:"confirm",name:"proceed",message:"Open in browser?",initial:true});o&&await So(i),process.exit(0);}let n=_e[r];return n||process.exit(1),{url:Ve({...n,base:e.base,rtl:e.rtl},{template:e.template}),base:e.base}}async function Me(e,t,r){let n=U$1(T({resolvedPaths:{cwd:t},...r?.registries&&{registries:r.registries}})),{config:i}=await _([e],n,{silent:true,writeFile:false});n=i,X$1(e,n);let[o]=await ba([e],{config:n,useCache:true}),s=o?.type==="registry:base"&&o.config?o.config:void 0,c=e;if($o(e)){let a=new URL(e);a.searchParams.delete("track"),c=a.toString();}return {registryBaseConfig:s,installStyleIndex:o?.extends!=="none",url:c}}function $o(e){try{return new URL(e).pathname==="/init"&&e.startsWith(c$1)}catch{return false}}var Po=process.env.SHADCN_GITHUB_URL??"https://github.com/shadcn-ui/ui.git";function U(e){return {...e,frameworks:e.frameworks??[],scaffold:e.scaffold??Yr({title:e.title,templateDir:e.templateDir}),postInit:e.postInit??
|
|
6
|
+
`,"utf-8"),m.succeed();}return {config:a,newRegistries:Object.keys(s)}}var _e={nova:{title:"Nova",description:"Lucide / Geist",style:"nova",baseColor:"neutral",theme:"neutral",iconLibrary:"lucide",font:"geist",menuAccent:"subtle",menuColor:"default",radius:"default",rtl:false},vega:{title:"Vega",description:"Lucide / Inter",style:"vega",baseColor:"neutral",theme:"neutral",iconLibrary:"lucide",font:"inter",menuAccent:"subtle",menuColor:"default",radius:"default",rtl:false},maia:{title:"Maia",description:"Hugeicons / Figtree",style:"maia",baseColor:"neutral",theme:"neutral",iconLibrary:"hugeicons",font:"figtree",menuAccent:"subtle",menuColor:"default",radius:"default",rtl:false},lyra:{title:"Lyra",description:"Phosphor / JetBrains Mono",style:"lyra",baseColor:"neutral",theme:"neutral",iconLibrary:"phosphor",font:"jetbrains-mono",menuAccent:"subtle",menuColor:"default",radius:"default",rtl:false},mira:{title:"Mira",description:"Hugeicons / Inter",style:"mira",baseColor:"neutral",theme:"neutral",iconLibrary:"hugeicons",font:"inter",menuAccent:"subtle",menuColor:"default",radius:"default",rtl:false}};function ko(e){let t=new URL(`${c$1}/create`),{rtl:r,...n}=e??{};for(let[i,o]of Object.entries(n))o!==void 0&&t.searchParams.set(i,String(o));return r&&t.searchParams.set("rtl","true"),t.toString()}function Ve(e,t){let r=new URLSearchParams({base:e.base,style:e.style,baseColor:e.baseColor,theme:e.theme,iconLibrary:e.iconLibrary,font:e.font,rtl:String(e.rtl??false),menuAccent:e.menuAccent,menuColor:e.menuColor,radius:e.radius});return t?.template&&r.set("template",t.template),r.set("track","1"),`${c$1}/init?${r.toString()}`}async function Ie(){let{base:e}=await pe({type:"select",name:"base",message:`Select a ${a.info("component library")}`,choices:[{title:"Radix",value:"radix"},{title:"Base",value:"base"}]});return e||process.exit(1),e}async function We(e){let t=Object.entries(_e),{selectedPreset:r}=await pe({type:"select",name:"selectedPreset",message:`Which ${a.info("preset")} would you like to use?`,choices:[...t.map(([i,o])=>({title:o.title,description:o.description,value:i})),{title:"Custom",description:`Build your own at ${a.info(`${c$1}/create`)}`,value:"custom"}]});if(r||process.exit(1),r==="custom"){let i=ko({command:"init",rtl:e.rtl,base:e.base,...e.template&&{template:e.template}});b.break(),b.log(` Build your custom preset on ${a.info(i)}`),b.log(` Then ${a.info("copy and run the command")} from ui.shadcn.com.`),b.break();let{proceed:o}=await pe({type:"confirm",name:"proceed",message:"Open in browser?",initial:true});o&&await So(i),process.exit(0);}let n=_e[r];return n||process.exit(1),{url:Ve({...n,base:e.base,rtl:e.rtl},{template:e.template}),base:e.base}}async function Me(e,t,r){let n=U$1(T({resolvedPaths:{cwd:t},...r?.registries&&{registries:r.registries}})),{config:i}=await _([e],n,{silent:true,writeFile:false});n=i,X$1(e,n);let[o]=await ba([e],{config:n,useCache:true}),s=o?.type==="registry:base"&&o.config?o.config:void 0,c=e;if($o(e)){let a=new URL(e);a.searchParams.delete("track"),c=a.toString();}return {registryBaseConfig:s,installStyleIndex:o?.extends!=="none",url:c}}function $o(e){try{return new URL(e).pathname==="/init"&&e.startsWith(c$1)}catch{return false}}var Po=process.env.SHADCN_GITHUB_URL??"https://github.com/shadcn-ui/ui.git";function U(e){return {...e,frameworks:e.frameworks??[],scaffold:e.scaffold??Yr({title:e.title,templateDir:e.templateDir}),postInit:e.postInit??Fo}}function he(e,{monorepo:t}){if(!t||!e.monorepo)return e;let r=e.monorepo,n={...e,templateDir:r.templateDir,defaultProjectName:r.defaultProjectName??r.templateDir,init:r.init??e.init,files:r.files??e.files};return n.scaffold=Yr({title:e.title,templateDir:r.templateDir}),n}function jo(e){switch(e){case "pnpm":return ["--no-frozen-lockfile"];default:return []}}async function Eo(e,t){if(t==="pnpm")return;let r=te__default.join(e,"pnpm-workspace.yaml"),n=te__default.join(e,"package.json"),i=te__default.join(e,"pnpm-lock.yaml");A.existsSync(i)&&await A.remove(i);let o=A.existsSync(r);if(A.existsSync(n)){let s=await A.readFile(n,"utf8"),c=JSON.parse(s);if(delete c.packageManager,o){let a=await A.readFile(r,"utf8"),f=[];for(let l of a.split(`
|
|
7
7
|
`)){let m=l.match(/^\s*-\s*["']?(.+?)["']?\s*$/);m&&f.push(m[1]);}c.workspaces=f,await A.remove(r);}await A.writeFile(n,JSON.stringify(c,null,2)+`
|
|
8
8
|
`);}o&&t==="npm"&&await Hr(e);}async function Hr(e){let t=await A.readdir(e,{withFileTypes:true});for(let r of t){if(r.name==="node_modules")continue;let n=te__default.join(e,r.name);if(r.isDirectory())await Hr(n);else if(r.name==="package.json"){let i=await A.readFile(n,"utf8");if(!i.includes("workspace:"))continue;let o=JSON.parse(i),s=false;for(let c of ["dependencies","devDependencies","peerDependencies","optionalDependencies"]){let a=o[c];if(a)for(let[f,l]of Object.entries(a))typeof l=="string"&&l.startsWith("workspace:")&&(a[f]="*",s=true);}s&&await A.writeFile(n,JSON.stringify(o,null,2)+`
|
|
9
9
|
`);}}}function Yr({title:e,templateDir:t}){return async({projectPath:r,packageManager:n})=>{let i=w(`Creating a new ${e} project. This may take a few minutes.`).start();try{let o=process.env.SHADCN_TEMPLATE_DIR;if(o){let f=te__default.resolve(o,t);await A.copy(f,r,{filter:l=>!l.includes("node_modules")});}else {let f=te__default.join(Io.tmpdir(),`shadcn-template-${Date.now()}`);await execa("git",["clone","--depth","1","--filter=blob:none","--sparse",Po,f]),await execa("git",["-C",f,"sparse-checkout","set",`templates/${t}`]);let l=te__default.resolve(f,"templates",t);await A.move(l,r),await A.remove(f);}await Eo(r,n);let c=["install",...jo(n)];await execa(n,c,{cwd:r});let a=te__default.join(r,"package.json");if(A.existsSync(a)){let f=await A.readFile(a,"utf8"),l=JSON.parse(f);l.name=te__default.basename(r),await A.writeFile(a,JSON.stringify(l,null,2)+`
|
|
10
|
-
`);}i?.succeed(`Creating a new ${e} project.`);}catch(o){i?.fail(`Something went wrong creating a new ${e} project.`),$(o);}}}async function
|
|
10
|
+
`);}i?.succeed(`Creating a new ${e} project.`);}catch(o){i?.fail(`Something went wrong creating a new ${e} project.`),$(o);}}}async function Fo({projectPath:e}){try{await execa("git",["init"],{cwd:e}),await execa("git",["add","-A"],{cwd:e}),await execa("git",["commit","-m","feat: initial commit"],{cwd:e});}catch{}}function Kr(e,t){if(e.includes("\0"))return false;let r;try{r=e;let d="";for(;r!==d&&r.includes("%");)d=r,r=decodeURIComponent(r);}catch{return false}let n=te__default.normalize(r.replace(/\\/g,"/")),i=te__default.normalize(t),o=d=>d.replace(/\[\.\.\..*?\]/g,"").includes("..");if(o(n)||o(r)||o(e))return false;let s=d=>d.replace(/\[\.\.\..*?\]/g,""),c=s(e),a=s(r);if([/\.\.[\/\\]/,/[\/\\]\.\./,/\.\./,/\.\.%/,/\x00/,/[\x01-\x1f]/].some(d=>d.test(c)||d.test(a))||(e.includes("~")||r.includes("~"))&&(e.includes("../")||r.includes("../")))return false;if(/^[a-zA-Z]:[\/\\]/.test(r))return process.platform==="win32"?r.toLowerCase().startsWith(t.toLowerCase()):false;if(te__default.isAbsolute(n))return n.startsWith(i+te__default.sep);let m=te__default.resolve(i,n);return m.startsWith(i+te__default.sep)||m===i}async function pt(e,t,r){if(!t.resolvedPaths.tailwindCss||!Object.keys(e??{}).length)return;r={cleanupDefaultNextStyles:false,silent:false,tailwindVersion:"v3",overwriteCssVars:false,...r};let n=t.resolvedPaths.tailwindCss,i=te__default.relative(t.resolvedPaths.cwd,n),o=w(`Updating CSS variables in ${a.info(i)}`,{silent:r.silent}).start(),s=await promises.readFile(n,"utf8"),c=await Ue(s,e??{},t,{cleanupDefaultNextStyles:r.cleanupDefaultNextStyles,tailwindVersion:r.tailwindVersion,tailwindConfig:r.tailwindConfig,overwriteCssVars:r.overwriteCssVars});await promises.writeFile(n,c,"utf8"),o.succeed();}async function Ue(e,t,r,n={cleanupDefaultNextStyles:false,tailwindVersion:"v3",tailwindConfig:void 0,overwriteCssVars:false}){n={cleanupDefaultNextStyles:false,tailwindVersion:"v3",tailwindConfig:void 0,overwriteCssVars:false,...n};let i=[To(t)];n.cleanupDefaultNextStyles&&i.push(Zr()),n.tailwindVersion==="v4"&&(i=[],i.push(_o({params:"dark (&:is(.dark *))"})),n.cleanupDefaultNextStyles&&i.push(Zr()),i.push(Do(t,{overwriteCssVars:n.overwriteCssVars})),i.push(Lo(t)),n.tailwindConfig&&(i.push(Vo(n.tailwindConfig)),i.push(Mo(n.tailwindConfig)),i.push(Wo(n.tailwindConfig))));let s=(await k$1(i).process(e,{from:void 0})).css;return s=s.replace(/\/\* ---break--- \*\//g,""),n.tailwindVersion==="v4"&&(s=s.replace(/(\n\s*\n)+/g,`
|
|
11
11
|
|
|
12
12
|
`)),s}function To(e){return {postcssPlugin:"update-css-vars",Once(t){let r=t.nodes.find(n=>n.type==="atrule"&&n.name==="layer"&&n.params==="base");r instanceof Oo||(r=k$1.atRule({name:"layer",params:"base",nodes:[],raws:{semicolon:true,before:`
|
|
13
13
|
`,between:" "}}),t.append(r),t.insertBefore(r,k$1.comment({text:"---break---"}))),r!==void 0&&Object.entries(e).forEach(([n,i])=>{let o=n==="light"?":root":`.${n}`;Ao(r,o,i);});}}}function Xr(e){let t=e.nodes.find(r=>r.type==="rule"&&r.selector===":root");if(t){let r=["--background","--foreground"];t.nodes.filter(n=>n.type==="decl"&&r.includes(n.prop)).forEach(n=>n.remove()),t.nodes.length===0&&t.remove();}}function Zr(){return {postcssPlugin:"cleanup-default-next-styles",Once(e){let t=e.nodes.find(n=>n.type==="rule"&&n.selector==="body");t&&(t.nodes.find(n=>n.type==="decl"&&n.prop==="color"&&["rgb(var(--foreground-rgb))","var(--foreground)"].includes(n.value))?.remove(),t.nodes.find(n=>n.type==="decl"&&n.prop==="background"&&(n.value.startsWith("linear-gradient")||n.value==="var(--background)"))?.remove(),t.nodes.find(n=>n.type==="decl"&&n.prop==="font-family"&&n.value==="Arial, Helvetica, sans-serif")?.remove(),t.nodes.length===0&&t.remove()),Xr(e);let r=e.nodes.find(n=>n.type==="atrule"&&n.params==="(prefers-color-scheme: dark)");r&&(Xr(r),r.nodes.length===0&&r.remove());}}}function Ao(e,t,r){let n=e.nodes?.find(i=>i.type==="rule"&&i.selector===t);n||Object.keys(r).length>0&&(n=k$1.rule({selector:t,raws:{between:" ",before:`
|
|
@@ -43,8 +43,8 @@ It looks like you are using React 19.
|
|
|
43
43
|
Some packages may fail to install due to peer dependency issues in npm (see ${c$1}/react-19).
|
|
44
44
|
`);let c=await pe([{type:"select",name:"flag",message:"How would you like to proceed?",choices:[{title:"Use --force",value:"force"},{title:"Use --legacy-peer-deps",value:"legacy-peer-deps"}]}]);c&&(s=c.flag);}i?.start(),await qo(o,e,t,r.resolvedPaths.cwd,s),i?.succeed();}function Yo(e){let t=qa(e.resolvedPaths.cwd,false);if(!t?.dependencies?.react)return false;let r=/^(?:\^|~)?19(?:\.\d+)*(?:-.*)?$/.test(t.dependencies.react),n=t.dependencies["react-day-picker"]?.startsWith("8");return r&&n}async function Ko(e){return qa(e.resolvedPaths.cwd,false)?.dependencies?.expo?"expo":a$1(e.resolvedPaths.cwd)}async function qo(e,t,r,n,i){if(e==="npm")return Xo(t,r,n,i);if(e==="deno")return Zo(t,r,n);if(e==="expo")return Qo(t,r,n);t?.length&&await execa(e,["add",...t],{cwd:n}),r?.length&&await execa(e,["add","-D",...r],{cwd:n});}async function Xo(e,t,r,n){e.length&&await execa("npm",["install",...n?[`--${n}`]:[],...e],{cwd:r}),t.length&&await execa("npm",["install",...n?[`--${n}`]:[],"-D",...t],{cwd:r});}async function Zo(e,t,r){e?.length&&await execa("deno",["add",...e.map(n=>`npm:${n}`)],{cwd:r}),t?.length&&await execa("deno",["add","-D",...t.map(n=>`npm:${n}`)],{cwd:r});}async function Qo(e,t,r){e.length&&await execa("npx",["expo","install",...e],{cwd:r}),t.length&&await execa("npx",["expo","install","-- -D",...t],{cwd:r});}async function Mt(e,t$1,r){if(!e||Object.keys(e).length===0)return {envVarsAdded:[],envFileUpdated:null,envFileCreated:null};r={silent:false,...r};let n=w("Adding environment variables.",{silent:r.silent})?.start(),i=t$1.resolvedPaths.cwd,o=te__default.join(i,".env.local"),s=t(i);s&&(o=s);let c=existsSync(o),a$1=te__default.basename(o),f=Object.entries(e).map(([h,g])=>`${h}=${g}`).join(`
|
|
45
45
|
`),l=[],m=null,d=null;if(c){let h=await promises.readFile(o,"utf-8"),g=v(h,f);if(l=u(h,f),l.length>0){if(await promises.writeFile(o,g,"utf-8"),m=te__default.relative(i,o),n?.succeed(`Added the following variables to ${a.info(a$1)}:`),!r.silent)for(let w of l)b.log(` ${a.success("+")} ${w}`);}else n?.stop();}else if(await promises.writeFile(o,f+`
|
|
46
|
-
`,"utf-8"),d=te__default.relative(i,o),l=Object.keys(e),n?.succeed(`Added the following variables to ${a.info(a$1)}:`),!r.silent)for(let h of l)b.log(` ${a.success("+")} ${h}`);return !r.silent&&l.length>0&&b.break(),{envVarsAdded:l,envFileUpdated:m,envFileCreated:d}}async function Je(e,t){if(!e.fonts?.length)return e;let r=await ra(t.resolvedPaths.cwd);if(!r)return e;e.cssVars??={},e.cssVars.theme??={};let n=r.framework.name==="next-app"||r.framework.name==="next-pages";for(let i of e.fonts)if(n)e.cssVars.theme[i.font.variable]=`var(${i.font.variable})`;else {let
|
|
47
|
-
`);}s.push(g),m.font.selector||c.push(m.font.variable.replace("--",""));}let a=new Set(["font-sans","font-serif","font-mono"]),f=[...c].reverse().find(m=>a.has(m)),l=c.filter(m=>!a.has(m));return f&&l.unshift(f),s.length>0&&mi(i,s,l,r),i.getFullText()}function li(e){let t={};return e.font.subsets?.length&&(t.subsets=e.font.subsets),e.font.weight?.length&&(t.weight=e.font.weight),t.variable=e.font.variable,JSON.stringify(t).replace(/"([^"]+)":/g,"$1:").replace(/"/g,"'")}function fi(e){return e.split("_").map((t,r)=>r===0?t.toLowerCase():t.charAt(0).toUpperCase()+t.slice(1).toLowerCase()).join("")}function nn(e,t){let r=e.getVariableStatements();for(let n of r)for(let i of n.getDeclarations()){let o=i.getInitializer();if(!o||o.getKind()!==SyntaxKind.CallExpression)continue;let c=o.getArguments();if(c.length===0)continue;let a=c[0].getText();if(a.includes("variable:")&&a.includes(t))return i}return null}function pi(e){let t=e.getImportDeclarations();return t.length>0?t[t.length-1].getChildIndex()+1:0}function mi(e,t,r,n){let i=e.getDescendantsOfKind(SyntaxKind.JsxOpeningElement);for(let o of i){if(o.getTagNameNode().getText()!=="html")continue;let c=r.map(h=>`"${h}"`),a=t.map(h=>`${h}.variable`),f=[...c,...a],l=o.getAttribute("className");if(!l){ze(e,n),o.addAttribute({name:"className",initializer:`{cn(${f.join(", ")})}`});return}if(l.getKind()!==SyntaxKind.JsxAttribute)return;let m=l.asKindOrThrow(SyntaxKind.JsxAttribute),d=m.getInitializer();if(!d)return;if(d.getKind()===SyntaxKind.StringLiteral){let h=d.getText().slice(1,-1);ze(e,n),m.setInitializer(`{cn("${h}", ${f.join(", ")})}`);}else if(d.getKind()===SyntaxKind.JsxExpression){let h=d.asKindOrThrow(SyntaxKind.JsxExpression),g=h.getExpression();if(!g)return;let w=g.getText();if(w.startsWith("cn(")){let x=a.every($=>w.includes($)),v=r.every($=>w.includes(`"${$}"`)),P=["font-sans","font-serif","font-mono"].filter($=>!r.includes($)).some($=>w.includes(`"${$}"`));if(x&&v&&!P)continue;let C=ui(w,a);C=gi(C);let R=hi(C,f);h.replaceWithText(`{${R}}`);}else if(/^\w+\.variable$/.test(w)){if(a.includes(w)&&r.length===0)continue;ze(e,n),h.replaceWithText(`{cn(${f.join(", ")})}`);}else if(w.startsWith("`")&&w.endsWith("`")){let x=di(w);ze(e,n);let v=new Set(f),P=new Set(["font-sans","font-serif","font-mono"].map(R=>`"${R}"`)),C=x.filter(R=>!v.has(R)&&!P.has(R));h.replaceWithText(`{cn(${[...C,...f].join(", ")})}`);}else ze(e,n),h.replaceWithText(`{cn(${w}, ${f.join(", ")})}`);}}}function ze(e,t){if(!e.getImportDeclaration(n=>n.getNamedImports().some(o=>o.getName()==="cn"))){let n=e.getImportDeclaration(i=>i.getModuleSpecifierValue().includes("/lib/utils"));n?n.getNamedImports().some(o=>o.getName()==="cn")||n.addNamedImport("cn"):e.addImportDeclaration({moduleSpecifier:t.aliases.utils,namedImports:["cn"]});}}function di(e){let t=[],r=[],i=e.slice(1,-1).split(/(\$\{[^}]+\})/);for(let o of i)if(o)if(o.startsWith("${")&&o.endsWith("}")){let s=o.slice(2,-1).trim();s&&r.push(s);}else {let s=o.trim().split(/\s+/).filter(Boolean);for(let c of s)t.push(`"${c}"`);}return [...t,...r]}function ui(e,t){let r=e;for(let n of t)r=r.replace(new RegExp(`,?\\s*${n.replace(".","\\.")}`,"g"),"").replace(/cn\(\s*,/,"cn(");return r}function gi(e){let t=e;for(let r of ["font-sans","font-serif","font-mono"])t=t.replace(new RegExp(`,?\\s*"${r}"`,"g"),"").replace(/cn\(\s*,/,"cn(");return t}function hi(e,t){let r=t.join(", ");return e.replace(/\)$/,`, ${r})`)}async function ne(e,t,r){r={overwrite:false,silent:false,isNewProject:false,...r};let n=await P(t);return n&&n.ui&&n.ui.resolvedPaths.cwd!==t.resolvedPaths.cwd?await bi(e,t,n,{...r,isRemote:e?.length===1&&!!e[0].match(/\/chat\/b\//)}):await wi(e,t,{...r,skipFonts:r.skipFonts})}async function wi(e,t,r){if(!e.length)return;let n=w("Checking registry.",{silent:r.silent})?.start(),i=await _$1(e,U$1(t));if(!i)return n?.fail(),$(new Error("Failed to fetch components from registry."));try{sn(i.files??[],t.resolvedPaths.cwd);}catch(c){return n?.fail(),$(c)}n?.succeed();let o=await ta$1(t);r.skipFonts||(i=await Je(i,t)),await D(i.dependencies,i.devDependencies,t,{silent:r.silent}),await Y$1(i.tailwind?.config,t,{silent:r.silent,tailwindVersion:o}),await Mt(i.envVars,t,{silent:r.silent}),r.skipFonts||await Ge(i.fonts,t,{silent:r.silent}),await D$1(i.files,t,{overwrite:r.overwrite,silent:r.silent,path:r.path});let s=i.cssVars?r.overwriteCssVars??await on(e,t):void 0;await Be(i.css,t,{silent:r.silent,cssVars:i.cssVars,cleanupDefaultNextStyles:r.isNewProject,overwriteCssVars:s,tailwindVersion:o,tailwindConfig:i.tailwind?.config}),i.docs&&b.info(i.docs);}async function bi(e,t,r,n){if(!e.length)return;let i=w("Checking registry.",{silent:n.silent})?.start(),o=await _$1(e,U$1(t));if(!o)return i?.fail(),$(new Error("Failed to fetch components from registry."));try{sn(o.files??[],t.resolvedPaths.cwd);}catch(R){return i?.fail(),$(R)}i?.succeed();let s=[],c=[],a=[],f=w("Installing components.")?.start(),l=r.ui,m=await ta$1(l),d=R(t.resolvedPaths.cwd,l.resolvedPaths.ui);o=await Je(o,t),await D(o.dependencies,o.devDependencies,l,{silent:true}),o.tailwind?.config&&(await Y$1(o.tailwind?.config,l,{silent:true,tailwindVersion:m}),c.push(te__default.relative(d,l.resolvedPaths.tailwindConfig))),o.envVars&&await Mt(o.envVars,l,{silent:true}),await Ge(o.fonts,t,{silent:true});let h=new Map;for(let R of o.files??[]){let $=R.type||"registry:ui";h.has($)||h.set($,[]),h.get($).push(R);}let g={"registry:ui":"ui","registry:hook":"hooks","registry:lib":"lib"};for(let R$1 of Array.from(h.keys())){let $=h.get(R$1),M=g[R$1],Z=M&&r[M]?r[M]:t,et=R(t.resolvedPaths.cwd,Z.resolvedPaths.ui||Z.resolvedPaths.cwd),jt=await Q(et,Z.resolvedPaths.cwd)??Z.resolvedPaths.cwd,Et=await D$1($,Z,{overwrite:n.overwrite,silent:true,rootSpinner:f,isRemote:n.isRemote,isWorkspace:true,path:n.path});s.push(...Et.filesCreated.map(Ae=>te__default.relative(et,te__default.join(jt,Ae)))),c.push(...Et.filesUpdated.map(Ae=>te__default.relative(et,te__default.join(jt,Ae)))),a.push(...Et.filesSkipped.map(Ae=>te__default.relative(et,te__default.join(jt,Ae))));}let w$1=o.cssVars?n.overwriteCssVars??await on(e,t):void 0;await Be(o.css,l,{silent:true,cssVars:o.cssVars,overwriteCssVars:w$1,tailwindVersion:m,tailwindConfig:o.tailwind?.config}),(o.cssVars||o.css)&&c.push(te__default.relative(d,l.resolvedPaths.tailwindCss)),f?.succeed();let x=Array.from(new Set(s)).sort(),v=Array.from(new Set(c.filter(R=>!s.includes(R)))).sort(),P=Array.from(new Set(a)).sort();if(!(x.length||v.length)&&!P.length&&w("No files updated.",{silent:n.silent})?.info(),x.length){w(`Created ${x.length} ${x.length===1?"file":"files"}:`,{silent:n.silent})?.succeed();for(let R of x)b.log(` - ${R}`);}if(v.length){w(`Updated ${v.length} ${v.length===1?"file":"files"}:`,{silent:n.silent})?.info();for(let R of v)b.log(` - ${R}`);}if(P.length){w(`Skipped ${P.length} ${P.length===1?"file":"files"}: (use --overwrite to overwrite)`,{silent:n.silent})?.info();for(let R of P)b.log(` - ${R}`);}o.docs&&b.info(o.docs);}async function on(e,t){let r=await ba(e,{config:t});return z.array(n$1).parse(r).some(i=>i.type==="registry:theme"||i.type==="registry:style"||i.type==="registry:font"||i.type==="registry:base")}function sn(e,t){for(let r of e)if(r?.target&&!Kr(r.target,t))throw new Error(`We found an unsafe file path "${r.target} in the registry item. Installation aborted.`)}async function fe(e){let t=te__default.resolve(e.projectPath,"packages/ui"),r=te__default.resolve(e.projectPath,"apps/web"),n=te__default.resolve(t,"components.json"),i=await A.readJson(n);e.registryBaseConfig&&(i=an(i,e.registryBaseConfig)),i.tailwind.baseColor="neutral",e.rtl&&(i.rtl=true),e.menuColor&&(i.menuColor=e.menuColor),e.menuAccent&&(i.menuAccent=e.menuAccent),e.iconLibrary&&(i.iconLibrary=e.iconLibrary),await A.writeJson(n,i,{spaces:2});let o=te__default.resolve(r,"components.json"),s=await A.readJson(o);e.registryBaseConfig&&(s=an(s,e.registryBaseConfig)),s.tailwind.baseColor="neutral",e.rtl&&(s.rtl=true),e.menuColor&&(s.menuColor=e.menuColor),e.menuAccent&&(s.menuAccent=e.menuAccent),e.iconLibrary&&(s.iconLibrary=e.iconLibrary),await A.writeJson(o,s,{spaces:2});let c$1=await O(t,c.parse(i)),{config:a}=await _(e.components,c$1,{silent:true});await ne(e.components,a,{overwrite:true,silent:e.silent,isNewProject:true,skipFonts:true});let f=await O(r,c.parse(s)),l=await _$1(e.components,U$1(a));if(l?.fonts?.length){let[d]=l.fonts,
|
|
46
|
+
`,"utf-8"),d=te__default.relative(i,o),l=Object.keys(e),n?.succeed(`Added the following variables to ${a.info(a$1)}:`),!r.silent)for(let h of l)b.log(` ${a.success("+")} ${h}`);return !r.silent&&l.length>0&&b.break(),{envVarsAdded:l,envFileUpdated:m,envFileCreated:d}}async function Je(e,t){if(!e.fonts?.length)return e;let r=await ra(t.resolvedPaths.cwd);if(!r)return e;e.cssVars??={},e.cssVars.theme??={};let n=r.framework.name==="next-app"||r.framework.name==="next-pages";for(let i of e.fonts)if(n)e.cssVars.theme[i.font.variable]=`var(${i.font.variable})`;else {let o=i.name.replace("font-",""),s=i.font.dependency??`@fontsource-variable/${o}`;e.dependencies??=[],e.dependencies.push(s),e.css??={},e.css[`@import "${s}"`]={},e.cssVars.theme[i.font.variable]=i.font.family;}if(e.fonts.length>0){let i=new Map;for(let o of e.fonts){let s=o.font.selector??"html",c=o.font.variable.replace("--","");i.has(s)||i.set(s,[]),i.get(s).push(c);}e.css??={},e.css["@layer base"]??={};for(let[o,s]of Array.from(i.entries())){let c=s.join(" ");e.css["@layer base"][o]??={};let a=Object.keys(e.css["@layer base"][o]).find(f=>f.startsWith("@apply "));a?(delete e.css["@layer base"][o][a],e.css["@layer base"][o][`${a} ${c}`]={}):e.css["@layer base"][o][`@apply ${c}`]={};}}return e}async function Ge(e,t,r){if(!e?.length)return;let n=await ra(t.resolvedPaths.cwd);if(!n||n.framework.name!=="next-app"&&n.framework.name!=="next-pages")return;let i=w("Updating fonts.",{silent:r.silent})?.start();try{await si(e,t,n),i?.succeed("Updating fonts.");}catch(o){throw i?.fail("Failed to update fonts."),o}}async function si(e,t,r){let n=await ai(t,r);if(!n)return;let i=await promises.readFile(n,"utf-8"),o=await ci(i,e,t);o!==i&&await promises.writeFile(n,o,"utf-8");}async function ai(e,t){let r=e.resolvedPaths.cwd,n=t.isSrcDir,o=t.isTsx?"tsx":"jsx",s=n?[`src/app/layout.${o}`,`app/layout.${o}`]:[`app/layout.${o}`];for(let c of s){let a=te__default.join(r,c);if(existsSync(a))return a}return null}async function ci(e,t,r){let i=new Project({compilerOptions:{}}).createSourceFile("layout.tsx",e,{scriptKind:ScriptKind.TSX}),o=t.filter(m=>m.font.provider==="google"),s=[],c=[];for(let m of o){let d=m.font.import;if(!d)continue;let h=i.getImportDeclaration(v=>v.getModuleSpecifierValue()==="next/font/google");if(h){if(h.getNamedImports().some(C=>C.getName()===d)){let C=nn(i,m.font.variable);C&&(s.push(C.getName()),m.font.selector||c.push(m.font.variable.replace("--","")));continue}h.addNamedImport(d);}else i.addImportDeclaration({moduleSpecifier:"next/font/google",namedImports:[d]});let g=fi(d),w=li(m),x=nn(i,m.font.variable);if(x)x.setInitializer(`${d}(${w})`),x.getName()!==g&&x.rename(g);else {let v=pi(i);i.insertVariableStatement(v,{declarationKind:VariableDeclarationKind.Const,declarations:[{name:g,initializer:`${d}(${w})`}]}).appendWhitespace(`
|
|
47
|
+
`);}s.push(g),m.font.selector||c.push(m.font.variable.replace("--",""));}let a=new Set(["font-sans","font-serif","font-mono"]),f=[...c].reverse().find(m=>a.has(m)),l=c.filter(m=>!a.has(m));return f&&l.unshift(f),s.length>0&&mi(i,s,l,r),i.getFullText()}function li(e){let t={};return e.font.subsets?.length&&(t.subsets=e.font.subsets),e.font.weight?.length&&(t.weight=e.font.weight),t.variable=e.font.variable,JSON.stringify(t).replace(/"([^"]+)":/g,"$1:").replace(/"/g,"'")}function fi(e){return e.split("_").map((t,r)=>r===0?t.toLowerCase():t.charAt(0).toUpperCase()+t.slice(1).toLowerCase()).join("")}function nn(e,t){let r=e.getVariableStatements();for(let n of r)for(let i of n.getDeclarations()){let o=i.getInitializer();if(!o||o.getKind()!==SyntaxKind.CallExpression)continue;let c=o.getArguments();if(c.length===0)continue;let a=c[0].getText();if(a.includes("variable:")&&a.includes(t))return i}return null}function pi(e){let t=e.getImportDeclarations();return t.length>0?t[t.length-1].getChildIndex()+1:0}function mi(e,t,r,n){let i=e.getDescendantsOfKind(SyntaxKind.JsxOpeningElement);for(let o of i){if(o.getTagNameNode().getText()!=="html")continue;let c=r.map(h=>`"${h}"`),a=t.map(h=>`${h}.variable`),f=[...c,...a],l=o.getAttribute("className");if(!l){ze(e,n),o.addAttribute({name:"className",initializer:`{cn(${f.join(", ")})}`});return}if(l.getKind()!==SyntaxKind.JsxAttribute)return;let m=l.asKindOrThrow(SyntaxKind.JsxAttribute),d=m.getInitializer();if(!d)return;if(d.getKind()===SyntaxKind.StringLiteral){let h=d.getText().slice(1,-1);ze(e,n),m.setInitializer(`{cn("${h}", ${f.join(", ")})}`);}else if(d.getKind()===SyntaxKind.JsxExpression){let h=d.asKindOrThrow(SyntaxKind.JsxExpression),g=h.getExpression();if(!g)return;let w=g.getText();if(w.startsWith("cn(")){let x=a.every($=>w.includes($)),v=r.every($=>w.includes(`"${$}"`)),P=["font-sans","font-serif","font-mono"].filter($=>!r.includes($)).some($=>w.includes(`"${$}"`));if(x&&v&&!P)continue;let C=ui(w,a);C=gi(C);let R=hi(C,f);h.replaceWithText(`{${R}}`);}else if(/^\w+\.variable$/.test(w)){if(a.includes(w)&&r.length===0)continue;ze(e,n),h.replaceWithText(`{cn(${f.join(", ")})}`);}else if(w.startsWith("`")&&w.endsWith("`")){let x=di(w);ze(e,n);let v=new Set(f),P=new Set(["font-sans","font-serif","font-mono"].map(R=>`"${R}"`)),C=x.filter(R=>!v.has(R)&&!P.has(R));h.replaceWithText(`{cn(${[...C,...f].join(", ")})}`);}else ze(e,n),h.replaceWithText(`{cn(${w}, ${f.join(", ")})}`);}}}function ze(e,t){if(!e.getImportDeclaration(n=>n.getNamedImports().some(o=>o.getName()==="cn"))){let n=e.getImportDeclaration(i=>i.getModuleSpecifierValue().includes("/lib/utils"));n?n.getNamedImports().some(o=>o.getName()==="cn")||n.addNamedImport("cn"):e.addImportDeclaration({moduleSpecifier:t.aliases.utils,namedImports:["cn"]});}}function di(e){let t=[],r=[],i=e.slice(1,-1).split(/(\$\{[^}]+\})/);for(let o of i)if(o)if(o.startsWith("${")&&o.endsWith("}")){let s=o.slice(2,-1).trim();s&&r.push(s);}else {let s=o.trim().split(/\s+/).filter(Boolean);for(let c of s)t.push(`"${c}"`);}return [...t,...r]}function ui(e,t){let r=e;for(let n of t)r=r.replace(new RegExp(`,?\\s*${n.replace(".","\\.")}`,"g"),"").replace(/cn\(\s*,/,"cn(");return r}function gi(e){let t=e;for(let r of ["font-sans","font-serif","font-mono"])t=t.replace(new RegExp(`,?\\s*"${r}"`,"g"),"").replace(/cn\(\s*,/,"cn(");return t}function hi(e,t){let r=t.join(", ");return e.replace(/\)$/,`, ${r})`)}async function ne(e,t,r){r={overwrite:false,silent:false,isNewProject:false,...r};let n=await P(t);return n&&n.ui&&n.ui.resolvedPaths.cwd!==t.resolvedPaths.cwd?await bi(e,t,n,{...r,isRemote:e?.length===1&&!!e[0].match(/\/chat\/b\//)}):await wi(e,t,{...r,skipFonts:r.skipFonts})}async function wi(e,t,r){if(!e.length)return;let n=w("Checking registry.",{silent:r.silent})?.start(),i=await _$1(e,U$1(t));if(!i)return n?.fail(),$(new Error("Failed to fetch components from registry."));try{sn(i.files??[],t.resolvedPaths.cwd);}catch(c){return n?.fail(),$(c)}n?.succeed();let o=await ta$1(t);r.skipFonts||(i=await Je(i,t)),await D(i.dependencies,i.devDependencies,t,{silent:r.silent}),await Y$1(i.tailwind?.config,t,{silent:r.silent,tailwindVersion:o}),await Mt(i.envVars,t,{silent:r.silent}),r.skipFonts||await Ge(i.fonts,t,{silent:r.silent}),await D$1(i.files,t,{overwrite:r.overwrite,silent:r.silent,path:r.path});let s=i.cssVars?r.overwriteCssVars??await on(e,t):void 0;await Be(i.css,t,{silent:r.silent,cssVars:i.cssVars,cleanupDefaultNextStyles:r.isNewProject,overwriteCssVars:s,tailwindVersion:o,tailwindConfig:i.tailwind?.config}),i.docs&&b.info(i.docs);}async function bi(e,t,r,n){if(!e.length)return;let i=w("Checking registry.",{silent:n.silent})?.start(),o=await _$1(e,U$1(t));if(!o)return i?.fail(),$(new Error("Failed to fetch components from registry."));try{sn(o.files??[],t.resolvedPaths.cwd);}catch(R){return i?.fail(),$(R)}i?.succeed();let s=[],c=[],a=[],f=w("Installing components.")?.start(),l=r.ui,m=await ta$1(l),d=R(t.resolvedPaths.cwd,l.resolvedPaths.ui);o=await Je(o,t),await D(o.dependencies,o.devDependencies,l,{silent:true}),o.tailwind?.config&&(await Y$1(o.tailwind?.config,l,{silent:true,tailwindVersion:m}),c.push(te__default.relative(d,l.resolvedPaths.tailwindConfig))),o.envVars&&await Mt(o.envVars,l,{silent:true}),await Ge(o.fonts,t,{silent:true});let h=new Map;for(let R of o.files??[]){let $=R.type||"registry:ui";h.has($)||h.set($,[]),h.get($).push(R);}let g={"registry:ui":"ui","registry:hook":"hooks","registry:lib":"lib"};for(let R$1 of Array.from(h.keys())){let $=h.get(R$1),M=g[R$1],Z=M&&r[M]?r[M]:t,et=R(t.resolvedPaths.cwd,Z.resolvedPaths.ui||Z.resolvedPaths.cwd),jt=await Q(et,Z.resolvedPaths.cwd)??Z.resolvedPaths.cwd,Et=await D$1($,Z,{overwrite:n.overwrite,silent:true,rootSpinner:f,isRemote:n.isRemote,isWorkspace:true,path:n.path});s.push(...Et.filesCreated.map(Ae=>te__default.relative(et,te__default.join(jt,Ae)))),c.push(...Et.filesUpdated.map(Ae=>te__default.relative(et,te__default.join(jt,Ae)))),a.push(...Et.filesSkipped.map(Ae=>te__default.relative(et,te__default.join(jt,Ae))));}let w$1=o.cssVars?n.overwriteCssVars??await on(e,t):void 0;await Be(o.css,l,{silent:true,cssVars:o.cssVars,overwriteCssVars:w$1,tailwindVersion:m,tailwindConfig:o.tailwind?.config}),(o.cssVars||o.css)&&c.push(te__default.relative(d,l.resolvedPaths.tailwindCss)),f?.succeed();let x=Array.from(new Set(s)).sort(),v=Array.from(new Set(c.filter(R=>!s.includes(R)))).sort(),P=Array.from(new Set(a)).sort();if(!(x.length||v.length)&&!P.length&&w("No files updated.",{silent:n.silent})?.info(),x.length){w(`Created ${x.length} ${x.length===1?"file":"files"}:`,{silent:n.silent})?.succeed();for(let R of x)b.log(` - ${R}`);}if(v.length){w(`Updated ${v.length} ${v.length===1?"file":"files"}:`,{silent:n.silent})?.info();for(let R of v)b.log(` - ${R}`);}if(P.length){w(`Skipped ${P.length} ${P.length===1?"file":"files"}: (use --overwrite to overwrite)`,{silent:n.silent})?.info();for(let R of P)b.log(` - ${R}`);}o.docs&&b.info(o.docs);}async function on(e,t){let r=await ba(e,{config:t});return z.array(n$1).parse(r).some(i=>i.type==="registry:theme"||i.type==="registry:style"||i.type==="registry:font"||i.type==="registry:base")}function sn(e,t){for(let r of e)if(r?.target&&!Kr(r.target,t))throw new Error(`We found an unsafe file path "${r.target} in the registry item. Installation aborted.`)}async function fe(e){let t=te__default.resolve(e.projectPath,"packages/ui"),r=te__default.resolve(e.projectPath,"apps/web"),n=te__default.resolve(t,"components.json"),i=await A.readJson(n);e.registryBaseConfig&&(i=an(i,e.registryBaseConfig)),i.tailwind.baseColor="neutral",e.rtl&&(i.rtl=true),e.menuColor&&(i.menuColor=e.menuColor),e.menuAccent&&(i.menuAccent=e.menuAccent),e.iconLibrary&&(i.iconLibrary=e.iconLibrary),await A.writeJson(n,i,{spaces:2});let o=te__default.resolve(r,"components.json"),s=await A.readJson(o);e.registryBaseConfig&&(s=an(s,e.registryBaseConfig)),s.tailwind.baseColor="neutral",e.rtl&&(s.rtl=true),e.menuColor&&(s.menuColor=e.menuColor),e.menuAccent&&(s.menuAccent=e.menuAccent),e.iconLibrary&&(s.iconLibrary=e.iconLibrary),await A.writeJson(o,s,{spaces:2});let c$1=await O(t,c.parse(i)),{config:a}=await _(e.components,c$1,{silent:true});await ne(e.components,a,{overwrite:true,silent:e.silent,isNewProject:true,skipFonts:true});let f=await O(r,c.parse(s)),l=await _$1(e.components,U$1(a));if(l?.fonts?.length){let[d]=l.fonts,h=d.name.replace("font-",""),g=d.font.dependency??`@fontsource-variable/${h}`;await D([g],[],c$1,{silent:true}),await pt({theme:{[d.font.variable]:d.font.family}},c$1,{silent:e.silent,overwriteCssVars:false,tailwindVersion:"v4"}),await Be({[`@import "${g}"`]:{}},c$1,{silent:e.silent});}let m=c$1.iconLibrary;if(m&&m in a$2){let d=[...a$2[m].packages];await D(d,[],c$1,{silent:true}),await D(d,[],f,{silent:true});}return f}var ln=U({name:"astro",title:"Astro",defaultProjectName:"astro-app",templateDir:"astro-app",frameworks:["astro"],create:async()=>{},files:[{type:"registry:page",path:"src/pages/index.astro",target:"src/pages/index.astro",content:cn`---
|
|
48
48
|
import Layout from "@/layouts/main.astro"
|
|
49
49
|
import { ComponentExample } from "@/components/component-example"
|
|
50
50
|
---
|
|
@@ -122,17 +122,17 @@ export function App() {
|
|
|
122
122
|
|
|
123
123
|
export default App;
|
|
124
124
|
`}]}});var B={next:dn,vite:bn,start:yn,"react-router":gn,astro:ln,laravel:fn};function wt(e){if(e){for(let[t,r]of Object.entries(B))if(r.frameworks.includes(e))return t}}async function bt(e){let t=e.template&&e.template in B?e.template:"next",r=he(B[t],{monorepo:e.monorepo}),n=e.name??r.defaultProjectName,i=e.components?.length===1&&!!e.components[0].match(/\/chat\/b\//);if(i&&(t="next"),!e.force){let{type:a$1,name:f}=await pe([{type:e.template||i?null:"select",name:"type",message:`The path ${a.info(e.cwd)} does not contain a package.json file.
|
|
125
|
-
Would you like to start a new project?`,choices:Object.entries(B).map(([l,m])=>({title:m.title,value:l,description:m.description})),initial:0},{type:e.name?null:"text",name:"name",message:"What is your project named?",initial:n,format:l=>l.trim(),validate:l=>l.length>128?"Name should be less than 128 characters.":true}]);t=a$1??t,n=f??n;}let o=he(B[t],{monorepo:e.monorepo}),s=await a$1(e.cwd,{withFallback:true}),c=te__default.join(e.cwd,n);try{await A.access(e.cwd,A.constants.W_OK);}catch{b.break(),b.error(`The path ${a.info(e.cwd)} is not writable.`),b.error(`It is likely you do not have write permissions for this folder or the path ${a.info(e.cwd)} does not exist.`),b.break(),process.exit(1);}return A.existsSync(te__default.resolve(e.cwd,n,"package.json"))&&(b.break(),b.error(`A project with the name ${a.info(n)} already exists.`),b.error("Please choose a different name and try again."),b.break(),process.exit(1)),await o.scaffold({projectPath:c,packageManager:s,cwd:e.cwd}),{projectPath:c,projectName:n,template:t}}async function X(e=process.cwd()){try{let{config:t}=await import('@dotenvx/dotenvx'),r=[".env.local",".env.development.local",".env.development",".env"];for(let n of r){let i=join(e,n);existsSync(i)&&t({path:i,overload:!1,quiet:!0});}}catch(t){b.warn("Failed to load env files:",t);}}var
|
|
126
|
-
You may now add components.`),process.removeListener("exit",i),Rn(te__default.resolve(a$1,"components.json")),b.break();}catch(o){process.removeListener("exit",i),i(),b.break(),$(o);}finally{V();}});async function xt(e){let t,r,n=e.template,i=n?he(B[n],{monorepo:e.monorepo}):void 0;if(e.monorepo&&i?.init&&A.existsSync(te__default.resolve(e.cwd,"package.json")))t=await ra(e.cwd);else if(e.skipPreflight)t=await ra(e.cwd);else {let C=await Jr(e);if(C.errors["1"]){let{projectPath:R,template:$}=await bt(e);R||process.exit(1),e.cwd=R,e.isNewProject=true,r=$,t=await ra(e.cwd);}else t=C.projectInfo;}let s=r??n,c=s?he(B[s],{monorepo:e.monorepo}):void 0,a$1=[...e.installStyleIndex?["index"]:[],...e.components??[],...c?["button"]:[]];if(c?.init){let C=await c.init({projectPath:e.cwd,components:a$1,registryBaseConfig:e.registryBaseConfig,rtl:e.rtl??false,menuColor:e.menuColor,menuAccent:e.menuAccent,iconLibrary:e.iconLibrary,silent:e.silent});return await c.postInit({projectPath:e.cwd}),C}let f=await sa(e.cwd,t),l=f?await Pi(f,e):await Ii(await N(e.cwd));if(!e.yes){let{proceed:C}=await pe({type:"confirm",name:"proceed",message:`Write configuration to ${a.info("components.json")}. Proceed?`,initial:true});C||process.exit(1);}let m=await O(e.cwd,l),{config:d$1}=await _(a$1,m,{silent:true});d$1.registries&&(l.registries=d$1.registries);let h=w("Writing components.json.").start(),g=te__default.resolve(e.cwd,"components.json"),w$1=`${g}${
|
|
125
|
+
Would you like to start a new project?`,choices:Object.entries(B).map(([l,m])=>({title:m.title,value:l,description:m.description})),initial:0},{type:e.name?null:"text",name:"name",message:"What is your project named?",initial:n,format:l=>l.trim(),validate:l=>l.length>128?"Name should be less than 128 characters.":true}]);t=a$1??t,n=f??n;}let o=he(B[t],{monorepo:e.monorepo}),s=await a$1(e.cwd,{withFallback:true}),c=te__default.join(e.cwd,n);try{await A.access(e.cwd,A.constants.W_OK);}catch{b.break(),b.error(`The path ${a.info(e.cwd)} is not writable.`),b.error(`It is likely you do not have write permissions for this folder or the path ${a.info(e.cwd)} does not exist.`),b.break(),process.exit(1);}return A.existsSync(te__default.resolve(e.cwd,n,"package.json"))&&(b.break(),b.error(`A project with the name ${a.info(n)} already exists.`),b.error("Please choose a different name and try again."),b.break(),process.exit(1)),await o.scaffold({projectPath:c,packageManager:s,cwd:e.cwd}),{projectPath:c,projectName:n,template:t}}async function X(e=process.cwd()){try{let{config:t}=await import('@dotenvx/dotenvx'),r=[".env.local",".env.development.local",".env.development",".env"];for(let n of r){let i=join(e,n);existsSync(i)&&t({path:i,overload:!1,quiet:!0});}}catch(t){b.warn("Failed to load env files:",t);}}var Fe=".bak";function vn(e){if(!A.existsSync(e))return null;let t=`${e}${Fe}`;try{return A.renameSync(e,t),t}catch(r){return console.error(`Failed to create backup of ${e}: ${r}`),null}}function Cn(e){let t=`${e}${Fe}`;if(!A.existsSync(t))return false;try{return A.renameSync(t,e),!0}catch(r){return console.error(`Warning: Could not restore backup file ${t}: ${r}`),false}}function Rn(e){let t=`${e}${Fe}`;if(!A.existsSync(t))return false;try{return A.unlinkSync(t),!0}catch{return false}}var $i=z.object({cwd:z.string(),name:z.string().optional(),preset:z.union([z.boolean(),z.string()]).optional(),components:z.array(z.string()).optional(),yes:z.boolean(),defaults:z.boolean(),force:z.boolean(),reinstall:z.boolean().optional(),silent:z.boolean(),isNewProject:z.boolean().default(false),cssVariables:z.boolean().default(true),rtl:z.boolean().optional(),base:z.enum(["radix","base"]).optional(),template:z.string().optional(),monorepo:z.boolean().optional(),existingConfig:z.record(z.unknown()).optional(),installStyleIndex:z.boolean().default(true),registryBaseConfig:c.deepPartial().optional(),menuColor:z.enum(["default","inverted","default-translucent","inverted-translucent"]).optional(),menuAccent:z.enum(["subtle","bold"]).optional(),iconLibrary:z.string().optional()}),Sn=new Command().name("init").alias("create").description("initialize your project and install dependencies").argument("[components...]","names, url or local path to component").option("-t, --template <template>","the template to use. (next, start, vite, react-router, laravel, astro)").option("-b, --base <base>","the component library to use. (radix, base)").option("--monorepo","scaffold a monorepo project.").option("--no-monorepo","skip the monorepo prompt.").option("-p, --preset [name]","use a preset configuration").option("-y, --yes","skip confirmation prompt.",true).option("-d, --defaults","use default configuration: --template=next --preset=base-nova",false).option("-f, --force","force overwrite of existing configuration.",false).option("-c, --cwd <cwd>","the working directory. defaults to the current directory.",process.cwd()).option("-n, --name <name>","the name for the new project.").option("-s, --silent","mute output.",false).option("--css-variables","use css variables for theming.",true).option("--no-css-variables","do not use css variables for theming.").option("--rtl","enable RTL support.").option("--no-rtl","disable RTL support.").option("--reinstall","re-install existing UI components.").option("--no-reinstall","do not re-install existing UI components.").action(async(e,t)=>{let r,n$1=[],i=()=>{r&&Cn(r.replace(Fe,""));};process.on("exit",i);try{let o$1=$i.parse({...t,reinstall:t.reinstall,cwd:te__default.resolve(t.cwd)}),s=new Map(Object.entries(_e)),c;if(o$1.defaults&&(o$1.template=o$1.template||"next",o$1.base=o$1.base||"base",o$1.reinstall=o$1.reinstall??!1),o$1.template&&!(o$1.template in B)&&(b.error(`Invalid template: ${a.info(o$1.template)}. Available templates: ${Object.keys(B).map(d=>a.info(d)).join(", ")}.`),b.break(),process.exit(1)),typeof o$1.preset=="string"&&!G(o$1.preset)&&!o(o$1.preset)){let d=Array.from(s.keys());s.has(o$1.preset)||(b.error(`Invalid preset: ${a.info(o$1.preset)}. Available presets: ${d.join(", ")}`),b.break(),process.exit(1));}let a$1=o$1.cwd,f=A.existsSync(te__default.resolve(a$1,"components.json"));if(!o$1.monorepo&&!f&&await Y(a$1)){let d=await ra(a$1);if(!d||d.framework.name==="manual"){let h=await K(a$1);h.length>0&&(q("init",h),process.exit(1));}}if(f&&!o$1.force){let{overwrite:d}=await pe({type:"confirm",name:"overwrite",message:`A ${a.info("components.json")} file already exists. Would you like to overwrite it?`,initial:!1});d||(b.info(` To start over, remove the ${a.info("components.json")} file and run ${a.info("init")} again.`),b.break(),process.exit(1)),o$1.force=!0;}let l;if(f){try{l=await A.readJson(te__default.resolve(a$1,"components.json"));}catch{}l&&(o$1.existingConfig=l);let d=o$1.reinstall;if(d===void 0){let{reinstall:h}=await pe({type:"confirm",name:"reinstall",message:"Would you like to re-install existing UI components?",initial:!1});d=h;}if(d&&(n$1=await ua(a$1),n$1.length)){b.break(),b.log(" The following components will be re-installed and overwritten:");for(let h=0;h<n$1.length;h+=8)b.log(` - ${n$1.slice(h,h+8).join(", ")}`);b.break();}}if(o$1.preset===void 0&&e.length===0&&!o$1.defaults){let d=A.existsSync(te__default.resolve(a$1,"package.json"));if(!o$1.template&&!d){let{template:h}=await pe({type:"select",name:"template",message:"Select a template",choices:Object.entries(B).map(([g,w])=>({title:w.title,value:g,description:w.description,disabled:o$1.monorepo&&g==="laravel"}))});h||process.exit(1),o$1.template=h;}if(!o$1.template&&d){let h=await ra(a$1),g=wt(h?.framework.name);g&&(o$1.template=g);}if(o$1.template==="laravel"&&!d&&(b.break(),b.log(` Please create a new app with ${a.info("laravel new --react")} first then run ${a.info("shadcn init")}.`),b.log(` See ${a.info(`${c$1}/docs/installation/laravel`)} for more information.`),b.break(),process.exit(0)),o$1.monorepo===void 0&&!d&&o$1.template&&B[o$1.template]?.monorepo){let{monorepo:h}=await pe({type:"confirm",name:"monorepo",message:"Would you like to set up a monorepo?",initial:!1});o$1.monorepo=h;}o$1.base||(o$1.base=await Ie()),o$1.preset=!0;}if(o$1.preset!==void 0){let d=o$1.preset===!0?!0:o$1.preset;if(d===!0){let h=await We({rtl:o$1.rtl??!1,template:o$1.template,base:o$1.base});e=[h.url,...e],c=h.base;}if(typeof d=="string"){let h;if(G(d)){let g=new URL(d);o$1.rtl?g.searchParams.set("rtl","true"):o$1.rtl===!1&&g.searchParams.delete("rtl"),g.pathname==="/init"&&d.startsWith(c$1)&&g.searchParams.set("track","1"),h=g.toString(),c=g.searchParams.get("base")??void 0;}else if(o(d)){let g=n(d);g||(b.error(`Invalid preset code: ${a.info(d)}`),b.break(),process.exit(1)),h=Ve({...g,base:"radix",rtl:o$1.rtl??!1},{template:o$1.template}),c=void 0;}else {let g=s.get(d);if(!g)throw new Error(`Unknown preset: ${d}`);h=Ve({...g,base:o$1.base??"radix",rtl:o$1.rtl??g.rtl},{template:o$1.template}),c=void 0;}e=[h,...e];}}let m=o$1.base??c??(l?.style?l.style.startsWith("base-")?"base":"radix":"");if(!m)if(e.length>0)m="radix";else {let d=await Ie();m=d,o$1.base=d;}if(o$1.defaults&&!e.some(G)&&(e=[Ve({..._e.nova,base:m,rtl:o$1.rtl??!1},{template:o$1.template}),...e]),e.length>0&&G(e[0])){let d=new URL(e[0]);d.searchParams.set("base",m),e[0]=d.toString();}if(l?.style){let d=await ji(l.style,m);if(d!==m&&(m=d,e.length>0&&G(e[0]))){let h=new URL(e[0]);h.searchParams.set("base",d),e[0]=h.toString();}}if(n$1.length&&(e=[...e,...n$1]),o$1.components=e,await X(o$1.cwd),e.length>0){let d=te__default.resolve(a$1,"components.json");f&&(r=vn(d)??void 0,r||b.warn(`Could not back up ${a.info("components.json")}.`));let{registryBaseConfig:h,installStyleIndex:g,url:w}=await Me(e[0],a$1,{registries:l?.registries});e[0]=w,g||(o$1.installStyleIndex=!1),h&&(o$1.registryBaseConfig=h);}await xt(o$1),b.break(),b.log(`Project initialization completed.
|
|
126
|
+
You may now add components.`),process.removeListener("exit",i),Rn(te__default.resolve(a$1,"components.json")),b.break();}catch(o){process.removeListener("exit",i),i(),b.break(),$(o);}finally{V();}});async function xt(e){let t,r,n=e.template,i=n?he(B[n],{monorepo:e.monorepo}):void 0;if(e.monorepo&&i?.init&&A.existsSync(te__default.resolve(e.cwd,"package.json")))t=await ra(e.cwd);else if(e.skipPreflight)t=await ra(e.cwd);else {let C=await Jr(e);if(C.errors["1"]){let{projectPath:R,template:$}=await bt(e);R||process.exit(1),e.cwd=R,e.isNewProject=true,r=$,t=await ra(e.cwd);}else t=C.projectInfo;}let s=r??n,c=s?he(B[s],{monorepo:e.monorepo}):void 0,a$1=[...e.installStyleIndex?["index"]:[],...e.components??[],...c?["button"]:[]];if(c?.init){let C=await c.init({projectPath:e.cwd,components:a$1,registryBaseConfig:e.registryBaseConfig,rtl:e.rtl??false,menuColor:e.menuColor,menuAccent:e.menuAccent,iconLibrary:e.iconLibrary,silent:e.silent});return await c.postInit({projectPath:e.cwd}),C}let f=await sa(e.cwd,t),l=f?await Pi(f,e):await Ii(await N(e.cwd));if(!e.yes){let{proceed:C}=await pe({type:"confirm",name:"proceed",message:`Write configuration to ${a.info("components.json")}. Proceed?`,initial:true});C||process.exit(1);}let m=await O(e.cwd,l),{config:d$1}=await _(a$1,m,{silent:true});d$1.registries&&(l.registries=d$1.registries);let h=w("Writing components.json.").start(),g=te__default.resolve(e.cwd,"components.json"),w$1=`${g}${Fe}`,x=(C,R)=>{let{registries:$,...M}=an(C,R);return {...M,registries:$}};if(A.existsSync(w$1)){let C=await A.readJson(w$1);e.force?C.registries&&(l.registries={...C.registries,...l.registries||{}}):l=x(C,l);}e.registryBaseConfig&&(l=x(l,e.registryBaseConfig)),e.rtl!==void 0&&(l.rtl=e.rtl),l.registries=Object.fromEntries(Object.entries(l.registries||{}).filter(([C])=>!Object.keys(d).includes(C))),await promises.writeFile(g,`${JSON.stringify(l,null,2)}
|
|
127
127
|
`,"utf8"),h.succeed();let v=await O(e.cwd,l),P$1=await P(v);if(P$1){let C={};if(l.menuColor&&(C.menuColor=l.menuColor),l.menuAccent&&(C.menuAccent=l.menuAccent),l.rtl!==void 0&&(C.rtl=l.rtl),l.iconLibrary&&(C.iconLibrary=l.iconLibrary),Object.keys(C).length>0)for(let R of Object.keys(P$1)){let $=P$1[R];if($.resolvedPaths.cwd===v.resolvedPaths.cwd)continue;let M=te__default.resolve($.resolvedPaths.cwd,"components.json");if(A.existsSync(M)){let Z=await A.readJson(M);await A.writeJson(M,{...Z,...C},{spaces:2});}}}return M.clearCaches(),await ne(a$1,v,{overwrite:true,overwriteCssVars:e.reinstall||void 0,silent:e.silent,isNewProject:e.isNewProject||t?.framework.name==="next-app"}),c&&await c.postInit({projectPath:e.cwd}),v}async function Ii(e=null){let[t,r]=await Promise.all([fa(),ha()]);b.info("");let n=await pe([{type:"toggle",name:"typescript",message:`Would you like to use ${a.info("TypeScript")} (recommended)?`,initial:e?.tsx??true,active:"yes",inactive:"no"},{type:"select",name:"style",message:`Which ${a.info("style")} would you like to use?`,choices:t.map(i=>({title:i.label,value:i.name}))},{type:"select",name:"tailwindBaseColor",message:`Which color would you like to use as the ${a.info("base color")}?`,choices:r.map(i=>({title:i.label,value:i.name}))},{type:"text",name:"tailwindCss",message:`Where is your ${a.info("global CSS")} file?`,initial:e?.tailwind.css??K$1},{type:"toggle",name:"tailwindCssVariables",message:`Would you like to use ${a.info("CSS variables")} for theming?`,initial:e?.tailwind.cssVariables??true,active:"yes",inactive:"no"},{type:"text",name:"tailwindPrefix",message:`Are you using a custom ${a.info("tailwind prefix eg. tw-")}? (Leave blank if not)`,initial:""},{type:"text",name:"tailwindConfig",message:`Where is your ${a.info("tailwind.config.js")} located?`,initial:e?.tailwind.config??L},{type:"text",name:"components",message:`Configure the import alias for ${a.info("components")}:`,initial:e?.aliases.components??I},{type:"text",name:"utils",message:`Configure the import alias for ${a.info("utils")}:`,initial:e?.aliases.utils??J},{type:"toggle",name:"rsc",message:`Are you using ${a.info("React Server Components")}?`,initial:e?.rsc??true,active:"yes",inactive:"no"}]);return n.style||process.exit(1),c.parse({$schema:"https://ui.shadcn.com/schema.json",style:n.style,tailwind:{config:n.tailwindConfig,css:n.tailwindCss,baseColor:n.tailwindBaseColor,cssVariables:n.tailwindCssVariables,prefix:n.tailwindPrefix},rsc:n.rsc,tsx:n.typescript,aliases:{utils:n.utils,components:n.components,lib:n.components.replace(/\/components$/,"lib"),hooks:n.components.replace(/\/components$/,"hooks")}})}async function Pi(e,t){let r=e.style,n="neutral",i=e.tailwind.cssVariables,o=e.iconLibrary??"lucide";if(!t.defaults){let[s,c]=await Promise.all([fa(),ta$1(e)]);r=(await pe([{type:c==="v4"||r?null:"select",name:"style",message:`Which ${a.info("style")} would you like to use?`,choices:s.map(f=>({title:f.name==="new-york"?"New York (Recommended)":f.label,value:f.name})),initial:0}])).style??r??"new-york";}return i=t.cssVariables,c.parse({$schema:e?.$schema,style:r,tailwind:{...e?.tailwind,baseColor:n,cssVariables:i},rsc:e?.rsc,tsx:e?.tsx,iconLibrary:o,rtl:t.rtl??e?.rtl??false,aliases:e?.aliases})}async function ji(e,t){let r=e.startsWith("base-")?"base":"radix";if(t===r)return t;b.warn(` You are switching from ${a.info(r)} to ${a.info(t)}.`),b.warn(` Components outside the ${a.info("ui")} directory that depend on ${a.info(r)} primitives may need manual updates.`),b.break();let{proceed:n}=await pe({type:"confirm",name:"proceed",message:"Would you like to continue?",initial:false});return n?t:r}async function $n(e){let t={};if(!A.existsSync(e.cwd)||!A.existsSync(te__default.resolve(e.cwd,"package.json")))return t["1"]=true,{errors:t,config:null};if(!A.existsSync(te__default.resolve(e.cwd,"components.json"))){if(await Y(e.cwd)){let r=await K(e.cwd);r.length>0&&(q("add [component]",r),process.exit(1));}return t["3"]=true,{errors:t,config:null}}try{let r=await N(e.cwd);return {errors:t,config:r}}catch{b.break(),b.error(`An invalid ${a.info("components.json")} file was found at ${a.info(e.cwd)}.
|
|
128
|
-
Before you can add components, you must create a valid ${a.info("components.json")} file by running the ${a.info("init")} command.`),b.error(`Learn more at ${a.info(`${c$1}/docs/components-json`)}.`),b.break(),process.exit(1);}}async function Pn(e,t,r={}){let n={files:[],dependencies:[],devDependencies:[],css:null,envVars:null,fonts:[],docs:null};if(!e.length)return n;let i=await _$1(e,U$1(t));if(!i)throw new Error("Failed to fetch components from registry.");return r.skipFonts||(i=await Je(i,t)),n.dependencies=Array.from(new Set(i.dependencies??[])),n.devDependencies=Array.from(new Set(i.devDependencies??[])),n.docs=i.docs??null,await Ei(i,t,n),await
|
|
129
|
-
`)}function Mi(e,t,r){let n=[];n.push(Ye(t)),n.push(dim("\u2502"));let i=Tn(e.files,r),o=e.css&&
|
|
128
|
+
Before you can add components, you must create a valid ${a.info("components.json")} file by running the ${a.info("init")} command.`),b.error(`Learn more at ${a.info(`${c$1}/docs/components-json`)}.`),b.break(),process.exit(1);}}async function Pn(e,t,r={}){let n={files:[],dependencies:[],devDependencies:[],css:null,envVars:null,fonts:[],docs:null};if(!e.length)return n;let i=await _$1(e,U$1(t));if(!i)throw new Error("Failed to fetch components from registry.");return r.skipFonts||(i=await Je(i,t)),n.dependencies=Array.from(new Set(i.dependencies??[])),n.devDependencies=Array.from(new Set(i.devDependencies??[])),n.docs=i.docs??null,await Ei(i,t,n),await Fi(i,t,n,r),Ni(i,t,n),r.skipFonts||Oi(i,n),n}async function Ei(e,t,r$1,n){let i=e.files;if(!i?.length)return;let[o,s$1]=await Promise.all([ra(t.resolvedPaths.cwd),t.tailwind.baseColor?ia(t.tailwind.baseColor):Promise.resolve(void 0)]);for(let c=0;c<i.length;c++){let a=i[c];if(!a.content)continue;let f$1=E(a,t,{isSrcDir:o?.isSrcDir,framework:o?.framework.name,commonRoot:F(i.map(x=>x.path),a.path),fileIndex:c});if(!f$1)continue;t.tsx||(f$1=f$1.replace(/\.tsx?$/,x=>x===".tsx"?".jsx":".js"));let l=existsSync(f$1),m=te__default.relative(t.resolvedPaths.cwd,f$1),d=a.type==="registry:file"||a.type==="registry:item",h=s(f$1)||d?a.content:await B$1({filename:a.path,raw:a.content,config:t,baseColor:s$1,transformJsx:!t.tsx,isRemote:false},[x,y,a$3,A$1,c$2,f,C,d$1,z$1]),g="create",w;l&&(w=await promises.readFile(f$1,"utf-8"),r(w,h)?g="skip":g="overwrite"),r$1.files.push({path:m,action:g,content:h,...g==="overwrite"&&{existingContent:w},type:a.type??"registry:ui"});}}async function Fi(e,t,r,n){let i=e.css&&Object.keys(e.css).length>0,o=Object.keys(e.cssVars??{}).length>0;if(!t.resolvedPaths.tailwindCss||!i&&!o)return;let s=t.resolvedPaths.tailwindCss,c=existsSync(s),a=te__default.relative(t.resolvedPaths.cwd,s),f=c?await promises.readFile(s,"utf8"):"",l=f;o&&(l=await Ue(l,e.cssVars,t,{overwriteCssVars:n.overwriteCssVars})),i&&(l=await Vt(l,e.css));let m=0;if(e.cssVars)for(let d of Object.values(e.cssVars))d&&(m+=Object.keys(d).length);r.css={path:a,content:l,...c&&{existingContent:f},action:c?"update":"create",cssVarsCount:m};}function Ni(e,t,r){if(!e.envVars||Object.keys(e.envVars).length===0)return;let n=te__default.join(t.resolvedPaths.cwd,".env.local"),i=existsSync(n),o=te__default.relative(t.resolvedPaths.cwd,n);r.envVars={path:o,variables:e.envVars,action:i?"update":"create"};}function Oi(e,t){if(e.fonts?.length)for(let r of e.fonts)t.fonts.push({name:r.font.family,provider:r.font.provider==="google"?"Google Fonts":r.font.provider});}var me=5,Di=dim("\u250C"+"\u2500".repeat(46)),Li=dim("\u2514"+"\u2500".repeat(46)),_i={create:"+",overwrite:"~",skip:"="},Vi={create:"create",overwrite:"overwrite",skip:"skip (identical)"};function He(e){return e==="create"?green(e):e==="overwrite"||e==="update"?yellow(e):dim(e)}function Ye(e){return `${bold("\u250C")} ${bold(`shadcn add ${e.join(", ")}`)} ${dim("(dry run)")}`}function Fn(e,t){return e===t||e.includes(t)||e.endsWith(t)}function xe(e,t,r=n=>n){e.push(`${dim("\u2502")} ${Di}`);for(let n of t)e.push(`${dim("\u2502")} ${dim("\u2502")} ${r(n)}`);e.push(`${dim("\u2502")} ${Li}`);}function Nn(e,t,r={}){return r.diff?typeof r.diff=="string"?Mi(e,t,r.diff):Ui(e,t):r.view?typeof r.view=="string"?zi(e,t,r.view):Bi(e,t):Wi(e,t)}function Wi(e,t){let r=[];r.push(Ye(t)),r.push(dim("\u2502")),Ji(e,r),jn("Dependencies",e.dependencies,r),jn("Dev Dependencies",e.devDependencies,r),Gi(e,r),Hi(e,r),Yi(e,r);let n=e.files.filter(o=>o.action==="overwrite").length;n>0&&(r.push(yellow(`\u26A0 ${n} ${n===1?"file":"files"} will be overwritten.`)),r.push(dim("\u2502")));let i=[];return e.files.length>0&&i.push(`${e.files.length} ${e.files.length===1?"file":"files"}`),e.dependencies.length>0&&i.push(`${e.dependencies.length} ${e.dependencies.length===1?"dep":"deps"}`),e.css?.cssVarsCount&&i.push(`${e.css.cssVarsCount} CSS vars`),i.length>0&&(r.push(`${dim("\u2502")} ${dim(i.join(", "))}`),r.push(dim("\u2502"))),r.push(`${dim("\u2502")} ${dim("Run with --diff to view changes.")}`),r.push(`${dim("\u2502")} ${dim("Run with --view to view file contents.")}`),r.push(`${dim("\u2514")} ${dim("Run without --dry-run to apply.")}`),r.join(`
|
|
129
|
+
`)}function Mi(e,t,r){let n=[];n.push(Ye(t)),n.push(dim("\u2502"));let i=Tn(e.files,r),o=e.css&&Fn(e.css.path,r);if(i.length===0&&!o)n.push(`${dim("\u2502")} ${yellow(`No file matching "${r}" found.`)}`),n.push(dim("\u2502"));else {for(let s of i)On(s,n);if(o&&e.css){if(n.push(`${dim("\u251C")} ${bold(e.css.path)} ${dim("(")}${He(e.css.action)}${dim(")")}`),e.css.action==="create"||!e.css.existingContent)xe(n,e.css.content.split(`
|
|
130
130
|
`),s=>green(`+${s}`));else {let s=An(e.css.existingContent,e.css.content,e.css.path,{fullContext:true});xe(n,s);}n.push(dim("\u2502"));}}return n.push(`${dim("\u2514")} ${dim("Run without --dry-run to apply.")}`),n.join(`
|
|
131
131
|
`)}function Ui(e,t){let r=[];r.push(Ye(t)),r.push(dim("\u2502"));let n=e.files.slice(0,me);if(n.length===0&&!e.css)r.push(`${dim("\u2502")} ${dim("No changes.")}`),r.push(dim("\u2502"));else {for(let s of n)On(s,r);e.files.length>me&&r.push(dim("\u2502"));}let i=e.files.length;return i>me&&r.push(` ${dim(`Showing ${me} of ${i} files. Use --diff <path> to view a specific file.`)}`),r.push(`${dim("\u2514")} ${dim("Run without --dry-run to apply.")}`),r.join(`
|
|
132
132
|
`)}function Bi(e,t){let r=[];r.push(Ye(t)),r.push(dim("\u2502"));let n=e.files.slice(0,me);if(n.length===0&&!e.css)r.push(`${dim("\u2502")} ${dim("No files.")}`),r.push(dim("\u2502"));else {for(let s of n){let c=s.content.split(`
|
|
133
133
|
`);r.push(`${dim("\u251C")} ${bold(s.path)} ${dim("(")}${He(s.action)}${dim(")")} ${dim(`${c.length} lines`)}`),xe(r,c),r.push(dim("\u2502"));}e.files.length>me&&r.push(dim("\u2502"));}let i=e.files.length;return i>me&&r.push(` ${dim(`Showing ${me} of ${i} files. Use --view <path> to view a specific file.`)}`),r.push(`${dim("\u2514")} ${dim("Run without --dry-run to apply.")}`),r.join(`
|
|
134
134
|
`)}function On(e,t){if(t.push(`${dim("\u251C")} ${bold(e.path)} ${dim("(")}${He(e.action)}${dim(")")}`),e.action==="skip")t.push(`${dim("\u2502")} ${dim("No changes.")}`);else if(e.action==="create")xe(t,e.content.split(`
|
|
135
|
-
`),r=>green(`+${r}`));else {let r=An(e.existingContent,e.content,e.path);xe(t,r);}t.push(dim("\u2502"));}function zi(e,t,r){let n=[];n.push(Ye(t)),n.push(dim("\u2502"));let i=Tn(e.files,r),o=e.css&&
|
|
135
|
+
`),r=>green(`+${r}`));else {let r=An(e.existingContent,e.content,e.path);xe(t,r);}t.push(dim("\u2502"));}function zi(e,t,r){let n=[];n.push(Ye(t)),n.push(dim("\u2502"));let i=Tn(e.files,r),o=e.css&&Fn(e.css.path,r);if(i.length===0&&!o)n.push(`${dim("\u2502")} ${yellow(`No file matching "${r}" found.`)}`),n.push(dim("\u2502"));else {for(let s of i){let c=s.content.split(`
|
|
136
136
|
`);n.push(`${dim("\u251C")} ${bold(s.path)} ${dim("(")}${He(s.action)}${dim(")")} ${dim(`${c.length} lines`)}`),xe(n,c),n.push(dim("\u2502"));}if(o&&e.css){let s=e.css.content.split(`
|
|
137
137
|
`);n.push(`${dim("\u251C")} ${bold(e.css.path)} ${dim("(")}${He(e.css.action)}${dim(")")} ${dim(`${s.length} lines`)}`),xe(n,s),n.push(dim("\u2502"));}}return n.push(`${dim("\u2514")} ${dim("Run without --dry-run to apply.")}`),n.join(`
|
|
138
138
|
`)}function Ji(e,t){if(e.files.length===0)return;let r={create:0,overwrite:0,skip:0};for(let s of e.files)r[s.action]++;let n=[];r.create>0&&n.push(green(`+${r.create} new`)),r.overwrite>0&&n.push(yellow(`~${r.overwrite} overwrite`)),r.skip>0&&n.push(dim(`=${r.skip} skip`));let i=n.length>0?` ${n.join(dim(", "))}`:"";t.push(`${dim("\u251C")} ${bold("Files")} ${dim(`(${e.files.length})`)}${i}`);let o=Math.max(...e.files.map(s=>s.path.length));for(let s of e.files){let c=_i[s.action],a=Vi[s.action],f=" ".repeat(Math.max(1,o-s.path.length+2)),l=s.action==="create"?green:s.action==="overwrite"?yellow:dim,m=s.action==="skip"?dim(s.path):s.path;t.push(`${dim("\u2502")} ${l(c)} ${m}${f}${l(a)}`);}t.push(dim("\u2502"));}function jn(e,t,r){if(t.length){r.push(`${dim("\u251C")} ${bold(e)} ${dim(`(${t.length})`)}`);for(let n of t)r.push(`${dim("\u2502")} ${green("+")} ${n}`);r.push(dim("\u2502"));}}function Gi(e,t){e.css&&(t.push(`${dim("\u251C")} ${bold("CSS")}`),e.css.cssVarsCount>0?t.push(`${dim("\u2502")} ${green("+")} ${e.css.cssVarsCount} CSS variables added to ${cyan(e.css.path)}`):t.push(`${dim("\u2502")} ${green("+")} Updated ${cyan(e.css.path)}`),t.push(dim("\u2502")));}function Hi(e,t){if(!e.envVars)return;let r=Object.keys(e.envVars.variables);t.push(`${dim("\u251C")} ${bold("Environment Variables")}`);for(let n of r)t.push(`${dim("\u2502")} ${green("+")} ${n}`);t.push(dim("\u2502"));}function Yi(e,t){if(e.fonts.length){t.push(`${dim("\u251C")} ${bold("Fonts")}`);for(let r of e.fonts)t.push(`${dim("\u2502")} ${green("+")} ${r.name} ${dim(`(${r.provider})`)}`);t.push(dim("\u2502"));}}function Tn(e,t){let r=e.filter(n=>n.path===t);return r.length>0?r:e.filter(n=>n.path.includes(t)||n.path.replace(/\\/g,"/").includes(t))}function An(e,t,r,n={}){if(Qi(e,t))return [dim(" Formatting-only changes (spacing, quotes, semicolons).")];let i=En(e),o=En(t),s=n.fullContext?Math.max(i.split(`
|
|
@@ -146,7 +146,7 @@ Before you can add components, you must create a valid ${a.info("components.json
|
|
|
146
146
|
export default function Page() {
|
|
147
147
|
return <${n?.meta?.importSpecifier} />
|
|
148
148
|
}`;await ve__default.writeFile(r,i,"utf8");}var os=z.object({components:z.array(z.string()).optional(),yes:z.boolean(),overwrite:z.boolean(),cwd:z.string(),all:z.boolean(),path:z.string().optional(),silent:z.boolean(),dryRun:z.boolean(),diff:z.union([z.string(),z.literal(true)]).optional(),view:z.union([z.string(),z.literal(true)]).optional()}),_n=new Command().name("add").description("add a component to your project").argument("[components...]","names, url or local path to component").option("-y, --yes","skip confirmation prompt.",false).option("-o, --overwrite","overwrite existing files.",false).option("-c, --cwd <cwd>","the working directory. defaults to the current directory.",process.cwd()).option("-a, --all","add all available components",false).option("-p, --path <path>","the path to add the component to.").option("-s, --silent","mute output.",false).option("--dry-run","preview changes without writing files.",false).option("--diff [path]","show diff for a file.").option("--view [path]","show file contents.").action(async(e$1,t)=>{try{let r=os.parse({components:e$1,...t,cwd:te__default.resolve(t.cwd)});await X(r.cwd);let n=r.dryRun||r.diff||r.view,i=await N(r.cwd);i||(i=T({style:"new-york",resolvedPaths:{cwd:r.cwd}}));let o=!1;if(e$1.length>0){let{config:g,newRegistries:w}=await _(e$1,i,{silent:r.silent,writeFile:!1});i=g,o=w.length>0;}let s,c=!0;if(e$1.length>0){let[g]=await ba([e$1[0]],{config:i});if(s=g?.type,c=s!=="registry:theme"&&s!=="registry:style"&&s!=="registry:base",H(g)&&!n){await ne(e$1,i,r);return}if(!r.yes&&!n&&(s==="registry:style"||s==="registry:theme")){b.break();let{confirm:w}=await pe({type:"confirm",name:"confirm",message:a.warn(`You are about to install a new ${s.replace("registry:","")}.
|
|
149
|
-
Existing CSS variables and components will be overwritten. Continue?`)});w||(b.break(),b.log("Installation cancelled."),b.break(),process.exit(1));}}r.components?.length||(r.components=await is(r));let a$1=await ra(r.cwd);if(a$1?.tailwindVersion==="v4"){let g=e.filter(w=>r.components?.includes(w.name));g?.length&&(b.break(),g.forEach(w=>{b.warn(a.warn(w.message));}),b.break(),process.exit(1));}let{errors:f,config:l}=await $n(r),m=!1;if(f["3"]){let{proceed:g}=await pe({type:"confirm",name:"proceed",message:`You need to create a ${a.info("components.json")} file to add components. Proceed?`,initial:!0});g||(b.break(),process.exit(1));let w=wt(a$1?.framework.name),x=await Ie(),{url:v}=await We({rtl:!1,base:x,template:w}),{registryBaseConfig:P,installStyleIndex:C,url:R}=await Me(v,r.cwd);l=await xt({cwd:r.cwd,yes:!0,force:!0,defaults:!1,skipPreflight:!1,silent:r.silent&&!o,isNewProject:!1,cssVariables:!0,rtl:!1,installStyleIndex:C,components:[R,...r.components??[]],registryBaseConfig:P}),m=!0;}let d=!1;if(f["1"]){let{projectPath:g,template:w}=await bt({cwd:r.cwd,force:r.overwrite,components:r.components});g||(b.break(),process.exit(1)),r.cwd=g;let x=await Ie(),{url:v}=await We({rtl:!1,base:x,template:w}),{registryBaseConfig:P,installStyleIndex:C,url:R}=await Me(v,r.cwd);l=await xt({cwd:r.cwd,yes:!0,force:!0,defaults:!1,skipPreflight:!0,silent:!o&&r.silent,isNewProject:!0,cssVariables:!0,rtl:!1,installStyleIndex:C,components:[R,...r.components??[]],registryBaseConfig:P}),m=!0,d=r.components?.length===1&&!!r.components[0].match(/\/chat\/b\//);}if(!l)throw new Error(`Failed to read config at ${a.info(r.cwd)}.`);let{config:h}=await _(r.components,l,{silent:r.silent||o,writeFile:!n});if(l=h,n){let g=w("Resolving items.",{silent:r.silent}).start(),w$1=await Pn(r.components,l,{overwrite:r.overwrite});g.stop(),b.log(Fn(w$1,r.components,{diff:r.diff,view:r.view}));return}m||await ne(r.components,l,r),d&&await Ln(r.components[0],l);}catch(r){b.break(),$(r);}finally{V();}});async function is(e$1){let t=await ea();if(!t)return b.break(),$(new Error("Failed to fetch registry index.")),[];if(e$1.all)return t.map(i=>i.name).filter(i=>!e.some(o=>o.name===i));if(e$1.components?.length)return e$1.components;let{components:r}=await pe({type:"multiselect",name:"components",message:"Which components would you like to add?",hint:"Space to select. A to toggle all. Enter to submit.",instructions:false,choices:t.filter(i=>i.type==="registry:ui"&&!e.some(o=>o.name===i.name)).map(i=>({title:i.name,value:i.name,selected:e$1.all?true:e$1.components?.includes(i.name)}))});r?.length||(b.warn("No components selected. Exiting."),b.info(""),process.exit(1));let n=z.array(z.string()).safeParse(r);return n.success?n.data:(b.error(""),$(new Error("Something went wrong. Please try again.")),[])}async function Un(e){let t={},r={cwd:e.cwd,registryFile:te__default.resolve(e.cwd,e.registryFile),outputDir:te__default.resolve(e.cwd,e.outputDir)};return A.existsSync(r.registryFile)||(t["13"]=true),await A.mkdir(r.outputDir,{recursive:true}),Object.keys(t).length>0&&(t["13"]&&(b.break(),b.error(`The path ${a.info(r.registryFile)} does not exist.`)),b.break(),process.exit(1)),{errors:t,resolvePaths:r}}var as=z.object({cwd:z.string(),registryFile:z.string(),outputDir:z.string()}),Bn=new Command().name("build").description("build components for a shadcn registry").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()).action(async(e,t)=>{try{let r=as.parse({cwd:te.resolve(t.cwd),registryFile:e,outputDir:t.output}),{resolvePaths:n}=await Un(r),i=await ve.readFile(n.registryFile,"utf-8"),o=o$1.safeParse(JSON.parse(i));o.success||(b.error(`Invalid registry file found at ${a.info(n.registryFile)}.`),process.exit(1));let s=w("Building registry...");for(let c of o.data.items){s.start(`Building ${c.name}...`),c.$schema="https://ui.shadcn.com/schema/registry-item.json";for(let f of c.files??[])f.content=await ve.readFile(te.resolve(n.cwd,f.path),"utf-8");let a$1=n$1.safeParse(c);if(!a$1.success){b.error(`Invalid registry item found for ${a.info(c.name)}.`);continue}await ve.writeFile(te.resolve(n.outputDir,`${a$1.data.name}.json`),JSON.stringify(a$1.data,null,2));}await ve.copyFile(n.registryFile,te.resolve(n.outputDir,"registry.json")),s.succeed("Building registry.");}catch(r){b.break(),$(r);}});var ps=z.object({component:z.string().optional(),yes:z.boolean(),cwd:z.string(),path:z.string().optional()}),Jn=new Command().name("diff").description("[DEPRECATED] Use `add [component] --diff` instead.").argument("[component]","the component name").option("-y, --yes","skip confirmation prompt.",false).option("-c, --cwd <cwd>","the working directory. defaults to the current directory.",process.cwd()).action(async(e,t)=>{try{let r=ps.parse({component:e,...t}),n=te__default.resolve(r.cwd);existsSync(n)||(b.error(`The path ${n} does not exist. Please try again.`),process.exit(1));let i=await N(n);if(!i){if(await Y(n)){let a=await K(n);a.length>0&&(q("diff [component]",a),process.exit(1));}b.warn(`Configuration is missing. Please run ${a.success("init")} to create a components.json file.`),process.exit(1);}let o=await ea();if(o||($(new Error("Failed to fetch registry index.")),process.exit(1)),!r.component){let a$1=i.resolvedPaths.components,f=o.filter(m=>{for(let d of m.files??[]){let h=te__default.resolve(a$1,typeof d=="string"?d:d.path);if(existsSync(h))return !0}return !1}),l=[];for(let m of f){let d=await zn(m,i);d.length&&l.push({name:m.name,changes:d});}l.length||(b.info("No updates found."),process.exit(0)),b.info("The following components have updates available:");for(let m of l){b.info(`- ${m.name}`);for(let d of m.changes)b.info(` - ${d.filePath}`);}b.break(),b.info(`Run ${a.success("diff <component>")} to see the changes.`),process.exit(0);}let s=o.find(a=>a.name===r.component);s||(b.error(`The component ${a.success(r.component)} does not exist.`),process.exit(1));let c=await zn(s,i);c.length||(b.info(`No updates found for ${r.component}.`),process.exit(0));for(let a of c)b.info(`- ${a.filePath}`),await ms(a.patch),b.info("");}catch(r){$(r);}});async function zn(e,t){let r=await ka(t.style,[e]),n=await ia(t.tailwind.baseColor);if(!r)return [];let i=[];for(let o of r){let s=await la(t,o);if(s)for(let c of o.files??[]){let a=te__default.resolve(s,typeof c=="string"?c:c.path);if(!existsSync(a))continue;let f=await promises.readFile(a,"utf8");if(typeof c=="string"||!c.content)continue;let l=await B$1({filename:c.path,raw:c.content,config:t,baseColor:n}),m=diffLines(l,f);m.length>1&&i.push({filePath:a,patch:m});}}return i}async function ms(e){e.forEach(t=>{if(t)return t.added?process.stdout.write(a.success(t.value)):t.removed?process.stdout.write(a.error(t.value)):process.stdout.write(t.value)});}var Gn=new Command().name("docs").description("get docs, api references and usage examples for components").argument("<components...>","component names").option("-c, --cwd <cwd>","the working directory. defaults to the current directory.",process.cwd()).option("-b, --base <base>","the base to use either 'base' or 'radix'. defaults to project base.").option("--json","output as JSON.",false).action(async(e,t)=>{try{let r=te__default.resolve(t.cwd),n=await N(r),i=t.base??S(n?.style),o=await ea();o||(b.error("Failed to fetch the registry index."),process.exit(1));let s=[];for(let a$1 of e){let f=o.find(m=>m.name===a$1);f||(b.error(`Component ${a.info(a$1)} not found in the shadcn registry.`),process.exit(1));let l=f.meta?.links?.[i];if(!l||Object.keys(l).length===0){b.warn(`No documentation links available for ${a.info(a$1)}.`);continue}s.push({component:a$1,base:i,links:l});}if(t.json){console.log(JSON.stringify({base:i,results:s},null,2));return}let c=Math.max(...s.flatMap(a=>Object.keys(a.links).map(f=>f.length)));for(let{component:a$1,links:f}of s){b.log(a.info(a$1));for(let[l,m]of Object.entries(f))b.log(` - ${l.padEnd(c+2)}${m}`);b.break();}}catch(r){$(r);}});var Yn="https://raw.githubusercontent.com/shadcn-ui/ui/refs/heads/main/apps/v4/registry/bases",Kn=new Command().name("info").description("get information about your project").option("-c, --cwd <cwd>","the working directory. defaults to the current directory.",process.cwd()).option("--json","output as JSON.",false).action(async e=>{try{let t=te__default.resolve(e.cwd);if(!existsSync(te__default.resolve(t,"components.json"))&&await Y(t)){let c=await K(t);c.length>0&&(e.json?console.log(JSON.stringify({error:"monorepo_root",message:"You are running info from a monorepo root. Use the -c flag to specify a workspace.",targets:c.map(a=>a.name)},null,2)):q("info",c),process.exit(1));}let r=await ra(t),n=await N(t),i=await ua(t),o=S(n?.style),s=ws(r,n,i,o);if(e.json){console.log(JSON.stringify(s,null,2));return}bs(s);}catch(t){$(t);}});function ys(e){if(!e)return {};let t={};for(let[r,n]of Object.entries(e))t[r]=typeof n=="string"?n:n.url;return t}function ws(e,t,r,n){return {project:e?{framework:e.framework.label,frameworkName:e.framework.name,frameworkVersion:e.frameworkVersion??null,srcDirectory:e.isSrcDir,rsc:e.isRSC,typescript:e.isTsx,tailwindVersion:e.tailwindVersion??null,tailwindConfig:e.tailwindConfigFile??null,tailwindCss:e.tailwindCssFile??null,importAlias:e.aliasPrefix??null}:null,config:t?{style:t.style,base:n,rsc:t.rsc,typescript:t.tsx,iconLibrary:t.iconLibrary??null,rtl:t.rtl??false,menuColor:t.menuColor??null,menuAccent:t.menuAccent??null,aliases:{components:t.aliases.components,utils:t.aliases.utils,ui:t.aliases.ui??null,lib:t.aliases.lib??null,hooks:t.aliases.hooks??null},resolvedPaths:{cwd:t.resolvedPaths.cwd,tailwindConfig:t.resolvedPaths.tailwindConfig||null,tailwindCss:t.resolvedPaths.tailwindCss||null,utils:t.resolvedPaths.utils,components:t.resolvedPaths.components,lib:t.resolvedPaths.lib,hooks:t.resolvedPaths.hooks,ui:t.resolvedPaths.ui},registries:ys(t.registries)}:null,components:r,links:{docs:`${c$1}/docs`,components:`${c$1}/docs/components/${n}/[component].md`,ui:`${Yn}/${n}/ui/[component].tsx`,examples:`${Yn}/${n}/examples/[component]-example.tsx`,schema:"https://ui.shadcn.com/schema.json"}}}function bs(e){b.log(a.info("Project")),e.project?Oe({framework:`${e.project.framework} (${e.project.frameworkName})`,frameworkVersion:e.project.frameworkVersion??"-",srcDirectory:e.project.srcDirectory?"Yes":"No",rsc:e.project.rsc?"Yes":"No",typescript:e.project.typescript?"Yes":"No",tailwindVersion:e.project.tailwindVersion??"-",tailwindConfig:e.project.tailwindConfig??"-",tailwindCss:e.project.tailwindCss??"-",importAlias:e.project.importAlias??"-"}):b.log(" No project info detected."),b.break(),b.log(a.info("Configuration")),e.config?(Oe({style:e.config.style,base:e.config.base,rsc:e.config.rsc?"Yes":"No",typescript:e.config.typescript?"Yes":"No",iconLibrary:e.config.iconLibrary??"-",rtl:e.config.rtl?"Yes":"No",menuColor:e.config.menuColor??"-",menuAccent:e.config.menuAccent??"-"}),b.break(),b.log(a.info("Aliases")),Oe({components:e.config.aliases.components,utils:e.config.aliases.utils,ui:e.config.aliases.ui??"-",lib:e.config.aliases.lib??"-",hooks:e.config.aliases.hooks??"-"}),b.break(),b.log(a.info("Resolved Paths")),Oe({cwd:e.config.resolvedPaths.cwd,tailwindConfig:e.config.resolvedPaths.tailwindConfig??"-",tailwindCss:e.config.resolvedPaths.tailwindCss??"-",utils:e.config.resolvedPaths.utils,components:e.config.resolvedPaths.components,lib:e.config.resolvedPaths.lib,hooks:e.config.resolvedPaths.hooks,ui:e.config.resolvedPaths.ui}),Object.keys(e.config.registries).length>0&&(b.break(),b.log("registries:"),Oe(e.config.registries))):b.log(" No components.json found."),b.break(),b.log(a.info("Installed Components")),e.components.length>0?b.log(` ${e.components.join(", ")}`):b.log(" No components installed."),b.break(),b.log(a.info("Links")),Oe(e.links),b.break();}function Oe(e){let t=Math.max(...Object.keys(e).map(r=>r.length));for(let[r,n]of Object.entries(e))b.log(` ${r.padEnd(t+2)}${n}`);}var Ce="latest",kt=[{name:"claude",label:"Claude Code",configPath:".mcp.json",config:{mcpServers:{shadcn:{command:"npx",args:[`shadcn@${Ce}`,"mcp"]}}}},{name:"cursor",label:"Cursor",configPath:".cursor/mcp.json",config:{mcpServers:{shadcn:{command:"npx",args:[`shadcn@${Ce}`,"mcp"]}}}},{name:"vscode",label:"VS Code",configPath:".vscode/mcp.json",config:{servers:{shadcn:{command:"npx",args:[`shadcn@${Ce}`,"mcp"]}}}},{name:"codex",label:"Codex",configPath:".codex/config.toml",config:`[mcp_servers.shadcn]
|
|
149
|
+
Existing CSS variables and components will be overwritten. Continue?`)});w||(b.break(),b.log("Installation cancelled."),b.break(),process.exit(1));}}r.components?.length||(r.components=await is(r));let a$1=await ra(r.cwd);if(a$1?.tailwindVersion==="v4"){let g=e.filter(w=>r.components?.includes(w.name));g?.length&&(b.break(),g.forEach(w=>{b.warn(a.warn(w.message));}),b.break(),process.exit(1));}let{errors:f,config:l}=await $n(r),m=!1;if(f["3"]){let{proceed:g}=await pe({type:"confirm",name:"proceed",message:`You need to create a ${a.info("components.json")} file to add components. Proceed?`,initial:!0});g||(b.break(),process.exit(1));let w=wt(a$1?.framework.name),x=await Ie(),{url:v}=await We({rtl:!1,base:x,template:w}),{registryBaseConfig:P,installStyleIndex:C,url:R}=await Me(v,r.cwd);l=await xt({cwd:r.cwd,yes:!0,force:!0,defaults:!1,skipPreflight:!1,silent:r.silent&&!o,isNewProject:!1,cssVariables:!0,rtl:!1,installStyleIndex:C,components:[R,...r.components??[]],registryBaseConfig:P}),m=!0;}let d=!1;if(f["1"]){let{projectPath:g,template:w}=await bt({cwd:r.cwd,force:r.overwrite,components:r.components});g||(b.break(),process.exit(1)),r.cwd=g;let x=await Ie(),{url:v}=await We({rtl:!1,base:x,template:w}),{registryBaseConfig:P,installStyleIndex:C,url:R}=await Me(v,r.cwd);l=await xt({cwd:r.cwd,yes:!0,force:!0,defaults:!1,skipPreflight:!0,silent:!o&&r.silent,isNewProject:!0,cssVariables:!0,rtl:!1,installStyleIndex:C,components:[R,...r.components??[]],registryBaseConfig:P}),m=!0,d=r.components?.length===1&&!!r.components[0].match(/\/chat\/b\//);}if(!l)throw new Error(`Failed to read config at ${a.info(r.cwd)}.`);let{config:h}=await _(r.components,l,{silent:r.silent||o,writeFile:!n});if(l=h,n){let g=w("Resolving items.",{silent:r.silent}).start(),w$1=await Pn(r.components,l,{overwrite:r.overwrite});g.stop(),b.log(Nn(w$1,r.components,{diff:r.diff,view:r.view}));return}m||await ne(r.components,l,r),d&&await Ln(r.components[0],l);}catch(r){b.break(),$(r);}finally{V();}});async function is(e$1){let t=await ea();if(!t)return b.break(),$(new Error("Failed to fetch registry index.")),[];if(e$1.all)return t.map(i=>i.name).filter(i=>!e.some(o=>o.name===i));if(e$1.components?.length)return e$1.components;let{components:r}=await pe({type:"multiselect",name:"components",message:"Which components would you like to add?",hint:"Space to select. A to toggle all. Enter to submit.",instructions:false,choices:t.filter(i=>i.type==="registry:ui"&&!e.some(o=>o.name===i.name)).map(i=>({title:i.name,value:i.name,selected:e$1.all?true:e$1.components?.includes(i.name)}))});r?.length||(b.warn("No components selected. Exiting."),b.info(""),process.exit(1));let n=z.array(z.string()).safeParse(r);return n.success?n.data:(b.error(""),$(new Error("Something went wrong. Please try again.")),[])}async function Un(e){let t={},r={cwd:e.cwd,registryFile:te__default.resolve(e.cwd,e.registryFile),outputDir:te__default.resolve(e.cwd,e.outputDir)};return A.existsSync(r.registryFile)||(t["13"]=true),await A.mkdir(r.outputDir,{recursive:true}),Object.keys(t).length>0&&(t["13"]&&(b.break(),b.error(`The path ${a.info(r.registryFile)} does not exist.`)),b.break(),process.exit(1)),{errors:t,resolvePaths:r}}var as=z.object({cwd:z.string(),registryFile:z.string(),outputDir:z.string()}),Bn=new Command().name("build").description("build components for a shadcn registry").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()).action(async(e,t)=>{try{let r=as.parse({cwd:te.resolve(t.cwd),registryFile:e,outputDir:t.output}),{resolvePaths:n}=await Un(r),i=await ve.readFile(n.registryFile,"utf-8"),o=o$1.safeParse(JSON.parse(i));o.success||(b.error(`Invalid registry file found at ${a.info(n.registryFile)}.`),process.exit(1));let s=w("Building registry...");for(let c of o.data.items){s.start(`Building ${c.name}...`),c.$schema="https://ui.shadcn.com/schema/registry-item.json";for(let f of c.files??[])f.content=await ve.readFile(te.resolve(n.cwd,f.path),"utf-8");let a$1=n$1.safeParse(c);if(!a$1.success){b.error(`Invalid registry item found for ${a.info(c.name)}.`);continue}await ve.writeFile(te.resolve(n.outputDir,`${a$1.data.name}.json`),JSON.stringify(a$1.data,null,2));}await ve.copyFile(n.registryFile,te.resolve(n.outputDir,"registry.json")),s.succeed("Building registry.");}catch(r){b.break(),$(r);}});var ps=z.object({component:z.string().optional(),yes:z.boolean(),cwd:z.string(),path:z.string().optional()}),Jn=new Command().name("diff").description("[DEPRECATED] Use `add [component] --diff` instead.").argument("[component]","the component name").option("-y, --yes","skip confirmation prompt.",false).option("-c, --cwd <cwd>","the working directory. defaults to the current directory.",process.cwd()).action(async(e,t)=>{try{let r=ps.parse({component:e,...t}),n=te__default.resolve(r.cwd);existsSync(n)||(b.error(`The path ${n} does not exist. Please try again.`),process.exit(1));let i=await N(n);if(!i){if(await Y(n)){let a=await K(n);a.length>0&&(q("diff [component]",a),process.exit(1));}b.warn(`Configuration is missing. Please run ${a.success("init")} to create a components.json file.`),process.exit(1);}let o=await ea();if(o||($(new Error("Failed to fetch registry index.")),process.exit(1)),!r.component){let a$1=i.resolvedPaths.components,f=o.filter(m=>{for(let d of m.files??[]){let h=te__default.resolve(a$1,typeof d=="string"?d:d.path);if(existsSync(h))return !0}return !1}),l=[];for(let m of f){let d=await zn(m,i);d.length&&l.push({name:m.name,changes:d});}l.length||(b.info("No updates found."),process.exit(0)),b.info("The following components have updates available:");for(let m of l){b.info(`- ${m.name}`);for(let d of m.changes)b.info(` - ${d.filePath}`);}b.break(),b.info(`Run ${a.success("diff <component>")} to see the changes.`),process.exit(0);}let s=o.find(a=>a.name===r.component);s||(b.error(`The component ${a.success(r.component)} does not exist.`),process.exit(1));let c=await zn(s,i);c.length||(b.info(`No updates found for ${r.component}.`),process.exit(0));for(let a of c)b.info(`- ${a.filePath}`),await ms(a.patch),b.info("");}catch(r){$(r);}});async function zn(e,t){let r=await ka(t.style,[e]),n=await ia(t.tailwind.baseColor);if(!r)return [];let i=[];for(let o of r){let s=await la(t,o);if(s)for(let c of o.files??[]){let a=te__default.resolve(s,typeof c=="string"?c:c.path);if(!existsSync(a))continue;let f=await promises.readFile(a,"utf8");if(typeof c=="string"||!c.content)continue;let l=await B$1({filename:c.path,raw:c.content,config:t,baseColor:n}),m=diffLines(l,f);m.length>1&&i.push({filePath:a,patch:m});}}return i}async function ms(e){e.forEach(t=>{if(t)return t.added?process.stdout.write(a.success(t.value)):t.removed?process.stdout.write(a.error(t.value)):process.stdout.write(t.value)});}var Gn=new Command().name("docs").description("get docs, api references and usage examples for components").argument("<components...>","component names").option("-c, --cwd <cwd>","the working directory. defaults to the current directory.",process.cwd()).option("-b, --base <base>","the base to use either 'base' or 'radix'. defaults to project base.").option("--json","output as JSON.",false).action(async(e,t)=>{try{let r=te__default.resolve(t.cwd),n=await N(r),i=t.base??S(n?.style),o=await ea();o||(b.error("Failed to fetch the registry index."),process.exit(1));let s=[];for(let a$1 of e){let f=o.find(m=>m.name===a$1);f||(b.error(`Component ${a.info(a$1)} not found in the shadcn registry.`),process.exit(1));let l=f.meta?.links?.[i];if(!l||Object.keys(l).length===0){b.warn(`No documentation links available for ${a.info(a$1)}.`);continue}s.push({component:a$1,base:i,links:l});}if(t.json){console.log(JSON.stringify({base:i,results:s},null,2));return}let c=Math.max(...s.flatMap(a=>Object.keys(a.links).map(f=>f.length)));for(let{component:a$1,links:f}of s){b.log(a.info(a$1));for(let[l,m]of Object.entries(f))b.log(` - ${l.padEnd(c+2)}${m}`);b.break();}}catch(r){$(r);}});var Yn="https://raw.githubusercontent.com/shadcn-ui/ui/refs/heads/main/apps/v4/registry/bases",Kn=new Command().name("info").description("get information about your project").option("-c, --cwd <cwd>","the working directory. defaults to the current directory.",process.cwd()).option("--json","output as JSON.",false).action(async e=>{try{let t=te__default.resolve(e.cwd);if(!existsSync(te__default.resolve(t,"components.json"))&&await Y(t)){let c=await K(t);c.length>0&&(e.json?console.log(JSON.stringify({error:"monorepo_root",message:"You are running info from a monorepo root. Use the -c flag to specify a workspace.",targets:c.map(a=>a.name)},null,2)):q("info",c),process.exit(1));}let r=await ra(t),n=await N(t),i=await ua(t),o=S(n?.style),s=ws(r,n,i,o);if(e.json){console.log(JSON.stringify(s,null,2));return}bs(s);}catch(t){$(t);}});function ys(e){if(!e)return {};let t={};for(let[r,n]of Object.entries(e))t[r]=typeof n=="string"?n:n.url;return t}function ws(e,t,r,n){return {project:e?{framework:e.framework.label,frameworkName:e.framework.name,frameworkVersion:e.frameworkVersion??null,srcDirectory:e.isSrcDir,rsc:e.isRSC,typescript:e.isTsx,tailwindVersion:e.tailwindVersion??null,tailwindConfig:e.tailwindConfigFile??null,tailwindCss:e.tailwindCssFile??null,importAlias:e.aliasPrefix??null}:null,config:t?{style:t.style,base:n,rsc:t.rsc,typescript:t.tsx,iconLibrary:t.iconLibrary??null,rtl:t.rtl??false,menuColor:t.menuColor??null,menuAccent:t.menuAccent??null,aliases:{components:t.aliases.components,utils:t.aliases.utils,ui:t.aliases.ui??null,lib:t.aliases.lib??null,hooks:t.aliases.hooks??null},resolvedPaths:{cwd:t.resolvedPaths.cwd,tailwindConfig:t.resolvedPaths.tailwindConfig||null,tailwindCss:t.resolvedPaths.tailwindCss||null,utils:t.resolvedPaths.utils,components:t.resolvedPaths.components,lib:t.resolvedPaths.lib,hooks:t.resolvedPaths.hooks,ui:t.resolvedPaths.ui},registries:ys(t.registries)}:null,components:r,links:{docs:`${c$1}/docs`,components:`${c$1}/docs/components/${n}/[component].md`,ui:`${Yn}/${n}/ui/[component].tsx`,examples:`${Yn}/${n}/examples/[component]-example.tsx`,schema:"https://ui.shadcn.com/schema.json"}}}function bs(e){b.log(a.info("Project")),e.project?Oe({framework:`${e.project.framework} (${e.project.frameworkName})`,frameworkVersion:e.project.frameworkVersion??"-",srcDirectory:e.project.srcDirectory?"Yes":"No",rsc:e.project.rsc?"Yes":"No",typescript:e.project.typescript?"Yes":"No",tailwindVersion:e.project.tailwindVersion??"-",tailwindConfig:e.project.tailwindConfig??"-",tailwindCss:e.project.tailwindCss??"-",importAlias:e.project.importAlias??"-"}):b.log(" No project info detected."),b.break(),b.log(a.info("Configuration")),e.config?(Oe({style:e.config.style,base:e.config.base,rsc:e.config.rsc?"Yes":"No",typescript:e.config.typescript?"Yes":"No",iconLibrary:e.config.iconLibrary??"-",rtl:e.config.rtl?"Yes":"No",menuColor:e.config.menuColor??"-",menuAccent:e.config.menuAccent??"-"}),b.break(),b.log(a.info("Aliases")),Oe({components:e.config.aliases.components,utils:e.config.aliases.utils,ui:e.config.aliases.ui??"-",lib:e.config.aliases.lib??"-",hooks:e.config.aliases.hooks??"-"}),b.break(),b.log(a.info("Resolved Paths")),Oe({cwd:e.config.resolvedPaths.cwd,tailwindConfig:e.config.resolvedPaths.tailwindConfig??"-",tailwindCss:e.config.resolvedPaths.tailwindCss??"-",utils:e.config.resolvedPaths.utils,components:e.config.resolvedPaths.components,lib:e.config.resolvedPaths.lib,hooks:e.config.resolvedPaths.hooks,ui:e.config.resolvedPaths.ui}),Object.keys(e.config.registries).length>0&&(b.break(),b.log("registries:"),Oe(e.config.registries))):b.log(" No components.json found."),b.break(),b.log(a.info("Installed Components")),e.components.length>0?b.log(` ${e.components.join(", ")}`):b.log(" No components installed."),b.break(),b.log(a.info("Links")),Oe(e.links),b.break();}function Oe(e){let t=Math.max(...Object.keys(e).map(r=>r.length));for(let[r,n]of Object.entries(e))b.log(` ${r.padEnd(t+2)}${n}`);}var Ce="latest",kt=[{name:"claude",label:"Claude Code",configPath:".mcp.json",config:{mcpServers:{shadcn:{command:"npx",args:[`shadcn@${Ce}`,"mcp"]}}}},{name:"cursor",label:"Cursor",configPath:".cursor/mcp.json",config:{mcpServers:{shadcn:{command:"npx",args:[`shadcn@${Ce}`,"mcp"]}}}},{name:"vscode",label:"VS Code",configPath:".vscode/mcp.json",config:{servers:{shadcn:{command:"npx",args:[`shadcn@${Ce}`,"mcp"]}}}},{name:"codex",label:"Codex",configPath:".codex/config.toml",config:`[mcp_servers.shadcn]
|
|
150
150
|
command = "npx"
|
|
151
151
|
args = ["shadcn@${Ce}", "mcp"]
|
|
152
152
|
`},{name:"opencode",label:"OpenCode",configPath:"opencode.json",config:{$schema:"https://opencode.ai/config.json",mcp:{shadcn:{type:"local",command:["npx",`shadcn@${Ce}`,"mcp"],enabled:true}}}}],St=[`shadcn@${Ce}`],Xt=new Command().name("mcp").description("MCP server and configuration commands").option("-c, --cwd <cwd>","the working directory. defaults to the current directory.",process.cwd()).action(async e=>{try{await X(e.cwd);let t=new StdioServerTransport;await b$1.connect(t);}catch(t){b.break(),$(t);}}),ks=qt.object({client:qt.enum(["claude","cursor","vscode","codex","opencode"]),cwd:qt.string()});Xt.command("init").description("Initialize MCP configuration for your client").option("--client <client>",`MCP client (${kt.map(e=>e.name).join(", ")})`).action(async(e,t)=>{try{let n=(t.parent?.opts()||{}).cwd||process.cwd(),i=e.client;if(!i){let f=await pe({type:"select",name:"client",message:"Which MCP client are you using?",choices:kt.map(l=>({title:l.label,value:l.name}))});f.client||(b.break(),process.exit(1)),i=f.client;}let o=ks.parse({client:i,cwd:n}),s=await N(o.cwd);if(o.client==="codex"){if(s)await D([],St,s,{silent:!1});else {let f=await a$1(o.cwd),l=f==="npm"?"install":"add",m=f==="npm"?"--save-dev":"-D",d=w("Installing dependencies...").start();await execa(f,[l,m,...St],{cwd:o.cwd}),d.succeed("Installing dependencies.");}b.break(),b.log("To configure the shadcn MCP server in Codex:"),b.break(),b.log(`1. Open or create the file ${a.info("~/.codex/config.toml")}`),b.log("2. Add the following configuration:"),b.log(),b.info(`[mcp_servers.shadcn]
|
|
@@ -159,4 +159,4 @@ args = ["shadcn@${Ce}", "mcp"]`),b.break(),b.info("3. Restart Codex to load the
|
|
|
159
159
|
`).map(x=>{if(x.trim().startsWith("import "))return x;let v=x;return v=v.replace(/\b(asChild\s*\?\s*)Slot(\s*:)/g,"$1__SLOT_PLACEHOLDER__$2"),v=v.replace(/\bReact\.ComponentProps<typeof\s+Slot>/g,"React.ComponentProps<typeof __SLOT_PLACEHOLDER__>"),v=v.replace(/\bComponentProps<typeof\s+Slot>/g,"ComponentProps<typeof __SLOT_PLACEHOLDER__>"),v=v.replace(/(<\/?)Slot(\s*\/?>)/g,"$1__SLOT_PLACEHOLDER__$2"),v=v.replace(/\bSlot\b/g,(P,C,R)=>{let $=R.substring(0,C),M=($.match(/"/g)||[]).length,Z=($.match(/'/g)||[]).length;return M%2!==0||Z%2!==0?P:"__SLOT_PLACEHOLDER__"}),v=v.replace(/__SLOT_PLACEHOLDER__/g,"SlotPrimitive.Slot"),v}).join(`
|
|
160
160
|
`));let h=Array.from(new Set(i));return {content:c,replacedPackages:h}}var Ws=["sidebar.tsx","pagination.tsx","calendar.tsx"],Ms=`${c$1}/docs/rtl#manual-migration-optional`;async function ro(e,t={}){let r,n;if(t.path){if(n=e.resolvedPaths.cwd,t.path.includes("*"))r=await Qt(t.path,{cwd:n,onlyFiles:true,ignore:["**/node_modules/**"]});else {let f=te__default.resolve(n,t.path),l=await promises.stat(f).catch(()=>null);if(!l)throw new Error(`File not found: ${t.path}`);if(l.isDirectory())n=f,r=await Qt("**/*.{js,ts,jsx,tsx}",{cwd:n,onlyFiles:true,ignore:["**/node_modules/**"]});else if(l.isFile())r=[t.path];else throw new Error(`Unsupported path type: ${t.path}`)}if(r.length===0)throw new Error(`No files found matching: ${t.path}`)}else {if(!e.resolvedPaths.ui)throw new Error("Could not find a valid `ui` path in your `components.json`. Please provide a path or glob pattern.");n=e.resolvedPaths.ui,r=await Qt("**/*.{js,ts,jsx,tsx}",{cwd:n,onlyFiles:true});}if(!t.yes){let a$1=t.path?t.path:`./${te__default.relative(e.resolvedPaths.cwd,n)}`,{confirm:f}=await pe({type:"confirm",name:"confirm",initial:true,message:`We will migrate ${a.info(r.length)} file(s) in ${a.info(a$1)} to RTL. Continue?`});f||(b.info("Migration cancelled."),process.exit(0));}let i=w("Updating components.json...").start();try{let a=te__default.resolve(e.resolvedPaths.cwd,"components.json"),f=JSON.parse(await promises.readFile(a,"utf-8"));f.rtl=!0,await promises.writeFile(a,JSON.stringify(f,null,2)+`
|
|
161
161
|
`),i.succeed("Updated components.json.");}catch{throw i.fail("Failed to update components.json."),new Error("Could not update components.json. Please manually set `rtl: true`.")}let o=w("Migrating files to RTL...").start(),s=0,c=[];if(await Promise.all(r.map(async a=>{o.text=`Migrating ${a}...`;let f=te__default.join(n,a),l=await promises.readFile(f,"utf-8"),m=await e$1(l,true);m!==l&&(await promises.writeFile(f,m),s++);let d=te__default.basename(a);Ws.includes(d)&&c.push(a);})),o.succeed(`Migration complete. ${s} file(s) transformed.`),c.length>0){b.break(),b.warn("The following components may need manual RTL adjustments:");for(let a of c)b.info(` - ${a}`);b.break(),b.info(`See ${a.info(Ms)} for more information.`);}}async function oo(e){let t={};if(!A.existsSync(e.cwd)||!A.existsSync(te__default.resolve(e.cwd,"package.json")))return t["1"]=true,{errors:t,config:null};if(!A.existsSync(te__default.resolve(e.cwd,"components.json")))return t["3"]=true,{errors:t,config:null};try{let r=await N(e.cwd);return {errors:t,config:r}}catch{b.break(),b.error(`An invalid ${a.info("components.json")} file was found at ${a.info(e.cwd)}.
|
|
162
|
-
Before you can run a migration, you must create a valid ${a.info("components.json")} file by running the ${a.info("init")} command.`),b.error(`Learn more at ${a.info(`${c$1}/docs/components-json`)}.`),b.break(),process.exit(1);}}var io=[{name:"icons",description:"migrate your ui components to a different icon library."},{name:"radix",description:"migrate to radix-ui."},{name:"rtl",description:"migrate your components to support RTL (right-to-left)."}],zs=z.object({cwd:z.string(),list:z.boolean(),yes:z.boolean(),migration:z.string().refine(e=>e&&io.some(t=>t.name===e),{message:"You must specify a valid migration. Run `shadcn migrate --list` to see available migrations."}).optional(),path:z.string().optional()}),so=new Command().name("migrate").description("run a migration.").argument("[migration]","the migration to run.").argument("[path]","optional path or glob pattern to migrate.").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,r)=>{try{let n=zs.parse({cwd:te__default.resolve(r.cwd),migration:e,path:t,list:r.list,yes:r.yes});if(n.list||!n.migration){b.info("Available migrations:");for(let s of io)b.info(`- ${s.name}: ${s.description}`);return}if(!n.migration)throw new Error("You must specify a migration. Run `shadcn migrate --list` to see available migrations.");let{errors:i,config:o}=await oo(n);if(i["1"]||i["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.");n.migration==="icons"&&await eo(o),n.migration==="radix"&&await to(o,{yes:n.yes,path:n.path}),n.migration==="rtl"&&await ro(o,{yes:n.yes,path:n.path});}catch(n){b.break(),$(n);}});var Hs=z.object({cwd:z.string(),silent:z.boolean()}),co=new Command().name("add").description("add registries to your project").argument("[registries...]","registries (@namespace) or registry URLs (@namespace=url)").option("-c, --cwd <cwd>","the working directory. defaults to the current directory.",process.cwd()).option("-s, --silent","mute output.",false).action(async(e,t)=>{try{let r=Hs.parse({cwd:te__default.resolve(t.cwd),silent:t.silent}),n=e.length>0?e:await qs({silent:r.silent});await Ks(n,r.cwd,{silent:r.silent});}catch(r){b.break(),$(r);}});function Ys(e){let[t,...r]=e.split("="),n=r.length>0?r.join("="):void 0;if(!t.startsWith("@"))throw new Error(`Invalid registry namespace: ${a.info(t)}. Registry names must start with @ (e.g., @acme).`);return {namespace:t,url:n}}function or(e,t,r){return `${e} ${e===1?t:r}`}async function Ks(e,t,r){let n=te__default.resolve(t,"components.json");if(!A.existsSync(n))throw new Error(`No ${a.info("components.json")} found. Run ${a.info("shadcn init")} first.`);let i=e.map(Ys),o=i.filter(g=>!g.url),s=[];if(o.length>0){let g=w("Fetching registries.",{silent:r.silent}).start(),w$1=await ma();if(!w$1)throw g.fail(),new Error("Failed to fetch registries.");g.succeed(),s=w$1;}let c={};for(let{namespace:g,url:w}of i){if(g in d){b.warn(`${a.info(g)} is a built-in registry and cannot be added.`);continue}if(w){if(!w.includes("{name}"))throw new Error(`Invalid registry URL for ${a.info(g)}. URL must include {name} placeholder. Example: ${a.info(`${g}=https://example.com/r/{name}.json`)}`);c[g]=w;}else {let x=s.find(v=>v.name===g);if(!x)throw new Error(`Registry ${a.info(g)} not found. Provide a URL: ${a.info(`${g}=https://.../{name}.json`)}`);c[g]=x.url;}}if(Object.keys(c).length===0)return {addedRegistries:[]};let a$1=await A.readJson(n),f=a$1.registries||{},l={},m=[];for(let[g,w]of Object.entries(c))f[g]?m.push(g):l[g]=w;if(Object.keys(l).length===0){if(m.length>0&&!r.silent){w(`Skipped ${or(m.length,"registry","registries")}: (already configured)`,{silent:r.silent})?.info();for(let g of m)b.log(` - ${g}`);}else r.silent||b.info("No new registries to add.");return}let d$1={...a$1,registries:{...f,...l}},h=w("Updating components.json.",{silent:r.silent}).start();if(await A.writeJson(n,d$1,{spaces:2}),h.succeed(),!r.silent){let g=Object.keys(l);w(`Added ${or(g.length,"registry","registries")}:`,{silent:r.silent})?.succeed();for(let w of g)b.log(` - ${w}`);if(m.length>0){w(`Skipped ${or(m.length,"registry","registries")}: (already configured)`,{silent:r.silent})?.info();for(let w of m)b.log(` - ${w}`);}}}async function qs(e){let t=w("Fetching registries.",{silent:e.silent}).start(),r=await ma();if(!r)throw t.fail(),new Error("Failed to fetch registries.");t.succeed();let n=[...r].sort((o,s)=>o.name.localeCompare(s.name)),{selected:i}=await pe({type:"autocompleteMultiselect",name:"selected",message:"Which registries would you like to add?",hint:"Space to select. A to toggle all. Enter to submit.",instructions:false,choices:n.map(o=>({title:o.name,description:o.description,value:o.name}))});return i?.length||(b.warn("No registries selected. Exiting."),b.info(""),process.exit(1)),i}var lo=new Command().name("registry").description("manage registries").addCommand(co);var Qs=z.object({cwd:z.string(),query:z.string().optional(),limit:z.number().optional(),offset:z.number().optional()}),mo=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 r=Qs.parse({cwd:te__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 X(r.cwd);let n=T({style:"new-york",resolvedPaths:{cwd:r.cwd}}),i=U$1(n),o=te__default.resolve(r.cwd,"components.json");if(A.existsSync(o)){let l=await A.readJson(o),m=c.partial().parse(l);i=U$1({...n,...m});}let s=i;try{let l=await N(r.cwd);l&&(s=U$1(l));}catch{}let{config:c$1,newRegistries:a}=await _(e.map(l=>`${l}/registry`),s,{silent:!0,writeFile:!1});a.length>0&&(s.registries=c$1.registries),W(e,s);let f=await va(e,{query:r.query,limit:r.limit,offset:r.offset,config:s});console.log(JSON.stringify(f,null,2)),process.exit(0);}catch(r){$(r);}finally{V();}});var ta=z.object({cwd:z.string()}),yo=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 r=ta.parse({cwd:te__default.resolve(t.cwd)});await X(r.cwd);let n=U$1({}),i=te__default.resolve(r.cwd,"components.json");if(A.existsSync(i)){let f=await A.readJson(i),l=c.partial().parse(f);n=U$1(l);}let o=n;try{let f=await N(r.cwd);f&&(o=U$1(f));}catch{}let{config:s,newRegistries:c$1}=await _(e,o,{silent:!0,writeFile:!1});c$1.length>0&&(o.registries=s.registries),W(e,o);let a=await ba(e,{config:o});console.log(JSON.stringify(a,null,2)),process.exit(0);}catch(r){$(r);}finally{V();}});var wo={version:"4.0.
|
|
162
|
+
Before you can run a migration, you must create a valid ${a.info("components.json")} file by running the ${a.info("init")} command.`),b.error(`Learn more at ${a.info(`${c$1}/docs/components-json`)}.`),b.break(),process.exit(1);}}var io=[{name:"icons",description:"migrate your ui components to a different icon library."},{name:"radix",description:"migrate to radix-ui."},{name:"rtl",description:"migrate your components to support RTL (right-to-left)."}],zs=z.object({cwd:z.string(),list:z.boolean(),yes:z.boolean(),migration:z.string().refine(e=>e&&io.some(t=>t.name===e),{message:"You must specify a valid migration. Run `shadcn migrate --list` to see available migrations."}).optional(),path:z.string().optional()}),so=new Command().name("migrate").description("run a migration.").argument("[migration]","the migration to run.").argument("[path]","optional path or glob pattern to migrate.").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,r)=>{try{let n=zs.parse({cwd:te__default.resolve(r.cwd),migration:e,path:t,list:r.list,yes:r.yes});if(n.list||!n.migration){b.info("Available migrations:");for(let s of io)b.info(`- ${s.name}: ${s.description}`);return}if(!n.migration)throw new Error("You must specify a migration. Run `shadcn migrate --list` to see available migrations.");let{errors:i,config:o}=await oo(n);if(i["1"]||i["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.");n.migration==="icons"&&await eo(o),n.migration==="radix"&&await to(o,{yes:n.yes,path:n.path}),n.migration==="rtl"&&await ro(o,{yes:n.yes,path:n.path});}catch(n){b.break(),$(n);}});var Hs=z.object({cwd:z.string(),silent:z.boolean()}),co=new Command().name("add").description("add registries to your project").argument("[registries...]","registries (@namespace) or registry URLs (@namespace=url)").option("-c, --cwd <cwd>","the working directory. defaults to the current directory.",process.cwd()).option("-s, --silent","mute output.",false).action(async(e,t)=>{try{let r=Hs.parse({cwd:te__default.resolve(t.cwd),silent:t.silent}),n=e.length>0?e:await qs({silent:r.silent});await Ks(n,r.cwd,{silent:r.silent});}catch(r){b.break(),$(r);}});function Ys(e){let[t,...r]=e.split("="),n=r.length>0?r.join("="):void 0;if(!t.startsWith("@"))throw new Error(`Invalid registry namespace: ${a.info(t)}. Registry names must start with @ (e.g., @acme).`);return {namespace:t,url:n}}function or(e,t,r){return `${e} ${e===1?t:r}`}async function Ks(e,t,r){let n=te__default.resolve(t,"components.json");if(!A.existsSync(n))throw new Error(`No ${a.info("components.json")} found. Run ${a.info("shadcn init")} first.`);let i=e.map(Ys),o=i.filter(g=>!g.url),s=[];if(o.length>0){let g=w("Fetching registries.",{silent:r.silent}).start(),w$1=await ma();if(!w$1)throw g.fail(),new Error("Failed to fetch registries.");g.succeed(),s=w$1;}let c={};for(let{namespace:g,url:w}of i){if(g in d){b.warn(`${a.info(g)} is a built-in registry and cannot be added.`);continue}if(w){if(!w.includes("{name}"))throw new Error(`Invalid registry URL for ${a.info(g)}. URL must include {name} placeholder. Example: ${a.info(`${g}=https://example.com/r/{name}.json`)}`);c[g]=w;}else {let x=s.find(v=>v.name===g);if(!x)throw new Error(`Registry ${a.info(g)} not found. Provide a URL: ${a.info(`${g}=https://.../{name}.json`)}`);c[g]=x.url;}}if(Object.keys(c).length===0)return {addedRegistries:[]};let a$1=await A.readJson(n),f=a$1.registries||{},l={},m=[];for(let[g,w]of Object.entries(c))f[g]?m.push(g):l[g]=w;if(Object.keys(l).length===0){if(m.length>0&&!r.silent){w(`Skipped ${or(m.length,"registry","registries")}: (already configured)`,{silent:r.silent})?.info();for(let g of m)b.log(` - ${g}`);}else r.silent||b.info("No new registries to add.");return}let d$1={...a$1,registries:{...f,...l}},h=w("Updating components.json.",{silent:r.silent}).start();if(await A.writeJson(n,d$1,{spaces:2}),h.succeed(),!r.silent){let g=Object.keys(l);w(`Added ${or(g.length,"registry","registries")}:`,{silent:r.silent})?.succeed();for(let w of g)b.log(` - ${w}`);if(m.length>0){w(`Skipped ${or(m.length,"registry","registries")}: (already configured)`,{silent:r.silent})?.info();for(let w of m)b.log(` - ${w}`);}}}async function qs(e){let t=w("Fetching registries.",{silent:e.silent}).start(),r=await ma();if(!r)throw t.fail(),new Error("Failed to fetch registries.");t.succeed();let n=[...r].sort((o,s)=>o.name.localeCompare(s.name)),{selected:i}=await pe({type:"autocompleteMultiselect",name:"selected",message:"Which registries would you like to add?",hint:"Space to select. A to toggle all. Enter to submit.",instructions:false,choices:n.map(o=>({title:o.name,description:o.description,value:o.name}))});return i?.length||(b.warn("No registries selected. Exiting."),b.info(""),process.exit(1)),i}var lo=new Command().name("registry").description("manage registries").addCommand(co);var Qs=z.object({cwd:z.string(),query:z.string().optional(),limit:z.number().optional(),offset:z.number().optional()}),mo=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 r=Qs.parse({cwd:te__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 X(r.cwd);let n=T({style:"new-york",resolvedPaths:{cwd:r.cwd}}),i=U$1(n),o=te__default.resolve(r.cwd,"components.json");if(A.existsSync(o)){let l=await A.readJson(o),m=c.partial().parse(l);i=U$1({...n,...m});}let s=i;try{let l=await N(r.cwd);l&&(s=U$1(l));}catch{}let{config:c$1,newRegistries:a}=await _(e.map(l=>`${l}/registry`),s,{silent:!0,writeFile:!1});a.length>0&&(s.registries=c$1.registries),W(e,s);let f=await va(e,{query:r.query,limit:r.limit,offset:r.offset,config:s});console.log(JSON.stringify(f,null,2)),process.exit(0);}catch(r){$(r);}finally{V();}});var ta=z.object({cwd:z.string()}),yo=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 r=ta.parse({cwd:te__default.resolve(t.cwd)});await X(r.cwd);let n=U$1({}),i=te__default.resolve(r.cwd,"components.json");if(A.existsSync(i)){let f=await A.readJson(i),l=c.partial().parse(f);n=U$1(l);}let o=n;try{let f=await N(r.cwd);f&&(o=U$1(f));}catch{}let{config:s,newRegistries:c$1}=await _(e,o,{silent:!0,writeFile:!1});c$1.length>0&&(o.registries=s.registries),W(e,o);let a=await ba(e,{config:o});console.log(JSON.stringify(a,null,2)),process.exit(0);}catch(r){$(r);}finally{V();}});var wo={version:"4.0.7-beta.1"};process.on("SIGINT",()=>process.exit(0));process.on("SIGTERM",()=>process.exit(0));async function oa(){let e=new Command().name("shadcn").description("build your component library").version(wo.version,"-v, --version","display the version number");e.addCommand(Sn).addCommand(_n).addCommand(Jn).addCommand(Gn).addCommand(yo).addCommand(mo).addCommand(so).addCommand(Kn).addCommand(Bn).addCommand(Xt).addCommand(lo),e.parse();}oa();
|
package/dist/mcp/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export{b as server}from'../chunk-
|
|
1
|
+
export{b as server}from'../chunk-BRAYUB7V.js';import'../chunk-2QWB2ZQC.js';import'../chunk-HW2MEAJZ.js';import'../chunk-JPE2JKEP.js';import'../chunk-CHWMSXYA.js';
|
package/dist/registry/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export{p as RegistriesIndexParseError,f as RegistryError,j as RegistryFetchError,i as RegistryForbiddenError,o as RegistryInvalidNamespaceError,l as RegistryLocalFileError,n as RegistryMissingEnvironmentVariablesError,k as RegistryNotConfiguredError,g as RegistryNotFoundError,m as RegistryParseError,h as RegistryUnauthorizedError,ma as getRegistries,na as getRegistriesIndex,aa as getRegistry,ba as getRegistryItems,ca as resolveRegistryItems,va as searchRegistries}from'../chunk-
|
|
1
|
+
export{p as RegistriesIndexParseError,f as RegistryError,j as RegistryFetchError,i as RegistryForbiddenError,o as RegistryInvalidNamespaceError,l as RegistryLocalFileError,n as RegistryMissingEnvironmentVariablesError,k as RegistryNotConfiguredError,g as RegistryNotFoundError,m as RegistryParseError,h as RegistryUnauthorizedError,ma as getRegistries,na as getRegistriesIndex,aa as getRegistry,ba as getRegistryItems,ca as resolveRegistryItems,va as searchRegistries}from'../chunk-2QWB2ZQC.js';import'../chunk-HW2MEAJZ.js';import'../chunk-JPE2JKEP.js';import'../chunk-CHWMSXYA.js';
|
package/dist/schema/index.d.ts
CHANGED
|
@@ -557,6 +557,7 @@ declare const registryItemFontSchema: z.ZodObject<{
|
|
|
557
557
|
weight: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
|
|
558
558
|
subsets: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
|
|
559
559
|
selector: z.ZodOptional<z.ZodString>;
|
|
560
|
+
dependency: z.ZodOptional<z.ZodString>;
|
|
560
561
|
}, "strip", z.ZodTypeAny, {
|
|
561
562
|
family: string;
|
|
562
563
|
provider: "google";
|
|
@@ -565,6 +566,7 @@ declare const registryItemFontSchema: z.ZodObject<{
|
|
|
565
566
|
weight?: string[] | undefined;
|
|
566
567
|
subsets?: string[] | undefined;
|
|
567
568
|
selector?: string | undefined;
|
|
569
|
+
dependency?: string | undefined;
|
|
568
570
|
}, {
|
|
569
571
|
family: string;
|
|
570
572
|
provider: "google";
|
|
@@ -573,6 +575,7 @@ declare const registryItemFontSchema: z.ZodObject<{
|
|
|
573
575
|
weight?: string[] | undefined;
|
|
574
576
|
subsets?: string[] | undefined;
|
|
575
577
|
selector?: string | undefined;
|
|
578
|
+
dependency?: string | undefined;
|
|
576
579
|
}>;
|
|
577
580
|
declare const registryItemCommonSchema: z.ZodObject<{
|
|
578
581
|
$schema: z.ZodOptional<z.ZodString>;
|
|
@@ -1174,6 +1177,7 @@ declare const registryItemSchema: z.ZodDiscriminatedUnion<"type", [z.ZodObject<{
|
|
|
1174
1177
|
weight: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
|
|
1175
1178
|
subsets: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
|
|
1176
1179
|
selector: z.ZodOptional<z.ZodString>;
|
|
1180
|
+
dependency: z.ZodOptional<z.ZodString>;
|
|
1177
1181
|
}, "strip", z.ZodTypeAny, {
|
|
1178
1182
|
family: string;
|
|
1179
1183
|
provider: "google";
|
|
@@ -1182,6 +1186,7 @@ declare const registryItemSchema: z.ZodDiscriminatedUnion<"type", [z.ZodObject<{
|
|
|
1182
1186
|
weight?: string[] | undefined;
|
|
1183
1187
|
subsets?: string[] | undefined;
|
|
1184
1188
|
selector?: string | undefined;
|
|
1189
|
+
dependency?: string | undefined;
|
|
1185
1190
|
}, {
|
|
1186
1191
|
family: string;
|
|
1187
1192
|
provider: "google";
|
|
@@ -1190,6 +1195,7 @@ declare const registryItemSchema: z.ZodDiscriminatedUnion<"type", [z.ZodObject<{
|
|
|
1190
1195
|
weight?: string[] | undefined;
|
|
1191
1196
|
subsets?: string[] | undefined;
|
|
1192
1197
|
selector?: string | undefined;
|
|
1198
|
+
dependency?: string | undefined;
|
|
1193
1199
|
}>;
|
|
1194
1200
|
}, "strip", z.ZodTypeAny, {
|
|
1195
1201
|
type: "registry:font";
|
|
@@ -1202,6 +1208,7 @@ declare const registryItemSchema: z.ZodDiscriminatedUnion<"type", [z.ZodObject<{
|
|
|
1202
1208
|
weight?: string[] | undefined;
|
|
1203
1209
|
subsets?: string[] | undefined;
|
|
1204
1210
|
selector?: string | undefined;
|
|
1211
|
+
dependency?: string | undefined;
|
|
1205
1212
|
};
|
|
1206
1213
|
tailwind?: {
|
|
1207
1214
|
config?: {
|
|
@@ -1250,6 +1257,7 @@ declare const registryItemSchema: z.ZodDiscriminatedUnion<"type", [z.ZodObject<{
|
|
|
1250
1257
|
weight?: string[] | undefined;
|
|
1251
1258
|
subsets?: string[] | undefined;
|
|
1252
1259
|
selector?: string | undefined;
|
|
1260
|
+
dependency?: string | undefined;
|
|
1253
1261
|
};
|
|
1254
1262
|
tailwind?: {
|
|
1255
1263
|
config?: {
|
|
@@ -1901,6 +1909,7 @@ declare const registrySchema: z.ZodObject<{
|
|
|
1901
1909
|
weight: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
|
|
1902
1910
|
subsets: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
|
|
1903
1911
|
selector: z.ZodOptional<z.ZodString>;
|
|
1912
|
+
dependency: z.ZodOptional<z.ZodString>;
|
|
1904
1913
|
}, "strip", z.ZodTypeAny, {
|
|
1905
1914
|
family: string;
|
|
1906
1915
|
provider: "google";
|
|
@@ -1909,6 +1918,7 @@ declare const registrySchema: z.ZodObject<{
|
|
|
1909
1918
|
weight?: string[] | undefined;
|
|
1910
1919
|
subsets?: string[] | undefined;
|
|
1911
1920
|
selector?: string | undefined;
|
|
1921
|
+
dependency?: string | undefined;
|
|
1912
1922
|
}, {
|
|
1913
1923
|
family: string;
|
|
1914
1924
|
provider: "google";
|
|
@@ -1917,6 +1927,7 @@ declare const registrySchema: z.ZodObject<{
|
|
|
1917
1927
|
weight?: string[] | undefined;
|
|
1918
1928
|
subsets?: string[] | undefined;
|
|
1919
1929
|
selector?: string | undefined;
|
|
1930
|
+
dependency?: string | undefined;
|
|
1920
1931
|
}>;
|
|
1921
1932
|
}, "strip", z.ZodTypeAny, {
|
|
1922
1933
|
type: "registry:font";
|
|
@@ -1929,6 +1940,7 @@ declare const registrySchema: z.ZodObject<{
|
|
|
1929
1940
|
weight?: string[] | undefined;
|
|
1930
1941
|
subsets?: string[] | undefined;
|
|
1931
1942
|
selector?: string | undefined;
|
|
1943
|
+
dependency?: string | undefined;
|
|
1932
1944
|
};
|
|
1933
1945
|
tailwind?: {
|
|
1934
1946
|
config?: {
|
|
@@ -1977,6 +1989,7 @@ declare const registrySchema: z.ZodObject<{
|
|
|
1977
1989
|
weight?: string[] | undefined;
|
|
1978
1990
|
subsets?: string[] | undefined;
|
|
1979
1991
|
selector?: string | undefined;
|
|
1992
|
+
dependency?: string | undefined;
|
|
1980
1993
|
};
|
|
1981
1994
|
tailwind?: {
|
|
1982
1995
|
config?: {
|
|
@@ -2263,6 +2276,7 @@ declare const registrySchema: z.ZodObject<{
|
|
|
2263
2276
|
weight?: string[] | undefined;
|
|
2264
2277
|
subsets?: string[] | undefined;
|
|
2265
2278
|
selector?: string | undefined;
|
|
2279
|
+
dependency?: string | undefined;
|
|
2266
2280
|
};
|
|
2267
2281
|
tailwind?: {
|
|
2268
2282
|
config?: {
|
|
@@ -2422,6 +2436,7 @@ declare const registrySchema: z.ZodObject<{
|
|
|
2422
2436
|
weight?: string[] | undefined;
|
|
2423
2437
|
subsets?: string[] | undefined;
|
|
2424
2438
|
selector?: string | undefined;
|
|
2439
|
+
dependency?: string | undefined;
|
|
2425
2440
|
};
|
|
2426
2441
|
tailwind?: {
|
|
2427
2442
|
config?: {
|
|
@@ -2938,6 +2953,7 @@ declare const registryIndexSchema: z.ZodArray<z.ZodDiscriminatedUnion<"type", [z
|
|
|
2938
2953
|
weight: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
|
|
2939
2954
|
subsets: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
|
|
2940
2955
|
selector: z.ZodOptional<z.ZodString>;
|
|
2956
|
+
dependency: z.ZodOptional<z.ZodString>;
|
|
2941
2957
|
}, "strip", z.ZodTypeAny, {
|
|
2942
2958
|
family: string;
|
|
2943
2959
|
provider: "google";
|
|
@@ -2946,6 +2962,7 @@ declare const registryIndexSchema: z.ZodArray<z.ZodDiscriminatedUnion<"type", [z
|
|
|
2946
2962
|
weight?: string[] | undefined;
|
|
2947
2963
|
subsets?: string[] | undefined;
|
|
2948
2964
|
selector?: string | undefined;
|
|
2965
|
+
dependency?: string | undefined;
|
|
2949
2966
|
}, {
|
|
2950
2967
|
family: string;
|
|
2951
2968
|
provider: "google";
|
|
@@ -2954,6 +2971,7 @@ declare const registryIndexSchema: z.ZodArray<z.ZodDiscriminatedUnion<"type", [z
|
|
|
2954
2971
|
weight?: string[] | undefined;
|
|
2955
2972
|
subsets?: string[] | undefined;
|
|
2956
2973
|
selector?: string | undefined;
|
|
2974
|
+
dependency?: string | undefined;
|
|
2957
2975
|
}>;
|
|
2958
2976
|
}, "strip", z.ZodTypeAny, {
|
|
2959
2977
|
type: "registry:font";
|
|
@@ -2966,6 +2984,7 @@ declare const registryIndexSchema: z.ZodArray<z.ZodDiscriminatedUnion<"type", [z
|
|
|
2966
2984
|
weight?: string[] | undefined;
|
|
2967
2985
|
subsets?: string[] | undefined;
|
|
2968
2986
|
selector?: string | undefined;
|
|
2987
|
+
dependency?: string | undefined;
|
|
2969
2988
|
};
|
|
2970
2989
|
tailwind?: {
|
|
2971
2990
|
config?: {
|
|
@@ -3014,6 +3033,7 @@ declare const registryIndexSchema: z.ZodArray<z.ZodDiscriminatedUnion<"type", [z
|
|
|
3014
3033
|
weight?: string[] | undefined;
|
|
3015
3034
|
subsets?: string[] | undefined;
|
|
3016
3035
|
selector?: string | undefined;
|
|
3036
|
+
dependency?: string | undefined;
|
|
3017
3037
|
};
|
|
3018
3038
|
tailwind?: {
|
|
3019
3039
|
config?: {
|
|
@@ -3486,6 +3506,7 @@ declare const registryResolvedItemsTreeSchema: z.ZodObject<Pick<{
|
|
|
3486
3506
|
weight: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
|
|
3487
3507
|
subsets: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
|
|
3488
3508
|
selector: z.ZodOptional<z.ZodString>;
|
|
3509
|
+
dependency: z.ZodOptional<z.ZodString>;
|
|
3489
3510
|
}, "strip", z.ZodTypeAny, {
|
|
3490
3511
|
family: string;
|
|
3491
3512
|
provider: "google";
|
|
@@ -3494,6 +3515,7 @@ declare const registryResolvedItemsTreeSchema: z.ZodObject<Pick<{
|
|
|
3494
3515
|
weight?: string[] | undefined;
|
|
3495
3516
|
subsets?: string[] | undefined;
|
|
3496
3517
|
selector?: string | undefined;
|
|
3518
|
+
dependency?: string | undefined;
|
|
3497
3519
|
}, {
|
|
3498
3520
|
family: string;
|
|
3499
3521
|
provider: "google";
|
|
@@ -3502,6 +3524,7 @@ declare const registryResolvedItemsTreeSchema: z.ZodObject<Pick<{
|
|
|
3502
3524
|
weight?: string[] | undefined;
|
|
3503
3525
|
subsets?: string[] | undefined;
|
|
3504
3526
|
selector?: string | undefined;
|
|
3527
|
+
dependency?: string | undefined;
|
|
3505
3528
|
}>;
|
|
3506
3529
|
}, "strip", z.ZodTypeAny, {
|
|
3507
3530
|
type: "registry:font";
|
|
@@ -3514,6 +3537,7 @@ declare const registryResolvedItemsTreeSchema: z.ZodObject<Pick<{
|
|
|
3514
3537
|
weight?: string[] | undefined;
|
|
3515
3538
|
subsets?: string[] | undefined;
|
|
3516
3539
|
selector?: string | undefined;
|
|
3540
|
+
dependency?: string | undefined;
|
|
3517
3541
|
};
|
|
3518
3542
|
tailwind?: {
|
|
3519
3543
|
config?: {
|
|
@@ -3562,6 +3586,7 @@ declare const registryResolvedItemsTreeSchema: z.ZodObject<Pick<{
|
|
|
3562
3586
|
weight?: string[] | undefined;
|
|
3563
3587
|
subsets?: string[] | undefined;
|
|
3564
3588
|
selector?: string | undefined;
|
|
3589
|
+
dependency?: string | undefined;
|
|
3565
3590
|
};
|
|
3566
3591
|
tailwind?: {
|
|
3567
3592
|
config?: {
|
|
@@ -3640,6 +3665,7 @@ declare const registryResolvedItemsTreeSchema: z.ZodObject<Pick<{
|
|
|
3640
3665
|
weight?: string[] | undefined;
|
|
3641
3666
|
subsets?: string[] | undefined;
|
|
3642
3667
|
selector?: string | undefined;
|
|
3668
|
+
dependency?: string | undefined;
|
|
3643
3669
|
};
|
|
3644
3670
|
tailwind?: {
|
|
3645
3671
|
config?: {
|
|
@@ -3718,6 +3744,7 @@ declare const registryResolvedItemsTreeSchema: z.ZodObject<Pick<{
|
|
|
3718
3744
|
weight?: string[] | undefined;
|
|
3719
3745
|
subsets?: string[] | undefined;
|
|
3720
3746
|
selector?: string | undefined;
|
|
3747
|
+
dependency?: string | undefined;
|
|
3721
3748
|
};
|
|
3722
3749
|
tailwind?: {
|
|
3723
3750
|
config?: {
|
package/dist/schema/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export{z as configJsonSchema,d as configSchema,r as iconsSchema,y as presetSchema,c as rawConfigSchema,w as registriesIndexSchema,x as registriesSchema,s as registryBaseColorSchema,a as registryConfigItemSchema,b as registryConfigSchema,p as registryIndexSchema,m as registryItemCommonSchema,j as registryItemCssSchema,i as registryItemCssVarsSchema,k as registryItemEnvVarsSchema,g as registryItemFileSchema,l as registryItemFontSchema,n as registryItemSchema,h as registryItemTailwindSchema,f as registryItemTypeSchema,t as registryResolvedItemsTreeSchema,o as registrySchema,u as searchResultItemSchema,v as searchResultsSchema,q as stylesSchema,e as workspaceConfigSchema}from'../chunk-
|
|
1
|
+
export{z as configJsonSchema,d as configSchema,r as iconsSchema,y as presetSchema,c as rawConfigSchema,w as registriesIndexSchema,x as registriesSchema,s as registryBaseColorSchema,a as registryConfigItemSchema,b as registryConfigSchema,p as registryIndexSchema,m as registryItemCommonSchema,j as registryItemCssSchema,i as registryItemCssVarsSchema,k as registryItemEnvVarsSchema,g as registryItemFileSchema,l as registryItemFontSchema,n as registryItemSchema,h as registryItemTailwindSchema,f as registryItemTypeSchema,t as registryResolvedItemsTreeSchema,o as registrySchema,u as searchResultItemSchema,v as searchResultsSchema,q as stylesSchema,e as workspaceConfigSchema}from'../chunk-HW2MEAJZ.js';
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "shadcn",
|
|
3
|
-
"version": "4.0.
|
|
3
|
+
"version": "4.0.7-beta.1",
|
|
4
4
|
"description": "Add components to your apps.",
|
|
5
5
|
"publishConfig": {
|
|
6
6
|
"access": "public"
|
|
@@ -60,6 +60,24 @@
|
|
|
60
60
|
}
|
|
61
61
|
},
|
|
62
62
|
"bin": "./dist/index.js",
|
|
63
|
+
"scripts": {
|
|
64
|
+
"dev": "tsup --watch",
|
|
65
|
+
"build": "tsup",
|
|
66
|
+
"typecheck": "tsc --noEmit",
|
|
67
|
+
"clean": "rimraf dist && rimraf components",
|
|
68
|
+
"start:dev": "cross-env REGISTRY_URL=http://localhost:4000/r SHADCN_TEMPLATE_DIR=../../templates node dist/index.js",
|
|
69
|
+
"start:prod": "cross-env REGISTRY_URL=https://ui.shadcn.com/r node dist/index.js",
|
|
70
|
+
"start": "node dist/index.js",
|
|
71
|
+
"format:write": "prettier --write \"**/*.{ts,tsx,mdx}\" --cache",
|
|
72
|
+
"format:check": "prettier --check \"**/*.{ts,tsx,mdx}\" --cache",
|
|
73
|
+
"release": "changeset version",
|
|
74
|
+
"pub:beta": "pnpm build && pnpm publish --no-git-checks --access public --tag beta",
|
|
75
|
+
"pub:next": "pnpm build && pnpm publish --no-git-checks --access public --tag next",
|
|
76
|
+
"pub:release": "pnpm build && pnpm publish --access public",
|
|
77
|
+
"test": "vitest run",
|
|
78
|
+
"test:dev": "REGISTRY_URL=http://localhost:4000/r SHADCN_TEMPLATE_DIR=../../templates vitest run",
|
|
79
|
+
"mcp:inspect": "pnpm dlx @modelcontextprotocol/inspector node dist/index.js mcp"
|
|
80
|
+
},
|
|
63
81
|
"dependencies": {
|
|
64
82
|
"@antfu/ni": "^25.0.0",
|
|
65
83
|
"@babel/core": "^7.28.0",
|
|
@@ -106,23 +124,5 @@
|
|
|
106
124
|
"tsup": "^8.5.0",
|
|
107
125
|
"type-fest": "^4.41.0",
|
|
108
126
|
"typescript": "^5.9.2"
|
|
109
|
-
},
|
|
110
|
-
"scripts": {
|
|
111
|
-
"dev": "tsup --watch",
|
|
112
|
-
"build": "tsup",
|
|
113
|
-
"typecheck": "tsc --noEmit",
|
|
114
|
-
"clean": "rimraf dist && rimraf components",
|
|
115
|
-
"start:dev": "cross-env REGISTRY_URL=http://localhost:4000/r SHADCN_TEMPLATE_DIR=../../templates node dist/index.js",
|
|
116
|
-
"start:prod": "cross-env REGISTRY_URL=https://ui.shadcn.com/r node dist/index.js",
|
|
117
|
-
"start": "node dist/index.js",
|
|
118
|
-
"format:write": "prettier --write \"**/*.{ts,tsx,mdx}\" --cache",
|
|
119
|
-
"format:check": "prettier --check \"**/*.{ts,tsx,mdx}\" --cache",
|
|
120
|
-
"release": "changeset version",
|
|
121
|
-
"pub:beta": "pnpm build && pnpm publish --no-git-checks --access public --tag beta",
|
|
122
|
-
"pub:next": "pnpm build && pnpm publish --no-git-checks --access public --tag next",
|
|
123
|
-
"pub:release": "pnpm build && pnpm publish --access public",
|
|
124
|
-
"test": "vitest run",
|
|
125
|
-
"test:dev": "REGISTRY_URL=http://localhost:4000/r SHADCN_TEMPLATE_DIR=../../templates vitest run",
|
|
126
|
-
"mcp:inspect": "pnpm dlx @modelcontextprotocol/inspector node dist/index.js mcp"
|
|
127
127
|
}
|
|
128
|
-
}
|
|
128
|
+
}
|
package/LICENSE.md
DELETED
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
MIT License
|
|
2
|
-
|
|
3
|
-
Copyright (c) 2023 shadcn
|
|
4
|
-
|
|
5
|
-
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
-
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
-
in the Software without restriction, including without limitation the rights
|
|
8
|
-
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
-
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
-
furnished to do so, subject to the following conditions:
|
|
11
|
-
|
|
12
|
-
The above copyright notice and this permission notice shall be included in all
|
|
13
|
-
copies or substantial portions of the Software.
|
|
14
|
-
|
|
15
|
-
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
-
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
-
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
-
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
-
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
-
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
-
SOFTWARE.
|