dimaac 1.0.1 ā 1.0.2
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 +148 -77
- package/package.json +6 -6
package/index.js
CHANGED
|
@@ -5,30 +5,13 @@ const fs = require('fs');
|
|
|
5
5
|
const path = require('path');
|
|
6
6
|
const https = require('https');
|
|
7
7
|
|
|
8
|
-
const
|
|
8
|
+
const API_BASE = 'https://ui.dimaac.com/api';
|
|
9
|
+
const REGISTRY_URL = `${API_BASE}/components`;
|
|
9
10
|
|
|
10
11
|
program
|
|
11
12
|
.name('dimaac')
|
|
12
13
|
.description('Add DiMaac UI components to your projects')
|
|
13
|
-
.version('1.0.
|
|
14
|
-
|
|
15
|
-
const componentCategories = {
|
|
16
|
-
'reveals': ['TextScrambleReveal', 'LiquidImageReveal'],
|
|
17
|
-
'cards': ['MouseTiltCard', 'SwipeableCards'],
|
|
18
|
-
'interactive': ['MouseTrail', 'ContextMenu'],
|
|
19
|
-
'gallery': ['ScrollingGallery', 'ImageGallery'],
|
|
20
|
-
'loaders': ['TextLoader'],
|
|
21
|
-
'layout': ['ExpandablePanel']
|
|
22
|
-
};
|
|
23
|
-
|
|
24
|
-
const exampleCategories = {
|
|
25
|
-
'reveals': ['TextScrambleRevealDemo', 'LiquidImageRevealDemo'],
|
|
26
|
-
'cards': ['MouseTiltCardDemo', 'SwipeableCardsDemo'],
|
|
27
|
-
'interactive': ['MouseTrailDemo', 'ContextMenuDemo'],
|
|
28
|
-
'gallery': ['ScrollingGalleryDemo', 'ImageGalleryDemo'],
|
|
29
|
-
'loaders': ['TextLoaderDemo'],
|
|
30
|
-
'layout': ['ExpandablePanelDemo']
|
|
31
|
-
};
|
|
14
|
+
.version('1.0.2');
|
|
32
15
|
|
|
33
16
|
function ensureDirectoryExists(dirPath) {
|
|
34
17
|
if (!fs.existsSync(dirPath)) {
|
|
@@ -53,55 +36,121 @@ function downloadFile(url, destination) {
|
|
|
53
36
|
});
|
|
54
37
|
}
|
|
55
38
|
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
39
|
+
function fetchRegistry() {
|
|
40
|
+
return new Promise((resolve, reject) => {
|
|
41
|
+
https.get(REGISTRY_URL, (response) => {
|
|
42
|
+
let data = '';
|
|
43
|
+
|
|
44
|
+
response.on('data', (chunk) => {
|
|
45
|
+
data += chunk;
|
|
46
|
+
});
|
|
47
|
+
|
|
48
|
+
response.on('end', () => {
|
|
49
|
+
try {
|
|
50
|
+
const registry = JSON.parse(data);
|
|
51
|
+
if (registry.success) {
|
|
52
|
+
resolve(registry.components);
|
|
53
|
+
} else {
|
|
54
|
+
reject(new Error('Failed to fetch component registry'));
|
|
55
|
+
}
|
|
56
|
+
} catch (error) {
|
|
57
|
+
reject(new Error('Invalid registry response'));
|
|
58
|
+
}
|
|
59
|
+
});
|
|
60
|
+
}).on('error', reject);
|
|
61
|
+
});
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
// Convert slug (post-swiper) to PascalCase (PostSwiper) for matching
|
|
65
|
+
function slugToPascal(slug) {
|
|
66
|
+
if (!slug || typeof slug !== 'string') return slug;
|
|
67
|
+
return slug
|
|
68
|
+
.split(/[-_\s]+/)
|
|
69
|
+
.map(part => part.charAt(0).toUpperCase() + part.slice(1).toLowerCase())
|
|
70
|
+
.join('');
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
async function findComponent(componentName, registry) {
|
|
74
|
+
if (!componentName) return null;
|
|
75
|
+
|
|
76
|
+
// Try exact match first
|
|
77
|
+
for (const [category, components] of Object.entries(registry)) {
|
|
78
|
+
const component = components.find(comp => comp.name === componentName);
|
|
79
|
+
if (component) return { category, component };
|
|
66
80
|
}
|
|
67
81
|
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
}
|
|
75
|
-
return;
|
|
82
|
+
// Try case-insensitive match
|
|
83
|
+
const nameLower = componentName.toLowerCase();
|
|
84
|
+
for (const [category, components] of Object.entries(registry)) {
|
|
85
|
+
const component = components.find(
|
|
86
|
+
comp => comp.name.toLowerCase() === nameLower
|
|
87
|
+
);
|
|
88
|
+
if (component) return { category, component };
|
|
76
89
|
}
|
|
77
90
|
|
|
78
|
-
|
|
79
|
-
|
|
91
|
+
// Try slug-to-PascalCase (e.g. post-swiper -> PostSwiper)
|
|
92
|
+
const pascalName = slugToPascal(componentName);
|
|
93
|
+
if (pascalName !== componentName) {
|
|
94
|
+
for (const [category, components] of Object.entries(registry)) {
|
|
95
|
+
const component = components.find(comp => comp.name === pascalName);
|
|
96
|
+
if (component) return { category, component };
|
|
97
|
+
}
|
|
98
|
+
}
|
|
80
99
|
|
|
81
|
-
|
|
82
|
-
|
|
100
|
+
return null;
|
|
101
|
+
}
|
|
83
102
|
|
|
103
|
+
async function installComponent(componentName, includeExample = false) {
|
|
84
104
|
try {
|
|
85
|
-
|
|
86
|
-
|
|
105
|
+
console.log('š¦ Fetching latest component registry...');
|
|
106
|
+
const registry = await fetchRegistry();
|
|
107
|
+
|
|
108
|
+
const result = await findComponent(componentName, registry);
|
|
109
|
+
|
|
110
|
+
if (!result) {
|
|
111
|
+
console.error(`Component "${componentName}" not found.`);
|
|
112
|
+
console.log('\nš¦ Available components:');
|
|
113
|
+
Object.entries(registry).forEach(([category, components]) => {
|
|
114
|
+
console.log(`\n ${category.toUpperCase()}:`);
|
|
115
|
+
components.forEach(comp => console.log(` - ${comp.name} (${comp.description})`));
|
|
116
|
+
});
|
|
117
|
+
return;
|
|
118
|
+
}
|
|
87
119
|
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
120
|
+
const { category, component } = result;
|
|
121
|
+
const componentDir = path.join(process.cwd(), 'ui', 'components');
|
|
122
|
+
ensureDirectoryExists(componentDir);
|
|
123
|
+
|
|
124
|
+
const destination = path.join(componentDir, `${component.name}.tsx`);
|
|
125
|
+
|
|
126
|
+
console.log(`ā¬ļø Downloading ${component.name}...`);
|
|
127
|
+
await downloadFile(component.sourceUrl, destination);
|
|
128
|
+
console.log(`ā
Successfully installed ${component.name} to ui/components/`);
|
|
129
|
+
|
|
130
|
+
if (includeExample && component.exampleUrl) {
|
|
131
|
+
const exampleDir = path.join(process.cwd(), 'examples');
|
|
91
132
|
ensureDirectoryExists(exampleDir);
|
|
92
133
|
|
|
93
|
-
const
|
|
94
|
-
const exampleDestination = path.join(exampleDir, `${exampleName}.tsx`);
|
|
134
|
+
const exampleDestination = path.join(exampleDir, `${component.name}Demo.tsx`);
|
|
95
135
|
|
|
96
136
|
try {
|
|
97
|
-
|
|
98
|
-
|
|
137
|
+
console.log(`ā¬ļø Downloading example...`);
|
|
138
|
+
await downloadFile(component.exampleUrl, exampleDestination);
|
|
139
|
+
console.log(`ā
Successfully installed ${component.name}Demo to examples/`);
|
|
99
140
|
} catch (error) {
|
|
100
|
-
console.log(`ā ļø Example not found for ${
|
|
141
|
+
console.log(`ā ļø Example not found for ${component.name}`);
|
|
101
142
|
}
|
|
102
143
|
}
|
|
144
|
+
|
|
145
|
+
if (component.dependencies && component.dependencies.length > 0) {
|
|
146
|
+
console.log(`\nš Required dependencies:`);
|
|
147
|
+
component.dependencies.forEach(dep => console.log(` - ${dep}`));
|
|
148
|
+
console.log(`\nInstall with: npm install ${component.dependencies.join(' ')}`);
|
|
149
|
+
}
|
|
150
|
+
|
|
103
151
|
} catch (error) {
|
|
104
|
-
console.error(`ā Failed to install ${
|
|
152
|
+
console.error(`ā Failed to install ${componentName}:`, error.message);
|
|
153
|
+
console.log('\nš” Make sure you have an internet connection and try again.');
|
|
105
154
|
}
|
|
106
155
|
}
|
|
107
156
|
|
|
@@ -110,11 +159,12 @@ program
|
|
|
110
159
|
.description('Initialize DiMaac UI in your project')
|
|
111
160
|
.action(async () => {
|
|
112
161
|
console.log('š Initializing DiMaac UI...');
|
|
113
|
-
|
|
114
|
-
const
|
|
162
|
+
|
|
163
|
+
const uiDir = path.join(process.cwd(), 'ui');
|
|
164
|
+
const componentsDir = path.join(process.cwd(), 'ui', 'components');
|
|
115
165
|
ensureDirectoryExists(componentsDir);
|
|
116
|
-
|
|
117
|
-
console.log('ā
Created components directory');
|
|
166
|
+
|
|
167
|
+
console.log('ā
Created ui/components directory');
|
|
118
168
|
console.log('š¦ DiMaac UI initialized successfully!');
|
|
119
169
|
console.log('\nNext steps:');
|
|
120
170
|
console.log(' npx dimaac add [component]');
|
|
@@ -130,24 +180,38 @@ program
|
|
|
130
180
|
.option('--all', 'Install all components')
|
|
131
181
|
.action(async (component, options) => {
|
|
132
182
|
if (options.all) {
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
183
|
+
try {
|
|
184
|
+
console.log('š¦ Fetching latest component registry...');
|
|
185
|
+
const registry = await fetchRegistry();
|
|
186
|
+
|
|
187
|
+
console.log('Installing all components...');
|
|
188
|
+
for (const [category, components] of Object.entries(registry)) {
|
|
189
|
+
for (const comp of components) {
|
|
190
|
+
await installComponent(comp.name, options.example);
|
|
191
|
+
}
|
|
137
192
|
}
|
|
193
|
+
} catch (error) {
|
|
194
|
+
console.error('ā Failed to fetch component registry:', error.message);
|
|
138
195
|
}
|
|
139
196
|
return;
|
|
140
197
|
}
|
|
141
198
|
|
|
142
199
|
if (!component) {
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
200
|
+
try {
|
|
201
|
+
console.log('š¦ Fetching latest component registry...');
|
|
202
|
+
const registry = await fetchRegistry();
|
|
203
|
+
|
|
204
|
+
console.log('\nš¦ Available Components:');
|
|
205
|
+
Object.entries(registry).forEach(([category, components]) => {
|
|
206
|
+
console.log(`\n ${category.toUpperCase()}:`);
|
|
207
|
+
components.forEach(comp => console.log(` - ${comp.name} (${comp.description})`));
|
|
208
|
+
});
|
|
209
|
+
console.log('\nUsage: npx dimaac add [component]');
|
|
210
|
+
console.log('Example: npx dimaac add MouseTiltCard');
|
|
211
|
+
console.log('Add -e flag to include example: npx dimaac add MouseTiltCard -e');
|
|
212
|
+
} catch (error) {
|
|
213
|
+
console.error('ā Failed to fetch component registry:', error.message);
|
|
214
|
+
}
|
|
151
215
|
return;
|
|
152
216
|
}
|
|
153
217
|
|
|
@@ -157,14 +221,21 @@ program
|
|
|
157
221
|
program
|
|
158
222
|
.command('list')
|
|
159
223
|
.description('List all available components')
|
|
160
|
-
.action(() => {
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
224
|
+
.action(async () => {
|
|
225
|
+
try {
|
|
226
|
+
console.log('š¦ Fetching latest component registry...');
|
|
227
|
+
const registry = await fetchRegistry();
|
|
228
|
+
|
|
229
|
+
console.log('\nš¦ Available Components:');
|
|
230
|
+
Object.entries(registry).forEach(([category, components]) => {
|
|
231
|
+
console.log(`\n ${category.toUpperCase()}:`);
|
|
232
|
+
components.forEach(comp => console.log(` - ${comp.name} (${comp.description})`));
|
|
233
|
+
});
|
|
234
|
+
console.log('\nUsage: npx dimaac add [component] [-e]');
|
|
235
|
+
console.log('Add -e flag to include example/demo files');
|
|
236
|
+
} catch (error) {
|
|
237
|
+
console.error('ā Failed to fetch component registry:', error.message);
|
|
238
|
+
}
|
|
168
239
|
});
|
|
169
240
|
|
|
170
241
|
program.parse();
|
package/package.json
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "dimaac",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.2",
|
|
4
4
|
"description": "Add DiMaac UI components to your projects",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"bin": {
|
|
7
|
-
"dimaac": "
|
|
7
|
+
"dimaac": "index.js"
|
|
8
8
|
},
|
|
9
9
|
"scripts": {
|
|
10
10
|
"test": "echo \"Error: no test specified\" && exit 1",
|
|
@@ -27,10 +27,10 @@
|
|
|
27
27
|
},
|
|
28
28
|
"repository": {
|
|
29
29
|
"type": "git",
|
|
30
|
-
"url": "https://github.com/
|
|
30
|
+
"url": "git+https://github.com/DimaacUI/DiMaac-UI.git"
|
|
31
31
|
},
|
|
32
32
|
"bugs": {
|
|
33
|
-
"url": "https://github.com/
|
|
33
|
+
"url": "https://github.com/DimaacUI/DiMaac-UI/issues"
|
|
34
34
|
},
|
|
35
|
-
"homepage": "https://github.com/
|
|
36
|
-
}
|
|
35
|
+
"homepage": "https://github.com/DimaacUI/DiMaac-UI#readme"
|
|
36
|
+
}
|