dimaac 1.0.0 → 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.
Files changed (3) hide show
  1. package/README.md +23 -48
  2. package/index.js +148 -77
  3. package/package.json +6 -6
package/README.md CHANGED
@@ -1,74 +1,49 @@
1
- # DiMaac UI CLI
1
+ # DiMaac
2
2
 
3
- Professional CLI tool for installing DiMaac UI components and examples.
3
+ Add DiMaac UI components to your projects.
4
4
 
5
- ## Installation Options
5
+ ## Usage
6
6
 
7
- ### Option 1: Global Installation (Recommended)
8
7
  ```bash
9
- npm install -g dimaac-ui-cli
8
+ npx dimaac init
10
9
  ```
11
10
 
12
- ### Option 2: Local Installation
13
- ```bash
14
- npm install dimaac-ui-cli
15
- ```
11
+ `init` command initializes a components directory for your project.
12
+
13
+ ### add
16
14
 
17
- ### Option 3: Use with npx (No Installation Required)
18
15
  ```bash
19
- npx dimaac-ui-cli add component MouseTiltCard
16
+ npx dimaac add [component]
20
17
  ```
21
18
 
22
- ## Usage
23
-
24
- ### Install Components
19
+ Adds a new component to your project.
25
20
 
21
+ Example:
26
22
  ```bash
27
- # Global installation
28
- dimaac add component MouseTiltCard
29
- dimaac add component TextScrambleReveal
30
- dimaac add component SwipeableCards
31
-
32
- # Local installation
33
- npx dimaac add component MouseTiltCard
34
- npm run dimaac add component MouseTiltCard
35
-
36
- # With npx (no installation)
37
- npx dimaac-ui-cli add component MouseTiltCard
38
-
39
- # Components will be installed to ./components/{category}/
23
+ npx dimaac add MouseTiltCard
40
24
  ```
41
25
 
42
- ### Install Examples
26
+ You can also use the optional `--all` flag to install all components:
43
27
 
44
28
  ```bash
45
- # Global installation
46
- dimaac add example MouseTiltCardDemo
47
- dimaac add example TextScrambleRevealDemo
48
- dimaac add example SwipeableCardsDemo
49
-
50
- # Local installation
51
- npx dimaac add example MouseTiltCardDemo
52
- npm run dimaac add example MouseTiltCardDemo
29
+ npx dimaac add --all
30
+ ```
53
31
 
54
- # With npx (no installation)
55
- npx dimaac-ui-cli add example MouseTiltCardDemo
32
+ You can install the related demos / examples for the related components by using the `-e` flag with the add command:
56
33
 
57
- # Examples will be installed to ./examples/{category}/
34
+ ```bash
35
+ npx dimaac add [component] -e
58
36
  ```
59
37
 
60
- ### List Available Components
61
-
38
+ Example:
62
39
  ```bash
63
- # Global installation
64
- dimaac list
40
+ npx dimaac add MouseTiltCard -e
41
+ ```
65
42
 
66
- # Local installation
67
- npx dimaac list
68
- npm run dimaac list
43
+ To check all the available components, you can use the add without supplying anything extra:
69
44
 
70
- # With npx (no installation)
71
- npx dimaac-ui-cli list
45
+ ```bash
46
+ npx dimaac add
72
47
  ```
73
48
 
74
49
  ## Available Components
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 GITHUB_RAW_BASE = 'https://raw.githubusercontent.com/Hank-D-Tank/dimaac-ui/main';
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.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
- async function installComponent(componentName, includeExample = false) {
57
- let category = null;
58
- let actualComponentName = null;
59
-
60
- for (const [cat, components] of Object.entries(componentCategories)) {
61
- if (components.includes(componentName)) {
62
- category = cat;
63
- actualComponentName = componentName;
64
- break;
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
- if (!category) {
69
- console.error(`Component "${componentName}" not found.`);
70
- console.log('Available components:');
71
- Object.entries(componentCategories).forEach(([cat, components]) => {
72
- console.log(` ${cat}:`);
73
- components.forEach(comp => console.log(` - ${comp}`));
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
- const componentDir = path.join(process.cwd(), 'components', category);
79
- ensureDirectoryExists(componentDir);
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
- const sourceUrl = `${GITHUB_RAW_BASE}/src/ui/components/${category}/${actualComponentName}.tsx`;
82
- const destination = path.join(componentDir, `${actualComponentName}.tsx`);
100
+ return null;
101
+ }
83
102
 
103
+ async function installComponent(componentName, includeExample = false) {
84
104
  try {
85
- await downloadFile(sourceUrl, destination);
86
- console.log(`✅ Successfully installed ${actualComponentName} to components/${category}/`);
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
- if (includeExample) {
89
- const exampleName = `${actualComponentName}Demo`;
90
- const exampleDir = path.join(process.cwd(), 'examples', category);
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 exampleUrl = `${GITHUB_RAW_BASE}/src/examples/components/${category}/${exampleName}.tsx`;
94
- const exampleDestination = path.join(exampleDir, `${exampleName}.tsx`);
134
+ const exampleDestination = path.join(exampleDir, `${component.name}Demo.tsx`);
95
135
 
96
136
  try {
97
- await downloadFile(exampleUrl, exampleDestination);
98
- console.log(`✅ Successfully installed ${exampleName} to examples/${category}/`);
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 ${actualComponentName}`);
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 ${actualComponentName}:`, error.message);
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 componentsDir = path.join(process.cwd(), 'components');
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
- console.log('Installing all components...');
134
- for (const [category, components] of Object.entries(componentCategories)) {
135
- for (const comp of components) {
136
- await installComponent(comp, options.example);
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
- console.log('\n📦 Available Components:');
144
- Object.entries(componentCategories).forEach(([category, components]) => {
145
- console.log(`\n ${category.toUpperCase()}:`);
146
- components.forEach(comp => console.log(` - ${comp}`));
147
- });
148
- console.log('\nUsage: npx dimaac add [component]');
149
- console.log('Example: npx dimaac add MouseTiltCard');
150
- console.log('Add -e flag to include example: npx dimaac add MouseTiltCard -e');
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
- console.log('\n📦 Available Components:');
162
- Object.entries(componentCategories).forEach(([category, components]) => {
163
- console.log(`\n ${category.toUpperCase()}:`);
164
- components.forEach(comp => console.log(` - ${comp}`));
165
- });
166
- console.log('\nUsage: npx dimaac add [component] [-e]');
167
- console.log('Add -e flag to include example/demo files');
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.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": "./index.js"
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/your-username/dimaac-ui.git"
30
+ "url": "git+https://github.com/DimaacUI/DiMaac-UI.git"
31
31
  },
32
32
  "bugs": {
33
- "url": "https://github.com/your-username/dimaac-ui/issues"
33
+ "url": "https://github.com/DimaacUI/DiMaac-UI/issues"
34
34
  },
35
- "homepage": "https://github.com/your-username/dimaac-ui#readme"
36
- }
35
+ "homepage": "https://github.com/DimaacUI/DiMaac-UI#readme"
36
+ }