(language, style, category, subcategory, dependencies = '')
| 15 | }; |
| 16 | |
| 17 | export const generateCliCommands = (language, style, category, subcategory, dependencies = '') => { |
| 18 | if (!category || !subcategory) return null; |
| 19 | |
| 20 | const shadcnVariant = variantForShadcn(language, style); |
| 21 | |
| 22 | const componentName = slugToComponentName(subcategory); |
| 23 | const baseUrl = 'https://reactbits.dev'; |
| 24 | |
| 25 | const jsrepoUrl = `${baseUrl}/r/${componentName}-${shadcnVariant}`; |
| 26 | const shadcnUrl = `@react-bits/${componentName}-${shadcnVariant}`; |
| 27 | |
| 28 | const prefixCommands = { |
| 29 | pnpm: 'pnpm dlx', |
| 30 | npx: 'npx', |
| 31 | yarn: 'yarn', |
| 32 | bun: 'bun x --bun' |
| 33 | }; |
| 34 | |
| 35 | const jsrepo = Object.fromEntries( |
| 36 | Object.entries(prefixCommands).map(([mgr, prefix]) => [mgr, `${prefix} jsrepo@latest add ${jsrepoUrl}`]) |
| 37 | ); |
| 38 | |
| 39 | const shadcn = Object.fromEntries( |
| 40 | Object.entries(prefixCommands).map(([mgr, prefix]) => [mgr, `${prefix} shadcn@latest add ${shadcnUrl}`]) |
| 41 | ); |
| 42 | |
| 43 | const depsString = typeof dependencies === 'string' ? dependencies.trim() : ''; |
| 44 | const manual = depsString |
| 45 | ? { |
| 46 | pnpm: `pnpm add ${depsString}`, |
| 47 | npm: `npm install ${depsString}`, |
| 48 | yarn: `yarn add ${depsString}`, |
| 49 | bun: `bun add ${depsString}` |
| 50 | } |
| 51 | : null; |
| 52 | |
| 53 | return { manual, jsrepo, shadcn }; |
| 54 | }; |
no test coverage detected