@srcroot/ui 0.0.62 → 0.0.64

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/dist/index.js +54 -17
  2. package/package.json +1 -1
package/dist/index.js CHANGED
@@ -413,6 +413,9 @@ async function init(options) {
413
413
  await initializer.run();
414
414
  }
415
415
 
416
+ // src/cli/commands/add.ts
417
+ import path6 from "path";
418
+
416
419
  // src/cli/services/component-adder.ts
417
420
  import fs5 from "fs-extra";
418
421
  import path5 from "path";
@@ -863,14 +866,14 @@ var REGISTRY = {
863
866
  description: "Button to scroll to top",
864
867
  category: "Navigation",
865
868
  dependencies: ["button"],
866
- registryDependencies: ["framer-motion"]
869
+ registryDependencies: []
867
870
  },
868
871
  "scroll-animation": {
869
872
  file: "ui/scroll-animation.tsx",
870
873
  description: "Scroll-triggered animations",
871
874
  category: "Layout",
872
875
  dependencies: [],
873
- registryDependencies: ["framer-motion"]
876
+ registryDependencies: ["gsap", "@gsap/react"]
874
877
  },
875
878
  whatsapp: {
876
879
  file: "ui/whatsapp.tsx",
@@ -981,21 +984,14 @@ var ComponentAdder = class {
981
984
  logPlan(componentDeps, packageDeps) {
982
985
  const componentsToAdd = Array.from(componentDeps);
983
986
  const packagesToInstall = Array.from(packageDeps);
984
- if (componentsToAdd.length > 10) {
987
+ if (componentsToAdd.length > 0) {
985
988
  logger.info(`
986
- \u{1F4E6} Adding ${componentsToAdd.length} components...
987
- `);
988
- } else {
989
- logger.info("\n\u{1F4E6} Adding components:\n");
990
- componentsToAdd.forEach((name) => {
991
- console.log(` - ${name}`);
992
- });
989
+ \u{1F4E6} Adding components:`);
990
+ console.log(` ${componentsToAdd.join(", ")}`);
993
991
  }
994
992
  if (packagesToInstall.length > 0) {
995
- logger.info("\n\u{1F4E6} Installing dependencies:\n");
996
- packagesToInstall.forEach((pkg) => {
997
- console.log(` - ${pkg}`);
998
- });
993
+ logger.info("\n\u{1F4E6} Installing dependencies:");
994
+ console.log(` ${packagesToInstall.join(", ")}`);
999
995
  }
1000
996
  console.log();
1001
997
  }
@@ -1022,11 +1018,52 @@ Please manually install: ${packages.join(" ")}`);
1022
1018
  const componentsDir = path5.join(srcPath, "components", "ui");
1023
1019
  try {
1024
1020
  await fs5.ensureDir(componentsDir);
1021
+ let overwriteAll = false;
1022
+ let skipAll = false;
1023
+ if (!this.options.overwrite) {
1024
+ const conflicts = [];
1025
+ for (const name of components) {
1026
+ const comp = REGISTRY[name];
1027
+ const fileName = path5.basename(comp.file);
1028
+ const targetPath = path5.join(componentsDir, fileName);
1029
+ if (fs5.existsSync(targetPath)) {
1030
+ conflicts.push(fileName);
1031
+ }
1032
+ }
1033
+ if (conflicts.length > 0) {
1034
+ spinner.stop();
1035
+ logger.warn(`
1036
+ \u26A0\uFE0F The following components already exist:`);
1037
+ console.log(` ${conflicts.join(", ")}`);
1038
+ console.log();
1039
+ const { action } = await prompts2({
1040
+ type: "select",
1041
+ name: "action",
1042
+ message: "How would you like to proceed?",
1043
+ choices: [
1044
+ { title: "Overwrite all", value: "overwrite" },
1045
+ { title: "Skip all", value: "skip" },
1046
+ { title: "Decide for each", value: "ask" }
1047
+ ]
1048
+ });
1049
+ if (!action) {
1050
+ logger.warn("Action cancelled.");
1051
+ process.exit(0);
1052
+ }
1053
+ if (action === "overwrite") overwriteAll = true;
1054
+ if (action === "skip") skipAll = true;
1055
+ }
1056
+ spinner.start("Adding components...");
1057
+ }
1025
1058
  for (const name of components) {
1026
1059
  const comp = REGISTRY[name];
1027
1060
  const fileName = path5.basename(comp.file);
1028
1061
  const targetPath = path5.join(componentsDir, fileName);
1029
- if (fs5.existsSync(targetPath) && !this.options.overwrite) {
1062
+ if (fs5.existsSync(targetPath) && !this.options.overwrite && !overwriteAll) {
1063
+ if (skipAll) {
1064
+ spinner.info(`Skipped ${fileName}`);
1065
+ continue;
1066
+ }
1030
1067
  spinner.stop();
1031
1068
  const { overwrite } = await prompts2({
1032
1069
  type: "confirm",
@@ -1041,7 +1078,7 @@ Please manually install: ${packages.join(" ")}`);
1041
1078
  }
1042
1079
  spinner.start("Adding components...");
1043
1080
  }
1044
- const registryPath = path5.resolve(__dirname4, "..", "src", "registry", comp.file);
1081
+ const registryPath = path5.resolve(__dirname4, "..", "..", "registry", comp.file);
1045
1082
  if (!fs5.existsSync(registryPath)) {
1046
1083
  spinner.warn(`Registry file not found for ${name}: ${registryPath}`);
1047
1084
  continue;
@@ -1067,7 +1104,7 @@ Please manually install: ${packages.join(" ")}`);
1067
1104
 
1068
1105
  // src/cli/commands/add.ts
1069
1106
  async function add(components, options) {
1070
- const cwd = process.cwd();
1107
+ const cwd = path6.resolve(options.cwd);
1071
1108
  const adder = new ComponentAdder(cwd, options);
1072
1109
  await adder.add(components);
1073
1110
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@srcroot/ui",
3
- "version": "0.0.62",
3
+ "version": "0.0.64",
4
4
  "description": "A UI library with polymorphic, accessible React components",
5
5
  "author": "Shifaul Islam",
6
6
  "license": "MIT",