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.
- package/index.js +98 -0
- 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
|
+
}
|