gbs-add-block 0.0.10 → 0.0.12
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 +55 -7
- package/package.json +1 -1
package/index.js
CHANGED
|
@@ -17,10 +17,16 @@ const COMPONENTS = [
|
|
|
17
17
|
"Modal",
|
|
18
18
|
"Spinner",
|
|
19
19
|
"Toast",
|
|
20
|
-
"Uploader"
|
|
20
|
+
"Uploader",
|
|
21
21
|
];
|
|
22
|
+
|
|
23
|
+
const FRAMEWORKS = {
|
|
24
|
+
next: "Next.js",
|
|
25
|
+
vite: "Vite",
|
|
26
|
+
};
|
|
27
|
+
|
|
22
28
|
const SOURCE_PATH = path.join(__dirname, "source", "components");
|
|
23
|
-
|
|
29
|
+
let DEST_PATH;
|
|
24
30
|
|
|
25
31
|
const rl = readline.createInterface({
|
|
26
32
|
input: process.stdin,
|
|
@@ -29,8 +35,18 @@ const rl = readline.createInterface({
|
|
|
29
35
|
|
|
30
36
|
let isFirstCopy = true;
|
|
31
37
|
|
|
38
|
+
function listFrameworks() {
|
|
39
|
+
console.log("Available frameworks:");
|
|
40
|
+
console.log("");
|
|
41
|
+
Object.entries(FRAMEWORKS).forEach(([key, name], index) => {
|
|
42
|
+
console.log(`${index + 1}. ${name}`);
|
|
43
|
+
});
|
|
44
|
+
}
|
|
45
|
+
|
|
32
46
|
function listComponents() {
|
|
47
|
+
console.log(" ");
|
|
33
48
|
console.log("Available components:");
|
|
49
|
+
console.log(" ");
|
|
34
50
|
COMPONENTS.forEach((component, index) => {
|
|
35
51
|
console.log(`${index + 1}. ${component}`);
|
|
36
52
|
});
|
|
@@ -60,7 +76,13 @@ function copyComponent(component) {
|
|
|
60
76
|
}
|
|
61
77
|
|
|
62
78
|
fs.copySync(componentSrc, componentDest, { overwrite: true });
|
|
79
|
+
console.log("");
|
|
63
80
|
console.log(`Component ${component} copied successfully to ${componentDest}`);
|
|
81
|
+
console.log("");
|
|
82
|
+
console.log(
|
|
83
|
+
"For Props and Usage Guides Visit : https://blackmax-designs.gitbook.io/building-block-v2.0"
|
|
84
|
+
);
|
|
85
|
+
console.log("");
|
|
64
86
|
|
|
65
87
|
if (isFirstCopy) {
|
|
66
88
|
copyCommonFiles();
|
|
@@ -68,6 +90,35 @@ function copyComponent(component) {
|
|
|
68
90
|
}
|
|
69
91
|
}
|
|
70
92
|
|
|
93
|
+
function promptForFramework() {
|
|
94
|
+
listFrameworks();
|
|
95
|
+
rl.question("Select your framework (enter the number): ", (answer) => {
|
|
96
|
+
const index = parseInt(answer) - 1;
|
|
97
|
+
const frameworks = Object.keys(FRAMEWORKS);
|
|
98
|
+
|
|
99
|
+
if (isNaN(index) || index < 0 || index >= frameworks.length) {
|
|
100
|
+
console.log("Invalid selection. Please try again.");
|
|
101
|
+
promptForFramework();
|
|
102
|
+
return;
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
const selectedFramework = frameworks[index];
|
|
106
|
+
|
|
107
|
+
// Set destination path based on framework
|
|
108
|
+
if (selectedFramework === "next") {
|
|
109
|
+
DEST_PATH = path.join(process.cwd(), "app", "component-lib");
|
|
110
|
+
} else {
|
|
111
|
+
DEST_PATH = path.join(process.cwd(), "src", "component-lib");
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
// Ensure the destination directory exists
|
|
115
|
+
fs.ensureDirSync(DEST_PATH);
|
|
116
|
+
|
|
117
|
+
// Continue with component selection
|
|
118
|
+
promptForComponent();
|
|
119
|
+
});
|
|
120
|
+
}
|
|
121
|
+
|
|
71
122
|
function promptForComponent() {
|
|
72
123
|
listComponents();
|
|
73
124
|
rl.question(
|
|
@@ -102,8 +153,5 @@ function promptForComponent() {
|
|
|
102
153
|
);
|
|
103
154
|
}
|
|
104
155
|
|
|
105
|
-
//
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
// Start the component selection process
|
|
109
|
-
promptForComponent();
|
|
156
|
+
// Start with framework selection
|
|
157
|
+
promptForFramework();
|