@bemoje/cli 3.1.2 → 3.1.3
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/lib/index.cjs +66 -66
- package/lib/index.d.cts +379 -379
- package/lib/index.d.ts +379 -379
- package/lib/index.js +66 -66
- package/package.json +5 -45
package/lib/index.cjs
CHANGED
|
@@ -19,13 +19,58 @@ var humanizeDuration__default = /*#__PURE__*/_interopDefault(humanizeDuration);
|
|
|
19
19
|
var __defProp = Object.defineProperty;
|
|
20
20
|
var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
|
|
21
21
|
|
|
22
|
-
//
|
|
23
|
-
function
|
|
24
|
-
|
|
25
|
-
|
|
22
|
+
// src/lib/helpers/parseOptionFlags.ts
|
|
23
|
+
function parseOptionFlags(flags) {
|
|
24
|
+
const match = flags.match(/^-(.+?), --([A-Za-z][\w-]*)(?:\s*(<(.+?)>|\[(.+?)]))?$/);
|
|
25
|
+
if (!match) {
|
|
26
|
+
throw new Error(`Invalid option format: ${flags}`);
|
|
26
27
|
}
|
|
28
|
+
const short = match[1];
|
|
29
|
+
if (short.length !== 1) {
|
|
30
|
+
throw new Error(`Expected short name to be a single character. Got: -${short}`);
|
|
31
|
+
}
|
|
32
|
+
const long = match[2];
|
|
33
|
+
const argName = (match[4] || match[5])?.replace(/\.{3}$/, "") || void 0;
|
|
34
|
+
const name = long.split("-").reduce((str, word) => {
|
|
35
|
+
return str + word[0].toUpperCase() + word.slice(1);
|
|
36
|
+
});
|
|
37
|
+
return {
|
|
38
|
+
short,
|
|
39
|
+
long,
|
|
40
|
+
name,
|
|
41
|
+
argName
|
|
42
|
+
};
|
|
27
43
|
}
|
|
28
|
-
__name(
|
|
44
|
+
__name(parseOptionFlags, "parseOptionFlags");
|
|
45
|
+
|
|
46
|
+
// src/lib/helpers/getCommandAndAncestors.ts
|
|
47
|
+
function getCommandAndAncestors(cmd) {
|
|
48
|
+
const result = [];
|
|
49
|
+
let command = cmd;
|
|
50
|
+
for (; command; command = command.parent) {
|
|
51
|
+
result.push(command);
|
|
52
|
+
}
|
|
53
|
+
return result;
|
|
54
|
+
}
|
|
55
|
+
__name(getCommandAndAncestors, "getCommandAndAncestors");
|
|
56
|
+
|
|
57
|
+
// src/lib/helpers/getCommandAncestors.ts
|
|
58
|
+
function getCommandAncestors(cmd) {
|
|
59
|
+
return getCommandAndAncestors(cmd).slice(1);
|
|
60
|
+
}
|
|
61
|
+
__name(getCommandAncestors, "getCommandAncestors");
|
|
62
|
+
|
|
63
|
+
// src/lib/helpers/findOption.ts
|
|
64
|
+
function findOption(cmd, nameOrShortOrLong) {
|
|
65
|
+
return nameOrShortOrLong.startsWith("--") ? cmd.options.find((o) => {
|
|
66
|
+
return o.long === nameOrShortOrLong.slice(2);
|
|
67
|
+
}) : nameOrShortOrLong.startsWith("-") ? cmd.options.find((o) => {
|
|
68
|
+
return o.short === nameOrShortOrLong.slice(1);
|
|
69
|
+
}) : cmd.options.find((o) => {
|
|
70
|
+
return o.name === nameOrShortOrLong;
|
|
71
|
+
});
|
|
72
|
+
}
|
|
73
|
+
__name(findOption, "findOption");
|
|
29
74
|
|
|
30
75
|
// ../object/src/entriesOf.ts
|
|
31
76
|
function entriesOf(obj) {
|
|
@@ -71,6 +116,22 @@ function valuesOf(obj) {
|
|
|
71
116
|
}
|
|
72
117
|
__name(valuesOf, "valuesOf");
|
|
73
118
|
|
|
119
|
+
// src/lib/helpers/findCommand.ts
|
|
120
|
+
function findCommand(cmd, nameOrAlias) {
|
|
121
|
+
return cmd.commands[nameOrAlias] ?? valuesOf(cmd.commands).find((c) => {
|
|
122
|
+
return c.aliases.includes(nameOrAlias);
|
|
123
|
+
});
|
|
124
|
+
}
|
|
125
|
+
__name(findCommand, "findCommand");
|
|
126
|
+
|
|
127
|
+
// ../decorators/src/assertDescriptorValueIsFunction.ts
|
|
128
|
+
function assertDescriptorValueIsFunction(key, descriptor) {
|
|
129
|
+
if (!(typeof descriptor.value === "function" && descriptor.value !== Function.prototype)) {
|
|
130
|
+
throw new TypeError(`"value" not a function for ${key} with descriptor: ${JSON.stringify(descriptor)}.`);
|
|
131
|
+
}
|
|
132
|
+
}
|
|
133
|
+
__name(assertDescriptorValueIsFunction, "assertDescriptorValueIsFunction");
|
|
134
|
+
|
|
74
135
|
// ../map/src/mapGetOrDefault.ts
|
|
75
136
|
function mapGetOrDefault(map, key, factory) {
|
|
76
137
|
let value = map.get(key);
|
|
@@ -831,43 +892,6 @@ function collectVariadicOptionValues(parsed, options) {
|
|
|
831
892
|
}
|
|
832
893
|
__name(collectVariadicOptionValues, "collectVariadicOptionValues");
|
|
833
894
|
|
|
834
|
-
// src/lib/helpers/findCommand.ts
|
|
835
|
-
function findCommand(cmd, nameOrAlias) {
|
|
836
|
-
return cmd.commands[nameOrAlias] ?? valuesOf(cmd.commands).find((c) => {
|
|
837
|
-
return c.aliases.includes(nameOrAlias);
|
|
838
|
-
});
|
|
839
|
-
}
|
|
840
|
-
__name(findCommand, "findCommand");
|
|
841
|
-
|
|
842
|
-
// src/lib/helpers/findOption.ts
|
|
843
|
-
function findOption(cmd, nameOrShortOrLong) {
|
|
844
|
-
return nameOrShortOrLong.startsWith("--") ? cmd.options.find((o) => {
|
|
845
|
-
return o.long === nameOrShortOrLong.slice(2);
|
|
846
|
-
}) : nameOrShortOrLong.startsWith("-") ? cmd.options.find((o) => {
|
|
847
|
-
return o.short === nameOrShortOrLong.slice(1);
|
|
848
|
-
}) : cmd.options.find((o) => {
|
|
849
|
-
return o.name === nameOrShortOrLong;
|
|
850
|
-
});
|
|
851
|
-
}
|
|
852
|
-
__name(findOption, "findOption");
|
|
853
|
-
|
|
854
|
-
// src/lib/helpers/getCommandAndAncestors.ts
|
|
855
|
-
function getCommandAndAncestors(cmd) {
|
|
856
|
-
const result = [];
|
|
857
|
-
let command = cmd;
|
|
858
|
-
for (; command; command = command.parent) {
|
|
859
|
-
result.push(command);
|
|
860
|
-
}
|
|
861
|
-
return result;
|
|
862
|
-
}
|
|
863
|
-
__name(getCommandAndAncestors, "getCommandAndAncestors");
|
|
864
|
-
|
|
865
|
-
// src/lib/helpers/getCommandAncestors.ts
|
|
866
|
-
function getCommandAncestors(cmd) {
|
|
867
|
-
return getCommandAndAncestors(cmd).slice(1);
|
|
868
|
-
}
|
|
869
|
-
__name(getCommandAncestors, "getCommandAncestors");
|
|
870
|
-
|
|
871
895
|
// src/lib/internal/mergeOptionDefaults.ts
|
|
872
896
|
function mergeOptionDefaults(values, options) {
|
|
873
897
|
for (const option of options) {
|
|
@@ -897,30 +921,6 @@ function normalizeArgv(argv, options) {
|
|
|
897
921
|
return argv;
|
|
898
922
|
}
|
|
899
923
|
__name(normalizeArgv, "normalizeArgv");
|
|
900
|
-
|
|
901
|
-
// src/lib/helpers/parseOptionFlags.ts
|
|
902
|
-
function parseOptionFlags(flags) {
|
|
903
|
-
const match = flags.match(/^-(.+?), --([A-Za-z][\w-]*)(?:\s*(<(.+?)>|\[(.+?)]))?$/);
|
|
904
|
-
if (!match) {
|
|
905
|
-
throw new Error(`Invalid option format: ${flags}`);
|
|
906
|
-
}
|
|
907
|
-
const short = match[1];
|
|
908
|
-
if (short.length !== 1) {
|
|
909
|
-
throw new Error(`Expected short name to be a single character. Got: -${short}`);
|
|
910
|
-
}
|
|
911
|
-
const long = match[2];
|
|
912
|
-
const argName = (match[4] || match[5])?.replace(/\.{3}$/, "") || void 0;
|
|
913
|
-
const name = long.split("-").reduce((str, word) => {
|
|
914
|
-
return str + word[0].toUpperCase() + word.slice(1);
|
|
915
|
-
});
|
|
916
|
-
return {
|
|
917
|
-
short,
|
|
918
|
-
long,
|
|
919
|
-
name,
|
|
920
|
-
argName
|
|
921
|
-
};
|
|
922
|
-
}
|
|
923
|
-
__name(parseOptionFlags, "parseOptionFlags");
|
|
924
924
|
function resolveArguments(positionals, args) {
|
|
925
925
|
const result = args.map((arg, index) => {
|
|
926
926
|
if (arg.variadic) {
|