galaxy-design 0.2.1 → 0.2.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +44 -4
- package/dist/bin.js +1 -1
- package/dist/bin.js.map +1 -1
- package/dist/commands/add.js +1 -1
- package/dist/commands/add.js.map +1 -1
- package/dist/commands/init.js +8 -4
- package/dist/commands/init.js.map +1 -1
- package/dist/registries/registry-react.json +64 -4
- package/dist/utils/component-copier.js +34 -7
- package/dist/utils/component-copier.js.map +1 -1
- package/dist/utils/component-transformer.js +175 -0
- package/dist/utils/component-transformer.js.map +1 -0
- package/dist/utils/config-schema.js +43 -1
- package/dist/utils/config-schema.js.map +1 -1
- package/dist/utils/detect.js +8 -0
- package/dist/utils/detect.js.map +1 -1
- package/dist/utils/framework-registry.js +9 -2
- package/dist/utils/framework-registry.js.map +1 -1
- package/dist/utils/platform-detector.js +33 -1
- package/dist/utils/platform-detector.js.map +1 -1
- package/package.json +7 -3
package/README.md
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
# Galaxy UI CLI
|
|
2
2
|
|
|
3
|
-
A modern, framework-agnostic CLI tool for adding beautiful, accessible UI components to your projects. Inspired by shadcn/ui, but supporting React, Vue, and
|
|
3
|
+
A modern, framework-agnostic CLI tool for adding beautiful, accessible UI components to your projects. Inspired by shadcn/ui, but supporting React, Vue, Angular, Next.js, and Nuxt.js.
|
|
4
4
|
|
|
5
5
|
## 🌟 Features
|
|
6
6
|
|
|
7
|
-
- 🚀 **Multi-framework support**: React, Vue, and
|
|
7
|
+
- 🚀 **Multi-framework support**: React, Vue, Angular, Next.js, and Nuxt.js
|
|
8
8
|
- 📦 **41 production-ready components** across 8 categories
|
|
9
|
-
- 🎨 **Built with Radix UI primitives** (radix-ui for React, radix-vue for Vue, radix-ng for Angular)
|
|
9
|
+
- 🎨 **Built with Radix UI primitives** (radix-ui for React/Next.js, radix-vue for Vue/Nuxt.js, radix-ng for Angular)
|
|
10
10
|
- 🌙 **Dark mode support** out of the box
|
|
11
11
|
- 📱 **Responsive design** with mobile-first approach
|
|
12
12
|
- ♿ **Accessibility-focused** (WAI-ARIA compliant)
|
|
@@ -35,7 +35,7 @@ npx galaxy-design@latest init
|
|
|
35
35
|
|
|
36
36
|
This interactive command will:
|
|
37
37
|
|
|
38
|
-
- ✅ Detect your framework (React, Vue, or
|
|
38
|
+
- ✅ Detect your framework (React, Vue, Angular, Next.js, or Nuxt.js)
|
|
39
39
|
- ✅ Detect your package manager (npm, pnpm, yarn, or bun)
|
|
40
40
|
- ✅ Install required dependencies (lucide icons, clsx, tailwind-merge, radix primitives)
|
|
41
41
|
- ✅ Create component directory structure
|
|
@@ -183,6 +183,46 @@ import {InputComponent} from '@/components/ui/input';
|
|
|
183
183
|
export class MyComponent {}
|
|
184
184
|
```
|
|
185
185
|
|
|
186
|
+
### Next.js
|
|
187
|
+
|
|
188
|
+
```tsx
|
|
189
|
+
'use client'
|
|
190
|
+
|
|
191
|
+
import {Button} from '@/components/ui/button'
|
|
192
|
+
import {Input} from '@/components/ui/input'
|
|
193
|
+
|
|
194
|
+
export default function MyComponent() {
|
|
195
|
+
return (
|
|
196
|
+
<div>
|
|
197
|
+
<Button variant="default" size="lg">
|
|
198
|
+
Click me
|
|
199
|
+
</Button>
|
|
200
|
+
<Input placeholder="Enter text..." />
|
|
201
|
+
</div>
|
|
202
|
+
)
|
|
203
|
+
}
|
|
204
|
+
```
|
|
205
|
+
|
|
206
|
+
**Note:** Galaxy UI CLI automatically adds the `'use client'` directive to components that use client-side features (hooks, event handlers, browser APIs). Server-compatible components won't have this directive added.
|
|
207
|
+
|
|
208
|
+
### Nuxt.js
|
|
209
|
+
|
|
210
|
+
```vue
|
|
211
|
+
<script setup lang="ts">
|
|
212
|
+
import {Button} from '@/components/ui/button'
|
|
213
|
+
import {Input} from '@/components/ui/input'
|
|
214
|
+
</script>
|
|
215
|
+
|
|
216
|
+
<template>
|
|
217
|
+
<div>
|
|
218
|
+
<Button variant="default" size="lg">Click me</Button>
|
|
219
|
+
<Input placeholder="Enter text..." />
|
|
220
|
+
</div>
|
|
221
|
+
</template>
|
|
222
|
+
```
|
|
223
|
+
|
|
224
|
+
**Note:** Components work seamlessly with Nuxt 3's auto-import feature. Make sure to configure the `@/` alias in your `nuxt.config.ts`.
|
|
225
|
+
|
|
186
226
|
## ⚙️ Configuration
|
|
187
227
|
|
|
188
228
|
Galaxy UI stores configuration in `components.json` at your project root:
|
package/dist/bin.js
CHANGED
|
@@ -3,7 +3,7 @@ import { Command } from 'commander';
|
|
|
3
3
|
import { initCommand } from './commands/init.js';
|
|
4
4
|
import { addCommand } from './commands/add.js';
|
|
5
5
|
const program = new Command();
|
|
6
|
-
program.name('galaxy-
|
|
6
|
+
program.name('galaxy-design').description('CLI tool for Galaxy UI component library').version('0.2.2');
|
|
7
7
|
program.command('init').description('Initialize Galaxy UI in your project').option('-y, --yes', 'Skip prompts and use defaults').option('-c, --cwd <path>', 'Current working directory', process.cwd()).action(initCommand);
|
|
8
8
|
program.command('add').description('Add components to your project').argument('[components...]', 'Component names to add').option('-a, --all', 'Add all components').option('-c, --cwd <path>', 'Current working directory', process.cwd()).action(addCommand);
|
|
9
9
|
program.parse();
|
package/dist/bin.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/bin.ts"],"sourcesContent":["#!/usr/bin/env node\nimport { Command } from 'commander';\nimport { initCommand } from './commands/init.js';\nimport { addCommand } from './commands/add.js';\n\nconst program = new Command();\n\nprogram\n .name('galaxy-
|
|
1
|
+
{"version":3,"sources":["../src/bin.ts"],"sourcesContent":["#!/usr/bin/env node\nimport { Command } from 'commander';\nimport { initCommand } from './commands/init.js';\nimport { addCommand } from './commands/add.js';\n\nconst program = new Command();\n\nprogram\n .name('galaxy-design')\n .description('CLI tool for Galaxy UI component library')\n .version('0.2.2');\n\nprogram\n .command('init')\n .description('Initialize Galaxy UI in your project')\n .option('-y, --yes', 'Skip prompts and use defaults')\n .option('-c, --cwd <path>', 'Current working directory', process.cwd())\n .action(initCommand);\n\nprogram\n .command('add')\n .description('Add components to your project')\n .argument('[components...]', 'Component names to add')\n .option('-a, --all', 'Add all components')\n .option('-c, --cwd <path>', 'Current working directory', process.cwd())\n .action(addCommand);\n\nprogram.parse();\n"],"names":["Command","initCommand","addCommand","program","name","description","version","command","option","process","cwd","action","argument","parse"],"mappings":";AACA,SAASA,OAAO,QAAQ,YAAY;AACpC,SAASC,WAAW,QAAQ,qBAAqB;AACjD,SAASC,UAAU,QAAQ,oBAAoB;AAE/C,MAAMC,UAAU,IAAIH;AAEpBG,QACGC,IAAI,CAAC,iBACLC,WAAW,CAAC,4CACZC,OAAO,CAAC;AAEXH,QACGI,OAAO,CAAC,QACRF,WAAW,CAAC,wCACZG,MAAM,CAAC,aAAa,iCACpBA,MAAM,CAAC,oBAAoB,6BAA6BC,QAAQC,GAAG,IACnEC,MAAM,CAACV;AAEVE,QACGI,OAAO,CAAC,OACRF,WAAW,CAAC,kCACZO,QAAQ,CAAC,mBAAmB,0BAC5BJ,MAAM,CAAC,aAAa,sBACpBA,MAAM,CAAC,oBAAoB,6BAA6BC,QAAQC,GAAG,IACnEC,MAAM,CAACT;AAEVC,QAAQU,KAAK"}
|
package/dist/commands/add.js
CHANGED
|
@@ -15,7 +15,7 @@ export async function addCommand(components, options) {
|
|
|
15
15
|
// Check if components.json exists (new config system)
|
|
16
16
|
if (!hasComponentsConfig(cwd)) {
|
|
17
17
|
console.log(chalk.red('❌ Galaxy UI is not initialized in this project.'));
|
|
18
|
-
console.log(chalk.gray('Run') + chalk.cyan(' galaxy-
|
|
18
|
+
console.log(chalk.gray('Run') + chalk.cyan(' galaxy-design init ') + chalk.gray('first.'));
|
|
19
19
|
return;
|
|
20
20
|
}
|
|
21
21
|
// Load components.json configuration
|
package/dist/commands/add.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/commands/add.ts"],"sourcesContent":["import prompts from 'prompts';\nimport chalk from 'chalk';\nimport ora from 'ora';\nimport { resolve, join, dirname } from 'path';\nimport { existsSync } from 'fs';\nimport { fileURLToPath } from 'url';\nimport { loadConfig, configExists } from '../utils/config.js';\nimport {\n loadComponentsConfig,\n hasComponentsConfig,\n getFrameworkFromConfig,\n} from '../utils/components-config.js';\nimport {\n loadFrameworkRegistry,\n getFrameworkComponent,\n getFrameworkComponentDependencies,\n getAllFrameworkComponents,\n} from '../utils/framework-registry.js';\nimport { writeFile, fileExists, readFile, ensureDir } from '../utils/files.js';\nimport { installDependencies } from '../utils/package-manager.js';\nimport type { Framework } from '../utils/config-schema.js';\nimport { fetchFileFromGitHub, getComponentGitHubPath } from '../utils/github-fetcher.js';\n\nconst __filename = fileURLToPath(import.meta.url);\nconst __dirname = dirname(__filename);\n\ninterface AddOptions {\n all?: boolean;\n cwd: string;\n}\n\nexport async function addCommand(components: string[], options: AddOptions) {\n const cwd = options.cwd;\n\n // Check if components.json exists (new config system)\n if (!hasComponentsConfig(cwd)) {\n console.log(chalk.red('❌ Galaxy UI is not initialized in this project.'));\n console.log(chalk.gray('Run') + chalk.cyan(' galaxy-ui init ') + chalk.gray('first.'));\n return;\n }\n\n // Load components.json configuration\n const componentsConfig = loadComponentsConfig(cwd);\n if (!componentsConfig) {\n console.log(chalk.red('❌ Failed to load components.json configuration.'));\n return;\n }\n\n const framework = componentsConfig.framework;\n console.log(chalk.gray(`Framework detected: ${chalk.cyan(framework)}\\n`));\n\n // Load framework-specific registry\n const registry = loadFrameworkRegistry(framework);\n const allComponents = getAllFrameworkComponents(framework);\n\n // Determine which components to add\n let componentsToAdd: string[] = [];\n\n if (options.all) {\n // Add all components\n componentsToAdd = Object.keys(allComponents);\n } else if (components.length === 0) {\n // Interactive mode\n const choices = [];\n\n // Create choices organized by category\n const categories = new Map<string, any[]>();\n\n for (const [key, component] of Object.entries(allComponents)) {\n const category = component.category || 'other';\n if (!categories.has(category)) {\n categories.set(category, []);\n }\n categories.get(category)!.push({ key, component });\n }\n\n for (const [category, items] of categories) {\n choices.push({\n title: chalk.bold.cyan(category.charAt(0).toUpperCase() + category.slice(1)),\n value: `category:${category}`,\n disabled: true,\n });\n\n for (const { key, component } of items) {\n choices.push({\n title: ` ${component.name}`,\n description: component.description || '',\n value: key,\n });\n }\n }\n\n const response = await prompts({\n type: 'multiselect',\n name: 'components',\n message: 'Which components would you like to add?',\n choices,\n hint: '- Space to select. Return to submit',\n });\n\n if (!response.components || response.components.length === 0) {\n console.log(chalk.gray('No components selected.'));\n return;\n }\n\n componentsToAdd = response.components;\n } else {\n // Add specified components\n for (const input of components) {\n // Check if component exists in registry\n if (allComponents[input]) {\n componentsToAdd.push(input);\n } else {\n console.log(chalk.yellow(`⚠ Component \"${input}\" not found. Skipping.`));\n }\n }\n }\n\n if (componentsToAdd.length === 0) {\n console.log(chalk.yellow('No valid components to add.'));\n return;\n }\n\n // Remove duplicates\n componentsToAdd = [...new Set(componentsToAdd)];\n\n console.log(chalk.bold.cyan(`\\n📦 Adding ${componentsToAdd.length} component(s)...\\n`));\n\n // Collect all dependencies\n const allDependencies: string[] = [];\n const allDevDependencies: string[] = [];\n\n // Add each component\n const results: { name: string; success: boolean; path?: string; error?: string }[] = [];\n\n for (const componentKey of componentsToAdd) {\n const component = getFrameworkComponent(framework, componentKey);\n\n if (!component) {\n results.push({\n name: componentKey,\n success: false,\n error: 'Component not found in registry',\n });\n continue;\n }\n\n const spinner = ora(`Adding ${chalk.cyan(component.name)}...`).start();\n\n try {\n // Get component destination path from aliases\n const componentsAlias = componentsConfig.aliases.components;\n const destPath = componentsAlias.replace('@/', '');\n const fullDestPath = resolve(cwd, destPath, 'ui');\n ensureDir(fullDestPath);\n\n // Get file extension based on framework\n const fileExtensions: Record<Framework, string> = {\n vue: '.vue',\n react: '.tsx',\n angular: '.component.ts',\n 'react-native': '.tsx',\n flutter: '.dart',\n };\n const ext = fileExtensions[framework];\n\n // Create component folder\n const componentFolderPath = join(fullDestPath, componentKey);\n ensureDir(componentFolderPath);\n\n // Copy component files from GitHub\n for (const file of component.files) {\n const fileName = file.includes('/') ? file.split('/').pop()! : file;\n const destFilePath = join(componentFolderPath, fileName);\n\n // Check if file already exists\n if (fileExists(destFilePath)) {\n spinner.warn(\n `${chalk.cyan(component.name)} - File already exists: ${fileName}`\n );\n continue;\n }\n\n try {\n // Fetch file from GitHub\n const sourceFolder = component.type === 'block' ? 'blocks' : 'components';\n const githubPath = `packages/${framework}/src/${sourceFolder}/${componentKey}/${file}`;\n const content = await fetchFileFromGitHub(githubPath);\n writeFile(destFilePath, content);\n } catch (error) {\n // Try with capitalized file name\n try {\n const capitalizedFile = file.charAt(0).toUpperCase() + file.slice(1);\n const sourceFolder = component.type === 'block' ? 'blocks' : 'components';\n const githubPath = `packages/${framework}/src/${sourceFolder}/${componentKey}/${capitalizedFile}`;\n const content = await fetchFileFromGitHub(githubPath);\n writeFile(destFilePath, content);\n } catch (capitalizedError) {\n // If both attempts fail, write a placeholder\n const placeholderContent = `// ${component.name} component for ${framework}\\n// TODO: Failed to fetch component from GitHub: ${error instanceof Error ? error.message : 'Unknown error'}\\n`;\n writeFile(destFilePath, placeholderContent);\n spinner.warn(`${chalk.yellow('⚠')} Failed to fetch ${file} from GitHub, created placeholder`);\n }\n }\n }\n\n spinner.succeed(\n `${chalk.green('✓')} Added ${chalk.cyan(component.name)} to ${chalk.gray(\n destPath + '/ui/' + componentKey + '/'\n )}`\n );\n\n results.push({\n name: component.name,\n success: true,\n path: componentFolderPath,\n });\n\n // Collect dependencies\n const deps = getFrameworkComponentDependencies(framework, componentKey);\n allDependencies.push(...deps.dependencies);\n allDevDependencies.push(...deps.devDependencies);\n } catch (error) {\n spinner.fail(`Failed to add ${chalk.cyan(component.name)}`);\n results.push({\n name: component.name,\n success: false,\n error: error instanceof Error ? error.message : 'Unknown error',\n });\n }\n }\n\n // Install dependencies\n const uniqueDependencies = [...new Set(allDependencies)];\n const uniqueDevDependencies = [...new Set(allDevDependencies)];\n\n if (uniqueDependencies.length > 0 || uniqueDevDependencies.length > 0) {\n console.log('\\n');\n const installSpinner = ora('Installing dependencies...').start();\n\n try {\n if (uniqueDependencies.length > 0) {\n await installDependencies(uniqueDependencies, { cwd, dev: false, silent: true });\n }\n if (uniqueDevDependencies.length > 0) {\n await installDependencies(uniqueDevDependencies, { cwd, dev: true, silent: true });\n }\n installSpinner.succeed('Dependencies installed');\n } catch (error) {\n installSpinner.fail('Failed to install dependencies');\n console.log(chalk.yellow('Please install them manually:'));\n if (uniqueDependencies.length > 0) {\n console.log(chalk.gray(` npm install ${uniqueDependencies.join(' ')}`));\n }\n if (uniqueDevDependencies.length > 0) {\n console.log(chalk.gray(` npm install -D ${uniqueDevDependencies.join(' ')}`));\n }\n }\n }\n\n // Summary\n const successful = results.filter(r => r.success).length;\n const failed = results.filter(r => !r.success).length;\n\n console.log('\\n');\n\n if (successful > 0) {\n console.log(\n chalk.green.bold(`✓ Successfully added ${successful} component(s)`)\n );\n }\n\n if (failed > 0) {\n console.log(chalk.red.bold(`✗ Failed to add ${failed} component(s)`));\n for (const result of results.filter(r => !r.success)) {\n console.log(chalk.red(` - ${result.name}: ${result.error}`));\n }\n }\n\n // Next steps\n if (successful > 0) {\n console.log('\\n' + chalk.gray('Next steps:'));\n\n switch (framework) {\n case 'vue':\n console.log(chalk.gray(' 1. Import the components in your Vue component'));\n console.log(chalk.gray(' 2. Use them in your template'));\n break;\n case 'react':\n console.log(chalk.gray(' 1. Import the components in your React component'));\n console.log(chalk.gray(' 2. Use them in your JSX'));\n break;\n case 'angular':\n console.log(chalk.gray(' 1. Import the components in your Angular module or component'));\n console.log(chalk.gray(' 2. Use them in your templates'));\n break;\n }\n\n console.log(chalk.gray(' 3. Enjoy building with Galaxy UI! 🚀\\n'));\n }\n}\n"],"names":["prompts","chalk","ora","resolve","join","dirname","fileURLToPath","loadComponentsConfig","hasComponentsConfig","loadFrameworkRegistry","getFrameworkComponent","getFrameworkComponentDependencies","getAllFrameworkComponents","writeFile","fileExists","ensureDir","installDependencies","fetchFileFromGitHub","__filename","url","__dirname","addCommand","components","options","cwd","console","log","red","gray","cyan","componentsConfig","framework","registry","allComponents","componentsToAdd","all","Object","keys","length","choices","categories","Map","key","component","entries","category","has","set","get","push","items","title","bold","charAt","toUpperCase","slice","value","disabled","name","description","response","type","message","hint","input","yellow","Set","allDependencies","allDevDependencies","results","componentKey","success","error","spinner","start","componentsAlias","aliases","destPath","replace","fullDestPath","fileExtensions","vue","react","angular","flutter","ext","componentFolderPath","file","files","fileName","includes","split","pop","destFilePath","warn","sourceFolder","githubPath","content","capitalizedFile","capitalizedError","placeholderContent","Error","succeed","green","path","deps","dependencies","devDependencies","fail","uniqueDependencies","uniqueDevDependencies","installSpinner","dev","silent","successful","filter","r","failed","result"],"mappings":"AAAA,OAAOA,aAAa,UAAU;AAC9B,OAAOC,WAAW,QAAQ;AAC1B,OAAOC,SAAS,MAAM;AACtB,SAASC,OAAO,EAAEC,IAAI,EAAEC,OAAO,QAAQ,OAAO;AAE9C,SAASC,aAAa,QAAQ,MAAM;AAEpC,SACEC,oBAAoB,EACpBC,mBAAmB,QAEd,gCAAgC;AACvC,SACEC,qBAAqB,EACrBC,qBAAqB,EACrBC,iCAAiC,EACjCC,yBAAyB,QACpB,iCAAiC;AACxC,SAASC,SAAS,EAAEC,UAAU,EAAYC,SAAS,QAAQ,oBAAoB;AAC/E,SAASC,mBAAmB,QAAQ,8BAA8B;AAElE,SAASC,mBAAmB,QAAgC,6BAA6B;AAEzF,MAAMC,aAAaZ,cAAc,YAAYa,GAAG;AAChD,MAAMC,YAAYf,QAAQa;AAO1B,OAAO,eAAeG,WAAWC,UAAoB,EAAEC,OAAmB;IACxE,MAAMC,MAAMD,QAAQC,GAAG;IAEvB,sDAAsD;IACtD,IAAI,CAAChB,oBAAoBgB,MAAM;QAC7BC,QAAQC,GAAG,CAACzB,MAAM0B,GAAG,CAAC;QACtBF,QAAQC,GAAG,CAACzB,MAAM2B,IAAI,CAAC,SAAS3B,MAAM4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IACxD,MAAM+E,SAAShD,QAAQ8C,MAAM,CAACC,CAAAA,IAAK,CAACA,EAAE7C,OAAO,EAAEjC,MAAM;IAErDb,QAAQC,GAAG,CAAC;IAEZ,IAAIwF,aAAa,GAAG;QAClBzF,QAAQC,GAAG,CACTzB,MAAMsG,KAAK,CAACnD,IAAI,CAAC,CAAC,qBAAqB,EAAE8D,WAAW,aAAa,CAAC;IAEtE;IAEA,IAAIG,SAAS,GAAG;QACd5F,QAAQC,GAAG,CAACzB,MAAM0B,GAAG,CAACyB,IAAI,CAAC,CAAC,gBAAgB,EAAEiE,OAAO,aAAa,CAAC;QACnE,KAAK,MAAMC,UAAUjD,QAAQ8C,MAAM,CAACC,CAAAA,IAAK,CAACA,EAAE7C,OAAO,EAAG;YACpD9C,QAAQC,GAAG,CAACzB,MAAM0B,GAAG,CAAC,CAAC,IAAI,EAAE2F,OAAO5D,IAAI,CAAC,EAAE,EAAE4D,OAAO9C,KAAK,EAAE;QAC7D;IACF;IAEA,aAAa;IACb,IAAI0C,aAAa,GAAG;QAClBzF,QAAQC,GAAG,CAAC,OAAOzB,MAAM2B,IAAI,CAAC;QAE9B,OAAQG;YACN,KAAK;gBACHN,QAAQC,GAAG,CAACzB,MAAM2B,IAAI,CAAC;gBACvBH,QAAQC,GAAG,CAACzB,MAAM2B,IAAI,CAAC;gBACvB;YACF,KAAK;gBACHH,QAAQC,GAAG,CAACzB,MAAM2B,IAAI,CAAC;gBACvBH,QAAQC,GAAG,CAACzB,MAAM2B,IAAI,CAAC;gBACvB;YACF,KAAK;gBACHH,QAAQC,GAAG,CAACzB,MAAM2B,IAAI,CAAC;gBACvBH,QAAQC,GAAG,CAACzB,MAAM2B,IAAI,CAAC;gBACvB;QACJ;QAEAH,QAAQC,GAAG,CAACzB,MAAM2B,IAAI,CAAC;IACzB;AACF"}
|
|
1
|
+
{"version":3,"sources":["../../src/commands/add.ts"],"sourcesContent":["import prompts from 'prompts';\nimport chalk from 'chalk';\nimport ora from 'ora';\nimport { resolve, join, dirname } from 'path';\nimport { existsSync } from 'fs';\nimport { fileURLToPath } from 'url';\nimport { loadConfig, configExists } from '../utils/config.js';\nimport {\n loadComponentsConfig,\n hasComponentsConfig,\n getFrameworkFromConfig,\n} from '../utils/components-config.js';\nimport {\n loadFrameworkRegistry,\n getFrameworkComponent,\n getFrameworkComponentDependencies,\n getAllFrameworkComponents,\n} from '../utils/framework-registry.js';\nimport { writeFile, fileExists, readFile, ensureDir } from '../utils/files.js';\nimport { installDependencies } from '../utils/package-manager.js';\nimport type { Framework } from '../utils/config-schema.js';\nimport { fetchFileFromGitHub, getComponentGitHubPath } from '../utils/github-fetcher.js';\n\nconst __filename = fileURLToPath(import.meta.url);\nconst __dirname = dirname(__filename);\n\ninterface AddOptions {\n all?: boolean;\n cwd: string;\n}\n\nexport async function addCommand(components: string[], options: AddOptions) {\n const cwd = options.cwd;\n\n // Check if components.json exists (new config system)\n if (!hasComponentsConfig(cwd)) {\n console.log(chalk.red('❌ Galaxy UI is not initialized in this project.'));\n console.log(chalk.gray('Run') + chalk.cyan(' galaxy-design init ') + chalk.gray('first.'));\n return;\n }\n\n // Load components.json configuration\n const componentsConfig = loadComponentsConfig(cwd);\n if (!componentsConfig) {\n console.log(chalk.red('❌ Failed to load components.json configuration.'));\n return;\n }\n\n const framework = componentsConfig.framework;\n console.log(chalk.gray(`Framework detected: ${chalk.cyan(framework)}\\n`));\n\n // Load framework-specific registry\n const registry = loadFrameworkRegistry(framework);\n const allComponents = getAllFrameworkComponents(framework);\n\n // Determine which components to add\n let componentsToAdd: string[] = [];\n\n if (options.all) {\n // Add all components\n componentsToAdd = Object.keys(allComponents);\n } else if (components.length === 0) {\n // Interactive mode\n const choices = [];\n\n // Create choices organized by category\n const categories = new Map<string, any[]>();\n\n for (const [key, component] of Object.entries(allComponents)) {\n const category = component.category || 'other';\n if (!categories.has(category)) {\n categories.set(category, []);\n }\n categories.get(category)!.push({ key, component });\n }\n\n for (const [category, items] of categories) {\n choices.push({\n title: chalk.bold.cyan(category.charAt(0).toUpperCase() + category.slice(1)),\n value: `category:${category}`,\n disabled: true,\n });\n\n for (const { key, component } of items) {\n choices.push({\n title: ` ${component.name}`,\n description: component.description || '',\n value: key,\n });\n }\n }\n\n const response = await prompts({\n type: 'multiselect',\n name: 'components',\n message: 'Which components would you like to add?',\n choices,\n hint: '- Space to select. Return to submit',\n });\n\n if (!response.components || response.components.length === 0) {\n console.log(chalk.gray('No components selected.'));\n return;\n }\n\n componentsToAdd = response.components;\n } else {\n // Add specified components\n for (const input of components) {\n // Check if component exists in registry\n if (allComponents[input]) {\n componentsToAdd.push(input);\n } else {\n console.log(chalk.yellow(`⚠ Component \"${input}\" not found. Skipping.`));\n }\n }\n }\n\n if (componentsToAdd.length === 0) {\n console.log(chalk.yellow('No valid components to add.'));\n return;\n }\n\n // Remove duplicates\n componentsToAdd = [...new Set(componentsToAdd)];\n\n console.log(chalk.bold.cyan(`\\n📦 Adding ${componentsToAdd.length} component(s)...\\n`));\n\n // Collect all dependencies\n const allDependencies: string[] = [];\n const allDevDependencies: string[] = [];\n\n // Add each component\n const results: { name: string; success: boolean; path?: string; error?: string }[] = [];\n\n for (const componentKey of componentsToAdd) {\n const component = getFrameworkComponent(framework, componentKey);\n\n if (!component) {\n results.push({\n name: componentKey,\n success: false,\n error: 'Component not found in registry',\n });\n continue;\n }\n\n const spinner = ora(`Adding ${chalk.cyan(component.name)}...`).start();\n\n try {\n // Get component destination path from aliases\n const componentsAlias = componentsConfig.aliases.components;\n const destPath = componentsAlias.replace('@/', '');\n const fullDestPath = resolve(cwd, destPath, 'ui');\n ensureDir(fullDestPath);\n\n // Get file extension based on framework\n const fileExtensions: Record<Framework, string> = {\n vue: '.vue',\n react: '.tsx',\n angular: '.component.ts',\n 'react-native': '.tsx',\n flutter: '.dart',\n };\n const ext = fileExtensions[framework];\n\n // Create component folder\n const componentFolderPath = join(fullDestPath, componentKey);\n ensureDir(componentFolderPath);\n\n // Copy component files from GitHub\n for (const file of component.files) {\n const fileName = file.includes('/') ? file.split('/').pop()! : file;\n const destFilePath = join(componentFolderPath, fileName);\n\n // Check if file already exists\n if (fileExists(destFilePath)) {\n spinner.warn(\n `${chalk.cyan(component.name)} - File already exists: ${fileName}`\n );\n continue;\n }\n\n try {\n // Fetch file from GitHub\n const sourceFolder = component.type === 'block' ? 'blocks' : 'components';\n const githubPath = `packages/${framework}/src/${sourceFolder}/${componentKey}/${file}`;\n const content = await fetchFileFromGitHub(githubPath);\n writeFile(destFilePath, content);\n } catch (error) {\n // Try with capitalized file name\n try {\n const capitalizedFile = file.charAt(0).toUpperCase() + file.slice(1);\n const sourceFolder = component.type === 'block' ? 'blocks' : 'components';\n const githubPath = `packages/${framework}/src/${sourceFolder}/${componentKey}/${capitalizedFile}`;\n const content = await fetchFileFromGitHub(githubPath);\n writeFile(destFilePath, content);\n } catch (capitalizedError) {\n // If both attempts fail, write a placeholder\n const placeholderContent = `// ${component.name} component for ${framework}\\n// TODO: Failed to fetch component from GitHub: ${error instanceof Error ? error.message : 'Unknown error'}\\n`;\n writeFile(destFilePath, placeholderContent);\n spinner.warn(`${chalk.yellow('⚠')} Failed to fetch ${file} from GitHub, created placeholder`);\n }\n }\n }\n\n spinner.succeed(\n `${chalk.green('✓')} Added ${chalk.cyan(component.name)} to ${chalk.gray(\n destPath + '/ui/' + componentKey + '/'\n )}`\n );\n\n results.push({\n name: component.name,\n success: true,\n path: componentFolderPath,\n });\n\n // Collect dependencies\n const deps = getFrameworkComponentDependencies(framework, componentKey);\n allDependencies.push(...deps.dependencies);\n allDevDependencies.push(...deps.devDependencies);\n } catch (error) {\n spinner.fail(`Failed to add ${chalk.cyan(component.name)}`);\n results.push({\n name: component.name,\n success: false,\n error: error instanceof Error ? error.message : 'Unknown error',\n });\n }\n }\n\n // Install dependencies\n const uniqueDependencies = [...new Set(allDependencies)];\n const uniqueDevDependencies = [...new Set(allDevDependencies)];\n\n if (uniqueDependencies.length > 0 || uniqueDevDependencies.length > 0) {\n console.log('\\n');\n const installSpinner = ora('Installing dependencies...').start();\n\n try {\n if (uniqueDependencies.length > 0) {\n await installDependencies(uniqueDependencies, { cwd, dev: false, silent: true });\n }\n if (uniqueDevDependencies.length > 0) {\n await installDependencies(uniqueDevDependencies, { cwd, dev: true, silent: true });\n }\n installSpinner.succeed('Dependencies installed');\n } catch (error) {\n installSpinner.fail('Failed to install dependencies');\n console.log(chalk.yellow('Please install them manually:'));\n if (uniqueDependencies.length > 0) {\n console.log(chalk.gray(` npm install ${uniqueDependencies.join(' ')}`));\n }\n if (uniqueDevDependencies.length > 0) {\n console.log(chalk.gray(` npm install -D ${uniqueDevDependencies.join(' ')}`));\n }\n }\n }\n\n // Summary\n const successful = results.filter(r => r.success).length;\n const failed = results.filter(r => !r.success).length;\n\n console.log('\\n');\n\n if (successful > 0) {\n console.log(\n chalk.green.bold(`✓ Successfully added ${successful} component(s)`)\n );\n }\n\n if (failed > 0) {\n console.log(chalk.red.bold(`✗ Failed to add ${failed} component(s)`));\n for (const result of results.filter(r => !r.success)) {\n console.log(chalk.red(` - ${result.name}: ${result.error}`));\n }\n }\n\n // Next steps\n if (successful > 0) {\n console.log('\\n' + chalk.gray('Next steps:'));\n\n switch (framework) {\n case 'vue':\n console.log(chalk.gray(' 1. Import the components in your Vue component'));\n console.log(chalk.gray(' 2. Use them in your template'));\n break;\n case 'react':\n console.log(chalk.gray(' 1. Import the components in your React component'));\n console.log(chalk.gray(' 2. Use them in your JSX'));\n break;\n case 'angular':\n console.log(chalk.gray(' 1. Import the components in your Angular module or component'));\n console.log(chalk.gray(' 2. Use them in your templates'));\n break;\n }\n\n console.log(chalk.gray(' 3. Enjoy building with Galaxy UI! 🚀\\n'));\n }\n}\n"],"names":["prompts","chalk","ora","resolve","join","dirname","fileURLToPath","loadComponentsConfig","hasComponentsConfig","loadFrameworkRegistry","getFrameworkComponent","getFrameworkComponentDependencies","getAllFrameworkComponents","writeFile","fileExists","ensureDir","installDependencies","fetchFileFromGitHub","__filename","url","__dirname","addCommand","components","options","cwd","console","log","red","gray","cyan","componentsConfig","framework","registry","allComponents","componentsToAdd","all","Object","keys","length","choices","categories","Map","key","component","entries","category","has","set","get","push","items","title","bold","charAt","toUpperCase","slice","value","disabled","name","description","response","type","message","hint","input","yellow","Set","allDependencies","allDevDependencies","results","componentKey","success","error","spinner","start","componentsAlias","aliases","destPath","replace","fullDestPath","fileExtensions","vue","react","angular","flutter","ext","componentFolderPath","file","files","fileName","includes","split","pop","destFilePath","warn","sourceFolder","githubPath","content","capitalizedFile","capitalizedError","placeholderContent","Error","succeed","green","path","deps","dependencies","devDependencies","fail","uniqueDependencies","uniqueDevDependencies","installSpinner","dev","silent","successful","filter","r","failed","result"],"mappings":"AAAA,OAAOA,aAAa,UAAU;AAC9B,OAAOC,WAAW,QAAQ;AAC1B,OAAOC,SAAS,MAAM;AACtB,SAASC,OAAO,EAAEC,IAAI,EAAEC,OAAO,QAAQ,OAAO;AAE9C,SAASC,aAAa,QAAQ,MAAM;AAEpC,SACEC,oBAAoB,EACpBC,mBAAmB,QAEd,gCAAgC;AACvC,SACEC,qBAAqB,EACrBC,qBAAqB,EACrBC,iCAAiC,EACjCC,yBAAyB,QACpB,iCAAiC;AACxC,SAASC,SAAS,EAAEC,UAAU,EAAYC,SAAS,QAAQ,oBAAoB;AAC/E,SAASC,mBAAmB,QAAQ,8BAA8B;AAElE,SAASC,mBAAmB,QAAgC,6BAA6B;AAEzF,MAAMC,aAAaZ,cAAc,YAAYa,GAAG;AAChD,MAAMC,YAAYf,QAAQa;AAO1B,OAAO,eAAeG,WAAWC,UAAoB,EAAEC,OAAmB;IACxE,MAAMC,MAAMD,QAAQC,GAAG;IAEvB,sDAAsD;IACtD,IAAI,CAAChB,oBAAoBgB,MAAM;QAC7BC,QAAQC,GAAG,CAACzB,MAAM0B,GAAG,CAAC;QACtBF,QAAQC,GAAG,CAACzB,MAAM2B,IAAI,CAAC,SAAS3B,MAAM4B,IAAI,CAAC,0BAA0B5B,MAAM2B,IAAI,CA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CAAAA,IAAK,CAACA,EAAE7C,OAAO,EAAEjC,MAAM;IAErDb,QAAQC,GAAG,CAAC;IAEZ,IAAIwF,aAAa,GAAG;QAClBzF,QAAQC,GAAG,CACTzB,MAAMsG,KAAK,CAACnD,IAAI,CAAC,CAAC,qBAAqB,EAAE8D,WAAW,aAAa,CAAC;IAEtE;IAEA,IAAIG,SAAS,GAAG;QACd5F,QAAQC,GAAG,CAACzB,MAAM0B,GAAG,CAACyB,IAAI,CAAC,CAAC,gBAAgB,EAAEiE,OAAO,aAAa,CAAC;QACnE,KAAK,MAAMC,UAAUjD,QAAQ8C,MAAM,CAACC,CAAAA,IAAK,CAACA,EAAE7C,OAAO,EAAG;YACpD9C,QAAQC,GAAG,CAACzB,MAAM0B,GAAG,CAAC,CAAC,IAAI,EAAE2F,OAAO5D,IAAI,CAAC,EAAE,EAAE4D,OAAO9C,KAAK,EAAE;QAC7D;IACF;IAEA,aAAa;IACb,IAAI0C,aAAa,GAAG;QAClBzF,QAAQC,GAAG,CAAC,OAAOzB,MAAM2B,IAAI,CAAC;QAE9B,OAAQG;YACN,KAAK;gBACHN,QAAQC,GAAG,CAACzB,MAAM2B,IAAI,CAAC;gBACvBH,QAAQC,GAAG,CAACzB,MAAM2B,IAAI,CAAC;gBACvB;YACF,KAAK;gBACHH,QAAQC,GAAG,CAACzB,MAAM2B,IAAI,CAAC;gBACvBH,QAAQC,GAAG,CAACzB,MAAM2B,IAAI,CAAC;gBACvB;YACF,KAAK;gBACHH,QAAQC,GAAG,CAACzB,MAAM2B,IAAI,CAAC;gBACvBH,QAAQC,GAAG,CAACzB,MAAM2B,IAAI,CAAC;gBACvB;QACJ;QAEAH,QAAQC,GAAG,CAACzB,MAAM2B,IAAI,CAAC;IACzB;AACF"}
|
package/dist/commands/init.js
CHANGED
|
@@ -28,7 +28,7 @@ export async function initCommand(options) {
|
|
|
28
28
|
// Detect framework
|
|
29
29
|
const detectedFramework = detectFramework(cwd);
|
|
30
30
|
if (detectedFramework === 'unknown') {
|
|
31
|
-
console.log(chalk.red('❌ Could not detect framework. Please ensure you are in a valid Angular, React, Vue, React Native, or Flutter project.'));
|
|
31
|
+
console.log(chalk.red('❌ Could not detect framework. Please ensure you are in a valid Angular, React, Vue, Next.js, Nuxt.js, React Native, or Flutter project.'));
|
|
32
32
|
return;
|
|
33
33
|
}
|
|
34
34
|
console.log(chalk.green(`✓ Detected ${chalk.bold(detectedFramework)} framework`));
|
|
@@ -39,6 +39,8 @@ export async function initCommand(options) {
|
|
|
39
39
|
vue: 'vue',
|
|
40
40
|
'react-native': 'react-native',
|
|
41
41
|
flutter: 'flutter',
|
|
42
|
+
nextjs: 'nextjs',
|
|
43
|
+
nuxtjs: 'nuxtjs',
|
|
42
44
|
unknown: null
|
|
43
45
|
};
|
|
44
46
|
const framework = frameworkMap[detectedFramework];
|
|
@@ -153,6 +155,7 @@ export async function initCommand(options) {
|
|
|
153
155
|
// Framework-specific dependencies
|
|
154
156
|
switch(framework){
|
|
155
157
|
case 'vue':
|
|
158
|
+
case 'nuxtjs':
|
|
156
159
|
dependencies.push('radix-vue');
|
|
157
160
|
devDependencies.push('tailwindcss', 'autoprefixer', 'postcss');
|
|
158
161
|
if (config.iconLibrary === 'lucide') {
|
|
@@ -160,6 +163,7 @@ export async function initCommand(options) {
|
|
|
160
163
|
}
|
|
161
164
|
break;
|
|
162
165
|
case 'react':
|
|
166
|
+
case 'nextjs':
|
|
163
167
|
dependencies.push('@radix-ui/react-slot');
|
|
164
168
|
devDependencies.push('tailwindcss', 'autoprefixer', 'postcss');
|
|
165
169
|
if (config.iconLibrary === 'lucide') {
|
|
@@ -241,9 +245,9 @@ export async function initCommand(options) {
|
|
|
241
245
|
console.log(chalk.white(` 1. Configure Tailwind CSS in ${config.tailwind.config}`));
|
|
242
246
|
console.log(chalk.white(` 2. Import utilities in ${config.tailwind.css}`));
|
|
243
247
|
console.log(chalk.white(` 3. Add components:`));
|
|
244
|
-
console.log(chalk.gray(` galaxy-
|
|
245
|
-
console.log(chalk.gray(` galaxy-
|
|
246
|
-
console.log(chalk.gray(` galaxy-
|
|
248
|
+
console.log(chalk.gray(` galaxy-design add button`));
|
|
249
|
+
console.log(chalk.gray(` galaxy-design add input card`));
|
|
250
|
+
console.log(chalk.gray(` galaxy-design add --all\n`));
|
|
247
251
|
console.log(chalk.cyan('Learn more:'));
|
|
248
252
|
console.log(chalk.white(' Documentation: https://galaxy-design.vercel.app'));
|
|
249
253
|
console.log(chalk.white(' GitHub: https://github.com/buikevin/galaxy-design\n'));
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/commands/init.ts"],"sourcesContent":["import prompts from 'prompts';\nimport chalk from 'chalk';\nimport ora from 'ora';\nimport {\n detectFramework,\n detectPackageManager,\n type Framework as DetectedFramework,\n} from '../utils/detect.js';\nimport {\n createComponentsConfig,\n hasComponentsConfig,\n loadComponentsConfig,\n type Framework,\n} from '../utils/components-config.js';\nimport {\n getDefaultConfig,\n type BaseColor,\n type IconLibrary,\n} from '../utils/config-schema.js';\nimport { writeFile, ensureDir } from '../utils/files.js';\nimport { installDependencies } from '../utils/package-manager.js';\nimport { resolve } from 'path';\n\ninterface InitOptions {\n yes?: boolean;\n cwd: string;\n}\n\nexport async function initCommand(options: InitOptions) {\n console.log(chalk.bold.cyan('\\n🌌 Galaxy UI CLI - Multi-Framework Edition\\n'));\n\n const cwd = options.cwd;\n\n // Check if already initialized\n if (hasComponentsConfig(cwd)) {\n console.log(chalk.yellow('⚠ components.json already exists in this project.'));\n const { overwrite } = await prompts({\n type: 'confirm',\n name: 'overwrite',\n message: 'Do you want to overwrite the existing configuration?',\n initial: false,\n });\n\n if (!overwrite) {\n console.log(chalk.gray('Initialization cancelled.'));\n return;\n }\n }\n\n // Detect framework\n const detectedFramework = detectFramework(cwd);\n\n if (detectedFramework === 'unknown') {\n console.log(\n chalk.red(\n '❌ Could not detect framework. Please ensure you are in a valid Angular, React, Vue, React Native, or Flutter project.'\n )\n );\n return;\n }\n\n console.log(chalk.green(`✓ Detected ${chalk.bold(detectedFramework)} framework`));\n\n // Map detected framework to Framework type\n const frameworkMap: Record<DetectedFramework, Framework | null> = {\n angular: 'angular',\n react: 'react',\n vue: 'vue',\n 'react-native': 'react-native',\n flutter: 'flutter',\n unknown: null,\n };\n\n const framework = frameworkMap[detectedFramework];\n if (!framework) {\n console.log(chalk.red('❌ Unsupported framework detected.'));\n return;\n }\n\n // Detect package manager\n const packageManager = detectPackageManager(cwd);\n console.log(chalk.green(`✓ Using ${chalk.bold(packageManager)} package manager`));\n\n // Get configuration from user (or use defaults with --yes)\n let config = getDefaultConfig(framework);\n\n if (!options.yes) {\n console.log(chalk.cyan('\\n📝 Configuration\\n'));\n\n // Build prompts based on framework\n const promptQuestions: any[] = [];\n\n // TypeScript prompt (not for Flutter)\n if (framework !== 'flutter') {\n promptQuestions.push({\n type: 'toggle',\n name: 'typescript',\n message: 'Would you like to use TypeScript?',\n initial: true,\n active: 'yes',\n inactive: 'no',\n });\n }\n\n // Base color prompt (for all frameworks)\n promptQuestions.push({\n type: 'select',\n name: 'baseColor',\n message: 'Which base color would you like to use?',\n choices: [\n { title: 'Slate', value: 'slate' },\n { title: 'Gray', value: 'gray' },\n { title: 'Zinc', value: 'zinc' },\n { title: 'Neutral', value: 'neutral' },\n { title: 'Stone', value: 'stone' },\n ],\n initial: 0,\n });\n\n // Icon library prompt (not for Flutter - uses built-in icons)\n if (framework !== 'flutter') {\n promptQuestions.push({\n type: 'select',\n name: 'iconLibrary',\n message: 'Which icon library would you like to use?',\n choices: [\n { title: 'Lucide (Recommended)', value: 'lucide' },\n { title: 'Heroicons', value: 'heroicons' },\n { title: 'Radix Icons', value: 'radix-icons' },\n ],\n initial: 0,\n });\n }\n\n // CSS file prompt (only for web frameworks and React Native)\n if (framework !== 'flutter' && config.tailwind.css) {\n promptQuestions.push({\n type: 'text',\n name: 'cssFile',\n message: framework === 'react-native'\n ? 'Where is your global CSS file (for NativeWind)?'\n : 'Where is your global CSS file?',\n initial: config.tailwind.css,\n });\n }\n\n const answers = await prompts(promptQuestions);\n\n if (Object.keys(answers).length === 0) {\n console.log(chalk.gray('Initialization cancelled.'));\n return;\n }\n\n // Update config with user choices\n config = {\n ...config,\n typescript: answers.typescript ?? config.typescript,\n iconLibrary: (answers.iconLibrary as IconLibrary) ?? config.iconLibrary,\n tailwind: {\n ...config.tailwind,\n baseColor: (answers.baseColor as BaseColor) ?? config.tailwind.baseColor,\n css: answers.cssFile ?? config.tailwind.css,\n },\n };\n }\n\n console.log(chalk.cyan('\\n📦 Installing dependencies...\\n'));\n\n // Install dependencies\n const spinner = ora('Installing dependencies...').start();\n\n const dependencies: string[] = [];\n const devDependencies: string[] = [];\n\n // Common dependencies\n dependencies.push('clsx', 'tailwind-merge');\n\n // Framework-specific dependencies\n switch (framework) {\n case 'vue':\n dependencies.push('radix-vue');\n devDependencies.push('tailwindcss', 'autoprefixer', 'postcss');\n if (config.iconLibrary === 'lucide') {\n dependencies.push('lucide-vue-next');\n }\n break;\n\n case 'react':\n dependencies.push('@radix-ui/react-slot');\n devDependencies.push('tailwindcss', 'autoprefixer', 'postcss');\n if (config.iconLibrary === 'lucide') {\n dependencies.push('lucide-react');\n }\n if (config.typescript) {\n devDependencies.push('@types/react', '@types/react-dom');\n }\n break;\n\n case 'angular':\n // Angular components use Radix NG primitives\n dependencies.push('@radix-ng/primitives');\n if (config.iconLibrary === 'lucide') {\n dependencies.push('lucide-angular');\n }\n break;\n }\n\n try {\n // Install dependencies\n if (dependencies.length > 0) {\n await installDependencies(dependencies, {\n cwd,\n silent: true,\n });\n }\n\n // Install devDependencies\n if (devDependencies.length > 0) {\n await installDependencies(devDependencies, {\n cwd,\n dev: true,\n silent: true,\n });\n }\n\n spinner.succeed('Dependencies installed');\n } catch (error) {\n spinner.fail('Failed to install dependencies');\n console.error(chalk.red(error));\n return;\n }\n\n // Create directories\n const dirSpinner = ora('Creating directories...').start();\n\n try {\n const componentsPath = resolve(cwd, config.aliases.components.replace('@/', ''));\n const utilsPath = resolve(cwd, config.aliases.utils.replace('@/', ''));\n\n await ensureDir(componentsPath);\n await ensureDir(resolve(componentsPath, 'ui'));\n await ensureDir(utilsPath.replace('/utils', '')); // Create lib dir\n\n dirSpinner.succeed('Directories created');\n } catch (error) {\n dirSpinner.fail('Failed to create directories');\n console.error(chalk.red(error));\n return;\n }\n\n // Create utils file\n const utilsSpinner = ora('Creating utility functions...').start();\n\n try {\n const utilsPath = resolve(cwd, config.aliases.utils.replace('@/', '') + '.ts');\n const utilsContent = getUtilsContent();\n writeFile(utilsPath, utilsContent);\n\n utilsSpinner.succeed('Utility functions created');\n } catch (error) {\n utilsSpinner.fail('Failed to create utility functions');\n console.error(chalk.red(error));\n return;\n }\n\n // Save components.json\n const configSpinner = ora('Creating components.json...').start();\n\n try {\n createComponentsConfig(cwd, framework);\n configSpinner.succeed('components.json created');\n } catch (error) {\n configSpinner.fail('Failed to create components.json');\n console.error(chalk.red(error));\n return;\n }\n\n // Success message\n console.log(chalk.green('\\n✨ Success! Galaxy UI has been initialized.\\n'));\n console.log(chalk.cyan('Next steps:\\n'));\n console.log(chalk.white(` 1. Configure Tailwind CSS in ${config.tailwind.config}`));\n console.log(chalk.white(` 2. Import utilities in ${config.tailwind.css}`));\n console.log(chalk.white(` 3. Add components:`));\n console.log(chalk.gray(` galaxy-ui add button`));\n console.log(chalk.gray(` galaxy-ui add input card`));\n console.log(chalk.gray(` galaxy-ui add --all\\n`));\n\n console.log(chalk.cyan('Learn more:'));\n console.log(chalk.white(' Documentation: https://galaxy-design.vercel.app'));\n console.log(chalk.white(' GitHub: https://github.com/buikevin/galaxy-design\\n'));\n}\n\n/**\n * Get utils.ts content\n */\nfunction getUtilsContent(): string {\n return `import { clsx, type ClassValue } from 'clsx';\nimport { twMerge } from 'tailwind-merge';\n\n/**\n * Merge Tailwind CSS classes\n */\nexport function cn(...inputs: ClassValue[]) {\n return twMerge(clsx(inputs));\n}\n`;\n}\n"],"names":["prompts","chalk","ora","detectFramework","detectPackageManager","createComponentsConfig","hasComponentsConfig","getDefaultConfig","writeFile","ensureDir","installDependencies","resolve","initCommand","options","console","log","bold","cyan","cwd","yellow","overwrite","type","name","message","initial","gray","detectedFramework","red","green","frameworkMap","angular","react","vue","flutter","unknown","framework","packageManager","config","yes","promptQuestions","push","active","inactive","choices","title","value","tailwind","css","answers","Object","keys","length","typescript","iconLibrary","baseColor","cssFile","spinner","start","dependencies","devDependencies","silent","dev","succeed","error","fail","dirSpinner","componentsPath","aliases","components","replace","utilsPath","utils","utilsSpinner","utilsContent","getUtilsContent","configSpinner","white"],"mappings":";AAAA,OAAOA,aAAa,UAAU;AAC9B,OAAOC,WAAW,QAAQ;AAC1B,OAAOC,SAAS,MAAM;AACtB,SACEC,eAAe,EACfC,oBAAoB,QAEf,qBAAqB;AAC5B,SACEC,sBAAsB,EACtBC,mBAAmB,QAGd,gCAAgC;AACvC,SACEC,gBAAgB,QAGX,4BAA4B;AACnC,SAASC,SAAS,EAAEC,SAAS,QAAQ,oBAAoB;AACzD,SAASC,mBAAmB,QAAQ,8BAA8B;AAClE,SAASC,OAAO,QAAQ,OAAO;AAO/B,OAAO,eAAeC,YAAYC,OAAoB;IACpDC,QAAQC,GAAG,CAACd,MAAMe,IAAI,CAACC,IAAI,CAAC;IAE5B,MAAMC,MAAML,QAAQK,GAAG;IAEvB,+BAA+B;IAC/B,IAAIZ,oBAAoBY,MAAM;QAC5BJ,QAAQC,GAAG,CAACd,MAAMkB,MAAM,CAAC;QACzB,MAAM,EAAEC,SAAS,EAAE,GAAG,MAAMpB,QAAQ;YAClCqB,MAAM;YACNC,MAAM;YACNC,SAAS;YACTC,SAAS;QACX;QAEA,IAAI,CAACJ,WAAW;YACdN,QAAQC,GAAG,CAACd,MAAMwB,IAAI,CAAC;YACvB;QACF;IACF;IAEA,mBAAmB;IACnB,MAAMC,oBAAoBvB,gBAAgBe;IAE1C,IAAIQ,sBAAsB,WAAW;QACnCZ,QAAQC,GAAG,CACTd,MAAM0B,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AAQC,GAAG,CAACd,MAAM2E,KAAK,CAAC,CAAC,oBAAoB,CAAC;IAC9C9D,QAAQC,GAAG,CAACd,MAAMwB,IAAI,CAAC,CAAC,yBAAyB,CAAC;IAClDX,QAAQC,GAAG,CAACd,MAAMwB,IAAI,CAAC,CAAC,6BAA6B,CAAC;IACtDX,QAAQC,GAAG,CAACd,MAAMwB,IAAI,CAAC,CAAC,0BAA0B,CAAC;IAEnDX,QAAQC,GAAG,CAACd,MAAMgB,IAAI,CAAC;IACvBH,QAAQC,GAAG,CAACd,MAAM2E,KAAK,CAAC;IACxB9D,QAAQC,GAAG,CAACd,MAAM2E,KAAK,CAAC;AAC1B;AAEA;;CAEC,GACD,SAASF;IACP,OAAO,CAAC;;;;;;;;;AASV,CAAC;AACD"}
|
|
1
|
+
{"version":3,"sources":["../../src/commands/init.ts"],"sourcesContent":["import prompts from 'prompts';\nimport chalk from 'chalk';\nimport ora from 'ora';\nimport {\n detectFramework,\n detectPackageManager,\n type Framework as DetectedFramework,\n} from '../utils/detect.js';\nimport {\n createComponentsConfig,\n hasComponentsConfig,\n loadComponentsConfig,\n type Framework,\n} from '../utils/components-config.js';\nimport {\n getDefaultConfig,\n type BaseColor,\n type IconLibrary,\n} from '../utils/config-schema.js';\nimport { writeFile, ensureDir } from '../utils/files.js';\nimport { installDependencies } from '../utils/package-manager.js';\nimport { resolve } from 'path';\n\ninterface InitOptions {\n yes?: boolean;\n cwd: string;\n}\n\nexport async function initCommand(options: InitOptions) {\n console.log(chalk.bold.cyan('\\n🌌 Galaxy UI CLI - Multi-Framework Edition\\n'));\n\n const cwd = options.cwd;\n\n // Check if already initialized\n if (hasComponentsConfig(cwd)) {\n console.log(chalk.yellow('⚠ components.json already exists in this project.'));\n const { overwrite } = await prompts({\n type: 'confirm',\n name: 'overwrite',\n message: 'Do you want to overwrite the existing configuration?',\n initial: false,\n });\n\n if (!overwrite) {\n console.log(chalk.gray('Initialization cancelled.'));\n return;\n }\n }\n\n // Detect framework\n const detectedFramework = detectFramework(cwd);\n\n if (detectedFramework === 'unknown') {\n console.log(\n chalk.red(\n '❌ Could not detect framework. Please ensure you are in a valid Angular, React, Vue, Next.js, Nuxt.js, React Native, or Flutter project.'\n )\n );\n return;\n }\n\n console.log(chalk.green(`✓ Detected ${chalk.bold(detectedFramework)} framework`));\n\n // Map detected framework to Framework type\n const frameworkMap: Record<DetectedFramework, Framework | null> = {\n angular: 'angular',\n react: 'react',\n vue: 'vue',\n 'react-native': 'react-native',\n flutter: 'flutter',\n nextjs: 'nextjs',\n nuxtjs: 'nuxtjs',\n unknown: null,\n };\n\n const framework = frameworkMap[detectedFramework];\n if (!framework) {\n console.log(chalk.red('❌ Unsupported framework detected.'));\n return;\n }\n\n // Detect package manager\n const packageManager = detectPackageManager(cwd);\n console.log(chalk.green(`✓ Using ${chalk.bold(packageManager)} package manager`));\n\n // Get configuration from user (or use defaults with --yes)\n let config = getDefaultConfig(framework);\n\n if (!options.yes) {\n console.log(chalk.cyan('\\n📝 Configuration\\n'));\n\n // Build prompts based on framework\n const promptQuestions: any[] = [];\n\n // TypeScript prompt (not for Flutter)\n if (framework !== 'flutter') {\n promptQuestions.push({\n type: 'toggle',\n name: 'typescript',\n message: 'Would you like to use TypeScript?',\n initial: true,\n active: 'yes',\n inactive: 'no',\n });\n }\n\n // Base color prompt (for all frameworks)\n promptQuestions.push({\n type: 'select',\n name: 'baseColor',\n message: 'Which base color would you like to use?',\n choices: [\n { title: 'Slate', value: 'slate' },\n { title: 'Gray', value: 'gray' },\n { title: 'Zinc', value: 'zinc' },\n { title: 'Neutral', value: 'neutral' },\n { title: 'Stone', value: 'stone' },\n ],\n initial: 0,\n });\n\n // Icon library prompt (not for Flutter - uses built-in icons)\n if (framework !== 'flutter') {\n promptQuestions.push({\n type: 'select',\n name: 'iconLibrary',\n message: 'Which icon library would you like to use?',\n choices: [\n { title: 'Lucide (Recommended)', value: 'lucide' },\n { title: 'Heroicons', value: 'heroicons' },\n { title: 'Radix Icons', value: 'radix-icons' },\n ],\n initial: 0,\n });\n }\n\n // CSS file prompt (only for web frameworks and React Native)\n if (framework !== 'flutter' && config.tailwind.css) {\n promptQuestions.push({\n type: 'text',\n name: 'cssFile',\n message: framework === 'react-native'\n ? 'Where is your global CSS file (for NativeWind)?'\n : 'Where is your global CSS file?',\n initial: config.tailwind.css,\n });\n }\n\n const answers = await prompts(promptQuestions);\n\n if (Object.keys(answers).length === 0) {\n console.log(chalk.gray('Initialization cancelled.'));\n return;\n }\n\n // Update config with user choices\n config = {\n ...config,\n typescript: answers.typescript ?? config.typescript,\n iconLibrary: (answers.iconLibrary as IconLibrary) ?? config.iconLibrary,\n tailwind: {\n ...config.tailwind,\n baseColor: (answers.baseColor as BaseColor) ?? config.tailwind.baseColor,\n css: answers.cssFile ?? config.tailwind.css,\n },\n };\n }\n\n console.log(chalk.cyan('\\n📦 Installing dependencies...\\n'));\n\n // Install dependencies\n const spinner = ora('Installing dependencies...').start();\n\n const dependencies: string[] = [];\n const devDependencies: string[] = [];\n\n // Common dependencies\n dependencies.push('clsx', 'tailwind-merge');\n\n // Framework-specific dependencies\n switch (framework) {\n case 'vue':\n case 'nuxtjs':\n dependencies.push('radix-vue');\n devDependencies.push('tailwindcss', 'autoprefixer', 'postcss');\n if (config.iconLibrary === 'lucide') {\n dependencies.push('lucide-vue-next');\n }\n break;\n\n case 'react':\n case 'nextjs':\n dependencies.push('@radix-ui/react-slot');\n devDependencies.push('tailwindcss', 'autoprefixer', 'postcss');\n if (config.iconLibrary === 'lucide') {\n dependencies.push('lucide-react');\n }\n if (config.typescript) {\n devDependencies.push('@types/react', '@types/react-dom');\n }\n break;\n\n case 'angular':\n // Angular components use Radix NG primitives\n dependencies.push('@radix-ng/primitives');\n if (config.iconLibrary === 'lucide') {\n dependencies.push('lucide-angular');\n }\n break;\n }\n\n try {\n // Install dependencies\n if (dependencies.length > 0) {\n await installDependencies(dependencies, {\n cwd,\n silent: true,\n });\n }\n\n // Install devDependencies\n if (devDependencies.length > 0) {\n await installDependencies(devDependencies, {\n cwd,\n dev: true,\n silent: true,\n });\n }\n\n spinner.succeed('Dependencies installed');\n } catch (error) {\n spinner.fail('Failed to install dependencies');\n console.error(chalk.red(error));\n return;\n }\n\n // Create directories\n const dirSpinner = ora('Creating directories...').start();\n\n try {\n const componentsPath = resolve(cwd, config.aliases.components.replace('@/', ''));\n const utilsPath = resolve(cwd, config.aliases.utils.replace('@/', ''));\n\n await ensureDir(componentsPath);\n await ensureDir(resolve(componentsPath, 'ui'));\n await ensureDir(utilsPath.replace('/utils', '')); // Create lib dir\n\n dirSpinner.succeed('Directories created');\n } catch (error) {\n dirSpinner.fail('Failed to create directories');\n console.error(chalk.red(error));\n return;\n }\n\n // Create utils file\n const utilsSpinner = ora('Creating utility functions...').start();\n\n try {\n const utilsPath = resolve(cwd, config.aliases.utils.replace('@/', '') + '.ts');\n const utilsContent = getUtilsContent();\n writeFile(utilsPath, utilsContent);\n\n utilsSpinner.succeed('Utility functions created');\n } catch (error) {\n utilsSpinner.fail('Failed to create utility functions');\n console.error(chalk.red(error));\n return;\n }\n\n // Save components.json\n const configSpinner = ora('Creating components.json...').start();\n\n try {\n createComponentsConfig(cwd, framework);\n configSpinner.succeed('components.json created');\n } catch (error) {\n configSpinner.fail('Failed to create components.json');\n console.error(chalk.red(error));\n return;\n }\n\n // Success message\n console.log(chalk.green('\\n✨ Success! Galaxy UI has been initialized.\\n'));\n console.log(chalk.cyan('Next steps:\\n'));\n console.log(chalk.white(` 1. Configure Tailwind CSS in ${config.tailwind.config}`));\n console.log(chalk.white(` 2. Import utilities in ${config.tailwind.css}`));\n console.log(chalk.white(` 3. Add components:`));\n console.log(chalk.gray(` galaxy-design add button`));\n console.log(chalk.gray(` galaxy-design add input card`));\n console.log(chalk.gray(` galaxy-design add --all\\n`));\n\n console.log(chalk.cyan('Learn more:'));\n console.log(chalk.white(' Documentation: https://galaxy-design.vercel.app'));\n console.log(chalk.white(' GitHub: https://github.com/buikevin/galaxy-design\\n'));\n}\n\n/**\n * Get utils.ts content\n */\nfunction getUtilsContent(): string {\n return `import { clsx, type ClassValue } from 'clsx';\nimport { twMerge } from 'tailwind-merge';\n\n/**\n * Merge Tailwind CSS classes\n */\nexport function cn(...inputs: ClassValue[]) {\n return twMerge(clsx(inputs));\n}\n`;\n}\n"],"names":["prompts","chalk","ora","detectFramework","detectPackageManager","createComponentsConfig","hasComponentsConfig","getDefaultConfig","writeFile","ensureDir","installDependencies","resolve","initCommand","options","console","log","bold","cyan","cwd","yellow","overwrite","type","name","message","initial","gray","detectedFramework","red","green","frameworkMap","angular","react","vue","flutter","nextjs","nuxtjs","unknown","framework","packageManager","config","yes","promptQuestions","push","active","inactive","choices","title","value","tailwind","css","answers","Object","keys","length","typescript","iconLibrary","baseColor","cssFile","spinner","start","dependencies","devDependencies","silent","dev","succeed","error","fail","dirSpinner","componentsPath","aliases","components","replace","utilsPath","utils","utilsSpinner","utilsContent","getUtilsContent","configSpinner","white"],"mappings":";AAAA,OAAOA,aAAa,UAAU;AAC9B,OAAOC,WAAW,QAAQ;AAC1B,OAAOC,SAAS,MAAM;AACtB,SACEC,eAAe,EACfC,oBAAoB,QAEf,qBAAqB;AAC5B,SACEC,sBAAsB,EACtBC,mBAAmB,QAGd,gCAAgC;AACvC,SACEC,gBAAgB,QAGX,4BAA4B;AACnC,SAASC,SAAS,EAAEC,SAAS,QAAQ,oBAAoB;AACzD,SAASC,mBAAmB,QAAQ,8BAA8B;AAClE,SAASC,OAAO,QAAQ,OAAO;AAO/B,OAAO,eAAeC,YAAYC,OAAoB;IACpDC,QAAQC,GAAG,CAACd,MAAMe,IAAI,CAACC,IAAI,CAAC;IAE5B,MAAMC,MAAML,QAAQK,GAAG;IAEvB,+BAA+B;IAC/B,IAAIZ,oBAAoBY,MAAM;QAC5BJ,QAAQC,GAAG,CAACd,MAAMkB,MAAM,CAAC;QACzB,MAAM,EAAEC,SAAS,EAAE,GAAG,MAAMpB,QAAQ;YAClCqB,MAAM;YACNC,MAAM;YAC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AAK,CAAC;IACxBd,QAAQC,GAAG,CAACd,MAAMgB,IAAI,CAAC;IACvBH,QAAQC,GAAG,CAACd,MAAM6E,KAAK,CAAC,CAAC,+BAA+B,EAAEvC,OAAOS,QAAQ,CAACT,MAAM,EAAE;IAClFzB,QAAQC,GAAG,CAACd,MAAM6E,KAAK,CAAC,CAAC,yBAAyB,EAAEvC,OAAOS,QAAQ,CAACC,GAAG,EAAE;IACzEnC,QAAQC,GAAG,CAACd,MAAM6E,KAAK,CAAC,CAAC,oBAAoB,CAAC;IAC9ChE,QAAQC,GAAG,CAACd,MAAMwB,IAAI,CAAC,CAAC,6BAA6B,CAAC;IACtDX,QAAQC,GAAG,CAACd,MAAMwB,IAAI,CAAC,CAAC,iCAAiC,CAAC;IAC1DX,QAAQC,GAAG,CAACd,MAAMwB,IAAI,CAAC,CAAC,8BAA8B,CAAC;IAEvDX,QAAQC,GAAG,CAACd,MAAMgB,IAAI,CAAC;IACvBH,QAAQC,GAAG,CAACd,MAAM6E,KAAK,CAAC;IACxBhE,QAAQC,GAAG,CAACd,MAAM6E,KAAK,CAAC;AAC1B;AAEA;;CAEC,GACD,SAASF;IACP,OAAO,CAAC;;;;;;;;;AASV,CAAC;AACD"}
|
|
@@ -92,6 +92,16 @@
|
|
|
92
92
|
"files": ["Textarea.tsx", "index.ts"],
|
|
93
93
|
"category": "form"
|
|
94
94
|
},
|
|
95
|
+
"form": {
|
|
96
|
+
"name": "Form",
|
|
97
|
+
"type": "form",
|
|
98
|
+
"description": "Building forms with React Hook Form and Zod validation",
|
|
99
|
+
"dependencies": ["react-hook-form", "@hookform/resolvers", "zod"],
|
|
100
|
+
"devDependencies": [],
|
|
101
|
+
"registryDependencies": ["button", "input", "label"],
|
|
102
|
+
"files": ["Form.tsx", "index.ts"],
|
|
103
|
+
"category": "form"
|
|
104
|
+
},
|
|
95
105
|
"separator": {
|
|
96
106
|
"name": "Separator",
|
|
97
107
|
"type": "layout",
|
|
@@ -142,6 +152,16 @@
|
|
|
142
152
|
"files": ["Collapsible.tsx", "index.ts"],
|
|
143
153
|
"category": "layout"
|
|
144
154
|
},
|
|
155
|
+
"card": {
|
|
156
|
+
"name": "Card",
|
|
157
|
+
"type": "layout",
|
|
158
|
+
"description": "Displays a card with header, content, and footer",
|
|
159
|
+
"dependencies": [],
|
|
160
|
+
"devDependencies": [],
|
|
161
|
+
"registryDependencies": [],
|
|
162
|
+
"files": ["Card.tsx", "index.ts"],
|
|
163
|
+
"category": "layout"
|
|
164
|
+
},
|
|
145
165
|
"alert-dialog": {
|
|
146
166
|
"name": "Alert Dialog",
|
|
147
167
|
"type": "feedback",
|
|
@@ -152,6 +172,16 @@
|
|
|
152
172
|
"files": ["AlertDialog.tsx", "index.ts"],
|
|
153
173
|
"category": "feedback"
|
|
154
174
|
},
|
|
175
|
+
"alert": {
|
|
176
|
+
"name": "Alert",
|
|
177
|
+
"type": "feedback",
|
|
178
|
+
"description": "Displays a callout for user attention",
|
|
179
|
+
"dependencies": [],
|
|
180
|
+
"devDependencies": [],
|
|
181
|
+
"registryDependencies": [],
|
|
182
|
+
"files": ["Alert.tsx", "index.ts"],
|
|
183
|
+
"category": "feedback"
|
|
184
|
+
},
|
|
155
185
|
"progress": {
|
|
156
186
|
"name": "Progress",
|
|
157
187
|
"type": "feedback",
|
|
@@ -202,6 +232,16 @@
|
|
|
202
232
|
"files": ["NavigationMenu.tsx", "index.ts"],
|
|
203
233
|
"category": "navigation"
|
|
204
234
|
},
|
|
235
|
+
"breadcrumb": {
|
|
236
|
+
"name": "Breadcrumb",
|
|
237
|
+
"type": "navigation",
|
|
238
|
+
"description": "Displays the path to the current resource using a hierarchy of links",
|
|
239
|
+
"dependencies": [],
|
|
240
|
+
"devDependencies": [],
|
|
241
|
+
"registryDependencies": [],
|
|
242
|
+
"files": ["Breadcrumb.tsx", "index.ts"],
|
|
243
|
+
"category": "navigation"
|
|
244
|
+
},
|
|
205
245
|
"menubar": {
|
|
206
246
|
"name": "Menubar",
|
|
207
247
|
"type": "navigation",
|
|
@@ -392,6 +432,26 @@
|
|
|
392
432
|
"files": ["Skeleton.tsx", "index.ts"],
|
|
393
433
|
"category": "feedback"
|
|
394
434
|
},
|
|
435
|
+
"badge": {
|
|
436
|
+
"name": "Badge",
|
|
437
|
+
"type": "feedback",
|
|
438
|
+
"description": "Displays a badge or a component that looks like a badge",
|
|
439
|
+
"dependencies": [],
|
|
440
|
+
"devDependencies": [],
|
|
441
|
+
"registryDependencies": [],
|
|
442
|
+
"files": ["Badge.tsx", "index.ts"],
|
|
443
|
+
"category": "feedback"
|
|
444
|
+
},
|
|
445
|
+
"toast": {
|
|
446
|
+
"name": "Toast",
|
|
447
|
+
"type": "feedback",
|
|
448
|
+
"description": "A succinct message that is displayed temporarily",
|
|
449
|
+
"dependencies": ["@radix-ui/react-toast"],
|
|
450
|
+
"devDependencies": [],
|
|
451
|
+
"registryDependencies": [],
|
|
452
|
+
"files": ["Toast.tsx", "Toaster.tsx", "index.ts"],
|
|
453
|
+
"category": "feedback"
|
|
454
|
+
},
|
|
395
455
|
"kbd": {
|
|
396
456
|
"name": "Kbd",
|
|
397
457
|
"type": "data-display",
|
|
@@ -496,11 +556,11 @@
|
|
|
496
556
|
"groups": {
|
|
497
557
|
"form": {
|
|
498
558
|
"name": "Form Components",
|
|
499
|
-
"components": ["button", "input", "label", "select", "checkbox", "radio-group", "switch", "slider", "textarea", "calendar", "calendar-range", "tags-input"]
|
|
559
|
+
"components": ["button", "input", "label", "select", "checkbox", "radio-group", "switch", "slider", "textarea", "form", "calendar", "calendar-range", "tags-input"]
|
|
500
560
|
},
|
|
501
561
|
"layout": {
|
|
502
562
|
"name": "Layout Components",
|
|
503
|
-
"components": ["separator", "accordion", "tabs", "dialog", "collapsible", "scroll-area", "aspect-ratio", "resizable", "sheet", "toolbar"]
|
|
563
|
+
"components": ["card", "separator", "accordion", "tabs", "dialog", "collapsible", "scroll-area", "aspect-ratio", "resizable", "sheet", "toolbar"]
|
|
504
564
|
},
|
|
505
565
|
"interactive": {
|
|
506
566
|
"name": "Interactive Components",
|
|
@@ -508,7 +568,7 @@
|
|
|
508
568
|
},
|
|
509
569
|
"feedback": {
|
|
510
570
|
"name": "Feedback Components",
|
|
511
|
-
"components": ["alert-dialog", "progress", "empty", "skeleton"]
|
|
571
|
+
"components": ["alert-dialog", "alert", "progress", "empty", "skeleton", "badge", "toast"]
|
|
512
572
|
},
|
|
513
573
|
"data-display": {
|
|
514
574
|
"name": "Data Display Components",
|
|
@@ -516,7 +576,7 @@
|
|
|
516
576
|
},
|
|
517
577
|
"navigation": {
|
|
518
578
|
"name": "Navigation Components",
|
|
519
|
-
"components": ["dropdown-menu", "navigation-menu", "menubar", "context-menu", "popover", "tooltip", "pagination", "command"]
|
|
579
|
+
"components": ["dropdown-menu", "navigation-menu", "breadcrumb", "menubar", "context-menu", "popover", "tooltip", "pagination", "command"]
|
|
520
580
|
},
|
|
521
581
|
"charts": {
|
|
522
582
|
"name": "Chart Components",
|
|
@@ -1,8 +1,9 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { existsSync, mkdirSync, readFileSync, writeFileSync } from 'fs';
|
|
2
2
|
import { dirname, join, relative } from 'path';
|
|
3
3
|
import { getComponentSourceDir, isMobilePlatform } from './platform-detector';
|
|
4
4
|
import { getComponent, validateComponentDependencies } from './registry-loader';
|
|
5
5
|
import { fetchAndSaveFile, getComponentGitHubPath } from './github-fetcher';
|
|
6
|
+
import { transformComponent } from './component-transformer';
|
|
6
7
|
/**
|
|
7
8
|
* Copy a component to target project
|
|
8
9
|
*
|
|
@@ -55,6 +56,7 @@ import { fetchAndSaveFile, getComponentGitHubPath } from './github-fetcher';
|
|
|
55
56
|
}
|
|
56
57
|
// Copy file - from GitHub or local
|
|
57
58
|
try {
|
|
59
|
+
let fileContent;
|
|
58
60
|
if (useGitHub) {
|
|
59
61
|
// Fetch from GitHub
|
|
60
62
|
const githubPath = getComponentGitHubPath(options.platform, componentName, file);
|
|
@@ -63,6 +65,8 @@ import { fetchAndSaveFile, getComponentGitHubPath } from './github-fetcher';
|
|
|
63
65
|
result.errors.push(`Failed to fetch ${file} from GitHub`);
|
|
64
66
|
continue;
|
|
65
67
|
}
|
|
68
|
+
// Read the fetched content for transformation
|
|
69
|
+
fileContent = readFileSync(targetFile, 'utf-8');
|
|
66
70
|
} else {
|
|
67
71
|
// Copy from local packages directory (for development)
|
|
68
72
|
const packagesDir = options.packagesDir;
|
|
@@ -73,7 +77,20 @@ import { fetchAndSaveFile, getComponentGitHubPath } from './github-fetcher';
|
|
|
73
77
|
result.errors.push(`Source file not found: ${sourceFile}`);
|
|
74
78
|
continue;
|
|
75
79
|
}
|
|
76
|
-
|
|
80
|
+
fileContent = readFileSync(sourceFile, 'utf-8');
|
|
81
|
+
}
|
|
82
|
+
// Transform component if needed (Next.js, Nuxt.js)
|
|
83
|
+
const transformResult = transformComponent(fileContent, {
|
|
84
|
+
platform: options.platform,
|
|
85
|
+
componentName,
|
|
86
|
+
filePath: targetFile
|
|
87
|
+
});
|
|
88
|
+
// Write the transformed content
|
|
89
|
+
writeFileSync(targetFile, transformResult.content, 'utf-8');
|
|
90
|
+
// Log transformation notes if modified
|
|
91
|
+
if (transformResult.modified && transformResult.notes.length > 0) {
|
|
92
|
+
// Store notes for later display (optional)
|
|
93
|
+
console.log(` 📝 ${file}: ${transformResult.notes.join(', ')}`);
|
|
77
94
|
}
|
|
78
95
|
result.filesCopied.push(relative(options.targetDir, targetFile));
|
|
79
96
|
} catch (error) {
|
|
@@ -119,11 +136,19 @@ import { fetchAndSaveFile, getComponentGitHubPath } from './github-fetcher';
|
|
|
119
136
|
// Flutter: lib/components
|
|
120
137
|
return join(projectRoot, 'lib', 'components');
|
|
121
138
|
case 'vue':
|
|
122
|
-
|
|
123
|
-
|
|
139
|
+
case 'nuxtjs':
|
|
140
|
+
// Vue/Nuxt: src/components or components
|
|
141
|
+
if (existsSync(join(projectRoot, 'src'))) {
|
|
142
|
+
return join(projectRoot, 'src', 'components');
|
|
143
|
+
}
|
|
144
|
+
return join(projectRoot, 'components');
|
|
124
145
|
case 'react':
|
|
125
|
-
|
|
126
|
-
|
|
146
|
+
case 'nextjs':
|
|
147
|
+
// React/Next.js: src/components or components
|
|
148
|
+
if (existsSync(join(projectRoot, 'src'))) {
|
|
149
|
+
return join(projectRoot, 'src', 'components');
|
|
150
|
+
}
|
|
151
|
+
return join(projectRoot, 'components');
|
|
127
152
|
case 'angular':
|
|
128
153
|
// Angular: src/components or components
|
|
129
154
|
if (existsSync(join(projectRoot, 'src', 'app'))) {
|
|
@@ -151,12 +176,14 @@ import { fetchAndSaveFile, getComponentGitHubPath } from './github-fetcher';
|
|
|
151
176
|
switch(platform){
|
|
152
177
|
case 'react-native':
|
|
153
178
|
case 'react':
|
|
179
|
+
case 'nextjs':
|
|
154
180
|
// TypeScript/JSX import
|
|
155
|
-
return `import { ${exports.join(', ')} } from '
|
|
181
|
+
return `import { ${exports.join(', ')} } from '@/components/${componentName}';`;
|
|
156
182
|
case 'flutter':
|
|
157
183
|
// Dart import
|
|
158
184
|
return `import 'package:your_app/components/${componentName}/${componentName.replace(/-/g, '_')}.dart';`;
|
|
159
185
|
case 'vue':
|
|
186
|
+
case 'nuxtjs':
|
|
160
187
|
// Vue import
|
|
161
188
|
return `import { ${exports.join(', ')} } from '@/components/${componentName}';`;
|
|
162
189
|
case 'angular':
|