UNPKG

@radianos/radianbeta

Version:

add components to your project

540 lines (455 loc) 29.8 kB
#!/usr/bin/env node var w={name:"radianos",version:"0.0.0",main:"index.js",type:"module",publishConfig:{access:"public"},exports:"./dist/index.js",bin:"./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":"^0.2.2",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 Tr}from"commander";import{Command as yr}from"commander";import{execa as wr}from"execa";import E from"fs-extra";import R from"path";import V from"prompts";import{z as y}from"zod";import P from"fs-extra";import B from"path";import l from"chalk";var a={error:l.redBright,success:l.greenBright,warning:l.yellowBright,info:l.blueBright,dark:l.blackBright,light:l.whiteBright,deprecated:l.gray,magenta:l.magentaBright,cyan:l.cyanBright,bold:l.bold,italic:l.italic,underline:l.underline,strikethrough:l.strikethrough},Br={error:l.bgRedBright,success:l.bgGreenBright,warning:l.bgYellowBright,info:l.bgBlueBright,dark:l.bgBlackBright,light:l.bgWhiteBright,magenta:l.bgMagentaBright,cyan:l.bgCyanBright};import{cosmiconfig as nr}from"cosmiconfig";import{z as F}from"zod";var ir=nr("components"),ar=F.object({useSrcDir:F.boolean(),alias:F.string().optional()});async function N(r=process.cwd()){try{let e=await ir.search(r);return e?ar.parse(e):null}catch(e){throw new Error(`Error loading components.json configuration: ${e instanceof Error?e.message:"Unknown error"}`)}}var M=async r=>{if(!P.existsSync(r.cwd)||!P.existsSync(B.resolve(r.cwd,"package.json")))return{config:null};if(!P.existsSync(B.resolve(r.cwd,"components.json")))throw new Error(`The components.json file is missing. Run the following command to set up your project: ${a.info("npx radianos init")}`);try{return await N(r.cwd)}catch{throw new Error(`An invalid ${a.info("components.json")} file was found at ${a.info(r.cwd)}. Before you can add components, you must create a valid ${a.info("components.json")} file by running the ${a.info("init")} command.`)}};import sr from"fs-extra";import{detect as cr}from"package-manager-detector";import lr from"path";var b=async r=>{let e=lr.resolve(r);if(!sr.existsSync(e))throw new Error(`The path "${e}" does not exist.`);return await cr({cwd:e})};var W=async r=>{let e=await b(r);if(!e)return null;switch(e.name){case"npm":return"install";case"pnpm":return"install";case"bun":return"add";case"yarn":return"add";default:return null}};import k from"fast-glob";import O from"fs-extra";import z from"path";import{loadConfig as mr}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 s={success:(...r)=>{console.log(a.success(r.join(" ")))},info:(...r)=>{console.log(a.info(r.join(" ")))},warn:(...r)=>{console.log(a.warning(r.join(" ")))},error:(...r)=>{console.log(a.error(r.join(" ")))},log:(...r)=>{console.log(a.dark(r.join("")))},break:()=>{console.log("")}};var j=["**/node_modules/**","dist","build",".next","public"];var S=async r=>{let[e,o,t,n,i,m]=await Promise.all([pr(r),O.pathExists(z.resolve(r,"src")),gr(r),dr(r),fr(r),ur(r)]),c=await O.pathExists(z.resolve(r,`${o?"src/":""}app`)),p={framework:x.manual,hasSrcDir:o,isRSC:!1,isTsx:t,tailwindConfigFile:n,tailwindCssFile:i,aliasPrefix:m};return e?.startsWith("next.config.")?(p.framework=c?x["next-app"]:x["next-pages"],p.isRSC=c,p):(e?.startsWith("vite.config.")&&(p.framework=x.vite),p)},pr=async r=>{let e=await k.glob("**/{next,vite}.config.*",{cwd:r,deep:3,ignore:j});return e.length?e[0]:null},dr=async r=>{let e=await k.glob("tailwind.config.*",{cwd:r,deep:3,ignore:j});return e.length?e[0]:null},fr=async r=>{let e=await k.glob(["**/*.css","**/*.scss"],{cwd:r,deep:5,ignore:j});if(!e.length)return null;for(let o of e){let t=await O.readFile(z.resolve(r,o),"utf-8");if(t.includes('@import "tailwindcss"')||t.includes("@import 'tailwindcss'"))return o}return null};var gr=async r=>(await k.glob("tsconfig.*",{cwd:r,deep:1,ignore:j})).length>0,ur=async r=>{let e=mr(r);if(e.resultType==="failed"||!e.paths)return null;for(let[o,t]of Object.entries(e.paths))if(t.includes("./*")||t.includes("./src/*")||t.includes("./app/*")||t.includes("./resources/js/*/"))return o.at(0)??null;return null};function f(r){typeof r=="string"&&(s.break(),s.error(r),s.break(),process.exit(1)),r instanceof Error&&(s.break(),s.error(r.message),s.break(),process.exit(1)),s.error("Something went wrong. Please try again."),process.exit(1)}var _="https://radianos.com/api/components",C=async()=>{try{let r=await fetch(_);if(!r.ok){let o=`Failed to fetch data from ${_}. Status: ${r.status} - ${r.statusText}`;throw new Error(o)}return await r.json()}catch(r){f(r)}};import hr from"ora";function d(r,e){return hr({text:r,isSilent:e?.silent})}var br=y.object({components:y.array(y.string()).optional(),cwd:y.string(),yes:y.boolean(),all:y.boolean(),overwrite:y.boolean(),silent:y.boolean()}),L=new yr().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(r,e)=>{try{let o=br.parse({components:r,cwd:R.resolve(e.cwd),...e});if(await M(o),!o.components?.length){let i=await xr(o);i.length||(s.warn("No components selected. Exiting."),process.exit(1)),o.components=i}let t=await vr(o.components),n=await G(await C(),t);await kr(n,o,await S(o.cwd))}catch(o){f(o)}});async function xr(r){try{let e=(await C()).map(t=>t.name);if(r.all)return e;if(r.components?.length)return r.components;let{components:o}=await V({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:e.map(t=>({title:t,value:t,selected:r.components?.includes(t)}))});return o}catch{f(new Error("Failed to fetch available components."))}}var vr=async r=>{let e=d("Checking registry").start(),o=(await C()).map(n=>n.name),t=r.filter(n=>!o.includes(n));return t.length>0&&(e.fail("Checking registry. Not found:"),t.forEach(n=>s.info(`- ${n}`)),process.exit(1)),e.succeed(),r};async function kr(r,e,o){let t=o.hasSrcDir;await jr(r,e);let n=[],i=[],m=[];for(let c of r)for(let p of c.files){let g=R.join(e.cwd,t?"src":"",p.dir,p.name),v=await E.exists(g);if(v&&!e.overwrite){let{overwrite:or}=await V({type:"confirm",name:"overwrite",message:`Component ${a.info(p.name)} already exists.Would you like to overwrite?`,initial:!1});if(!or){m.push(g);continue}}let A=R.dirname(g);await E.exists(A)||await E.mkdir(A,{recursive:!0}),await E.writeFile(g,p.content),v?i.push(g):n.push(g)}e.silent||(n.length>0&&(s.break(),s.info(`Created ${n.length} file(s):`),n.forEach(c=>s.log(` - ${c}`))),i.length>0&&(s.break(),s.info(`Updated ${i.length} file(s):`),i.forEach(c=>s.log(` - ${c}`))),m.length>0&&(s.break(),s.info(`Skipped ${m.length} file(s):`),m.forEach(c=>s.log(` - ${c}`))))}async function jr(r,e){let o=new Set;for(let n of r)n.dependencies?.length&&n.dependencies.forEach(i=>o.add(i));if(!o.size)return;let t=Array.from(o);try{let n=d("Installing the dependencies",{silent:e.silent}).start();await wr((await b(e.cwd)).name,["install","--legacy-peer-deps",...t],{cwd:e.cwd,stdio:"ignore"}),n.succeed()}catch(n){f(new Error(`Failed to install dependencies: ${n.message}`))}}async function G(r,e){let o=[];for(let t of e){let n=r.find(i=>i.name===t);if(n&&(o.push(n),n.registryDependencies)){let i=await G(r,n.registryDependencies);o.push(...i)}}return o.filter((t,n,i)=>i.findIndex(m=>m.name===t.name)===n)}import{Command as Ir}from"commander";import{execa as Fr}from"execa";import u from"fs-extra";import h from"path";import q from"prompts";import I from"zod";import $ from"fs-extra";import J from"path";var U=async r=>{if(!$.existsSync(r.cwd)||!$.existsSync(J.resolve(r.cwd,"package.json")))return{projectInfo:null};let e=d("Preflight checks",{silent:!1}).start();if($.existsSync(J.resolve(r.cwd,"components.json")))throw e.fail(),new Error(`The ${a.info("components.json")} file already exists at ${a.info(r.cwd)}. To start over, remove the ${a.info("components.json")} file and run ${a.info("init")} command again`);e.succeed("Before init checks completed");let o=d("Detecting framework",{silent:!1}).start(),t=await S(r.cwd);if((!t||t?.framework.name==="manual")&&(o?.fail(),t?.framework.link.installation))throw new Error(`We could not detect a supported framework at ${a.info(r.cwd)}. Visit ${a.info(t?.framework.link.installation)} to manually configure your project. Once configured, you can use the cli to add components.`);o?.succeed(`Detecting framework. Detected ${a.info(t.framework.label)}.`);let n=d("Verifying tailwind configuration",{silent:!1}).start();if(!t.tailwindCssFile)throw n?.fail(),new Error(`We could not find a Tailwind at ${a.info(r.cwd)}. Make sure you have a Tailwind installed your project. Visit ${a.info("https://tailwindcss.com/docs/installation")} to get started.`);n?.succeed("Verifying tailwind configuration. Found Tailwind configuration.");let i=d("Validating import alias",{silent:!1}).start();if(!t.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: ${a.info(t.aliasPrefix)}.`),{projectInfo:t}};import{execa as Sr}from"execa";var T=async(r,e,o)=>{if(!e.length)return;let n=(await b(r)).name,i=await W(r),m=d("Installing dependencies",{silent:o}).start();try{await Sr(n,[i,"--legacy-peer-deps",...e],{cwd:r,stdio:"ignore"}),m.succeed()}catch{m.fail(),f("Failed to install dependencies.")}};import H from"path";import{Project as Cr,SyntaxKind as Er}from"ts-morph";async function D(r,e){let o=new Cr,t=e?H.join(r,"src","app","layout.tsx"):H.join(r,"app","layout.tsx"),n=o.addSourceFileAtPath(t);n.getImportDeclarations().forEach(i=>{i.getModuleSpecifierValue().includes("next/font")&&i.remove()}),n.getVariableStatements().forEach(i=>{i.getDeclarations().forEach(c=>{c.getInitializer()?.getText().includes("Geist")&&i.remove()})}),n.getDescendantsOfKind(Er.JsxElement).forEach(i=>{let c=i.getOpeningElement().getAttribute("className");if(c){let p=c.getInitializer()?.getText();if(p?.includes("geist")){let g=p.replace(/[`{}$]/g,"").split(" ").filter(v=>!v.includes("geist")).join(" ");g.trim()?c.setInitializer(`"${g}"`):c.remove()}}}),await n.save()}var K=`import { clsx, type ClassValue } from "clsx"; import { twMerge } from "tailwind-merge"; export function cn(...inputs: ClassValue[]) { return twMerge(clsx(inputs.filter(Boolean))); } `;var Y=`@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") layer(base); @import "tailwindcss"; @plugin "tailwindcss-animate"; @custom-variant dark (&:is(.dark *)); :root { /* primary */ --color-primary-50: hsla(250, 100%, 98%, 1); --color-primary-100: hsla(250, 100%, 95%, 1); --color-primary-200: hsla(250, 100%, 92%, 1); --color-primary-300: hsla(250, 100%, 86%, 1); --color-primary-400: hsla(250, 100%, 76%, 1); --color-primary-500: hsla(250, 100%, 68%, 1); --color-primary-600: hsla(250, 80%, 60%, 1); --color-primary-700: hsla(250, 60%, 52%, 1); --color-primary-800: hsla(250, 55%, 44%, 1); --color-primary-900: hsla(250, 50%, 24%, 1); --color-primary-950: hsla(250, 50%, 15%, 1); /* information */ --color-information-50: hsla(210, 100%, 98%, 1); --color-information-100: hsla(210, 100%, 95%, 1); --color-information-200: hsla(210, 100%, 92%, 1); --color-information-300: hsla(210, 100%, 86%, 1); --color-information-400: hsla(210, 100%, 76%, 1); --color-information-500: hsla(210, 100%, 68%, 1); --color-information-600: hsla(210, 100%, 60%, 1); --color-information-700: hsla(210, 100%, 50%, 1); --color-information-800: hsla(210, 80%, 42%, 1); --color-information-900: hsla(210, 60%, 24%, 1); --color-information-950: hsla(210, 50%, 16%, 1); /* success */ --color-success-50: hsla(135, 100%, 98%, 1); --color-success-100: hsla(135, 80%, 95%, 1); --color-success-200: hsla(135, 80%, 95%, 1); --color-success-300: hsla(135, 80%, 95%, 1); --color-success-400: hsla(135, 80%, 95%, 1); --color-success-500: hsla(135, 80%, 95%, 1); --color-success-600: hsla(135, 70%, 56%, 1); --color-success-700: hsla(135, 70%, 56%, 1); --color-success-800: hsla(135, 50%, 44%, 1); --color-success-900: hsla(135, 50%, 24%, 1); --color-success-950: hsla(135, 50%, 16%, 1); /* error */ --color-error-50: hsla(0, 100%, 98%, 1); --color-error-100: hsla(0, 100%, 95%, 1); --color-error-200: hsla(0, 100%, 92%, 1); --color-error-300: hsla(0, 100%, 86%, 1); --color-error-400: hsla(0, 100%, 86%, 1); --color-error-500: hsla(0, 90%, 68%, 1); --color-error-600: hsla(0, 90%, 68%, 1); --color-error-700: hsla(0, 70%, 52%, 1); --color-error-800: hsla(0, 65%, 44%, 1); --color-error-900: hsla(0, 60%, 24%, 1); --color-error-950: hsla(0, 50%, 16%, 1); /* warning */ --color-warning-50: hsla(35, 100%, 98%, 1); --color-warning-100: hsla(35, 100%, 95%, 1); --color-warning-200: hsla(35, 100%, 92%, 1); --color-warning-300: hsla(35, 100%, 92%, 1); --color-warning-400: hsla(35, 100%, 76%, 1); --color-warning-500: hsla(35, 100%, 68%, 1); --color-warning-600: hsla(35, 100%, 60%, 1); --color-warning-700: hsla(35, 100%, 50%, 1); --color-warning-800: hsla(35, 80%, 44%, 1); --color-warning-900: hsla(35, 70%, 24%, 1); --color-warning-950: hsla(35, 50%, 16%, 1); /* neutral */ --color-neutral-50: hsla(0, 0%, 98%, 1); --color-neutral-100: hsla(250, 5%, 96%, 1); --color-neutral-200: hsla(250, 6%, 92%, 1); --color-neutral-300: hsla(250, 5%, 86%, 1); --color-neutral-400: hsla(250, 5%, 68%, 1); --color-neutral-500: hsla(250, 5%, 46%, 1); --color-neutral-600: hsla(250, 5%, 34%, 1); --color-neutral-700: hsla(250, 5%, 26%, 1); --color-neutral-800: hsla(250, 5%, 16%, 1); --color-neutral-900: hsla(250, 6%, 10%, 1); --color-neutral-950: hsla(250, 4%, 4%, 1); /* static */ --color-static-white: hsl(0 0% 100%); --color-static-black: hsla(250, 4%, 4%, 1); } @theme { /* primary */ --color-primary: var(--color-primary-600); --color-primary-accent: var(--color-primary-50); --color-primary-accent-secondary: var(--color-primary-100); --color-primary-focus: var(--color-primary-200); --color-primary-stroke: var(--color-primary-400); --color-primary-hover: var(--color-primary-500); --color-primary-text: var(--color-primary-800); /* information */ --color-information: var(--color-information-700); --color-information-accent: var(--color-information-50); --color-information-accent-secondary: var(--color-information-100); --color-information-focus: var(--color-information-200); --color-information-stroke: var(--color-information-400); --color-information-hover: var(--color-information-500); --color-information-text: var(--color-information-800); /* success */ --color-success: var(--color-success-700); --color-success-accent: var(--color-success-50); --color-success-accent-secondary: var(--color-success-100); --color-success-focus: var(--color-success-200); --color-success-stroke: var(--color-success-400); --color-success-hover: var(--color-success-500); --color-success-text: var(--color-success-800); /* error */ --color-error: var(--color-error-600); --color-error-accent: var(--color-error-50); --color-error-accent-secondary: var(--color-error-100); --color-error-focus: var(--color-error-200); --color-error-stroke: var(--color-error-400); --color-error-hover: var(--color-error-500); --color-error-text: var(--color-error-800); /* warning */ --color-warning: var(--color-warning-700); --color-warning-accent: var(--color-warning-50); --color-warning-accent-secondary: var(--color-warning-100); --color-warning-focus: var(--color-warning-200); --color-warning-stroke: var(--color-warning-400); --color-warning-hover: var(--color-warning-500); --color-warning-text: var(--color-warning-800); /* background */ --color-bg1: var(--color-static-white); --color-bg2: var(--color-neutral-50); --color-bg3: var(--color-neutral-100); --color-bg4: var(--color-neutral-200); /* foreground */ --color-fg1: var(--color-neutral-950); --color-fg2: var(--color-neutral-700); --color-fg3: var(--color-neutral-400); /* text */ --color-text-primary: var(--color-neutral-950); --color-text-paragraph: var(--color-neutral-700); --color-text-disabled: var(--color-neutral-500); /* stroke */ --color-stroke: var(--color-neutral-300); --color-stroke-decorative: var(--color-neutral-200); /* Breakpoints */ --breakpoint-laptop: 90rem; /* Animations */ --animate-accordion-down: accordion-down 0.2s ease-out; --animate-accordion-up: accordion-up 0.2s ease-out; --animate-caret-blink: caret-blink 1.1s ease-out infinite; @keyframes accordion-down { from { height: 0; } to { height: var(--radix-accordion-content-height); } } @keyframes accordion-up { from { height: var(--radix-accordion-content-height); } to { height: 0; } } @keyframes caret-blink { 0%, 70%, 100% { opacity: 1; } 20%, 50% { opacity: 0; } } } .dark { /* primary */ --color-primary: var(--color-primary-600); --color-primary-accent: var(--color-primary-950); --color-primary-accent-secondary: var(--color-primary-900); --color-primary-focus: var(--color-primary-800); --color-primary-stroke: var(--color-primary-800); --color-primary-hover: var(--color-primary-400); --color-primary-text: var(--color-primary-400); /* information */ --color-information: var(--color-information-700); --color-information-accent: var(--color-information-950); --color-information-accent-secondary: var(--color-information-900); --color-information-focus: var(--color-information-800); --color-information-stroke: var(--color-information-800); --color-information-hover: var(--color-information-400); --color-information-text: var(--color-information-400); /* success */ --color-success: var(--color-success-700); --color-success-accent: var(--color-success-950); --color-success-accent-secondary: var(--color-success-900); --color-success-focus: var(--color-success-800); --color-success-stroke: var(--color-success-800); --color-success-hover: var(--color-success-400); --color-success-text: var(--color-success-400); /* error */ --color-error: var(--color-error-600); --color-error-accent: var(--color-error-950); --color-error-accent-secondary: var(--color-error-900); --color-error-focus: var(--color-error-800); --color-error-stroke: var(--color-error-800); --color-error-hover: var(--color-error-400); --color-error-text: var(--color-error-400); /* warning */ --color-warning: var(--color-warning-700); --color-warning-accent: var(--color-warning-950); --color-warning-accent-secondary: var(--color-warning-900); --color-warning-focus: var(--color-warning-800); --color-warning-stroke: var(--color-warning-800); --color-warning-hover: var(--color-warning-400); --color-warning-text: var(--color-warning-400); /* Background */ --color-bg1: var(--color-static-black); --color-bg2: var(--color-neutral-900); --color-bg3: var(--color-neutral-800); --color-bg4: var(--color-neutral-700); /* foreground */ --color-fg1: var(--color-neutral-50); --color-fg2: var(--color-neutral-400); --color-fg3: var(--color-neutral-700); /* stroke */ --color-stroke: var(--color-neutral-800); --color-stroke-decorative: var(--color-neutral-900); } @layer base { *, ::after, ::before, ::backdrop, ::file-selector-button { border-color: var(--color-gray-200, currentColor); } } @utility font-heading { /* Base typography classes for headings and body */ font-family: "Inter Display", system-ui, sans-serif; } @utility font-body { font-family: "Inter", system-ui, sans-serif; } @utility heading-1 { /* Heading styles */ @apply font-heading text-[2.25rem] leading-[2.75rem] font-bold; @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] leading-[2.5rem] font-bold; @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] leading-[2.375rem] font-bold; @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] leading-[2.25rem] font-bold; @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] leading-[2rem] font-bold; @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] leading-[1.75rem] font-bold; @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-lg { /* Body text styles */ @apply font-body text-[1.125rem] leading-[1.75rem]; } @utility body-base { @apply font-body text-[1rem] leading-[1.5rem]; } @utility body-15 { @apply font-body text-[0.9375rem] leading-[1.375]; } @utility body-sm { @apply font-body text-[0.875rem] leading-[1.25rem]; } @utility body-13 { @apply font-body text-[0.8125rem] leading-[1.125rem]; } @utility body-xs { @apply font-body text-[0.75rem] leading-[1rem]; } @utility no-scrollbar { -ms-overflow-style: none; /* IE and Edge */ scrollbar-width: none; /* Firefox */ &::-webkit-scrollbar { display: none; /* Chrome, Safari and Opera */ } } @utility hide-stepper { /* Hide the number stepper for input[type="number"] */ &input[type="number"]::-webkit-outer-spin-button { -webkit-appearance: none; margin: 0; -moz-appearance: textfield !important; } & input[type="number"]::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; -moz-appearance: textfield !important; } & input[type="number"] { -webkit-appearance: none; margin: 0; -moz-appearance: textfield !important; } } @layer base { button:not(:disabled), [role="button"]:not(:disabled) { cursor: pointer; } } @layer base { * { @apply border-stroke; scrollbar-width: thin; scrollbar-color: hsl(var(--border)) transparent; scroll-behavior: smooth; } html { font-family: "Inter", system-ui, sans-serif; } body { @apply bg-bg1 text-fg1; } code[data-line-numbers] { counter-reset: line; } code[data-line-numbers] > [data-line]::before { counter-increment: line; content: counter(line); /* Other styling */ display: inline-block; width: 0.75rem; margin-right: 2rem; text-align: right; color: gray; } code[data-line-numbers-max-digits="2"] > [data-line]::before { width: 1.25rem; } code[data-line-numbers-max-digits="3"] > [data-line]::before { width: 1.75rem; } code[data-line-numbers-max-digits="4"] > [data-line]::before { width: 2.25rem; } } @layer utilities { /* Custom scrollbar styling. */ ::-webkit-scrollbar { width: 6px; } ::-webkit-scrollbar-track { background: transparent; } ::-webkit-scrollbar-thumb { background: hsl(var(--border)); border-radius: 5px; } ::-webkit-scrollbar-thumb:hover { background: hsl(var(--border-secondary)); } /* 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; } .dark img { filter: none !important; } .dark .invert-in-dark { filter: invert(1) !important; } .svg-color { fill: var(--color-fg1); } } `;var Q=["tailwindcss-animate","class-variance-authority","clsx","tailwind-merge","lucide-react"],Pr=I.object({cwd:I.string(),yes:I.boolean(),defaultConfigurations:I.boolean()}),X=new Ir().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 r=>{try{let e=Pr.parse(r);await Or(e),s.break(),s.info(`${a.success("Success!")} Project initialization completed. You may now add components.`),s.break()}catch(e){f(e)}}),Z=async(r,e)=>{try{let o=e?h.join(r,"src","app"):h.join(r,"app");if(!u.existsSync(o))throw new Error(`Could not find 'app' directory at the expected path: ${o}`);let t=h.join(o,"globals.css");await u.writeFile(t,Y,"utf-8")}catch(o){throw new Error(`Failed to create 'globals.css'${o.message}`)}},rr=async(r,e)=>{try{let o=e?h.join(r,"src"):r,t=h.join(o,"lib");await u.ensureDir(t);let n=h.join(t,"utils.ts");await u.writeFile(n,K,"utf8")}catch(o){throw new Error(`Failed to create utils.ts: ${o}`)}};var Or=async r=>{let e=await U(r);if(!e.projectInfo){(await q({type:"confirm",name:"confirmNewProject",message:`The path ${a.bold(a.info(r.cwd))} does't contain a package.json file. Would you like to create a new ${a.bold(a.info("Next.js"))} project?`,initial:!1})).confirmNewProject||process.exit();let{projectPath:c}=await Rr({cwd:r.cwd});r.cwd=c;return}let{hasSrcDir:o}=e.projectInfo,t=d("Writing components.json file").start(),n=h.resolve(r.cwd,"components.json");await u.writeFile(n,JSON.stringify({hasSrcDir:o},null,2),"utf8"),t.succeed();let i=d("Setting up project configuration").start();await rr(r.cwd,o),await D(r.cwd,o),await Z(r.cwd,o),i.succeed("Project configuration completed"),await T(`${r.cwd}`,Q)},zr=async()=>{let{projectName:r,useSrcDir:e}=await q([{type:"text",name:"projectName",message:"What would you like to name your project?",initial:"my-app",format:o=>o.trim(),validate:o=>o.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:r,useSrcDir:e}},Rr=async r=>{try{let{projectName:e,useSrcDir:o}=await zr(),t=h.join(r.cwd,e);try{await u.access(r.cwd,u.constants.W_OK)}catch{s.break(),s.error(`The path ${a.info(r.cwd)} is not writable.`),s.error(`Possible reasons: 1. You do not have write permissions for this folder. 2. The path does not exist.`),s.break(),process.exit(1)}if(u.existsSync(t))throw new Error(`A project with the name ${e} already exists in the current directory.`);let n=d(`Creating a new ${a.bold(a.info("Next.js"))} project. This might take some time.`).start();await Fr("npx",["create-next-app","--tailwind","--eslint","--typescript","--app",e,"--use-npm",o?"--src-dir":"--no-src-dir","--yes"],{cwd:r.cwd,stdio:"ignore"}),n.succeed();let i=d("Writing components.json file").start(),m=h.resolve(t,"components.json");await u.writeFile(m,JSON.stringify({hasSrcDir:o},null,2),"utf8"),i.succeed();let c=d("Setting up project configuration").start();return await rr(t,o),await D(t,o),await Z(t,o),c.succeed(),await T(`${t}`,Q),{projectPath:t,projectName:e}}catch(e){f(e)}};import{instagram as $r}from"gradient-string";var er=r=>{s.break(),s.log($r(r)),s.break()};process.on("uncaughtException",f);process.on("unhandledRejection",f);process.on("SIGINT",()=>process.exit(0));process.on("SIGTERM",()=>process.exit(0));async function Dr(){let r=new Tr().name(w.name).description(w.description).version(w.version||"1.0.0","-v, --version","display the version number");er(`RadianOS v${w.version}`),r.addCommand(X),r.addCommand(L),r.parse()}Dr(); //# sourceMappingURL=index.js.map