shadcn 2.6.4 → 2.7.0
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-63R22Q5C.js → chunk-CRHL7BFC.js} +2 -2
- package/dist/chunk-JJ2VRW56.js +29 -0
- package/dist/chunk-JJ2VRW56.js.map +1 -0
- package/dist/index.js +48 -47
- package/dist/index.js.map +1 -1
- package/dist/mcp/index.js +2 -2
- package/dist/registry/index.js +1 -1
- package/package.json +1 -1
- package/dist/chunk-26TTVK5I.js +0 -29
- package/dist/chunk-26TTVK5I.js.map +0 -1
- /package/dist/{chunk-63R22Q5C.js.map → chunk-CRHL7BFC.js.map} +0 -0
package/dist/index.js
CHANGED
|
@@ -1,83 +1,84 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
import { a as a$1 } from './chunk-
|
|
3
|
-
import { I, W, M, q, a, s, n, h, o, r, i, K
|
|
4
|
-
export { I as BASE_COLORS, T as clearRegistryCache, S as fetchRegistry, Q as fetchTree, R as getItemTargetPath, O as getRegistryBaseColor, N as getRegistryBaseColors, L as getRegistryIcons, J as getRegistryIndex, M as getRegistryItem, Z as getRegistryParentMap, K as getRegistryStyles, Y as getRegistryTypeAliasMap, W as isUrl, V as registryGetTheme, U as registryResolveItemsTree, X as resolveRegistryItems, P as resolveTree } from './chunk-
|
|
2
|
+
import { a as a$1 } from './chunk-CRHL7BFC.js';
|
|
3
|
+
import { I, W, M, q, a, s, n, h, o, r, i, K, N, e, f, c, d, g, p, J, C, B as B$1, Q as Q$1, O, R, j, U, t, X, S as S$1, Z as Z$1, Y, l, k, u, v, L as L$1, m, b } from './chunk-JJ2VRW56.js';
|
|
4
|
+
export { I as BASE_COLORS, T as clearRegistryCache, S as fetchRegistry, Q as fetchTree, R as getItemTargetPath, O as getRegistryBaseColor, N as getRegistryBaseColors, L as getRegistryIcons, J as getRegistryIndex, M as getRegistryItem, Z as getRegistryParentMap, K as getRegistryStyles, Y as getRegistryTypeAliasMap, W as isUrl, V as registryGetTheme, U as registryResolveItemsTree, X as resolveRegistryItems, P as resolveTree } from './chunk-JJ2VRW56.js';
|
|
5
5
|
import * as S from 'path';
|
|
6
6
|
import S__default, { basename } from 'path';
|
|
7
7
|
import { promises, existsSync } from 'fs';
|
|
8
|
-
import
|
|
8
|
+
import te from 'fs-extra';
|
|
9
9
|
import v$1 from 'postcss';
|
|
10
10
|
import kr from 'postcss/lib/at-rule';
|
|
11
11
|
import { z } from 'zod';
|
|
12
12
|
import { detect } from '@antfu/ni';
|
|
13
13
|
import { execa } from 'execa';
|
|
14
|
-
import
|
|
15
|
-
import
|
|
14
|
+
import Ze from 'prompts';
|
|
15
|
+
import ji, { tmpdir } from 'os';
|
|
16
16
|
import { Project, ScriptKind, SyntaxKind } from 'ts-morph';
|
|
17
17
|
import { transformFromAstSync } from '@babel/core';
|
|
18
18
|
import { parse } from '@babel/parser';
|
|
19
|
-
import
|
|
20
|
-
import * as
|
|
19
|
+
import ii from '@babel/plugin-transform-typescript';
|
|
20
|
+
import * as Ce from 'recast';
|
|
21
21
|
import { loadConfig } from 'tsconfig-paths';
|
|
22
22
|
import { Command } from 'commander';
|
|
23
23
|
import * as B from 'fs/promises';
|
|
24
24
|
import B__default from 'fs/promises';
|
|
25
25
|
import { diffLines } from 'diff';
|
|
26
26
|
import { randomBytes } from 'crypto';
|
|
27
|
-
import
|
|
27
|
+
import tn from 'fast-glob';
|
|
28
28
|
import { StdioServerTransport } from '@modelcontextprotocol/sdk/server/stdio.js';
|
|
29
29
|
|
|
30
|
-
var
|
|
31
|
-
To start over, remove the ${a.info("components.json")} file and run ${a.info("init")} again.`),q.break(),process.exit(1)),r$1?.succeed();let i=r("Verifying framework.",{silent:e.silent}).start(),
|
|
32
|
-
Visit ${a.info(
|
|
33
|
-
Once configured, you can use the cli to add components.`),q.break(),process.exit(1)),i?.succeed(`Verifying framework. Found ${a.info(
|
|
30
|
+
var F="1";var _="3";var ae="5",Ke="6",$t="7";var Q="13";async function Nt(e){let t={};if(!te.existsSync(e.cwd)||!te.existsSync(S__default.resolve(e.cwd,"package.json")))return t[F]=!0,{errors:t,projectInfo:null};let r$1=r("Preflight checks.",{silent:e.silent}).start();te.existsSync(S__default.resolve(e.cwd,"components.json"))&&!e.force&&(r$1?.fail(),q.break(),q.error(`A ${a.info("components.json")} file already exists at ${a.info(e.cwd)}.
|
|
31
|
+
To start over, remove the ${a.info("components.json")} file and run ${a.info("init")} again.`),q.break(),process.exit(1)),r$1?.succeed();let i=r("Verifying framework.",{silent:e.silent}).start(),n$1=await n(e.cwd);(!n$1||n$1?.framework.name==="manual")&&(t[$t]=!0,i?.fail(),q.break(),n$1?.framework.links.installation&&q.error(`We could not detect a supported framework at ${a.info(e.cwd)}.
|
|
32
|
+
Visit ${a.info(n$1?.framework.links.installation)} to manually configure your project.
|
|
33
|
+
Once configured, you can use the cli to add components.`),q.break(),process.exit(1)),i?.succeed(`Verifying framework. Found ${a.info(n$1.framework.label)}.`);let o="Validating Tailwind CSS.";n$1.tailwindVersion==="v4"&&(o=`Validating Tailwind CSS config. Found ${a.info("v4")}.`);let a$1=r(o,{silent:e.silent}).start();n$1.tailwindVersion==="v3"&&(!n$1?.tailwindConfigFile||!n$1?.tailwindCssFile)?(t[ae]=!0,a$1?.fail()):n$1.tailwindVersion==="v4"&&!n$1?.tailwindCssFile?(t[ae]=!0,a$1?.fail()):n$1.tailwindVersion?a$1?.succeed():(t[ae]=!0,a$1?.fail());let s=r("Validating import alias.",{silent:e.silent}).start();return n$1?.aliasPrefix?s?.succeed():(t[Ke]=!0,s?.fail()),Object.keys(t).length>0&&(t[ae]&&(q.break(),q.error(`No Tailwind CSS configuration found at ${a.info(e.cwd)}.`),q.error("It is likely you do not have Tailwind CSS installed or have an invalid configuration."),q.error("Install Tailwind CSS then try again."),n$1?.framework.links.tailwind&&q.error(`Visit ${a.info(n$1?.framework.links.tailwind)} to get started.`)),t[Ke]&&(q.break(),q.error("No import alias found in your tsconfig.json file."),n$1?.framework.links.installation&&q.error(`Visit ${a.info(n$1?.framework.links.installation)} to learn how to set an import alias.`)),q.break(),process.exit(1)),{errors:t,projectInfo:n$1}}async function Je(e,t,r$1){if(!t.resolvedPaths.tailwindCss||!e||Object.keys(e).length===0)return;r$1={silent:!1,...r$1};let i=t.resolvedPaths.tailwindCss,n=S__default.relative(t.resolvedPaths.cwd,i),o=r(`Updating ${a.info(n)}`,{silent:r$1.silent}).start(),a$1=await promises.readFile(i,"utf8"),s=await Ir(a$1,e);await promises.writeFile(i,s,"utf8"),o.succeed();}async function Ir(e,t){let r=[Pr(t)],n=(await v$1(r).process(e,{from:void 0})).css;return n=n.replace(/\/\* ---break--- \*\//g,""),n=n.replace(/(\n\s*\n)+/g,`
|
|
34
34
|
|
|
35
|
-
`),
|
|
35
|
+
`),n=n.trimEnd(),n}function Pr(e){return {postcssPlugin:"update-css",Once(t){for(let[r,i]of Object.entries(e))if(r.startsWith("@")){let n=r.match(/@([a-zA-Z-]+)\s*(.*)/);if(!n)continue;let[,o,a]=n;if(o==="plugin"){if(!t.nodes?.find(c=>c.type==="atrule"&&c.name==="plugin"&&c.params===a)){let c=v$1.atRule({name:"plugin",params:a,raws:{semicolon:!0,before:`
|
|
36
|
+
`}}),l=t.nodes?.filter(m=>m.type==="atrule"&&m.name==="import"),f=t.nodes?.filter(m=>m.type==="atrule"&&m.name==="plugin");if(f&&f.length>0){let m=f[f.length-1];t.insertAfter(m,c);}else if(l&&l.length>0){let m=l[l.length-1];t.insertAfter(m,c),t.insertBefore(c,v$1.comment({text:"---break---"})),t.insertAfter(c,v$1.comment({text:"---break---"}));}else t.prepend(c),t.insertBefore(c,v$1.comment({text:"---break---"})),t.insertAfter(c,v$1.comment({text:"---break---"}));}}else if(o==="keyframes"){let s=t.nodes?.find(l=>l.type==="atrule"&&l.name==="theme"&&l.params==="inline");s||(s=v$1.atRule({name:"theme",params:"inline",raws:{semicolon:!0,between:" ",before:`
|
|
36
37
|
`}}),t.append(s),t.insertBefore(s,v$1.comment({text:"---break---"})));let c=v$1.atRule({name:"keyframes",params:a,raws:{semicolon:!0,between:" ",before:`
|
|
37
|
-
`}});if(s.append(c),typeof i=="object")for(let[l,
|
|
38
|
-
`}});
|
|
39
|
-
`}});if(t.append(c),t.insertBefore(c,v$1.comment({text:"---break---"})),typeof i=="object")for(let[l,
|
|
40
|
-
`}});c.append(
|
|
41
|
-
`}}),e.append(
|
|
38
|
+
`}});if(s.append(c),typeof i=="object")for(let[l,f]of Object.entries(i))ie(c,l,f);}else if(o==="utility"){let s=t.nodes?.find(c=>c.type==="atrule"&&c.name===o&&c.params===a);if(s){if(typeof i=="object")for(let[c,l]of Object.entries(i))if(typeof l=="string"){let f=s.nodes?.find(u=>u.type==="decl"&&u.prop===c),m=v$1.decl({prop:c,value:l,raws:{semicolon:!0,before:`
|
|
39
|
+
`}});f?f.replaceWith(m):s.append(m);}else typeof l=="object"&&ie(s,c,l);}else {let c=v$1.atRule({name:o,params:a,raws:{semicolon:!0,between:" ",before:`
|
|
40
|
+
`}});if(t.append(c),t.insertBefore(c,v$1.comment({text:"---break---"})),typeof i=="object")for(let[l,f]of Object.entries(i))if(typeof f=="string"){let m=v$1.decl({prop:l,value:f,raws:{semicolon:!0,before:`
|
|
41
|
+
`}});c.append(m);}else typeof f=="object"&&ie(c,l,f);}}else Dt(t,o,a,i);}else ie(t,r,i);}}}function Dt(e,t,r,i){let n=e.nodes?.find(o=>o.type==="atrule"&&o.name===t&&o.params===r);if(n||(n=v$1.atRule({name:t,params:r,raws:{semicolon:!0,between:" ",before:`
|
|
42
|
+
`}}),e.append(n),e.insertBefore(n,v$1.comment({text:"---break---"}))),typeof i=="object")for(let[o,a]of Object.entries(i))if(o.startsWith("@")){let s=o.match(/@([a-zA-Z-]+)\s*(.*)/);if(s){let[,c,l]=s;Dt(n,c,l,a);}}else ie(n,o,a);else if(typeof i=="string")try{let a=v$1.parse(`.temp{${i}}`).first;if(a&&a.nodes){let s=v$1.rule({selector:"temp",raws:{semicolon:!0,between:" ",before:`
|
|
42
43
|
`}});a.nodes.forEach(c=>{if(c.type==="decl"){let l=c.clone();l.raws.before=`
|
|
43
|
-
`,s.append(l);}}),s.nodes?.length&&
|
|
44
|
-
`}}),e.append(i)),typeof r=="object"){for(let[o
|
|
45
|
-
`}}),s=i.nodes?.find(c=>c.type==="decl"&&c.prop===
|
|
46
|
-
`,i?.append(s);}});}catch(
|
|
44
|
+
`,s.append(l);}}),s.nodes?.length&&n.append(s);}}catch(o){throw console.error("Error parsing at-rule content:",i,o),o}}function ie(e,t,r){let i=e.nodes?.find(n=>n.type==="rule"&&n.selector===t);if(i||(i=v$1.rule({selector:t,raws:{semicolon:!0,between:" ",before:`
|
|
45
|
+
`}}),e.append(i)),typeof r=="object"){for(let[n,o]of Object.entries(r))if(typeof o=="string"){let a=v$1.decl({prop:n,value:o,raws:{semicolon:!0,before:`
|
|
46
|
+
`}}),s=i.nodes?.find(c=>c.type==="decl"&&c.prop===n);s?s.replaceWith(a):i.append(a);}else if(typeof o=="object"){let a=n.startsWith("&")?t.replace(/^([^:]+)/,`$1${n.substring(1)}`):n;ie(e,a,o);}}else if(typeof r=="string")try{let o=v$1.parse(`.temp{${r}}`).first;o&&o.nodes&&o.nodes.forEach(a=>{if(a.type==="decl"){let s=a.clone();s.raws.before=`
|
|
47
|
+
`,i?.append(s);}});}catch(n){throw console.error("Error parsing rule content:",t,r,n),n}}async function Ye(e,t,r$1){if(!t.resolvedPaths.tailwindCss||!Object.keys(e??{}).length)return;r$1={cleanupDefaultNextStyles:!1,silent:!1,tailwindVersion:"v3",overwriteCssVars:!1,initIndex:!0,...r$1};let i=t.resolvedPaths.tailwindCss,n=S__default.relative(t.resolvedPaths.cwd,i),o=r(`Updating CSS variables in ${a.info(n)}`,{silent:r$1.silent}).start(),a$1=await promises.readFile(i,"utf8"),s=await jr(a$1,e??{},t,{cleanupDefaultNextStyles:r$1.cleanupDefaultNextStyles,tailwindVersion:r$1.tailwindVersion,tailwindConfig:r$1.tailwindConfig,overwriteCssVars:r$1.overwriteCssVars,initIndex:r$1.initIndex});await promises.writeFile(i,s,"utf8"),o.succeed();}async function jr(e,t,r,i={cleanupDefaultNextStyles:!1,tailwindVersion:"v3",tailwindConfig:void 0,overwriteCssVars:!1,initIndex:!0}){i={cleanupDefaultNextStyles:!1,tailwindVersion:"v3",tailwindConfig:void 0,overwriteCssVars:!1,initIndex:!0,...i};let n=[Tr(t)];if(i.cleanupDefaultNextStyles&&n.push(Lt()),i.tailwindVersion==="v4"){if(n=[],r.resolvedPaths?.cwd){let s=m(r.resolvedPaths.cwd);!s?.dependencies?.["tailwindcss-animate"]&&!s?.devDependencies?.["tailwindcss-animate"]&&i.initIndex&&n.push(Dr({params:"tw-animate-css"}));}n.push(Ar({params:"dark (&:is(.dark *))"})),i.cleanupDefaultNextStyles&&n.push(Lt()),n.push(Or(t,{overwriteCssVars:i.overwriteCssVars})),n.push(Nr(t)),i.tailwindConfig&&(n.push(Fr(i.tailwindConfig)),n.push(Lr(i.tailwindConfig)),n.push(_r(i.tailwindConfig)));}r.tailwind.cssVariables&&i.initIndex&&n.push(Er({tailwindVersion:i.tailwindVersion}));let a=(await v$1(n).process(e,{from:void 0})).css;return a=a.replace(/\/\* ---break--- \*\//g,""),i.tailwindVersion==="v4"&&(a=a.replace(/(\n\s*\n)+/g,`
|
|
47
48
|
|
|
48
|
-
`)),a}function Er({tailwindVersion:e}){return {postcssPlugin:"update-base-layer",Once(t){let r=[{selector:"*",apply:e==="v4"?"border-border outline-ring/50":"border-border"},{selector:"body",apply:"bg-background text-foreground"}],i=t.nodes.find(
|
|
49
|
-
`}}),t.append(i),t.insertBefore(i,v$1.comment({text:"---break---"}))),r.forEach(({selector:
|
|
49
|
+
`)),a}function Er({tailwindVersion:e}){return {postcssPlugin:"update-base-layer",Once(t){let r=[{selector:"*",apply:e==="v4"?"border-border outline-ring/50":"border-border"},{selector:"body",apply:"bg-background text-foreground"}],i=t.nodes.find(n=>n.type==="atrule"&&n.name==="layer"&&n.params==="base"&&r.every(({selector:o,apply:a})=>n.nodes?.some(s=>s.type==="rule"&&s.selector===o&&s.nodes.some(c=>c.type==="atrule"&&c.name==="apply"&&c.params===a))));i||(i=v$1.atRule({name:"layer",params:"base",raws:{semicolon:!0,between:" ",before:`
|
|
50
|
+
`}}),t.append(i),t.insertBefore(i,v$1.comment({text:"---break---"}))),r.forEach(({selector:n,apply:o})=>{i?.nodes?.find(s=>s.type==="rule"&&s.selector===n)||i?.append(v$1.rule({selector:n,nodes:[v$1.atRule({name:"apply",params:o,raws:{semicolon:!0,before:`
|
|
50
51
|
`}})],raws:{semicolon:!0,between:" ",before:`
|
|
51
52
|
`}}));});}}}function Tr(e){return {postcssPlugin:"update-css-vars",Once(t){let r=t.nodes.find(i=>i.type==="atrule"&&i.name==="layer"&&i.params==="base");r instanceof kr||(r=v$1.atRule({name:"layer",params:"base",nodes:[],raws:{semicolon:!0,before:`
|
|
52
|
-
`,between:" "}}),t.append(r),t.insertBefore(r,v$1.comment({text:"---break---"}))),r!==void 0&&Object.entries(e).forEach(([i,
|
|
53
|
-
`}}),e.append(i)),Object.entries(r).forEach(([o
|
|
54
|
-
`}}),r.append(a),r.insertBefore(a,v$1.comment({text:"---break---"}))),Object.entries(
|
|
55
|
-
`}}),e.append(t),e.insertBefore(t,v$1.comment({text:"---break---"}))),t}function
|
|
56
|
-
`}});if(i.length>0){let
|
|
57
|
-
`}});if(r.length>0){let a=r[r.length-1];t.insertAfter(a,
|
|
58
|
-
`}});t.insertAfter(
|
|
59
|
-
`}});for(let[l,
|
|
53
|
+
`,between:" "}}),t.append(r),t.insertBefore(r,v$1.comment({text:"---break---"}))),r!==void 0&&Object.entries(e).forEach(([i,n])=>{let o=i==="light"?":root":`.${i}`;$r(r,o,n);});}}}function _t(e){let t=e.nodes.find(r=>r.type==="rule"&&r.selector===":root");if(t){let r=["--background","--foreground"];t.nodes.filter(i=>i.type==="decl"&&r.includes(i.prop)).forEach(i=>i.remove()),t.nodes.length===0&&t.remove();}}function Lt(){return {postcssPlugin:"cleanup-default-next-styles",Once(e){let t=e.nodes.find(i=>i.type==="rule"&&i.selector==="body");t&&(t.nodes.find(i=>i.type==="decl"&&i.prop==="color"&&["rgb(var(--foreground-rgb))","var(--foreground)"].includes(i.value))?.remove(),t.nodes.find(i=>i.type==="decl"&&i.prop==="background"&&(i.value.startsWith("linear-gradient")||i.value==="var(--background)"))?.remove(),t.nodes.find(i=>i.type==="decl"&&i.prop==="font-family"&&i.value==="Arial, Helvetica, sans-serif")?.remove(),t.nodes.length===0&&t.remove()),_t(e);let r=e.nodes.find(i=>i.type==="atrule"&&i.params==="(prefers-color-scheme: dark)");r&&(_t(r),r.nodes.length===0&&r.remove());}}}function $r(e,t,r){let i=e.nodes?.find(n=>n.type==="rule"&&n.selector===t);i||Object.keys(r).length>0&&(i=v$1.rule({selector:t,raws:{between:" ",before:`
|
|
54
|
+
`}}),e.append(i)),Object.entries(r).forEach(([n,o])=>{let a=`--${n.replace(/^--/,"")}`,s=v$1.decl({prop:a,value:o,raws:{semicolon:!0}}),c=i?.nodes.find(l=>l.type==="decl"&&l.prop===a);c?c.replaceWith(s):i?.append(s);});}function Or(e,t){return {postcssPlugin:"update-css-vars-v4",Once(r){Object.entries(e).forEach(([i,n])=>{let o=i==="light"?":root":`.${i}`;if(i==="theme"){o="@theme";let s=Se(r);Object.entries(n).forEach(([c,l])=>{let f=`--${c.replace(/^--/,"")}`,m=v$1.decl({prop:f,value:l,raws:{semicolon:!0}}),u=s?.nodes?.find(g=>g.type==="decl"&&g.prop===f);t.overwriteCssVars?u?u.replaceWith(m):s?.append(m):u||s?.append(m);});return}let a=r.nodes?.find(s=>s.type==="rule"&&s.selector===o);!a&&Object.keys(n).length>0&&(a=v$1.rule({selector:o,nodes:[],raws:{semicolon:!0,between:" ",before:`
|
|
55
|
+
`}}),r.append(a),r.insertBefore(a,v$1.comment({text:"---break---"}))),Object.entries(n).forEach(([s,c])=>{let l=`--${s.replace(/^--/,"")}`;l==="--sidebar-background"&&(l="--sidebar"),Vt(c)&&(c=`hsl(${c})`);let f=v$1.decl({prop:l,value:c,raws:{semicolon:!0}}),m=a?.nodes.find(u=>u.type==="decl"&&u.prop===l);t.overwriteCssVars?m?m.replaceWith(f):a?.append(f):m||a?.append(f);});});}}}function Nr(e){return {postcssPlugin:"update-theme",Once(t){let r=Array.from(new Set(Object.keys(e).flatMap(o=>Object.keys(e[o]||{}))));if(!r.length)return;let i=Se(t),n=i.nodes?.filter(o=>o.type==="decl"&&o.prop.startsWith("--"));for(let o of r){let a=Object.values(e).find(m=>m[o])?.[o];if(!a)continue;if(o==="radius"){let m={sm:"calc(var(--radius) - 4px)",md:"calc(var(--radius) - 2px)",lg:"var(--radius)",xl:"calc(var(--radius) + 4px)"};for(let[u,g]of Object.entries(m)){let y=v$1.decl({prop:`--radius-${u}`,value:g,raws:{semicolon:!0}});i?.nodes?.find(h=>h.type==="decl"&&h.prop===y.prop)||i?.append(y);}continue}let s=Vt(a)||Mr(a)?`--color-${o.replace(/^--/,"")}`:`--${o.replace(/^--/,"")}`;s==="--color-sidebar-background"&&(s="--color-sidebar");let c=`var(--${o})`;s==="--color-sidebar"&&(c="var(--sidebar)");let l=v$1.decl({prop:s,value:c,raws:{semicolon:!0}});i?.nodes?.find(m=>m.type==="decl"&&m.prop===l.prop)||(n?.length?i?.insertAfter(n[n.length-1],l):i?.append(l));}}}}function Se(e){let t=e.nodes.find(r=>r.type==="atrule"&&r.name==="theme"&&r.params==="inline");return t||(t=v$1.atRule({name:"theme",params:"inline",nodes:[],raws:{semicolon:!0,between:" ",before:`
|
|
56
|
+
`}}),e.append(t),e.insertBefore(t,v$1.comment({text:"---break---"}))),t}function Ar({params:e}){return {postcssPlugin:"add-custom-variant",Once(t){if(!t.nodes.find(i=>i.type==="atrule"&&i.name==="custom-variant")){let i=t.nodes.filter(o=>o.type==="atrule"&&o.name==="import"),n=v$1.atRule({name:"custom-variant",params:e,raws:{semicolon:!0,before:`
|
|
57
|
+
`}});if(i.length>0){let o=i[i.length-1];t.insertAfter(o,n);}else t.insertAfter(t.nodes[0],n);t.insertBefore(n,v$1.comment({text:"---break---"}));}}}}function Dr({params:e}){return {postcssPlugin:"add-custom-import",Once(t){let r=t.nodes.filter(o=>o.type==="atrule"&&o.name==="import"),i=t.nodes.find(o=>o.type==="atrule"&&o.name==="custom-variant");if(!r.some(o=>o.params.replace(/["']/g,"")===e)){let o=v$1.atRule({name:"import",params:`"${e}"`,raws:{semicolon:!0,before:`
|
|
58
|
+
`}});if(r.length>0){let a=r[r.length-1];t.insertAfter(a,o);}else i?(t.insertBefore(i,o),t.insertBefore(i,v$1.comment({text:"---break---"}))):(t.prepend(o),t.insertAfter(o,v$1.comment({text:"---break---"})));}}}}function Fr(e){return {postcssPlugin:"update-tailwind-config",Once(t){if(!e?.plugins)return;let i=Vr(t)==="single"?"'":'"',n=t.nodes.filter(a=>a.type==="atrule"&&a.name==="plugin"),o=n[n.length-1]||t.nodes[0];for(let a of e.plugins){let s=a.replace(/^require\(["']|["']\)$/g,"");if(n.some(l=>l.params.replace(/["']/g,"")===s))continue;let c=v$1.atRule({name:"plugin",params:`${i}${s}${i}`,raws:{semicolon:!0,before:`
|
|
59
|
+
`}});t.insertAfter(o,c),t.insertBefore(c,v$1.comment({text:"---break---"}));}}}}function _r(e){return {postcssPlugin:"update-tailwind-config-keyframes",Once(t){if(!e?.theme?.extend?.keyframes)return;let r=Se(t),i=r.nodes?.filter(o=>o.type==="atrule"&&o.name==="keyframes"),n=z.record(z.string(),z.record(z.string(),z.string()));for(let[o,a]of Object.entries(e.theme.extend.keyframes)){if(typeof o!="string")continue;let s=n.safeParse(a);if(!s.success||i?.find(l=>l.type==="atrule"&&l.name==="keyframes"&&l.params===o))continue;let c=v$1.atRule({name:"keyframes",params:o,nodes:[],raws:{semicolon:!0,between:" ",before:`
|
|
60
|
+
`}});for(let[l,f]of Object.entries(s.data)){let m=v$1.rule({selector:l,nodes:Object.entries(f).map(([u,g])=>v$1.decl({prop:u,value:g,raws:{semicolon:!0,before:`
|
|
60
61
|
`,between:": "}})),raws:{semicolon:!0,between:" ",before:`
|
|
61
|
-
`}});c.append(
|
|
62
|
-
`}});r.append(c);}}}}function Vr(e){return e.nodes[0].toString().includes("'")?"single":"double"}function
|
|
62
|
+
`}});c.append(m);}r.append(c),r.insertBefore(c,v$1.comment({text:"---break---"}));}}}}function Lr(e){return {postcssPlugin:"update-tailwind-config-animation",Once(t){if(!e?.theme?.extend?.animation)return;let r=Se(t),i=r.nodes?.filter(o=>o.type==="decl"&&o.prop.startsWith("--animate-")),n=z.record(z.string(),z.string()).safeParse(e.theme.extend.animation);if(n.success)for(let[o,a]of Object.entries(n.data)){let s=`--animate-${o}`;if(i?.find(l=>l.prop===s))continue;let c=v$1.decl({prop:s,value:a,raws:{semicolon:!0,between:": ",before:`
|
|
63
|
+
`}});r.append(c);}}}}function Vr(e){return e.nodes[0].toString().includes("'")?"single":"double"}function Vt(e){if(e.startsWith("hsl")||e.startsWith("rgb")||e.startsWith("#")||e.startsWith("oklch"))return !1;let t=e.split(" ");return t.length===3&&t.slice(1,3).every(r=>r.includes("%"))}function Mr(e){return e.startsWith("hsl")||e.startsWith("rgb")||e.startsWith("#")||e.startsWith("oklch")}async function Re(e,{withFallback:t}={withFallback:!1}){let r=await detect({programmatic:!0,cwd:e});if(r==="yarn@berry")return "yarn";if(r==="pnpm@6")return "pnpm";if(r==="bun")return "bun";if(r==="deno")return "deno";if(!t)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 Z(e,t,r$1,i){if(e=Array.from(new Set(e)),t=Array.from(new Set(t)),!e?.length&&!t?.length)return;i={silent:!1,...i};let n=r("Installing dependencies.",{silent:i.silent})?.start(),o=await Ur(r$1),a="";if(Br(r$1)&&o==="npm")if(i.silent)a="force";else {n.stopAndPersist(),q.warn(`
|
|
63
64
|
It looks like you are using React 19.
|
|
64
65
|
Some packages may fail to install due to peer dependency issues in npm (see https://ui.shadcn.com/react-19).
|
|
65
|
-
`);let s=await Qe([{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"}]}]);s&&(a=s.flag);}o?.start(),e?.length&&await execa(n,[n==="npm"?"install":"add",...n==="npm"&&a?[`--${a}`]:[],...n==="deno"?e.map(s=>`npm:${s}`):e],{cwd:r$1.resolvedPaths.cwd}),t?.length&&await execa(n,[n==="npm"?"install":"add",...n==="npm"&&a?[`--${a}`]:[],"-D",...n==="deno"?t.map(s=>`npm:${s}`):t],{cwd:r$1.resolvedPaths.cwd}),o?.succeed();}function Br(e){let t=m(e.resolvedPaths.cwd,!1);if(!t?.dependencies?.react)return !1;let r=/^(?:\^|~)?19(?:\.\d+)*(?:-.*)?$/.test(t.dependencies.react),i=t.dependencies["react-day-picker"]?.startsWith("8");return r&&i}var Re=async({sourceFile:e,config:t,baseColor:r})=>(t.tailwind?.cssVariables||!r?.inlineColors||e.getDescendantsOfKind(SyntaxKind.StringLiteral).forEach(i=>{let o=i.getText();if(o){let n=Gr(o.replace(/"/g,""),r.inlineColors);i.replaceWithText(`"${n.trim()}"`);}}),e);function Ye(e){if(!e.includes("/")&&!e.includes(":"))return [null,e,null];let t=[],[r,i]=e.split("/");if(!r.includes(":"))return [null,r,i];let o=r.split(":"),n=o.pop(),a=o.join(":");return t.push(a??null,n??null,i??null),t}var Kr=["bg-","text-","border-","ring-offset-","ring-"];function Gr(e,t){e.includes(" border ")&&(e=e.replace(" border "," border border-border "));let r=e.split(" "),i=new Set,o=new Set;for(let n of r){let[a,s,c]=Ye(n),l=Kr.find(f=>s?.startsWith(f));if(!l){i.has(n)||i.add(n);continue}let m=s?.replace(l,"");if(m&&m in t.light){i.add([a,`${l}${t.light[m]}`].filter(Boolean).join(":")+(c?`/${c}`:"")),o.add(["dark",a,`${l}${t.dark[m]}`].filter(Boolean).join(":")+(c?`/${c}`:""));continue}i.has(n)||i.add(n);}return [...Array.from(i),...Array.from(o)].join(" ").trim()}var L={lucide:{name:"lucide-react",package:"lucide-react",import:"lucide-react"},radix:{name:"@radix-ui/react-icons",package:"@radix-ui/react-icons",import:"@radix-ui/react-icons"}};var Mt="lucide",ve=async({sourceFile:e,config:t})=>{if(!t.iconLibrary||!(t.iconLibrary in L))return e;let r=await L$1(),i=Mt,o=t.iconLibrary;if(i===o)return e;let n=[];for(let a of e.getImportDeclarations()??[])if(a.getModuleSpecifier()?.getText()===`"${L[Mt].import}"`){for(let s of a.getNamedImports()??[]){let c=s.getName(),l=r[c]?.[o];!l||n.includes(l)||(n.push(l),s.remove(),e.getDescendantsOfKind(SyntaxKind.JsxSelfClosingElement).filter(m=>m.getTagNameNode()?.getText()===c).forEach(m=>m.getTagNameNode()?.replaceWithText(l)));}a.getNamedImports()?.length===0&&a.remove();}if(n.length>0){let a=e.addImportDeclaration({moduleSpecifier:L[o]?.import,namedImports:n.map(s=>({name:s}))});Yr(e)||a.replaceWithText(a.getText().replace(";",""));}return e};function Yr(e){return e.getImportDeclarations()?.[0]?.getText().endsWith(";")??!1}var Ie=async({sourceFile:e,config:t,isRemote:r})=>{let o=`@${t.aliases?.utils?.split("/")[0]?.slice(1)}/lib/utils`,n=e.getImportDeclarations();if(![".tsx",".ts",".jsx",".js"].includes(e.getExtension()))return e;for(let a of n){let s=qr(a.getModuleSpecifierValue(),t,r);a.setModuleSpecifier(s),(o===s||s==="@/lib/utils")&&a.getNamedImports().find(m=>m.getName()==="cn")&&a.setModuleSpecifier(o===s?s.replace(o,t.aliases.utils):t.aliases.utils);}return e};function qr(e,t,r=!1){if(!e.startsWith("@/")&&!r)return e;if(r&&e.startsWith("@/")&&(e=e.replace(/^@\//,"@/registry/new-york/")),!e.startsWith("@/registry/")){let i=t.aliases.components.split("/")[0];return e.replace(/^@\//,`${i}/`)}return e.match(/^@\/registry\/(.+)\/ui/)?e.replace(/^@\/registry\/(.+)\/ui/,t.aliases.ui??`${t.aliases.components}/ui`):t.aliases.components&&e.match(/^@\/registry\/(.+)\/components/)?e.replace(/^@\/registry\/(.+)\/components/,t.aliases.components):t.aliases.lib&&e.match(/^@\/registry\/(.+)\/lib/)?e.replace(/^@\/registry\/(.+)\/lib/,t.aliases.lib):t.aliases.hooks&&e.match(/^@\/registry\/(.+)\/hooks/)?e.replace(/^@\/registry\/(.+)\/hooks/,t.aliases.hooks):e.replace(/^@\/registry\/[^/]+/,t.aliases.components)}var Zr={sourceType:"module",allowImportExportEverywhere:!0,allowReturnOutsideFunction:!0,startLine:1,tokens:!0,plugins:["asyncGenerators","bigInt","classPrivateMethods","classPrivateProperties","classProperties","classStaticBlock","decimal","decorators-legacy","doExpressions","dynamicImport","exportDefaultFrom","exportNamespaceFrom","functionBind","functionSent","importAssertions","importMeta","nullishCoalescingOperator","numericSeparator","objectRestSpread","optionalCatchBinding","optionalChaining",["pipelineOperator",{proposal:"minimal"}],["recordAndTuple",{syntaxType:"hash"}],"throwExpressions","topLevelAwait","v8intrinsic","typescript","jsx"]},zt=async({sourceFile:e,config:t})=>{let r=e.getFullText();if(t.tsx)return r;let i=Pe.parse(r,{parser:{parse:n=>parse(n,Zr)}}),o=transformFromAstSync(i,r,{cloneInputAst:!1,code:!1,ast:!0,plugins:[Qr],configFile:!1});if(!o||!o.ast)throw new Error("Failed to transform JSX");return Pe.print(o.ast).code};var ti=/^["']use client["']$/g,Ce=async({sourceFile:e,config:t})=>{if(t.rsc)return e;let r=e.getFirstChildByKind(SyntaxKind.ExpressionStatement);return r&&ti.test(r.getText())&&r.remove(),e};var ke=async({sourceFile:e,config:t})=>{if(!t.tailwind?.prefix)return e;let r=await p(t);return e.getDescendantsOfKind(SyntaxKind.CallExpression).filter(i=>i.getExpression().getText()==="cva").forEach(i=>{if(i.getArguments()[0]?.isKind(SyntaxKind.StringLiteral)){let o=i.getArguments()[0];o&&o.replaceWithText(`"${K(o.getText()?.replace(/"|'/g,""),t.tailwind.prefix,r)}"`);}i.getArguments()[1]?.isKind(SyntaxKind.ObjectLiteralExpression)&&i.getArguments()[1]?.getDescendantsOfKind(SyntaxKind.PropertyAssignment).find(o=>o.getName()==="variants")?.getDescendantsOfKind(SyntaxKind.PropertyAssignment).forEach(o=>{o.getDescendantsOfKind(SyntaxKind.PropertyAssignment).forEach(n=>{let a=n.getInitializerIfKind(SyntaxKind.StringLiteral);a&&a?.replaceWithText(`"${K(a.getText()?.replace(/"|'/g,""),t.tailwind.prefix,r)}"`);});});}),e.getDescendantsOfKind(SyntaxKind.JsxAttribute).forEach(i=>{if(i.getName()==="className"){if(i.getInitializer()?.isKind(SyntaxKind.StringLiteral)){let o=i.getInitializer();o&&o.replaceWithText(`"${K(o.getText()?.replace(/"|'/g,""),t.tailwind.prefix,r)}"`);}if(i.getInitializer()?.isKind(SyntaxKind.JsxExpression)){let o=i.getInitializer()?.getDescendantsOfKind(SyntaxKind.CallExpression).find(n=>n.getExpression().getText()==="cn");o&&o.getArguments().forEach(n=>{(n.isKind(SyntaxKind.ConditionalExpression)||n.isKind(SyntaxKind.BinaryExpression))&&n.getChildrenOfKind(SyntaxKind.StringLiteral).forEach(a=>{a.replaceWithText(`"${K(a.getText()?.replace(/"|'/g,""),t.tailwind.prefix,r)}"`);}),n.isKind(SyntaxKind.StringLiteral)&&n.replaceWithText(`"${K(n.getText()?.replace(/"|'/g,""),t.tailwind.prefix,r)}"`);});}}i.getName()==="classNames"&&i.getInitializer()?.isKind(SyntaxKind.JsxExpression)&&i.getDescendantsOfKind(SyntaxKind.PropertyAssignment).forEach(o=>{if(o.getInitializer()?.isKind(SyntaxKind.CallExpression)){let n=o.getInitializerIfKind(SyntaxKind.CallExpression);n&&n.getArguments().forEach(a=>{a.isKind(SyntaxKind.ConditionalExpression)&&a.getChildrenOfKind(SyntaxKind.StringLiteral).forEach(s=>{s.replaceWithText(`"${K(s.getText()?.replace(/"|'/g,""),t.tailwind.prefix,r)}"`);}),a.isKind(SyntaxKind.StringLiteral)&&a.replaceWithText(`"${K(a.getText()?.replace(/"|'/g,""),t.tailwind.prefix,r)}"`);});}if(o.getInitializer()?.isKind(SyntaxKind.StringLiteral)&&o.getName()!=="variant"){let n=o.getInitializer();n&&n.replaceWithText(`"${K(n.getText()?.replace(/"|'/g,""),t.tailwind.prefix,r)}"`);}});}),e};function K(e,t="",r){return r==="v3"?e.split(" ").map(i=>{let[o,n,a]=Ye(i);return o?a?`${o}:${t}${n}/${a}`:`${o}:${t}${n}`:a?`${t}${n}/${a}`:`${t}${n}`}).join(" "):e.split(" ").map(i=>i.indexOf(`${t}:`)===0?i:`${t}:${i.trim()}`).join(" ")}var si=new Project({compilerOptions:{}});async function ai(e){let t=await promises.mkdtemp(S__default.join(tmpdir(),"shadcn-"));return S__default.join(t,e)}async function je(e,t=[Ie,Ce,Re,ke,ve]){let r=await ai(e.filename),i=si.createSourceFile(r,e.raw,{scriptKind:ScriptKind.TSX});for(let o of t)await o({sourceFile:i,...e});return e.transformJsx?await zt({sourceFile:i,...e}):i.getText()}async function qe(e,t,r$1){if(!e?.length)return {filesCreated:[],filesUpdated:[],filesSkipped:[]};r$1={overwrite:!1,force:!1,silent:!1,isRemote:!1,...r$1};let i=r("Updating files.",{silent:r$1.silent})?.start(),[o,n$1]=await Promise.all([n(t.resolvedPaths.cwd),O(t.tailwind.baseColor)]),a$1=[],s=[],c=[];for(let u of e){if(!u.content)continue;let g=di(u,t,{isSrcDir:o?.isSrcDir,framework:o?.framework.name,commonRoot:gi(e.map(b=>b.path),u.path)});if(!g)continue;let y=basename(u.path),h=S__default.dirname(g);t.tsx||(g=g.replace(/\.tsx?$/,b=>b===".tsx"?".jsx":".js"));let R=existsSync(g),x=await je({filename:u.path,raw:u.content,config:t,baseColor:n$1,transformJsx:!t.tsx,isRemote:r$1.isRemote},[Ie,Ce,Re,ke,ve]);if(R){let b=await promises.readFile(g,"utf-8"),[I,k]=await Promise.all([Bt(b),Bt(x)]);if(I===k){c.push(S__default.relative(t.resolvedPaths.cwd,g));continue}}if(R&&!r$1.overwrite){i.stop(),r$1.rootSpinner&&r$1.rootSpinner.stop();let{overwrite:b}=await Qe({type:"confirm",name:"overwrite",message:`The file ${a.info(y)} already exists. Would you like to overwrite?`,initial:!1});if(!b){c.push(S__default.relative(t.resolvedPaths.cwd,g)),r$1.rootSpinner&&r$1.rootSpinner.start();continue}i?.start(),r$1.rootSpinner&&r$1.rootSpinner.start();}existsSync(h)||await promises.mkdir(h,{recursive:!0}),await promises.writeFile(g,x,"utf-8"),R?s.push(S__default.relative(t.resolvedPaths.cwd,g)):a$1.push(S__default.relative(t.resolvedPaths.cwd,g));}let l=[...a$1,...s,...c],m=await wi(l,t);if(s.push(...m),s=s.filter(u=>!a$1.includes(u)),!(a$1.length||s.length)&&!c.length&&i?.info("No files updated."),a$1=Array.from(new Set(a$1)),s=Array.from(new Set(s)),c=Array.from(new Set(c)),a$1.length){if(i?.succeed(`Created ${a$1.length} ${a$1.length===1?"file":"files"}:`),!r$1.silent)for(let u of a$1)q.log(` - ${u}`);}else i?.stop();if(s.length&&(r(`Updated ${s.length} ${s.length===1?"file":"files"}:`,{silent:r$1.silent})?.info(),!r$1.silent))for(let u of s)q.log(` - ${u}`);if(c.length&&(r(`Skipped ${c.length} ${s.length===1?"file":"files"}: (files might be identical, use --overwrite to overwrite)`,{silent:r$1.silent})?.info(),!r$1.silent))for(let u of c)q.log(` - ${u}`);return r$1.silent||q.break(),{filesCreated:a$1,filesUpdated:s,filesSkipped:c}}function di(e,t,r){if(e.target){if(e.target.startsWith("~/"))return S__default.join(t.resolvedPaths.cwd,e.target.replace("~/",""));let n=e.target;return e.type==="registry:page"&&(n=yi(n,r.framework),!n)?"":r.isSrcDir?S__default.join(t.resolvedPaths.cwd,"src",n.replace("src/","")):S__default.join(t.resolvedPaths.cwd,n.replace("src/",""))}let i=ui(e,t),o=hi(e.path,i);return S__default.join(i,o)}function ui(e,t){return e.type==="registry:ui"?t.resolvedPaths.ui:e.type==="registry:lib"?t.resolvedPaths.lib:e.type==="registry:block"||e.type==="registry:component"?t.resolvedPaths.components:e.type==="registry:hook"?t.resolvedPaths.hooks:t.resolvedPaths.components}function gi(e,t){let r=e.map(a=>a.replace(/^\//,"")),i=t.replace(/^\//,""),o=i.split("/").slice(0,-1).join("/");if(!o)return "";let n=o.split("/");for(let a=n.length;a>0;a--){let s=n.slice(0,a).join("/");if(r.some(l=>l!==i&&l.startsWith(s+"/")))return "/"+s}return "/"+o}function hi(e,t){let r=e.replace(/^\/|\/$/g,""),i=t.replace(/^\/|\/$/g,""),o=r.split("/"),n=i.split("/"),a=n[n.length-1],s=o.findIndex(c=>c===a);return s===-1?o[o.length-1]:o.slice(s+1).join("/")}async function Bt(e){return e.replace(/\r\n/g,`
|
|
66
|
-
`).trim()}function
|
|
67
|
-
Would you like to start a new project?`,choices:[{title:"Next.js",value:"next"},{title:"Next.js (Monorepo)",value:"next-monorepo"}],initial:0},{type:"text",name:"name",message:"What is your project named?",initial:r,format:l=>l.trim(),validate:l=>l.length>128?"Name should be less than 128 characters.":!0}]);t=s??t,r=c;}let
|
|
68
|
-
You may now add components.`),q.break();}catch(r){q.break(),s(r);}});async function
|
|
69
|
-
Before you can add components, you must create a valid ${a.info("components.json")} file by running the ${a.info("init")} command.`),q.error(`Learn more at ${a.info("https://ui.shadcn.com/docs/components-json")}.`),q.break(),process.exit(1);}}async function Zt(e,t){let r=S__default.join(t.resolvedPaths.cwd,"app/page.tsx");if(!(await B__default.stat(r)).isFile())return;let i=await M(e,t.style);if(!i?.meta?.importSpecifier||!i?.meta?.moduleSpecifier)return;let
|
|
66
|
+
`);let s=await Ze([{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"}]}]);s&&(a=s.flag);}n?.start(),await Kr(o,e,t,r$1.resolvedPaths.cwd,a),n?.succeed();}function Br(e){let t=m(e.resolvedPaths.cwd,!1);if(!t?.dependencies?.react)return !1;let r=/^(?:\^|~)?19(?:\.\d+)*(?:-.*)?$/.test(t.dependencies.react),i=t.dependencies["react-day-picker"]?.startsWith("8");return r&&i}async function Ur(e){return m(e.resolvedPaths.cwd,!1)?.dependencies?.expo?"expo":Re(e.resolvedPaths.cwd)}async function Kr(e,t,r,i,n){if(e==="npm")return Gr(t,r,i,n);if(e==="deno")return Jr(t,r,i);if(e==="expo")return Yr(t,r,i);t?.length&&await execa(e,["add",...t],{cwd:i}),r?.length&&await execa(e,["add","-D",...r],{cwd:i});}async function Gr(e,t,r,i){e.length&&await execa("npm",["install",...i?[`--${i}`]:[],...e],{cwd:r}),t.length&&await execa("npm",["install",...i?[`--${i}`]:[],"-D",...t],{cwd:r});}async function Jr(e,t,r){e?.length&&await execa("deno",["add",...e.map(i=>`npm:${i}`)],{cwd:r}),t?.length&&await execa("deno",["add","-D",...t.map(i=>`npm:${i}`)],{cwd:r});}async function Yr(e,t,r){e.length&&await execa("npx",["expo","install",...e],{cwd:r}),t.length&&await execa("npx",["expo","install","-- -D",...t],{cwd:r});}var ve=async({sourceFile:e,config:t,baseColor:r})=>(t.tailwind?.cssVariables||!r?.inlineColors||e.getDescendantsOfKind(SyntaxKind.StringLiteral).forEach(i=>{let n=i.getText();if(n){let o=Xr(n.replace(/"/g,""),r.inlineColors);i.replaceWithText(`"${o.trim()}"`);}}),e);function qe(e){if(!e.includes("/")&&!e.includes(":"))return [null,e,null];let t=[],[r,i]=e.split("/");if(!r.includes(":"))return [null,r,i];let n=r.split(":"),o=n.pop(),a=n.join(":");return t.push(a??null,o??null,i??null),t}var Hr=["bg-","text-","border-","ring-offset-","ring-"];function Xr(e,t){e.includes(" border ")&&(e=e.replace(" border "," border border-border "));let r=e.split(" "),i=new Set,n=new Set;for(let o of r){let[a,s,c]=qe(o),l=Hr.find(m=>s?.startsWith(m));if(!l){i.has(o)||i.add(o);continue}let f=s?.replace(l,"");if(f&&f in t.light){i.add([a,`${l}${t.light[f]}`].filter(Boolean).join(":")+(c?`/${c}`:"")),n.add(["dark",a,`${l}${t.dark[f]}`].filter(Boolean).join(":")+(c?`/${c}`:""));continue}i.has(o)||i.add(o);}return [...Array.from(i),...Array.from(n)].join(" ").trim()}var L={lucide:{name:"lucide-react",package:"lucide-react",import:"lucide-react"},radix:{name:"@radix-ui/react-icons",package:"@radix-ui/react-icons",import:"@radix-ui/react-icons"}};var Mt="lucide",Ie=async({sourceFile:e,config:t})=>{if(!t.iconLibrary||!(t.iconLibrary in L))return e;let r=await L$1(),i=Mt,n=t.iconLibrary;if(i===n)return e;let o=[];for(let a of e.getImportDeclarations()??[])if(a.getModuleSpecifier()?.getText()===`"${L[Mt].import}"`){for(let s of a.getNamedImports()??[]){let c=s.getName(),l=r[c]?.[n];!l||o.includes(l)||(o.push(l),s.remove(),e.getDescendantsOfKind(SyntaxKind.JsxSelfClosingElement).filter(f=>f.getTagNameNode()?.getText()===c).forEach(f=>f.getTagNameNode()?.replaceWithText(l)));}a.getNamedImports()?.length===0&&a.remove();}if(o.length>0){let a=e.addImportDeclaration({moduleSpecifier:L[n]?.import,namedImports:o.map(s=>({name:s}))});Zr(e)||a.replaceWithText(a.getText().replace(";",""));}return e};function Zr(e){return e.getImportDeclarations()?.[0]?.getText().endsWith(";")??!1}var Pe=async({sourceFile:e,config:t,isRemote:r})=>{let n=`@${t.aliases?.utils?.split("/")[0]?.slice(1)}/lib/utils`,o=e.getImportDeclarations();if(![".tsx",".ts",".jsx",".js"].includes(e.getExtension()))return e;for(let a of o){let s=ei(a.getModuleSpecifierValue(),t,r);a.setModuleSpecifier(s),(n===s||s==="@/lib/utils")&&a.getNamedImports().find(f=>f.getName()==="cn")&&a.setModuleSpecifier(n===s?s.replace(n,t.aliases.utils):t.aliases.utils);}return e};function ei(e,t,r=!1){if(!e.startsWith("@/")&&!r)return e;if(r&&e.startsWith("@/")&&(e=e.replace(/^@\//,"@/registry/new-york/")),!e.startsWith("@/registry/")){let i=t.aliases.components.split("/")[0];return e.replace(/^@\//,`${i}/`)}return e.match(/^@\/registry\/(.+)\/ui/)?e.replace(/^@\/registry\/(.+)\/ui/,t.aliases.ui??`${t.aliases.components}/ui`):t.aliases.components&&e.match(/^@\/registry\/(.+)\/components/)?e.replace(/^@\/registry\/(.+)\/components/,t.aliases.components):t.aliases.lib&&e.match(/^@\/registry\/(.+)\/lib/)?e.replace(/^@\/registry\/(.+)\/lib/,t.aliases.lib):t.aliases.hooks&&e.match(/^@\/registry\/(.+)\/hooks/)?e.replace(/^@\/registry\/(.+)\/hooks/,t.aliases.hooks):e.replace(/^@\/registry\/[^/]+/,t.aliases.components)}var ni={sourceType:"module",allowImportExportEverywhere:!0,allowReturnOutsideFunction:!0,startLine:1,tokens:!0,plugins:["asyncGenerators","bigInt","classPrivateMethods","classPrivateProperties","classProperties","classStaticBlock","decimal","decorators-legacy","doExpressions","dynamicImport","exportDefaultFrom","exportNamespaceFrom","functionBind","functionSent","importAssertions","importMeta","nullishCoalescingOperator","numericSeparator","objectRestSpread","optionalCatchBinding","optionalChaining",["pipelineOperator",{proposal:"minimal"}],["recordAndTuple",{syntaxType:"hash"}],"throwExpressions","topLevelAwait","v8intrinsic","typescript","jsx"]},Wt=async({sourceFile:e,config:t})=>{let r=e.getFullText();if(t.tsx)return r;let i=Ce.parse(r,{parser:{parse:o=>parse(o,ni)}}),n=transformFromAstSync(i,r,{cloneInputAst:!1,code:!1,ast:!0,plugins:[ii],configFile:!1});if(!n||!n.ast)throw new Error("Failed to transform JSX");return Ce.print(n.ast).code};var si=/^["']use client["']$/g,ke=async({sourceFile:e,config:t})=>{if(t.rsc)return e;let r=e.getFirstChildByKind(SyntaxKind.ExpressionStatement);return r&&si.test(r.getText())&&r.remove(),e};var je=async({sourceFile:e,config:t})=>{if(!t.tailwind?.prefix)return e;let r=await p(t);return e.getDescendantsOfKind(SyntaxKind.CallExpression).filter(i=>i.getExpression().getText()==="cva").forEach(i=>{if(i.getArguments()[0]?.isKind(SyntaxKind.StringLiteral)){let n=i.getArguments()[0];n&&n.replaceWithText(`"${G(n.getText()?.replace(/"|'/g,""),t.tailwind.prefix,r)}"`);}i.getArguments()[1]?.isKind(SyntaxKind.ObjectLiteralExpression)&&i.getArguments()[1]?.getDescendantsOfKind(SyntaxKind.PropertyAssignment).find(n=>n.getName()==="variants")?.getDescendantsOfKind(SyntaxKind.PropertyAssignment).forEach(n=>{n.getDescendantsOfKind(SyntaxKind.PropertyAssignment).forEach(o=>{let a=o.getInitializerIfKind(SyntaxKind.StringLiteral);a&&a?.replaceWithText(`"${G(a.getText()?.replace(/"|'/g,""),t.tailwind.prefix,r)}"`);});});}),e.getDescendantsOfKind(SyntaxKind.JsxAttribute).forEach(i=>{if(i.getName()==="className"){if(i.getInitializer()?.isKind(SyntaxKind.StringLiteral)){let n=i.getInitializer();n&&n.replaceWithText(`"${G(n.getText()?.replace(/"|'/g,""),t.tailwind.prefix,r)}"`);}if(i.getInitializer()?.isKind(SyntaxKind.JsxExpression)){let n=i.getInitializer()?.getDescendantsOfKind(SyntaxKind.CallExpression).find(o=>o.getExpression().getText()==="cn");n&&n.getArguments().forEach(o=>{(o.isKind(SyntaxKind.ConditionalExpression)||o.isKind(SyntaxKind.BinaryExpression))&&o.getChildrenOfKind(SyntaxKind.StringLiteral).forEach(a=>{a.replaceWithText(`"${G(a.getText()?.replace(/"|'/g,""),t.tailwind.prefix,r)}"`);}),o.isKind(SyntaxKind.StringLiteral)&&o.replaceWithText(`"${G(o.getText()?.replace(/"|'/g,""),t.tailwind.prefix,r)}"`);});}}i.getName()==="classNames"&&i.getInitializer()?.isKind(SyntaxKind.JsxExpression)&&i.getDescendantsOfKind(SyntaxKind.PropertyAssignment).forEach(n=>{if(n.getInitializer()?.isKind(SyntaxKind.CallExpression)){let o=n.getInitializerIfKind(SyntaxKind.CallExpression);o&&o.getArguments().forEach(a=>{a.isKind(SyntaxKind.ConditionalExpression)&&a.getChildrenOfKind(SyntaxKind.StringLiteral).forEach(s=>{s.replaceWithText(`"${G(s.getText()?.replace(/"|'/g,""),t.tailwind.prefix,r)}"`);}),a.isKind(SyntaxKind.StringLiteral)&&a.replaceWithText(`"${G(a.getText()?.replace(/"|'/g,""),t.tailwind.prefix,r)}"`);});}if(n.getInitializer()?.isKind(SyntaxKind.StringLiteral)&&n.getName()!=="variant"){let o=n.getInitializer();o&&o.replaceWithText(`"${G(o.getText()?.replace(/"|'/g,""),t.tailwind.prefix,r)}"`);}});}),e};function G(e,t="",r){return r==="v3"?e.split(" ").map(i=>{let[n,o,a]=qe(i);return n?a?`${n}:${t}${o}/${a}`:`${n}:${t}${o}`:a?`${t}${o}/${a}`:`${t}${o}`}).join(" "):e.split(" ").map(i=>i.indexOf(`${t}:`)===0?i:`${t}:${i.trim()}`).join(" ")}var fi=new Project({compilerOptions:{}});async function mi(e){let t=await promises.mkdtemp(S__default.join(tmpdir(),"shadcn-"));return S__default.join(t,e)}async function Ee(e,t=[Pe,ke,ve,je,Ie]){let r=await mi(e.filename),i=fi.createSourceFile(r,e.raw,{scriptKind:ScriptKind.TSX});for(let n of t)await n({sourceFile:i,...e});return e.transformJsx?await Wt({sourceFile:i,...e}):i.getText()}async function He(e,t,r$1){if(!e?.length)return {filesCreated:[],filesUpdated:[],filesSkipped:[]};r$1={overwrite:!1,force:!1,silent:!1,isRemote:!1,...r$1};let i=r("Updating files.",{silent:r$1.silent})?.start(),[n$1,o]=await Promise.all([n(t.resolvedPaths.cwd),O(t.tailwind.baseColor)]),a$1=[],s=[],c=[];for(let u of e){if(!u.content)continue;let g=wi(u,t,{isSrcDir:n$1?.isSrcDir,framework:n$1?.framework.name,commonRoot:bi(e.map(b=>b.path),u.path)});if(!g)continue;let y=basename(u.path),h=S__default.dirname(g);t.tsx||(g=g.replace(/\.tsx?$/,b=>b===".tsx"?".jsx":".js"));let R=existsSync(g),x=await Ee({filename:u.path,raw:u.content,config:t,baseColor:o,transformJsx:!t.tsx,isRemote:r$1.isRemote},[Pe,ke,ve,je,Ie]);if(R){let b=await promises.readFile(g,"utf-8"),[I,k]=await Promise.all([Bt(b),Bt(x)]);if(I===k){c.push(S__default.relative(t.resolvedPaths.cwd,g));continue}}if(R&&!r$1.overwrite){i.stop(),r$1.rootSpinner&&r$1.rootSpinner.stop();let{overwrite:b}=await Ze({type:"confirm",name:"overwrite",message:`The file ${a.info(y)} already exists. Would you like to overwrite?`,initial:!1});if(!b){c.push(S__default.relative(t.resolvedPaths.cwd,g)),r$1.rootSpinner&&r$1.rootSpinner.start();continue}i?.start(),r$1.rootSpinner&&r$1.rootSpinner.start();}existsSync(h)||await promises.mkdir(h,{recursive:!0}),await promises.writeFile(g,x,"utf-8"),R?s.push(S__default.relative(t.resolvedPaths.cwd,g)):a$1.push(S__default.relative(t.resolvedPaths.cwd,g));}let l=[...a$1,...s,...c],f=await vi(l,t);if(s.push(...f),s=s.filter(u=>!a$1.includes(u)),!(a$1.length||s.length)&&!c.length&&i?.info("No files updated."),a$1=Array.from(new Set(a$1)),s=Array.from(new Set(s)),c=Array.from(new Set(c)),a$1.length){if(i?.succeed(`Created ${a$1.length} ${a$1.length===1?"file":"files"}:`),!r$1.silent)for(let u of a$1)q.log(` - ${u}`);}else i?.stop();if(s.length&&(r(`Updated ${s.length} ${s.length===1?"file":"files"}:`,{silent:r$1.silent})?.info(),!r$1.silent))for(let u of s)q.log(` - ${u}`);if(c.length&&(r(`Skipped ${c.length} ${s.length===1?"file":"files"}: (files might be identical, use --overwrite to overwrite)`,{silent:r$1.silent})?.info(),!r$1.silent))for(let u of c)q.log(` - ${u}`);return r$1.silent||q.break(),{filesCreated:a$1,filesUpdated:s,filesSkipped:c}}function wi(e,t,r){if(e.target){if(e.target.startsWith("~/"))return S__default.join(t.resolvedPaths.cwd,e.target.replace("~/",""));let o=e.target;return e.type==="registry:page"&&(o=Ri(o,r.framework),!o)?"":r.isSrcDir?S__default.join(t.resolvedPaths.cwd,"src",o.replace("src/","")):S__default.join(t.resolvedPaths.cwd,o.replace("src/",""))}let i=xi(e,t),n=Si(e.path,i);return S__default.join(i,n)}function xi(e,t){return e.type==="registry:ui"?t.resolvedPaths.ui:e.type==="registry:lib"?t.resolvedPaths.lib:e.type==="registry:block"||e.type==="registry:component"?t.resolvedPaths.components:e.type==="registry:hook"?t.resolvedPaths.hooks:t.resolvedPaths.components}function bi(e,t){let r=e.map(a=>a.replace(/^\//,"")),i=t.replace(/^\//,""),n=i.split("/").slice(0,-1).join("/");if(!n)return "";let o=n.split("/");for(let a=o.length;a>0;a--){let s=o.slice(0,a).join("/");if(r.some(l=>l!==i&&l.startsWith(s+"/")))return "/"+s}return "/"+n}function Si(e,t){let r=e.replace(/^\/|\/$/g,""),i=t.replace(/^\/|\/$/g,""),n=r.split("/"),o=i.split("/"),a=o[o.length-1],s=n.findIndex(c=>c===a);return s===-1?n[n.length-1]:n.slice(s+1).join("/")}async function Bt(e){return e.replace(/\r\n/g,`
|
|
67
|
+
`).trim()}function Ri(e,t){if(!t)return "";if(t==="next-app")return e;if(t==="next-pages"){let r=e.replace(/^app\//,"pages/");return r=r.replace(/\/page(\.[jt]sx?)$/,"$1"),r}if(t==="react-router"){let r=e.replace(/^app\//,"app/routes/");return r=r.replace(/\/page(\.[jt]sx?)$/,"$1"),r}if(t==="laravel"){let r=e.replace(/^app\//,"resources/js/pages/");return r=r.replace(/\/page(\.[jt]sx?)$/,"$1"),r}return ""}async function vi(e,t){let r=new Project({compilerOptions:{}}),i=await n(t.resolvedPaths.cwd),n$1=await loadConfig(t.resolvedPaths.cwd),o=[];if(!i||n$1.resultType==="failed")return [];for(let a of e){let s=S__default.resolve(t.resolvedPaths.cwd,a);if(!existsSync(s))continue;let c=await promises.readFile(s,"utf-8"),l=await promises.mkdtemp(S__default.join(tmpdir(),"shadcn-")),f=r.createSourceFile(S__default.join(l,basename(s)),c,{scriptKind:ScriptKind.TSX});if(![".tsx",".ts",".jsx",".js"].includes(f.getExtension()))continue;let m=f.getImportDeclarations();for(let u of m){let g=u.getModuleSpecifierValue();if(i?.aliasPrefix&&!g.startsWith(`${i.aliasPrefix}/`))continue;let y=await b(g,n$1);if(!y)continue;let h=Ii(y,e,t);if(!h)continue;let R=Pi(h,t,i);!R||R===g||(u.setModuleSpecifier(R),await promises.writeFile(s,f.getFullText(),"utf-8"),o.push(a));}}return o}function Ii(e,t,r,i=[".tsx",".ts",".js",".jsx",".css"]){let n=S__default.normalize(r.resolvedPaths.cwd),o=t.map(R=>R.split(S__default.sep).join(S__default.posix.sep)),a=new Set(o),s=S__default.extname(e),c=s!=="",l=c?e.slice(0,-s.length):e,m=S__default.relative(n,l).split(S__default.sep).join(S__default.posix.sep),u=c?[s]:i,g=new Set;for(let R of u){let x=l+R,b=S__default.posix.normalize(S__default.relative(n,x));(a.has(b)||existsSync(x))&&g.add(b);let I=S__default.join(l,`index${R}`),k=S__default.posix.normalize(S__default.relative(n,I));(a.has(k)||existsSync(I))&&g.add(k);}let y=S__default.basename(l);for(let R of o)u.some(x=>R.endsWith(`/${y}${x}`))&&g.add(R);return g.size===0?null:Array.from(g).sort((R,x)=>{let b=S__default.posix.extname(R),I=S__default.posix.extname(x),k=u.indexOf(b)-u.indexOf(I);if(k!==0)return k;let D=m&&R.startsWith(m)?-1:1,E=m&&x.startsWith(m)?-1:1;return D-E})[0]}function Pi(e,t,r){let i=S__default.normalize(S__default.join(t.resolvedPaths.cwd,e)),n=Object.entries(t.resolvedPaths).filter(([,y])=>y&&i.startsWith(S__default.normalize(y+S__default.sep))).sort((y,h)=>h[1].length-y[1].length);if(n.length===0)return null;let[o,a]=n[0],s=S__default.relative(a,i);s=s.split(S__default.sep).join("/");let c=S__default.posix.extname(s),f=[".ts",".tsx",".js",".jsx"].includes(c)?"":c,m=s.slice(0,s.length-c.length);m.endsWith("/index")&&(m=m.slice(0,-6));let u=o==="cwd"?r.aliasPrefix:t.aliases[o];if(!u)return null;let g=m===""?"":`/${m}`;return g=g.replace("/src",""),`${u}${g}${f}`}async function Te(e,t,r){r={overwrite:!1,silent:!1,isNewProject:!1,style:"index",...r};let i=await j(t);return i&&i.ui&&i.ui.resolvedPaths.cwd!==t.resolvedPaths.cwd?await ki(e,t,i,{...r,isRemote:e?.length===1&&!!e[0].match(/\/chat\/b\//)}):await Ci(e,t,r)}async function Ci(e,t$1,r$1){let i=r("Checking registry.",{silent:r$1.silent})?.start(),n=await U(e,t$1);if(!n)return i?.fail(),s(new Error("Failed to fetch components from registry."));i?.succeed();let o=await p(t$1);await t(n.tailwind?.config,t$1,{silent:r$1.silent,tailwindVersion:o});let a=await Gt(e,t$1);await Ye(n.cssVars,t$1,{cleanupDefaultNextStyles:r$1.isNewProject,silent:r$1.silent,tailwindVersion:o,tailwindConfig:n.tailwind?.config,overwriteCssVars:a,initIndex:r$1.style?r$1.style==="index":!1}),await Je(n.css,t$1,{silent:r$1.silent}),await Z(n.dependencies,n.devDependencies,t$1,{silent:r$1.silent}),await He(n.files,t$1,{overwrite:r$1.overwrite,silent:r$1.silent}),n.docs&&q.info(n.docs);}async function ki(e,t$1,r$1,i){let n=r("Checking registry.",{silent:i.silent})?.start(),o=await X(e,t$1),a=await S$1(o),s$1=z.array(B$1).parse(a);if(!s$1)return n?.fail(),s(new Error("Failed to fetch components from registry."));n?.succeed();let c=Z$1(s$1),l$1=Y(),f=[],m=[],u=[],g=r("Installing components.")?.start();for(let h of s$1){let R=l$1.get(h.type),x=c.get(h.name);if(!R)continue;let b=h.type==="registry:ui"||x?.type==="registry:ui"?r$1.ui:t$1,I=await p(b),k$1=l(t$1.resolvedPaths.cwd,b.resolvedPaths.ui),D=await k(k$1,b.resolvedPaths.cwd)??b.resolvedPaths.cwd;if(h.tailwind?.config&&(await t(h.tailwind?.config,b,{silent:!0,tailwindVersion:I}),m.push(S__default.relative(k$1,b.resolvedPaths.tailwindConfig))),h.cssVars){let V=await Gt(e,t$1);await Ye(h.cssVars,b,{silent:!0,tailwindVersion:I,tailwindConfig:h.tailwind?.config,overwriteCssVars:V}),m.push(S__default.relative(k$1,b.resolvedPaths.tailwindCss));}h.css&&(await Je(h.css,b,{silent:!0}),m.push(S__default.relative(k$1,b.resolvedPaths.tailwindCss))),await Z(h.dependencies,h.devDependencies,b,{silent:!0});let E=await He(h.files,b,{overwrite:i.overwrite,silent:!0,rootSpinner:g,isRemote:i.isRemote});f.push(...E.filesCreated.map(V=>S__default.relative(k$1,S__default.join(D,V)))),m.push(...E.filesUpdated.map(V=>S__default.relative(k$1,S__default.join(D,V)))),u.push(...E.filesSkipped.map(V=>S__default.relative(k$1,S__default.join(D,V))));}if(g?.succeed(),f.sort(),m.sort(),u.sort(),!(f.length||m.length)&&!u.length&&r("No files updated.",{silent:i.silent})?.info(),f.length){r(`Created ${f.length} ${f.length===1?"file":"files"}:`,{silent:i.silent})?.succeed();for(let h of f)q.log(` - ${h}`);}if(m.length){r(`Updated ${m.length} ${m.length===1?"file":"files"}:`,{silent:i.silent})?.info();for(let h of m)q.log(` - ${h}`);}if(u.length){r(`Skipped ${u.length} ${m.length===1?"file":"files"}: (use --overwrite to overwrite)`,{silent:i.silent})?.info();for(let h of u)q.log(` - ${h}`);}}async function Gt(e,t){let r=await X(e,t),i=await S$1(r);return z.array(B$1).parse(i).some(o=>o.type==="registry:theme"||o.type==="registry:style")}var Ti="https://codeload.github.com/shadcn-ui/ui/tar.gz/main",ee={next:"next","next-monorepo":"next-monorepo"};async function Oe(e){e={srcDir:!1,...e};let t=e.template&&ee[e.template]?e.template:"next",r=t===ee.next?"my-app":"my-monorepo",i="latest",n=e.components?.length===1&&!!e.components[0].match(/\/chat\/b\//);if(e.components&&n)try{let[s]=await S$1(e.components),{meta:c}=z.object({meta:z.object({nextVersion:z.string()})}).parse(s);i=c.nextVersion,t=ee.next;}catch(s$1){q.break(),s(s$1);}if(!e.force){let{type:s,name:c}=await Ze([{type:e.template||n?null:"select",name:"type",message:`The path ${a.info(e.cwd)} does not contain a package.json file.
|
|
68
|
+
Would you like to start a new project?`,choices:[{title:"Next.js",value:"next"},{title:"Next.js (Monorepo)",value:"next-monorepo"}],initial:0},{type:"text",name:"name",message:"What is your project named?",initial:r,format:l=>l.trim(),validate:l=>l.length>128?"Name should be less than 128 characters.":!0}]);t=s??t,r=c;}let o=await Re(e.cwd,{withFallback:!0}),a$1=`${e.cwd}/${r}`;try{await te.access(e.cwd,te.constants.W_OK);}catch{q.break(),q.error(`The path ${a.info(e.cwd)} is not writable.`),q.error(`It is likely you do not have write permissions for this folder or the path ${a.info(e.cwd)} does not exist.`),q.break(),process.exit(1);}return te.existsSync(S__default.resolve(e.cwd,r,"package.json"))&&(q.break(),q.error(`A project with the name ${a.info(r)} already exists.`),q.error("Please choose a different name and try again."),q.break(),process.exit(1)),t===ee.next&&await $i(a$1,{version:i,cwd:e.cwd,packageManager:o,srcDir:!!e.srcDir}),t===ee["next-monorepo"]&&await Oi(a$1,{packageManager:o}),{projectPath:a$1,projectName:r,template:t}}async function $i(e,t){let r$1=r("Creating a new Next.js project. This may take a few minutes.").start(),i=["--tailwind","--eslint","--typescript","--app",t.srcDir?"--src-dir":"--no-src-dir","--no-import-alias",`--use-${t.packageManager}`];(t.version.startsWith("15")||t.version.startsWith("latest")||t.version.startsWith("canary"))&&i.push("--turbopack");try{await execa("npx",[`create-next-app@${t.version}`,e,"--silent",...i],{cwd:t.cwd});}catch{q.break(),q.error("Something went wrong creating a new Next.js project. Please try again."),process.exit(1);}r$1?.succeed("Creating a new Next.js project.");}async function Oi(e,t){let r$1=r("Creating a new Next.js monorepo. This may take a few minutes.").start();try{let i=S__default.join(ji.tmpdir(),`shadcn-template-${Date.now()}`);await te.ensureDir(i);let n=await fetch(Ti);if(!n.ok)throw new Error(`Failed to download template: ${n.statusText}`);let o=S__default.resolve(i,"template.tar.gz");await te.writeFile(o,Buffer.from(await n.arrayBuffer())),await execa("tar",["-xzf",o,"-C",i,"--strip-components=2","ui-main/templates/monorepo-next"]);let a=S__default.resolve(i,"monorepo-next");await te.move(a,e),await te.remove(i),await execa(t.packageManager,["install"],{cwd:e});let s=process.cwd();await execa("git",["--version"],{cwd:e}),await execa("git",["init"],{cwd:e}),await execa("git",["add","-A"],{cwd:e}),await execa("git",["commit","-m","Initial commit"],{cwd:e}),await execa("cd",[s]),r$1?.succeed("Creating a new Next.js monorepo.");}catch(i){r$1?.fail("Something went wrong creating a new Next.js monorepo."),s(i);}}async function Yt(e,t,r$1){if(!e)return;r$1={silent:!1,...r$1};let i=S__default.relative(t.resolvedPaths.cwd,t.resolvedPaths.tailwindConfig),n=r(`Updating ${a.info(i)}`,{silent:r$1.silent}).start(),o=await promises.readFile(t.resolvedPaths.tailwindConfig,"utf8"),a$1=await Ai(o,e,t);await promises.writeFile(t.resolvedPaths.tailwindConfig,a$1,"utf8"),n?.succeed();}async function Ai(e,t,r){let i=await u(e,r),n=i.getDescendantsOfKind(SyntaxKind.ObjectLiteralExpression).find(o=>o.getProperties().some(a=>a.isKind(SyntaxKind.PropertyAssignment)&&a.getName()==="content"));return n?(Di(n,t),i.getFullText()):e}async function Di(e,t){let r=v(e),i=e.getProperty("content");if(!i){let n={name:"content",initializer:`[${r}${t.join(`${r}, ${r}`)}${r}]`};return e.addPropertyAssignment(n),e}if(i.isKind(SyntaxKind.PropertyAssignment)){let n=i.getInitializer();if(n?.isKind(SyntaxKind.ArrayLiteralExpression))for(let o of t){let a=`${r}${o}${r}`;n.getElements().map(s=>s.getText()).includes(a)||n.addElement(a);}return e}return e}var Li=z.object({cwd:z.string(),components:z.array(z.string()).optional(),yes:z.boolean(),defaults:z.boolean(),force:z.boolean(),silent:z.boolean(),isNewProject:z.boolean(),srcDir:z.boolean().optional(),cssVariables:z.boolean(),template:z.string().optional().refine(e=>e?ee[e]:!0,{message:"Invalid template. Please use 'next' or 'next-monorepo'."}),baseColor:z.string().optional().refine(e=>e?I.find(t=>t.name===e):!0,{message:`Invalid base color. Please use '${I.map(e=>e.name).join("', '")}'`}),style:z.string()}),qt=new Command().name("init").description("initialize your project and install dependencies").argument("[components...]","the components to add or a url to the component.").option("-t, --template <template>","the template to use. (next, next-monorepo)").option("-b, --base-color <base-color>","the base color to use. (neutral, gray, zinc, stone, slate)",void 0).option("-y, --yes","skip confirmation prompt.",!0).option("-d, --defaults,","use default configuration.",!1).option("-f, --force","force overwrite of existing configuration.",!1).option("-c, --cwd <cwd>","the working directory. defaults to the current directory.",process.cwd()).option("-s, --silent","mute output.",!1).option("--src-dir","use the src directory when creating a new project.",!1).option("--no-src-dir","do not use the src directory when creating a new project.").option("--css-variables","use css variables for theming.",!0).option("--no-css-variables","do not use css variables for theming.").action(async(e,t)=>{try{let r=Li.parse({cwd:S__default.resolve(t.cwd),isNewProject:!1,components:e,style:"index",...t});if(e.length>0&&W(e[0])){let i=await M(e[0],"");i?.type==="registry:style"&&(r.baseColor="neutral",r.style=i.extends??"index");}await Ae(r),q.log(`${a.success("Success!")} Project initialization completed.
|
|
69
|
+
You may now add components.`),q.break();}catch(r){q.break(),s(r);}});async function Ae(e){let t,r$1;if(e.skipPreflight)t=await n(e.cwd);else {let l=await Nt(e);if(l.errors[F]){let{projectPath:f,template:m}=await Oe(e);f||process.exit(1),e.cwd=f,e.isNewProject=!0,r$1=m;}t=l.projectInfo;}if(r$1==="next-monorepo")return e.cwd=S__default.resolve(e.cwd,"apps/web"),await h(e.cwd);let i$1=await o(e.cwd,t),n$1=i$1?await Mi(i$1,e):await Vi(await h(e.cwd));if(!e.yes){let{proceed:l}=await Ze({type:"confirm",name:"proceed",message:`Write configuration to ${a.info("components.json")}. Proceed?`,initial:!0});l||process.exit(0);}let o$1=r("Writing components.json.").start(),a$1=S__default.resolve(e.cwd,"components.json");await promises.writeFile(a$1,JSON.stringify(n$1,null,2),"utf8"),o$1.succeed();let s=await i(e.cwd,n$1),c=[...e.style==="none"?[]:[e.style],...e.components??[]];return await Te(c,s,{overwrite:!0,silent:e.silent,style:e.style,isNewProject:e.isNewProject||t?.framework.name==="next-app"}),e.isNewProject&&e.srcDir&&await Yt(["./src/**/*.{js,ts,jsx,tsx,mdx}"],s,{silent:e.silent}),s}async function Vi(e$1=null){let[t,r]=await Promise.all([K(),N()]);q.info("");let i=await Ze([{type:"toggle",name:"typescript",message:`Would you like to use ${a.info("TypeScript")} (recommended)?`,initial:e$1?.tsx??!0,active:"yes",inactive:"no"},{type:"select",name:"style",message:`Which ${a.info("style")} would you like to use?`,choices:t.map(n=>({title:n.label,value:n.name}))},{type:"select",name:"tailwindBaseColor",message:`Which color would you like to use as the ${a.info("base color")}?`,choices:r.map(n=>({title:n.label,value:n.name}))},{type:"text",name:"tailwindCss",message:`Where is your ${a.info("global CSS")} file?`,initial:e$1?.tailwind.css??e},{type:"toggle",name:"tailwindCssVariables",message:`Would you like to use ${a.info("CSS variables")} for theming?`,initial:e$1?.tailwind.cssVariables??!0,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$1?.tailwind.config??f},{type:"text",name:"components",message:`Configure the import alias for ${a.info("components")}:`,initial:e$1?.aliases.components??c},{type:"text",name:"utils",message:`Configure the import alias for ${a.info("utils")}:`,initial:e$1?.aliases.utils??d},{type:"toggle",name:"rsc",message:`Are you using ${a.info("React Server Components")}?`,initial:e$1?.rsc??!0,active:"yes",inactive:"no"}]);return g.parse({$schema:"https://ui.shadcn.com/schema.json",style:i.style,tailwind:{config:i.tailwindConfig,css:i.tailwindCss,baseColor:i.tailwindBaseColor,cssVariables:i.tailwindCssVariables,prefix:i.tailwindPrefix},rsc:i.rsc,tsx:i.typescript,aliases:{utils:i.utils,components:i.components,lib:i.components.replace(/\/components$/,"lib"),hooks:i.components.replace(/\/components$/,"hooks")}})}async function Mi(e,t){let r=e.style,i=t.baseColor,n=e.tailwind.cssVariables;if(!t.defaults){let[o,a$1,s]=await Promise.all([K(),N(),p(e)]),c=await Ze([{type:s==="v4"?null:"select",name:"style",message:`Which ${a.info("style")} would you like to use?`,choices:o.map(l=>({title:l.name==="new-york"?"New York (Recommended)":l.label,value:l.name})),initial:0},{type:t.baseColor?null:"select",name:"tailwindBaseColor",message:`Which color would you like to use as the ${a.info("base color")}?`,choices:a$1.map(l=>({title:l.label,value:l.name}))}]);r=c.style??"new-york",i=c.tailwindBaseColor??i,n=t.cssVariables;}return g.parse({$schema:e?.$schema,style:r,tailwind:{...e?.tailwind,baseColor:i,cssVariables:n},rsc:e?.rsc,tsx:e?.tsx,aliases:e?.aliases,iconLibrary:e?.iconLibrary})}async function Xt(e){let t={};if(!te.existsSync(e.cwd)||!te.existsSync(S__default.resolve(e.cwd,"package.json")))return t[F]=!0,{errors:t,config:null};if(!te.existsSync(S__default.resolve(e.cwd,"components.json")))return t[_]=!0,{errors:t,config:null};try{let r=await h(e.cwd);return {errors:t,config:r}}catch{q.break(),q.error(`An invalid ${a.info("components.json")} file was found at ${a.info(e.cwd)}.
|
|
70
|
+
Before you can add components, you must create a valid ${a.info("components.json")} file by running the ${a.info("init")} command.`),q.error(`Learn more at ${a.info("https://ui.shadcn.com/docs/components-json")}.`),q.break(),process.exit(1);}}async function Zt(e,t){let r=S__default.join(t.resolvedPaths.cwd,"app/page.tsx");if(!(await B__default.stat(r)).isFile())return;let i=await M(e,t.style);if(!i?.meta?.importSpecifier||!i?.meta?.moduleSpecifier)return;let n=`import { ${i?.meta?.importSpecifier} } from "${i.meta.moduleSpecifier}"
|
|
70
71
|
|
|
71
72
|
export default function Page() {
|
|
72
73
|
return <${i?.meta?.importSpecifier} />
|
|
73
|
-
}`;await B__default.writeFile(r,
|
|
74
|
-
Existing CSS variables and components will be overwritten. Continue?`)});c||(q.break(),q.log("Installation cancelled."),q.break(),process.exit(1));}if(r.components?.length||(r.components=await Vi(r)),(await n(r.cwd))?.tailwindVersion==="v4"){let c=tt.filter(l=>r.components?.includes(l.name));c?.length&&(q.break(),c.forEach(l=>{q.warn(a.warn(l.message));}),q.break(),process.exit(1));}let{errors:n$1,config:a$1}=await Xt(r);if(n$1[_]){let{proceed:c}=await Qe({type:"confirm",name:"proceed",message:`You need to create a ${a.info("components.json")} file to add components. Proceed?`,initial:!0});c||(q.break(),process.exit(1)),a$1=await Ne({cwd:r.cwd,yes:!0,force:!0,defaults:!1,skipPreflight:!1,silent:!0,isNewProject:!1,srcDir:r.srcDir,cssVariables:r.cssVariables,style:"index"});}let s=!1;if(n$1[A]){let{projectPath:c,template:l}=await $e({cwd:r.cwd,force:r.overwrite,srcDir:r.srcDir,components:r.components});c||(q.break(),process.exit(1)),r.cwd=c,l==="next-monorepo"?(r.cwd=S__default.resolve(r.cwd,"apps/web"),a$1=await h(r.cwd)):(a$1=await Ne({cwd:r.cwd,yes:!0,force:!0,defaults:!1,skipPreflight:!0,silent:!0,isNewProject:!0,srcDir:r.srcDir,cssVariables:r.cssVariables,style:"index"}),s=r.components?.length===1&&!!r.components[0].match(/\/chat\/b\//));}if(!a$1)throw new Error(`Failed to read config at ${a.info(r.cwd)}.`);await Ee(r.components,a$1,r),s&&await Zt(r.components[0],a$1);}catch(r){q.break(),s(r);}});async function Vi(e){let t=await J();if(!t)return q.break(),s(new Error("Failed to fetch registry index.")),[];if(e.all)return t.map(o=>o.name).filter(o=>!tt.some(n=>n.name===o));if(e.components?.length)return e.components;let{components:r}=await Qe({type:"multiselect",name:"components",message:"Which components would you like to add?",hint:"Space to select. A to toggle all. Enter to submit.",instructions:!1,choices:t.filter(o=>o.type==="registry:ui"&&!tt.some(n=>n.name===o.name)).map(o=>({title:o.name,value:o.name,selected:e.all?!0:e.components?.includes(o.name)}))});r?.length||(q.warn("No components selected. Exiting."),q.info(""),process.exit(1));let i=z.array(z.string()).safeParse(r);return i.success?i.data:(q.error(""),s(new Error("Something went wrong. Please try again.")),[])}async function or(e){let t={},r={cwd:e.cwd,registryFile:S__default.resolve(e.cwd,e.registryFile),outputDir:S__default.resolve(e.cwd,e.outputDir)};return Z.existsSync(r.registryFile)||(t[H]=!0),await Z.mkdir(r.outputDir,{recursive:!0}),Object.keys(t).length>0&&(t[H]&&(q.break(),q.error(`The path ${a.info(r.registryFile)} does not exist.`)),q.break(),process.exit(1)),{errors:t,resolvePaths:r}}var zi=z.object({cwd:z.string(),registryFile:z.string(),outputDir:z.string()}),nr=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$1=zi.parse({cwd:S.resolve(t.cwd),registryFile:e,outputDir:t.output}),{resolvePaths:i}=await or(r$1),o=await B.readFile(i.registryFile,"utf-8"),n=C.safeParse(JSON.parse(o));n.success||(q.error(`Invalid registry file found at ${a.info(i.registryFile)}.`),process.exit(1));let a$1=r("Building registry...");for(let s of n.data.items){if(!s.files)continue;a$1.start(`Building ${s.name}...`),s.$schema="https://ui.shadcn.com/schema/registry-item.json";for(let l of s.files)l.content=await B.readFile(S.resolve(i.cwd,l.path),"utf-8");let c=B$1.safeParse(s);if(!c.success){q.error(`Invalid registry item found for ${a.info(s.name)}.`);continue}await B.writeFile(S.resolve(i.outputDir,`${c.data.name}.json`),JSON.stringify(c.data,null,2));}a$1.succeed("Building registry.");}catch(r){q.break(),s(r);}});var Ki=z.object({component:z.string().optional(),yes:z.boolean(),cwd:z.string(),path:z.string().optional()}),ar=new Command().name("diff").description("check for updates against the registry").argument("[component]","the component name").option("-y, --yes","skip confirmation prompt.",!1).option("-c, --cwd <cwd>","the working directory. defaults to the current directory.",process.cwd()).action(async(e,t)=>{try{let r=Ki.parse({component:e,...t}),i=S__default.resolve(r.cwd);existsSync(i)||(q.error(`The path ${i} does not exist. Please try again.`),process.exit(1));let o=await h(i);o||(q.warn(`Configuration is missing. Please run ${a.success("init")} to create a components.json file.`),process.exit(1));let n=await J();if(n||(s(new Error("Failed to fetch registry index.")),process.exit(1)),!r.component){let c=o.resolvedPaths.components,l=n.filter(f=>{for(let u of f.files??[]){let g=S__default.resolve(c,typeof u=="string"?u:u.path);if(existsSync(g))return !0}return !1}),m=[];for(let f of l){let u=await sr(f,o);u.length&&m.push({name:f.name,changes:u});}m.length||(q.info("No updates found."),process.exit(0)),q.info("The following components have updates available:");for(let f of m){q.info(`- ${f.name}`);for(let u of f.changes)q.info(` - ${u.filePath}`);}q.break(),q.info(`Run ${a.success("diff <component>")} to see the changes.`),process.exit(0);}let a$1=n.find(c=>c.name===r.component);a$1||(q.error(`The component ${a.success(r.component)} does not exist.`),process.exit(1));let s$1=await sr(a$1,o);s$1.length||(q.info(`No updates found for ${r.component}.`),process.exit(0));for(let c of s$1)q.info(`- ${c.filePath}`),await Gi(c.patch),q.info("");}catch(r){s(r);}});async function sr(e,t){let r=await Q$1(t.style,[e]),i=await O(t.tailwind.baseColor);if(!r)return [];let o=[];for(let n of r){let a=await R(t,n);if(a)for(let s of n.files??[]){let c=S__default.resolve(a,typeof s=="string"?s:s.path);if(!existsSync(c))continue;let l=await promises.readFile(c,"utf8");if(typeof s=="string"||!s.content)continue;let m=await je({filename:s.path,raw:s.content,config:t,baseColor:i}),f=diffLines(m,l);f.length>1&&o.push({filePath:c,patch:f});}}return o}async function Gi(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 cr=new Command().name("info").description("get information about your project").option("-c, --cwd <cwd>","the working directory. defaults to the current directory.",process.cwd()).action(async e=>{q.info("> project info"),console.log(await n(e.cwd)),q.break(),q.info("> components.json"),console.log(await h(e.cwd));});async function pr(e){if(!e.resolvedPaths.ui)throw new Error("We could not find a valid `ui` path in your `components.json` file. Please ensure you have a valid `ui` path in your `components.json` file.");let t=e.resolvedPaths.ui,[r$1,i]=await Promise.all([Hi("**/*.{js,ts,jsx,tsx}",{cwd:t}),L$1()]);if(Object.keys(i).length===0)throw new Error("Something went wrong fetching the registry icons.");let o=Object.entries(L).map(([m,f])=>({title:f.name,value:m})),n=await Qe([{type:"select",name:"sourceLibrary",message:`Which icon library would you like to ${a.info("migrate from")}?`,choices:o},{type:"select",name:"targetLibrary",message:`Which icon library would you like to ${a.info("migrate to")}?`,choices:o}]);if(n.sourceLibrary===n.targetLibrary)throw new Error("You cannot migrate to the same icon library. Please choose a different icon library.");if(!(n.sourceLibrary in L&&n.targetLibrary in L))throw new Error("Invalid icon library. Please choose a valid icon library.");let a$1=L[n.sourceLibrary],s=L[n.targetLibrary],{confirm:c}=await Qe({type:"confirm",name:"confirm",initial:!0,message:`We will migrate ${a.info(r$1.length)} files in ${a.info(`./${S__default.relative(e.resolvedPaths.cwd,t)}`)} from ${a.info(a$1.name)} to ${a.info(s.name)}. Continue?`});c||(q.info("Migration cancelled."),process.exit(0)),s.package&&await X([s.package],[],e,{silent:!1});let l=r("Migrating icons...")?.start();await Promise.all(r$1.map(async m=>{l.text=`Migrating ${m}...`;let f=S__default.join(t,m),u=await promises.readFile(f,"utf-8"),g=await eo(u,n.sourceLibrary,n.targetLibrary,i);await promises.writeFile(f,g);})),l.succeed("Migration complete.");}async function eo(e,t,r,i){let o=L[t]?.import,n=L[r]?.import,a=await promises.mkdtemp(S__default.join(tmpdir(),"shadcn-")),s=new Project({compilerOptions:{}}),c=S__default.join(a,`shadcn-icons-${randomBytes(4).toString("hex")}.tsx`),l=s.createSourceFile(c,e,{scriptKind:ScriptKind.TSX}),m=[];for(let f of l.getImportDeclarations()??[])if(f.getModuleSpecifier()?.getText()===`"${o}"`){for(let u of f.getNamedImports()??[]){let g=u.getName(),y=Object.values(i).find(h=>h[t]===g)?.[r];!y||m.includes(y)||(m.push(y),u.remove(),l.getDescendantsOfKind(SyntaxKind.JsxSelfClosingElement).filter(h=>h.getTagNameNode()?.getText()===g).forEach(h=>h.getTagNameNode()?.replaceWithText(y)));}f.getNamedImports()?.length===0&&f.remove();}return m.length>0&&l.addImportDeclaration({moduleSpecifier:n,namedImports:m.map(f=>({name:f}))}),await l.getText()}function io(e){return e.split("-").map(t=>t.charAt(0).toUpperCase()+t.slice(1)).join("")}function oo(e,t,r,i){let n=e.replace(/\/\/.*$/gm,"").replace(/\/\*[\s\S]*?\*\//g,"").replace(/\s+/g," ").trim().split(",").map(a=>a.trim()).filter(Boolean);for(let a of n){let s=a.match(/^type\s+(\w+)(?:\s+as\s+(\w+))?$/),c=a.match(/^(\w+)\s+as\s+(\w+)$/);if(s){let l=s[1],m=s[2];i==="slot"&&l==="Slot"&&!m?r.push({name:"Slot",alias:"SlotPrimitive",isType:!0}):r.push({name:l,alias:m,isType:!0});}else if(c){let l=c[1],m=c[2];i==="slot"&&l==="Slot"&&m==="Slot"?r.push({name:"Slot",alias:"SlotPrimitive",isType:t}):r.push({name:l,alias:m,isType:t});}else i==="slot"&&a==="Slot"?r.push({name:"Slot",alias:"SlotPrimitive",isType:t}):r.push({name:a,isType:t});}}async function mr(e,t={}){if(!e.resolvedPaths.ui)throw new Error("We could not find a valid `ui` path in your `components.json` file. Please ensure you have a valid `ui` path in your `components.json` file.");let r$1=e.resolvedPaths.ui,i=await Hi("**/*.{js,ts,jsx,tsx}",{cwd:r$1});if(!t.yes){let{confirm:s}=await Qe({type:"confirm",name:"confirm",initial:!0,message:`We will migrate ${a.info(i.length)} files in ${a.info(`./${S__default.relative(e.resolvedPaths.cwd,r$1)}`)} to ${a.info("radix-ui")}. Continue?`});s||(q.info("Migration cancelled."),process.exit(0));}let o=r("Migrating imports...")?.start(),n=new Set;await Promise.all(i.map(async s=>{o.text=`Migrating ${s}...`;let c=S__default.join(r$1,s),l=await promises.readFile(c,"utf-8"),{content:m,replacedPackages:f}=await no(l);f.forEach(u=>n.add(u)),await promises.writeFile(c,m);})),o.succeed("Migrating imports.");let a$1=r("Updating package.json...")?.start();try{let s=m(e.resolvedPaths.cwd,!1);if(!s){a$1.fail("Could not read package.json"),q.warn("Could not update package.json. You may need to manually replace @radix-ui/react-* packages with radix-ui");return}let c=Array.from(n),l=["dependencies","devDependencies"];for(let m of l)if(s[m])for(let f of c)s[m][f]&&delete s[m][f];if(c.length>0){s.dependencies||(s.dependencies={}),s.dependencies["radix-ui"]="latest";let m=S__default.join(e.resolvedPaths.cwd,"package.json");await promises.writeFile(m,JSON.stringify(s,null,2)+`
|
|
75
|
-
`),a$1.succeed("Updated package.json."),await
|
|
74
|
+
}`;await B__default.writeFile(r,n,"utf8");}var rt=[{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."}],Bi=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(),srcDir:z.boolean().optional(),cssVariables:z.boolean()}),tr=new Command().name("add").description("add a component to your project").argument("[components...]","the components to add or a url to the component.").option("-y, --yes","skip confirmation prompt.",!1).option("-o, --overwrite","overwrite existing files.",!1).option("-c, --cwd <cwd>","the working directory. defaults to the current directory.",process.cwd()).option("-a, --all","add all available components",!1).option("-p, --path <path>","the path to add the component to.").option("-s, --silent","mute output.",!1).option("--src-dir","use the src directory when creating a new project.",!1).option("--no-src-dir","do not use the src directory when creating a new project.").option("--css-variables","use css variables for theming.",!0).option("--no-css-variables","do not use css variables for theming.").action(async(e,t)=>{try{let r=Bi.parse({components:e,cwd:S__default.resolve(t.cwd),...t}),i;if(e.length>0&&W(e[0])&&(i=(await M(e[0],""))?.type),!r.yes&&(i==="registry:style"||i==="registry:theme")){q.break();let{confirm:c}=await Ze({type:"confirm",name:"confirm",message:a.warn(`You are about to install a new ${i.replace("registry:","")}.
|
|
75
|
+
Existing CSS variables and components will be overwritten. Continue?`)});c||(q.break(),q.log("Installation cancelled."),q.break(),process.exit(1));}if(r.components?.length||(r.components=await Ui(r)),(await n(r.cwd))?.tailwindVersion==="v4"){let c=rt.filter(l=>r.components?.includes(l.name));c?.length&&(q.break(),c.forEach(l=>{q.warn(a.warn(l.message));}),q.break(),process.exit(1));}let{errors:o,config:a$1}=await Xt(r);if(o[_]){let{proceed:c}=await Ze({type:"confirm",name:"proceed",message:`You need to create a ${a.info("components.json")} file to add components. Proceed?`,initial:!0});c||(q.break(),process.exit(1)),a$1=await Ae({cwd:r.cwd,yes:!0,force:!0,defaults:!1,skipPreflight:!1,silent:!0,isNewProject:!1,srcDir:r.srcDir,cssVariables:r.cssVariables,style:"index"});}let s=!1;if(o[F]){let{projectPath:c,template:l}=await Oe({cwd:r.cwd,force:r.overwrite,srcDir:r.srcDir,components:r.components});c||(q.break(),process.exit(1)),r.cwd=c,l==="next-monorepo"?(r.cwd=S__default.resolve(r.cwd,"apps/web"),a$1=await h(r.cwd)):(a$1=await Ae({cwd:r.cwd,yes:!0,force:!0,defaults:!1,skipPreflight:!0,silent:!0,isNewProject:!0,srcDir:r.srcDir,cssVariables:r.cssVariables,style:"index"}),s=r.components?.length===1&&!!r.components[0].match(/\/chat\/b\//));}if(!a$1)throw new Error(`Failed to read config at ${a.info(r.cwd)}.`);await Te(r.components,a$1,r),s&&await Zt(r.components[0],a$1);}catch(r){q.break(),s(r);}});async function Ui(e){let t=await J();if(!t)return q.break(),s(new Error("Failed to fetch registry index.")),[];if(e.all)return t.map(n=>n.name).filter(n=>!rt.some(o=>o.name===n));if(e.components?.length)return e.components;let{components:r}=await Ze({type:"multiselect",name:"components",message:"Which components would you like to add?",hint:"Space to select. A to toggle all. Enter to submit.",instructions:!1,choices:t.filter(n=>n.type==="registry:ui"&&!rt.some(o=>o.name===n.name)).map(n=>({title:n.name,value:n.name,selected:e.all?!0:e.components?.includes(n.name)}))});r?.length||(q.warn("No components selected. Exiting."),q.info(""),process.exit(1));let i=z.array(z.string()).safeParse(r);return i.success?i.data:(q.error(""),s(new Error("Something went wrong. Please try again.")),[])}async function nr(e){let t={},r={cwd:e.cwd,registryFile:S__default.resolve(e.cwd,e.registryFile),outputDir:S__default.resolve(e.cwd,e.outputDir)};return te.existsSync(r.registryFile)||(t[Q]=!0),await te.mkdir(r.outputDir,{recursive:!0}),Object.keys(t).length>0&&(t[Q]&&(q.break(),q.error(`The path ${a.info(r.registryFile)} does not exist.`)),q.break(),process.exit(1)),{errors:t,resolvePaths:r}}var Gi=z.object({cwd:z.string(),registryFile:z.string(),outputDir:z.string()}),or=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$1=Gi.parse({cwd:S.resolve(t.cwd),registryFile:e,outputDir:t.output}),{resolvePaths:i}=await nr(r$1),n=await B.readFile(i.registryFile,"utf-8"),o=C.safeParse(JSON.parse(n));o.success||(q.error(`Invalid registry file found at ${a.info(i.registryFile)}.`),process.exit(1));let a$1=r("Building registry...");for(let s of o.data.items){if(!s.files)continue;a$1.start(`Building ${s.name}...`),s.$schema="https://ui.shadcn.com/schema/registry-item.json";for(let l of s.files)l.content=await B.readFile(S.resolve(i.cwd,l.path),"utf-8");let c=B$1.safeParse(s);if(!c.success){q.error(`Invalid registry item found for ${a.info(s.name)}.`);continue}await B.writeFile(S.resolve(i.outputDir,`${c.data.name}.json`),JSON.stringify(c.data,null,2));}a$1.succeed("Building registry.");}catch(r){q.break(),s(r);}});var Hi=z.object({component:z.string().optional(),yes:z.boolean(),cwd:z.string(),path:z.string().optional()}),ar=new Command().name("diff").description("check for updates against the registry").argument("[component]","the component name").option("-y, --yes","skip confirmation prompt.",!1).option("-c, --cwd <cwd>","the working directory. defaults to the current directory.",process.cwd()).action(async(e,t)=>{try{let r=Hi.parse({component:e,...t}),i=S__default.resolve(r.cwd);existsSync(i)||(q.error(`The path ${i} does not exist. Please try again.`),process.exit(1));let n=await h(i);n||(q.warn(`Configuration is missing. Please run ${a.success("init")} to create a components.json file.`),process.exit(1));let o=await J();if(o||(s(new Error("Failed to fetch registry index.")),process.exit(1)),!r.component){let c=n.resolvedPaths.components,l=o.filter(m=>{for(let u of m.files??[]){let g=S__default.resolve(c,typeof u=="string"?u:u.path);if(existsSync(g))return !0}return !1}),f=[];for(let m of l){let u=await sr(m,n);u.length&&f.push({name:m.name,changes:u});}f.length||(q.info("No updates found."),process.exit(0)),q.info("The following components have updates available:");for(let m of f){q.info(`- ${m.name}`);for(let u of m.changes)q.info(` - ${u.filePath}`);}q.break(),q.info(`Run ${a.success("diff <component>")} to see the changes.`),process.exit(0);}let a$1=o.find(c=>c.name===r.component);a$1||(q.error(`The component ${a.success(r.component)} does not exist.`),process.exit(1));let s$1=await sr(a$1,n);s$1.length||(q.info(`No updates found for ${r.component}.`),process.exit(0));for(let c of s$1)q.info(`- ${c.filePath}`),await Xi(c.patch),q.info("");}catch(r){s(r);}});async function sr(e,t){let r=await Q$1(t.style,[e]),i=await O(t.tailwind.baseColor);if(!r)return [];let n=[];for(let o of r){let a=await R(t,o);if(a)for(let s of o.files??[]){let c=S__default.resolve(a,typeof s=="string"?s:s.path);if(!existsSync(c))continue;let l=await promises.readFile(c,"utf8");if(typeof s=="string"||!s.content)continue;let f=await Ee({filename:s.path,raw:s.content,config:t,baseColor:i}),m=diffLines(f,l);m.length>1&&n.push({filePath:c,patch:m});}}return n}async function Xi(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 cr=new Command().name("info").description("get information about your project").option("-c, --cwd <cwd>","the working directory. defaults to the current directory.",process.cwd()).action(async e=>{q.info("> project info"),console.log(await n(e.cwd)),q.break(),q.info("> components.json"),console.log(await h(e.cwd));});async function pr(e){if(!e.resolvedPaths.ui)throw new Error("We could not find a valid `ui` path in your `components.json` file. Please ensure you have a valid `ui` path in your `components.json` file.");let t=e.resolvedPaths.ui,[r$1,i]=await Promise.all([tn("**/*.{js,ts,jsx,tsx}",{cwd:t}),L$1()]);if(Object.keys(i).length===0)throw new Error("Something went wrong fetching the registry icons.");let n=Object.entries(L).map(([f,m])=>({title:m.name,value:f})),o=await Ze([{type:"select",name:"sourceLibrary",message:`Which icon library would you like to ${a.info("migrate from")}?`,choices:n},{type:"select",name:"targetLibrary",message:`Which icon library would you like to ${a.info("migrate to")}?`,choices:n}]);if(o.sourceLibrary===o.targetLibrary)throw new Error("You cannot migrate to the same icon library. Please choose a different icon library.");if(!(o.sourceLibrary in L&&o.targetLibrary in L))throw new Error("Invalid icon library. Please choose a valid icon library.");let a$1=L[o.sourceLibrary],s=L[o.targetLibrary],{confirm:c}=await Ze({type:"confirm",name:"confirm",initial:!0,message:`We will migrate ${a.info(r$1.length)} files in ${a.info(`./${S__default.relative(e.resolvedPaths.cwd,t)}`)} from ${a.info(a$1.name)} to ${a.info(s.name)}. Continue?`});c||(q.info("Migration cancelled."),process.exit(0)),s.package&&await Z([s.package],[],e,{silent:!1});let l=r("Migrating icons...")?.start();await Promise.all(r$1.map(async f=>{l.text=`Migrating ${f}...`;let m=S__default.join(t,f),u=await promises.readFile(m,"utf-8"),g=await sn(u,o.sourceLibrary,o.targetLibrary,i);await promises.writeFile(m,g);})),l.succeed("Migration complete.");}async function sn(e,t,r,i){let n=L[t]?.import,o=L[r]?.import,a=await promises.mkdtemp(S__default.join(tmpdir(),"shadcn-")),s=new Project({compilerOptions:{}}),c=S__default.join(a,`shadcn-icons-${randomBytes(4).toString("hex")}.tsx`),l=s.createSourceFile(c,e,{scriptKind:ScriptKind.TSX}),f=[];for(let m of l.getImportDeclarations()??[])if(m.getModuleSpecifier()?.getText()===`"${n}"`){for(let u of m.getNamedImports()??[]){let g=u.getName(),y=Object.values(i).find(h=>h[t]===g)?.[r];!y||f.includes(y)||(f.push(y),u.remove(),l.getDescendantsOfKind(SyntaxKind.JsxSelfClosingElement).filter(h=>h.getTagNameNode()?.getText()===g).forEach(h=>h.getTagNameNode()?.replaceWithText(y)));}m.getNamedImports()?.length===0&&m.remove();}return f.length>0&&l.addImportDeclaration({moduleSpecifier:o,namedImports:f.map(m=>({name:m}))}),await l.getText()}function ln(e){return e.split("-").map(t=>t.charAt(0).toUpperCase()+t.slice(1)).join("")}function pn(e,t,r,i){let o=e.replace(/\/\/.*$/gm,"").replace(/\/\*[\s\S]*?\*\//g,"").replace(/\s+/g," ").trim().split(",").map(a=>a.trim()).filter(Boolean);for(let a of o){let s=a.match(/^type\s+(\w+)(?:\s+as\s+(\w+))?$/),c=a.match(/^(\w+)\s+as\s+(\w+)$/);if(s){let l=s[1],f=s[2];i==="slot"&&l==="Slot"&&!f?r.push({name:"Slot",alias:"SlotPrimitive",isType:!0}):r.push({name:l,alias:f,isType:!0});}else if(c){let l=c[1],f=c[2];i==="slot"&&l==="Slot"&&f==="Slot"?r.push({name:"Slot",alias:"SlotPrimitive",isType:t}):r.push({name:l,alias:f,isType:t});}else i==="slot"&&a==="Slot"?r.push({name:"Slot",alias:"SlotPrimitive",isType:t}):r.push({name:a,isType:t});}}async function fr(e,t={}){if(!e.resolvedPaths.ui)throw new Error("We could not find a valid `ui` path in your `components.json` file. Please ensure you have a valid `ui` path in your `components.json` file.");let r$1=e.resolvedPaths.ui,i=await tn("**/*.{js,ts,jsx,tsx}",{cwd:r$1});if(!t.yes){let{confirm:s}=await Ze({type:"confirm",name:"confirm",initial:!0,message:`We will migrate ${a.info(i.length)} files in ${a.info(`./${S__default.relative(e.resolvedPaths.cwd,r$1)}`)} to ${a.info("radix-ui")}. Continue?`});s||(q.info("Migration cancelled."),process.exit(0));}let n=r("Migrating imports...")?.start(),o=new Set;await Promise.all(i.map(async s=>{n.text=`Migrating ${s}...`;let c=S__default.join(r$1,s),l=await promises.readFile(c,"utf-8"),{content:f,replacedPackages:m}=await fn(l);m.forEach(u=>o.add(u)),await promises.writeFile(c,f);})),n.succeed("Migrating imports.");let a$1=r("Updating package.json...")?.start();try{let s=m(e.resolvedPaths.cwd,!1);if(!s){a$1.fail("Could not read package.json"),q.warn("Could not update package.json. You may need to manually replace @radix-ui/react-* packages with radix-ui");return}let c=Array.from(o),l=["dependencies","devDependencies"];for(let f of l)if(s[f])for(let m of c)s[f][m]&&delete s[f][m];if(c.length>0){s.dependencies||(s.dependencies={}),s.dependencies["radix-ui"]="latest";let f=S__default.join(e.resolvedPaths.cwd,"package.json");await promises.writeFile(f,JSON.stringify(s,null,2)+`
|
|
76
|
+
`),a$1.succeed("Updated package.json."),await Z(["radix-ui"],[],e,{silent:!1});}else a$1.succeed("No packages found in source files.");}catch{a$1.fail("Failed to update package.json"),q.warn("You may need to manually replace @radix-ui/react-* packages with radix-ui");}}async function fn(e){let t=/import\s+(?:(type)\s+)?(?:\*\s+as\s+(\w+)|{([^}]+)})\s+from\s+(["'])@radix-ui\/react-([^"']+)\4(;?)/g,r=[],i=[],n=[],o='"',a=!1,s=e,c;for(;(c=t.exec(e))!==null;){let[y,h,R,x,b,I,k]=c;if(I==="icons"||I.startsWith("icons/"))continue;i.push(y),i.length===1&&(o=b,a=k===";"),n.push(`@radix-ui/react-${I}`);let D=!!h;if(R){let E=ln(I);r.push({name:E,alias:R,isType:D});}else x&&pn(x,D,r,I);}if(r.length===0)return {content:e,replacedPackages:[]};let l=r.filter((y,h,R)=>h===R.findIndex(x=>x.name===y.name&&x.alias===y.alias&&x.isType===y.isType)),m=`import { ${l.map(y=>{let h=y.isType?"type ":"";return y.alias?`${h}${y.name} as ${y.alias}`:`${h}${y.name}`}).join(", ")} } from ${o}radix-ui${o}${a?";":""}`;s=i.reduce((y,h,R)=>y.replace(h,R===0?m:""),s),s=s.replace(/\n\s*\n\s*\n/g,`
|
|
76
77
|
|
|
77
78
|
`),l.some(y=>y.name==="Slot"&&y.alias==="SlotPrimitive")&&(s=s.split(`
|
|
78
|
-
`).map(R=>{if(R.trim().startsWith("import "))return R;let x=R;return x=x.replace(/\b(asChild\s*\?\s*)Slot(\s*:)/g,"$1__SLOT_PLACEHOLDER__$2"),x=x.replace(/\bReact\.ComponentProps<typeof\s+Slot>/g,"React.ComponentProps<typeof __SLOT_PLACEHOLDER__>"),x=x.replace(/\bComponentProps<typeof\s+Slot>/g,"ComponentProps<typeof __SLOT_PLACEHOLDER__>"),x=x.replace(/(<\/?)Slot(\s*\/?>)/g,"$1__SLOT_PLACEHOLDER__$2"),x=x.replace(/\bSlot\b/g,(b,I,k)=>{let
|
|
79
|
-
`));let g=Array.from(new Set(
|
|
80
|
-
Before you can run a migration, you must create a valid ${a.info("components.json")} file by running the ${a.info("init")} command.`),q.error(`Learn more at ${a.info("https://ui.shadcn.com/docs/components-json")}.`),q.break(),process.exit(1);}}var ur=[{name:"icons",description:"migrate your ui components to a different icon library."},{name:"radix",description:"migrate to radix-ui."}],
|
|
81
|
-
Before you can build the registry, you must create a valid ${a.info("components.json")} file by running the ${a.info("init")} command.`),q.break(),process.exit(1);}}var yr=[".tsx",".ts",".jsx",".js",".css"],wr=["lib/utils.ts"],
|
|
79
|
+
`).map(R=>{if(R.trim().startsWith("import "))return R;let x=R;return x=x.replace(/\b(asChild\s*\?\s*)Slot(\s*:)/g,"$1__SLOT_PLACEHOLDER__$2"),x=x.replace(/\bReact\.ComponentProps<typeof\s+Slot>/g,"React.ComponentProps<typeof __SLOT_PLACEHOLDER__>"),x=x.replace(/\bComponentProps<typeof\s+Slot>/g,"ComponentProps<typeof __SLOT_PLACEHOLDER__>"),x=x.replace(/(<\/?)Slot(\s*\/?>)/g,"$1__SLOT_PLACEHOLDER__$2"),x=x.replace(/\bSlot\b/g,(b,I,k)=>{let D=k.substring(0,I),E=(D.match(/"/g)||[]).length,V=(D.match(/'/g)||[]).length;return E%2!==0||V%2!==0?b:"__SLOT_PLACEHOLDER__"}),x=x.replace(/__SLOT_PLACEHOLDER__/g,"SlotPrimitive.Slot"),x}).join(`
|
|
80
|
+
`));let g=Array.from(new Set(n));return {content:s,replacedPackages:g}}async function dr(e){let t={};if(!te.existsSync(e.cwd)||!te.existsSync(S__default.resolve(e.cwd,"package.json")))return t[F]=!0,{errors:t,config:null};if(!te.existsSync(S__default.resolve(e.cwd,"components.json")))return t[_]=!0,{errors:t,config:null};try{let r=await h(e.cwd);return {errors:t,config:r}}catch{q.break(),q.error(`An invalid ${a.info("components.json")} file was found at ${a.info(e.cwd)}.
|
|
81
|
+
Before you can run a migration, you must create a valid ${a.info("components.json")} file by running the ${a.info("init")} command.`),q.error(`Learn more at ${a.info("https://ui.shadcn.com/docs/components-json")}.`),q.break(),process.exit(1);}}var ur=[{name:"icons",description:"migrate your ui components to a different icon library."},{name:"radix",description:"migrate to radix-ui."}],un=z.object({cwd:z.string(),list:z.boolean(),yes:z.boolean(),migration:z.string().refine(e=>e&&ur.some(t=>t.name===e),{message:"You must specify a valid migration. Run `shadcn migrate --list` to see available migrations."}).optional()}),gr=new Command().name("migrate").description("run a migration.").argument("[migration]","the migration to run.").option("-c, --cwd <cwd>","the working directory. defaults to the current directory.",process.cwd()).option("-l, --list","list all migrations.",!1).option("-y, --yes","skip confirmation prompt.",!1).action(async(e,t)=>{try{let r=un.parse({cwd:S__default.resolve(t.cwd),migration:e,list:t.list,yes:t.yes});if(r.list||!r.migration){q.info("Available migrations:");for(let o of ur)q.info(`- ${o.name}: ${o.description}`);return}if(!r.migration)throw new Error("You must specify a migration. Run `shadcn migrate --list` to see available migrations.");let{errors:i,config:n}=await dr(r);if(i[F]||i[_])throw new Error("No `components.json` file found. Ensure you are at the root of your project.");if(!n)throw new Error("Something went wrong reading your `components.json` file. Please ensure you have a valid `components.json` file.");r.migration==="icons"&&await pr(n),r.migration==="radix"&&await fr(n,{yes:r.yes});}catch(r){q.break(),s(r);}});async function hr(e){let t={},r={cwd:e.cwd,registryFile:S__default.resolve(e.cwd,e.registryFile),outputDir:S__default.resolve(e.cwd,e.outputDir)};if(!te.existsSync(r.registryFile))return t[Q]=!0,{errors:t,resolvePaths:null,config:null};if(!te.existsSync(S__default.resolve(e.cwd,"components.json")))return t[_]=!0,{errors:t,resolvePaths:null,config:null};await te.mkdir(r.outputDir,{recursive:!0});try{let i=await h(e.cwd);return {errors:t,config:i,resolvePaths:r}}catch{q.break(),q.error(`An invalid ${a.info("components.json")} file was found at ${a.info(e.cwd)}.
|
|
82
|
+
Before you can build the registry, you must create a valid ${a.info("components.json")} file by running the ${a.info("init")} command.`),q.break(),process.exit(1);}}var yr=[".tsx",".ts",".jsx",".js",".css"],wr=["lib/utils.ts"],xn=[/^(react|react-dom|next)(\/.*)?$/,/^(node|jsr|npm):.*$/],bn=new Project({compilerOptions:{}});function Sn(e){if(xn.some(t=>t.test(e)))return null;if(!e.startsWith("@")&&e.includes("/")&&(e=e.split("/")[0]),e.startsWith("@")){let t=e.split("/");t.length>2&&(e=t.slice(0,2).join("/"));}return e}async function ft(e,t,r,i=new Set){let n=S.resolve(t.resolvedPaths.cwd,e),o=S.relative(t.resolvedPaths.cwd,n);if(wr.includes(o))return {dependencies:[],files:[]};let a=S.extname(e);if(!yr.includes(a))return {dependencies:[],files:[]};if(i.has(o))return {dependencies:[],files:[]};if(i.add(o),!(await B.stat(n)).isFile())return {dependencies:[],files:[]};let c=await B.readFile(n,"utf-8"),l=await Rn(S.basename(n)),f=bn.createSourceFile(l,c,{scriptKind:ScriptKind.TSX}),m=await loadConfig(t.resolvedPaths.cwd);if(m.resultType==="failed")return {dependencies:[],files:[]};let u=[],g=new Set,y=xr(e),h={path:o,type:y,target:""};u.push(h);let R=f.getImportDeclarations();for(let b$1 of R){let I=b$1.getModuleSpecifierValue(),k=I.startsWith(".");if(!I.startsWith(`${r.aliasPrefix}/`)&&!k){let M=Sn(I);M&&g.add(M);continue}let E=await b(I,m);if(k&&(E=S.resolve(S.dirname(n),I)),!E)continue;if(!S.extname(E))for(let M of yr){let dt=`${E}${M}`;try{await B.access(dt),E=dt;break}catch{continue}}let de=S.relative(t.resolvedPaths.cwd,E);if(i.has(de)||wr.includes(de))continue;let Le=xr(I),mt={path:de,type:Le,target:""};(Le==="registry:page"||Le==="registry:file")&&(mt.target=I),u.push(mt);let ue=await ft(de,t,r,i);if(ue.files)for(let M of ue.files)i.has(M.path)||(i.add(M.path),u.push(M));ue.dependencies&&ue.dependencies.forEach(M=>g.add(M));}let x=Array.from(new Map(u.map(b=>[b.path,b])).values());return {dependencies:Array.from(g),files:x}}async function Rn(e){let t=await B.mkdtemp(S.join(tmpdir(),"shadcn-"));return S.join(t,e)}function xr(e){return e.includes("/ui/")?"registry:ui":e.includes("/lib/")?"registry:lib":e.includes("/hooks/")?"registry:hook":(e.includes("/components/"),"registry:component")}var In=z.object({cwd:z.string(),registryFile:z.string(),outputDir:z.string(),verbose:z.boolean().optional().default(!1)}),br=new Command().name("registry:build").description("builds the registry [EXPERIMENTAL]").argument("[registry]","path to registry.json file","./registry.json").option("-o, --output <path>","destination directory for json files","./public/r").option("-c, --cwd <cwd>","the working directory. defaults to the current directory.",process.cwd()).option("-v, --verbose","verbose output").action(async(e,t)=>{await Pn({cwd:S.resolve(t.cwd),registryFile:e,outputDir:t.output,verbose:t.verbose});});async function Pn(e){try{let t=In.parse(e),[{errors:r$1,resolvePaths:i,config:n$1},o]=await Promise.all([hr(t),n(t.cwd)]);(r$1[_]||!n$1||!o)&&(q.error(`A ${a.info("components.json")} file is required to build the registry. Run ${a.info("shadcn init")} to create one.`),q.break(),process.exit(1)),(r$1[Q]||!i)&&(q.error(`We could not find a registry file at ${a.info(S.resolve(t.cwd,t.registryFile))}.`),q.break(),process.exit(1));let a$1=await B.readFile(i.registryFile,"utf-8"),s=C.safeParse(JSON.parse(a$1));s.success||(q.error(`Invalid registry file found at ${a.info(i.registryFile)}.`),q.break(),process.exit(1));let c=r("Building registry..."),l=await Cn(s.data,n$1,o);for(let f of l.items)f.files=f.files?.filter((m,u,g)=>u===g.findIndex(y=>y.path===m.path)),f.dependencies&&(f.dependencies=f.dependencies.filter((m,u,g)=>u===g.findIndex(y=>y===m)));for(let f of l.items){if(!f.files)continue;c.start(`Building ${f.name}...`),f.$schema="https://ui.shadcn.com/schema/registry-item.json";for(let u of f.files){let g=S.resolve(i.cwd,u.path);try{if(!(await B.stat(g)).isFile())continue;u.content=await B.readFile(g,"utf-8");}catch(y){console.error("Error reading file in registry build:",g,y);continue}}let m=B$1.safeParse(f);if(!m.success){q.error(`Invalid registry item found for ${a.info(f.name)}.`);continue}await B.writeFile(S.resolve(i.outputDir,`${m.data.name}.json`),JSON.stringify(m.data,null,2));}if(await B.copyFile(i.registryFile,S.resolve(i.outputDir,"registry.json")),c.succeed("Building registry."),t.verbose){r(`The registry has ${a.info(l.items.length.toString())} items:`).succeed();for(let f of l.items){q.log(` - ${f.name} (${a.info(f.type)})`);for(let m of f.files??[])q.log(` - ${m.path}`);}}}catch(t){q.break(),s(t);}}async function Cn(e,t,r){for(let i of e.items)if(i.files?.length)for(let n of i.files){let o=await ft(n.path,t,r);o.files=o.files?.filter(a=>a.path!==n.path),o.files&&i.files.push(...o.files),o.dependencies&&(i.dependencies=i.dependencies?i.dependencies.concat(o.dependencies):o.dependencies);}return e}var Sr=new Command().name("registry:mcp").description("starts the registry MCP server [EXPERIMENTAL]").option("-c, --cwd <cwd>","the working directory. defaults to the current directory.",process.cwd()).action(async()=>{try{let e=new StdioServerTransport;await a$1.connect(e);}catch(e){q.break(),s(e);}});var Rr={name:"shadcn",version:"2.7.0",description:"Add components to your apps.",publishConfig:{access:"public"},license:"MIT",author:{name:"shadcn",url:"https://twitter.com/shadcn"},repository:{type:"git",url:"https://github.com/shadcn/ui.git",directory:"packages/shadcn"},files:["dist"],keywords:["components","ui","tailwind","radix-ui","shadcn"],type:"module",exports:{".":{types:"./dist/index.d.ts",default:"./dist/index.js"},"./registry":{types:"./dist/registry/index.d.ts",default:"./dist/registry/index.js"},"./mcp":{types:"./dist/mcp/index.d.ts",default:"./dist/mcp/index.js"}},bin:"./dist/index.js",scripts:{dev:"tsup --watch",build:"tsup",typecheck:"tsc --noEmit",clean:"rimraf dist && rimraf components","start:dev":"cross-env REGISTRY_URL=http://localhost:4000/r node dist/index.js","start:prod":"cross-env REGISTRY_URL=https://ui.shadcn.com/r node dist/index.js",start:"node dist/index.js","format:write":'prettier --write "**/*.{ts,tsx,mdx}" --cache',"format:check":'prettier --check "**/*.{ts,tsx,mdx}" --cache',release:"changeset version","pub:beta":"pnpm build && pnpm publish --no-git-checks --access public --tag beta","pub:next":"pnpm build && pnpm publish --no-git-checks --access public --tag next","pub:release":"pnpm build && pnpm publish --access public",test:"vitest run","test:dev":"REGISTRY_URL=http://localhost:4000/r vitest run"},dependencies:{"@antfu/ni":"^23.2.0","@babel/core":"^7.22.1","@babel/parser":"^7.22.6","@babel/plugin-transform-typescript":"^7.22.5","@modelcontextprotocol/sdk":"^1.10.2",commander:"^10.0.0",cosmiconfig:"^8.1.3",deepmerge:"^4.3.1",diff:"^5.1.0",execa:"^7.0.0","fast-glob":"^3.3.2","fs-extra":"^11.1.0","https-proxy-agent":"^6.2.0",kleur:"^4.1.5",msw:"^2.7.1","node-fetch":"^3.3.0",ora:"^6.1.2",postcss:"^8.4.24",prompts:"^2.4.2",recast:"^0.23.2","stringify-object":"^5.0.0","ts-morph":"^18.0.0","tsconfig-paths":"^4.2.0",zod:"^3.20.2","zod-to-json-schema":"^3.24.5"},devDependencies:{"@types/babel__core":"^7.20.1","@types/diff":"^5.0.3","@types/fs-extra":"^11.0.1","@types/prompts":"^2.4.2","@types/stringify-object":"^4.0.5",rimraf:"^6.0.1",tsup:"^6.6.3","type-fest":"^3.8.0",typescript:"^4.9.3"}};process.on("SIGINT",()=>process.exit(0));process.on("SIGTERM",()=>process.exit(0));async function $n(){let e=new Command().name("shadcn").description("add components and dependencies to your project").version(Rr.version,"-v, --version","display the version number");e.addCommand(qt).addCommand(tr).addCommand(ar).addCommand(gr).addCommand(cr).addCommand(or),e.addCommand(br).addCommand(Sr),e.parse();}$n();
|
|
82
83
|
//# sourceMappingURL=out.js.map
|
|
83
84
|
//# sourceMappingURL=index.js.map
|