UNPKG

radianui

Version:

add components to your project

406 lines (342 loc) 26.9 kB
#!/usr/bin/env node var b={name:"radianui",version:"0.0.0",main:"index.js",type:"module",publishConfig:{access:"public"},exports:"./dist/index.js",bin:{radianos:"dist/index.js"},scripts:{dev:"tsup --watch",build:"tsup"},keywords:["radian","radianos","radianos cli","components","ui","tailwind","radix-ui"],author:"Radian OS",license:"ISC",description:"add components to your project",dependencies:{"@clack/prompts":"^0.9.1",chalk:"^5.3.0",commander:"^12.1.0",cosmiconfig:"^9.0.0",execa:"^9.5.0","fast-glob":"^3.3.2","fs-extra":"^11.2.0","gradient-string":"^3.0.0","node-fetch":"^3.3.2",ora:"^8.1.0","package-manager-detector":"^1.3.0",prompts:"^2.4.2","ts-morph":"^25.0.1","tsconfig-paths":"^4.2.0",tsup:"^8.3.5","type-fest":"^4.26.1",zod:"^3.23.8"},devDependencies:{"@trivago/prettier-plugin-sort-imports":"^5.2.2","@types/fs-extra":"^11.0.4","@types/node":"^22.7.9","@types/prompts":"^2.4.9",prettier:"^3.4.2","prettier-plugin-organize-imports":"^4.1.0",typescript:"^5.6.3"}};import{Command as De}from"commander";import{Command as be}from"commander";import{execa as xe}from"execa";import F from"fs-extra";import R from"path";import J from"prompts";import{z as y}from"zod";import T from"fs-extra";import M from"path";import c from"chalk";var s={error:c.redBright,success:c.greenBright,warning:c.yellowBright,info:c.blueBright,dark:c.blackBright,light:c.whiteBright,deprecated:c.gray,magenta:c.magentaBright,cyan:c.cyanBright,bold:c.bold,italic:c.italic,underline:c.underline,strikethrough:c.strikethrough},We={error:c.bgRedBright,success:c.bgGreenBright,warning:c.bgYellowBright,info:c.bgBlueBright,dark:c.bgBlackBright,light:c.bgWhiteBright,magenta:c.bgMagentaBright,cyan:c.bgCyanBright};import{cosmiconfig as ae}from"cosmiconfig";import{z as P}from"zod";var le=ae("components"),ce=P.object({useSrcDir:P.boolean(),alias:P.string().optional()});async function B(e=process.cwd()){try{let t=await le.search(e);return t?ce.parse(t):null}catch(t){throw new Error(`Error loading components.json configuration: ${t instanceof Error?t.message:"Unknown error"}`)}}var W=async e=>{if(!T.existsSync(e.cwd)||!T.existsSync(M.resolve(e.cwd,"package.json")))return{config:null};if(!T.existsSync(M.resolve(e.cwd,"components.json")))throw new Error(`The components.json file is missing. Run the following command to set up your project: ${s.info("npx radianos init")}`);try{return await B(e.cwd)}catch{throw new Error(`An invalid ${s.info("components.json")} file was found at ${s.info(e.cwd)}. Before you can add components, you must create a valid ${s.info("components.json")} file by running the ${s.info("init")} command.`)}};import _ from"fs-extra";import{detect as pe,getUserAgent as de}from"package-manager-detector";import V from"path";var w=async(e,{withFallback:t}={withFallback:!1})=>{let r=V.resolve(e);if(!_.existsSync(r))throw new Error(`The path "${r}" does not exist.`);if(!_.existsSync(V.join(r,"package.json"))&&t)return L();let n=await pe({cwd:r});switch(n.name){case"npm":case"pnpm":case"bun":case"yarn":return n.name;default:return t?L():"npm"}};function L(){let e=de()||"";return e.startsWith("pnpm")?"pnpm":e.startsWith("yarn")?"yarn":e.startsWith("bun")?"bun":"npm"}var v=async e=>{let t=await w(e);if(!t)return null;switch(t){case"npm":return"install";case"pnpm":return"install";case"bun":return"add";case"yarn":return"add";default:return null}};import j from"fast-glob";import O from"fs-extra";import $ from"path";import{loadConfig as me}from"tsconfig-paths";var x={manual:{name:"manual",label:"Manual",link:{installation:"https://radianos.com/documentation/installation",tailwind:"https://tailwindcss.com/docs/guides/manual"}},"next-app":{name:"next-app",label:"Next.js",link:{installation:"https://radianos.com/documentation/installation",tailwind:"https://tailwindcss.com/docs/guides/nextjs"}},"next-pages":{name:"next-pages",label:"Next.js",link:{installation:"https://radianos.com/documentation/installation",tailwind:"https://tailwindcss.com/docs/guides/nextjs"}},vite:{name:"vite",label:"Vite",link:{installation:"https://radianos.com/documentation/installation",tailwind:"https://tailwindcss.com/docs/guides/vite"}}};var a={success:(...e)=>{console.log(s.success(e.join(" ")))},info:(...e)=>{console.log(s.info(e.join(" ")))},warn:(...e)=>{console.log(s.warning(e.join(" ")))},error:(...e)=>{console.log(s.error(e.join(" ")))},log:(...e)=>{console.log(s.dark(e.join("")))},break:()=>{console.log("")}};var S=["**/node_modules/**","dist","build",".next","public"];var C=async e=>{let[t,r,o,n,i,p]=await Promise.all([fe(e),O.pathExists($.resolve(e,"src")),ue(e),ge(e),he(e),ye(e)]),l=await O.pathExists($.resolve(e,`${r?"src/":""}app`)),d={framework:x.manual,hasSrcDir:r,isRSC:!1,isTsx:o,tailwindConfigFile:n,tailwindCssFile:i,aliasPrefix:p};return t?.startsWith("next.config.")?(d.framework=l?x["next-app"]:x["next-pages"],d.isRSC=l,d):(t?.startsWith("vite.config.")&&(d.framework=x.vite),d)},fe=async e=>{let t=await j.glob("**/{next,vite}.config.*",{cwd:e,deep:3,ignore:S});return t.length?t[0]:null},ge=async e=>{let t=await j.glob("tailwind.config.*",{cwd:e,deep:3,ignore:S});return t.length?t[0]:null},he=async e=>{let t=await j.glob(["**/*.css","**/*.scss"],{cwd:e,deep:5,ignore:S});if(!t.length)return null;for(let r of t){let o=await O.readFile($.resolve(e,r),"utf-8");if(o.includes('@import "tailwindcss"')||o.includes("@import 'tailwindcss'"))return r}return null};var ue=async e=>(await j.glob("tsconfig.*",{cwd:e,deep:1,ignore:S})).length>0,ye=async e=>{let t=me(e);if(t.resultType==="failed"||!t.paths)return null;for(let[r,o]of Object.entries(t.paths))if(o.includes("./*")||o.includes("./src/*")||o.includes("./app/*")||o.includes("./resources/js/*/"))return r.at(0)??null;return null};function f(e){typeof e=="string"&&(a.break(),a.error(e),a.break(),process.exit(1)),e instanceof Error&&(a.break(),a.error(e.message),a.break(),process.exit(1)),a.error("Something went wrong. Please try again."),process.exit(1)}var G="https://radianos.com/api/components",E=async()=>{try{let e=await fetch(G);if(!e.ok){let r=`Failed to fetch data from ${G}. Status: ${e.status} - ${e.statusText}`;throw new Error(r)}return await e.json()}catch(e){f(e)}};import we from"ora";function m(e,t){return we({text:e,isSilent:t?.silent})}var ke=y.object({components:y.array(y.string()).optional(),cwd:y.string(),yes:y.boolean(),all:y.boolean(),overwrite:y.boolean(),silent:y.boolean()}),U=new be().name("add").description("Add components to ui folder inside the components folder in your project").argument("[components...]","The components to add.").option("-y, --yes","Skip confirmation prompts.",!1).option("-a, --all","Install all available components.",!1).option("-c, --cwd <cwd>","The working directory. Defaults to the current directory.",process.cwd()).option("-o, --overwrite","Overwrite existing files if they exist.",!1).option("-s, --silent","Mute output logs.",!1).action(async(e,t)=>{try{let r=ke.parse({components:e,cwd:R.resolve(t.cwd),...t});if(await W(r),!r.components?.length){let i=await ve(r);i.length||(a.warn("No components selected. Exiting."),process.exit(1)),r.components=i}let o=await je(r.components),n=await K(await E(),o);await Se(n,r,await C(r.cwd))}catch(r){f(r)}});async function ve(e){try{let t=(await E()).map(o=>o.name);if(e.all)return t;if(e.components?.length)return e.components;let{components:r}=await J({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.map(o=>({title:o,value:o,selected:e.components?.includes(o)}))});return r}catch{f(new Error("Failed to fetch available components."))}}var je=async e=>{let t=m("Checking registry").start(),r=(await E()).map(n=>n.name),o=e.filter(n=>!r.includes(n));return o.length>0&&(t.fail("Checking registry. Not found:"),o.forEach(n=>a.info(`- ${n}`)),process.exit(1)),t.succeed(),e};async function Se(e,t,r){let o=r.hasSrcDir;await Ce(e,t);let n=[],i=[],p=[];for(let l of e)for(let d of l.files){let g=R.join(t.cwd,o?"src":"",d.dir,d.name),k=await F.exists(g);if(k&&!t.overwrite){let{overwrite:ie}=await J({type:"confirm",name:"overwrite",message:`Component ${s.info(d.name)} already exists.Would you like to overwrite?`,initial:!1});if(!ie){p.push(g);continue}}let N=R.dirname(g);await F.exists(N)||await F.mkdir(N,{recursive:!0}),await F.writeFile(g,d.content),k?i.push(g):n.push(g)}t.silent||(n.length>0&&(a.break(),a.info(`Created ${n.length} file(s):`),n.forEach(l=>a.log(` - ${l}`))),i.length>0&&(a.break(),a.info(`Updated ${i.length} file(s):`),i.forEach(l=>a.log(` - ${l}`))),p.length>0&&(a.break(),a.info(`Skipped ${p.length} file(s):`),p.forEach(l=>a.log(` - ${l}`))))}async function Ce(e,t){let r=new Set;for(let n of e)n.dependencies?.length&&n.dependencies.forEach(i=>r.add(i));if(!r.size)return;let o=Array.from(r);try{let n=m("Installing the dependencies",{silent:t.silent}).start();await xe(await w(t.cwd),[await v(t.cwd),...o],{cwd:t.cwd,stdio:"ignore"}),n.succeed()}catch(n){f(new Error(`Failed to install dependencies: ${n.message}`))}}async function K(e,t,r=new Set){let o=[];for(let n of t){if(r.has(n))continue;r.add(n);let i=e.find(p=>p.name===n);if(i&&(o.push(i),i.registryDependencies?.length)){let p=await K(e,i.registryDependencies,r);o.push(...p)}}return o.filter((n,i,p)=>p.findIndex(l=>l.name===n.name)===i)}import{Command as Pe}from"commander";import{execa as Te}from"execa";import h from"fs-extra";import u from"path";import Z from"prompts";import I from"zod";import z from"fs-extra";import H from"path";var Y=async e=>{if(!z.existsSync(e.cwd)||!z.existsSync(H.resolve(e.cwd,"package.json")))return{projectInfo:null};let t=m("Preflight checks",{silent:!1}).start();if(z.existsSync(H.resolve(e.cwd,"components.json")))throw t.fail(),new Error(`The ${s.info("components.json")} file already exists at ${s.info(e.cwd)}. To start over, remove the ${s.info("components.json")} file and run ${s.info("init")} command again`);t.succeed("Before init checks completed");let r=m("Detecting framework",{silent:!1}).start(),o=await C(e.cwd);if((!o||o?.framework.name==="manual")&&(r?.fail(),o?.framework.link.installation))throw new Error(`We could not detect a supported framework at ${s.info(e.cwd)}. Visit ${s.info(o?.framework.link.installation)} to manually configure your project. Once configured, you can use the cli to add components.`);r?.succeed(`Detecting framework. Detected ${s.info(o.framework.label)}.`);let n=m("Verifying tailwind configuration",{silent:!1}).start();if(!o.tailwindCssFile)throw n?.fail(),new Error(`We could not find a Tailwind at ${s.info(e.cwd)}. Make sure you have a Tailwind installed your project. Visit ${s.info("https://tailwindcss.com/docs/installation")} to get started.`);n?.succeed("Verifying tailwind configuration. Found Tailwind configuration.");let i=m("Validating import alias",{silent:!1}).start();if(!o.aliasPrefix)throw i.fail(),new Error(`We could not find an import alias prefix in your TypeScript configuration. Make sure you have a 'paths' configuration in your tsconfig.json or tsconfig.js file. Once configured, you can use the cli to add components.`);return i.succeed(`Validating import alias. Found import alias prefix: ${s.info(o.aliasPrefix)}.`),{projectInfo:o}};import{execa as Ee}from"execa";var A=async(e,t,r)=>{if(!t.length)return;let o=await w(e,{withFallback:!0}),n=await v(e),i=m("Installing dependencies",{silent:r}).start();try{await Ee(o,[n,...t],{cwd:e}),i.succeed()}catch{i.fail(),f("Failed to install dependencies.")}};import X from"path";import{Project as Fe,SyntaxKind as Ie}from"ts-morph";async function D(e,t){let r=new Fe,o=t?X.join(e,"src","app","layout.tsx"):X.join(e,"app","layout.tsx"),n=r.addSourceFileAtPath(o);n.getImportDeclarations().forEach(i=>{i.getModuleSpecifierValue().includes("next/font")&&i.remove()}),n.getVariableStatements().forEach(i=>{i.getDeclarations().forEach(l=>{l.getInitializer()?.getText().includes("Geist")&&i.remove()})}),n.getDescendantsOfKind(Ie.JsxElement).forEach(i=>{let l=i.getOpeningElement().getAttribute("className");if(l){let d=l.getInitializer()?.getText();if(d?.includes("geist")){let g=d.replace(/[`{}$]/g,"").split(" ").filter(k=>!k.includes("geist")).join(" ");g.trim()?l.setInitializer(`"${g}"`):l.remove()}}}),await n.save()}var q=`import { clsx, type ClassValue } from "clsx"; import { twMerge } from "tailwind-merge"; export function cn(...inputs: ClassValue[]) { return twMerge(clsx(inputs.filter(Boolean))); } `;var Q=`@import url("https://fonts.googleapis.com/css2?family=Inter:ital,opsz,wght@0,14..32,100..900;1,14..32,100..900&family=Poppins:ital,wght@0,100;0,200;0,300;0,400;0,500;0,600;0,700;0,800;0,900;1,100;1,200;1,300;1,400;1,500;1,600;1,700;1,800;1,900&display=swap"); @import "tailwindcss"; @import "tw-animate-css"; @custom-variant dark (&:is(.dark *)); @theme static { /* Border radius variables */ --radius-radius-none: 0px; --radius-radius-xs: 2px; --radius-radius-sm: 4px; --radius-radius-md: 6px; --radius-radius-lg: 8px; --radius-radius-xl: 12px; --radius-radius-2xl: 16px; /* primary */ --color-primary: hsl(250, 80%, 60%); --color-primary-accent: hsl(230, 100%, 96%); --color-primary-focus: hsl(234, 100%, 94%); --color-primary-stroke: hsl(246, 89%, 67%); --color-primary-hover: hsl(246, 89%, 67%); --color-primary-text: hsl(252, 62%, 51%); /* information */ --color-info: hsl(210, 100%, 50%); --color-info-accent: hsl(197, 100%, 96%); --color-info-focus: hsl(196, 100%, 85%); --color-info-stroke: hsl(196, 100%, 64%); --color-info-hover: hsl(206, 100%, 51%); --color-info-text: hsl(210, 100%, 50%); /* success */ --color-success: hsl(135, 56%, 29%); --color-success-accent: hsl(136, 65%, 96%); --color-success-focus: hsl(134, 68%, 93%); --color-success-stroke: hsl(135, 60%, 40%); --color-success-hover: hsl(135, 60%, 40%); --color-success-text: hsl(136, 48%, 20%); /* error */ --color-error: hsl(0, 80%, 55%); --color-error-accent: hsl(0, 100%, 96%); --color-error-focus: hsl(0, 100%, 94%); --color-error-stroke: hsl(0, 93%, 60%); --color-error-hover: hsl(0, 93%, 60%); --color-error-text: hsl(0, 81%, 42%); /* warning */ --color-warning: hsl(29, 96%, 37%); --color-warning-accent: hsl(51, 100%, 94%); --color-warning-focus: hsl(52, 100%, 88%); --color-warning-stroke: hsl(35, 100%, 45%); --color-warning-hover: hsl(35, 100%, 45%); --color-warning-text: hsl(26, 88%, 31%); /* background */ --color-bg-level0: hsl(230, 6%, 96%); --color-bg-base: hsl(0, 0%, 100%); --color-bg-level1: hsl(0, 0%, 100%); --color-bg-level2: hsl(0, 0%, 100%); --color-text: hsl(230, 6%, 4%); --color-text-secondary: hsl(230, 6%, 36%); --color-text-tertiary: hsl(230, 6%, 60%); --color-text-disabled: hsl(230, 6%, 80%); --color-text-inverse: hsl(0, 0%, 100%); /* stroke */ --color-border: hsl(230, 6%, 88%); --color-soft: hsl(230, 6%, 92%); --color-soft-alpha: color-mix(in srgb, hsl(240, 5%, 4%), transparent 92%); --color-border-alpha: color-mix(in srgb, hsl(240, 5%, 4%), transparent 88%); /* 2% opacity */ /* fill */ --color-fill-level1: hsl(230, 6%, 98%); --color-fill-level2: hsl(230, 6%, 96%); --color-fill-level3: hsl(230, 6%, 88%); --color-fill-level4: hsl(230, 6%, 84%); /* fill-inverse */ --color-inverse-fill-level1: color-mix(in srgb, hsl(0, 0%, 100%), transparent 98%); /* 2% opacity */ --color-inverse-fill-level2: color-mix(in srgb, hsl(0, 0%, 100%), transparent 96%); /* 4% opacity */ --color-inverse-fill-level3: color-mix(in srgb, hsl(0, 0%, 100%), transparent 92%); /* 8% opacity */ --color-inverse-fill-level4: color-mix(in srgb, hsl(0, 0%, 100%), transparent 84%); /* 16% opacity */ /* static */ --color-static-white: hsl(0, 0%, 100%); --color-static-black: hsl(230, 6%, 4%); /* inverse */ --color-inverse-black: hsl(230, 6%, 4%); --color-inverse-white: hsl(0, 0%, 100%); /* Breakpoints */ --breakpoint-laptop: 90rem; /* Font families */ --heading-font: "Inter Display", system-ui, sans-serif; --body-font: "Inter", system-ui, sans-serif; } .dark { /* primary */ --color-primary: hsl(246, 89%, 67%); --color-primary-accent: hsl(252, 51%, 20%); --color-primary-accent-secondary: hsl(249, 51%, 30%); --color-primary-focus: hsl(249, 51%, 30%); --color-primary-stroke: hsl(251, 58%, 41%); --color-primary-hover: hsl(241, 95%, 74%); --color-primary-text: hsl(241, 95%, 74%); /* information */ --color-info: hsl(206, 100%, 51%); --color-info-accent: hsl(212, 74%, 21%); --color-info-accent-secondary: hsl(210, 85%, 30%); --color-info-focus: hsl(210, 85%, 30%); --color-info-stroke: hsl(212, 92%, 40%); --color-info-hover: hsl(201, 100%, 56%); --color-info-text: hsl(196, 100%, 64%); /* success */ --color-success: hsl(135, 56%, 29%); --color-success-accent: hsl(138, 65%, 10%); --color-success-accent-secondary: hsl(136, 48%, 20%); --color-success-focus: hsl(136, 48%, 20%); --color-success-stroke: hsl(136, 50%, 24%); --color-success-hover: hsl(135, 55%, 45%); --color-success-text: hsl(134, 54%, 58%); /* error */ --color-error: hsl(0, 80%, 55%); --color-error-accent: hsl(0, 82%, 15%); --color-error-accent-secondary: hsl(0, 69%, 30%); --color-error-focus: hsl(0, 69%, 30%); --color-error-stroke: hsl(0, 78%, 35%); --color-error-hover: hsl(0, 100%, 71%); --color-error-text: hsl(0, 100%, 71%); /* warning */ --color-warning: hsl(29, 96%, 37%); --color-warning-accent: hsl(23, 97%, 14%); --color-warning-accent-secondary: hsl(25, 82%, 26%); --color-warning-focus: hsl(25, 82%, 26%); --color-warning-stroke: hsl(26, 88%, 31%); --color-warning-hover: hsl(41, 98%, 50%); --color-warning-text: hsl(47, 100%, 56%); /* Background */ --color-bg-level0: hsl(230, 6%, 0%); --color-bg-base: hsl(230, 6%, 4%); --color-bg-level1: hsl(230, 6%, 8%); --color-bg-level2: hsl(230, 6%, 12%); /* foreground */ --color-text: hsl(0, 0%, 100%); --color-text-secondary: hsl(230, 6%, 60%); --color-text-tertiary: hsl(230, 6%, 48%); --color-text-disabled: hsl(230, 6%, 36%); --color-text-inverse: hsl(230, 6%, 4%); /* stroke */ --color-border: hsl(230, 6%, 16%); --color-border-alpha: color-mix(in srgb, hsl(0, 0%, 100%), transparent 88%); --color-soft: hsl(230, 6%, 12%); --color-soft-alpha: color-mix(in srgb, hsl(0, 0%, 100%), transparent 92%); /* fill */ --color-fill-level1: hsl(230, 6%, 6%); /* 2% opacity */ --color-fill-level2: hsl(230, 6%, 8%); /* 4% opacity */ --color-fill-level3: hsl(230, 6%, 12%); /* 8% opacity */ --color-fill-level4: hsl(230, 6%, 16%); /* 16% opacity */ /* fill-inverse */ --color-inverse-fill-level1: color-mix(in srgb, hsl(240, 5%, 4%), transparent 98%); /* 2% opacity */ --color-inverse-fill-level2: color-mix(in srgb, hsl(240, 5%, 4%), transparent 96%); /* 4% opacity */ --color-inverse-fill-level3: color-mix(in srgb, hsl(240, 5%, 4%), transparent 92%); /* 8% opacity */ --color-inverse-fill-level4: color-mix(in srgb, hsl(240, 5%, 4%), transparent 84%); /* 16% opacity */ /* static */ --color-static-white: hsl(0, 0%, 100%); --color-static-black: hsl(230, 6%, 4%); /* inverse */ --color-inverse-black: hsl(0, 0%, 100%); --color-inverse-white: hsl(230, 6%, 4%); --color-text-primary: hsl(0, 0%, 100%); /* --color-text-paragraph: var(--color-white-10); */ --color-text-disabled: hsl(230, 6%, 36%); /* --color-text-4: var(--color-black-5); */ /* static */ --color-static-white: hsl(0, 0%, 100%); --color-static-black: hsl(240, 5%, 4%); } @theme inline { --animate-infinite-scroll: infinite-scroll var(--duration) infinite linear; --animate-infinite-scroll-vertical: infinite-scroll-vertical var(--duration) infinite linear; @keyframes infinite-scroll { from { transform: translateX(0); } to { transform: translateX(calc(-100% - var(--gap))); } } @keyframes infinite-scroll-vertical { from { transform: translateY(0); } to { transform: translateY(calc(-100% - var(--gap))); } } } @layer base { * { @apply border-border; } body { @apply font-body bg-bg-base text-text; } } @utility animation-pause { animation-play-state: paused; } /* The default border color has changed to 'currentColor' in Tailwind CSS v4, so we've added these compatibility styles to make sure everything still looks the same as it did with Tailwind CSS v3. If we ever want to remove these styles, we need to add an explicit border color utility to any element that depends on these defaults. */ @utility font-heading { /* Base typography classes for headings and body */ font-family: var(--heading-font); } @utility font-body { font-family: var(--body-font); } @utility heading-1 { /* Heading styles */ @apply font-heading text-[2.25rem] font-bold leading-[2.75rem]; @media (width >=theme(--breakpoint-sm)) { font-size: 3rem; line-height: 3.5rem; } @media (width >=theme(--breakpoint-lg)) { font-size: 4rem; line-height: 4.5rem; } } @utility heading-2 { @apply font-heading text-[2rem] font-bold leading-[2.5rem]; @media (width >=theme(--breakpoint-sm)) { font-size: 2.5rem; line-height: 3rem; } @media (width >=theme(--breakpoint-lg)) { font-size: 3rem; line-height: 3.5rem; } } @utility heading-3 { @apply font-heading text-[1.875rem] font-bold leading-[2.375rem]; @media (width >=theme(--breakpoint-sm)) { font-size: 2.25rem; line-height: 2.75rem; } @media (width >=theme(--breakpoint-lg)) { font-size: 2.5rem; line-height: 3rem; } } @utility heading-4 { @apply font-heading text-[1.75rem] font-bold leading-[2.25rem]; @media (width >=theme(--breakpoint-sm)) { font-size: 1.875rem; line-height: 2.375rem; } @media (width >=theme(--breakpoint-lg)) { font-size: 2rem; line-height: 2.5rem; } } @utility heading-5 { @apply font-heading text-[1.5rem] font-bold leading-[2rem]; @media (width >=theme(--breakpoint-sm)) { font-size: 1.5rem; line-height: 2rem; } @media (width >=theme(--breakpoint-lg)) { font-size: 1.5rem; line-height: 2rem; } } @utility heading-6 { @apply font-heading text-[1.25rem] font-bold leading-[1.75rem]; @media (width >=theme(--breakpoint-sm)) { font-size: 1.25rem; line-height: 1.75rem; } @media (width >=theme(--breakpoint-lg)) { font-size: 1.25rem; line-height: 1.75rem; } } @utility body-15 { @apply font-body text-[0.9375rem] leading-[1.375]; } @utility text-sm-p { @apply font-body text-sm leading-[1.25rem]; } @utility body-13 { @apply font-body text-[0.8125rem] leading-[1.125rem]; } @utility no-scrollbar { -ms-overflow-style: none; /* IE and Edge */ scrollbar-width: none; /* Firefox */ &::-webkit-scrollbar { display: none; /* Chrome, Safari and Opera */ } } @layer utilities { /* Chrome & other browser puts a background color on autofill inputs, this removes it */ input:-webkit-autofill, input:-webkit-autofill:hover, input:-webkit-autofill:focus, input:-webkit-autofill:active { -webkit-background-clip: text; -webkit-text-fill-color: inherit; transition: background-color 5000s ease-in-out 0s; box-shadow: inset 0 0 20px 20px transparent; } }`;var ee=["tw-animate-css","class-variance-authority","clsx","tailwind-merge","lucide-react"],Oe=I.object({cwd:I.string(),yes:I.boolean(),defaultConfigurations:I.boolean()}),te=new Pe().name("init").description("initializes your project with required dependencies").option("-y,--yes","skip confirmation prompts",!1).option("-d,--defaultConfigurations","use default configurations",!1).option("-c,--cwd <cwd>","current working directory",process.cwd()).action(async e=>{try{let t=Oe.parse(e);await $e(t),a.break(),a.info(`${s.success("Success!")} Project initialization completed. You may now add components.`),a.break()}catch(t){f(t)}}),re=async(e,t)=>{try{let r=t?u.join(e,"src","app"):u.join(e,"app");if(!h.existsSync(r))throw new Error(`Could not find 'app' directory at the expected path: ${r}`);let o=u.join(r,"globals.css");await h.writeFile(o,Q,"utf-8")}catch(r){throw new Error(`Failed to create 'globals.css'${r.message}`)}},oe=async(e,t)=>{try{let r=t?u.join(e,"src"):e,o=u.join(r,"lib");await h.ensureDir(o);let n=u.join(o,"utils.ts");await h.writeFile(n,q,"utf8")}catch(r){throw new Error(`Failed to create utils.ts: ${r}`)}};var $e=async e=>{let t=await Y(e);if(!t.projectInfo){(await Z({type:"confirm",name:"confirmNewProject",message:`The path ${s.bold(s.info(e.cwd))} does't contain a package.json file. Would you like to create a new ${s.bold(s.info("Next.js"))} project?`,initial:!1})).confirmNewProject||process.exit();let{projectPath:l}=await ze({cwd:e.cwd});e.cwd=l;return}let{hasSrcDir:r}=t.projectInfo,o=m("Writing components.json file").start(),n=u.resolve(e.cwd,"components.json");await h.writeFile(n,JSON.stringify({hasSrcDir:r},null,2),"utf8"),o.succeed();let i=m("Setting up project configuration").start();await oe(e.cwd,r),await D(e.cwd,r),await re(e.cwd,r),i.succeed("Project configuration completed"),await A(`${e.cwd}`,ee)},Re=async()=>{let{projectName:e,useSrcDir:t}=await Z([{type:"text",name:"projectName",message:"What would you like to name your project?",initial:"my-app",format:r=>r.trim(),validate:r=>r.length>128?"Name should be less than 128 characters.":!0},{type:"confirm",name:"useSrcDir",message:"Would you like to use /src directory?",initial:!0}]);return{projectName:e,useSrcDir:t}},ze=async e=>{try{let{projectName:t,useSrcDir:r}=await Re(),o=u.join(e.cwd,t),n=await w(e.cwd,{withFallback:!0});try{await h.access(e.cwd,h.constants.W_OK)}catch{a.break(),a.error(`The path ${s.info(e.cwd)} is not writable.`),a.error(`Possible reasons: 1. You do not have write permissions for this folder. 2. The path does not exist.`),a.break(),process.exit(1)}if(h.existsSync(o))throw new Error(`A project with the name ${t} already exists in the current directory.`);let i=m(`Creating a new ${s.bold(s.info("Next.js"))} project. This might take some time.`).start();await Te("npx",["create-next-app","--tailwind","--eslint","--typescript","--app",t,`--use-${n}`,r?"--src-dir":"--no-src-dir","--yes"],{cwd:e.cwd,stdio:"ignore"}),i.succeed();let p=m("Writing components.json file").start(),l=u.resolve(o,"components.json");await h.writeFile(l,JSON.stringify({hasSrcDir:r},null,2),"utf8"),p.succeed();let d=m("Setting up project configuration").start();return await oe(o,r),await D(o,r),await re(o,r),d.succeed(),await A(`${o}`,ee),{projectPath:o,projectName:t}}catch(t){f(t)}};import{instagram as Ae}from"gradient-string";var ne=e=>{a.break(),a.log(Ae(e)),a.break()};process.on("uncaughtException",f);process.on("unhandledRejection",f);process.on("SIGINT",()=>process.exit(0));process.on("SIGTERM",()=>process.exit(0));async function Ne(){let e=new De().name(b.name).description(b.description).version(b.version||"1.0.0","-v, --version","display the version number");ne(`RadianOS v${b.version}`),e.addCommand(te),e.addCommand(U),e.parse()}Ne(); //# sourceMappingURL=index.js.map