@cannbot-ai/install-helper 0.0.2-beta.25 → 0.0.2-beta.27

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 CHANGED
@@ -552,6 +552,40 @@ import chalk2 from "chalk";
552
552
  var selectTheme = {
553
553
  helpMode: "never"
554
554
  };
555
+ function getDisplayWidth2(str) {
556
+ let width = 0;
557
+ for (const ch of str) {
558
+ const code = ch.codePointAt(0);
559
+ if (code >= 11904 && code <= 40959 || code >= 63744 && code <= 64255 || code >= 65072 && code <= 65103 || code >= 65280 && code <= 65519 || code >= 13312 && code <= 19903 || code >= 131072 && code <= 173791) {
560
+ width += 2;
561
+ } else {
562
+ width += 1;
563
+ }
564
+ }
565
+ return width;
566
+ }
567
+ function wrapDescription(text) {
568
+ const prefix = " \u{1F4A1} ";
569
+ const indent = " ";
570
+ const cols = process.stdout.columns || 120;
571
+ const maxLen = Math.max(20, cols - getDisplayWidth2(prefix) - 1);
572
+ const lines = [];
573
+ let line = "";
574
+ let lineWidth = 0;
575
+ for (const ch of text) {
576
+ const chWidth = getDisplayWidth2(ch);
577
+ if (lineWidth + chWidth > maxLen && line) {
578
+ lines.push(line);
579
+ line = ch;
580
+ lineWidth = chWidth;
581
+ } else {
582
+ line += ch;
583
+ lineWidth += chWidth;
584
+ }
585
+ }
586
+ if (line) lines.push(line);
587
+ return lines.map((l, i) => chalk2.cyan(i === 0 ? prefix + l : indent + l)).join("\n");
588
+ }
555
589
  var checkboxTheme = {
556
590
  icon: {
557
591
  checked: "\x1B[32m\u2611\x1B[22m",
@@ -560,7 +594,7 @@ var checkboxTheme = {
560
594
  },
561
595
  helpMode: "never",
562
596
  style: {
563
- description: (text) => chalk2.cyan(" \u{1F4A1} " + text)
597
+ description: (text) => wrapDescription(text)
564
598
  }
565
599
  };
566
600
 
@@ -3170,7 +3204,7 @@ function createCLI() {
3170
3204
  setLanguage(config.language);
3171
3205
  }
3172
3206
  const program2 = new Command();
3173
- program2.name("install-helper").description("CANNBot Install Helper - Interactive installer for CANN operator development skills").version("0.0.2-beta.25");
3207
+ program2.name("install-helper").description("CANNBot Install Helper - Interactive installer for CANN operator development skills").version("0.0.2-beta.27");
3174
3208
  program2.command("init", { isDefault: false }).description("Run interactive installation wizard").action(async () => {
3175
3209
  await initCommand();
3176
3210
  });