@srcroot/ui 0.0.21 → 0.0.23
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/dist/index.js +25 -7
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -969,6 +969,7 @@ async function add(components, options) {
|
|
|
969
969
|
name: "items",
|
|
970
970
|
message: "Which components would you like to add?",
|
|
971
971
|
hint: "Space to select. A to toggle all. Enter to submit.",
|
|
972
|
+
instructions: false,
|
|
972
973
|
choices: Object.keys(REGISTRY).map((name) => ({
|
|
973
974
|
title: name,
|
|
974
975
|
value: name
|
|
@@ -1009,10 +1010,16 @@ async function add(components, options) {
|
|
|
1009
1010
|
resolveDeps(comp);
|
|
1010
1011
|
}
|
|
1011
1012
|
const componentsToAdd = Array.from(toInstall);
|
|
1012
|
-
|
|
1013
|
-
|
|
1014
|
-
|
|
1015
|
-
|
|
1013
|
+
if (componentsToAdd.length > 10) {
|
|
1014
|
+
console.log(chalk2.cyan(`
|
|
1015
|
+
\u{1F4E6} Adding ${componentsToAdd.length} components...
|
|
1016
|
+
`));
|
|
1017
|
+
} else {
|
|
1018
|
+
console.log(chalk2.cyan("\n\u{1F4E6} Adding components:\n"));
|
|
1019
|
+
componentsToAdd.forEach((name) => {
|
|
1020
|
+
console.log(chalk2.dim(` - ${name}`));
|
|
1021
|
+
});
|
|
1022
|
+
}
|
|
1016
1023
|
console.log();
|
|
1017
1024
|
if (!options.yes) {
|
|
1018
1025
|
const response = await prompts2({
|
|
@@ -1027,14 +1034,18 @@ async function add(components, options) {
|
|
|
1027
1034
|
}
|
|
1028
1035
|
}
|
|
1029
1036
|
const spinner = ora2("Adding components...").start();
|
|
1030
|
-
const
|
|
1037
|
+
const hasSrc = fs2.existsSync(path2.join(cwd, "src"));
|
|
1038
|
+
const srcPath = hasSrc ? path2.join(cwd, "src") : cwd;
|
|
1039
|
+
const componentsDir = path2.join(srcPath, "components", "ui");
|
|
1031
1040
|
try {
|
|
1032
1041
|
await fs2.ensureDir(componentsDir);
|
|
1033
1042
|
for (const name of componentsToAdd) {
|
|
1034
1043
|
const comp = REGISTRY[name];
|
|
1035
1044
|
const targetPath = path2.join(componentsDir, comp.file);
|
|
1036
1045
|
if (fs2.existsSync(targetPath) && !options.overwrite) {
|
|
1037
|
-
|
|
1046
|
+
if (componentsToAdd.length <= 10) {
|
|
1047
|
+
spinner.info(`${chalk2.cyan(comp.file)} already exists, skipping`);
|
|
1048
|
+
}
|
|
1038
1049
|
continue;
|
|
1039
1050
|
}
|
|
1040
1051
|
const registryPath = path2.resolve(__dirname3, "..", "registry", comp.file);
|
|
@@ -1044,7 +1055,14 @@ async function add(components, options) {
|
|
|
1044
1055
|
}
|
|
1045
1056
|
const content = await fs2.readFile(registryPath, "utf-8");
|
|
1046
1057
|
await fs2.writeFile(targetPath, content);
|
|
1047
|
-
|
|
1058
|
+
if (componentsToAdd.length > 10) {
|
|
1059
|
+
spinner.text = `Adding ${chalk2.cyan(comp.file)}...`;
|
|
1060
|
+
} else {
|
|
1061
|
+
spinner.succeed(`Added ${chalk2.cyan(comp.file)}`);
|
|
1062
|
+
}
|
|
1063
|
+
}
|
|
1064
|
+
if (componentsToAdd.length > 10) {
|
|
1065
|
+
spinner.succeed(`Added ${componentsToAdd.length} components`);
|
|
1048
1066
|
}
|
|
1049
1067
|
console.log(chalk2.green("\n\u2705 Components added successfully!\n"));
|
|
1050
1068
|
} catch (error) {
|