@cannbot-ai/install-helper 0.0.2-beta.27 → 0.0.2-beta.28
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 +37 -13
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -552,11 +552,17 @@ import chalk2 from "chalk";
|
|
|
552
552
|
var selectTheme = {
|
|
553
553
|
helpMode: "never"
|
|
554
554
|
};
|
|
555
|
+
function isCJK(code) {
|
|
556
|
+
return code >= 11904 && code <= 40959 || code >= 63744 && code <= 64255 || code >= 65072 && code <= 65103 || code >= 65280 && code <= 65519 || code >= 13312 && code <= 19903 || code >= 131072 && code <= 173791 || code >= 173824 && code <= 177983 || code >= 177984 && code <= 178207 || code >= 178208 && code <= 183983;
|
|
557
|
+
}
|
|
558
|
+
function isEmoji(code) {
|
|
559
|
+
return code >= 127744 && code <= 129791 || code >= 9728 && code <= 10175;
|
|
560
|
+
}
|
|
555
561
|
function getDisplayWidth2(str) {
|
|
556
562
|
let width = 0;
|
|
557
563
|
for (const ch of str) {
|
|
558
564
|
const code = ch.codePointAt(0);
|
|
559
|
-
if (code
|
|
565
|
+
if (isCJK(code) || isEmoji(code)) {
|
|
560
566
|
width += 2;
|
|
561
567
|
} else {
|
|
562
568
|
width += 1;
|
|
@@ -568,23 +574,41 @@ function wrapDescription(text) {
|
|
|
568
574
|
const prefix = " \u{1F4A1} ";
|
|
569
575
|
const indent = " ";
|
|
570
576
|
const cols = process.stdout.columns || 120;
|
|
571
|
-
const maxLen = Math.max(20, cols - getDisplayWidth2(prefix) -
|
|
577
|
+
const maxLen = Math.max(20, cols - getDisplayWidth2(prefix) - 2);
|
|
578
|
+
const tokens = [];
|
|
579
|
+
let i = 0;
|
|
580
|
+
while (i < text.length) {
|
|
581
|
+
const code = text[i].codePointAt(0);
|
|
582
|
+
if (isCJK(code)) {
|
|
583
|
+
tokens.push({ text: text[i], width: 2 });
|
|
584
|
+
i++;
|
|
585
|
+
} else {
|
|
586
|
+
let j = i;
|
|
587
|
+
while (j < text.length) {
|
|
588
|
+
const c = text[j].codePointAt(0);
|
|
589
|
+
if (isCJK(c)) break;
|
|
590
|
+
j++;
|
|
591
|
+
}
|
|
592
|
+
const word = text.slice(i, j);
|
|
593
|
+
tokens.push({ text: word, width: getDisplayWidth2(word) });
|
|
594
|
+
i = j;
|
|
595
|
+
}
|
|
596
|
+
}
|
|
572
597
|
const lines = [];
|
|
573
598
|
let line = "";
|
|
574
599
|
let lineWidth = 0;
|
|
575
|
-
for (const
|
|
576
|
-
|
|
577
|
-
|
|
578
|
-
|
|
579
|
-
|
|
580
|
-
lineWidth = chWidth;
|
|
600
|
+
for (const token of tokens) {
|
|
601
|
+
if (lineWidth + token.width > maxLen && line) {
|
|
602
|
+
lines.push(line.trimEnd());
|
|
603
|
+
line = token.text;
|
|
604
|
+
lineWidth = token.width;
|
|
581
605
|
} else {
|
|
582
|
-
line +=
|
|
583
|
-
lineWidth +=
|
|
606
|
+
line += token.text;
|
|
607
|
+
lineWidth += token.width;
|
|
584
608
|
}
|
|
585
609
|
}
|
|
586
|
-
if (line) lines.push(line);
|
|
587
|
-
return lines.map((l,
|
|
610
|
+
if (line) lines.push(line.trimEnd());
|
|
611
|
+
return lines.map((l, i2) => chalk2.cyan(i2 === 0 ? prefix + l : indent + l)).join("\n");
|
|
588
612
|
}
|
|
589
613
|
var checkboxTheme = {
|
|
590
614
|
icon: {
|
|
@@ -3204,7 +3228,7 @@ function createCLI() {
|
|
|
3204
3228
|
setLanguage(config.language);
|
|
3205
3229
|
}
|
|
3206
3230
|
const program2 = new Command();
|
|
3207
|
-
program2.name("install-helper").description("CANNBot Install Helper - Interactive installer for CANN operator development skills").version("0.0.2-beta.
|
|
3231
|
+
program2.name("install-helper").description("CANNBot Install Helper - Interactive installer for CANN operator development skills").version("0.0.2-beta.28");
|
|
3208
3232
|
program2.command("init", { isDefault: false }).description("Run interactive installation wizard").action(async () => {
|
|
3209
3233
|
await initCommand();
|
|
3210
3234
|
});
|