MCPcopy Create free account
hub / github.com/DavidHDev/react-bits / generateCliCommands

Function generateCliCommands

src/utils/cli.js:17–54  ·  view source on GitHub ↗
(language, style, category, subcategory, dependencies = '')

Source from the content-addressed store, hash-verified

15};
16
17export 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};

Callers 2

generateExportCodeFunction · 0.90
CliInstallationFunction · 0.90

Calls 2

variantForShadcnFunction · 0.85
slugToComponentNameFunction · 0.85

Tested by

no test coverage detected