UNPKG

radianos

Version:

add components to your project

540 lines (455 loc) 28.9 kB
#!/usr/bin/env node var w={name:"radianos",version:"1.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:[],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","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 Or}from"commander";import{Command as ur}from"commander";import{execa as hr}from"execa";import S from"fs-extra";import R from"path";import _ from"prompts";import{z as h}from"zod";import F from"fs-extra";import B from"path";import c from"chalk";var i={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},zr={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 er}from"cosmiconfig";import{z as I}from"zod";var tr=er("components"),nr=I.object({useSrcDir:I.boolean(),alias:I.string().optional()});async function A(r=process.cwd()){try{let o=await tr.search(r);return o?nr.parse(o):null}catch(o){throw new Error(`Error loading components.json configuration: ${o instanceof Error?o.message:"Unknown error"}`)}}var N=async r=>{if(!F.existsSync(r.cwd)||!F.existsSync(B.resolve(r.cwd,"package.json")))return{config:null};if(!F.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: ${i.info("npx radianos init")}`);try{return await A(r.cwd)}catch{throw new Error(`An invalid ${i.info("components.json")} file was found at ${i.info(r.cwd)}. Before you can add components, you must create a valid ${i.info("components.json")} file by running the ${i.info("init")} command.`)}};import ir from"fs-extra";import{detect as ar}from"package-manager-detector";import sr from"path";var b=async r=>{let o=sr.resolve(r);if(!ir.existsSync(o))throw new Error(`The path "${o}" does not exist.`);return await ar({cwd:o})};var M=async r=>{let o=await b(r);if(!o)return null;switch(o.name){case"npm":return"install";case"pnpm":return"install";case"bun":return"add";case"yarn":return"add";default:return null}};import v from"fast-glob";import P from"fs-extra";import O from"path";import{loadConfig as cr}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:(...r)=>{console.log(i.success(r.join(" ")))},info:(...r)=>{console.log(i.info(r.join(" ")))},warn:(...r)=>{console.log(i.warning(r.join(" ")))},error:(...r)=>{console.log(i.error(r.join(" ")))},log:(...r)=>{console.log(i.dark(r.join("")))},break:()=>{console.log("")}};var k=["**/node_modules/**","dist","build",".next","public"];var j=async r=>{let[o,e,t,n,s,p]=await Promise.all([lr(r),P.pathExists(O.resolve(r,"src")),dr(r),mr(r),pr(r),fr(r)]),m=await P.pathExists(O.resolve(r,`${e?"src/":""}app`)),f={framework:x.manual,hasSrcDir:e,isRSC:!1,isTsx:t,tailwindConfigFile:n,tailwindCssFile:s,aliasPrefix:p};return o?.startsWith("next.config.")?(f.framework=m?x["next-app"]:x["next-pages"],f.isRSC=m,f):(o?.startsWith("vite.config.")&&(f.framework=x.vite),f)},lr=async r=>{let o=await v.glob("**/{next,vite}.config.*",{cwd:r,deep:3,ignore:k});return o.length?o[0]:null},mr=async r=>{let o=await v.glob("tailwind.config.*",{cwd:r,deep:3,ignore:k});return o.length?o[0]:null},pr=async r=>{let o=await v.glob(["**/*.css","**/*.scss"],{cwd:r,deep:5,ignore:k});if(!o.length)return null;for(let e of o){let t=await P.readFile(O.resolve(r,e),"utf-8");if(t.includes('@import "tailwindcss"')||t.includes("@import 'tailwindcss'"))return e}return null};var dr=async r=>(await v.glob("tsconfig.*",{cwd:r,deep:1,ignore:k})).length>0,fr=async r=>{let o=cr(r);if(o.resultType==="failed"||!o.paths)return null;for(let[e,t]of Object.entries(o.paths))if(t.includes("./*")||t.includes("./src/*")||t.includes("./app/*")||t.includes("./resources/js/*/"))return e.at(0)??null;return null};function d(r){typeof r=="string"&&(a.break(),a.error(r),a.break(),process.exit(1)),r instanceof Error&&(a.break(),a.error(r.message),a.break(),process.exit(1)),a.error("Something went wrong. Please try again."),process.exit(1)}var W="https://radianos.com/api/components",C=async()=>{try{let r=await fetch(W);if(!r.ok){let e=`Failed to fetch data from ${W}. Status: ${r.status} - ${r.statusText}`;throw new Error(e)}return await r.json()}catch(r){d(r)}};import gr from"ora";function l(r,o){return gr({text:r,isSilent:o?.silent})}var yr=h.object({components:h.array(h.string()).optional(),cwd:h.string(),yes:h.boolean(),all:h.boolean(),overwrite:h.boolean(),silent:h.boolean()}),L=new ur().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,o)=>{try{let e=yr.parse({components:r,cwd:R.resolve(o.cwd),...o});if(await N(e),!e.components?.length){let s=await wr(e);s.length||(a.warn("No components selected. Exiting."),process.exit(1)),e.components=s}let t=await br(e.components),n=await G(await C(),t);await xr(n,e,await j(e.cwd))}catch(e){d(e)}});async function wr(r){try{let o=(await C()).map(t=>t.name);if(r.all)return o;if(r.components?.length)return r.components;let{components:e}=await _({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:o.map(t=>({title:t,value:t,selected:r.components?.includes(t)}))});return e}catch{d(new Error("Failed to fetch available components."))}}var br=async r=>{let o=l("Checking registry").start(),e=(await C()).map(n=>n.name),t=r.filter(n=>!e.includes(n));return t.length>0&&(o.fail("Checking registry. Not found:"),t.forEach(n=>a.info(`- ${n}`)),process.exit(1)),o.succeed(),r};async function xr(r,o,e){let t=e.hasSrcDir;await vr(r,o);let n=[],s=[],p=[];for(let m of r)for(let f of m.files){let y=R.join(o.cwd,t?"src":"",f.dir,f.name),z=await S.exists(y);if(z&&!o.overwrite){let{overwrite:rr}=await _({type:"confirm",name:"overwrite",message:`Component ${i.info(f.name)} already exists.Would you like to overwrite?`,initial:!1});if(!rr){p.push(y);continue}}let D=R.dirname(y);await S.exists(D)||await S.mkdir(D,{recursive:!0}),await S.writeFile(y,f.content),z?s.push(y):n.push(y)}o.silent||(n.length>0&&(a.break(),a.info(`Created ${n.length} file(s):`),n.forEach(m=>a.log(` - ${m}`))),s.length>0&&(a.break(),a.info(`Updated ${s.length} file(s):`),s.forEach(m=>a.log(` - ${m}`))),p.length>0&&(a.break(),a.info(`Skipped ${p.length} file(s):`),p.forEach(m=>a.log(` - ${m}`))))}async function vr(r,o){let e=new Set;for(let n of r)n.dependencies?.length&&n.dependencies.forEach(s=>e.add(s));if(!e.size)return;let t=Array.from(e);try{let n=l("Installing the dependencies",{silent:o.silent}).start();await hr((await b(o.cwd)).name,["install","--legacy-peer-deps",...t],{cwd:o.cwd,stdio:"ignore"}),n.succeed()}catch(n){d(new Error(`Failed to install dependencies: ${n.message}`))}}async function G(r,o){let e=[];for(let t of o){let n=r.find(s=>s.name===t);if(n&&(e.push(n),n.registryDependencies)){let s=await G(r,n.registryDependencies);e.push(...s)}}return e.filter((t,n,s)=>s.findIndex(p=>p.name===t.name)===n)}import{Command as jr}from"commander";import{execa as Cr}from"execa";import g from"fs-extra";import u from"path";import K from"prompts";import E from"zod";import $ from"fs-extra";import V from"path";var U=async r=>{if(!$.existsSync(r.cwd)||!$.existsSync(V.resolve(r.cwd,"package.json")))return{projectInfo:null};let o=l("Preflight checks",{silent:!1}).start();if($.existsSync(V.resolve(r.cwd,"components.json")))throw o.fail(),new Error(`The ${i.info("components.json")} file already exists at ${i.info(r.cwd)}. To start over, remove the ${i.info("components.json")} file and run ${i.info("init")} command again`);o.succeed("Before init checks completed");let e=l("Detecting framework",{silent:!1}).start(),t=await j(r.cwd);if((!t||t?.framework.name==="manual")&&(e?.fail(),t?.framework.link.installation))throw new Error(`We could not detect a supported framework at ${i.info(r.cwd)}. Visit ${i.info(t?.framework.link.installation)} to manually configure your project. Once configured, you can use the cli to add components.`);e?.succeed(`Detecting framework. Detected ${i.info(t.framework.label)}.`);let n=l("Verifying tailwind configuration",{silent:!1}).start();if(!t.tailwindCssFile)throw n?.fail(),new Error(`We could not find a Tailwind at ${i.info(r.cwd)}. Make sure you have a Tailwind installed your project. Visit ${i.info("https://tailwindcss.com/docs/installation")} to get started.`);n?.succeed("Verifying tailwind configuration. Found Tailwind configuration.");let s=l("Validating import alias",{silent:!1}).start();if(!t.aliasPrefix)throw s.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 s.succeed(`Validating import alias. Found import alias prefix: ${i.info(t.aliasPrefix)}.`),{projectInfo:t}};import{execa as kr}from"execa";var T=async(r,o,e)=>{if(!o.length)return;let n=(await b(r)).name,s=await M(r),p=l("Installing dependencies",{silent:e}).start();try{await kr(n,[s,"--legacy-peer-deps",...o],{cwd:r,stdio:"ignore"}),p.succeed()}catch{p.fail(),d("Failed to install dependencies.")}};var H=`import { clsx, type ClassValue } from "clsx"; import { twMerge } from "tailwind-merge"; export function cn(...inputs: ClassValue[]) { return twMerge(clsx(inputs.filter(Boolean))); } `;var J=`@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 Y=["tailwindcss-animate","class-variance-authority","clsx","tailwind-merge","lucide-react"],Sr=E.object({cwd:E.string(),yes:E.boolean(),defaultConfigurations:E.boolean()}),q=new jr().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 o=Sr.parse(r);await Er(o),a.break(),a.info(`${i.success("Success!")} Project initialization completed. You may now add components.`),a.break()}catch(o){d(o)}}),Q=async(r,o)=>{try{let e=o?u.join(r,"src","app"):u.join(r,"app");if(!g.existsSync(e))throw new Error(`Could not find 'app' directory at the expected path: ${e}`);let t=u.join(e,"globals.css");await g.writeFile(t,J,"utf-8")}catch(e){throw new Error(`Failed to create 'globals.css'${e.message}`)}},X=async(r,o)=>{try{let e=o?u.join(r,"src"):r,t=u.join(e,"lib");await g.ensureDir(t);let n=u.join(t,"utils.ts");await g.writeFile(n,H,"utf8")}catch(e){throw new Error(`Failed to create utils.ts: ${e}`)}};var Er=async r=>{let o=await U(r);if(!o.projectInfo){(await K({type:"confirm",name:"confirmNewProject",message:`The path ${i.bold(i.info(r.cwd))} does't contain a package.json file. Would you like to create a new ${i.bold(i.info("Next.js"))} project?`,initial:!1})).confirmNewProject||process.exit();let{projectPath:m}=await Fr({cwd:r.cwd});r.cwd=m;return}let{hasSrcDir:e}=o.projectInfo,t=l("Writing components.json file").start(),n=u.resolve(r.cwd,"components.json");await g.writeFile(n,JSON.stringify({hasSrcDir:e},null,2),"utf8"),t.succeed();let s=l("Setting up project configuration").start();await X(r.cwd,e),await Q(r.cwd,e),s.succeed("Project configuration completed"),await T(`${r.cwd}`,Y)},Ir=async()=>{let{projectName:r,useSrcDir:o}=await K([{type:"text",name:"projectName",message:"What would you like to name your project?",initial:"my-app",format:e=>e.trim(),validate:e=>e.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:o}},Fr=async r=>{try{let{projectName:o,useSrcDir:e}=await Ir(),t=u.join(r.cwd,o);try{await g.access(r.cwd,g.constants.W_OK)}catch{a.break(),a.error(`The path ${i.info(r.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(g.existsSync(t))throw new Error(`A project with the name ${o} already exists in the current directory.`);let n=l(`Creating a new ${i.bold(i.info("Next.js"))} project. This might take some time.`).start();await Cr("npx",["create-next-app","--tailwind","--eslint","--typescript","--app",o,"--use-npm",e?"--src-dir":"--no-src-dir","--yes"],{cwd:r.cwd,stdio:"ignore"}),n.succeed();let s=l("Writing components.json file").start(),p=u.resolve(t,"components.json");await g.writeFile(p,JSON.stringify({hasSrcDir:e},null,2),"utf8"),s.succeed();let m=l("Setting up project configuration").start();return await X(t,e),await Q(t,e),m.succeed(),await T(`${t}`,Y),{projectPath:t,projectName:o}}catch(o){d(o)}};import{instagram as Pr}from"gradient-string";var Z=r=>{a.break(),a.log(Pr(r)),a.break()};process.on("uncaughtException",d);process.on("unhandledRejection",d);process.on("SIGINT",()=>process.exit(0));process.on("SIGTERM",()=>process.exit(0));async function Rr(){let r=new Or().name(w.name).description(w.description).version(w.version||"1.0.0","-v, --version","display the version number");Z(`RadianOS v${w.version}`),r.addCommand(q),r.addCommand(L),r.parse()}Rr(); //# sourceMappingURL=index.js.map