@clerc/plugin-completions 1.0.0-beta.28 → 1.0.0-beta.29
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.d.ts +33 -0
- package/dist/index.js +17 -1531
- package/package.json +3 -3
package/dist/index.js
CHANGED
|
@@ -1,1527 +1,6 @@
|
|
|
1
1
|
import t from "@bomb.sh/tab";
|
|
2
|
-
import {
|
|
3
|
-
import tty from "node:tty";
|
|
2
|
+
import { Types, definePlugin, extractParameterInfo, normalizeFlagValue, normalizeParameterValue } from "@clerc/core";
|
|
4
3
|
|
|
5
|
-
//#region rolldown:runtime
|
|
6
|
-
var __create = Object.create;
|
|
7
|
-
var __defProp = Object.defineProperty;
|
|
8
|
-
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
9
|
-
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
10
|
-
var __getProtoOf = Object.getPrototypeOf;
|
|
11
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
12
|
-
var __commonJSMin = (cb, mod) => () => (mod || cb((mod = { exports: {} }).exports, mod), mod.exports);
|
|
13
|
-
var __export = (all, symbols) => {
|
|
14
|
-
let target = {};
|
|
15
|
-
for (var name in all) {
|
|
16
|
-
__defProp(target, name, {
|
|
17
|
-
get: all[name],
|
|
18
|
-
enumerable: true
|
|
19
|
-
});
|
|
20
|
-
}
|
|
21
|
-
if (symbols) {
|
|
22
|
-
__defProp(target, Symbol.toStringTag, { value: "Module" });
|
|
23
|
-
}
|
|
24
|
-
return target;
|
|
25
|
-
};
|
|
26
|
-
var __copyProps = (to, from, except, desc) => {
|
|
27
|
-
if (from && typeof from === "object" || typeof from === "function") {
|
|
28
|
-
for (var keys = __getOwnPropNames(from), i = 0, n = keys.length, key; i < n; i++) {
|
|
29
|
-
key = keys[i];
|
|
30
|
-
if (!__hasOwnProp.call(to, key) && key !== except) {
|
|
31
|
-
__defProp(to, key, {
|
|
32
|
-
get: ((k) => from[k]).bind(null, key),
|
|
33
|
-
enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
|
|
34
|
-
});
|
|
35
|
-
}
|
|
36
|
-
}
|
|
37
|
-
}
|
|
38
|
-
return to;
|
|
39
|
-
};
|
|
40
|
-
var __reExport = (target, mod, secondTarget, symbols) => {
|
|
41
|
-
if (symbols) {
|
|
42
|
-
__defProp(target, Symbol.toStringTag, { value: "Module" });
|
|
43
|
-
secondTarget && __defProp(secondTarget, Symbol.toStringTag, { value: "Module" });
|
|
44
|
-
}
|
|
45
|
-
__copyProps(target, mod, "default"), secondTarget && __copyProps(secondTarget, mod, "default");
|
|
46
|
-
};
|
|
47
|
-
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", {
|
|
48
|
-
value: mod,
|
|
49
|
-
enumerable: true
|
|
50
|
-
}) : target, mod));
|
|
51
|
-
|
|
52
|
-
//#endregion
|
|
53
|
-
//#region ../utils/src/index.ts
|
|
54
|
-
const toArray = (a) => Array.isArray(a) ? a : [a];
|
|
55
|
-
function joinWithAnd(values) {
|
|
56
|
-
if (values.length === 0) return "";
|
|
57
|
-
if (values.length === 1) return values[0];
|
|
58
|
-
const last = values.pop();
|
|
59
|
-
return `${values.join(", ")} and ${last}`;
|
|
60
|
-
}
|
|
61
|
-
const kebabCase = (s) => s.replace(/([A-Z])/g, (_, c) => `-${c.toLowerCase()}`);
|
|
62
|
-
const formatFlagName = (n) => n.length <= 1 ? `-${n}` : `--${kebabCase(n)}`;
|
|
63
|
-
const formatVersion = (v) => v.length === 0 ? "" : v.startsWith("v") ? v : `v${v}`;
|
|
64
|
-
const isTruthy = Boolean;
|
|
65
|
-
const objectIsEmpty = (obj) => Object.keys(obj).length === 0;
|
|
66
|
-
|
|
67
|
-
//#endregion
|
|
68
|
-
//#region ../plugin-help/src/utils.ts
|
|
69
|
-
function formatTypeValue(type) {
|
|
70
|
-
if (typeof type === "function") return type.display ?? type.name;
|
|
71
|
-
const innerType = type[0];
|
|
72
|
-
return `Array<${innerType.displayName ?? innerType.name}>`;
|
|
73
|
-
}
|
|
74
|
-
function formatFlagDefault(value) {
|
|
75
|
-
if (typeof value === "function" && "display" in value && value.display) return value.display;
|
|
76
|
-
return String(value);
|
|
77
|
-
}
|
|
78
|
-
function formatCommandName(name) {
|
|
79
|
-
if (name === "") return "(root)";
|
|
80
|
-
return name;
|
|
81
|
-
}
|
|
82
|
-
|
|
83
|
-
//#endregion
|
|
84
|
-
//#region ../plugin-help/src/formatters.ts
|
|
85
|
-
const defaultFormatters = {
|
|
86
|
-
formatTypeValue,
|
|
87
|
-
formatFlagDefault
|
|
88
|
-
};
|
|
89
|
-
|
|
90
|
-
//#endregion
|
|
91
|
-
//#region ../../node_modules/.pnpm/ansi-regex@6.1.0/node_modules/ansi-regex/index.js
|
|
92
|
-
function ansiRegex({ onlyFirst = false } = {}) {
|
|
93
|
-
const pattern = [`[\\u001B\\u009B][[\\]()#;?]*(?:(?:(?:(?:;[-a-zA-Z\\d\\/#&.:=?%@~_]+)*|[a-zA-Z\\d]+(?:;[-a-zA-Z\\d\\/#&.:=?%@~_]*)*)?(?:\\u0007|\\u001B\\u005C|\\u009C))`, "(?:(?:\\d{1,4}(?:;\\d{0,4})*)?[\\dA-PR-TZcf-nq-uy=><~]))"].join("|");
|
|
94
|
-
return new RegExp(pattern, onlyFirst ? void 0 : "g");
|
|
95
|
-
}
|
|
96
|
-
|
|
97
|
-
//#endregion
|
|
98
|
-
//#region ../../node_modules/.pnpm/strip-ansi@7.1.0/node_modules/strip-ansi/index.js
|
|
99
|
-
const regex = ansiRegex();
|
|
100
|
-
function stripAnsi(string) {
|
|
101
|
-
if (typeof string !== "string") throw new TypeError(`Expected a \`string\`, got \`${typeof string}\``);
|
|
102
|
-
return string.replace(regex, "");
|
|
103
|
-
}
|
|
104
|
-
|
|
105
|
-
//#endregion
|
|
106
|
-
//#region ../../node_modules/.pnpm/get-east-asian-width@1.3.0/node_modules/get-east-asian-width/lookup.js
|
|
107
|
-
function isAmbiguous(x) {
|
|
108
|
-
return x === 161 || x === 164 || x === 167 || x === 168 || x === 170 || x === 173 || x === 174 || x >= 176 && x <= 180 || x >= 182 && x <= 186 || x >= 188 && x <= 191 || x === 198 || x === 208 || x === 215 || x === 216 || x >= 222 && x <= 225 || x === 230 || x >= 232 && x <= 234 || x === 236 || x === 237 || x === 240 || x === 242 || x === 243 || x >= 247 && x <= 250 || x === 252 || x === 254 || x === 257 || x === 273 || x === 275 || x === 283 || x === 294 || x === 295 || x === 299 || x >= 305 && x <= 307 || x === 312 || x >= 319 && x <= 322 || x === 324 || x >= 328 && x <= 331 || x === 333 || x === 338 || x === 339 || x === 358 || x === 359 || x === 363 || x === 462 || x === 464 || x === 466 || x === 468 || x === 470 || x === 472 || x === 474 || x === 476 || x === 593 || x === 609 || x === 708 || x === 711 || x >= 713 && x <= 715 || x === 717 || x === 720 || x >= 728 && x <= 731 || x === 733 || x === 735 || x >= 768 && x <= 879 || x >= 913 && x <= 929 || x >= 931 && x <= 937 || x >= 945 && x <= 961 || x >= 963 && x <= 969 || x === 1025 || x >= 1040 && x <= 1103 || x === 1105 || x === 8208 || x >= 8211 && x <= 8214 || x === 8216 || x === 8217 || x === 8220 || x === 8221 || x >= 8224 && x <= 8226 || x >= 8228 && x <= 8231 || x === 8240 || x === 8242 || x === 8243 || x === 8245 || x === 8251 || x === 8254 || x === 8308 || x === 8319 || x >= 8321 && x <= 8324 || x === 8364 || x === 8451 || x === 8453 || x === 8457 || x === 8467 || x === 8470 || x === 8481 || x === 8482 || x === 8486 || x === 8491 || x === 8531 || x === 8532 || x >= 8539 && x <= 8542 || x >= 8544 && x <= 8555 || x >= 8560 && x <= 8569 || x === 8585 || x >= 8592 && x <= 8601 || x === 8632 || x === 8633 || x === 8658 || x === 8660 || x === 8679 || x === 8704 || x === 8706 || x === 8707 || x === 8711 || x === 8712 || x === 8715 || x === 8719 || x === 8721 || x === 8725 || x === 8730 || x >= 8733 && x <= 8736 || x === 8739 || x === 8741 || x >= 8743 && x <= 8748 || x === 8750 || x >= 8756 && x <= 8759 || x === 8764 || x === 8765 || x === 8776 || x === 8780 || x === 8786 || x === 8800 || x === 8801 || x >= 8804 && x <= 8807 || x === 8810 || x === 8811 || x === 8814 || x === 8815 || x === 8834 || x === 8835 || x === 8838 || x === 8839 || x === 8853 || x === 8857 || x === 8869 || x === 8895 || x === 8978 || x >= 9312 && x <= 9449 || x >= 9451 && x <= 9547 || x >= 9552 && x <= 9587 || x >= 9600 && x <= 9615 || x >= 9618 && x <= 9621 || x === 9632 || x === 9633 || x >= 9635 && x <= 9641 || x === 9650 || x === 9651 || x === 9654 || x === 9655 || x === 9660 || x === 9661 || x === 9664 || x === 9665 || x >= 9670 && x <= 9672 || x === 9675 || x >= 9678 && x <= 9681 || x >= 9698 && x <= 9701 || x === 9711 || x === 9733 || x === 9734 || x === 9737 || x === 9742 || x === 9743 || x === 9756 || x === 9758 || x === 9792 || x === 9794 || x === 9824 || x === 9825 || x >= 9827 && x <= 9829 || x >= 9831 && x <= 9834 || x === 9836 || x === 9837 || x === 9839 || x === 9886 || x === 9887 || x === 9919 || x >= 9926 && x <= 9933 || x >= 9935 && x <= 9939 || x >= 9941 && x <= 9953 || x === 9955 || x === 9960 || x === 9961 || x >= 9963 && x <= 9969 || x === 9972 || x >= 9974 && x <= 9977 || x === 9979 || x === 9980 || x === 9982 || x === 9983 || x === 10045 || x >= 10102 && x <= 10111 || x >= 11094 && x <= 11097 || x >= 12872 && x <= 12879 || x >= 57344 && x <= 63743 || x >= 65024 && x <= 65039 || x === 65533 || x >= 127232 && x <= 127242 || x >= 127248 && x <= 127277 || x >= 127280 && x <= 127337 || x >= 127344 && x <= 127373 || x === 127375 || x === 127376 || x >= 127387 && x <= 127404 || x >= 917760 && x <= 917999 || x >= 983040 && x <= 1048573 || x >= 1048576 && x <= 1114109;
|
|
109
|
-
}
|
|
110
|
-
function isFullWidth(x) {
|
|
111
|
-
return x === 12288 || x >= 65281 && x <= 65376 || x >= 65504 && x <= 65510;
|
|
112
|
-
}
|
|
113
|
-
function isWide(x) {
|
|
114
|
-
return x >= 4352 && x <= 4447 || x === 8986 || x === 8987 || x === 9001 || x === 9002 || x >= 9193 && x <= 9196 || x === 9200 || x === 9203 || x === 9725 || x === 9726 || x === 9748 || x === 9749 || x >= 9776 && x <= 9783 || x >= 9800 && x <= 9811 || x === 9855 || x >= 9866 && x <= 9871 || x === 9875 || x === 9889 || x === 9898 || x === 9899 || x === 9917 || x === 9918 || x === 9924 || x === 9925 || x === 9934 || x === 9940 || x === 9962 || x === 9970 || x === 9971 || x === 9973 || x === 9978 || x === 9981 || x === 9989 || x === 9994 || x === 9995 || x === 10024 || x === 10060 || x === 10062 || x >= 10067 && x <= 10069 || x === 10071 || x >= 10133 && x <= 10135 || x === 10160 || x === 10175 || x === 11035 || x === 11036 || x === 11088 || x === 11093 || x >= 11904 && x <= 11929 || x >= 11931 && x <= 12019 || x >= 12032 && x <= 12245 || x >= 12272 && x <= 12287 || x >= 12289 && x <= 12350 || x >= 12353 && x <= 12438 || x >= 12441 && x <= 12543 || x >= 12549 && x <= 12591 || x >= 12593 && x <= 12686 || x >= 12688 && x <= 12773 || x >= 12783 && x <= 12830 || x >= 12832 && x <= 12871 || x >= 12880 && x <= 42124 || x >= 42128 && x <= 42182 || x >= 43360 && x <= 43388 || x >= 44032 && x <= 55203 || x >= 63744 && x <= 64255 || x >= 65040 && x <= 65049 || x >= 65072 && x <= 65106 || x >= 65108 && x <= 65126 || x >= 65128 && x <= 65131 || x >= 94176 && x <= 94180 || x === 94192 || x === 94193 || x >= 94208 && x <= 100343 || x >= 100352 && x <= 101589 || x >= 101631 && x <= 101640 || x >= 110576 && x <= 110579 || x >= 110581 && x <= 110587 || x === 110589 || x === 110590 || x >= 110592 && x <= 110882 || x === 110898 || x >= 110928 && x <= 110930 || x === 110933 || x >= 110948 && x <= 110951 || x >= 110960 && x <= 111355 || x >= 119552 && x <= 119638 || x >= 119648 && x <= 119670 || x === 126980 || x === 127183 || x === 127374 || x >= 127377 && x <= 127386 || x >= 127488 && x <= 127490 || x >= 127504 && x <= 127547 || x >= 127552 && x <= 127560 || x === 127568 || x === 127569 || x >= 127584 && x <= 127589 || x >= 127744 && x <= 127776 || x >= 127789 && x <= 127797 || x >= 127799 && x <= 127868 || x >= 127870 && x <= 127891 || x >= 127904 && x <= 127946 || x >= 127951 && x <= 127955 || x >= 127968 && x <= 127984 || x === 127988 || x >= 127992 && x <= 128062 || x === 128064 || x >= 128066 && x <= 128252 || x >= 128255 && x <= 128317 || x >= 128331 && x <= 128334 || x >= 128336 && x <= 128359 || x === 128378 || x === 128405 || x === 128406 || x === 128420 || x >= 128507 && x <= 128591 || x >= 128640 && x <= 128709 || x === 128716 || x >= 128720 && x <= 128722 || x >= 128725 && x <= 128727 || x >= 128732 && x <= 128735 || x === 128747 || x === 128748 || x >= 128756 && x <= 128764 || x >= 128992 && x <= 129003 || x === 129008 || x >= 129292 && x <= 129338 || x >= 129340 && x <= 129349 || x >= 129351 && x <= 129535 || x >= 129648 && x <= 129660 || x >= 129664 && x <= 129673 || x >= 129679 && x <= 129734 || x >= 129742 && x <= 129756 || x >= 129759 && x <= 129769 || x >= 129776 && x <= 129784 || x >= 131072 && x <= 196605 || x >= 196608 && x <= 262141;
|
|
115
|
-
}
|
|
116
|
-
|
|
117
|
-
//#endregion
|
|
118
|
-
//#region ../../node_modules/.pnpm/get-east-asian-width@1.3.0/node_modules/get-east-asian-width/index.js
|
|
119
|
-
function validate(codePoint) {
|
|
120
|
-
if (!Number.isSafeInteger(codePoint)) throw new TypeError(`Expected a code point, got \`${typeof codePoint}\`.`);
|
|
121
|
-
}
|
|
122
|
-
function eastAsianWidth(codePoint, { ambiguousAsWide = false } = {}) {
|
|
123
|
-
validate(codePoint);
|
|
124
|
-
if (isFullWidth(codePoint) || isWide(codePoint) || ambiguousAsWide && isAmbiguous(codePoint)) return 2;
|
|
125
|
-
return 1;
|
|
126
|
-
}
|
|
127
|
-
|
|
128
|
-
//#endregion
|
|
129
|
-
//#region ../../node_modules/.pnpm/string-width@8.1.0/node_modules/string-width/index.js
|
|
130
|
-
/**
|
|
131
|
-
Logic:
|
|
132
|
-
- Segment graphemes to match how terminals render clusters.
|
|
133
|
-
- Width rules:
|
|
134
|
-
1. Skip non-printing clusters (Default_Ignorable, Control, pure Mark, lone Surrogates). Tabs are ignored by design.
|
|
135
|
-
2. RGI emoji clusters (\p{RGI_Emoji}) are double-width.
|
|
136
|
-
3. Otherwise use East Asian Width of the cluster’s first visible code point, and add widths for trailing Halfwidth/Fullwidth Forms within the same cluster (e.g., dakuten/handakuten/prolonged sound mark).
|
|
137
|
-
*/
|
|
138
|
-
const segmenter = new Intl.Segmenter();
|
|
139
|
-
const zeroWidthClusterRegex = /^(?:\p{Default_Ignorable_Code_Point}|\p{Control}|\p{Mark}|\p{Surrogate})+$/v;
|
|
140
|
-
const leadingNonPrintingRegex = /^[\p{Default_Ignorable_Code_Point}\p{Control}\p{Format}\p{Mark}\p{Surrogate}]+/v;
|
|
141
|
-
const rgiEmojiRegex = /^\p{RGI_Emoji}$/v;
|
|
142
|
-
function baseVisible(segment) {
|
|
143
|
-
return segment.replace(leadingNonPrintingRegex, "");
|
|
144
|
-
}
|
|
145
|
-
function isZeroWidthCluster(segment) {
|
|
146
|
-
return zeroWidthClusterRegex.test(segment);
|
|
147
|
-
}
|
|
148
|
-
function trailingHalfwidthWidth(segment, eastAsianWidthOptions) {
|
|
149
|
-
let extra = 0;
|
|
150
|
-
if (segment.length > 1) {
|
|
151
|
-
for (const char of segment.slice(1)) if (char >= "" && char <= "") extra += eastAsianWidth(char.codePointAt(0), eastAsianWidthOptions);
|
|
152
|
-
}
|
|
153
|
-
return extra;
|
|
154
|
-
}
|
|
155
|
-
function stringWidth(input, options = {}) {
|
|
156
|
-
if (typeof input !== "string" || input.length === 0) return 0;
|
|
157
|
-
const { ambiguousIsNarrow = true, countAnsiEscapeCodes = false } = options;
|
|
158
|
-
let string = input;
|
|
159
|
-
if (!countAnsiEscapeCodes) string = stripAnsi(string);
|
|
160
|
-
if (string.length === 0) return 0;
|
|
161
|
-
let width = 0;
|
|
162
|
-
const eastAsianWidthOptions = { ambiguousAsWide: !ambiguousIsNarrow };
|
|
163
|
-
for (const { segment } of segmenter.segment(string)) {
|
|
164
|
-
if (isZeroWidthCluster(segment)) continue;
|
|
165
|
-
if (rgiEmojiRegex.test(segment)) {
|
|
166
|
-
width += 2;
|
|
167
|
-
continue;
|
|
168
|
-
}
|
|
169
|
-
const codePoint = baseVisible(segment).codePointAt(0);
|
|
170
|
-
width += eastAsianWidth(codePoint, eastAsianWidthOptions);
|
|
171
|
-
width += trailingHalfwidthWidth(segment, eastAsianWidthOptions);
|
|
172
|
-
}
|
|
173
|
-
return width;
|
|
174
|
-
}
|
|
175
|
-
|
|
176
|
-
//#endregion
|
|
177
|
-
//#region ../../node_modules/.pnpm/text-table@0.2.0/node_modules/text-table/index.js
|
|
178
|
-
var require_text_table = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
179
|
-
module.exports = function(rows_, opts) {
|
|
180
|
-
if (!opts) opts = {};
|
|
181
|
-
var hsep = opts.hsep === void 0 ? " " : opts.hsep;
|
|
182
|
-
var align = opts.align || [];
|
|
183
|
-
var stringLength = opts.stringLength || function(s) {
|
|
184
|
-
return String(s).length;
|
|
185
|
-
};
|
|
186
|
-
var dotsizes = reduce(rows_, function(acc, row) {
|
|
187
|
-
forEach(row, function(c, ix) {
|
|
188
|
-
var n = dotindex(c);
|
|
189
|
-
if (!acc[ix] || n > acc[ix]) acc[ix] = n;
|
|
190
|
-
});
|
|
191
|
-
return acc;
|
|
192
|
-
}, []);
|
|
193
|
-
var rows = map(rows_, function(row) {
|
|
194
|
-
return map(row, function(c_, ix) {
|
|
195
|
-
var c = String(c_);
|
|
196
|
-
if (align[ix] === ".") {
|
|
197
|
-
var index = dotindex(c);
|
|
198
|
-
var size = dotsizes[ix] + (/\./.test(c) ? 1 : 2) - (stringLength(c) - index);
|
|
199
|
-
return c + Array(size).join(" ");
|
|
200
|
-
} else return c;
|
|
201
|
-
});
|
|
202
|
-
});
|
|
203
|
-
var sizes = reduce(rows, function(acc, row) {
|
|
204
|
-
forEach(row, function(c, ix) {
|
|
205
|
-
var n = stringLength(c);
|
|
206
|
-
if (!acc[ix] || n > acc[ix]) acc[ix] = n;
|
|
207
|
-
});
|
|
208
|
-
return acc;
|
|
209
|
-
}, []);
|
|
210
|
-
return map(rows, function(row) {
|
|
211
|
-
return map(row, function(c, ix) {
|
|
212
|
-
var n = sizes[ix] - stringLength(c) || 0;
|
|
213
|
-
var s = Array(Math.max(n + 1, 1)).join(" ");
|
|
214
|
-
if (align[ix] === "r" || align[ix] === ".") return s + c;
|
|
215
|
-
if (align[ix] === "c") return Array(Math.ceil(n / 2 + 1)).join(" ") + c + Array(Math.floor(n / 2 + 1)).join(" ");
|
|
216
|
-
return c + s;
|
|
217
|
-
}).join(hsep).replace(/\s+$/, "");
|
|
218
|
-
}).join("\n");
|
|
219
|
-
};
|
|
220
|
-
function dotindex(c) {
|
|
221
|
-
var m = /\.[^.]*$/.exec(c);
|
|
222
|
-
return m ? m.index + 1 : c.length;
|
|
223
|
-
}
|
|
224
|
-
function reduce(xs, f, init) {
|
|
225
|
-
if (xs.reduce) return xs.reduce(f, init);
|
|
226
|
-
var i = 0;
|
|
227
|
-
var acc = arguments.length >= 3 ? init : xs[i++];
|
|
228
|
-
for (; i < xs.length; i++) f(acc, xs[i], i);
|
|
229
|
-
return acc;
|
|
230
|
-
}
|
|
231
|
-
function forEach(xs, f) {
|
|
232
|
-
if (xs.forEach) return xs.forEach(f);
|
|
233
|
-
for (var i = 0; i < xs.length; i++) f.call(xs, xs[i], i);
|
|
234
|
-
}
|
|
235
|
-
function map(xs, f) {
|
|
236
|
-
if (xs.map) return xs.map(f);
|
|
237
|
-
var res = [];
|
|
238
|
-
for (var i = 0; i < xs.length; i++) res.push(f.call(xs, xs[i], i));
|
|
239
|
-
return res;
|
|
240
|
-
}
|
|
241
|
-
}));
|
|
242
|
-
|
|
243
|
-
//#endregion
|
|
244
|
-
//#region ../../node_modules/.pnpm/yoctocolors@2.1.2/node_modules/yoctocolors/base.js
|
|
245
|
-
const hasColors = tty?.WriteStream?.prototype?.hasColors?.() ?? false;
|
|
246
|
-
const format = (open, close) => {
|
|
247
|
-
if (!hasColors) return (input) => input;
|
|
248
|
-
const openCode = `\u001B[${open}m`;
|
|
249
|
-
const closeCode = `\u001B[${close}m`;
|
|
250
|
-
return (input) => {
|
|
251
|
-
const string = input + "";
|
|
252
|
-
let index = string.indexOf(closeCode);
|
|
253
|
-
if (index === -1) return openCode + string + closeCode;
|
|
254
|
-
let result = openCode;
|
|
255
|
-
let lastIndex = 0;
|
|
256
|
-
const replaceCode = (close === 22 ? closeCode : "") + openCode;
|
|
257
|
-
while (index !== -1) {
|
|
258
|
-
result += string.slice(lastIndex, index) + replaceCode;
|
|
259
|
-
lastIndex = index + closeCode.length;
|
|
260
|
-
index = string.indexOf(closeCode, lastIndex);
|
|
261
|
-
}
|
|
262
|
-
result += string.slice(lastIndex) + closeCode;
|
|
263
|
-
return result;
|
|
264
|
-
};
|
|
265
|
-
};
|
|
266
|
-
const reset = format(0, 0);
|
|
267
|
-
const bold = format(1, 22);
|
|
268
|
-
const dim = format(2, 22);
|
|
269
|
-
const italic = format(3, 23);
|
|
270
|
-
const underline = format(4, 24);
|
|
271
|
-
const overline = format(53, 55);
|
|
272
|
-
const inverse = format(7, 27);
|
|
273
|
-
const hidden = format(8, 28);
|
|
274
|
-
const strikethrough = format(9, 29);
|
|
275
|
-
const black = format(30, 39);
|
|
276
|
-
const red = format(31, 39);
|
|
277
|
-
const green = format(32, 39);
|
|
278
|
-
const yellow = format(33, 39);
|
|
279
|
-
const blue = format(34, 39);
|
|
280
|
-
const magenta = format(35, 39);
|
|
281
|
-
const cyan = format(36, 39);
|
|
282
|
-
const white = format(37, 39);
|
|
283
|
-
const gray = format(90, 39);
|
|
284
|
-
const bgBlack = format(40, 49);
|
|
285
|
-
const bgRed = format(41, 49);
|
|
286
|
-
const bgGreen = format(42, 49);
|
|
287
|
-
const bgYellow = format(43, 49);
|
|
288
|
-
const bgBlue = format(44, 49);
|
|
289
|
-
const bgMagenta = format(45, 49);
|
|
290
|
-
const bgCyan = format(46, 49);
|
|
291
|
-
const bgWhite = format(47, 49);
|
|
292
|
-
const bgGray = format(100, 49);
|
|
293
|
-
const redBright = format(91, 39);
|
|
294
|
-
const greenBright = format(92, 39);
|
|
295
|
-
const yellowBright = format(93, 39);
|
|
296
|
-
const blueBright = format(94, 39);
|
|
297
|
-
const magentaBright = format(95, 39);
|
|
298
|
-
const cyanBright = format(96, 39);
|
|
299
|
-
const whiteBright = format(97, 39);
|
|
300
|
-
const bgRedBright = format(101, 49);
|
|
301
|
-
const bgGreenBright = format(102, 49);
|
|
302
|
-
const bgYellowBright = format(103, 49);
|
|
303
|
-
const bgBlueBright = format(104, 49);
|
|
304
|
-
const bgMagentaBright = format(105, 49);
|
|
305
|
-
const bgCyanBright = format(106, 49);
|
|
306
|
-
const bgWhiteBright = format(107, 49);
|
|
307
|
-
|
|
308
|
-
//#endregion
|
|
309
|
-
//#region ../plugin-help/src/renderer.ts
|
|
310
|
-
var import_text_table = /* @__PURE__ */ __toESM(require_text_table(), 1);
|
|
311
|
-
const DEFAULT_GROUP_KEY = "default";
|
|
312
|
-
const table = (items) => (0, import_text_table.default)(items, { stringLength: stringWidth });
|
|
313
|
-
const splitTable = (items) => table(items).split("\n");
|
|
314
|
-
const DELIMITER = "-";
|
|
315
|
-
const INDENT = " ".repeat(2);
|
|
316
|
-
const withIndent = (str) => `${INDENT}${str}`;
|
|
317
|
-
function groupDefinitionsToMap(definitions) {
|
|
318
|
-
const map$1 = /* @__PURE__ */ new Map();
|
|
319
|
-
if (definitions) for (const [key, name] of definitions) map$1.set(key, name);
|
|
320
|
-
return map$1;
|
|
321
|
-
}
|
|
322
|
-
function validateGroup(group, groupMap, itemType, itemName) {
|
|
323
|
-
if (group && group !== DEFAULT_GROUP_KEY && !groupMap.has(group)) throw new Error(`Unknown ${itemType} group "${group}" for "${itemName}". Available groups: ${[...groupMap.keys()].join(", ") || "(none)"}`);
|
|
324
|
-
}
|
|
325
|
-
var HelpRenderer = class {
|
|
326
|
-
_command;
|
|
327
|
-
get _commandGroups() {
|
|
328
|
-
return groupDefinitionsToMap(this._getGroups().commands);
|
|
329
|
-
}
|
|
330
|
-
get _flagGroups() {
|
|
331
|
-
return groupDefinitionsToMap(this._getGroups().flags);
|
|
332
|
-
}
|
|
333
|
-
get _globalFlagGroups() {
|
|
334
|
-
return groupDefinitionsToMap(this._getGroups().globalFlags);
|
|
335
|
-
}
|
|
336
|
-
constructor(_formatters, _cli, _globalFlags, _getGroups, _getExamples, _notes) {
|
|
337
|
-
this._formatters = _formatters;
|
|
338
|
-
this._cli = _cli;
|
|
339
|
-
this._globalFlags = _globalFlags;
|
|
340
|
-
this._getGroups = _getGroups;
|
|
341
|
-
this._getExamples = _getExamples;
|
|
342
|
-
this._notes = _notes;
|
|
343
|
-
}
|
|
344
|
-
setCommand(command) {
|
|
345
|
-
if (command) {
|
|
346
|
-
this._command = command;
|
|
347
|
-
this._getExamples = () => command?.help?.examples;
|
|
348
|
-
this._notes = command?.help?.notes;
|
|
349
|
-
}
|
|
350
|
-
}
|
|
351
|
-
renderSections(sections) {
|
|
352
|
-
return sections.filter(isTruthy).map((section) => {
|
|
353
|
-
const body = Array.isArray(section.body) ? section.body.filter((s) => s !== void 0).join("\n") : section.body;
|
|
354
|
-
if (!section.title) return body;
|
|
355
|
-
return `${underline(bold(section.title))}\n${body.split("\n").map(withIndent).join("\n")}`;
|
|
356
|
-
}).join("\n\n");
|
|
357
|
-
}
|
|
358
|
-
render() {
|
|
359
|
-
const sections = [
|
|
360
|
-
this.renderHeader(),
|
|
361
|
-
this.renderUsage(),
|
|
362
|
-
this.renderParameters(),
|
|
363
|
-
this.renderCommandFlags(),
|
|
364
|
-
this.renderGlobalFlags(),
|
|
365
|
-
this.renderCommands(),
|
|
366
|
-
this.renderExamples(),
|
|
367
|
-
this.renderNotes()
|
|
368
|
-
];
|
|
369
|
-
return this.renderSections(sections);
|
|
370
|
-
}
|
|
371
|
-
renderHeader() {
|
|
372
|
-
const { _name, _version, _description } = this._cli;
|
|
373
|
-
const command = this._command;
|
|
374
|
-
const description = command ? command.description : _description;
|
|
375
|
-
const formattedCommandName = command?.name ? ` ${bold(command.name)}` : "";
|
|
376
|
-
const headerLine = command ? `${dim(_name)}${formattedCommandName}` : `${bold(_name)} ${formatVersion(_version)}`;
|
|
377
|
-
const alias = command?.alias ? `Alias${toArray(command.alias).length > 1 ? "es" : ""}: ${toArray(command.alias).map((a) => bold(a)).join(", ")}` : void 0;
|
|
378
|
-
return { body: [`${headerLine}${description ? ` ${DELIMITER} ${description}` : ""}`, alias] };
|
|
379
|
-
}
|
|
380
|
-
renderUsage() {
|
|
381
|
-
const { _scriptName } = this._cli;
|
|
382
|
-
const command = this._command;
|
|
383
|
-
let usage = `$ ${_scriptName}`;
|
|
384
|
-
if (command) {
|
|
385
|
-
if (command.name) usage += ` ${command.name}`;
|
|
386
|
-
if (command.parameters) usage += ` ${command.parameters.map((p$1) => typeof p$1 === "string" ? p$1 : p$1.key).join(" ")}`;
|
|
387
|
-
} else if (this._cli._commands.size > 0 && !(this._cli._commands.has("") && this._cli._commands.size === 1)) usage += this._cli._commands.has("") ? ` ${dim("[command]")}` : ` ${dim("<command>")}`;
|
|
388
|
-
if (command?.flags && !objectIsEmpty(command.flags) || !objectIsEmpty(this._globalFlags)) usage += ` ${dim("[flags]")}`;
|
|
389
|
-
return {
|
|
390
|
-
title: "Usage",
|
|
391
|
-
body: [usage]
|
|
392
|
-
};
|
|
393
|
-
}
|
|
394
|
-
renderParameters() {
|
|
395
|
-
const command = this._command;
|
|
396
|
-
if (!command?.parameters || command.parameters.length === 0) return;
|
|
397
|
-
return {
|
|
398
|
-
title: "Parameters",
|
|
399
|
-
body: splitTable(command.parameters.filter((p$1) => p$1 !== DOUBLE_DASH).map((parameter) => {
|
|
400
|
-
const key = typeof parameter === "string" ? parameter : parameter.key;
|
|
401
|
-
const type = typeof parameter === "string" ? void 0 : parameter.type;
|
|
402
|
-
const formattedType = type ? this._formatters.formatTypeValue(type) : "string";
|
|
403
|
-
const description = typeof parameter === "string" ? void 0 : parameter.description;
|
|
404
|
-
return [
|
|
405
|
-
bold(key),
|
|
406
|
-
dim(formattedType),
|
|
407
|
-
description
|
|
408
|
-
].filter(isTruthy);
|
|
409
|
-
}))
|
|
410
|
-
};
|
|
411
|
-
}
|
|
412
|
-
getSubcommands(parentCommandName) {
|
|
413
|
-
const subcommands = /* @__PURE__ */ new Map();
|
|
414
|
-
if (parentCommandName === "") return subcommands;
|
|
415
|
-
const prefix = `${parentCommandName} `;
|
|
416
|
-
for (const [name, command] of this._cli._commands) if (name.startsWith(prefix)) {
|
|
417
|
-
const subcommandName = name.slice(prefix.length);
|
|
418
|
-
subcommands.set(subcommandName, command);
|
|
419
|
-
}
|
|
420
|
-
return subcommands;
|
|
421
|
-
}
|
|
422
|
-
buildGroupedCommandsBody(commandsToShow, prefix) {
|
|
423
|
-
const groupedCommands = /* @__PURE__ */ new Map();
|
|
424
|
-
const defaultCommands = [];
|
|
425
|
-
let rootCommand = [];
|
|
426
|
-
for (const command of commandsToShow.values()) {
|
|
427
|
-
if (command.__isAlias || command.help?.show === false) continue;
|
|
428
|
-
const group = command.help?.group;
|
|
429
|
-
validateGroup(group, this._commandGroups, "command", command.name);
|
|
430
|
-
const item = [`${bold(formatCommandName(command.name.slice(prefix.length)))}${command.alias ? ` (${toArray(command.alias).join(", ")})` : ""}`, command.description].filter(isTruthy);
|
|
431
|
-
if (command.name === "") rootCommand = item;
|
|
432
|
-
else if (group && group !== DEFAULT_GROUP_KEY) {
|
|
433
|
-
const groupItems = groupedCommands.get(group) ?? [];
|
|
434
|
-
groupItems.push(item);
|
|
435
|
-
groupedCommands.set(group, groupItems);
|
|
436
|
-
} else defaultCommands.push(item);
|
|
437
|
-
}
|
|
438
|
-
const body = [];
|
|
439
|
-
const defaultGroup = [];
|
|
440
|
-
if (rootCommand.length > 0) defaultGroup.push(rootCommand);
|
|
441
|
-
if (defaultCommands.length > 0) defaultGroup.push(...defaultCommands);
|
|
442
|
-
if (defaultGroup.length > 0) body.push(...splitTable(defaultGroup));
|
|
443
|
-
for (const [key, name] of this._commandGroups) {
|
|
444
|
-
const items = groupedCommands.get(key);
|
|
445
|
-
if (items && items.length > 0) {
|
|
446
|
-
if (body.length > 0) body.push("");
|
|
447
|
-
body.push(`${dim(name)}`);
|
|
448
|
-
body.push(...splitTable(items).map(withIndent));
|
|
449
|
-
}
|
|
450
|
-
}
|
|
451
|
-
return body;
|
|
452
|
-
}
|
|
453
|
-
renderAvailableSubcommands(parentCommandName) {
|
|
454
|
-
const subcommands = this.getSubcommands(parentCommandName);
|
|
455
|
-
if (subcommands.size === 0) return "";
|
|
456
|
-
const prefix = `${parentCommandName} `;
|
|
457
|
-
const body = this.buildGroupedCommandsBody(subcommands, prefix);
|
|
458
|
-
if (body.length === 0) return "";
|
|
459
|
-
const sections = [{ body: `${this._cli._name} ${bold(parentCommandName)} not found` }, {
|
|
460
|
-
title: "Available Subcommands",
|
|
461
|
-
body
|
|
462
|
-
}];
|
|
463
|
-
return this.renderSections(sections);
|
|
464
|
-
}
|
|
465
|
-
renderCommands() {
|
|
466
|
-
const commands = this._cli._commands;
|
|
467
|
-
let commandsToShow;
|
|
468
|
-
let title = "Commands";
|
|
469
|
-
let prefix = "";
|
|
470
|
-
if (this._command) {
|
|
471
|
-
prefix = this._command.name ? `${this._command.name} ` : "";
|
|
472
|
-
title = "Subcommands";
|
|
473
|
-
commandsToShow = this.getSubcommands(this._command.name);
|
|
474
|
-
if (commandsToShow.size === 0) return;
|
|
475
|
-
} else commandsToShow = commands;
|
|
476
|
-
if (commandsToShow.size === 0) return;
|
|
477
|
-
const body = this.buildGroupedCommandsBody(commandsToShow, prefix);
|
|
478
|
-
return {
|
|
479
|
-
title,
|
|
480
|
-
body
|
|
481
|
-
};
|
|
482
|
-
}
|
|
483
|
-
renderFlagItem(name, flag) {
|
|
484
|
-
flag = normalizeFlagValue(flag);
|
|
485
|
-
let flagName = formatFlagName(name);
|
|
486
|
-
if (flag.short) flagName += `, ${formatFlagName(flag.short)}`;
|
|
487
|
-
const type = this._formatters.formatTypeValue(flag.type);
|
|
488
|
-
const default_ = flag.default !== void 0 && dim(`[default: ${bold(this._formatters.formatFlagDefault(flag.default))}]`);
|
|
489
|
-
return [
|
|
490
|
-
bold(flagName),
|
|
491
|
-
dim(type),
|
|
492
|
-
flag.description,
|
|
493
|
-
default_
|
|
494
|
-
].filter(isTruthy);
|
|
495
|
-
}
|
|
496
|
-
renderGroupedFlags(flags, groupMap, itemType) {
|
|
497
|
-
const groupedFlags = /* @__PURE__ */ new Map();
|
|
498
|
-
const defaultFlags = [];
|
|
499
|
-
for (const [name, flag] of Object.entries(flags)) {
|
|
500
|
-
const group = flag.help?.group;
|
|
501
|
-
validateGroup(group, groupMap, itemType, name);
|
|
502
|
-
const item = this.renderFlagItem(name, flag);
|
|
503
|
-
if (group && group !== DEFAULT_GROUP_KEY) {
|
|
504
|
-
const groupItems = groupedFlags.get(group) ?? [];
|
|
505
|
-
groupItems.push(item);
|
|
506
|
-
groupedFlags.set(group, groupItems);
|
|
507
|
-
} else defaultFlags.push(item);
|
|
508
|
-
}
|
|
509
|
-
const body = [];
|
|
510
|
-
if (defaultFlags.length > 0) body.push(...splitTable(defaultFlags));
|
|
511
|
-
for (const [key, name] of groupMap) {
|
|
512
|
-
const items = groupedFlags.get(key);
|
|
513
|
-
if (items && items.length > 0) {
|
|
514
|
-
if (body.length > 0) body.push("");
|
|
515
|
-
body.push(`${dim(name)}`);
|
|
516
|
-
body.push(...splitTable(items).map(withIndent));
|
|
517
|
-
}
|
|
518
|
-
}
|
|
519
|
-
return body;
|
|
520
|
-
}
|
|
521
|
-
renderCommandFlags() {
|
|
522
|
-
const command = this._command;
|
|
523
|
-
if (!command?.flags || objectIsEmpty(command.flags)) return;
|
|
524
|
-
return {
|
|
525
|
-
title: "Flags",
|
|
526
|
-
body: this.renderGroupedFlags(command.flags, this._flagGroups, "flag")
|
|
527
|
-
};
|
|
528
|
-
}
|
|
529
|
-
renderGlobalFlags() {
|
|
530
|
-
if (!this._globalFlags || objectIsEmpty(this._globalFlags)) return;
|
|
531
|
-
return {
|
|
532
|
-
title: "Global Flags",
|
|
533
|
-
body: this.renderGroupedFlags(this._globalFlags, this._globalFlagGroups, "global flag")
|
|
534
|
-
};
|
|
535
|
-
}
|
|
536
|
-
renderNotes() {
|
|
537
|
-
if (!this._notes?.length) return;
|
|
538
|
-
return {
|
|
539
|
-
title: "Notes",
|
|
540
|
-
body: this._notes
|
|
541
|
-
};
|
|
542
|
-
}
|
|
543
|
-
renderExamples() {
|
|
544
|
-
const examples = this._getExamples();
|
|
545
|
-
if (!examples?.length) return;
|
|
546
|
-
return {
|
|
547
|
-
title: "Examples",
|
|
548
|
-
body: splitTable(examples.map(([command, description]) => {
|
|
549
|
-
return [
|
|
550
|
-
command,
|
|
551
|
-
DELIMITER,
|
|
552
|
-
description
|
|
553
|
-
];
|
|
554
|
-
}))
|
|
555
|
-
};
|
|
556
|
-
}
|
|
557
|
-
};
|
|
558
|
-
|
|
559
|
-
//#endregion
|
|
560
|
-
//#region ../plugin-help/src/store.ts
|
|
561
|
-
function addStoreApi(cli, { groups }) {
|
|
562
|
-
cli.store.help = { addGroup: (options) => {
|
|
563
|
-
if (options.commands) groups.commands = [...groups.commands ?? [], ...options.commands];
|
|
564
|
-
if (options.flags) groups.flags = [...groups.flags ?? [], ...options.flags];
|
|
565
|
-
if (options.globalFlags) groups.globalFlags = [...groups.globalFlags ?? [], ...options.globalFlags];
|
|
566
|
-
} };
|
|
567
|
-
}
|
|
568
|
-
|
|
569
|
-
//#endregion
|
|
570
|
-
//#region ../plugin-help/src/index.ts
|
|
571
|
-
const helpPlugin = ({ command = true, flag = true, showHelpWhenNoCommandSpecified = true, notes, examples, header, footer, formatters, groups = {} } = {}) => definePlugin({ setup: (cli) => {
|
|
572
|
-
addStoreApi(cli, { groups });
|
|
573
|
-
const mergedFormatters = {
|
|
574
|
-
...defaultFormatters,
|
|
575
|
-
...formatters
|
|
576
|
-
};
|
|
577
|
-
const generalHelpNotes = [
|
|
578
|
-
"If no command is specified, show help for the CLI.",
|
|
579
|
-
"If a command is specified, show help for the command.",
|
|
580
|
-
flag && "-h is an alias for --help."
|
|
581
|
-
].filter(isTruthy);
|
|
582
|
-
const getGeneralHelpExamples = () => [
|
|
583
|
-
command && [`$ ${cli._scriptName} help`, "Show help"],
|
|
584
|
-
command && [`$ ${cli._scriptName} help <command>`, "Show help for a specific command"],
|
|
585
|
-
flag && [`$ ${cli._scriptName} <command> --help`, "Show help for a specific command"]
|
|
586
|
-
].filter(isTruthy);
|
|
587
|
-
const effectiveNotes = notes ?? generalHelpNotes;
|
|
588
|
-
const getEffectiveExamples = () => examples ?? getGeneralHelpExamples();
|
|
589
|
-
function printHelp(s) {
|
|
590
|
-
if (header) console.log(header);
|
|
591
|
-
console.log(s);
|
|
592
|
-
if (footer) console.log(footer);
|
|
593
|
-
}
|
|
594
|
-
const renderer = new HelpRenderer(mergedFormatters, cli, cli._globalFlags, () => groups, getEffectiveExamples, effectiveNotes);
|
|
595
|
-
function tryPrintSubcommandsHelp(commandName) {
|
|
596
|
-
const subcommandsOutput = renderer.renderAvailableSubcommands(commandName);
|
|
597
|
-
if (subcommandsOutput) {
|
|
598
|
-
printHelp(subcommandsOutput);
|
|
599
|
-
return true;
|
|
600
|
-
}
|
|
601
|
-
return false;
|
|
602
|
-
}
|
|
603
|
-
if (command) cli.command("help", "Show help", {
|
|
604
|
-
parameters: ["[command...]"],
|
|
605
|
-
help: {
|
|
606
|
-
notes: generalHelpNotes,
|
|
607
|
-
examples: getGeneralHelpExamples()
|
|
608
|
-
}
|
|
609
|
-
}).on("help", (ctx) => {
|
|
610
|
-
const commandName = ctx.parameters.command;
|
|
611
|
-
let command$1;
|
|
612
|
-
if (commandName.length > 0) {
|
|
613
|
-
[command$1] = resolveCommand(cli._commands, commandName);
|
|
614
|
-
if (!command$1) {
|
|
615
|
-
const parentCommandName = commandName.join(" ");
|
|
616
|
-
if (tryPrintSubcommandsHelp(parentCommandName)) return;
|
|
617
|
-
throw new NoSuchCommandError(parentCommandName);
|
|
618
|
-
}
|
|
619
|
-
}
|
|
620
|
-
renderer.setCommand(command$1);
|
|
621
|
-
printHelp(renderer.render());
|
|
622
|
-
});
|
|
623
|
-
if (flag) cli.globalFlag("help", "Show help", {
|
|
624
|
-
short: "h",
|
|
625
|
-
type: Boolean,
|
|
626
|
-
default: false
|
|
627
|
-
});
|
|
628
|
-
cli.interceptor({
|
|
629
|
-
enforce: "post",
|
|
630
|
-
handler: async (ctx, next) => {
|
|
631
|
-
if (ctx.flags.help) {
|
|
632
|
-
const command$1 = ctx.command;
|
|
633
|
-
if (!command$1 && ctx.rawParsed.parameters.length > 0) {
|
|
634
|
-
if (tryPrintSubcommandsHelp(ctx.rawParsed.parameters.join(" "))) return;
|
|
635
|
-
await next();
|
|
636
|
-
}
|
|
637
|
-
renderer.setCommand(command$1);
|
|
638
|
-
printHelp(renderer.render());
|
|
639
|
-
} else if (showHelpWhenNoCommandSpecified && !ctx.command && ctx.rawParsed.parameters.length === 0) printHelp(renderer.render());
|
|
640
|
-
else await next();
|
|
641
|
-
}
|
|
642
|
-
});
|
|
643
|
-
} });
|
|
644
|
-
|
|
645
|
-
//#endregion
|
|
646
|
-
//#region ../plugin-version/src/index.ts
|
|
647
|
-
const versionPlugin = ({ command = true, flag = true } = {}) => definePlugin({ setup: (cli) => {
|
|
648
|
-
if (command) cli.command("version", "Prints current version", {}).on("version", () => {
|
|
649
|
-
console.log(formatVersion(cli._version));
|
|
650
|
-
});
|
|
651
|
-
if (flag) cli.globalFlag("version", "Prints current version", {
|
|
652
|
-
short: "V",
|
|
653
|
-
type: Boolean,
|
|
654
|
-
default: false
|
|
655
|
-
}).interceptor({
|
|
656
|
-
enforce: "pre",
|
|
657
|
-
handler: async (ctx, next) => {
|
|
658
|
-
if (ctx.flags.version) console.log(formatVersion(cli._version));
|
|
659
|
-
else await next();
|
|
660
|
-
}
|
|
661
|
-
});
|
|
662
|
-
} });
|
|
663
|
-
|
|
664
|
-
//#endregion
|
|
665
|
-
//#region ../../node_modules/.pnpm/picocolors@1.1.1/node_modules/picocolors/picocolors.js
|
|
666
|
-
var require_picocolors = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
667
|
-
let p = process || {}, argv = p.argv || [], env = p.env || {};
|
|
668
|
-
let isColorSupported = !(!!env.NO_COLOR || argv.includes("--no-color")) && (!!env.FORCE_COLOR || argv.includes("--color") || p.platform === "win32" || (p.stdout || {}).isTTY && env.TERM !== "dumb" || !!env.CI);
|
|
669
|
-
let formatter = (open, close, replace = open) => (input) => {
|
|
670
|
-
let string = "" + input, index = string.indexOf(close, open.length);
|
|
671
|
-
return ~index ? open + replaceClose(string, close, replace, index) + close : open + string + close;
|
|
672
|
-
};
|
|
673
|
-
let replaceClose = (string, close, replace, index) => {
|
|
674
|
-
let result = "", cursor = 0;
|
|
675
|
-
do {
|
|
676
|
-
result += string.substring(cursor, index) + replace;
|
|
677
|
-
cursor = index + close.length;
|
|
678
|
-
index = string.indexOf(close, cursor);
|
|
679
|
-
} while (~index);
|
|
680
|
-
return result + string.substring(cursor);
|
|
681
|
-
};
|
|
682
|
-
let createColors = (enabled = isColorSupported) => {
|
|
683
|
-
let f = enabled ? formatter : () => String;
|
|
684
|
-
return {
|
|
685
|
-
isColorSupported: enabled,
|
|
686
|
-
reset: f("\x1B[0m", "\x1B[0m"),
|
|
687
|
-
bold: f("\x1B[1m", "\x1B[22m", "\x1B[22m\x1B[1m"),
|
|
688
|
-
dim: f("\x1B[2m", "\x1B[22m", "\x1B[22m\x1B[2m"),
|
|
689
|
-
italic: f("\x1B[3m", "\x1B[23m"),
|
|
690
|
-
underline: f("\x1B[4m", "\x1B[24m"),
|
|
691
|
-
inverse: f("\x1B[7m", "\x1B[27m"),
|
|
692
|
-
hidden: f("\x1B[8m", "\x1B[28m"),
|
|
693
|
-
strikethrough: f("\x1B[9m", "\x1B[29m"),
|
|
694
|
-
black: f("\x1B[30m", "\x1B[39m"),
|
|
695
|
-
red: f("\x1B[31m", "\x1B[39m"),
|
|
696
|
-
green: f("\x1B[32m", "\x1B[39m"),
|
|
697
|
-
yellow: f("\x1B[33m", "\x1B[39m"),
|
|
698
|
-
blue: f("\x1B[34m", "\x1B[39m"),
|
|
699
|
-
magenta: f("\x1B[35m", "\x1B[39m"),
|
|
700
|
-
cyan: f("\x1B[36m", "\x1B[39m"),
|
|
701
|
-
white: f("\x1B[37m", "\x1B[39m"),
|
|
702
|
-
gray: f("\x1B[90m", "\x1B[39m"),
|
|
703
|
-
bgBlack: f("\x1B[40m", "\x1B[49m"),
|
|
704
|
-
bgRed: f("\x1B[41m", "\x1B[49m"),
|
|
705
|
-
bgGreen: f("\x1B[42m", "\x1B[49m"),
|
|
706
|
-
bgYellow: f("\x1B[43m", "\x1B[49m"),
|
|
707
|
-
bgBlue: f("\x1B[44m", "\x1B[49m"),
|
|
708
|
-
bgMagenta: f("\x1B[45m", "\x1B[49m"),
|
|
709
|
-
bgCyan: f("\x1B[46m", "\x1B[49m"),
|
|
710
|
-
bgWhite: f("\x1B[47m", "\x1B[49m"),
|
|
711
|
-
blackBright: f("\x1B[90m", "\x1B[39m"),
|
|
712
|
-
redBright: f("\x1B[91m", "\x1B[39m"),
|
|
713
|
-
greenBright: f("\x1B[92m", "\x1B[39m"),
|
|
714
|
-
yellowBright: f("\x1B[93m", "\x1B[39m"),
|
|
715
|
-
blueBright: f("\x1B[94m", "\x1B[39m"),
|
|
716
|
-
magentaBright: f("\x1B[95m", "\x1B[39m"),
|
|
717
|
-
cyanBright: f("\x1B[96m", "\x1B[39m"),
|
|
718
|
-
whiteBright: f("\x1B[97m", "\x1B[39m"),
|
|
719
|
-
bgBlackBright: f("\x1B[100m", "\x1B[49m"),
|
|
720
|
-
bgRedBright: f("\x1B[101m", "\x1B[49m"),
|
|
721
|
-
bgGreenBright: f("\x1B[102m", "\x1B[49m"),
|
|
722
|
-
bgYellowBright: f("\x1B[103m", "\x1B[49m"),
|
|
723
|
-
bgBlueBright: f("\x1B[104m", "\x1B[49m"),
|
|
724
|
-
bgMagentaBright: f("\x1B[105m", "\x1B[49m"),
|
|
725
|
-
bgCyanBright: f("\x1B[106m", "\x1B[49m"),
|
|
726
|
-
bgWhiteBright: f("\x1B[107m", "\x1B[49m")
|
|
727
|
-
};
|
|
728
|
-
};
|
|
729
|
-
module.exports = createColors();
|
|
730
|
-
module.exports.createColors = createColors;
|
|
731
|
-
}));
|
|
732
|
-
|
|
733
|
-
//#endregion
|
|
734
|
-
//#region ../../node_modules/.pnpm/kons@0.7.1/node_modules/kons/dist/utils-6230ae77.mjs
|
|
735
|
-
var import_picocolors$1 = /* @__PURE__ */ __toESM(require_picocolors(), 1);
|
|
736
|
-
function parseStack(stack) {
|
|
737
|
-
return stack.split("\n").splice(1).map((l) => l.trim().replace("file://", ""));
|
|
738
|
-
}
|
|
739
|
-
function formatStack(stack) {
|
|
740
|
-
return `
|
|
741
|
-
${parseStack(stack).map((line) => ` ${line.replace(/^at ([\s\S]+) \((.+)\)/, (_, m1, m2) => import_picocolors$1.default.gray(`at ${m1} (${import_picocolors$1.default.cyan(m2)})`))}`).join("\n")}`;
|
|
742
|
-
}
|
|
743
|
-
const NEWLINE_RE = /\r?\n/g;
|
|
744
|
-
function formatMessage(messages) {
|
|
745
|
-
return messages.map((m) => {
|
|
746
|
-
if (typeof (m == null ? void 0 : m.stack) === "string") return [m.message, formatStack(m.stack)];
|
|
747
|
-
if (typeof m === "string") return m.split(NEWLINE_RE);
|
|
748
|
-
return m;
|
|
749
|
-
}).flat();
|
|
750
|
-
}
|
|
751
|
-
function createBadge(badgeType, bgColor) {
|
|
752
|
-
const upperType = badgeType.toUpperCase();
|
|
753
|
-
const bgColorFormatter = import_picocolors$1.default[bgColor];
|
|
754
|
-
return import_picocolors$1.default.bold(import_picocolors$1.default.inverse(bgColorFormatter(` ${upperType} `)));
|
|
755
|
-
}
|
|
756
|
-
|
|
757
|
-
//#endregion
|
|
758
|
-
//#region ../../node_modules/.pnpm/kons@0.7.1/node_modules/kons/dist/index.mjs
|
|
759
|
-
var import_picocolors = /* @__PURE__ */ __toESM(require_picocolors(), 1);
|
|
760
|
-
function createFormatter(type, bgColor, { target = console.log, textColor, newline = true } = {}) {
|
|
761
|
-
const bgColorFormatter = import_picocolors.default[bgColor];
|
|
762
|
-
const textColorFormatter = textColor ? import_picocolors.default[textColor] : bgColorFormatter;
|
|
763
|
-
return (...messages) => {
|
|
764
|
-
const formattedMessages = formatMessage(messages);
|
|
765
|
-
const badge = createBadge(type, bgColor);
|
|
766
|
-
for (const message of formattedMessages) target(`${badge} ${textColorFormatter(message)}${newline ? "\n" : ""}`);
|
|
767
|
-
};
|
|
768
|
-
}
|
|
769
|
-
const log = createFormatter("log", "gray");
|
|
770
|
-
const info = createFormatter("info", "blue", { target: console.info });
|
|
771
|
-
const warn = createFormatter("warn", "yellow", { target: console.warn });
|
|
772
|
-
const success = createFormatter("success", "green");
|
|
773
|
-
const error = createFormatter("error", "red", { target: console.error });
|
|
774
|
-
|
|
775
|
-
//#endregion
|
|
776
|
-
//#region ../plugin-friendly-error/src/index.ts
|
|
777
|
-
const friendlyErrorPlugin = ({ target = error } = {}) => definePlugin({ setup: (cli) => cli.errorHandler((err) => {
|
|
778
|
-
target(err.message);
|
|
779
|
-
process.exit(1);
|
|
780
|
-
}) });
|
|
781
|
-
|
|
782
|
-
//#endregion
|
|
783
|
-
//#region ../../node_modules/.pnpm/fastest-levenshtein@1.0.16/node_modules/fastest-levenshtein/mod.js
|
|
784
|
-
var require_fastest_levenshtein = /* @__PURE__ */ __commonJSMin(((exports) => {
|
|
785
|
-
exports.__esModule = true;
|
|
786
|
-
exports.distance = exports.closest = void 0;
|
|
787
|
-
var peq = new Uint32Array(65536);
|
|
788
|
-
var myers_32 = function(a, b) {
|
|
789
|
-
var n = a.length;
|
|
790
|
-
var m = b.length;
|
|
791
|
-
var lst = 1 << n - 1;
|
|
792
|
-
var pv = -1;
|
|
793
|
-
var mv = 0;
|
|
794
|
-
var sc = n;
|
|
795
|
-
var i = n;
|
|
796
|
-
while (i--) peq[a.charCodeAt(i)] |= 1 << i;
|
|
797
|
-
for (i = 0; i < m; i++) {
|
|
798
|
-
var eq = peq[b.charCodeAt(i)];
|
|
799
|
-
var xv = eq | mv;
|
|
800
|
-
eq |= (eq & pv) + pv ^ pv;
|
|
801
|
-
mv |= ~(eq | pv);
|
|
802
|
-
pv &= eq;
|
|
803
|
-
if (mv & lst) sc++;
|
|
804
|
-
if (pv & lst) sc--;
|
|
805
|
-
mv = mv << 1 | 1;
|
|
806
|
-
pv = pv << 1 | ~(xv | mv);
|
|
807
|
-
mv &= xv;
|
|
808
|
-
}
|
|
809
|
-
i = n;
|
|
810
|
-
while (i--) peq[a.charCodeAt(i)] = 0;
|
|
811
|
-
return sc;
|
|
812
|
-
};
|
|
813
|
-
var myers_x = function(b, a) {
|
|
814
|
-
var n = a.length;
|
|
815
|
-
var m = b.length;
|
|
816
|
-
var mhc = [];
|
|
817
|
-
var phc = [];
|
|
818
|
-
var hsize = Math.ceil(n / 32);
|
|
819
|
-
var vsize = Math.ceil(m / 32);
|
|
820
|
-
for (var i = 0; i < hsize; i++) {
|
|
821
|
-
phc[i] = -1;
|
|
822
|
-
mhc[i] = 0;
|
|
823
|
-
}
|
|
824
|
-
var j = 0;
|
|
825
|
-
for (; j < vsize - 1; j++) {
|
|
826
|
-
var mv_1 = 0;
|
|
827
|
-
var pv_1 = -1;
|
|
828
|
-
var start_1 = j * 32;
|
|
829
|
-
var vlen_1 = Math.min(32, m) + start_1;
|
|
830
|
-
for (var k = start_1; k < vlen_1; k++) peq[b.charCodeAt(k)] |= 1 << k;
|
|
831
|
-
for (var i = 0; i < n; i++) {
|
|
832
|
-
var eq = peq[a.charCodeAt(i)];
|
|
833
|
-
var pb = phc[i / 32 | 0] >>> i & 1;
|
|
834
|
-
var mb = mhc[i / 32 | 0] >>> i & 1;
|
|
835
|
-
var xv = eq | mv_1;
|
|
836
|
-
var xh = ((eq | mb) & pv_1) + pv_1 ^ pv_1 | eq | mb;
|
|
837
|
-
var ph = mv_1 | ~(xh | pv_1);
|
|
838
|
-
var mh = pv_1 & xh;
|
|
839
|
-
if (ph >>> 31 ^ pb) phc[i / 32 | 0] ^= 1 << i;
|
|
840
|
-
if (mh >>> 31 ^ mb) mhc[i / 32 | 0] ^= 1 << i;
|
|
841
|
-
ph = ph << 1 | pb;
|
|
842
|
-
mh = mh << 1 | mb;
|
|
843
|
-
pv_1 = mh | ~(xv | ph);
|
|
844
|
-
mv_1 = ph & xv;
|
|
845
|
-
}
|
|
846
|
-
for (var k = start_1; k < vlen_1; k++) peq[b.charCodeAt(k)] = 0;
|
|
847
|
-
}
|
|
848
|
-
var mv = 0;
|
|
849
|
-
var pv = -1;
|
|
850
|
-
var start = j * 32;
|
|
851
|
-
var vlen = Math.min(32, m - start) + start;
|
|
852
|
-
for (var k = start; k < vlen; k++) peq[b.charCodeAt(k)] |= 1 << k;
|
|
853
|
-
var score = m;
|
|
854
|
-
for (var i = 0; i < n; i++) {
|
|
855
|
-
var eq = peq[a.charCodeAt(i)];
|
|
856
|
-
var pb = phc[i / 32 | 0] >>> i & 1;
|
|
857
|
-
var mb = mhc[i / 32 | 0] >>> i & 1;
|
|
858
|
-
var xv = eq | mv;
|
|
859
|
-
var xh = ((eq | mb) & pv) + pv ^ pv | eq | mb;
|
|
860
|
-
var ph = mv | ~(xh | pv);
|
|
861
|
-
var mh = pv & xh;
|
|
862
|
-
score += ph >>> m - 1 & 1;
|
|
863
|
-
score -= mh >>> m - 1 & 1;
|
|
864
|
-
if (ph >>> 31 ^ pb) phc[i / 32 | 0] ^= 1 << i;
|
|
865
|
-
if (mh >>> 31 ^ mb) mhc[i / 32 | 0] ^= 1 << i;
|
|
866
|
-
ph = ph << 1 | pb;
|
|
867
|
-
mh = mh << 1 | mb;
|
|
868
|
-
pv = mh | ~(xv | ph);
|
|
869
|
-
mv = ph & xv;
|
|
870
|
-
}
|
|
871
|
-
for (var k = start; k < vlen; k++) peq[b.charCodeAt(k)] = 0;
|
|
872
|
-
return score;
|
|
873
|
-
};
|
|
874
|
-
var distance$1 = function(a, b) {
|
|
875
|
-
if (a.length < b.length) {
|
|
876
|
-
var tmp = b;
|
|
877
|
-
b = a;
|
|
878
|
-
a = tmp;
|
|
879
|
-
}
|
|
880
|
-
if (b.length === 0) return a.length;
|
|
881
|
-
if (a.length <= 32) return myers_32(a, b);
|
|
882
|
-
return myers_x(a, b);
|
|
883
|
-
};
|
|
884
|
-
exports.distance = distance$1;
|
|
885
|
-
var closest = function(str, arr) {
|
|
886
|
-
var min_distance = Infinity;
|
|
887
|
-
var min_index = 0;
|
|
888
|
-
for (var i = 0; i < arr.length; i++) {
|
|
889
|
-
var dist = distance$1(str, arr[i]);
|
|
890
|
-
if (dist < min_distance) {
|
|
891
|
-
min_distance = dist;
|
|
892
|
-
min_index = i;
|
|
893
|
-
}
|
|
894
|
-
}
|
|
895
|
-
return arr[min_index];
|
|
896
|
-
};
|
|
897
|
-
exports.closest = closest;
|
|
898
|
-
}));
|
|
899
|
-
|
|
900
|
-
//#endregion
|
|
901
|
-
//#region ../../node_modules/.pnpm/lodash.deburr@4.1.0/node_modules/lodash.deburr/index.js
|
|
902
|
-
var require_lodash = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
903
|
-
/**
|
|
904
|
-
* lodash (Custom Build) <https://lodash.com/>
|
|
905
|
-
* Build: `lodash modularize exports="npm" -o ./`
|
|
906
|
-
* Copyright jQuery Foundation and other contributors <https://jquery.org/>
|
|
907
|
-
* Released under MIT license <https://lodash.com/license>
|
|
908
|
-
* Based on Underscore.js 1.8.3 <http://underscorejs.org/LICENSE>
|
|
909
|
-
* Copyright Jeremy Ashkenas, DocumentCloud and Investigative Reporters & Editors
|
|
910
|
-
*/
|
|
911
|
-
/** Used as references for various `Number` constants. */
|
|
912
|
-
var INFINITY = Infinity;
|
|
913
|
-
/** `Object#toString` result references. */
|
|
914
|
-
var symbolTag = "[object Symbol]";
|
|
915
|
-
/** Used to match Latin Unicode letters (excluding mathematical operators). */
|
|
916
|
-
var reLatin = /[\xc0-\xd6\xd8-\xf6\xf8-\xff\u0100-\u017f]/g;
|
|
917
|
-
/**
|
|
918
|
-
* Used to match [combining diacritical marks](https://en.wikipedia.org/wiki/Combining_Diacritical_Marks) and
|
|
919
|
-
* [combining diacritical marks for symbols](https://en.wikipedia.org/wiki/Combining_Diacritical_Marks_for_Symbols).
|
|
920
|
-
*/
|
|
921
|
-
var reComboMark = RegExp("[\\u0300-\\u036f\\ufe20-\\ufe23\\u20d0-\\u20f0]", "g");
|
|
922
|
-
/** Used to map Latin Unicode letters to basic Latin letters. */
|
|
923
|
-
var deburredLetters = {
|
|
924
|
-
"À": "A",
|
|
925
|
-
"Á": "A",
|
|
926
|
-
"Â": "A",
|
|
927
|
-
"Ã": "A",
|
|
928
|
-
"Ä": "A",
|
|
929
|
-
"Å": "A",
|
|
930
|
-
"à": "a",
|
|
931
|
-
"á": "a",
|
|
932
|
-
"â": "a",
|
|
933
|
-
"ã": "a",
|
|
934
|
-
"ä": "a",
|
|
935
|
-
"å": "a",
|
|
936
|
-
"Ç": "C",
|
|
937
|
-
"ç": "c",
|
|
938
|
-
"Ð": "D",
|
|
939
|
-
"ð": "d",
|
|
940
|
-
"È": "E",
|
|
941
|
-
"É": "E",
|
|
942
|
-
"Ê": "E",
|
|
943
|
-
"Ë": "E",
|
|
944
|
-
"è": "e",
|
|
945
|
-
"é": "e",
|
|
946
|
-
"ê": "e",
|
|
947
|
-
"ë": "e",
|
|
948
|
-
"Ì": "I",
|
|
949
|
-
"Í": "I",
|
|
950
|
-
"Î": "I",
|
|
951
|
-
"Ï": "I",
|
|
952
|
-
"ì": "i",
|
|
953
|
-
"í": "i",
|
|
954
|
-
"î": "i",
|
|
955
|
-
"ï": "i",
|
|
956
|
-
"Ñ": "N",
|
|
957
|
-
"ñ": "n",
|
|
958
|
-
"Ò": "O",
|
|
959
|
-
"Ó": "O",
|
|
960
|
-
"Ô": "O",
|
|
961
|
-
"Õ": "O",
|
|
962
|
-
"Ö": "O",
|
|
963
|
-
"Ø": "O",
|
|
964
|
-
"ò": "o",
|
|
965
|
-
"ó": "o",
|
|
966
|
-
"ô": "o",
|
|
967
|
-
"õ": "o",
|
|
968
|
-
"ö": "o",
|
|
969
|
-
"ø": "o",
|
|
970
|
-
"Ù": "U",
|
|
971
|
-
"Ú": "U",
|
|
972
|
-
"Û": "U",
|
|
973
|
-
"Ü": "U",
|
|
974
|
-
"ù": "u",
|
|
975
|
-
"ú": "u",
|
|
976
|
-
"û": "u",
|
|
977
|
-
"ü": "u",
|
|
978
|
-
"Ý": "Y",
|
|
979
|
-
"ý": "y",
|
|
980
|
-
"ÿ": "y",
|
|
981
|
-
"Æ": "Ae",
|
|
982
|
-
"æ": "ae",
|
|
983
|
-
"Þ": "Th",
|
|
984
|
-
"þ": "th",
|
|
985
|
-
"ß": "ss",
|
|
986
|
-
"Ā": "A",
|
|
987
|
-
"Ă": "A",
|
|
988
|
-
"Ą": "A",
|
|
989
|
-
"ā": "a",
|
|
990
|
-
"ă": "a",
|
|
991
|
-
"ą": "a",
|
|
992
|
-
"Ć": "C",
|
|
993
|
-
"Ĉ": "C",
|
|
994
|
-
"Ċ": "C",
|
|
995
|
-
"Č": "C",
|
|
996
|
-
"ć": "c",
|
|
997
|
-
"ĉ": "c",
|
|
998
|
-
"ċ": "c",
|
|
999
|
-
"č": "c",
|
|
1000
|
-
"Ď": "D",
|
|
1001
|
-
"Đ": "D",
|
|
1002
|
-
"ď": "d",
|
|
1003
|
-
"đ": "d",
|
|
1004
|
-
"Ē": "E",
|
|
1005
|
-
"Ĕ": "E",
|
|
1006
|
-
"Ė": "E",
|
|
1007
|
-
"Ę": "E",
|
|
1008
|
-
"Ě": "E",
|
|
1009
|
-
"ē": "e",
|
|
1010
|
-
"ĕ": "e",
|
|
1011
|
-
"ė": "e",
|
|
1012
|
-
"ę": "e",
|
|
1013
|
-
"ě": "e",
|
|
1014
|
-
"Ĝ": "G",
|
|
1015
|
-
"Ğ": "G",
|
|
1016
|
-
"Ġ": "G",
|
|
1017
|
-
"Ģ": "G",
|
|
1018
|
-
"ĝ": "g",
|
|
1019
|
-
"ğ": "g",
|
|
1020
|
-
"ġ": "g",
|
|
1021
|
-
"ģ": "g",
|
|
1022
|
-
"Ĥ": "H",
|
|
1023
|
-
"Ħ": "H",
|
|
1024
|
-
"ĥ": "h",
|
|
1025
|
-
"ħ": "h",
|
|
1026
|
-
"Ĩ": "I",
|
|
1027
|
-
"Ī": "I",
|
|
1028
|
-
"Ĭ": "I",
|
|
1029
|
-
"Į": "I",
|
|
1030
|
-
"İ": "I",
|
|
1031
|
-
"ĩ": "i",
|
|
1032
|
-
"ī": "i",
|
|
1033
|
-
"ĭ": "i",
|
|
1034
|
-
"į": "i",
|
|
1035
|
-
"ı": "i",
|
|
1036
|
-
"Ĵ": "J",
|
|
1037
|
-
"ĵ": "j",
|
|
1038
|
-
"Ķ": "K",
|
|
1039
|
-
"ķ": "k",
|
|
1040
|
-
"ĸ": "k",
|
|
1041
|
-
"Ĺ": "L",
|
|
1042
|
-
"Ļ": "L",
|
|
1043
|
-
"Ľ": "L",
|
|
1044
|
-
"Ŀ": "L",
|
|
1045
|
-
"Ł": "L",
|
|
1046
|
-
"ĺ": "l",
|
|
1047
|
-
"ļ": "l",
|
|
1048
|
-
"ľ": "l",
|
|
1049
|
-
"ŀ": "l",
|
|
1050
|
-
"ł": "l",
|
|
1051
|
-
"Ń": "N",
|
|
1052
|
-
"Ņ": "N",
|
|
1053
|
-
"Ň": "N",
|
|
1054
|
-
"Ŋ": "N",
|
|
1055
|
-
"ń": "n",
|
|
1056
|
-
"ņ": "n",
|
|
1057
|
-
"ň": "n",
|
|
1058
|
-
"ŋ": "n",
|
|
1059
|
-
"Ō": "O",
|
|
1060
|
-
"Ŏ": "O",
|
|
1061
|
-
"Ő": "O",
|
|
1062
|
-
"ō": "o",
|
|
1063
|
-
"ŏ": "o",
|
|
1064
|
-
"ő": "o",
|
|
1065
|
-
"Ŕ": "R",
|
|
1066
|
-
"Ŗ": "R",
|
|
1067
|
-
"Ř": "R",
|
|
1068
|
-
"ŕ": "r",
|
|
1069
|
-
"ŗ": "r",
|
|
1070
|
-
"ř": "r",
|
|
1071
|
-
"Ś": "S",
|
|
1072
|
-
"Ŝ": "S",
|
|
1073
|
-
"Ş": "S",
|
|
1074
|
-
"Š": "S",
|
|
1075
|
-
"ś": "s",
|
|
1076
|
-
"ŝ": "s",
|
|
1077
|
-
"ş": "s",
|
|
1078
|
-
"š": "s",
|
|
1079
|
-
"Ţ": "T",
|
|
1080
|
-
"Ť": "T",
|
|
1081
|
-
"Ŧ": "T",
|
|
1082
|
-
"ţ": "t",
|
|
1083
|
-
"ť": "t",
|
|
1084
|
-
"ŧ": "t",
|
|
1085
|
-
"Ũ": "U",
|
|
1086
|
-
"Ū": "U",
|
|
1087
|
-
"Ŭ": "U",
|
|
1088
|
-
"Ů": "U",
|
|
1089
|
-
"Ű": "U",
|
|
1090
|
-
"Ų": "U",
|
|
1091
|
-
"ũ": "u",
|
|
1092
|
-
"ū": "u",
|
|
1093
|
-
"ŭ": "u",
|
|
1094
|
-
"ů": "u",
|
|
1095
|
-
"ű": "u",
|
|
1096
|
-
"ų": "u",
|
|
1097
|
-
"Ŵ": "W",
|
|
1098
|
-
"ŵ": "w",
|
|
1099
|
-
"Ŷ": "Y",
|
|
1100
|
-
"ŷ": "y",
|
|
1101
|
-
"Ÿ": "Y",
|
|
1102
|
-
"Ź": "Z",
|
|
1103
|
-
"Ż": "Z",
|
|
1104
|
-
"Ž": "Z",
|
|
1105
|
-
"ź": "z",
|
|
1106
|
-
"ż": "z",
|
|
1107
|
-
"ž": "z",
|
|
1108
|
-
"IJ": "IJ",
|
|
1109
|
-
"ij": "ij",
|
|
1110
|
-
"Œ": "Oe",
|
|
1111
|
-
"œ": "oe",
|
|
1112
|
-
"ʼn": "'n",
|
|
1113
|
-
"ſ": "ss"
|
|
1114
|
-
};
|
|
1115
|
-
/** Detect free variable `global` from Node.js. */
|
|
1116
|
-
var freeGlobal = typeof global == "object" && global && global.Object === Object && global;
|
|
1117
|
-
/** Detect free variable `self`. */
|
|
1118
|
-
var freeSelf = typeof self == "object" && self && self.Object === Object && self;
|
|
1119
|
-
/** Used as a reference to the global object. */
|
|
1120
|
-
var root = freeGlobal || freeSelf || Function("return this")();
|
|
1121
|
-
/**
|
|
1122
|
-
* The base implementation of `_.propertyOf` without support for deep paths.
|
|
1123
|
-
*
|
|
1124
|
-
* @private
|
|
1125
|
-
* @param {Object} object The object to query.
|
|
1126
|
-
* @returns {Function} Returns the new accessor function.
|
|
1127
|
-
*/
|
|
1128
|
-
function basePropertyOf(object) {
|
|
1129
|
-
return function(key) {
|
|
1130
|
-
return object == null ? void 0 : object[key];
|
|
1131
|
-
};
|
|
1132
|
-
}
|
|
1133
|
-
/**
|
|
1134
|
-
* Used by `_.deburr` to convert Latin-1 Supplement and Latin Extended-A
|
|
1135
|
-
* letters to basic Latin letters.
|
|
1136
|
-
*
|
|
1137
|
-
* @private
|
|
1138
|
-
* @param {string} letter The matched letter to deburr.
|
|
1139
|
-
* @returns {string} Returns the deburred letter.
|
|
1140
|
-
*/
|
|
1141
|
-
var deburrLetter = basePropertyOf(deburredLetters);
|
|
1142
|
-
/**
|
|
1143
|
-
* Used to resolve the
|
|
1144
|
-
* [`toStringTag`](http://ecma-international.org/ecma-262/7.0/#sec-object.prototype.tostring)
|
|
1145
|
-
* of values.
|
|
1146
|
-
*/
|
|
1147
|
-
var objectToString = Object.prototype.toString;
|
|
1148
|
-
/** Built-in value references. */
|
|
1149
|
-
var Symbol$1 = root.Symbol;
|
|
1150
|
-
/** Used to convert symbols to primitives and strings. */
|
|
1151
|
-
var symbolProto = Symbol$1 ? Symbol$1.prototype : void 0, symbolToString = symbolProto ? symbolProto.toString : void 0;
|
|
1152
|
-
/**
|
|
1153
|
-
* The base implementation of `_.toString` which doesn't convert nullish
|
|
1154
|
-
* values to empty strings.
|
|
1155
|
-
*
|
|
1156
|
-
* @private
|
|
1157
|
-
* @param {*} value The value to process.
|
|
1158
|
-
* @returns {string} Returns the string.
|
|
1159
|
-
*/
|
|
1160
|
-
function baseToString(value) {
|
|
1161
|
-
if (typeof value == "string") return value;
|
|
1162
|
-
if (isSymbol(value)) return symbolToString ? symbolToString.call(value) : "";
|
|
1163
|
-
var result = value + "";
|
|
1164
|
-
return result == "0" && 1 / value == -INFINITY ? "-0" : result;
|
|
1165
|
-
}
|
|
1166
|
-
/**
|
|
1167
|
-
* Checks if `value` is object-like. A value is object-like if it's not `null`
|
|
1168
|
-
* and has a `typeof` result of "object".
|
|
1169
|
-
*
|
|
1170
|
-
* @static
|
|
1171
|
-
* @memberOf _
|
|
1172
|
-
* @since 4.0.0
|
|
1173
|
-
* @category Lang
|
|
1174
|
-
* @param {*} value The value to check.
|
|
1175
|
-
* @returns {boolean} Returns `true` if `value` is object-like, else `false`.
|
|
1176
|
-
* @example
|
|
1177
|
-
*
|
|
1178
|
-
* _.isObjectLike({});
|
|
1179
|
-
* // => true
|
|
1180
|
-
*
|
|
1181
|
-
* _.isObjectLike([1, 2, 3]);
|
|
1182
|
-
* // => true
|
|
1183
|
-
*
|
|
1184
|
-
* _.isObjectLike(_.noop);
|
|
1185
|
-
* // => false
|
|
1186
|
-
*
|
|
1187
|
-
* _.isObjectLike(null);
|
|
1188
|
-
* // => false
|
|
1189
|
-
*/
|
|
1190
|
-
function isObjectLike(value) {
|
|
1191
|
-
return !!value && typeof value == "object";
|
|
1192
|
-
}
|
|
1193
|
-
/**
|
|
1194
|
-
* Checks if `value` is classified as a `Symbol` primitive or object.
|
|
1195
|
-
*
|
|
1196
|
-
* @static
|
|
1197
|
-
* @memberOf _
|
|
1198
|
-
* @since 4.0.0
|
|
1199
|
-
* @category Lang
|
|
1200
|
-
* @param {*} value The value to check.
|
|
1201
|
-
* @returns {boolean} Returns `true` if `value` is a symbol, else `false`.
|
|
1202
|
-
* @example
|
|
1203
|
-
*
|
|
1204
|
-
* _.isSymbol(Symbol.iterator);
|
|
1205
|
-
* // => true
|
|
1206
|
-
*
|
|
1207
|
-
* _.isSymbol('abc');
|
|
1208
|
-
* // => false
|
|
1209
|
-
*/
|
|
1210
|
-
function isSymbol(value) {
|
|
1211
|
-
return typeof value == "symbol" || isObjectLike(value) && objectToString.call(value) == symbolTag;
|
|
1212
|
-
}
|
|
1213
|
-
/**
|
|
1214
|
-
* Converts `value` to a string. An empty string is returned for `null`
|
|
1215
|
-
* and `undefined` values. The sign of `-0` is preserved.
|
|
1216
|
-
*
|
|
1217
|
-
* @static
|
|
1218
|
-
* @memberOf _
|
|
1219
|
-
* @since 4.0.0
|
|
1220
|
-
* @category Lang
|
|
1221
|
-
* @param {*} value The value to process.
|
|
1222
|
-
* @returns {string} Returns the string.
|
|
1223
|
-
* @example
|
|
1224
|
-
*
|
|
1225
|
-
* _.toString(null);
|
|
1226
|
-
* // => ''
|
|
1227
|
-
*
|
|
1228
|
-
* _.toString(-0);
|
|
1229
|
-
* // => '-0'
|
|
1230
|
-
*
|
|
1231
|
-
* _.toString([1, 2, 3]);
|
|
1232
|
-
* // => '1,2,3'
|
|
1233
|
-
*/
|
|
1234
|
-
function toString(value) {
|
|
1235
|
-
return value == null ? "" : baseToString(value);
|
|
1236
|
-
}
|
|
1237
|
-
/**
|
|
1238
|
-
* Deburrs `string` by converting
|
|
1239
|
-
* [Latin-1 Supplement](https://en.wikipedia.org/wiki/Latin-1_Supplement_(Unicode_block)#Character_table)
|
|
1240
|
-
* and [Latin Extended-A](https://en.wikipedia.org/wiki/Latin_Extended-A)
|
|
1241
|
-
* letters to basic Latin letters and removing
|
|
1242
|
-
* [combining diacritical marks](https://en.wikipedia.org/wiki/Combining_Diacritical_Marks).
|
|
1243
|
-
*
|
|
1244
|
-
* @static
|
|
1245
|
-
* @memberOf _
|
|
1246
|
-
* @since 3.0.0
|
|
1247
|
-
* @category String
|
|
1248
|
-
* @param {string} [string=''] The string to deburr.
|
|
1249
|
-
* @returns {string} Returns the deburred string.
|
|
1250
|
-
* @example
|
|
1251
|
-
*
|
|
1252
|
-
* _.deburr('déjà vu');
|
|
1253
|
-
* // => 'deja vu'
|
|
1254
|
-
*/
|
|
1255
|
-
function deburr$1(string) {
|
|
1256
|
-
string = toString(string);
|
|
1257
|
-
return string && string.replace(reLatin, deburrLetter).replace(reComboMark, "");
|
|
1258
|
-
}
|
|
1259
|
-
module.exports = deburr$1;
|
|
1260
|
-
}));
|
|
1261
|
-
|
|
1262
|
-
//#endregion
|
|
1263
|
-
//#region ../../node_modules/.pnpm/didyoumean2@7.0.4/node_modules/didyoumean2/dist/index.mjs
|
|
1264
|
-
var import_fastest_levenshtein = require_fastest_levenshtein();
|
|
1265
|
-
var import_lodash = /* @__PURE__ */ __toESM(require_lodash(), 1);
|
|
1266
|
-
let ReturnTypeEnums = /* @__PURE__ */ function(ReturnTypeEnums$1) {
|
|
1267
|
-
ReturnTypeEnums$1["ALL_CLOSEST_MATCHES"] = "all-closest-matches";
|
|
1268
|
-
ReturnTypeEnums$1["ALL_MATCHES"] = "all-matches";
|
|
1269
|
-
ReturnTypeEnums$1["ALL_SORTED_MATCHES"] = "all-sorted-matches";
|
|
1270
|
-
ReturnTypeEnums$1["FIRST_CLOSEST_MATCH"] = "first-closest-match";
|
|
1271
|
-
ReturnTypeEnums$1["FIRST_MATCH"] = "first-match";
|
|
1272
|
-
return ReturnTypeEnums$1;
|
|
1273
|
-
}({});
|
|
1274
|
-
let ThresholdTypeEnums = /* @__PURE__ */ function(ThresholdTypeEnums$1) {
|
|
1275
|
-
ThresholdTypeEnums$1["EDIT_DISTANCE"] = "edit-distance";
|
|
1276
|
-
ThresholdTypeEnums$1["SIMILARITY"] = "similarity";
|
|
1277
|
-
return ThresholdTypeEnums$1;
|
|
1278
|
-
}({});
|
|
1279
|
-
const fillDefaultOptions = (options) => {
|
|
1280
|
-
const optionsWithDefaultValues = {
|
|
1281
|
-
caseSensitive: false,
|
|
1282
|
-
deburr: true,
|
|
1283
|
-
matchPath: [],
|
|
1284
|
-
returnType: ReturnTypeEnums.FIRST_CLOSEST_MATCH,
|
|
1285
|
-
thresholdType: ThresholdTypeEnums.SIMILARITY,
|
|
1286
|
-
trimSpaces: true,
|
|
1287
|
-
...options
|
|
1288
|
-
};
|
|
1289
|
-
if (!Object.values(ReturnTypeEnums).includes(optionsWithDefaultValues.returnType)) throw new TypeError("unknown returnType");
|
|
1290
|
-
if (!Object.values(ThresholdTypeEnums).includes(optionsWithDefaultValues.thresholdType)) throw new TypeError("unknown thresholdType");
|
|
1291
|
-
switch (optionsWithDefaultValues.thresholdType) {
|
|
1292
|
-
case ThresholdTypeEnums.EDIT_DISTANCE: return {
|
|
1293
|
-
threshold: 20,
|
|
1294
|
-
...optionsWithDefaultValues
|
|
1295
|
-
};
|
|
1296
|
-
case ThresholdTypeEnums.SIMILARITY: return {
|
|
1297
|
-
threshold: .4,
|
|
1298
|
-
...optionsWithDefaultValues
|
|
1299
|
-
};
|
|
1300
|
-
}
|
|
1301
|
-
};
|
|
1302
|
-
/**
|
|
1303
|
-
* Using edit distance between `a` and `b` to calculate similarity
|
|
1304
|
-
*
|
|
1305
|
-
* @param {string} a - `input`
|
|
1306
|
-
* @param {string} b - String from `matchList`
|
|
1307
|
-
* @returns {number} similarity between `a` and `b`
|
|
1308
|
-
*/
|
|
1309
|
-
const getSimilarity = (a, b) => {
|
|
1310
|
-
if (!a || !b) return 0;
|
|
1311
|
-
if (a === b) return 1;
|
|
1312
|
-
const editDistance = (0, import_fastest_levenshtein.distance)(a, b);
|
|
1313
|
-
const longestLength = Math.max(a.length, b.length);
|
|
1314
|
-
return (longestLength - editDistance) / longestLength;
|
|
1315
|
-
};
|
|
1316
|
-
/**
|
|
1317
|
-
* Normalize a string
|
|
1318
|
-
*
|
|
1319
|
-
* @param {string} str - any string
|
|
1320
|
-
* @param {object} options - options that allows you to modify the behavior
|
|
1321
|
-
* @returns {string} - normalized string
|
|
1322
|
-
*/
|
|
1323
|
-
const normalizeString = (str, options) => {
|
|
1324
|
-
let s = str;
|
|
1325
|
-
if (options.trimSpaces) s = s.trim().replaceAll(/\s+/gu, " ");
|
|
1326
|
-
if (options.deburr) s = (0, import_lodash.default)(s);
|
|
1327
|
-
if (!options.caseSensitive) s = s.toLowerCase();
|
|
1328
|
-
return s;
|
|
1329
|
-
};
|
|
1330
|
-
const getMatchItemStr = (matchItem, matchPath) => {
|
|
1331
|
-
const matchItemStr = matchPath.length > 0 ? matchPath.reduce((acc, prop) => {
|
|
1332
|
-
return acc?.[prop];
|
|
1333
|
-
}, matchItem) : matchItem;
|
|
1334
|
-
if (typeof matchItemStr !== "string") return "";
|
|
1335
|
-
return matchItemStr;
|
|
1336
|
-
};
|
|
1337
|
-
/**
|
|
1338
|
-
* Process matchItem according to options
|
|
1339
|
-
*
|
|
1340
|
-
* @param {object | string} matchItem - Item for matching with `input`
|
|
1341
|
-
* @param {object} options - options that allows you to modify the behavior
|
|
1342
|
-
* @returns {string} - processed matchItem
|
|
1343
|
-
*/
|
|
1344
|
-
const matchItemProcessor = (matchItem, options) => {
|
|
1345
|
-
const { matchPath } = options;
|
|
1346
|
-
return normalizeString(getMatchItemStr(matchItem, matchPath), options);
|
|
1347
|
-
};
|
|
1348
|
-
/**
|
|
1349
|
-
* Generate result
|
|
1350
|
-
*
|
|
1351
|
-
* @param {object[] | string[]} matchList - List for matching with `input`
|
|
1352
|
-
* @param {number[]} matchedIndexes - indexes of matchList that need to be returned as result
|
|
1353
|
-
* @param {ReturnTypeEnums} returnType - how the result will response to user
|
|
1354
|
-
* @returns {Array | null | object | string} - matched result(s), return object if `match` is `{Object[]}`
|
|
1355
|
-
*/
|
|
1356
|
-
const resultProcessor = (matchList, matchedIndexes, returnType) => {
|
|
1357
|
-
switch (returnType) {
|
|
1358
|
-
case ReturnTypeEnums.ALL_CLOSEST_MATCHES:
|
|
1359
|
-
case ReturnTypeEnums.ALL_MATCHES:
|
|
1360
|
-
case ReturnTypeEnums.ALL_SORTED_MATCHES: return matchedIndexes.map((matchedIndex) => matchList[matchedIndex]);
|
|
1361
|
-
case ReturnTypeEnums.FIRST_CLOSEST_MATCH:
|
|
1362
|
-
case ReturnTypeEnums.FIRST_MATCH: {
|
|
1363
|
-
const matchedIndex = matchedIndexes[0];
|
|
1364
|
-
if (matchedIndex === void 0) return null;
|
|
1365
|
-
return matchList[matchedIndex];
|
|
1366
|
-
}
|
|
1367
|
-
}
|
|
1368
|
-
};
|
|
1369
|
-
/**
|
|
1370
|
-
* Main function for didyoumean2
|
|
1371
|
-
*
|
|
1372
|
-
* @param {string} input - string that you are not sure and want to match with `matchList`
|
|
1373
|
-
* @param {object[] | string[]} matchList - List for matching with `input`
|
|
1374
|
-
* @param {null | object | undefined} options - options that allows you to modify the behavior
|
|
1375
|
-
* @returns {Array | null | object | string} - matched result(s), return object if `match` is `{Object[]}`
|
|
1376
|
-
*/
|
|
1377
|
-
function didYouMean(input, matchList, options) {
|
|
1378
|
-
const optionsWithDefaults = fillDefaultOptions(options);
|
|
1379
|
-
const { returnType, threshold, thresholdType } = optionsWithDefaults;
|
|
1380
|
-
const normalizedInput = normalizeString(input, optionsWithDefaults);
|
|
1381
|
-
let checkIfMatched;
|
|
1382
|
-
let scoreProcessor;
|
|
1383
|
-
switch (thresholdType) {
|
|
1384
|
-
case ThresholdTypeEnums.EDIT_DISTANCE:
|
|
1385
|
-
checkIfMatched = (score) => score <= threshold;
|
|
1386
|
-
scoreProcessor = (matchItem) => (0, import_fastest_levenshtein.distance)(normalizedInput, matchItemProcessor(matchItem, optionsWithDefaults));
|
|
1387
|
-
break;
|
|
1388
|
-
case ThresholdTypeEnums.SIMILARITY:
|
|
1389
|
-
checkIfMatched = (score) => score >= threshold;
|
|
1390
|
-
scoreProcessor = (matchItem) => getSimilarity(normalizedInput, matchItemProcessor(matchItem, optionsWithDefaults));
|
|
1391
|
-
break;
|
|
1392
|
-
}
|
|
1393
|
-
const matchedIndexes = [];
|
|
1394
|
-
switch (returnType) {
|
|
1395
|
-
case ReturnTypeEnums.ALL_CLOSEST_MATCHES:
|
|
1396
|
-
case ReturnTypeEnums.FIRST_CLOSEST_MATCH: {
|
|
1397
|
-
const scores = [];
|
|
1398
|
-
let marginValue;
|
|
1399
|
-
switch (thresholdType) {
|
|
1400
|
-
case ThresholdTypeEnums.EDIT_DISTANCE:
|
|
1401
|
-
marginValue = Number.POSITIVE_INFINITY;
|
|
1402
|
-
for (const matchItem of matchList) {
|
|
1403
|
-
const score = scoreProcessor(matchItem);
|
|
1404
|
-
if (marginValue > score) marginValue = score;
|
|
1405
|
-
scores.push(score);
|
|
1406
|
-
}
|
|
1407
|
-
break;
|
|
1408
|
-
case ThresholdTypeEnums.SIMILARITY:
|
|
1409
|
-
marginValue = 0;
|
|
1410
|
-
for (const matchItem of matchList) {
|
|
1411
|
-
const score = scoreProcessor(matchItem);
|
|
1412
|
-
if (marginValue < score) marginValue = score;
|
|
1413
|
-
scores.push(score);
|
|
1414
|
-
}
|
|
1415
|
-
break;
|
|
1416
|
-
}
|
|
1417
|
-
for (const [i, score] of scores.entries()) if (checkIfMatched(score) && score === marginValue) matchedIndexes.push(i);
|
|
1418
|
-
break;
|
|
1419
|
-
}
|
|
1420
|
-
case ReturnTypeEnums.ALL_MATCHES:
|
|
1421
|
-
for (const [i, matchItem] of matchList.entries()) {
|
|
1422
|
-
const score = scoreProcessor(matchItem);
|
|
1423
|
-
if (checkIfMatched(score)) matchedIndexes.push(i);
|
|
1424
|
-
}
|
|
1425
|
-
break;
|
|
1426
|
-
case ReturnTypeEnums.ALL_SORTED_MATCHES: {
|
|
1427
|
-
const unsortedResults = [];
|
|
1428
|
-
for (const [i, matchItem] of matchList.entries()) {
|
|
1429
|
-
const score = scoreProcessor(matchItem);
|
|
1430
|
-
if (checkIfMatched(score)) unsortedResults.push({
|
|
1431
|
-
score,
|
|
1432
|
-
index: i
|
|
1433
|
-
});
|
|
1434
|
-
}
|
|
1435
|
-
switch (thresholdType) {
|
|
1436
|
-
case ThresholdTypeEnums.EDIT_DISTANCE:
|
|
1437
|
-
unsortedResults.sort((a, b) => a.score - b.score);
|
|
1438
|
-
break;
|
|
1439
|
-
case ThresholdTypeEnums.SIMILARITY:
|
|
1440
|
-
unsortedResults.sort((a, b) => b.score - a.score);
|
|
1441
|
-
break;
|
|
1442
|
-
}
|
|
1443
|
-
for (const unsortedResult of unsortedResults) matchedIndexes.push(unsortedResult.index);
|
|
1444
|
-
break;
|
|
1445
|
-
}
|
|
1446
|
-
case ReturnTypeEnums.FIRST_MATCH:
|
|
1447
|
-
for (const [i, matchItem] of matchList.entries()) {
|
|
1448
|
-
const score = scoreProcessor(matchItem);
|
|
1449
|
-
if (checkIfMatched(score)) {
|
|
1450
|
-
matchedIndexes.push(i);
|
|
1451
|
-
break;
|
|
1452
|
-
}
|
|
1453
|
-
}
|
|
1454
|
-
break;
|
|
1455
|
-
}
|
|
1456
|
-
return resultProcessor(matchList, matchedIndexes, returnType);
|
|
1457
|
-
}
|
|
1458
|
-
|
|
1459
|
-
//#endregion
|
|
1460
|
-
//#region ../plugin-not-found/src/index.ts
|
|
1461
|
-
const notFoundPlugin = () => definePlugin({ setup: (cli) => cli.interceptor({
|
|
1462
|
-
enforce: "post",
|
|
1463
|
-
handler: async (_ctx, next) => {
|
|
1464
|
-
const commandKeys = [...cli._commands.keys()];
|
|
1465
|
-
const hasCommands = commandKeys.length > 0;
|
|
1466
|
-
try {
|
|
1467
|
-
await next();
|
|
1468
|
-
} catch (e) {
|
|
1469
|
-
if (!(e instanceof NoSuchCommandError || e instanceof NoCommandSpecifiedError)) throw e;
|
|
1470
|
-
if (e instanceof NoCommandSpecifiedError) {
|
|
1471
|
-
let text$1 = "No command specified.";
|
|
1472
|
-
if (hasCommands) text$1 += `\nPossible commands: ${commandKeys.join(", ")}.`;
|
|
1473
|
-
throw new NoCommandSpecifiedError(text$1);
|
|
1474
|
-
}
|
|
1475
|
-
const { commandName } = e;
|
|
1476
|
-
const closestCommandName = didYouMean(commandName, commandKeys);
|
|
1477
|
-
let text = `Command "${strikethrough(commandName)}" not found.`;
|
|
1478
|
-
if (hasCommands && closestCommandName) text += `\nDid you mean "${bold(closestCommandName)}"?`;
|
|
1479
|
-
else if (!hasCommands) text += "\nNo commands registered.";
|
|
1480
|
-
throw new NoSuchCommandError(commandName, text);
|
|
1481
|
-
}
|
|
1482
|
-
}
|
|
1483
|
-
}) });
|
|
1484
|
-
|
|
1485
|
-
//#endregion
|
|
1486
|
-
//#region ../plugin-strict-flags/src/index.ts
|
|
1487
|
-
const strictFlagsPlugin = () => definePlugin({ setup: (cli) => {
|
|
1488
|
-
cli.interceptor(async (ctx, next) => {
|
|
1489
|
-
const keys = Object.keys(ctx.rawParsed.unknown);
|
|
1490
|
-
if (!ctx.command || keys.length === 0) await next();
|
|
1491
|
-
else throw keys.length > 1 ? /* @__PURE__ */ new Error(`Unexpected flags: ${joinWithAnd(keys)}`) : /* @__PURE__ */ new Error(`Unexpected flag: ${keys[0]}`);
|
|
1492
|
-
});
|
|
1493
|
-
} });
|
|
1494
|
-
|
|
1495
|
-
//#endregion
|
|
1496
|
-
//#region ../clerc/src/re-exports.ts
|
|
1497
|
-
var re_exports_exports = /* @__PURE__ */ __export({
|
|
1498
|
-
completionsPlugin: () => completionsPlugin,
|
|
1499
|
-
defaultFormatters: () => defaultFormatters,
|
|
1500
|
-
friendlyErrorPlugin: () => friendlyErrorPlugin,
|
|
1501
|
-
helpPlugin: () => helpPlugin,
|
|
1502
|
-
notFoundPlugin: () => notFoundPlugin,
|
|
1503
|
-
strictFlagsPlugin: () => strictFlagsPlugin,
|
|
1504
|
-
versionPlugin: () => versionPlugin
|
|
1505
|
-
});
|
|
1506
|
-
import * as import___clerc_core from "@clerc/core";
|
|
1507
|
-
__reExport(re_exports_exports, import___clerc_core);
|
|
1508
|
-
|
|
1509
|
-
//#endregion
|
|
1510
|
-
//#region ../clerc/src/index.ts
|
|
1511
|
-
var src_exports = /* @__PURE__ */ __export({
|
|
1512
|
-
Cli: () => Cli,
|
|
1513
|
-
completionsPlugin: () => completionsPlugin,
|
|
1514
|
-
defaultFormatters: () => defaultFormatters,
|
|
1515
|
-
friendlyErrorPlugin: () => friendlyErrorPlugin,
|
|
1516
|
-
helpPlugin: () => helpPlugin,
|
|
1517
|
-
notFoundPlugin: () => notFoundPlugin,
|
|
1518
|
-
strictFlagsPlugin: () => strictFlagsPlugin,
|
|
1519
|
-
versionPlugin: () => versionPlugin
|
|
1520
|
-
});
|
|
1521
|
-
__reExport(src_exports, re_exports_exports);
|
|
1522
|
-
const Cli = (options) => Clerc.create(options).use(versionPlugin()).use(helpPlugin());
|
|
1523
|
-
|
|
1524
|
-
//#endregion
|
|
1525
4
|
//#region src/t.ts
|
|
1526
5
|
function resetTab() {
|
|
1527
6
|
t.commands.clear();
|
|
@@ -1529,13 +8,18 @@ function resetTab() {
|
|
|
1529
8
|
t.arguments.clear();
|
|
1530
9
|
t.completions = [];
|
|
1531
10
|
}
|
|
1532
|
-
function
|
|
1533
|
-
|
|
1534
|
-
|
|
1535
|
-
|
|
1536
|
-
|
|
11
|
+
function registerFlag(tc, flagName, def) {
|
|
12
|
+
const normalized = normalizeFlagValue(def);
|
|
13
|
+
const desc = normalized.description ?? "";
|
|
14
|
+
if (normalized.type === Boolean) tc.option(flagName, desc, normalized.short);
|
|
15
|
+
else {
|
|
16
|
+
const handler = normalized.completions?.handler ?? (async () => {});
|
|
17
|
+
tc.option(flagName, desc, handler, normalized.short);
|
|
1537
18
|
}
|
|
1538
19
|
}
|
|
20
|
+
function registerGlobalFlags(globalFlags, tc) {
|
|
21
|
+
for (const [flagName, def] of Object.entries(globalFlags)) registerFlag(tc, flagName, def);
|
|
22
|
+
}
|
|
1539
23
|
function buildTabModel(globalFlags, commands) {
|
|
1540
24
|
resetTab();
|
|
1541
25
|
registerGlobalFlags(globalFlags, t);
|
|
@@ -1546,11 +30,13 @@ function buildTabModel(globalFlags, commands) {
|
|
|
1546
30
|
command = t.command(cmd.name, cmd.description ?? "");
|
|
1547
31
|
registerGlobalFlags(globalFlags, command);
|
|
1548
32
|
}
|
|
1549
|
-
|
|
1550
|
-
|
|
1551
|
-
const
|
|
1552
|
-
|
|
33
|
+
cmd.completions?.handler?.(command);
|
|
34
|
+
for (const def of cmd.parameters ?? []) {
|
|
35
|
+
const normalized = normalizeParameterValue(def);
|
|
36
|
+
const { name, isVariadic } = extractParameterInfo(normalized.key);
|
|
37
|
+
command.argument(name, normalized.completions?.handler, isVariadic);
|
|
1553
38
|
}
|
|
39
|
+
for (const [flagName, def] of Object.entries(cmd.flags ?? {})) registerFlag(command, flagName, def);
|
|
1554
40
|
}
|
|
1555
41
|
}
|
|
1556
42
|
|