saqlain-ui 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.mjs +54 -0
  2. package/package.json +10 -0
package/index.mjs ADDED
@@ -0,0 +1,54 @@
1
+ #!/usr/bin/env node
2
+ import fs from 'fs';
3
+ import path from 'path';
4
+ import { execSync } from 'child_process';
5
+ let componentName = process.argv[2];
6
+
7
+ // If the user typed "add", grab the next word instead!
8
+ if (componentName === "add") {
9
+ componentName = process.argv[3];
10
+ }
11
+
12
+ if (!componentName) {
13
+ console.error("❌ Please provide a component name. Example: my-ui add button");
14
+ process.exit(1);
15
+ }
16
+ const REGISTRY_URL = `https://my-ui-library-vpgx.vercel.app/registry/${componentName}.json`;
17
+ const OUTPUT_DIR = './components/ui';
18
+
19
+ async function addComponent() {
20
+ try {
21
+ console.log(`⏳ Fetching '${componentName}' from registry...`);
22
+
23
+ const response = await fetch(REGISTRY_URL);
24
+
25
+ if (!response.ok) {
26
+ throw new Error(`Component '${componentName}' not found. Is your dev server running?`);
27
+ }
28
+
29
+ const componentData = await response.json();
30
+
31
+ // Check for and install NPM dependencies
32
+ if (componentData.dependencies && componentData.dependencies.length > 0) {
33
+ console.log(`📦 Installing dependencies: ${componentData.dependencies.join(', ')}...`);
34
+ execSync(`npm install ${componentData.dependencies.join(' ')} --legacy-peer-deps`, { stdio: 'inherit' });
35
+ }
36
+
37
+ if (!fs.existsSync(OUTPUT_DIR)) {
38
+ fs.mkdirSync(OUTPUT_DIR, { recursive: true });
39
+ }
40
+
41
+ componentData.files.forEach(file => {
42
+ const filePath = path.join(OUTPUT_DIR, file.name);
43
+ fs.writeFileSync(filePath, file.content);
44
+ console.log(`✅ Successfully installed ${file.name} into ${OUTPUT_DIR}/`);
45
+ });
46
+
47
+ console.log(`🎉 Component '${componentName}' is ready to use!`);
48
+
49
+ } catch (error) {
50
+ console.error("❌ Error:", error.message);
51
+ }
52
+ }
53
+
54
+ addComponent();
package/package.json ADDED
@@ -0,0 +1,10 @@
1
+ {
2
+ "name": "saqlain-ui",
3
+ "version": "1.0.0",
4
+ "description": "A beautifully crafted UI component library",
5
+ "main": "index.mjs",
6
+ "bin": {
7
+ "saqlain-ui": "./index.mjs"
8
+ },
9
+ "type": "module"
10
+ }