Comparing version 0.0.0-beta.386a8ee to 0.0.0-beta.45bf824
#!/usr/bin/env node | ||
import{existsSync as Q,promises as je}from"fs";import V from"path";import de from"path";import{createMatchPath as Ye}from"tsconfig-paths";async function O(t,e){return Ye(e.absoluteBaseUrl,e.paths)(t,void 0,()=>!0,[".ts",".tsx"])}import{cosmiconfig as qe}from"cosmiconfig";import{loadConfig as Ze}from"tsconfig-paths";import{z as h}from"zod";var ge="@/components",ue="@/lib/utils",he="app/globals.css",xe="tailwind.config.js";var Qe=qe("components",{searchPlaces:["components.json"]}),j=h.object({$schema:h.string().optional(),style:h.string(),rsc:h.coerce.boolean().default(!1),tsx:h.coerce.boolean().default(!0),tailwind:h.object({config:h.string(),css:h.string(),baseColor:h.string(),cssVariables:h.boolean().default(!0),prefix:h.string().default("").optional()}),aliases:h.object({components:h.string(),utils:h.string(),ui:h.string().optional()})}).strict(),et=j.extend({resolvedPaths:h.object({tailwindConfig:h.string(),tailwindCss:h.string(),utils:h.string(),components:h.string(),ui:h.string()})});async function v(t){let e=await tt(t);return e?await T(t,e):null}async function T(t,e){let n=await Ze(t);if(n.resultType==="failed")throw new Error(`Failed to load ${e.tsx?"tsconfig":"jsconfig"}.json. ${n.message??""}`.trim());return et.parse({...e,resolvedPaths:{tailwindConfig:de.resolve(t,e.tailwind.config),tailwindCss:de.resolve(t,e.tailwind.css),utils:await O(e.aliases.utils,n),components:await O(e.aliases.components,n),ui:e.aliases.ui?await O(e.aliases.ui,n):await O(e.aliases.components,n)}})}async function tt(t){try{let e=await Qe.search(t);return e?j.parse(e.config):null}catch{throw new Error(`Invalid configuration found in ${t}/components.json.`)}}import{detect as rt}from"@antfu/ni";async function N(t){let e=await rt({programmatic:!0,cwd:t});return e==="yarn@berry"?"yarn":e==="pnpm@6"?"pnpm":e==="bun"?"bun":e??"npm"}import D from"chalk";var a={error(...t){console.log(D.red(...t))},warn(...t){console.log(D.yellow(...t))},info(...t){console.log(D.cyan(...t))},success(...t){console.log(D.green(...t))},break(){console.log("")}};function b(t){typeof t=="string"&&(a.error(t),process.exit(1)),t instanceof Error&&(a.error(t.message),process.exit(1)),a.error("Something went wrong. Please try again."),process.exit(1)}import ot from"path";import{z as p}from"zod";var ye=p.object({name:p.string(),dependencies:p.array(p.string()).optional(),devDependencies:p.array(p.string()).optional(),registryDependencies:p.array(p.string()).optional(),files:p.array(p.string()),type:p.enum(["components:ui","components:component","components:example"])}),we=p.array(ye),nt=ye.extend({files:p.array(p.object({name:p.string(),content:p.string()}))}),Ce=p.array(nt),ve=p.array(p.object({name:p.string(),label:p.string()})),Se=p.object({inlineColors:p.object({light:p.record(p.string(),p.string()),dark:p.record(p.string(),p.string())}),cssVars:p.object({light:p.record(p.string(),p.string()),dark:p.record(p.string(),p.string())}),inlineColorsTemplate:p.string(),cssVarsTemplate:p.string()});import{HttpsProxyAgent as it}from"https-proxy-agent";import st from"node-fetch";var Ie=process.env.COMPONENTS_REGISTRY_URL??"https://ui.shadcn.com",at=process.env.https_proxy?new it(process.env.https_proxy):void 0;async function _(){try{let[t]=await M(["index.json"]);return we.parse(t)}catch{throw new Error("Failed to fetch components from registry.")}}async function X(){try{let[t]=await M(["styles/index.json"]);return ve.parse(t)}catch{throw new Error("Failed to fetch styles from registry.")}}async function Y(){return[{name:"neutral",label:"Neutral"},{name:"gray",label:"Gray"},{name:"zinc",label:"Zinc"},{name:"stone",label:"Stone"},{name:"slate",label:"Slate"}]}async function E(t){try{let[e]=await M([`colors/${t}.json`]);return Se.parse(e)}catch{throw new Error("Failed to fetch base color from registry.")}}async function q(t,e){let n=[];for(let r of e){let o=t.find(i=>i.name===r);if(o&&(n.push(o),o.registryDependencies)){let i=await q(t,o.registryDependencies);n.push(...i)}}return n.filter((r,o,i)=>i.findIndex(s=>s.name===r.name)===o)}async function L(t,e){try{let n=e.map(o=>`styles/${t}/${o.name}.json`),r=await M(n);return Ce.parse(r)}catch{throw new Error("Failed to fetch tree from registry.")}}async function W(t,e,n){if(n)return n;if(e.type==="components:ui"&&t.aliases.ui)return t.resolvedPaths.ui;let[r,o]=e.type.split(":");return r in t.resolvedPaths?ot.join(t.resolvedPaths[r],o):null}async function M(t){try{return await Promise.all(t.map(async n=>await(await st(`${Ie}/registry/${n}`,{agent:at})).json()))}catch(e){throw console.log(e),new Error(`Failed to fetch registry from ${Ie}.`)}}import{promises as ht}from"fs";import{tmpdir as xt}from"os";import Oe from"path";import{SyntaxKind as ct}from"ts-morph";var Te=async({sourceFile:t,config:e,baseColor:n})=>(e.tailwind?.cssVariables||!n?.inlineColors||t.getDescendantsOfKind(ct.StringLiteral).forEach(r=>{let o=r.getText();if(o){let i=pt(o.replace(/"/g,""),n.inlineColors);r.replaceWithText(`"${i.trim()}"`)}}),t);function Z(t){if(!t.includes("/")&&!t.includes(":"))return[null,t,null];let e=[],[n,r]=t.split("/");if(!n.includes(":"))return[null,n,r];let o=n.split(":"),i=o.pop(),s=o.join(":");return e.push(s??null,i??null,r??null),e}var lt=["bg-","text-","border-","ring-offset-","ring-"];function pt(t,e){t.includes(" border ")&&(t=t.replace(" border "," border border-border "));let n=t.split(" "),r=new Set,o=new Set;for(let i of n){let[s,f,c]=Z(i),d=lt.find(l=>f?.startsWith(l));if(!d){r.has(i)||r.add(i);continue}let m=f?.replace(d,"");if(m&&m in e.light){r.add([s,`${d}${e.light[m]}`].filter(Boolean).join(":")+(c?`/${c}`:"")),o.add(["dark",s,`${d}${e.dark[m]}`].filter(Boolean).join(":")+(c?`/${c}`:""));continue}r.has(i)||r.add(i)}return[...Array.from(r),...Array.from(o)].join(" ").trim()}var be=async({sourceFile:t,config:e})=>{let n=t.getImportDeclarations();for(let r of n){let o=r.getModuleSpecifierValue();o.startsWith("@/registry/")&&(e.aliases.ui?r.setModuleSpecifier(o.replace(/^@\/registry\/[^/]+\/ui/,e.aliases.ui)):r.setModuleSpecifier(o.replace(/^@\/registry\/[^/]+/,e.aliases.components))),o=="@/lib/utils"&&r.getNamedImports().find(f=>f.getName()==="cn")&&r.setModuleSpecifier(o.replace(/^@\/lib\/utils/,e.aliases.utils))}return t};import{transformFromAstSync as mt}from"@babel/core";import{parse as ft}from"@babel/parser";import dt from"@babel/plugin-transform-typescript";import*as U from"recast";var gt={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"]},Ee=async({sourceFile:t,config:e})=>{let n=t.getFullText();if(e.tsx)return n;let r=U.parse(n,{parser:{parse:i=>ft(i,gt)}}),o=mt(r,n,{cloneInputAst:!1,code:!1,ast:!0,plugins:[dt],configFile:!1});if(!o||!o.ast)throw new Error("Failed to transform JSX");return U.print(o.ast).code};import{SyntaxKind as ut}from"ts-morph";var Pe=async({sourceFile:t,config:e})=>{if(e.rsc)return t;let n=t.getFirstChildByKind(ut.ExpressionStatement);return n?.getText()==='"use client"'&&n.remove(),t};import{Project as yt,ScriptKind as wt}from"ts-morph";import{SyntaxKind as u}from"ts-morph";var Re=async({sourceFile:t,config:e})=>(e.tailwind?.prefix&&(t.getDescendantsOfKind(u.CallExpression).filter(n=>n.getExpression().getText()==="cva").forEach(n=>{if(n.getArguments()[0]?.isKind(u.StringLiteral)){let r=n.getArguments()[0];r&&r.replaceWithText(`"${y(r.getText()?.replace(/"/g,""),e.tailwind.prefix)}"`)}n.getArguments()[1]?.isKind(u.ObjectLiteralExpression)&&n.getArguments()[1]?.getDescendantsOfKind(u.PropertyAssignment).find(r=>r.getName()==="variants")?.getDescendantsOfKind(u.PropertyAssignment).forEach(r=>{r.getDescendantsOfKind(u.PropertyAssignment).forEach(o=>{let i=o.getInitializerIfKind(u.StringLiteral);i&&i?.replaceWithText(`"${y(i.getText()?.replace(/"/g,""),e.tailwind.prefix)}"`)})})}),t.getDescendantsOfKind(u.JsxAttribute).forEach(n=>{if(n.getName()==="className"){if(n.getInitializer()?.isKind(u.StringLiteral)){let r=n.getInitializer();r&&r.replaceWithText(`"${y(r.getText()?.replace(/"/g,""),e.tailwind.prefix)}"`)}if(n.getInitializer()?.isKind(u.JsxExpression)){let r=n.getInitializer()?.getDescendantsOfKind(u.CallExpression).find(o=>o.getExpression().getText()==="cn");r&&r.getArguments().forEach(o=>{(o.isKind(u.ConditionalExpression)||o.isKind(u.BinaryExpression))&&o.getChildrenOfKind(u.StringLiteral).forEach(i=>{i.replaceWithText(`"${y(i.getText()?.replace(/"/g,""),e.tailwind.prefix)}"`)}),o.isKind(u.StringLiteral)&&o.replaceWithText(`"${y(o.getText()?.replace(/"/g,""),e.tailwind.prefix)}"`)})}}n.getName()==="classNames"&&n.getInitializer()?.isKind(u.JsxExpression)&&n.getDescendantsOfKind(u.PropertyAssignment).forEach(r=>{if(r.getInitializer()?.isKind(u.CallExpression)){let o=r.getInitializerIfKind(u.CallExpression);o&&o.getArguments().forEach(i=>{i.isKind(u.ConditionalExpression)&&i.getChildrenOfKind(u.StringLiteral).forEach(s=>{s.replaceWithText(`"${y(s.getText()?.replace(/"/g,""),e.tailwind.prefix)}"`)}),i.isKind(u.StringLiteral)&&i.replaceWithText(`"${y(i.getText()?.replace(/"/g,""),e.tailwind.prefix)}"`)})}if(r.getInitializer()?.isKind(u.StringLiteral)&&r.getName()!=="variant"){let o=r.getInitializer();o&&o.replaceWithText(`"${y(o.getText()?.replace(/"/g,""),e.tailwind.prefix)}"`)}})})),t);function y(t,e=""){let n=t.split(" "),r=[];for(let o of n){let[i,s,f]=Z(o);i?f?r.push(`${i}:${e}${s}/${f}`):r.push(`${i}:${e}${s}`):f?r.push(`${e}${s}/${f}`):r.push(`${e}${s}`)}return r.join(" ")}function ke(t,e){let n=t.split(` | ||
`);for(let r of n)if(r.includes("@apply")){let o=r.replace("@apply","").trim(),i=y(o,e);t=t.replace(o,i)}return t}var Ct=[be,Pe,Te,Re],vt=new yt({compilerOptions:{}});async function St(t){let e=await ht.mkdtemp(Oe.join(xt(),"shadcn-"));return Oe.join(e,t)}async function K(t){let e=await St(t.filename),n=vt.createSourceFile(e,t.raw,{scriptKind:wt.TSX});for(let r of Ct)r({sourceFile:n,...t});return await Ee({sourceFile:n,...t})}import Ae from"chalk";import{Command as It}from"commander";import{execa as Fe}from"execa";import Tt from"ora";import ee from"prompts";import{z as S}from"zod";var bt=S.object({components:S.array(S.string()).optional(),yes:S.boolean(),overwrite:S.boolean(),cwd:S.string(),all:S.boolean(),path:S.string().optional()}),$e=new It().name("add").description("add a component to your project").argument("[components...]","the components to add").option("-y, --yes","skip confirmation prompt.",!0).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.").action(async(t,e)=>{try{let n=bt.parse({components:t,...e}),r=V.resolve(n.cwd);Q(r)||(a.error(`The path ${r} does not exist. Please try again.`),process.exit(1));let o=await v(r);o||(a.error(`Configuration is missing. Please run ${Ae.green("init")} to create a components.json file.`),a.error(""),process.exit(1));let i=await _(),s=n.all?i.map(l=>l.name):n.components;if(!n.components?.length&&!n.all){let{components:l}=await ee({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:i.map(g=>({title:g.name,value:g.name,selected:n.all?!0:n.components?.includes(g.name)}))});s=l}s?.length||(a.warn("No components selected. Exiting."),process.exit(0));let f=await q(i,s),c=await L(o.style,f),d=await E(o.tailwind.baseColor);if(c.length||(a.warn("Selected components not found. Exiting."),process.exit(0)),!n.yes){let{proceed:l}=await ee({type:"confirm",name:"proceed",message:"Ready to install components and dependencies. Proceed?",initial:!0});l||process.exit(0)}let m=Tt("Installing components...").start();for(let l of c){m.text=`Installing ${l.name}...`;let g=await W(o,l,n.path?V.resolve(r,n.path):void 0);if(!g)continue;if(Q(g)||await je.mkdir(g,{recursive:!0}),l.files.filter(I=>Q(V.resolve(g,I.name))).length&&!n.overwrite)if(s.includes(l.name)){m.stop();let{overwrite:I}=await ee({type:"confirm",name:"overwrite",message:`Component ${l.name} already exists. Would you like to overwrite?`,initial:!1});if(!I){a.info(`Skipped ${l.name}. To overwrite, run with the ${Ae.green("--overwrite")} flag.`);continue}m.start(`Installing ${l.name}...`)}else continue;for(let I of l.files){let k=V.resolve(g,I.name),Xe=await K({filename:I.name,raw:I.content,config:o,baseColor:d});o.tsx||(k=k.replace(/\.tsx$/,".jsx"),k=k.replace(/\.ts$/,".js")),await je.writeFile(k,Xe)}let $=await N(r);l.dependencies?.length&&await Fe($,[$==="npm"?"install":"add",...l.dependencies],{cwd:r}),l.devDependencies?.length&&await Fe($,[$==="npm"?"install":"add","-D",...l.devDependencies],{cwd:r})}m.succeed("Done.")}catch(n){b(n)}});import{existsSync as te,promises as Et}from"fs";import re from"path";import F from"chalk";import{Command as Pt}from"commander";import{diffLines as Rt}from"diff";import{z as A}from"zod";var kt=A.object({component:A.string().optional(),yes:A.boolean(),cwd:A.string(),path:A.string().optional()}),De=new Pt().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(t,e)=>{try{let n=kt.parse({component:t,...e}),r=re.resolve(n.cwd);te(r)||(a.error(`The path ${r} does not exist. Please try again.`),process.exit(1));let o=await v(r);o||(a.warn(`Configuration is missing. Please run ${F.green("init")} to create a components.json file.`),process.exit(1));let i=await _();if(!n.component){let c=o.resolvedPaths.components,d=i.filter(l=>{for(let g of l.files){let x=re.resolve(c,g);if(te(x))return!0}return!1}),m=[];for(let l of d){let g=await Ne(l,o);g.length&&m.push({name:l.name,changes:g})}m.length||(a.info("No updates found."),process.exit(0)),a.info("The following components have updates available:");for(let l of m){a.info(`- ${l.name}`);for(let g of l.changes)a.info(` - ${g.filePath}`)}a.break(),a.info(`Run ${F.green("diff <component>")} to see the changes.`),process.exit(0)}let s=i.find(c=>c.name===n.component);s||(a.error(`The component ${F.green(n.component)} does not exist.`),process.exit(1));let f=await Ne(s,o);f.length||(a.info(`No updates found for ${n.component}.`),process.exit(0));for(let c of f)a.info(`- ${c.filePath}`),await Ot(c.patch),a.info("")}catch(n){b(n)}});async function Ne(t,e){let n=await L(e.style,[t]),r=await E(e.tailwind.baseColor),o=[];for(let i of n){let s=await W(e,i);if(s)for(let f of i.files){let c=re.resolve(s,f.name);if(!te(c))continue;let d=await Et.readFile(c,"utf8"),m=await K({filename:f.name,raw:f.content,config:e,baseColor:r}),l=Rt(m,d);l.length>1&&o.push({file:f.name,filePath:c,patch:l})}}return o}async function Ot(t){t.forEach(e=>{if(e)return e.added?process.stdout.write(F.green(e.value)):e.removed?process.stdout.write(F.red(e.value)):process.stdout.write(e.value)})}import{existsSync as Lt,promises as P}from"fs";import R from"path";import ne from"path";var w={"next-app":{name:"next-app",label:"Next.js",links:{installation:"https://ui.shadcn.com/docs/installation/next",tailwind:"https://tailwindcss.com/docs/guides/nextjs"}},"next-pages":{name:"next-pages",label:"Next.js",links:{installation:"https://ui.shadcn.com/docs/installation/next",tailwind:"https://tailwindcss.com/docs/guides/nextjs"}},remix:{name:"remix",label:"Remix",links:{installation:"https://ui.shadcn.com/docs/installation/remix",tailwind:"https://tailwindcss.com/docs/guides/remix"}},vite:{name:"vite",label:"Vite",links:{installation:"https://ui.shadcn.com/docs/installation/vite",tailwind:"https://tailwindcss.com/docs/guides/vite"}},astro:{name:"astro",label:"Astro",links:{installation:"https://ui.shadcn.com/docs/installation/astro",tailwind:"https://tailwindcss.com/docs/guides/astro"}},laravel:{name:"laravel",label:"Laravel",links:{installation:"https://ui.shadcn.com/docs/installation/laravel",tailwind:"https://tailwindcss.com/docs/guides/laravel"}},gatsby:{name:"gatsby",label:"Gatsby",links:{installation:"https://ui.shadcn.com/docs/installation/gatsby",tailwind:"https://tailwindcss.com/docs/guides/gatsby"}},manual:{name:"manual",label:"Manual",links:{installation:"https://ui.shadcn.com/docs/installation/manual",tailwind:"https://tailwindcss.com/docs/installation"}}};import z from"fast-glob";import oe from"fs-extra";import{loadConfig as jt}from"tsconfig-paths";var G=["**/node_modules/**",".next","public","dist","build"];async function ie(t){let[e,n,r,o,i,s]=await Promise.all([z.glob("**/{next,vite,astro}.config.*|gatsby-config.*|composer.json",{cwd:t,deep:3,ignore:G}),oe.pathExists(ne.resolve(t,"src")),Nt(t),Ft(t),At(t),$t(t)]),f=await oe.pathExists(ne.resolve(t,`${n?"src/":""}app`)),c={framework:w.manual,isSrcDir:n,isRSC:!1,isTsx:r,tailwindConfigFile:o,tailwindCssFile:i,aliasPrefix:s};return e.length?e.find(d=>d.startsWith("next.config."))?.length?(c.framework=f?w["next-app"]:w["next-pages"],c.isRSC=f,c):e.find(d=>d.startsWith("astro.config."))?.length?(c.framework=w.astro,c):e.find(d=>d.startsWith("gatsby-config."))?.length?(c.framework=w.gatsby,c):e.find(d=>d.startsWith("composer.json"))?.length?(c.framework=w.laravel,c):(e.find(d=>d.startsWith("vite.config."))?.length&&(c.framework=f?w.remix:w.vite),c):c}async function At(t){let e=await z.glob("**/*.css",{cwd:t,deep:5,ignore:G});if(!e.length)return null;for(let n of e)if((await oe.readFile(ne.resolve(t,n),"utf8")).includes("@tailwind base"))return n;return null}async function Ft(t){let e=await z.glob("tailwind.config.*",{cwd:t,deep:3,ignore:G});return e.length?e[0]:null}async function $t(t){let e=await jt(t);if(e?.resultType==="failed"||!e?.paths)return null;for(let[n,r]of Object.entries(e.paths))if(r.includes("./*")||r.includes("./src/*")||r.includes("./app/*")||r.includes("./resources/js/*"))return n.at(0)??null;return null}async function Nt(t){return(await z.glob("tsconfig.*",{cwd:t,deep:1,ignore:G})).length>0}async function _e(t){let[e,n]=await Promise.all([v(t),ie(t)]);if(e)return e;if(!n||!n.tailwindConfigFile||!n.tailwindCssFile)return null;let r={$schema:"https://ui.shadcn.com/schema.json",rsc:n.isRSC,tsx:n.isTsx,style:"new-york",tailwind:{config:n.tailwindConfigFile,baseColor:"zinc",css:n.tailwindCssFile,cssVariables:!0,prefix:""},aliases:{utils:`${n.aliasPrefix}/lib/utils`,components:`${n.aliasPrefix}/components`}};return await T(t,r)}import We from"path";var se="1",ae="2",ce="3",le="4",Le="5";import C from"chalk";import pe from"fs-extra";import B from"ora";async function Me(t){let e={};a.info("");let n=B("Preflight checks.").start();(!pe.existsSync(t)||!pe.existsSync(We.resolve(t,"package.json")))&&(e[se]=!0),pe.existsSync(We.resolve(t,"components.json"))&&(e[ae]=!0),Object.keys(e).length>0&&(n?.fail(),a.info(""),e[se]&&a.error(`The path ${C.cyan(t)} does not exist or is empty.`),e[ae]&&a.error(`A ${C.cyan("components.json")} file already exists at ${C.cyan(t)}. | ||
To start over, remove the ${C.cyan("components.json")} file and run ${C.cyan("init")} again.`),a.info(""),process.exit(1)),n?.succeed();let r=await ie(t),o=B("Verifying framework.").start();r?.framework.name==="manual"?(e[Le]=!0,o?.fail(),a.info(""),a.error(`We could not detect a supported framework at ${C.cyan(t)}. | ||
Visit ${C.cyan(r?.framework.links.installation)} to manually configure your project. | ||
Once configured, you can use the cli to add components.`),a.info(""),process.exit(1)):o?.succeed(`Verifying framework: ${r?.framework.label}.`);let i=B("Validating Tailwind CSS.").start();!r?.tailwindConfigFile||!r?.tailwindCssFile?(e[ce]=!0,i?.fail()):i?.succeed();let s=B("Validating import alias.").start();return r?.aliasPrefix?s?.succeed():(e[le]=!0,s?.fail()),Object.keys(e).length>0&&(a.info(""),e[ce]&&a.error(`Tailwind CSS is not configured. Install Tailwind CSS then run init again. | ||
Visit ${C.cyan(r?.framework.links.tailwind)} to get started. | ||
`),e[le]&&a.error(`No import alias found in your tsconfig.json file. | ||
Visit ${C.cyan(r?.framework.links.installation)} to learn how to set an import alias.`),a.info(""),process.exit(1)),a.info(""),{errors:e,projectInfo:r}}var Ue=`import { type ClassValue, clsx } from "clsx" | ||
import { twMerge } from "tailwind-merge" | ||
// src/index.ts | ||
import { existsSync as existsSync2, promises as fs3 } from "fs"; | ||
import path3 from "path"; | ||
import { Command } from "commander"; | ||
import { execa } from "execa"; | ||
import ora from "ora"; | ||
import prompts from "prompts"; | ||
// src/utils/get-components.ts | ||
import fetch from "node-fetch"; | ||
import * as z from "zod"; | ||
var baseUrl = process.env.COMPONENTS_BASE_URL ?? "https://ui.shadcn.com"; | ||
var componentSchema = z.object({ | ||
component: z.string(), | ||
name: z.string(), | ||
dependencies: z.array(z.string()).optional(), | ||
files: z.array( | ||
z.object({ | ||
name: z.string(), | ||
dir: z.string(), | ||
content: z.string() | ||
}) | ||
) | ||
}); | ||
var componentsSchema = z.array(componentSchema); | ||
async function getAvailableComponents() { | ||
try { | ||
const response = await fetch(`${baseUrl}/api/components`); | ||
const components = await response.json(); | ||
return componentsSchema.parse(components); | ||
} catch (error) { | ||
throw new Error( | ||
`Failed to fetch components from ${baseUrl}/api/components.` | ||
); | ||
} | ||
export function cn(...inputs: ClassValue[]) { | ||
return twMerge(clsx(inputs)) | ||
} | ||
`,Ke=`import { clsx } from "clsx" | ||
import { twMerge } from "tailwind-merge" | ||
// src/utils/get-package-info.ts | ||
import path from "path"; | ||
import fs from "fs-extra"; | ||
function getPackageInfo() { | ||
const packageJsonPath = path.join("package.json"); | ||
return fs.readJSONSync(packageJsonPath); | ||
export function cn(...inputs) { | ||
return twMerge(clsx(inputs)) | ||
} | ||
// src/utils/get-package-manager.ts | ||
function getPackageManager() { | ||
const userAgent = process.env.npm_config_user_agent; | ||
if (!userAgent) { | ||
return "npm"; | ||
} | ||
if (userAgent.startsWith("yarn")) { | ||
return "yarn"; | ||
} | ||
if (userAgent.startsWith("pnpm")) { | ||
return "pnpm"; | ||
} | ||
return "npm"; | ||
} | ||
// src/utils/get-project-info.ts | ||
import { existsSync } from "fs"; | ||
import path2 from "path"; | ||
import fs2 from "fs-extra"; | ||
async function getProjectInfo() { | ||
const info = { | ||
tsconfig: null, | ||
alias: null, | ||
srcDir: false, | ||
appDir: false | ||
}; | ||
try { | ||
const tsconfig = await getTsConfig(); | ||
const paths = tsconfig?.compilerOptions?.paths; | ||
const alias = paths ? Object.keys(paths)[0].replace("*", "") : null; | ||
return { | ||
tsconfig, | ||
alias, | ||
srcDir: existsSync(path2.resolve("./src")), | ||
appDir: existsSync(path2.resolve("./app")) || existsSync(path2.resolve("./src/app")) | ||
}; | ||
} catch (error) { | ||
return info; | ||
} | ||
} | ||
async function getTsConfig() { | ||
try { | ||
const tsconfigPath = path2.join("tsconfig.json"); | ||
const tsconfig = await fs2.readJSON(tsconfigPath); | ||
if (!tsconfig) { | ||
throw new Error("tsconfig.json is missing"); | ||
} | ||
return tsconfig; | ||
} catch (error) { | ||
return null; | ||
} | ||
} | ||
// src/utils/logger.ts | ||
import chalk from "chalk"; | ||
var logger = { | ||
error(...args) { | ||
console.log(chalk.red(...args)); | ||
`,Ve=`/** @type {import('tailwindcss').Config} */ | ||
module.exports = { | ||
darkMode: ["class"], | ||
content: [ | ||
'./pages/**/*.{<%- extension %>,<%- extension %>x}', | ||
'./components/**/*.{<%- extension %>,<%- extension %>x}', | ||
'./app/**/*.{<%- extension %>,<%- extension %>x}', | ||
'./src/**/*.{<%- extension %>,<%- extension %>x}', | ||
], | ||
prefix: "<%- prefix %>", | ||
theme: { | ||
container: { | ||
center: true, | ||
padding: "2rem", | ||
screens: { | ||
"2xl": "1400px", | ||
}, | ||
}, | ||
extend: { | ||
keyframes: { | ||
"accordion-down": { | ||
from: { height: "0" }, | ||
to: { height: "var(--radix-accordion-content-height)" }, | ||
}, | ||
"accordion-up": { | ||
from: { height: "var(--radix-accordion-content-height)" }, | ||
to: { height: "0" }, | ||
}, | ||
}, | ||
animation: { | ||
"accordion-down": "accordion-down 0.2s ease-out", | ||
"accordion-up": "accordion-up 0.2s ease-out", | ||
}, | ||
}, | ||
}, | ||
warn(...args) { | ||
console.log(chalk.yellow(...args)); | ||
plugins: [require("tailwindcss-animate")], | ||
}`,ze=`/** @type {import('tailwindcss').Config} */ | ||
module.exports = { | ||
darkMode: ["class"], | ||
content: [ | ||
'./pages/**/*.{<%- extension %>,<%- extension %>x}', | ||
'./components/**/*.{<%- extension %>,<%- extension %>x}', | ||
'./app/**/*.{<%- extension %>,<%- extension %>x}', | ||
'./src/**/*.{<%- extension %>,<%- extension %>x}', | ||
], | ||
prefix: "<%- prefix %>", | ||
theme: { | ||
container: { | ||
center: true, | ||
padding: "2rem", | ||
screens: { | ||
"2xl": "1400px", | ||
}, | ||
}, | ||
extend: { | ||
colors: { | ||
border: "hsl(var(--border))", | ||
input: "hsl(var(--input))", | ||
ring: "hsl(var(--ring))", | ||
background: "hsl(var(--background))", | ||
foreground: "hsl(var(--foreground))", | ||
primary: { | ||
DEFAULT: "hsl(var(--primary))", | ||
foreground: "hsl(var(--primary-foreground))", | ||
}, | ||
secondary: { | ||
DEFAULT: "hsl(var(--secondary))", | ||
foreground: "hsl(var(--secondary-foreground))", | ||
}, | ||
destructive: { | ||
DEFAULT: "hsl(var(--destructive))", | ||
foreground: "hsl(var(--destructive-foreground))", | ||
}, | ||
muted: { | ||
DEFAULT: "hsl(var(--muted))", | ||
foreground: "hsl(var(--muted-foreground))", | ||
}, | ||
accent: { | ||
DEFAULT: "hsl(var(--accent))", | ||
foreground: "hsl(var(--accent-foreground))", | ||
}, | ||
popover: { | ||
DEFAULT: "hsl(var(--popover))", | ||
foreground: "hsl(var(--popover-foreground))", | ||
}, | ||
card: { | ||
DEFAULT: "hsl(var(--card))", | ||
foreground: "hsl(var(--card-foreground))", | ||
}, | ||
}, | ||
borderRadius: { | ||
lg: "var(--radius)", | ||
md: "calc(var(--radius) - 2px)", | ||
sm: "calc(var(--radius) - 4px)", | ||
}, | ||
keyframes: { | ||
"accordion-down": { | ||
from: { height: "0" }, | ||
to: { height: "var(--radix-accordion-content-height)" }, | ||
}, | ||
"accordion-up": { | ||
from: { height: "var(--radix-accordion-content-height)" }, | ||
to: { height: "0" }, | ||
}, | ||
}, | ||
animation: { | ||
"accordion-down": "accordion-down 0.2s ease-out", | ||
"accordion-up": "accordion-up 0.2s ease-out", | ||
}, | ||
}, | ||
}, | ||
info(...args) { | ||
console.log(chalk.cyan(...args)); | ||
plugins: [require("tailwindcss-animate")], | ||
}`,Ge=`import type { Config } from "tailwindcss" | ||
const config = { | ||
darkMode: ["class"], | ||
content: [ | ||
'./pages/**/*.{<%- extension %>,<%- extension %>x}', | ||
'./components/**/*.{<%- extension %>,<%- extension %>x}', | ||
'./app/**/*.{<%- extension %>,<%- extension %>x}', | ||
'./src/**/*.{<%- extension %>,<%- extension %>x}', | ||
], | ||
prefix: "<%- prefix %>", | ||
theme: { | ||
container: { | ||
center: true, | ||
padding: "2rem", | ||
screens: { | ||
"2xl": "1400px", | ||
}, | ||
}, | ||
extend: { | ||
keyframes: { | ||
"accordion-down": { | ||
from: { height: "0" }, | ||
to: { height: "var(--radix-accordion-content-height)" }, | ||
}, | ||
"accordion-up": { | ||
from: { height: "var(--radix-accordion-content-height)" }, | ||
to: { height: "0" }, | ||
}, | ||
}, | ||
animation: { | ||
"accordion-down": "accordion-down 0.2s ease-out", | ||
"accordion-up": "accordion-up 0.2s ease-out", | ||
}, | ||
}, | ||
}, | ||
success(...args) { | ||
console.log(chalk.green(...args)); | ||
} | ||
}; | ||
plugins: [require("tailwindcss-animate")], | ||
} satisfies Config | ||
// src/utils/templates.ts | ||
var STYLES = `@tailwind base; | ||
@tailwind components; | ||
@tailwind utilities; | ||
@layer base { | ||
:root { | ||
--background: 0 0% 100%; | ||
--foreground: 222.2 47.4% 11.2%; | ||
--muted: 210 40% 96.1%; | ||
--muted-foreground: 215.4 16.3% 46.9%; | ||
--popover: 0 0% 100%; | ||
--popover-foreground: 222.2 47.4% 11.2%; | ||
--card: 0 0% 100%; | ||
--card-foreground: 222.2 47.4% 11.2%; | ||
--border: 214.3 31.8% 91.4%; | ||
--input: 214.3 31.8% 91.4%; | ||
--primary: 222.2 47.4% 11.2%; | ||
--primary-foreground: 210 40% 98%; | ||
--secondary: 210 40% 96.1%; | ||
--secondary-foreground: 222.2 47.4% 11.2%; | ||
--accent: 210 40% 96.1%; | ||
--accent-foreground: 222.2 47.4% 11.2%; | ||
--destructive: 0 100% 50%; | ||
--destructive-foreground: 210 40% 98%; | ||
--ring: 215 20.2% 65.1%; | ||
--radius: 0.5rem; | ||
} | ||
.dark { | ||
--background: 224 71% 4%; | ||
--foreground: 213 31% 91%; | ||
--muted: 223 47% 11%; | ||
--muted-foreground: 215.4 16.3% 56.9%; | ||
--popover: 224 71% 4%; | ||
--popover-foreground: 215 20.2% 65.1%; | ||
--card: 0 0% 100%; | ||
--card-foreground: 222.2 47.4% 11.2%; | ||
--border: 216 34% 17%; | ||
--input: 216 34% 17%; | ||
--primary: 210 40% 98%; | ||
--primary-foreground: 222.2 47.4% 1.2%; | ||
--secondary: 222.2 47.4% 11.2%; | ||
--secondary-foreground: 210 40% 98%; | ||
--accent: 216 34% 17%; | ||
--accent-foreground: 210 40% 98%; | ||
--destructive: 0 63% 31%; | ||
--destructive-foreground: 210 40% 98%; | ||
--ring: 216 34% 17%; | ||
--radius: 0.5rem; | ||
} | ||
} | ||
@layer base { | ||
* { | ||
@apply border-border; | ||
} | ||
body { | ||
@apply bg-background text-foreground; | ||
font-feature-settings: "rlig" 1, "calt" 1; | ||
} | ||
}`; | ||
var UTILS = `import { ClassValue, clsx } from "clsx" | ||
import { twMerge } from "tailwind-merge" | ||
export function cn(...inputs: ClassValue[]) { | ||
return twMerge(clsx(inputs)) | ||
} | ||
`; | ||
var TAILWIND_CONFIG = `/** @type {import('tailwindcss').Config} */ | ||
module.exports = { | ||
export default config`,Be=`import type { Config } from "tailwindcss" | ||
const config = { | ||
darkMode: ["class"], | ||
content: [ | ||
'./pages/**/*.{ts,tsx}', | ||
'./components/**/*.{ts,tsx}', | ||
'./app/**/*.{ts,tsx}', | ||
'./pages/**/*.{<%- extension %>,<%- extension %>x}', | ||
'./components/**/*.{<%- extension %>,<%- extension %>x}', | ||
'./app/**/*.{<%- extension %>,<%- extension %>x}', | ||
'./src/**/*.{<%- extension %>,<%- extension %>x}', | ||
], | ||
prefix: "<%- prefix %>", | ||
theme: { | ||
@@ -266,3 +234,3 @@ container: { | ||
"accordion-down": { | ||
from: { height: 0 }, | ||
from: { height: "0" }, | ||
to: { height: "var(--radix-accordion-content-height)" }, | ||
@@ -272,3 +240,3 @@ }, | ||
from: { height: "var(--radix-accordion-content-height)" }, | ||
to: { height: 0 }, | ||
to: { height: "0" }, | ||
}, | ||
@@ -283,155 +251,5 @@ }, | ||
plugins: [require("tailwindcss-animate")], | ||
}`; | ||
} satisfies Config | ||
// src/index.ts | ||
process.on("SIGINT", () => process.exit(0)); | ||
process.on("SIGTERM", () => process.exit(0)); | ||
var PROJECT_DEPENDENCIES = [ | ||
"tailwindcss-animate", | ||
"class-variance-authority", | ||
"clsx", | ||
"tailwind-merge", | ||
"lucide-react" | ||
]; | ||
async function main() { | ||
const packageInfo = await getPackageInfo(); | ||
const projectInfo = await getProjectInfo(); | ||
const packageManager = getPackageManager(); | ||
const program = new Command().name("shadcn-ui").description("Add shadcn-ui components to your project").version( | ||
packageInfo.version || "1.0.0", | ||
"-v, --version", | ||
"display the version number" | ||
); | ||
program.command("init").description("Configure your Next.js project.").option("-y, --yes", "Skip confirmation prompt.").action(async (options) => { | ||
logger.warn( | ||
"This command assumes a Next.js project with TypeScript and Tailwind CSS." | ||
); | ||
logger.warn( | ||
"If you don't have these, follow the manual steps at https://ui.shadcn.com/docs/installation." | ||
); | ||
logger.warn(""); | ||
if (!options.yes) { | ||
const { proceed } = await prompts({ | ||
type: "confirm", | ||
name: "proceed", | ||
message: "Running this command will install dependencies and overwrite your existing tailwind.config.js. Proceed?", | ||
initial: true | ||
}); | ||
if (!proceed) { | ||
process.exit(0); | ||
} | ||
} | ||
const dependenciesSpinner = ora(`Installing dependencies...`).start(); | ||
await execa(packageManager, [ | ||
packageManager === "npm" ? "install" : "add", | ||
...PROJECT_DEPENDENCIES | ||
]); | ||
dependenciesSpinner.succeed(); | ||
if (!projectInfo?.appDir) { | ||
const stylesDir = projectInfo?.srcDir ? "./src/styles" : "./styles"; | ||
if (!existsSync2(path3.resolve(stylesDir))) { | ||
await fs3.mkdir(path3.resolve(stylesDir), { recursive: true }); | ||
} | ||
} | ||
let stylesDestination = projectInfo?.srcDir ? "./src/styles/globals.css" : "./styles/globals.css"; | ||
if (projectInfo?.appDir) { | ||
stylesDestination = projectInfo?.srcDir ? "./src/app/globals.css" : "./app/globals.css"; | ||
} | ||
const stylesSpinner = ora(`Adding styles with CSS variables...`).start(); | ||
await fs3.writeFile(stylesDestination, STYLES, "utf8"); | ||
stylesSpinner.succeed(); | ||
const libDir = projectInfo?.srcDir ? "./src/lib" : "./lib"; | ||
if (!existsSync2(path3.resolve(libDir))) { | ||
await fs3.mkdir(path3.resolve(libDir), { recursive: true }); | ||
} | ||
const utilsDestination = projectInfo?.srcDir ? "./src/lib/utils.ts" : "./lib/utils.ts"; | ||
const utilsSpinner = ora(`Adding utils...`).start(); | ||
await fs3.writeFile(utilsDestination, UTILS, "utf8"); | ||
utilsSpinner.succeed(); | ||
const tailwindDestination = "./tailwind.config.js"; | ||
const tailwindSpinner = ora(`Updating tailwind.config.js...`).start(); | ||
await fs3.writeFile(tailwindDestination, TAILWIND_CONFIG, "utf8"); | ||
tailwindSpinner.succeed(); | ||
}); | ||
program.command("add").description("add components to your project").argument("[components...]", "name of components").action(async (components) => { | ||
logger.warn( | ||
"Running the following command will overwrite existing files." | ||
); | ||
logger.warn( | ||
"Make sure you have committed your changes before proceeding." | ||
); | ||
logger.warn(""); | ||
const availableComponents = await getAvailableComponents(); | ||
if (!availableComponents?.length) { | ||
logger.error( | ||
"An error occurred while fetching components. Please try again." | ||
); | ||
process.exit(0); | ||
} | ||
let selectedComponents = availableComponents.filter( | ||
(component) => components.includes(component.component) | ||
); | ||
if (!selectedComponents?.length) { | ||
selectedComponents = await promptForComponents(availableComponents); | ||
} | ||
const dir = await promptForDestinationDir(); | ||
if (!selectedComponents?.length) { | ||
logger.warn("No components selected. Nothing to install."); | ||
process.exit(0); | ||
} | ||
const destinationDir = path3.resolve(dir); | ||
if (!existsSync2(destinationDir)) { | ||
const spinner = ora(`Creating ${dir}...`).start(); | ||
await fs3.mkdir(destinationDir, { recursive: true }); | ||
spinner.succeed(); | ||
} | ||
logger.success( | ||
`Installing ${selectedComponents.length} component(s) and dependencies...` | ||
); | ||
for (const component of selectedComponents) { | ||
const componentSpinner = ora(`${component.name}...`).start(); | ||
for (const file of component.files) { | ||
if (projectInfo?.alias) { | ||
file.content = file.content.replace(/@\//g, projectInfo.alias); | ||
} | ||
const filePath = path3.resolve(dir, file.name); | ||
await fs3.writeFile(filePath, file.content); | ||
} | ||
if (component.dependencies?.length) { | ||
await execa(packageManager, [ | ||
packageManager === "npm" ? "install" : "add", | ||
...component.dependencies | ||
]); | ||
} | ||
componentSpinner.succeed(component.name); | ||
} | ||
}); | ||
program.parse(); | ||
} | ||
async function promptForComponents(components) { | ||
const { components: selectedComponents } = await prompts({ | ||
type: "autocompleteMultiselect", | ||
name: "components", | ||
message: "Which component(s) would you like to add?", | ||
hint: "Space to select. A to select all. I to invert selection.", | ||
instructions: false, | ||
choices: components.map((component) => ({ | ||
title: component.name, | ||
value: component | ||
})) | ||
}); | ||
return selectedComponents; | ||
} | ||
async function promptForDestinationDir() { | ||
const { dir } = await prompts([ | ||
{ | ||
type: "text", | ||
name: "dir", | ||
message: "Where would you like to install the component(s)?", | ||
initial: "./components/ui" | ||
} | ||
]); | ||
return dir; | ||
} | ||
main(); | ||
export default config`;import fe from"chalk";import{Command as Wt}from"commander";import{execa as Mt}from"execa";import Ut from"lodash.template";import H from"ora";import me from"prompts";import{z as J}from"zod";var Kt=["tailwindcss-animate","class-variance-authority","clsx","tailwind-merge"],Vt=J.object({cwd:J.string(),yes:J.boolean(),defaults:J.boolean()}),Je=new Wt().name("init").description("initialize your project and install dependencies").option("-y, --yes","skip confirmation prompt.",!1).option("-d, --defaults,","use default configuration.",!1).option("-c, --cwd <cwd>","the working directory. defaults to the current directory.",process.cwd()).action(async t=>{try{let e=Vt.parse(t),n=R.resolve(e.cwd),{errors:r,projectInfo:o}=await Me(n);Object.keys(r).length>0&&(a.error("Something went wrong during the preflight check. Please check the output above for more details."),a.error(""),process.exit(1));let i=await _e(n),s=i?await Gt(n,i,t.defaults):await zt(n,await v(n),e.yes);await Bt(n,s),a.info(""),a.info(`${fe.green("Success!")} Project initialization completed. You may now add components.`),a.info("")}catch(e){b(e)}});async function zt(t,e=null,n=!1){let r=m=>fe.cyan(m),[o,i]=await Promise.all([X(),Y()]),s=await me([{type:"toggle",name:"typescript",message:`Would you like to use ${r("TypeScript")} (recommended)?`,initial:e?.tsx??!0,active:"yes",inactive:"no"},{type:"select",name:"style",message:`Which ${r("style")} would you like to use?`,choices:o.map(m=>({title:m.label,value:m.name}))},{type:"select",name:"tailwindBaseColor",message:`Which color would you like to use as the ${r("base color")}?`,choices:i.map(m=>({title:m.label,value:m.name}))},{type:"text",name:"tailwindCss",message:`Where is your ${r("global CSS")} file?`,initial:e?.tailwind.css??he},{type:"toggle",name:"tailwindCssVariables",message:`Would you like to use ${r("CSS variables")} for theming?`,initial:e?.tailwind.cssVariables??!0,active:"yes",inactive:"no"},{type:"text",name:"tailwindPrefix",message:`Are you using a custom ${r("tailwind prefix eg. tw-")}? (Leave blank if not)`,initial:""},{type:"text",name:"tailwindConfig",message:`Where is your ${r("tailwind.config.js")} located?`,initial:e?.tailwind.config??xe},{type:"text",name:"components",message:`Configure the import alias for ${r("components")}:`,initial:e?.aliases.components??ge},{type:"text",name:"utils",message:`Configure the import alias for ${r("utils")}:`,initial:e?.aliases.utils??ue},{type:"toggle",name:"rsc",message:`Are you using ${r("React Server Components")}?`,initial:e?.rsc??!0,active:"yes",inactive:"no"}]),f=j.parse({$schema:"https://ui.shadcn.com/schema.json",style:s.style,tailwind:{config:s.tailwindConfig,css:s.tailwindCss,baseColor:s.tailwindBaseColor,cssVariables:s.tailwindCssVariables,prefix:s.tailwindPrefix},rsc:s.rsc,tsx:s.typescript,aliases:{utils:s.utils,components:s.components}});if(!n){let{proceed:m}=await me({type:"confirm",name:"proceed",message:`Write configuration to ${r("components.json")}. Proceed?`,initial:!0});m||process.exit(0)}a.info("");let c=H("Writing components.json...").start(),d=R.resolve(t,"components.json");return await P.writeFile(d,JSON.stringify(f,null,2),"utf8"),c.succeed(),await T(t,f)}async function Gt(t,e,n=!1){let r=m=>fe.cyan(m),o=e.style,i=e.tailwind.baseColor,s=e.tailwind.cssVariables;if(!n){let[m,l]=await Promise.all([X(),Y()]),g=await me([{type:"select",name:"style",message:`Which ${r("style")} would you like to use?`,choices:m.map(x=>({title:x.label,value:x.name})),initial:m.findIndex(x=>x.name===o)},{type:"select",name:"tailwindBaseColor",message:`Which color would you like to use as the ${r("base color")}?`,choices:l.map(x=>({title:x.label,value:x.name}))},{type:"toggle",name:"tailwindCssVariables",message:`Would you like to use ${r("CSS variables")} for theming?`,initial:e?.tailwind.cssVariables,active:"yes",inactive:"no"}]);o=g.style,i=g.tailwindBaseColor,s=g.tailwindCssVariables}let f=j.parse({$schema:e?.$schema,style:o,tailwind:{...e?.tailwind,baseColor:i,cssVariables:s},rsc:e?.rsc,tsx:e?.tsx,aliases:e?.aliases});a.info("");let c=H("Writing components.json...").start(),d=R.resolve(t,"components.json");return await P.writeFile(d,JSON.stringify(f,null,2),"utf8"),c.succeed(),await T(t,f)}async function Bt(t,e){let n=H("Initializing project...")?.start();for(let[m,l]of Object.entries(e.resolvedPaths)){let g=R.extname(l)?R.dirname(l):l;m==="utils"&&l.endsWith("/utils")&&(g=g.replace(/\/utils$/,"")),Lt(g)||await P.mkdir(g,{recursive:!0})}let r=e.tsx?"ts":"js",o=R.extname(e.resolvedPaths.tailwindConfig),i;o===".ts"?i=e.tailwind.cssVariables?Be:Ge:i=e.tailwind.cssVariables?ze:Ve,await P.writeFile(e.resolvedPaths.tailwindConfig,Ut(i)({extension:r,prefix:e.tailwind.prefix}),"utf8");let s=await E(e.tailwind.baseColor);s&&await P.writeFile(e.resolvedPaths.tailwindCss,e.tailwind.cssVariables?e.tailwind.prefix?ke(s.cssVarsTemplate,e.tailwind.prefix):s.cssVarsTemplate:s.inlineColorsTemplate,"utf8"),await P.writeFile(`${e.resolvedPaths.utils}.${r}`,r==="ts"?Ue:Ke,"utf8"),n?.succeed();let f=H("Installing dependencies...")?.start(),c=await N(t),d=[...Kt,e.style==="new-york"?"@radix-ui/react-icons":"lucide-react"];await Mt(c,[c==="npm"?"install":"add",...d],{cwd:t}),f?.succeed()}import{Command as Xt}from"commander";import Jt from"path";import Ht from"fs-extra";function He(){let t=Jt.join("package.json");return Ht.readJSONSync(t)}process.on("SIGINT",()=>process.exit(0));process.on("SIGTERM",()=>process.exit(0));async function Yt(){let t=await He(),e=new Xt().name("shadcn-ui").description("add components and dependencies to your project").version(t.version||"1.0.0","-v, --version","display the version number");e.addCommand(Je).addCommand($e).addCommand(De),e.parse()}Yt(); | ||
//# sourceMappingURL=index.js.map |
{ | ||
"name": "shadcn-ui", | ||
"version": "0.0.0-beta.386a8ee", | ||
"version": "0.0.0-beta.45bf824", | ||
"description": "Add components to your apps.", | ||
@@ -32,18 +32,33 @@ "publishConfig": { | ||
"dependencies": { | ||
"@antfu/ni": "^0.21.4", | ||
"@babel/core": "^7.22.1", | ||
"@babel/parser": "^7.22.6", | ||
"@babel/plugin-transform-typescript": "^7.22.5", | ||
"chalk": "5.2.0", | ||
"commander": "^10.0.0", | ||
"cosmiconfig": "^8.1.3", | ||
"diff": "^5.1.0", | ||
"execa": "^7.0.0", | ||
"fast-glob": "^3.3.2", | ||
"fs-extra": "^11.1.0", | ||
"https-proxy-agent": "^6.2.0", | ||
"lodash.template": "^4.5.0", | ||
"node-fetch": "^3.3.0", | ||
"ora": "^6.1.2", | ||
"prompts": "^2.4.2", | ||
"recast": "^0.23.2", | ||
"ts-morph": "^18.0.0", | ||
"tsconfig-paths": "^4.2.0", | ||
"zod": "^3.20.2" | ||
}, | ||
"devDependencies": { | ||
"@types/babel__core": "^7.20.1", | ||
"@types/diff": "^5.0.3", | ||
"@types/fs-extra": "^11.0.1", | ||
"@types/lodash.template": "^4.5.1", | ||
"@types/prompts": "^2.4.2", | ||
"rimraf": "^4.1.3", | ||
"tsup": "^6.6.3", | ||
"type-fest": "^3.6.1", | ||
"typescript": "^4.5.5" | ||
"type-fest": "^3.8.0", | ||
"typescript": "^4.9.3" | ||
}, | ||
@@ -55,3 +70,3 @@ "scripts": { | ||
"clean": "rimraf dist && rimraf components", | ||
"start:dev": "cross-env COMPONENTS_BASE_URL=http://localhost:3001 node dist/index.js", | ||
"start:dev": "cross-env COMPONENTS_REGISTRY_URL=http://localhost:3003 node dist/index.js", | ||
"start": "node dist/index.js", | ||
@@ -63,4 +78,5 @@ "format:write": "prettier --write \"**/*.{ts,tsx,mdx}\" --cache", | ||
"pub:next": "pnpm build && pnpm publish --no-git-checks --access public --tag next", | ||
"pub:release": "pnpm build && pnpm publish --access public" | ||
"pub:release": "pnpm build && pnpm publish --access public", | ||
"test": "vitest run" | ||
} | ||
} |
@@ -39,3 +39,3 @@ # shadcn-ui | ||
Visit http://ui.shadcn.com/docs to view the documentation. | ||
Visit https://ui.shadcn.com/docs/cli to view the documentation. | ||
@@ -42,0 +42,0 @@ ## License |
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
Network access
Supply chain riskThis module accesses the network.
Found 1 instance in 1 package
Environment variable access
Supply chain riskPackage accesses environment variables, which may be a sign of credential stuffing or data theft.
Found 2 instances in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
Network access
Supply chain riskThis module accesses the network.
Found 1 instance in 1 package
Environment variable access
Supply chain riskPackage accesses environment variables, which may be a sign of credential stuffing or data theft.
Found 2 instances in 1 package
145082
20
9
342
10
+ Added@antfu/ni@^0.21.4
+ Added@babel/core@^7.22.1
+ Added@babel/parser@^7.22.6
+ Addedcosmiconfig@^8.1.3
+ Addeddiff@^5.1.0
+ Addedfast-glob@^3.3.2
+ Addedhttps-proxy-agent@^6.2.0
+ Addedlodash.template@^4.5.0
+ Addedrecast@^0.23.2
+ Addedts-morph@^18.0.0
+ Addedtsconfig-paths@^4.2.0
+ Added@ampproject/remapping@2.3.0(transitive)
+ Added@antfu/ni@0.21.12(transitive)
+ Added@babel/code-frame@7.26.2(transitive)
+ Added@babel/compat-data@7.26.3(transitive)
+ Added@babel/core@7.26.0(transitive)
+ Added@babel/generator@7.26.3(transitive)
+ Added@babel/helper-annotate-as-pure@7.25.9(transitive)
+ Added@babel/helper-compilation-targets@7.25.9(transitive)
+ Added@babel/helper-create-class-features-plugin@7.25.9(transitive)
+ Added@babel/helper-member-expression-to-functions@7.25.9(transitive)
+ Added@babel/helper-module-imports@7.25.9(transitive)
+ Added@babel/helper-module-transforms@7.26.0(transitive)
+ Added@babel/helper-optimise-call-expression@7.25.9(transitive)
+ Added@babel/helper-plugin-utils@7.25.9(transitive)
+ Added@babel/helper-replace-supers@7.25.9(transitive)
+ Added@babel/helper-skip-transparent-expression-wrappers@7.25.9(transitive)
+ Added@babel/helper-string-parser@7.25.9(transitive)
+ Added@babel/helper-validator-identifier@7.25.9(transitive)
+ Added@babel/helper-validator-option@7.25.9(transitive)
+ Added@babel/helpers@7.26.0(transitive)
+ Added@babel/parser@7.26.3(transitive)
+ Added@babel/plugin-syntax-typescript@7.25.9(transitive)
+ Added@babel/plugin-transform-typescript@7.26.3(transitive)
+ Added@babel/template@7.25.9(transitive)
+ Added@babel/traverse@7.26.4(transitive)
+ Added@babel/types@7.26.3(transitive)
+ Added@jridgewell/gen-mapping@0.3.8(transitive)
+ Added@jridgewell/resolve-uri@3.1.2(transitive)
+ Added@jridgewell/set-array@1.2.1(transitive)
+ Added@jridgewell/sourcemap-codec@1.5.0(transitive)
+ Added@jridgewell/trace-mapping@0.3.25(transitive)
+ Added@nodelib/fs.scandir@2.1.5(transitive)
+ Added@nodelib/fs.stat@2.0.5(transitive)
+ Added@nodelib/fs.walk@1.2.8(transitive)
+ Added@ts-morph/common@0.19.0(transitive)
+ Addedagent-base@7.1.3(transitive)
+ Addedargparse@2.0.1(transitive)
+ Addedast-types@0.16.1(transitive)
+ Addedbalanced-match@1.0.2(transitive)
+ Addedbrace-expansion@2.0.1(transitive)
+ Addedbraces@3.0.3(transitive)
+ Addedbrowserslist@4.24.2(transitive)
+ Addedcallsites@3.1.0(transitive)
+ Addedcaniuse-lite@1.0.30001688(transitive)
+ Addedcode-block-writer@12.0.0(transitive)
+ Addedconvert-source-map@2.0.0(transitive)
+ Addedcosmiconfig@8.3.6(transitive)
+ Addeddebug@4.4.0(transitive)
+ Addeddiff@5.2.0(transitive)
+ Addedelectron-to-chromium@1.5.73(transitive)
+ Addederror-ex@1.3.2(transitive)
+ Addedescalade@3.2.0(transitive)
+ Addedesprima@4.0.1(transitive)
+ Addedfast-glob@3.3.2(transitive)
+ Addedfastq@1.17.1(transitive)
+ Addedfill-range@7.1.1(transitive)
+ Addedgensync@1.0.0-beta.2(transitive)
+ Addedglob-parent@5.1.2(transitive)
+ Addedglobals@11.12.0(transitive)
+ Addedhttps-proxy-agent@6.2.1(transitive)
+ Addedimport-fresh@3.3.0(transitive)
+ Addedis-arrayish@0.2.1(transitive)
+ Addedis-extglob@2.1.1(transitive)
+ Addedis-glob@4.0.3(transitive)
+ Addedis-number@7.0.0(transitive)
+ Addedjs-tokens@4.0.0(transitive)
+ Addedjs-yaml@4.1.0(transitive)
+ Addedjsesc@3.1.0(transitive)
+ Addedjson-parse-even-better-errors@2.3.1(transitive)
+ Addedjson5@2.2.3(transitive)
+ Addedlines-and-columns@1.2.4(transitive)
+ Addedlodash._reinterpolate@3.0.0(transitive)
+ Addedlodash.template@4.5.0(transitive)
+ Addedlodash.templatesettings@4.2.0(transitive)
+ Addedlru-cache@5.1.1(transitive)
+ Addedmerge2@1.4.1(transitive)
+ Addedmicromatch@4.0.8(transitive)
+ Addedminimatch@7.4.6(transitive)
+ Addedminimist@1.2.8(transitive)
+ Addedmkdirp@2.1.6(transitive)
+ Addedms@2.1.3(transitive)
+ Addednode-releases@2.0.19(transitive)
+ Addedparent-module@1.0.1(transitive)
+ Addedparse-json@5.2.0(transitive)
+ Addedpath-browserify@1.0.1(transitive)
+ Addedpath-type@4.0.0(transitive)
+ Addedpicocolors@1.1.1(transitive)
+ Addedpicomatch@2.3.1(transitive)
+ Addedqueue-microtask@1.2.3(transitive)
+ Addedrecast@0.23.9(transitive)
+ Addedresolve-from@4.0.0(transitive)
+ Addedreusify@1.0.4(transitive)
+ Addedrun-parallel@1.2.0(transitive)
+ Addedsemver@6.3.1(transitive)
+ Addedsource-map@0.6.1(transitive)
+ Addedstrip-bom@3.0.0(transitive)
+ Addedtiny-invariant@1.3.3(transitive)
+ Addedto-regex-range@5.0.1(transitive)
+ Addedts-morph@18.0.0(transitive)
+ Addedtsconfig-paths@4.2.0(transitive)
+ Addedtslib@2.8.1(transitive)
+ Addedupdate-browserslist-db@1.1.1(transitive)
+ Addedyallist@3.1.1(transitive)