gbs-add-block 0.0.52 → 0.0.53
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/README.md
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
# GBS Building Blocks 2.0 (v0.0.
|
|
1
|
+
# GBS Building Blocks 2.0 (v0.0.53)
|
|
2
2
|
|
|
3
3
|
Latest and upgraded version of GBS building blocks with headless UI and removed dependencies.
|
|
4
4
|
|
|
@@ -6,7 +6,7 @@ Latest and upgraded version of GBS building blocks with headless UI and removed
|
|
|
6
6
|
|
|
7
7
|
For detailed documentation on usage and props, Please visit: [Building Block Documentation v2.0](https://blackmax-designs.gitbook.io/building-block-v2.0)
|
|
8
8
|
|
|
9
|
-
## What's New 🎉 (Ver 0.0.
|
|
9
|
+
## What's New 🎉 (Ver 0.0.53)
|
|
10
10
|
|
|
11
11
|
- Updated for more general installation methods
|
|
12
12
|
|
package/index.js
CHANGED
|
@@ -25,6 +25,10 @@ const CONFIG = {
|
|
|
25
25
|
"MaterialInput",
|
|
26
26
|
"ContextMenu",
|
|
27
27
|
],
|
|
28
|
+
// Define component dependencies
|
|
29
|
+
dependencies: {
|
|
30
|
+
FormRenderer: ["Select", "MultiSelect", "Input", "DatePicker"],
|
|
31
|
+
},
|
|
28
32
|
frameworks: {
|
|
29
33
|
next: {
|
|
30
34
|
name: "Next.js",
|
|
@@ -55,6 +59,11 @@ const copyCommonFiles = async (destPath) => {
|
|
|
55
59
|
}
|
|
56
60
|
};
|
|
57
61
|
|
|
62
|
+
const checkComponentExists = (component, destPath) => {
|
|
63
|
+
const componentPath = path.join(destPath, component.toLowerCase());
|
|
64
|
+
return fs.existsSync(componentPath);
|
|
65
|
+
};
|
|
66
|
+
|
|
58
67
|
const copyComponent = async (component, destPath) => {
|
|
59
68
|
try {
|
|
60
69
|
const componentSrc = path.join(SOURCE_PATH, component.toLowerCase());
|
|
@@ -66,13 +75,44 @@ const copyComponent = async (component, destPath) => {
|
|
|
66
75
|
|
|
67
76
|
await fs.copy(componentSrc, componentDest, { overwrite: true });
|
|
68
77
|
console.log(`✓ Component ${component} installed successfully`);
|
|
69
|
-
console.log(`\nFor documentation visit: ${CONFIG.docs}`);
|
|
70
78
|
} catch (error) {
|
|
71
79
|
console.error(`Error installing component ${component}:`, error.message);
|
|
72
80
|
process.exit(1);
|
|
73
81
|
}
|
|
74
82
|
};
|
|
75
83
|
|
|
84
|
+
const installComponentWithDependencies = async (component, destPath) => {
|
|
85
|
+
// Get dependencies for the component
|
|
86
|
+
const dependencies = CONFIG.dependencies[component] || [];
|
|
87
|
+
const componentsToInstall = new Set([component, ...dependencies]);
|
|
88
|
+
|
|
89
|
+
// Check which components need to be installed
|
|
90
|
+
const pendingInstalls = Array.from(componentsToInstall).filter(
|
|
91
|
+
(comp) => !checkComponentExists(comp, destPath)
|
|
92
|
+
);
|
|
93
|
+
|
|
94
|
+
if (pendingInstalls.length === 0) {
|
|
95
|
+
console.log(
|
|
96
|
+
`✓ ${component} and all its dependencies are already installed.`
|
|
97
|
+
);
|
|
98
|
+
return;
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
// Install all pending components
|
|
102
|
+
for (const comp of pendingInstalls) {
|
|
103
|
+
await copyComponent(comp, destPath);
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
if (dependencies.length > 0) {
|
|
107
|
+
console.log(`\nInstalled dependencies for ${component}:`);
|
|
108
|
+
dependencies.forEach((dep) => {
|
|
109
|
+
console.log(`- ${dep}`);
|
|
110
|
+
});
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
console.log(`\nFor documentation visit: ${CONFIG.docs}`);
|
|
114
|
+
};
|
|
115
|
+
|
|
76
116
|
const detectFramework = () => {
|
|
77
117
|
// Check for Next.js
|
|
78
118
|
if (fs.existsSync(path.join(process.cwd(), "next.config.js"))) {
|
|
@@ -110,7 +150,12 @@ const main = async () => {
|
|
|
110
150
|
// List components if requested
|
|
111
151
|
if (argv.list) {
|
|
112
152
|
console.log("\nAvailable components:");
|
|
113
|
-
CONFIG.components.forEach((comp) =>
|
|
153
|
+
CONFIG.components.forEach((comp) => {
|
|
154
|
+
const deps = CONFIG.dependencies[comp]
|
|
155
|
+
? ` (requires: ${CONFIG.dependencies[comp].join(", ")})`
|
|
156
|
+
: "";
|
|
157
|
+
console.log(`- ${comp}${deps}`);
|
|
158
|
+
});
|
|
114
159
|
return;
|
|
115
160
|
}
|
|
116
161
|
|
|
@@ -157,8 +202,8 @@ const main = async () => {
|
|
|
157
202
|
await copyCommonFiles(destPath);
|
|
158
203
|
}
|
|
159
204
|
|
|
160
|
-
//
|
|
161
|
-
await
|
|
205
|
+
// Install component and its dependencies
|
|
206
|
+
await installComponentWithDependencies(component, destPath);
|
|
162
207
|
};
|
|
163
208
|
|
|
164
209
|
main().catch((error) => {
|
package/package.json
CHANGED