gbs-add-block 0.0.11 → 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 +46 -14
- package/package.json +1 -1
package/index.js
CHANGED
|
@@ -19,8 +19,14 @@ const COMPONENTS = [
|
|
|
19
19
|
"Toast",
|
|
20
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,15 +35,15 @@ 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() {
|
|
33
|
-
console.log(
|
|
34
|
-
` _____ ____ _____
|
|
35
|
-
/ ____| | \\ / ___|
|
|
36
|
-
| | __ | |_) | | (___
|
|
37
|
-
| | |_ | | < \\ __ \\
|
|
38
|
-
| |__| | | |_) | ____) |
|
|
39
|
-
\\_____| |____/ |_____/ `
|
|
40
|
-
);
|
|
41
47
|
console.log(" ");
|
|
42
48
|
console.log("Available components:");
|
|
43
49
|
console.log(" ");
|
|
@@ -84,6 +90,35 @@ function copyComponent(component) {
|
|
|
84
90
|
}
|
|
85
91
|
}
|
|
86
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
|
+
|
|
87
122
|
function promptForComponent() {
|
|
88
123
|
listComponents();
|
|
89
124
|
rl.question(
|
|
@@ -118,8 +153,5 @@ function promptForComponent() {
|
|
|
118
153
|
);
|
|
119
154
|
}
|
|
120
155
|
|
|
121
|
-
//
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
// Start the component selection process
|
|
125
|
-
promptForComponent();
|
|
156
|
+
// Start with framework selection
|
|
157
|
+
promptForFramework();
|