uikki 1.0.0

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.
Files changed (2) hide show
  1. package/index.js +98 -0
  2. package/package.json +19 -0
package/index.js ADDED
@@ -0,0 +1,98 @@
1
+ #!/usr/bin/env node
2
+
3
+ const https = require('https');
4
+ const fs = require('fs');
5
+ const path = require('path');
6
+
7
+ const args = process.argv.slice(2);
8
+
9
+ if (args.length === 0 || args[0] !== 'add') {
10
+ console.log(`
11
+ πŸš€ Uikki CLI
12
+ μ‚¬μš©λ²•: npx uikki add <category>/<component-name>
13
+ μ˜ˆμ‹œ: npx uikki add ui/button
14
+ `);
15
+ process.exit(1);
16
+ }
17
+
18
+ const rawPath = args[1]; // e.g., button or ui/button
19
+ if (!rawPath) {
20
+ console.error("❌ μ»΄ν¬λ„ŒνŠΈ 이름을 μž…λ ₯ν•΄μ£Όμ„Έμš”. (예: npx uikki add button)");
21
+ process.exit(1);
22
+ }
23
+
24
+ let category = 'ui';
25
+ let componentName = rawPath;
26
+
27
+ if (rawPath.includes('/')) {
28
+ [category, componentName] = rawPath.split('/');
29
+ }
30
+
31
+ // Convert kebab-case to PascalCase
32
+ const toPascalCase = (str) =>
33
+ str
34
+ .split('-')
35
+ .map((word) => word.charAt(0).toUpperCase() + word.slice(1))
36
+ .join('');
37
+
38
+ const pascalName = toPascalCase(componentName);
39
+ const fileName = `Custom${pascalName}.tsx`;
40
+
41
+ // GitHub Raw URL (dev branch)
42
+ const repoUrl = `https://raw.githubusercontent.com/dmswl6310/Uikki-uikki/dev/src/data/components/${category}/${componentName}/${fileName}`;
43
+
44
+ const targetDir = path.join(process.cwd(), 'src', 'components', category);
45
+ const targetPath = path.join(targetDir, `${pascalName}.tsx`);
46
+
47
+ console.log(`⬇️ '${componentName}' μ»΄ν¬λ„ŒνŠΈλ₯Ό κ°€μ Έμ˜€λŠ” 쀑...`);
48
+
49
+ https.get(repoUrl, (res) => {
50
+ if (res.statusCode === 404) {
51
+ console.error(`❌ μ»΄ν¬λ„ŒνŠΈλ₯Ό 찾을 수 μ—†μŠ΅λ‹ˆλ‹€: ${category}/${componentName}`);
52
+ process.exit(1);
53
+ }
54
+
55
+ if (res.statusCode !== 200) {
56
+ console.error(`❌ λ„€νŠΈμ›Œν¬ μ—λŸ¬ λ°œμƒ: ${res.statusCode}`);
57
+ process.exit(1);
58
+ }
59
+
60
+ let data = '';
61
+
62
+ res.on('data', (chunk) => {
63
+ data += chunk;
64
+ });
65
+
66
+ res.on('end', () => {
67
+ // 1. Create directory if not exists
68
+ if (!fs.existsSync(targetDir)) {
69
+ fs.mkdirSync(targetDir, { recursive: true });
70
+ }
71
+
72
+ // 2. Clean up code slightly (Remove export type CustomAvatarProps and rename to Avatar)
73
+ let cleanedCode = data;
74
+ // We can replace 'CustomAvatar' with 'Avatar' to make it cleaner for the consumer
75
+ const regexCustom = new RegExp(`Custom${pascalName}`, 'g');
76
+ cleanedCode = cleanedCode.replace(regexCustom, pascalName);
77
+
78
+ // 3. Write to file
79
+ fs.writeFileSync(targetPath, cleanedCode);
80
+
81
+ console.log(`βœ… μ„±κ³΅μ μœΌλ‘œ μΆ”κ°€λ˜μ—ˆμŠ΅λ‹ˆλ‹€: ${targetPath}`);
82
+
83
+ // Check for common dependencies (heuristics)
84
+ const deps = [];
85
+ if (cleanedCode.includes('lucide-react')) deps.push('lucide-react');
86
+ if (cleanedCode.includes('framer-motion')) deps.push('framer-motion');
87
+ if (cleanedCode.includes('clsx') || cleanedCode.includes('tailwind-merge')) deps.push('clsx tailwind-merge');
88
+
89
+ if (deps.length > 0) {
90
+ console.log(`\nπŸ“¦ μΆ”κ°€ μ„€μΉ˜κ°€ ν•„μš”ν•œ νŒ¨ν‚€μ§€κ°€ λ°œκ²¬λ˜μ—ˆμŠ΅λ‹ˆλ‹€:`);
91
+ console.log(`npm install ${deps.join(' ')}`);
92
+ } else {
93
+ console.log(`\nπŸŽ‰ μΆ”κ°€ μ„€μΉ˜κ°€ ν•„μš”ν•œ μ˜μ‘΄μ„±μ΄ μ—†μŠ΅λ‹ˆλ‹€. λ°”λ‘œ μ‚¬μš©ν•˜μ„Έμš”!`);
94
+ }
95
+ });
96
+ }).on('error', (err) => {
97
+ console.error(`❌ μ—λŸ¬ λ°œμƒ: ${err.message}`);
98
+ });
package/package.json ADDED
@@ -0,0 +1,19 @@
1
+ {
2
+ "name": "uikki",
3
+ "version": "1.0.0",
4
+ "description": "CLI tool for Uikki UI Component Gallery",
5
+ "bin": {
6
+ "uikki": "./index.js"
7
+ },
8
+ "scripts": {
9
+ "test": "echo \"Error: no test specified\" && exit 1"
10
+ },
11
+ "keywords": [
12
+ "ui",
13
+ "components",
14
+ "react",
15
+ "cli"
16
+ ],
17
+ "author": "",
18
+ "license": "MIT"
19
+ }