@cannbot-ai/install-helper 0.0.2-beta.26 → 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,23 +552,38 @@ 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
+ }
555
567
  function wrapDescription(text) {
556
568
  const prefix = " \u{1F4A1} ";
557
569
  const indent = " ";
558
570
  const cols = process.stdout.columns || 120;
559
- const maxLen = Math.max(20, cols - prefix.length - 1);
560
- const words = text.split(/(\s+)/);
571
+ const maxLen = Math.max(20, cols - getDisplayWidth2(prefix) - 1);
561
572
  const lines = [];
562
573
  let line = "";
563
- for (const word of words) {
564
- if ((line + word).length > maxLen && line) {
565
- lines.push(line.trimEnd());
566
- line = word.trimStart();
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;
567
581
  } else {
568
- line += word;
582
+ line += ch;
583
+ lineWidth += chWidth;
569
584
  }
570
585
  }
571
- if (line) lines.push(line.trimEnd());
586
+ if (line) lines.push(line);
572
587
  return lines.map((l, i) => chalk2.cyan(i === 0 ? prefix + l : indent + l)).join("\n");
573
588
  }
574
589
  var checkboxTheme = {
@@ -3189,7 +3204,7 @@ function createCLI() {
3189
3204
  setLanguage(config.language);
3190
3205
  }
3191
3206
  const program2 = new Command();
3192
- program2.name("install-helper").description("CANNBot Install Helper - Interactive installer for CANN operator development skills").version("0.0.2-beta.26");
3207
+ program2.name("install-helper").description("CANNBot Install Helper - Interactive installer for CANN operator development skills").version("0.0.2-beta.27");
3193
3208
  program2.command("init", { isDefault: false }).description("Run interactive installation wizard").action(async () => {
3194
3209
  await initCommand();
3195
3210
  });