storybook 9.0.0-alpha.1 → 9.0.0-alpha.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/README.md +31 -29
- package/assets/browser/favicon.svg +1 -0
- package/assets/browser/nunito-sans-bold-italic.woff2 +0 -0
- package/assets/browser/nunito-sans-bold.woff2 +0 -0
- package/assets/browser/nunito-sans-italic.woff2 +0 -0
- package/assets/browser/nunito-sans-regular.woff2 +0 -0
- package/assets/docs/message-reference.png +0 -0
- package/assets/server/addon.tsconfig.json +6 -0
- package/assets/server/base-preview-body.html +119 -0
- package/assets/server/base-preview-head.html +451 -0
- package/assets/server/template.ejs +87 -0
- package/bin/index.cjs +1 -1
- package/dist/babel/index.cjs +54034 -0
- package/dist/babel/index.d.ts +7488 -0
- package/dist/babel/index.js +54044 -0
- package/dist/bin/index.cjs +123 -0
- package/dist/bin/index.js +117 -0
- package/dist/builder-manager/index.cjs +2167 -0
- package/dist/builder-manager/index.d.ts +19 -0
- package/dist/builder-manager/index.js +2189 -0
- package/dist/channels/index.cjs +1936 -0
- package/dist/channels/index.d.ts +108 -0
- package/dist/channels/index.js +1883 -0
- package/dist/cli/bin/index.cjs +2687 -0
- package/dist/cli/bin/index.d.ts +2 -0
- package/dist/cli/bin/index.js +2707 -0
- package/dist/cli/index.cjs +17327 -0
- package/dist/cli/index.d.ts +209 -0
- package/dist/cli/index.js +17349 -0
- package/dist/client-logger/index.cjs +112 -0
- package/dist/client-logger/index.d.ts +29 -0
- package/dist/client-logger/index.js +70 -0
- package/dist/common/index.cjs +20560 -0
- package/dist/common/index.d.ts +954 -0
- package/dist/common/index.js +20645 -0
- package/dist/components/index.cjs +30056 -0
- package/dist/components/index.d.ts +1423 -0
- package/dist/components/index.js +25416 -0
- package/dist/core-events/index.cjs +167 -0
- package/dist/core-events/index.d.ts +313 -0
- package/dist/core-events/index.js +149 -0
- package/dist/core-server/index.cjs +37870 -0
- package/dist/core-server/index.d.ts +462 -0
- package/dist/core-server/index.js +37964 -0
- package/dist/core-server/presets/common-manager.js +28 -0
- package/dist/core-server/presets/common-override-preset.cjs +4824 -0
- package/dist/core-server/presets/common-override-preset.js +4829 -0
- package/dist/core-server/presets/common-preset.cjs +10228 -0
- package/dist/core-server/presets/common-preset.js +10306 -0
- package/dist/csf/index.cjs +223 -0
- package/dist/csf/index.d.ts +752 -0
- package/dist/csf/index.js +216 -0
- package/dist/csf-tools/index.cjs +1422 -0
- package/dist/csf-tools/index.d.ts +250 -0
- package/dist/csf-tools/index.js +1439 -0
- package/dist/docs-tools/index.cjs +923 -0
- package/dist/docs-tools/index.d.ts +162 -0
- package/dist/docs-tools/index.js +909 -0
- package/dist/index.cjs +17 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js +2 -7
- package/dist/instrumenter/index.cjs +3273 -0
- package/dist/instrumenter/index.d.ts +104 -0
- package/dist/instrumenter/index.js +4800 -0
- package/dist/manager/globals-module-info.cjs +666 -0
- package/dist/manager/globals-module-info.d.ts +36 -0
- package/dist/manager/globals-module-info.js +653 -0
- package/dist/manager/globals-runtime.js +41565 -0
- package/dist/manager/globals.cjs +43 -0
- package/dist/manager/globals.d.ts +21 -0
- package/dist/manager/globals.js +30 -0
- package/dist/manager/runtime.js +12043 -0
- package/dist/manager-api/index.cjs +10770 -0
- package/dist/manager-api/index.d.ts +1211 -0
- package/dist/manager-api/index.js +4545 -0
- package/dist/manager-errors.d.ts +65 -0
- package/dist/manager-errors.js +83 -0
- package/dist/node-logger/index.cjs +1642 -0
- package/dist/node-logger/index.d.ts +117 -0
- package/dist/node-logger/index.js +1652 -0
- package/dist/preview/globals.cjs +34 -0
- package/dist/preview/globals.d.ts +12 -0
- package/dist/preview/globals.js +21 -0
- package/dist/preview/runtime.js +7721 -0
- package/dist/preview-api/index.cjs +5656 -0
- package/dist/preview-api/index.d.ts +1356 -0
- package/dist/preview-api/index.js +5663 -0
- package/dist/preview-errors.cjs +486 -0
- package/dist/preview-errors.d.ts +188 -0
- package/dist/preview-errors.js +433 -0
- package/dist/router/index.cjs +3320 -0
- package/dist/router/index.d.ts +385 -0
- package/dist/router/index.js +1849 -0
- package/dist/server-errors.cjs +710 -0
- package/dist/server-errors.d.ts +272 -0
- package/dist/server-errors.js +711 -0
- package/dist/telemetry/index.cjs +3683 -0
- package/dist/telemetry/index.d.ts +112 -0
- package/dist/telemetry/index.js +3720 -0
- package/dist/test/index.cjs +34915 -0
- package/dist/test/index.d.ts +186 -0
- package/dist/test/index.js +32798 -0
- package/dist/theming/create.cjs +2422 -0
- package/dist/theming/create.d.ts +50 -0
- package/dist/theming/create.js +990 -0
- package/dist/theming/index.cjs +4832 -0
- package/dist/theming/index.d.ts +11939 -0
- package/dist/theming/index.js +3253 -0
- package/dist/types/index.cjs +27 -0
- package/dist/types/index.d.ts +2541 -0
- package/dist/types/index.js +7 -0
- package/package.json +329 -212
- package/.eslintrc.cjs +0 -31
- package/__mocks__/@aw-web-design/x-default-browser.js +0 -2
- package/core/babel/index.cjs +0 -1
- package/core/babel/index.d.ts +0 -2
- package/core/babel/index.js +0 -1
- package/core/builder-manager/index.cjs +0 -1
- package/core/builder-manager/index.d.ts +0 -2
- package/core/builder-manager/index.js +0 -1
- package/core/channels/index.cjs +0 -1
- package/core/channels/index.d.ts +0 -2
- package/core/channels/index.js +0 -1
- package/core/cli/bin/index.cjs +0 -1
- package/core/cli/bin/index.d.ts +0 -2
- package/core/cli/bin/index.js +0 -1
- package/core/cli/index.cjs +0 -1
- package/core/cli/index.d.ts +0 -2
- package/core/cli/index.js +0 -1
- package/core/client-logger/index.cjs +0 -1
- package/core/client-logger/index.d.ts +0 -2
- package/core/client-logger/index.js +0 -1
- package/core/common/index.cjs +0 -1
- package/core/common/index.d.ts +0 -2
- package/core/common/index.js +0 -1
- package/core/components/index.cjs +0 -1
- package/core/components/index.d.ts +0 -2
- package/core/components/index.js +0 -1
- package/core/core-events/index.cjs +0 -1
- package/core/core-events/index.d.ts +0 -2
- package/core/core-events/index.js +0 -1
- package/core/core-server/index.cjs +0 -1
- package/core/core-server/index.d.ts +0 -2
- package/core/core-server/index.js +0 -1
- package/core/core-server/presets/common-manager.js +0 -1
- package/core/core-server/presets/common-override-preset.cjs +0 -1
- package/core/core-server/presets/common-override-preset.js +0 -1
- package/core/core-server/presets/common-preset.cjs +0 -1
- package/core/core-server/presets/common-preset.js +0 -1
- package/core/csf/index.cjs +0 -1
- package/core/csf/index.d.ts +0 -2
- package/core/csf/index.js +0 -1
- package/core/csf-tools/index.cjs +0 -1
- package/core/csf-tools/index.d.ts +0 -2
- package/core/csf-tools/index.js +0 -1
- package/core/docs-tools/index.cjs +0 -1
- package/core/docs-tools/index.d.ts +0 -2
- package/core/docs-tools/index.js +0 -1
- package/core/index.cjs +0 -1
- package/core/index.d.ts +0 -2
- package/core/index.js +0 -1
- package/core/manager/globals-module-info.cjs +0 -1
- package/core/manager/globals-module-info.d.ts +0 -2
- package/core/manager/globals-module-info.js +0 -1
- package/core/manager/globals-runtime.js +0 -1
- package/core/manager/globals.cjs +0 -1
- package/core/manager/globals.d.ts +0 -2
- package/core/manager/globals.js +0 -1
- package/core/manager-api/index.cjs +0 -1
- package/core/manager-api/index.d.ts +0 -2
- package/core/manager-api/index.js +0 -1
- package/core/manager-errors.d.ts +0 -2
- package/core/manager-errors.js +0 -1
- package/core/node-logger/index.cjs +0 -1
- package/core/node-logger/index.d.ts +0 -2
- package/core/node-logger/index.js +0 -1
- package/core/preview/globals.cjs +0 -1
- package/core/preview/globals.d.ts +0 -2
- package/core/preview/globals.js +0 -1
- package/core/preview/runtime.js +0 -1
- package/core/preview-api/index.cjs +0 -1
- package/core/preview-api/index.d.ts +0 -2
- package/core/preview-api/index.js +0 -1
- package/core/preview-errors.cjs +0 -1
- package/core/preview-errors.d.ts +0 -2
- package/core/preview-errors.js +0 -1
- package/core/router/index.cjs +0 -1
- package/core/router/index.d.ts +0 -2
- package/core/router/index.js +0 -1
- package/core/server-errors.cjs +0 -1
- package/core/server-errors.d.ts +0 -2
- package/core/server-errors.js +0 -1
- package/core/telemetry/index.cjs +0 -1
- package/core/telemetry/index.d.ts +0 -2
- package/core/telemetry/index.js +0 -1
- package/core/theming/create.cjs +0 -1
- package/core/theming/create.d.ts +0 -2
- package/core/theming/create.js +0 -1
- package/core/theming/index.cjs +0 -1
- package/core/theming/index.d.ts +0 -2
- package/core/theming/index.js +0 -1
- package/core/types/index.cjs +0 -1
- package/core/types/index.d.ts +0 -2
- package/core/types/index.js +0 -1
- package/core.cjs +0 -0
- package/core.d.ts +0 -0
- package/core.js +0 -1
- package/dist/chunk-OWLSIX54.js +0 -8
- package/dist/core-path.cjs +0 -1
- package/dist/core-path.d.ts +0 -3
- package/dist/core-path.js +0 -9
- package/dist/proxy.cjs +0 -1
- package/dist/proxy.d.ts +0 -2
- package/dist/proxy.js +0 -9
|
@@ -0,0 +1,2707 @@
|
|
|
1
|
+
import ESM_COMPAT_Module from "node:module";
|
|
2
|
+
import { fileURLToPath as ESM_COMPAT_fileURLToPath } from 'node:url';
|
|
3
|
+
import { dirname as ESM_COMPAT_dirname } from 'node:path';
|
|
4
|
+
const __filename = ESM_COMPAT_fileURLToPath(import.meta.url);
|
|
5
|
+
const __dirname = ESM_COMPAT_dirname(__filename);
|
|
6
|
+
const require = ESM_COMPAT_Module.createRequire(import.meta.url);
|
|
7
|
+
var He = Object.create;
|
|
8
|
+
var N = Object.defineProperty;
|
|
9
|
+
var De = Object.getOwnPropertyDescriptor;
|
|
10
|
+
var Pe = Object.getOwnPropertyNames;
|
|
11
|
+
var qe = Object.getPrototypeOf, Ie = Object.prototype.hasOwnProperty;
|
|
12
|
+
var c = (s, e) => N(s, "name", { value: e, configurable: !0 }), C = /* @__PURE__ */ ((s) => typeof require < "u" ? require : typeof Proxy < "\
|
|
13
|
+
u" ? new Proxy(s, {
|
|
14
|
+
get: (e, t) => (typeof require < "u" ? require : e)[t]
|
|
15
|
+
}) : s)(function(s) {
|
|
16
|
+
if (typeof require < "u") return require.apply(this, arguments);
|
|
17
|
+
throw Error('Dynamic require of "' + s + '" is not supported');
|
|
18
|
+
});
|
|
19
|
+
var b = (s, e) => () => (e || s((e = { exports: {} }).exports, e), e.exports);
|
|
20
|
+
var Ne = (s, e, t, i) => {
|
|
21
|
+
if (e && typeof e == "object" || typeof e == "function")
|
|
22
|
+
for (let n of Pe(e))
|
|
23
|
+
!Ie.call(s, n) && n !== t && N(s, n, { get: () => e[n], enumerable: !(i = De(e, n)) || i.enumerable });
|
|
24
|
+
return s;
|
|
25
|
+
};
|
|
26
|
+
var $ = (s, e, t) => (t = s != null ? He(qe(s)) : {}, Ne(
|
|
27
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
28
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
29
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
30
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
31
|
+
e || !s || !s.__esModule ? N(t, "default", { value: s, enumerable: !0 }) : t,
|
|
32
|
+
s
|
|
33
|
+
));
|
|
34
|
+
|
|
35
|
+
// ../node_modules/commander/lib/error.js
|
|
36
|
+
var k = b((F) => {
|
|
37
|
+
var V = class extends Error {
|
|
38
|
+
static {
|
|
39
|
+
c(this, "CommanderError");
|
|
40
|
+
}
|
|
41
|
+
/**
|
|
42
|
+
* Constructs the CommanderError class
|
|
43
|
+
* @param {number} exitCode suggested exit code which could be used with process.exit
|
|
44
|
+
* @param {string} code an id string representing the error
|
|
45
|
+
* @param {string} message human-readable description of the error
|
|
46
|
+
*/
|
|
47
|
+
constructor(e, t, i) {
|
|
48
|
+
super(i), Error.captureStackTrace(this, this.constructor), this.name = this.constructor.name, this.code = t, this.exitCode = e, this.nestedError =
|
|
49
|
+
void 0;
|
|
50
|
+
}
|
|
51
|
+
}, T = class extends V {
|
|
52
|
+
static {
|
|
53
|
+
c(this, "InvalidArgumentError");
|
|
54
|
+
}
|
|
55
|
+
/**
|
|
56
|
+
* Constructs the InvalidArgumentError class
|
|
57
|
+
* @param {string} [message] explanation of why argument is invalid
|
|
58
|
+
*/
|
|
59
|
+
constructor(e) {
|
|
60
|
+
super(1, "commander.invalidArgument", e), Error.captureStackTrace(this, this.constructor), this.name = this.constructor.name;
|
|
61
|
+
}
|
|
62
|
+
};
|
|
63
|
+
F.CommanderError = V;
|
|
64
|
+
F.InvalidArgumentError = T;
|
|
65
|
+
});
|
|
66
|
+
|
|
67
|
+
// ../node_modules/commander/lib/argument.js
|
|
68
|
+
var H = b((M) => {
|
|
69
|
+
var { InvalidArgumentError: Te } = k(), B = class {
|
|
70
|
+
static {
|
|
71
|
+
c(this, "Argument");
|
|
72
|
+
}
|
|
73
|
+
/**
|
|
74
|
+
* Initialize a new command argument with the given name and description.
|
|
75
|
+
* The default is that the argument is required, and you can explicitly
|
|
76
|
+
* indicate this with <> around the name. Put [] around the name for an optional argument.
|
|
77
|
+
*
|
|
78
|
+
* @param {string} name
|
|
79
|
+
* @param {string} [description]
|
|
80
|
+
*/
|
|
81
|
+
constructor(e, t) {
|
|
82
|
+
switch (this.description = t || "", this.variadic = !1, this.parseArg = void 0, this.defaultValue = void 0, this.defaultValueDescription =
|
|
83
|
+
void 0, this.argChoices = void 0, e[0]) {
|
|
84
|
+
case "<":
|
|
85
|
+
this.required = !0, this._name = e.slice(1, -1);
|
|
86
|
+
break;
|
|
87
|
+
case "[":
|
|
88
|
+
this.required = !1, this._name = e.slice(1, -1);
|
|
89
|
+
break;
|
|
90
|
+
default:
|
|
91
|
+
this.required = !0, this._name = e;
|
|
92
|
+
break;
|
|
93
|
+
}
|
|
94
|
+
this._name.length > 3 && this._name.slice(-3) === "..." && (this.variadic = !0, this._name = this._name.slice(0, -3));
|
|
95
|
+
}
|
|
96
|
+
/**
|
|
97
|
+
* Return argument name.
|
|
98
|
+
*
|
|
99
|
+
* @return {string}
|
|
100
|
+
*/
|
|
101
|
+
name() {
|
|
102
|
+
return this._name;
|
|
103
|
+
}
|
|
104
|
+
/**
|
|
105
|
+
* @package
|
|
106
|
+
*/
|
|
107
|
+
_concatValue(e, t) {
|
|
108
|
+
return t === this.defaultValue || !Array.isArray(t) ? [e] : t.concat(e);
|
|
109
|
+
}
|
|
110
|
+
/**
|
|
111
|
+
* Set the default value, and optionally supply the description to be displayed in the help.
|
|
112
|
+
*
|
|
113
|
+
* @param {*} value
|
|
114
|
+
* @param {string} [description]
|
|
115
|
+
* @return {Argument}
|
|
116
|
+
*/
|
|
117
|
+
default(e, t) {
|
|
118
|
+
return this.defaultValue = e, this.defaultValueDescription = t, this;
|
|
119
|
+
}
|
|
120
|
+
/**
|
|
121
|
+
* Set the custom handler for processing CLI command arguments into argument values.
|
|
122
|
+
*
|
|
123
|
+
* @param {Function} [fn]
|
|
124
|
+
* @return {Argument}
|
|
125
|
+
*/
|
|
126
|
+
argParser(e) {
|
|
127
|
+
return this.parseArg = e, this;
|
|
128
|
+
}
|
|
129
|
+
/**
|
|
130
|
+
* Only allow argument value to be one of choices.
|
|
131
|
+
*
|
|
132
|
+
* @param {string[]} values
|
|
133
|
+
* @return {Argument}
|
|
134
|
+
*/
|
|
135
|
+
choices(e) {
|
|
136
|
+
return this.argChoices = e.slice(), this.parseArg = (t, i) => {
|
|
137
|
+
if (!this.argChoices.includes(t))
|
|
138
|
+
throw new Te(
|
|
139
|
+
`Allowed choices are ${this.argChoices.join(", ")}.`
|
|
140
|
+
);
|
|
141
|
+
return this.variadic ? this._concatValue(t, i) : t;
|
|
142
|
+
}, this;
|
|
143
|
+
}
|
|
144
|
+
/**
|
|
145
|
+
* Make argument required.
|
|
146
|
+
*
|
|
147
|
+
* @returns {Argument}
|
|
148
|
+
*/
|
|
149
|
+
argRequired() {
|
|
150
|
+
return this.required = !0, this;
|
|
151
|
+
}
|
|
152
|
+
/**
|
|
153
|
+
* Make argument optional.
|
|
154
|
+
*
|
|
155
|
+
* @returns {Argument}
|
|
156
|
+
*/
|
|
157
|
+
argOptional() {
|
|
158
|
+
return this.required = !1, this;
|
|
159
|
+
}
|
|
160
|
+
};
|
|
161
|
+
function Fe(s) {
|
|
162
|
+
let e = s.name() + (s.variadic === !0 ? "..." : "");
|
|
163
|
+
return s.required ? "<" + e + ">" : "[" + e + "]";
|
|
164
|
+
}
|
|
165
|
+
c(Fe, "humanReadableArgName");
|
|
166
|
+
M.Argument = B;
|
|
167
|
+
M.humanReadableArgName = Fe;
|
|
168
|
+
});
|
|
169
|
+
|
|
170
|
+
// ../node_modules/commander/lib/help.js
|
|
171
|
+
var W = b((ae) => {
|
|
172
|
+
var { humanReadableArgName: Be } = H(), L = class {
|
|
173
|
+
static {
|
|
174
|
+
c(this, "Help");
|
|
175
|
+
}
|
|
176
|
+
constructor() {
|
|
177
|
+
this.helpWidth = void 0, this.sortSubcommands = !1, this.sortOptions = !1, this.showGlobalOptions = !1;
|
|
178
|
+
}
|
|
179
|
+
/**
|
|
180
|
+
* Get an array of the visible subcommands. Includes a placeholder for the implicit help command, if there is one.
|
|
181
|
+
*
|
|
182
|
+
* @param {Command} cmd
|
|
183
|
+
* @returns {Command[]}
|
|
184
|
+
*/
|
|
185
|
+
visibleCommands(e) {
|
|
186
|
+
let t = e.commands.filter((n) => !n._hidden), i = e._getHelpCommand();
|
|
187
|
+
return i && !i._hidden && t.push(i), this.sortSubcommands && t.sort((n, r) => n.name().localeCompare(r.name())), t;
|
|
188
|
+
}
|
|
189
|
+
/**
|
|
190
|
+
* Compare options for sort.
|
|
191
|
+
*
|
|
192
|
+
* @param {Option} a
|
|
193
|
+
* @param {Option} b
|
|
194
|
+
* @returns {number}
|
|
195
|
+
*/
|
|
196
|
+
compareOptions(e, t) {
|
|
197
|
+
let i = /* @__PURE__ */ c((n) => n.short ? n.short.replace(/^-/, "") : n.long.replace(/^--/, ""), "getSortKey");
|
|
198
|
+
return i(e).localeCompare(i(t));
|
|
199
|
+
}
|
|
200
|
+
/**
|
|
201
|
+
* Get an array of the visible options. Includes a placeholder for the implicit help option, if there is one.
|
|
202
|
+
*
|
|
203
|
+
* @param {Command} cmd
|
|
204
|
+
* @returns {Option[]}
|
|
205
|
+
*/
|
|
206
|
+
visibleOptions(e) {
|
|
207
|
+
let t = e.options.filter((n) => !n.hidden), i = e._getHelpOption();
|
|
208
|
+
if (i && !i.hidden) {
|
|
209
|
+
let n = i.short && e._findOption(i.short), r = i.long && e._findOption(i.long);
|
|
210
|
+
!n && !r ? t.push(i) : i.long && !r ? t.push(
|
|
211
|
+
e.createOption(i.long, i.description)
|
|
212
|
+
) : i.short && !n && t.push(
|
|
213
|
+
e.createOption(i.short, i.description)
|
|
214
|
+
);
|
|
215
|
+
}
|
|
216
|
+
return this.sortOptions && t.sort(this.compareOptions), t;
|
|
217
|
+
}
|
|
218
|
+
/**
|
|
219
|
+
* Get an array of the visible global options. (Not including help.)
|
|
220
|
+
*
|
|
221
|
+
* @param {Command} cmd
|
|
222
|
+
* @returns {Option[]}
|
|
223
|
+
*/
|
|
224
|
+
visibleGlobalOptions(e) {
|
|
225
|
+
if (!this.showGlobalOptions) return [];
|
|
226
|
+
let t = [];
|
|
227
|
+
for (let i = e.parent; i; i = i.parent) {
|
|
228
|
+
let n = i.options.filter(
|
|
229
|
+
(r) => !r.hidden
|
|
230
|
+
);
|
|
231
|
+
t.push(...n);
|
|
232
|
+
}
|
|
233
|
+
return this.sortOptions && t.sort(this.compareOptions), t;
|
|
234
|
+
}
|
|
235
|
+
/**
|
|
236
|
+
* Get an array of the arguments if any have a description.
|
|
237
|
+
*
|
|
238
|
+
* @param {Command} cmd
|
|
239
|
+
* @returns {Argument[]}
|
|
240
|
+
*/
|
|
241
|
+
visibleArguments(e) {
|
|
242
|
+
return e._argsDescription && e.registeredArguments.forEach((t) => {
|
|
243
|
+
t.description = t.description || e._argsDescription[t.name()] || "";
|
|
244
|
+
}), e.registeredArguments.find((t) => t.description) ? e.registeredArguments : [];
|
|
245
|
+
}
|
|
246
|
+
/**
|
|
247
|
+
* Get the command term to show in the list of subcommands.
|
|
248
|
+
*
|
|
249
|
+
* @param {Command} cmd
|
|
250
|
+
* @returns {string}
|
|
251
|
+
*/
|
|
252
|
+
subcommandTerm(e) {
|
|
253
|
+
let t = e.registeredArguments.map((i) => Be(i)).join(" ");
|
|
254
|
+
return e._name + (e._aliases[0] ? "|" + e._aliases[0] : "") + (e.options.length ? " [options]" : "") + // simplistic check for non-help option
|
|
255
|
+
(t ? " " + t : "");
|
|
256
|
+
}
|
|
257
|
+
/**
|
|
258
|
+
* Get the option term to show in the list of options.
|
|
259
|
+
*
|
|
260
|
+
* @param {Option} option
|
|
261
|
+
* @returns {string}
|
|
262
|
+
*/
|
|
263
|
+
optionTerm(e) {
|
|
264
|
+
return e.flags;
|
|
265
|
+
}
|
|
266
|
+
/**
|
|
267
|
+
* Get the argument term to show in the list of arguments.
|
|
268
|
+
*
|
|
269
|
+
* @param {Argument} argument
|
|
270
|
+
* @returns {string}
|
|
271
|
+
*/
|
|
272
|
+
argumentTerm(e) {
|
|
273
|
+
return e.name();
|
|
274
|
+
}
|
|
275
|
+
/**
|
|
276
|
+
* Get the longest command term length.
|
|
277
|
+
*
|
|
278
|
+
* @param {Command} cmd
|
|
279
|
+
* @param {Help} helper
|
|
280
|
+
* @returns {number}
|
|
281
|
+
*/
|
|
282
|
+
longestSubcommandTermLength(e, t) {
|
|
283
|
+
return t.visibleCommands(e).reduce((i, n) => Math.max(i, t.subcommandTerm(n).length), 0);
|
|
284
|
+
}
|
|
285
|
+
/**
|
|
286
|
+
* Get the longest option term length.
|
|
287
|
+
*
|
|
288
|
+
* @param {Command} cmd
|
|
289
|
+
* @param {Help} helper
|
|
290
|
+
* @returns {number}
|
|
291
|
+
*/
|
|
292
|
+
longestOptionTermLength(e, t) {
|
|
293
|
+
return t.visibleOptions(e).reduce((i, n) => Math.max(i, t.optionTerm(n).length), 0);
|
|
294
|
+
}
|
|
295
|
+
/**
|
|
296
|
+
* Get the longest global option term length.
|
|
297
|
+
*
|
|
298
|
+
* @param {Command} cmd
|
|
299
|
+
* @param {Help} helper
|
|
300
|
+
* @returns {number}
|
|
301
|
+
*/
|
|
302
|
+
longestGlobalOptionTermLength(e, t) {
|
|
303
|
+
return t.visibleGlobalOptions(e).reduce((i, n) => Math.max(i, t.optionTerm(n).length), 0);
|
|
304
|
+
}
|
|
305
|
+
/**
|
|
306
|
+
* Get the longest argument term length.
|
|
307
|
+
*
|
|
308
|
+
* @param {Command} cmd
|
|
309
|
+
* @param {Help} helper
|
|
310
|
+
* @returns {number}
|
|
311
|
+
*/
|
|
312
|
+
longestArgumentTermLength(e, t) {
|
|
313
|
+
return t.visibleArguments(e).reduce((i, n) => Math.max(i, t.argumentTerm(n).length), 0);
|
|
314
|
+
}
|
|
315
|
+
/**
|
|
316
|
+
* Get the command usage to be displayed at the top of the built-in help.
|
|
317
|
+
*
|
|
318
|
+
* @param {Command} cmd
|
|
319
|
+
* @returns {string}
|
|
320
|
+
*/
|
|
321
|
+
commandUsage(e) {
|
|
322
|
+
let t = e._name;
|
|
323
|
+
e._aliases[0] && (t = t + "|" + e._aliases[0]);
|
|
324
|
+
let i = "";
|
|
325
|
+
for (let n = e.parent; n; n = n.parent)
|
|
326
|
+
i = n.name() + " " + i;
|
|
327
|
+
return i + t + " " + e.usage();
|
|
328
|
+
}
|
|
329
|
+
/**
|
|
330
|
+
* Get the description for the command.
|
|
331
|
+
*
|
|
332
|
+
* @param {Command} cmd
|
|
333
|
+
* @returns {string}
|
|
334
|
+
*/
|
|
335
|
+
commandDescription(e) {
|
|
336
|
+
return e.description();
|
|
337
|
+
}
|
|
338
|
+
/**
|
|
339
|
+
* Get the subcommand summary to show in the list of subcommands.
|
|
340
|
+
* (Fallback to description for backwards compatibility.)
|
|
341
|
+
*
|
|
342
|
+
* @param {Command} cmd
|
|
343
|
+
* @returns {string}
|
|
344
|
+
*/
|
|
345
|
+
subcommandDescription(e) {
|
|
346
|
+
return e.summary() || e.description();
|
|
347
|
+
}
|
|
348
|
+
/**
|
|
349
|
+
* Get the option description to show in the list of options.
|
|
350
|
+
*
|
|
351
|
+
* @param {Option} option
|
|
352
|
+
* @return {string}
|
|
353
|
+
*/
|
|
354
|
+
optionDescription(e) {
|
|
355
|
+
let t = [];
|
|
356
|
+
return e.argChoices && t.push(
|
|
357
|
+
// use stringify to match the display of the default value
|
|
358
|
+
`choices: ${e.argChoices.map((i) => JSON.stringify(i)).join(", ")}`
|
|
359
|
+
), e.defaultValue !== void 0 && (e.required || e.optional || e.isBoolean() && typeof e.defaultValue == "boolean") && t.push(
|
|
360
|
+
`default: ${e.defaultValueDescription || JSON.stringify(e.defaultValue)}`
|
|
361
|
+
), e.presetArg !== void 0 && e.optional && t.push(`preset: ${JSON.stringify(e.presetArg)}`), e.envVar !== void 0 && t.push(`env: ${e.envVar}`),
|
|
362
|
+
t.length > 0 ? `${e.description} (${t.join(", ")})` : e.description;
|
|
363
|
+
}
|
|
364
|
+
/**
|
|
365
|
+
* Get the argument description to show in the list of arguments.
|
|
366
|
+
*
|
|
367
|
+
* @param {Argument} argument
|
|
368
|
+
* @return {string}
|
|
369
|
+
*/
|
|
370
|
+
argumentDescription(e) {
|
|
371
|
+
let t = [];
|
|
372
|
+
if (e.argChoices && t.push(
|
|
373
|
+
// use stringify to match the display of the default value
|
|
374
|
+
`choices: ${e.argChoices.map((i) => JSON.stringify(i)).join(", ")}`
|
|
375
|
+
), e.defaultValue !== void 0 && t.push(
|
|
376
|
+
`default: ${e.defaultValueDescription || JSON.stringify(e.defaultValue)}`
|
|
377
|
+
), t.length > 0) {
|
|
378
|
+
let i = `(${t.join(", ")})`;
|
|
379
|
+
return e.description ? `${e.description} ${i}` : i;
|
|
380
|
+
}
|
|
381
|
+
return e.description;
|
|
382
|
+
}
|
|
383
|
+
/**
|
|
384
|
+
* Generate the built-in help text.
|
|
385
|
+
*
|
|
386
|
+
* @param {Command} cmd
|
|
387
|
+
* @param {Help} helper
|
|
388
|
+
* @returns {string}
|
|
389
|
+
*/
|
|
390
|
+
formatHelp(e, t) {
|
|
391
|
+
let i = t.padWidth(e, t), n = t.helpWidth || 80, r = 2, o = 2;
|
|
392
|
+
function l(f, y) {
|
|
393
|
+
if (y) {
|
|
394
|
+
let I = `${f.padEnd(i + o)}${y}`;
|
|
395
|
+
return t.wrap(
|
|
396
|
+
I,
|
|
397
|
+
n - r,
|
|
398
|
+
i + o
|
|
399
|
+
);
|
|
400
|
+
}
|
|
401
|
+
return f;
|
|
402
|
+
}
|
|
403
|
+
c(l, "formatItem");
|
|
404
|
+
function a(f) {
|
|
405
|
+
return f.join(`
|
|
406
|
+
`).replace(/^/gm, " ".repeat(r));
|
|
407
|
+
}
|
|
408
|
+
c(a, "formatList");
|
|
409
|
+
let u = [`Usage: ${t.commandUsage(e)}`, ""], d = t.commandDescription(e);
|
|
410
|
+
d.length > 0 && (u = u.concat([
|
|
411
|
+
t.wrap(d, n, 0),
|
|
412
|
+
""
|
|
413
|
+
]));
|
|
414
|
+
let h = t.visibleArguments(e).map((f) => l(
|
|
415
|
+
t.argumentTerm(f),
|
|
416
|
+
t.argumentDescription(f)
|
|
417
|
+
));
|
|
418
|
+
h.length > 0 && (u = u.concat(["Arguments:", a(h), ""]));
|
|
419
|
+
let m = t.visibleOptions(e).map((f) => l(
|
|
420
|
+
t.optionTerm(f),
|
|
421
|
+
t.optionDescription(f)
|
|
422
|
+
));
|
|
423
|
+
if (m.length > 0 && (u = u.concat(["Options:", a(m), ""])), this.showGlobalOptions) {
|
|
424
|
+
let f = t.visibleGlobalOptions(e).map((y) => l(
|
|
425
|
+
t.optionTerm(y),
|
|
426
|
+
t.optionDescription(y)
|
|
427
|
+
));
|
|
428
|
+
f.length > 0 && (u = u.concat([
|
|
429
|
+
"Global Options:",
|
|
430
|
+
a(f),
|
|
431
|
+
""
|
|
432
|
+
]));
|
|
433
|
+
}
|
|
434
|
+
let _ = t.visibleCommands(e).map((f) => l(
|
|
435
|
+
t.subcommandTerm(f),
|
|
436
|
+
t.subcommandDescription(f)
|
|
437
|
+
));
|
|
438
|
+
return _.length > 0 && (u = u.concat(["Commands:", a(_), ""])), u.join(`
|
|
439
|
+
`);
|
|
440
|
+
}
|
|
441
|
+
/**
|
|
442
|
+
* Calculate the pad width from the maximum term length.
|
|
443
|
+
*
|
|
444
|
+
* @param {Command} cmd
|
|
445
|
+
* @param {Help} helper
|
|
446
|
+
* @returns {number}
|
|
447
|
+
*/
|
|
448
|
+
padWidth(e, t) {
|
|
449
|
+
return Math.max(
|
|
450
|
+
t.longestOptionTermLength(e, t),
|
|
451
|
+
t.longestGlobalOptionTermLength(e, t),
|
|
452
|
+
t.longestSubcommandTermLength(e, t),
|
|
453
|
+
t.longestArgumentTermLength(e, t)
|
|
454
|
+
);
|
|
455
|
+
}
|
|
456
|
+
/**
|
|
457
|
+
* Wrap the given string to width characters per line, with lines after the first indented.
|
|
458
|
+
* Do not wrap if insufficient room for wrapping (minColumnWidth), or string is manually formatted.
|
|
459
|
+
*
|
|
460
|
+
* @param {string} str
|
|
461
|
+
* @param {number} width
|
|
462
|
+
* @param {number} indent
|
|
463
|
+
* @param {number} [minColumnWidth=40]
|
|
464
|
+
* @return {string}
|
|
465
|
+
*
|
|
466
|
+
*/
|
|
467
|
+
wrap(e, t, i, n = 40) {
|
|
468
|
+
let r = " \\f\\t\\v\xA0\u1680\u2000-\u200A\u202F\u205F\u3000\uFEFF", o = new RegExp(`[\\n][${r}]+`);
|
|
469
|
+
if (e.match(o)) return e;
|
|
470
|
+
let l = t - i;
|
|
471
|
+
if (l < n) return e;
|
|
472
|
+
let a = e.slice(0, i), u = e.slice(i).replace(`\r
|
|
473
|
+
`, `
|
|
474
|
+
`), d = " ".repeat(i), m = "\\s\u200B", _ = new RegExp(
|
|
475
|
+
`
|
|
476
|
+
|.{1,${l - 1}}([${m}]|$)|[^${m}]+?([${m}]|$)`,
|
|
477
|
+
"g"
|
|
478
|
+
), f = u.match(_) || [];
|
|
479
|
+
return a + f.map((y, I) => y === `
|
|
480
|
+
` ? "" : (I > 0 ? d : "") + y.trimEnd()).join(`
|
|
481
|
+
`);
|
|
482
|
+
}
|
|
483
|
+
};
|
|
484
|
+
ae.Help = L;
|
|
485
|
+
});
|
|
486
|
+
|
|
487
|
+
// ../node_modules/commander/lib/option.js
|
|
488
|
+
var J = b((U) => {
|
|
489
|
+
var { InvalidArgumentError: Me } = k(), R = class {
|
|
490
|
+
static {
|
|
491
|
+
c(this, "Option");
|
|
492
|
+
}
|
|
493
|
+
/**
|
|
494
|
+
* Initialize a new `Option` with the given `flags` and `description`.
|
|
495
|
+
*
|
|
496
|
+
* @param {string} flags
|
|
497
|
+
* @param {string} [description]
|
|
498
|
+
*/
|
|
499
|
+
constructor(e, t) {
|
|
500
|
+
this.flags = e, this.description = t || "", this.required = e.includes("<"), this.optional = e.includes("["), this.variadic = /\w\.\.\.[>\]]$/.
|
|
501
|
+
test(e), this.mandatory = !1;
|
|
502
|
+
let i = We(e);
|
|
503
|
+
this.short = i.shortFlag, this.long = i.longFlag, this.negate = !1, this.long && (this.negate = this.long.startsWith("--no-")), this.defaultValue =
|
|
504
|
+
void 0, this.defaultValueDescription = void 0, this.presetArg = void 0, this.envVar = void 0, this.parseArg = void 0, this.hidden = !1,
|
|
505
|
+
this.argChoices = void 0, this.conflictsWith = [], this.implied = void 0;
|
|
506
|
+
}
|
|
507
|
+
/**
|
|
508
|
+
* Set the default value, and optionally supply the description to be displayed in the help.
|
|
509
|
+
*
|
|
510
|
+
* @param {*} value
|
|
511
|
+
* @param {string} [description]
|
|
512
|
+
* @return {Option}
|
|
513
|
+
*/
|
|
514
|
+
default(e, t) {
|
|
515
|
+
return this.defaultValue = e, this.defaultValueDescription = t, this;
|
|
516
|
+
}
|
|
517
|
+
/**
|
|
518
|
+
* Preset to use when option used without option-argument, especially optional but also boolean and negated.
|
|
519
|
+
* The custom processing (parseArg) is called.
|
|
520
|
+
*
|
|
521
|
+
* @example
|
|
522
|
+
* new Option('--color').default('GREYSCALE').preset('RGB');
|
|
523
|
+
* new Option('--donate [amount]').preset('20').argParser(parseFloat);
|
|
524
|
+
*
|
|
525
|
+
* @param {*} arg
|
|
526
|
+
* @return {Option}
|
|
527
|
+
*/
|
|
528
|
+
preset(e) {
|
|
529
|
+
return this.presetArg = e, this;
|
|
530
|
+
}
|
|
531
|
+
/**
|
|
532
|
+
* Add option name(s) that conflict with this option.
|
|
533
|
+
* An error will be displayed if conflicting options are found during parsing.
|
|
534
|
+
*
|
|
535
|
+
* @example
|
|
536
|
+
* new Option('--rgb').conflicts('cmyk');
|
|
537
|
+
* new Option('--js').conflicts(['ts', 'jsx']);
|
|
538
|
+
*
|
|
539
|
+
* @param {(string | string[])} names
|
|
540
|
+
* @return {Option}
|
|
541
|
+
*/
|
|
542
|
+
conflicts(e) {
|
|
543
|
+
return this.conflictsWith = this.conflictsWith.concat(e), this;
|
|
544
|
+
}
|
|
545
|
+
/**
|
|
546
|
+
* Specify implied option values for when this option is set and the implied options are not.
|
|
547
|
+
*
|
|
548
|
+
* The custom processing (parseArg) is not called on the implied values.
|
|
549
|
+
*
|
|
550
|
+
* @example
|
|
551
|
+
* program
|
|
552
|
+
* .addOption(new Option('--log', 'write logging information to file'))
|
|
553
|
+
* .addOption(new Option('--trace', 'log extra details').implies({ log: 'trace.txt' }));
|
|
554
|
+
*
|
|
555
|
+
* @param {object} impliedOptionValues
|
|
556
|
+
* @return {Option}
|
|
557
|
+
*/
|
|
558
|
+
implies(e) {
|
|
559
|
+
let t = e;
|
|
560
|
+
return typeof e == "string" && (t = { [e]: !0 }), this.implied = Object.assign(this.implied || {}, t), this;
|
|
561
|
+
}
|
|
562
|
+
/**
|
|
563
|
+
* Set environment variable to check for option value.
|
|
564
|
+
*
|
|
565
|
+
* An environment variable is only used if when processed the current option value is
|
|
566
|
+
* undefined, or the source of the current value is 'default' or 'config' or 'env'.
|
|
567
|
+
*
|
|
568
|
+
* @param {string} name
|
|
569
|
+
* @return {Option}
|
|
570
|
+
*/
|
|
571
|
+
env(e) {
|
|
572
|
+
return this.envVar = e, this;
|
|
573
|
+
}
|
|
574
|
+
/**
|
|
575
|
+
* Set the custom handler for processing CLI option arguments into option values.
|
|
576
|
+
*
|
|
577
|
+
* @param {Function} [fn]
|
|
578
|
+
* @return {Option}
|
|
579
|
+
*/
|
|
580
|
+
argParser(e) {
|
|
581
|
+
return this.parseArg = e, this;
|
|
582
|
+
}
|
|
583
|
+
/**
|
|
584
|
+
* Whether the option is mandatory and must have a value after parsing.
|
|
585
|
+
*
|
|
586
|
+
* @param {boolean} [mandatory=true]
|
|
587
|
+
* @return {Option}
|
|
588
|
+
*/
|
|
589
|
+
makeOptionMandatory(e = !0) {
|
|
590
|
+
return this.mandatory = !!e, this;
|
|
591
|
+
}
|
|
592
|
+
/**
|
|
593
|
+
* Hide option in help.
|
|
594
|
+
*
|
|
595
|
+
* @param {boolean} [hide=true]
|
|
596
|
+
* @return {Option}
|
|
597
|
+
*/
|
|
598
|
+
hideHelp(e = !0) {
|
|
599
|
+
return this.hidden = !!e, this;
|
|
600
|
+
}
|
|
601
|
+
/**
|
|
602
|
+
* @package
|
|
603
|
+
*/
|
|
604
|
+
_concatValue(e, t) {
|
|
605
|
+
return t === this.defaultValue || !Array.isArray(t) ? [e] : t.concat(e);
|
|
606
|
+
}
|
|
607
|
+
/**
|
|
608
|
+
* Only allow option value to be one of choices.
|
|
609
|
+
*
|
|
610
|
+
* @param {string[]} values
|
|
611
|
+
* @return {Option}
|
|
612
|
+
*/
|
|
613
|
+
choices(e) {
|
|
614
|
+
return this.argChoices = e.slice(), this.parseArg = (t, i) => {
|
|
615
|
+
if (!this.argChoices.includes(t))
|
|
616
|
+
throw new Me(
|
|
617
|
+
`Allowed choices are ${this.argChoices.join(", ")}.`
|
|
618
|
+
);
|
|
619
|
+
return this.variadic ? this._concatValue(t, i) : t;
|
|
620
|
+
}, this;
|
|
621
|
+
}
|
|
622
|
+
/**
|
|
623
|
+
* Return option name.
|
|
624
|
+
*
|
|
625
|
+
* @return {string}
|
|
626
|
+
*/
|
|
627
|
+
name() {
|
|
628
|
+
return this.long ? this.long.replace(/^--/, "") : this.short.replace(/^-/, "");
|
|
629
|
+
}
|
|
630
|
+
/**
|
|
631
|
+
* Return option name, in a camelcase format that can be used
|
|
632
|
+
* as a object attribute key.
|
|
633
|
+
*
|
|
634
|
+
* @return {string}
|
|
635
|
+
*/
|
|
636
|
+
attributeName() {
|
|
637
|
+
return Le(this.name().replace(/^no-/, ""));
|
|
638
|
+
}
|
|
639
|
+
/**
|
|
640
|
+
* Check if `arg` matches the short or long flag.
|
|
641
|
+
*
|
|
642
|
+
* @param {string} arg
|
|
643
|
+
* @return {boolean}
|
|
644
|
+
* @package
|
|
645
|
+
*/
|
|
646
|
+
is(e) {
|
|
647
|
+
return this.short === e || this.long === e;
|
|
648
|
+
}
|
|
649
|
+
/**
|
|
650
|
+
* Return whether a boolean option.
|
|
651
|
+
*
|
|
652
|
+
* Options are one of boolean, negated, required argument, or optional argument.
|
|
653
|
+
*
|
|
654
|
+
* @return {boolean}
|
|
655
|
+
* @package
|
|
656
|
+
*/
|
|
657
|
+
isBoolean() {
|
|
658
|
+
return !this.required && !this.optional && !this.negate;
|
|
659
|
+
}
|
|
660
|
+
}, G = class {
|
|
661
|
+
static {
|
|
662
|
+
c(this, "DualOptions");
|
|
663
|
+
}
|
|
664
|
+
/**
|
|
665
|
+
* @param {Option[]} options
|
|
666
|
+
*/
|
|
667
|
+
constructor(e) {
|
|
668
|
+
this.positiveOptions = /* @__PURE__ */ new Map(), this.negativeOptions = /* @__PURE__ */ new Map(), this.dualOptions = /* @__PURE__ */ new Set(),
|
|
669
|
+
e.forEach((t) => {
|
|
670
|
+
t.negate ? this.negativeOptions.set(t.attributeName(), t) : this.positiveOptions.set(t.attributeName(), t);
|
|
671
|
+
}), this.negativeOptions.forEach((t, i) => {
|
|
672
|
+
this.positiveOptions.has(i) && this.dualOptions.add(i);
|
|
673
|
+
});
|
|
674
|
+
}
|
|
675
|
+
/**
|
|
676
|
+
* Did the value come from the option, and not from possible matching dual option?
|
|
677
|
+
*
|
|
678
|
+
* @param {*} value
|
|
679
|
+
* @param {Option} option
|
|
680
|
+
* @returns {boolean}
|
|
681
|
+
*/
|
|
682
|
+
valueFromOption(e, t) {
|
|
683
|
+
let i = t.attributeName();
|
|
684
|
+
if (!this.dualOptions.has(i)) return !0;
|
|
685
|
+
let n = this.negativeOptions.get(i).presetArg, r = n !== void 0 ? n : !1;
|
|
686
|
+
return t.negate === (r === e);
|
|
687
|
+
}
|
|
688
|
+
};
|
|
689
|
+
function Le(s) {
|
|
690
|
+
return s.split("-").reduce((e, t) => e + t[0].toUpperCase() + t.slice(1));
|
|
691
|
+
}
|
|
692
|
+
c(Le, "camelcase");
|
|
693
|
+
function We(s) {
|
|
694
|
+
let e, t, i = s.split(/[ |,]+/);
|
|
695
|
+
return i.length > 1 && !/^[[<]/.test(i[1]) && (e = i.shift()), t = i.shift(), !e && /^-[^-]$/.test(t) && (e = t, t = void 0), { shortFlag: e,
|
|
696
|
+
longFlag: t };
|
|
697
|
+
}
|
|
698
|
+
c(We, "splitOptionFlags");
|
|
699
|
+
U.Option = R;
|
|
700
|
+
U.DualOptions = G;
|
|
701
|
+
});
|
|
702
|
+
|
|
703
|
+
// ../node_modules/commander/lib/suggestSimilar.js
|
|
704
|
+
var ce = b((le) => {
|
|
705
|
+
function Re(s, e) {
|
|
706
|
+
if (Math.abs(s.length - e.length) > 3)
|
|
707
|
+
return Math.max(s.length, e.length);
|
|
708
|
+
let t = [];
|
|
709
|
+
for (let i = 0; i <= s.length; i++)
|
|
710
|
+
t[i] = [i];
|
|
711
|
+
for (let i = 0; i <= e.length; i++)
|
|
712
|
+
t[0][i] = i;
|
|
713
|
+
for (let i = 1; i <= e.length; i++)
|
|
714
|
+
for (let n = 1; n <= s.length; n++) {
|
|
715
|
+
let r = 1;
|
|
716
|
+
s[n - 1] === e[i - 1] ? r = 0 : r = 1, t[n][i] = Math.min(
|
|
717
|
+
t[n - 1][i] + 1,
|
|
718
|
+
// deletion
|
|
719
|
+
t[n][i - 1] + 1,
|
|
720
|
+
// insertion
|
|
721
|
+
t[n - 1][i - 1] + r
|
|
722
|
+
// substitution
|
|
723
|
+
), n > 1 && i > 1 && s[n - 1] === e[i - 2] && s[n - 2] === e[i - 1] && (t[n][i] = Math.min(t[n][i], t[n - 2][i - 2] + 1));
|
|
724
|
+
}
|
|
725
|
+
return t[s.length][e.length];
|
|
726
|
+
}
|
|
727
|
+
c(Re, "editDistance");
|
|
728
|
+
function Ge(s, e) {
|
|
729
|
+
if (!e || e.length === 0) return "";
|
|
730
|
+
e = Array.from(new Set(e));
|
|
731
|
+
let t = s.startsWith("--");
|
|
732
|
+
t && (s = s.slice(2), e = e.map((o) => o.slice(2)));
|
|
733
|
+
let i = [], n = 3, r = 0.4;
|
|
734
|
+
return e.forEach((o) => {
|
|
735
|
+
if (o.length <= 1) return;
|
|
736
|
+
let l = Re(s, o), a = Math.max(s.length, o.length);
|
|
737
|
+
(a - l) / a > r && (l < n ? (n = l, i = [o]) : l === n && i.push(o));
|
|
738
|
+
}), i.sort((o, l) => o.localeCompare(l)), t && (i = i.map((o) => `--${o}`)), i.length > 1 ? `
|
|
739
|
+
(Did you mean one of ${i.join(", ")}?)` : i.length === 1 ? `
|
|
740
|
+
(Did you mean ${i[0]}?)` : "";
|
|
741
|
+
}
|
|
742
|
+
c(Ge, "suggestSimilar");
|
|
743
|
+
le.suggestSimilar = Ge;
|
|
744
|
+
});
|
|
745
|
+
|
|
746
|
+
// ../node_modules/commander/lib/command.js
|
|
747
|
+
var me = b((pe) => {
|
|
748
|
+
var Ue = C("node:events").EventEmitter, Y = C("node:child_process"), x = C("node:path"), z = C("node:fs"), p = C("node:process"), { Argument: Je,
|
|
749
|
+
humanReadableArgName: Ye } = H(), { CommanderError: K } = k(), { Help: ze } = W(), { Option: ue, DualOptions: Ke } = J(), { suggestSimilar: de } = ce(),
|
|
750
|
+
Q = class s extends Ue {
|
|
751
|
+
static {
|
|
752
|
+
c(this, "Command");
|
|
753
|
+
}
|
|
754
|
+
/**
|
|
755
|
+
* Initialize a new `Command`.
|
|
756
|
+
*
|
|
757
|
+
* @param {string} [name]
|
|
758
|
+
*/
|
|
759
|
+
constructor(e) {
|
|
760
|
+
super(), this.commands = [], this.options = [], this.parent = null, this._allowUnknownOption = !1, this._allowExcessArguments = !0, this.
|
|
761
|
+
registeredArguments = [], this._args = this.registeredArguments, this.args = [], this.rawArgs = [], this.processedArgs = [], this._scriptPath =
|
|
762
|
+
null, this._name = e || "", this._optionValues = {}, this._optionValueSources = {}, this._storeOptionsAsProperties = !1, this._actionHandler =
|
|
763
|
+
null, this._executableHandler = !1, this._executableFile = null, this._executableDir = null, this._defaultCommandName = null, this._exitCallback =
|
|
764
|
+
null, this._aliases = [], this._combineFlagAndOptionalValue = !0, this._description = "", this._summary = "", this._argsDescription = void 0,
|
|
765
|
+
this._enablePositionalOptions = !1, this._passThroughOptions = !1, this._lifeCycleHooks = {}, this._showHelpAfterError = !1, this._showSuggestionAfterError =
|
|
766
|
+
!0, this._outputConfiguration = {
|
|
767
|
+
writeOut: /* @__PURE__ */ c((t) => p.stdout.write(t), "writeOut"),
|
|
768
|
+
writeErr: /* @__PURE__ */ c((t) => p.stderr.write(t), "writeErr"),
|
|
769
|
+
getOutHelpWidth: /* @__PURE__ */ c(() => p.stdout.isTTY ? p.stdout.columns : void 0, "getOutHelpWidth"),
|
|
770
|
+
getErrHelpWidth: /* @__PURE__ */ c(() => p.stderr.isTTY ? p.stderr.columns : void 0, "getErrHelpWidth"),
|
|
771
|
+
outputError: /* @__PURE__ */ c((t, i) => i(t), "outputError")
|
|
772
|
+
}, this._hidden = !1, this._helpOption = void 0, this._addImplicitHelpCommand = void 0, this._helpCommand = void 0, this._helpConfiguration =
|
|
773
|
+
{};
|
|
774
|
+
}
|
|
775
|
+
/**
|
|
776
|
+
* Copy settings that are useful to have in common across root command and subcommands.
|
|
777
|
+
*
|
|
778
|
+
* (Used internally when adding a command using `.command()` so subcommands inherit parent settings.)
|
|
779
|
+
*
|
|
780
|
+
* @param {Command} sourceCommand
|
|
781
|
+
* @return {Command} `this` command for chaining
|
|
782
|
+
*/
|
|
783
|
+
copyInheritedSettings(e) {
|
|
784
|
+
return this._outputConfiguration = e._outputConfiguration, this._helpOption = e._helpOption, this._helpCommand = e._helpCommand, this.
|
|
785
|
+
_helpConfiguration = e._helpConfiguration, this._exitCallback = e._exitCallback, this._storeOptionsAsProperties = e._storeOptionsAsProperties,
|
|
786
|
+
this._combineFlagAndOptionalValue = e._combineFlagAndOptionalValue, this._allowExcessArguments = e._allowExcessArguments, this._enablePositionalOptions =
|
|
787
|
+
e._enablePositionalOptions, this._showHelpAfterError = e._showHelpAfterError, this._showSuggestionAfterError = e._showSuggestionAfterError,
|
|
788
|
+
this;
|
|
789
|
+
}
|
|
790
|
+
/**
|
|
791
|
+
* @returns {Command[]}
|
|
792
|
+
* @private
|
|
793
|
+
*/
|
|
794
|
+
_getCommandAndAncestors() {
|
|
795
|
+
let e = [];
|
|
796
|
+
for (let t = this; t; t = t.parent)
|
|
797
|
+
e.push(t);
|
|
798
|
+
return e;
|
|
799
|
+
}
|
|
800
|
+
/**
|
|
801
|
+
* Define a command.
|
|
802
|
+
*
|
|
803
|
+
* There are two styles of command: pay attention to where to put the description.
|
|
804
|
+
*
|
|
805
|
+
* @example
|
|
806
|
+
* // Command implemented using action handler (description is supplied separately to `.command`)
|
|
807
|
+
* program
|
|
808
|
+
* .command('clone <source> [destination]')
|
|
809
|
+
* .description('clone a repository into a newly created directory')
|
|
810
|
+
* .action((source, destination) => {
|
|
811
|
+
* console.log('clone command called');
|
|
812
|
+
* });
|
|
813
|
+
*
|
|
814
|
+
* // Command implemented using separate executable file (description is second parameter to `.command`)
|
|
815
|
+
* program
|
|
816
|
+
* .command('start <service>', 'start named service')
|
|
817
|
+
* .command('stop [service]', 'stop named service, or all if no name supplied');
|
|
818
|
+
*
|
|
819
|
+
* @param {string} nameAndArgs - command name and arguments, args are `<required>` or `[optional]` and last may also be `variadic...`
|
|
820
|
+
* @param {(object | string)} [actionOptsOrExecDesc] - configuration options (for action), or description (for executable)
|
|
821
|
+
* @param {object} [execOpts] - configuration options (for executable)
|
|
822
|
+
* @return {Command} returns new command for action handler, or `this` for executable command
|
|
823
|
+
*/
|
|
824
|
+
command(e, t, i) {
|
|
825
|
+
let n = t, r = i;
|
|
826
|
+
typeof n == "object" && n !== null && (r = n, n = null), r = r || {};
|
|
827
|
+
let [, o, l] = e.match(/([^ ]+) *(.*)/), a = this.createCommand(o);
|
|
828
|
+
return n && (a.description(n), a._executableHandler = !0), r.isDefault && (this._defaultCommandName = a._name), a._hidden = !!(r.noHelp ||
|
|
829
|
+
r.hidden), a._executableFile = r.executableFile || null, l && a.arguments(l), this._registerCommand(a), a.parent = this, a.copyInheritedSettings(
|
|
830
|
+
this), n ? this : a;
|
|
831
|
+
}
|
|
832
|
+
/**
|
|
833
|
+
* Factory routine to create a new unattached command.
|
|
834
|
+
*
|
|
835
|
+
* See .command() for creating an attached subcommand, which uses this routine to
|
|
836
|
+
* create the command. You can override createCommand to customise subcommands.
|
|
837
|
+
*
|
|
838
|
+
* @param {string} [name]
|
|
839
|
+
* @return {Command} new command
|
|
840
|
+
*/
|
|
841
|
+
createCommand(e) {
|
|
842
|
+
return new s(e);
|
|
843
|
+
}
|
|
844
|
+
/**
|
|
845
|
+
* You can customise the help with a subclass of Help by overriding createHelp,
|
|
846
|
+
* or by overriding Help properties using configureHelp().
|
|
847
|
+
*
|
|
848
|
+
* @return {Help}
|
|
849
|
+
*/
|
|
850
|
+
createHelp() {
|
|
851
|
+
return Object.assign(new ze(), this.configureHelp());
|
|
852
|
+
}
|
|
853
|
+
/**
|
|
854
|
+
* You can customise the help by overriding Help properties using configureHelp(),
|
|
855
|
+
* or with a subclass of Help by overriding createHelp().
|
|
856
|
+
*
|
|
857
|
+
* @param {object} [configuration] - configuration options
|
|
858
|
+
* @return {(Command | object)} `this` command for chaining, or stored configuration
|
|
859
|
+
*/
|
|
860
|
+
configureHelp(e) {
|
|
861
|
+
return e === void 0 ? this._helpConfiguration : (this._helpConfiguration = e, this);
|
|
862
|
+
}
|
|
863
|
+
/**
|
|
864
|
+
* The default output goes to stdout and stderr. You can customise this for special
|
|
865
|
+
* applications. You can also customise the display of errors by overriding outputError.
|
|
866
|
+
*
|
|
867
|
+
* The configuration properties are all functions:
|
|
868
|
+
*
|
|
869
|
+
* // functions to change where being written, stdout and stderr
|
|
870
|
+
* writeOut(str)
|
|
871
|
+
* writeErr(str)
|
|
872
|
+
* // matching functions to specify width for wrapping help
|
|
873
|
+
* getOutHelpWidth()
|
|
874
|
+
* getErrHelpWidth()
|
|
875
|
+
* // functions based on what is being written out
|
|
876
|
+
* outputError(str, write) // used for displaying errors, and not used for displaying help
|
|
877
|
+
*
|
|
878
|
+
* @param {object} [configuration] - configuration options
|
|
879
|
+
* @return {(Command | object)} `this` command for chaining, or stored configuration
|
|
880
|
+
*/
|
|
881
|
+
configureOutput(e) {
|
|
882
|
+
return e === void 0 ? this._outputConfiguration : (Object.assign(this._outputConfiguration, e), this);
|
|
883
|
+
}
|
|
884
|
+
/**
|
|
885
|
+
* Display the help or a custom message after an error occurs.
|
|
886
|
+
*
|
|
887
|
+
* @param {(boolean|string)} [displayHelp]
|
|
888
|
+
* @return {Command} `this` command for chaining
|
|
889
|
+
*/
|
|
890
|
+
showHelpAfterError(e = !0) {
|
|
891
|
+
return typeof e != "string" && (e = !!e), this._showHelpAfterError = e, this;
|
|
892
|
+
}
|
|
893
|
+
/**
|
|
894
|
+
* Display suggestion of similar commands for unknown commands, or options for unknown options.
|
|
895
|
+
*
|
|
896
|
+
* @param {boolean} [displaySuggestion]
|
|
897
|
+
* @return {Command} `this` command for chaining
|
|
898
|
+
*/
|
|
899
|
+
showSuggestionAfterError(e = !0) {
|
|
900
|
+
return this._showSuggestionAfterError = !!e, this;
|
|
901
|
+
}
|
|
902
|
+
/**
|
|
903
|
+
* Add a prepared subcommand.
|
|
904
|
+
*
|
|
905
|
+
* See .command() for creating an attached subcommand which inherits settings from its parent.
|
|
906
|
+
*
|
|
907
|
+
* @param {Command} cmd - new subcommand
|
|
908
|
+
* @param {object} [opts] - configuration options
|
|
909
|
+
* @return {Command} `this` command for chaining
|
|
910
|
+
*/
|
|
911
|
+
addCommand(e, t) {
|
|
912
|
+
if (!e._name)
|
|
913
|
+
throw new Error(`Command passed to .addCommand() must have a name
|
|
914
|
+
- specify the name in Command constructor or using .name()`);
|
|
915
|
+
return t = t || {}, t.isDefault && (this._defaultCommandName = e._name), (t.noHelp || t.hidden) && (e._hidden = !0), this._registerCommand(
|
|
916
|
+
e), e.parent = this, e._checkForBrokenPassThrough(), this;
|
|
917
|
+
}
|
|
918
|
+
/**
|
|
919
|
+
* Factory routine to create a new unattached argument.
|
|
920
|
+
*
|
|
921
|
+
* See .argument() for creating an attached argument, which uses this routine to
|
|
922
|
+
* create the argument. You can override createArgument to return a custom argument.
|
|
923
|
+
*
|
|
924
|
+
* @param {string} name
|
|
925
|
+
* @param {string} [description]
|
|
926
|
+
* @return {Argument} new argument
|
|
927
|
+
*/
|
|
928
|
+
createArgument(e, t) {
|
|
929
|
+
return new Je(e, t);
|
|
930
|
+
}
|
|
931
|
+
/**
|
|
932
|
+
* Define argument syntax for command.
|
|
933
|
+
*
|
|
934
|
+
* The default is that the argument is required, and you can explicitly
|
|
935
|
+
* indicate this with <> around the name. Put [] around the name for an optional argument.
|
|
936
|
+
*
|
|
937
|
+
* @example
|
|
938
|
+
* program.argument('<input-file>');
|
|
939
|
+
* program.argument('[output-file]');
|
|
940
|
+
*
|
|
941
|
+
* @param {string} name
|
|
942
|
+
* @param {string} [description]
|
|
943
|
+
* @param {(Function|*)} [fn] - custom argument processing function
|
|
944
|
+
* @param {*} [defaultValue]
|
|
945
|
+
* @return {Command} `this` command for chaining
|
|
946
|
+
*/
|
|
947
|
+
argument(e, t, i, n) {
|
|
948
|
+
let r = this.createArgument(e, t);
|
|
949
|
+
return typeof i == "function" ? r.default(n).argParser(i) : r.default(i), this.addArgument(r), this;
|
|
950
|
+
}
|
|
951
|
+
/**
|
|
952
|
+
* Define argument syntax for command, adding multiple at once (without descriptions).
|
|
953
|
+
*
|
|
954
|
+
* See also .argument().
|
|
955
|
+
*
|
|
956
|
+
* @example
|
|
957
|
+
* program.arguments('<cmd> [env]');
|
|
958
|
+
*
|
|
959
|
+
* @param {string} names
|
|
960
|
+
* @return {Command} `this` command for chaining
|
|
961
|
+
*/
|
|
962
|
+
arguments(e) {
|
|
963
|
+
return e.trim().split(/ +/).forEach((t) => {
|
|
964
|
+
this.argument(t);
|
|
965
|
+
}), this;
|
|
966
|
+
}
|
|
967
|
+
/**
|
|
968
|
+
* Define argument syntax for command, adding a prepared argument.
|
|
969
|
+
*
|
|
970
|
+
* @param {Argument} argument
|
|
971
|
+
* @return {Command} `this` command for chaining
|
|
972
|
+
*/
|
|
973
|
+
addArgument(e) {
|
|
974
|
+
let t = this.registeredArguments.slice(-1)[0];
|
|
975
|
+
if (t && t.variadic)
|
|
976
|
+
throw new Error(
|
|
977
|
+
`only the last argument can be variadic '${t.name()}'`
|
|
978
|
+
);
|
|
979
|
+
if (e.required && e.defaultValue !== void 0 && e.parseArg === void 0)
|
|
980
|
+
throw new Error(
|
|
981
|
+
`a default value for a required argument is never used: '${e.name()}'`
|
|
982
|
+
);
|
|
983
|
+
return this.registeredArguments.push(e), this;
|
|
984
|
+
}
|
|
985
|
+
/**
|
|
986
|
+
* Customise or override default help command. By default a help command is automatically added if your command has subcommands.
|
|
987
|
+
*
|
|
988
|
+
* @example
|
|
989
|
+
* program.helpCommand('help [cmd]');
|
|
990
|
+
* program.helpCommand('help [cmd]', 'show help');
|
|
991
|
+
* program.helpCommand(false); // suppress default help command
|
|
992
|
+
* program.helpCommand(true); // add help command even if no subcommands
|
|
993
|
+
*
|
|
994
|
+
* @param {string|boolean} enableOrNameAndArgs - enable with custom name and/or arguments, or boolean to override whether added
|
|
995
|
+
* @param {string} [description] - custom description
|
|
996
|
+
* @return {Command} `this` command for chaining
|
|
997
|
+
*/
|
|
998
|
+
helpCommand(e, t) {
|
|
999
|
+
if (typeof e == "boolean")
|
|
1000
|
+
return this._addImplicitHelpCommand = e, this;
|
|
1001
|
+
e = e ?? "help [command]";
|
|
1002
|
+
let [, i, n] = e.match(/([^ ]+) *(.*)/), r = t ?? "display help for command", o = this.createCommand(i);
|
|
1003
|
+
return o.helpOption(!1), n && o.arguments(n), r && o.description(r), this._addImplicitHelpCommand = !0, this._helpCommand = o, this;
|
|
1004
|
+
}
|
|
1005
|
+
/**
|
|
1006
|
+
* Add prepared custom help command.
|
|
1007
|
+
*
|
|
1008
|
+
* @param {(Command|string|boolean)} helpCommand - custom help command, or deprecated enableOrNameAndArgs as for `.helpCommand()`
|
|
1009
|
+
* @param {string} [deprecatedDescription] - deprecated custom description used with custom name only
|
|
1010
|
+
* @return {Command} `this` command for chaining
|
|
1011
|
+
*/
|
|
1012
|
+
addHelpCommand(e, t) {
|
|
1013
|
+
return typeof e != "object" ? (this.helpCommand(e, t), this) : (this._addImplicitHelpCommand = !0, this._helpCommand = e, this);
|
|
1014
|
+
}
|
|
1015
|
+
/**
|
|
1016
|
+
* Lazy create help command.
|
|
1017
|
+
*
|
|
1018
|
+
* @return {(Command|null)}
|
|
1019
|
+
* @package
|
|
1020
|
+
*/
|
|
1021
|
+
_getHelpCommand() {
|
|
1022
|
+
return this._addImplicitHelpCommand ?? (this.commands.length && !this._actionHandler && !this._findCommand("help")) ? (this._helpCommand ===
|
|
1023
|
+
void 0 && this.helpCommand(void 0, void 0), this._helpCommand) : null;
|
|
1024
|
+
}
|
|
1025
|
+
/**
|
|
1026
|
+
* Add hook for life cycle event.
|
|
1027
|
+
*
|
|
1028
|
+
* @param {string} event
|
|
1029
|
+
* @param {Function} listener
|
|
1030
|
+
* @return {Command} `this` command for chaining
|
|
1031
|
+
*/
|
|
1032
|
+
hook(e, t) {
|
|
1033
|
+
let i = ["preSubcommand", "preAction", "postAction"];
|
|
1034
|
+
if (!i.includes(e))
|
|
1035
|
+
throw new Error(`Unexpected value for event passed to hook : '${e}'.
|
|
1036
|
+
Expecting one of '${i.join("', '")}'`);
|
|
1037
|
+
return this._lifeCycleHooks[e] ? this._lifeCycleHooks[e].push(t) : this._lifeCycleHooks[e] = [t], this;
|
|
1038
|
+
}
|
|
1039
|
+
/**
|
|
1040
|
+
* Register callback to use as replacement for calling process.exit.
|
|
1041
|
+
*
|
|
1042
|
+
* @param {Function} [fn] optional callback which will be passed a CommanderError, defaults to throwing
|
|
1043
|
+
* @return {Command} `this` command for chaining
|
|
1044
|
+
*/
|
|
1045
|
+
exitOverride(e) {
|
|
1046
|
+
return e ? this._exitCallback = e : this._exitCallback = (t) => {
|
|
1047
|
+
if (t.code !== "commander.executeSubCommandAsync")
|
|
1048
|
+
throw t;
|
|
1049
|
+
}, this;
|
|
1050
|
+
}
|
|
1051
|
+
/**
|
|
1052
|
+
* Call process.exit, and _exitCallback if defined.
|
|
1053
|
+
*
|
|
1054
|
+
* @param {number} exitCode exit code for using with process.exit
|
|
1055
|
+
* @param {string} code an id string representing the error
|
|
1056
|
+
* @param {string} message human-readable description of the error
|
|
1057
|
+
* @return never
|
|
1058
|
+
* @private
|
|
1059
|
+
*/
|
|
1060
|
+
_exit(e, t, i) {
|
|
1061
|
+
this._exitCallback && this._exitCallback(new K(e, t, i)), p.exit(e);
|
|
1062
|
+
}
|
|
1063
|
+
/**
|
|
1064
|
+
* Register callback `fn` for the command.
|
|
1065
|
+
*
|
|
1066
|
+
* @example
|
|
1067
|
+
* program
|
|
1068
|
+
* .command('serve')
|
|
1069
|
+
* .description('start service')
|
|
1070
|
+
* .action(function() {
|
|
1071
|
+
* // do work here
|
|
1072
|
+
* });
|
|
1073
|
+
*
|
|
1074
|
+
* @param {Function} fn
|
|
1075
|
+
* @return {Command} `this` command for chaining
|
|
1076
|
+
*/
|
|
1077
|
+
action(e) {
|
|
1078
|
+
let t = /* @__PURE__ */ c((i) => {
|
|
1079
|
+
let n = this.registeredArguments.length, r = i.slice(0, n);
|
|
1080
|
+
return this._storeOptionsAsProperties ? r[n] = this : r[n] = this.opts(), r.push(this), e.apply(this, r);
|
|
1081
|
+
}, "listener");
|
|
1082
|
+
return this._actionHandler = t, this;
|
|
1083
|
+
}
|
|
1084
|
+
/**
|
|
1085
|
+
* Factory routine to create a new unattached option.
|
|
1086
|
+
*
|
|
1087
|
+
* See .option() for creating an attached option, which uses this routine to
|
|
1088
|
+
* create the option. You can override createOption to return a custom option.
|
|
1089
|
+
*
|
|
1090
|
+
* @param {string} flags
|
|
1091
|
+
* @param {string} [description]
|
|
1092
|
+
* @return {Option} new option
|
|
1093
|
+
*/
|
|
1094
|
+
createOption(e, t) {
|
|
1095
|
+
return new ue(e, t);
|
|
1096
|
+
}
|
|
1097
|
+
/**
|
|
1098
|
+
* Wrap parseArgs to catch 'commander.invalidArgument'.
|
|
1099
|
+
*
|
|
1100
|
+
* @param {(Option | Argument)} target
|
|
1101
|
+
* @param {string} value
|
|
1102
|
+
* @param {*} previous
|
|
1103
|
+
* @param {string} invalidArgumentMessage
|
|
1104
|
+
* @private
|
|
1105
|
+
*/
|
|
1106
|
+
_callParseArg(e, t, i, n) {
|
|
1107
|
+
try {
|
|
1108
|
+
return e.parseArg(t, i);
|
|
1109
|
+
} catch (r) {
|
|
1110
|
+
if (r.code === "commander.invalidArgument") {
|
|
1111
|
+
let o = `${n} ${r.message}`;
|
|
1112
|
+
this.error(o, { exitCode: r.exitCode, code: r.code });
|
|
1113
|
+
}
|
|
1114
|
+
throw r;
|
|
1115
|
+
}
|
|
1116
|
+
}
|
|
1117
|
+
/**
|
|
1118
|
+
* Check for option flag conflicts.
|
|
1119
|
+
* Register option if no conflicts found, or throw on conflict.
|
|
1120
|
+
*
|
|
1121
|
+
* @param {Option} option
|
|
1122
|
+
* @private
|
|
1123
|
+
*/
|
|
1124
|
+
_registerOption(e) {
|
|
1125
|
+
let t = e.short && this._findOption(e.short) || e.long && this._findOption(e.long);
|
|
1126
|
+
if (t) {
|
|
1127
|
+
let i = e.long && this._findOption(e.long) ? e.long : e.short;
|
|
1128
|
+
throw new Error(`Cannot add option '${e.flags}'${this._name && ` to command '${this._name}'`} due to conflicting flag '${i}'
|
|
1129
|
+
- already used by option '${t.flags}'`);
|
|
1130
|
+
}
|
|
1131
|
+
this.options.push(e);
|
|
1132
|
+
}
|
|
1133
|
+
/**
|
|
1134
|
+
* Check for command name and alias conflicts with existing commands.
|
|
1135
|
+
* Register command if no conflicts found, or throw on conflict.
|
|
1136
|
+
*
|
|
1137
|
+
* @param {Command} command
|
|
1138
|
+
* @private
|
|
1139
|
+
*/
|
|
1140
|
+
_registerCommand(e) {
|
|
1141
|
+
let t = /* @__PURE__ */ c((n) => [n.name()].concat(n.aliases()), "knownBy"), i = t(e).find(
|
|
1142
|
+
(n) => this._findCommand(n)
|
|
1143
|
+
);
|
|
1144
|
+
if (i) {
|
|
1145
|
+
let n = t(this._findCommand(i)).join("|"), r = t(e).join("|");
|
|
1146
|
+
throw new Error(
|
|
1147
|
+
`cannot add command '${r}' as already have command '${n}'`
|
|
1148
|
+
);
|
|
1149
|
+
}
|
|
1150
|
+
this.commands.push(e);
|
|
1151
|
+
}
|
|
1152
|
+
/**
|
|
1153
|
+
* Add an option.
|
|
1154
|
+
*
|
|
1155
|
+
* @param {Option} option
|
|
1156
|
+
* @return {Command} `this` command for chaining
|
|
1157
|
+
*/
|
|
1158
|
+
addOption(e) {
|
|
1159
|
+
this._registerOption(e);
|
|
1160
|
+
let t = e.name(), i = e.attributeName();
|
|
1161
|
+
if (e.negate) {
|
|
1162
|
+
let r = e.long.replace(/^--no-/, "--");
|
|
1163
|
+
this._findOption(r) || this.setOptionValueWithSource(
|
|
1164
|
+
i,
|
|
1165
|
+
e.defaultValue === void 0 ? !0 : e.defaultValue,
|
|
1166
|
+
"default"
|
|
1167
|
+
);
|
|
1168
|
+
} else e.defaultValue !== void 0 && this.setOptionValueWithSource(i, e.defaultValue, "default");
|
|
1169
|
+
let n = /* @__PURE__ */ c((r, o, l) => {
|
|
1170
|
+
r == null && e.presetArg !== void 0 && (r = e.presetArg);
|
|
1171
|
+
let a = this.getOptionValue(i);
|
|
1172
|
+
r !== null && e.parseArg ? r = this._callParseArg(e, r, a, o) : r !== null && e.variadic && (r = e._concatValue(r, a)), r == null &&
|
|
1173
|
+
(e.negate ? r = !1 : e.isBoolean() || e.optional ? r = !0 : r = ""), this.setOptionValueWithSource(i, r, l);
|
|
1174
|
+
}, "handleOptionValue");
|
|
1175
|
+
return this.on("option:" + t, (r) => {
|
|
1176
|
+
let o = `error: option '${e.flags}' argument '${r}' is invalid.`;
|
|
1177
|
+
n(r, o, "cli");
|
|
1178
|
+
}), e.envVar && this.on("optionEnv:" + t, (r) => {
|
|
1179
|
+
let o = `error: option '${e.flags}' value '${r}' from env '${e.envVar}' is invalid.`;
|
|
1180
|
+
n(r, o, "env");
|
|
1181
|
+
}), this;
|
|
1182
|
+
}
|
|
1183
|
+
/**
|
|
1184
|
+
* Internal implementation shared by .option() and .requiredOption()
|
|
1185
|
+
*
|
|
1186
|
+
* @return {Command} `this` command for chaining
|
|
1187
|
+
* @private
|
|
1188
|
+
*/
|
|
1189
|
+
_optionEx(e, t, i, n, r) {
|
|
1190
|
+
if (typeof t == "object" && t instanceof ue)
|
|
1191
|
+
throw new Error(
|
|
1192
|
+
"To add an Option object use addOption() instead of option() or requiredOption()"
|
|
1193
|
+
);
|
|
1194
|
+
let o = this.createOption(t, i);
|
|
1195
|
+
if (o.makeOptionMandatory(!!e.mandatory), typeof n == "function")
|
|
1196
|
+
o.default(r).argParser(n);
|
|
1197
|
+
else if (n instanceof RegExp) {
|
|
1198
|
+
let l = n;
|
|
1199
|
+
n = /* @__PURE__ */ c((a, u) => {
|
|
1200
|
+
let d = l.exec(a);
|
|
1201
|
+
return d ? d[0] : u;
|
|
1202
|
+
}, "fn"), o.default(r).argParser(n);
|
|
1203
|
+
} else
|
|
1204
|
+
o.default(n);
|
|
1205
|
+
return this.addOption(o);
|
|
1206
|
+
}
|
|
1207
|
+
/**
|
|
1208
|
+
* Define option with `flags`, `description`, and optional argument parsing function or `defaultValue` or both.
|
|
1209
|
+
*
|
|
1210
|
+
* The `flags` string contains the short and/or long flags, separated by comma, a pipe or space. A required
|
|
1211
|
+
* option-argument is indicated by `<>` and an optional option-argument by `[]`.
|
|
1212
|
+
*
|
|
1213
|
+
* See the README for more details, and see also addOption() and requiredOption().
|
|
1214
|
+
*
|
|
1215
|
+
* @example
|
|
1216
|
+
* program
|
|
1217
|
+
* .option('-p, --pepper', 'add pepper')
|
|
1218
|
+
* .option('-p, --pizza-type <TYPE>', 'type of pizza') // required option-argument
|
|
1219
|
+
* .option('-c, --cheese [CHEESE]', 'add extra cheese', 'mozzarella') // optional option-argument with default
|
|
1220
|
+
* .option('-t, --tip <VALUE>', 'add tip to purchase cost', parseFloat) // custom parse function
|
|
1221
|
+
*
|
|
1222
|
+
* @param {string} flags
|
|
1223
|
+
* @param {string} [description]
|
|
1224
|
+
* @param {(Function|*)} [parseArg] - custom option processing function or default value
|
|
1225
|
+
* @param {*} [defaultValue]
|
|
1226
|
+
* @return {Command} `this` command for chaining
|
|
1227
|
+
*/
|
|
1228
|
+
option(e, t, i, n) {
|
|
1229
|
+
return this._optionEx({}, e, t, i, n);
|
|
1230
|
+
}
|
|
1231
|
+
/**
|
|
1232
|
+
* Add a required option which must have a value after parsing. This usually means
|
|
1233
|
+
* the option must be specified on the command line. (Otherwise the same as .option().)
|
|
1234
|
+
*
|
|
1235
|
+
* The `flags` string contains the short and/or long flags, separated by comma, a pipe or space.
|
|
1236
|
+
*
|
|
1237
|
+
* @param {string} flags
|
|
1238
|
+
* @param {string} [description]
|
|
1239
|
+
* @param {(Function|*)} [parseArg] - custom option processing function or default value
|
|
1240
|
+
* @param {*} [defaultValue]
|
|
1241
|
+
* @return {Command} `this` command for chaining
|
|
1242
|
+
*/
|
|
1243
|
+
requiredOption(e, t, i, n) {
|
|
1244
|
+
return this._optionEx(
|
|
1245
|
+
{ mandatory: !0 },
|
|
1246
|
+
e,
|
|
1247
|
+
t,
|
|
1248
|
+
i,
|
|
1249
|
+
n
|
|
1250
|
+
);
|
|
1251
|
+
}
|
|
1252
|
+
/**
|
|
1253
|
+
* Alter parsing of short flags with optional values.
|
|
1254
|
+
*
|
|
1255
|
+
* @example
|
|
1256
|
+
* // for `.option('-f,--flag [value]'):
|
|
1257
|
+
* program.combineFlagAndOptionalValue(true); // `-f80` is treated like `--flag=80`, this is the default behaviour
|
|
1258
|
+
* program.combineFlagAndOptionalValue(false) // `-fb` is treated like `-f -b`
|
|
1259
|
+
*
|
|
1260
|
+
* @param {boolean} [combine] - if `true` or omitted, an optional value can be specified directly after the flag.
|
|
1261
|
+
* @return {Command} `this` command for chaining
|
|
1262
|
+
*/
|
|
1263
|
+
combineFlagAndOptionalValue(e = !0) {
|
|
1264
|
+
return this._combineFlagAndOptionalValue = !!e, this;
|
|
1265
|
+
}
|
|
1266
|
+
/**
|
|
1267
|
+
* Allow unknown options on the command line.
|
|
1268
|
+
*
|
|
1269
|
+
* @param {boolean} [allowUnknown] - if `true` or omitted, no error will be thrown for unknown options.
|
|
1270
|
+
* @return {Command} `this` command for chaining
|
|
1271
|
+
*/
|
|
1272
|
+
allowUnknownOption(e = !0) {
|
|
1273
|
+
return this._allowUnknownOption = !!e, this;
|
|
1274
|
+
}
|
|
1275
|
+
/**
|
|
1276
|
+
* Allow excess command-arguments on the command line. Pass false to make excess arguments an error.
|
|
1277
|
+
*
|
|
1278
|
+
* @param {boolean} [allowExcess] - if `true` or omitted, no error will be thrown for excess arguments.
|
|
1279
|
+
* @return {Command} `this` command for chaining
|
|
1280
|
+
*/
|
|
1281
|
+
allowExcessArguments(e = !0) {
|
|
1282
|
+
return this._allowExcessArguments = !!e, this;
|
|
1283
|
+
}
|
|
1284
|
+
/**
|
|
1285
|
+
* Enable positional options. Positional means global options are specified before subcommands which lets
|
|
1286
|
+
* subcommands reuse the same option names, and also enables subcommands to turn on passThroughOptions.
|
|
1287
|
+
* The default behaviour is non-positional and global options may appear anywhere on the command line.
|
|
1288
|
+
*
|
|
1289
|
+
* @param {boolean} [positional]
|
|
1290
|
+
* @return {Command} `this` command for chaining
|
|
1291
|
+
*/
|
|
1292
|
+
enablePositionalOptions(e = !0) {
|
|
1293
|
+
return this._enablePositionalOptions = !!e, this;
|
|
1294
|
+
}
|
|
1295
|
+
/**
|
|
1296
|
+
* Pass through options that come after command-arguments rather than treat them as command-options,
|
|
1297
|
+
* so actual command-options come before command-arguments. Turning this on for a subcommand requires
|
|
1298
|
+
* positional options to have been enabled on the program (parent commands).
|
|
1299
|
+
* The default behaviour is non-positional and options may appear before or after command-arguments.
|
|
1300
|
+
*
|
|
1301
|
+
* @param {boolean} [passThrough] for unknown options.
|
|
1302
|
+
* @return {Command} `this` command for chaining
|
|
1303
|
+
*/
|
|
1304
|
+
passThroughOptions(e = !0) {
|
|
1305
|
+
return this._passThroughOptions = !!e, this._checkForBrokenPassThrough(), this;
|
|
1306
|
+
}
|
|
1307
|
+
/**
|
|
1308
|
+
* @private
|
|
1309
|
+
*/
|
|
1310
|
+
_checkForBrokenPassThrough() {
|
|
1311
|
+
if (this.parent && this._passThroughOptions && !this.parent._enablePositionalOptions)
|
|
1312
|
+
throw new Error(
|
|
1313
|
+
`passThroughOptions cannot be used for '${this._name}' without turning on enablePositionalOptions for parent command(s)`
|
|
1314
|
+
);
|
|
1315
|
+
}
|
|
1316
|
+
/**
|
|
1317
|
+
* Whether to store option values as properties on command object,
|
|
1318
|
+
* or store separately (specify false). In both cases the option values can be accessed using .opts().
|
|
1319
|
+
*
|
|
1320
|
+
* @param {boolean} [storeAsProperties=true]
|
|
1321
|
+
* @return {Command} `this` command for chaining
|
|
1322
|
+
*/
|
|
1323
|
+
storeOptionsAsProperties(e = !0) {
|
|
1324
|
+
if (this.options.length)
|
|
1325
|
+
throw new Error("call .storeOptionsAsProperties() before adding options");
|
|
1326
|
+
if (Object.keys(this._optionValues).length)
|
|
1327
|
+
throw new Error(
|
|
1328
|
+
"call .storeOptionsAsProperties() before setting option values"
|
|
1329
|
+
);
|
|
1330
|
+
return this._storeOptionsAsProperties = !!e, this;
|
|
1331
|
+
}
|
|
1332
|
+
/**
|
|
1333
|
+
* Retrieve option value.
|
|
1334
|
+
*
|
|
1335
|
+
* @param {string} key
|
|
1336
|
+
* @return {object} value
|
|
1337
|
+
*/
|
|
1338
|
+
getOptionValue(e) {
|
|
1339
|
+
return this._storeOptionsAsProperties ? this[e] : this._optionValues[e];
|
|
1340
|
+
}
|
|
1341
|
+
/**
|
|
1342
|
+
* Store option value.
|
|
1343
|
+
*
|
|
1344
|
+
* @param {string} key
|
|
1345
|
+
* @param {object} value
|
|
1346
|
+
* @return {Command} `this` command for chaining
|
|
1347
|
+
*/
|
|
1348
|
+
setOptionValue(e, t) {
|
|
1349
|
+
return this.setOptionValueWithSource(e, t, void 0);
|
|
1350
|
+
}
|
|
1351
|
+
/**
|
|
1352
|
+
* Store option value and where the value came from.
|
|
1353
|
+
*
|
|
1354
|
+
* @param {string} key
|
|
1355
|
+
* @param {object} value
|
|
1356
|
+
* @param {string} source - expected values are default/config/env/cli/implied
|
|
1357
|
+
* @return {Command} `this` command for chaining
|
|
1358
|
+
*/
|
|
1359
|
+
setOptionValueWithSource(e, t, i) {
|
|
1360
|
+
return this._storeOptionsAsProperties ? this[e] = t : this._optionValues[e] = t, this._optionValueSources[e] = i, this;
|
|
1361
|
+
}
|
|
1362
|
+
/**
|
|
1363
|
+
* Get source of option value.
|
|
1364
|
+
* Expected values are default | config | env | cli | implied
|
|
1365
|
+
*
|
|
1366
|
+
* @param {string} key
|
|
1367
|
+
* @return {string}
|
|
1368
|
+
*/
|
|
1369
|
+
getOptionValueSource(e) {
|
|
1370
|
+
return this._optionValueSources[e];
|
|
1371
|
+
}
|
|
1372
|
+
/**
|
|
1373
|
+
* Get source of option value. See also .optsWithGlobals().
|
|
1374
|
+
* Expected values are default | config | env | cli | implied
|
|
1375
|
+
*
|
|
1376
|
+
* @param {string} key
|
|
1377
|
+
* @return {string}
|
|
1378
|
+
*/
|
|
1379
|
+
getOptionValueSourceWithGlobals(e) {
|
|
1380
|
+
let t;
|
|
1381
|
+
return this._getCommandAndAncestors().forEach((i) => {
|
|
1382
|
+
i.getOptionValueSource(e) !== void 0 && (t = i.getOptionValueSource(e));
|
|
1383
|
+
}), t;
|
|
1384
|
+
}
|
|
1385
|
+
/**
|
|
1386
|
+
* Get user arguments from implied or explicit arguments.
|
|
1387
|
+
* Side-effects: set _scriptPath if args included script. Used for default program name, and subcommand searches.
|
|
1388
|
+
*
|
|
1389
|
+
* @private
|
|
1390
|
+
*/
|
|
1391
|
+
_prepareUserArgs(e, t) {
|
|
1392
|
+
if (e !== void 0 && !Array.isArray(e))
|
|
1393
|
+
throw new Error("first parameter to parse must be array or undefined");
|
|
1394
|
+
if (t = t || {}, e === void 0 && t.from === void 0) {
|
|
1395
|
+
p.versions?.electron && (t.from = "electron");
|
|
1396
|
+
let n = p.execArgv ?? [];
|
|
1397
|
+
(n.includes("-e") || n.includes("--eval") || n.includes("-p") || n.includes("--print")) && (t.from = "eval");
|
|
1398
|
+
}
|
|
1399
|
+
e === void 0 && (e = p.argv), this.rawArgs = e.slice();
|
|
1400
|
+
let i;
|
|
1401
|
+
switch (t.from) {
|
|
1402
|
+
case void 0:
|
|
1403
|
+
case "node":
|
|
1404
|
+
this._scriptPath = e[1], i = e.slice(2);
|
|
1405
|
+
break;
|
|
1406
|
+
case "electron":
|
|
1407
|
+
p.defaultApp ? (this._scriptPath = e[1], i = e.slice(2)) : i = e.slice(1);
|
|
1408
|
+
break;
|
|
1409
|
+
case "user":
|
|
1410
|
+
i = e.slice(0);
|
|
1411
|
+
break;
|
|
1412
|
+
case "eval":
|
|
1413
|
+
i = e.slice(1);
|
|
1414
|
+
break;
|
|
1415
|
+
default:
|
|
1416
|
+
throw new Error(
|
|
1417
|
+
`unexpected parse option { from: '${t.from}' }`
|
|
1418
|
+
);
|
|
1419
|
+
}
|
|
1420
|
+
return !this._name && this._scriptPath && this.nameFromFilename(this._scriptPath), this._name = this._name || "program", i;
|
|
1421
|
+
}
|
|
1422
|
+
/**
|
|
1423
|
+
* Parse `argv`, setting options and invoking commands when defined.
|
|
1424
|
+
*
|
|
1425
|
+
* Use parseAsync instead of parse if any of your action handlers are async.
|
|
1426
|
+
*
|
|
1427
|
+
* Call with no parameters to parse `process.argv`. Detects Electron and special node options like `node --eval`. Easy mode!
|
|
1428
|
+
*
|
|
1429
|
+
* Or call with an array of strings to parse, and optionally where the user arguments start by specifying where the arguments are `from`:
|
|
1430
|
+
* - `'node'`: default, `argv[0]` is the application and `argv[1]` is the script being run, with user arguments after that
|
|
1431
|
+
* - `'electron'`: `argv[0]` is the application and `argv[1]` varies depending on whether the electron application is packaged
|
|
1432
|
+
* - `'user'`: just user arguments
|
|
1433
|
+
*
|
|
1434
|
+
* @example
|
|
1435
|
+
* program.parse(); // parse process.argv and auto-detect electron and special node flags
|
|
1436
|
+
* program.parse(process.argv); // assume argv[0] is app and argv[1] is script
|
|
1437
|
+
* program.parse(my-args, { from: 'user' }); // just user supplied arguments, nothing special about argv[0]
|
|
1438
|
+
*
|
|
1439
|
+
* @param {string[]} [argv] - optional, defaults to process.argv
|
|
1440
|
+
* @param {object} [parseOptions] - optionally specify style of options with from: node/user/electron
|
|
1441
|
+
* @param {string} [parseOptions.from] - where the args are from: 'node', 'user', 'electron'
|
|
1442
|
+
* @return {Command} `this` command for chaining
|
|
1443
|
+
*/
|
|
1444
|
+
parse(e, t) {
|
|
1445
|
+
let i = this._prepareUserArgs(e, t);
|
|
1446
|
+
return this._parseCommand([], i), this;
|
|
1447
|
+
}
|
|
1448
|
+
/**
|
|
1449
|
+
* Parse `argv`, setting options and invoking commands when defined.
|
|
1450
|
+
*
|
|
1451
|
+
* Call with no parameters to parse `process.argv`. Detects Electron and special node options like `node --eval`. Easy mode!
|
|
1452
|
+
*
|
|
1453
|
+
* Or call with an array of strings to parse, and optionally where the user arguments start by specifying where the arguments are `from`:
|
|
1454
|
+
* - `'node'`: default, `argv[0]` is the application and `argv[1]` is the script being run, with user arguments after that
|
|
1455
|
+
* - `'electron'`: `argv[0]` is the application and `argv[1]` varies depending on whether the electron application is packaged
|
|
1456
|
+
* - `'user'`: just user arguments
|
|
1457
|
+
*
|
|
1458
|
+
* @example
|
|
1459
|
+
* await program.parseAsync(); // parse process.argv and auto-detect electron and special node flags
|
|
1460
|
+
* await program.parseAsync(process.argv); // assume argv[0] is app and argv[1] is script
|
|
1461
|
+
* await program.parseAsync(my-args, { from: 'user' }); // just user supplied arguments, nothing special about argv[0]
|
|
1462
|
+
*
|
|
1463
|
+
* @param {string[]} [argv]
|
|
1464
|
+
* @param {object} [parseOptions]
|
|
1465
|
+
* @param {string} parseOptions.from - where the args are from: 'node', 'user', 'electron'
|
|
1466
|
+
* @return {Promise}
|
|
1467
|
+
*/
|
|
1468
|
+
async parseAsync(e, t) {
|
|
1469
|
+
let i = this._prepareUserArgs(e, t);
|
|
1470
|
+
return await this._parseCommand([], i), this;
|
|
1471
|
+
}
|
|
1472
|
+
/**
|
|
1473
|
+
* Execute a sub-command executable.
|
|
1474
|
+
*
|
|
1475
|
+
* @private
|
|
1476
|
+
*/
|
|
1477
|
+
_executeSubCommand(e, t) {
|
|
1478
|
+
t = t.slice();
|
|
1479
|
+
let i = !1, n = [".js", ".ts", ".tsx", ".mjs", ".cjs"];
|
|
1480
|
+
function r(d, h) {
|
|
1481
|
+
let m = x.resolve(d, h);
|
|
1482
|
+
if (z.existsSync(m)) return m;
|
|
1483
|
+
if (n.includes(x.extname(h))) return;
|
|
1484
|
+
let _ = n.find(
|
|
1485
|
+
(f) => z.existsSync(`${m}${f}`)
|
|
1486
|
+
);
|
|
1487
|
+
if (_) return `${m}${_}`;
|
|
1488
|
+
}
|
|
1489
|
+
c(r, "findFile"), this._checkForMissingMandatoryOptions(), this._checkForConflictingOptions();
|
|
1490
|
+
let o = e._executableFile || `${this._name}-${e._name}`, l = this._executableDir || "";
|
|
1491
|
+
if (this._scriptPath) {
|
|
1492
|
+
let d;
|
|
1493
|
+
try {
|
|
1494
|
+
d = z.realpathSync(this._scriptPath);
|
|
1495
|
+
} catch {
|
|
1496
|
+
d = this._scriptPath;
|
|
1497
|
+
}
|
|
1498
|
+
l = x.resolve(
|
|
1499
|
+
x.dirname(d),
|
|
1500
|
+
l
|
|
1501
|
+
);
|
|
1502
|
+
}
|
|
1503
|
+
if (l) {
|
|
1504
|
+
let d = r(l, o);
|
|
1505
|
+
if (!d && !e._executableFile && this._scriptPath) {
|
|
1506
|
+
let h = x.basename(
|
|
1507
|
+
this._scriptPath,
|
|
1508
|
+
x.extname(this._scriptPath)
|
|
1509
|
+
);
|
|
1510
|
+
h !== this._name && (d = r(
|
|
1511
|
+
l,
|
|
1512
|
+
`${h}-${e._name}`
|
|
1513
|
+
));
|
|
1514
|
+
}
|
|
1515
|
+
o = d || o;
|
|
1516
|
+
}
|
|
1517
|
+
i = n.includes(x.extname(o));
|
|
1518
|
+
let a;
|
|
1519
|
+
p.platform !== "win32" ? i ? (t.unshift(o), t = he(p.execArgv).concat(t), a = Y.spawn(p.argv[0], t, { stdio: "inherit" })) : a = Y.spawn(
|
|
1520
|
+
o, t, { stdio: "inherit" }) : (t.unshift(o), t = he(p.execArgv).concat(t), a = Y.spawn(p.execPath, t, { stdio: "inherit" })), a.killed ||
|
|
1521
|
+
["SIGUSR1", "SIGUSR2", "SIGTERM", "SIGINT", "SIGHUP"].forEach((h) => {
|
|
1522
|
+
p.on(h, () => {
|
|
1523
|
+
a.killed === !1 && a.exitCode === null && a.kill(h);
|
|
1524
|
+
});
|
|
1525
|
+
});
|
|
1526
|
+
let u = this._exitCallback;
|
|
1527
|
+
a.on("close", (d) => {
|
|
1528
|
+
d = d ?? 1, u ? u(
|
|
1529
|
+
new K(
|
|
1530
|
+
d,
|
|
1531
|
+
"commander.executeSubCommandAsync",
|
|
1532
|
+
"(close)"
|
|
1533
|
+
)
|
|
1534
|
+
) : p.exit(d);
|
|
1535
|
+
}), a.on("error", (d) => {
|
|
1536
|
+
if (d.code === "ENOENT") {
|
|
1537
|
+
let h = l ? `searched for local subcommand relative to directory '${l}'` : "no directory for search for local subcommand, use .exe\
|
|
1538
|
+
cutableDir() to supply a custom directory", m = `'${o}' does not exist
|
|
1539
|
+
- if '${e._name}' is not meant to be an executable command, remove description parameter from '.command()' and use '.description()' instead\
|
|
1540
|
+
|
|
1541
|
+
- if the default executable name is not suitable, use the executableFile option to supply a custom name or path
|
|
1542
|
+
- ${h}`;
|
|
1543
|
+
throw new Error(m);
|
|
1544
|
+
} else if (d.code === "EACCES")
|
|
1545
|
+
throw new Error(`'${o}' not executable`);
|
|
1546
|
+
if (!u)
|
|
1547
|
+
p.exit(1);
|
|
1548
|
+
else {
|
|
1549
|
+
let h = new K(
|
|
1550
|
+
1,
|
|
1551
|
+
"commander.executeSubCommandAsync",
|
|
1552
|
+
"(error)"
|
|
1553
|
+
);
|
|
1554
|
+
h.nestedError = d, u(h);
|
|
1555
|
+
}
|
|
1556
|
+
}), this.runningCommand = a;
|
|
1557
|
+
}
|
|
1558
|
+
/**
|
|
1559
|
+
* @private
|
|
1560
|
+
*/
|
|
1561
|
+
_dispatchSubcommand(e, t, i) {
|
|
1562
|
+
let n = this._findCommand(e);
|
|
1563
|
+
n || this.help({ error: !0 });
|
|
1564
|
+
let r;
|
|
1565
|
+
return r = this._chainOrCallSubCommandHook(
|
|
1566
|
+
r,
|
|
1567
|
+
n,
|
|
1568
|
+
"preSubcommand"
|
|
1569
|
+
), r = this._chainOrCall(r, () => {
|
|
1570
|
+
if (n._executableHandler)
|
|
1571
|
+
this._executeSubCommand(n, t.concat(i));
|
|
1572
|
+
else
|
|
1573
|
+
return n._parseCommand(t, i);
|
|
1574
|
+
}), r;
|
|
1575
|
+
}
|
|
1576
|
+
/**
|
|
1577
|
+
* Invoke help directly if possible, or dispatch if necessary.
|
|
1578
|
+
* e.g. help foo
|
|
1579
|
+
*
|
|
1580
|
+
* @private
|
|
1581
|
+
*/
|
|
1582
|
+
_dispatchHelpCommand(e) {
|
|
1583
|
+
e || this.help();
|
|
1584
|
+
let t = this._findCommand(e);
|
|
1585
|
+
return t && !t._executableHandler && t.help(), this._dispatchSubcommand(
|
|
1586
|
+
e,
|
|
1587
|
+
[],
|
|
1588
|
+
[this._getHelpOption()?.long ?? this._getHelpOption()?.short ?? "--help"]
|
|
1589
|
+
);
|
|
1590
|
+
}
|
|
1591
|
+
/**
|
|
1592
|
+
* Check this.args against expected this.registeredArguments.
|
|
1593
|
+
*
|
|
1594
|
+
* @private
|
|
1595
|
+
*/
|
|
1596
|
+
_checkNumberOfArguments() {
|
|
1597
|
+
this.registeredArguments.forEach((e, t) => {
|
|
1598
|
+
e.required && this.args[t] == null && this.missingArgument(e.name());
|
|
1599
|
+
}), !(this.registeredArguments.length > 0 && this.registeredArguments[this.registeredArguments.length - 1].variadic) && this.args.length >
|
|
1600
|
+
this.registeredArguments.length && this._excessArguments(this.args);
|
|
1601
|
+
}
|
|
1602
|
+
/**
|
|
1603
|
+
* Process this.args using this.registeredArguments and save as this.processedArgs!
|
|
1604
|
+
*
|
|
1605
|
+
* @private
|
|
1606
|
+
*/
|
|
1607
|
+
_processArguments() {
|
|
1608
|
+
let e = /* @__PURE__ */ c((i, n, r) => {
|
|
1609
|
+
let o = n;
|
|
1610
|
+
if (n !== null && i.parseArg) {
|
|
1611
|
+
let l = `error: command-argument value '${n}' is invalid for argument '${i.name()}'.`;
|
|
1612
|
+
o = this._callParseArg(
|
|
1613
|
+
i,
|
|
1614
|
+
n,
|
|
1615
|
+
r,
|
|
1616
|
+
l
|
|
1617
|
+
);
|
|
1618
|
+
}
|
|
1619
|
+
return o;
|
|
1620
|
+
}, "myParseArg");
|
|
1621
|
+
this._checkNumberOfArguments();
|
|
1622
|
+
let t = [];
|
|
1623
|
+
this.registeredArguments.forEach((i, n) => {
|
|
1624
|
+
let r = i.defaultValue;
|
|
1625
|
+
i.variadic ? n < this.args.length ? (r = this.args.slice(n), i.parseArg && (r = r.reduce((o, l) => e(i, l, o), i.defaultValue))) : r ===
|
|
1626
|
+
void 0 && (r = []) : n < this.args.length && (r = this.args[n], i.parseArg && (r = e(i, r, i.defaultValue))), t[n] = r;
|
|
1627
|
+
}), this.processedArgs = t;
|
|
1628
|
+
}
|
|
1629
|
+
/**
|
|
1630
|
+
* Once we have a promise we chain, but call synchronously until then.
|
|
1631
|
+
*
|
|
1632
|
+
* @param {(Promise|undefined)} promise
|
|
1633
|
+
* @param {Function} fn
|
|
1634
|
+
* @return {(Promise|undefined)}
|
|
1635
|
+
* @private
|
|
1636
|
+
*/
|
|
1637
|
+
_chainOrCall(e, t) {
|
|
1638
|
+
return e && e.then && typeof e.then == "function" ? e.then(() => t()) : t();
|
|
1639
|
+
}
|
|
1640
|
+
/**
|
|
1641
|
+
*
|
|
1642
|
+
* @param {(Promise|undefined)} promise
|
|
1643
|
+
* @param {string} event
|
|
1644
|
+
* @return {(Promise|undefined)}
|
|
1645
|
+
* @private
|
|
1646
|
+
*/
|
|
1647
|
+
_chainOrCallHooks(e, t) {
|
|
1648
|
+
let i = e, n = [];
|
|
1649
|
+
return this._getCommandAndAncestors().reverse().filter((r) => r._lifeCycleHooks[t] !== void 0).forEach((r) => {
|
|
1650
|
+
r._lifeCycleHooks[t].forEach((o) => {
|
|
1651
|
+
n.push({ hookedCommand: r, callback: o });
|
|
1652
|
+
});
|
|
1653
|
+
}), t === "postAction" && n.reverse(), n.forEach((r) => {
|
|
1654
|
+
i = this._chainOrCall(i, () => r.callback(r.hookedCommand, this));
|
|
1655
|
+
}), i;
|
|
1656
|
+
}
|
|
1657
|
+
/**
|
|
1658
|
+
*
|
|
1659
|
+
* @param {(Promise|undefined)} promise
|
|
1660
|
+
* @param {Command} subCommand
|
|
1661
|
+
* @param {string} event
|
|
1662
|
+
* @return {(Promise|undefined)}
|
|
1663
|
+
* @private
|
|
1664
|
+
*/
|
|
1665
|
+
_chainOrCallSubCommandHook(e, t, i) {
|
|
1666
|
+
let n = e;
|
|
1667
|
+
return this._lifeCycleHooks[i] !== void 0 && this._lifeCycleHooks[i].forEach((r) => {
|
|
1668
|
+
n = this._chainOrCall(n, () => r(this, t));
|
|
1669
|
+
}), n;
|
|
1670
|
+
}
|
|
1671
|
+
/**
|
|
1672
|
+
* Process arguments in context of this command.
|
|
1673
|
+
* Returns action result, in case it is a promise.
|
|
1674
|
+
*
|
|
1675
|
+
* @private
|
|
1676
|
+
*/
|
|
1677
|
+
_parseCommand(e, t) {
|
|
1678
|
+
let i = this.parseOptions(t);
|
|
1679
|
+
if (this._parseOptionsEnv(), this._parseOptionsImplied(), e = e.concat(i.operands), t = i.unknown, this.args = e.concat(t), e && this.
|
|
1680
|
+
_findCommand(e[0]))
|
|
1681
|
+
return this._dispatchSubcommand(e[0], e.slice(1), t);
|
|
1682
|
+
if (this._getHelpCommand() && e[0] === this._getHelpCommand().name())
|
|
1683
|
+
return this._dispatchHelpCommand(e[1]);
|
|
1684
|
+
if (this._defaultCommandName)
|
|
1685
|
+
return this._outputHelpIfRequested(t), this._dispatchSubcommand(
|
|
1686
|
+
this._defaultCommandName,
|
|
1687
|
+
e,
|
|
1688
|
+
t
|
|
1689
|
+
);
|
|
1690
|
+
this.commands.length && this.args.length === 0 && !this._actionHandler && !this._defaultCommandName && this.help({ error: !0 }), this.
|
|
1691
|
+
_outputHelpIfRequested(i.unknown), this._checkForMissingMandatoryOptions(), this._checkForConflictingOptions();
|
|
1692
|
+
let n = /* @__PURE__ */ c(() => {
|
|
1693
|
+
i.unknown.length > 0 && this.unknownOption(i.unknown[0]);
|
|
1694
|
+
}, "checkForUnknownOptions"), r = `command:${this.name()}`;
|
|
1695
|
+
if (this._actionHandler) {
|
|
1696
|
+
n(), this._processArguments();
|
|
1697
|
+
let o;
|
|
1698
|
+
return o = this._chainOrCallHooks(o, "preAction"), o = this._chainOrCall(
|
|
1699
|
+
o,
|
|
1700
|
+
() => this._actionHandler(this.processedArgs)
|
|
1701
|
+
), this.parent && (o = this._chainOrCall(o, () => {
|
|
1702
|
+
this.parent.emit(r, e, t);
|
|
1703
|
+
})), o = this._chainOrCallHooks(o, "postAction"), o;
|
|
1704
|
+
}
|
|
1705
|
+
if (this.parent && this.parent.listenerCount(r))
|
|
1706
|
+
n(), this._processArguments(), this.parent.emit(r, e, t);
|
|
1707
|
+
else if (e.length) {
|
|
1708
|
+
if (this._findCommand("*"))
|
|
1709
|
+
return this._dispatchSubcommand("*", e, t);
|
|
1710
|
+
this.listenerCount("command:*") ? this.emit("command:*", e, t) : this.commands.length ? this.unknownCommand() : (n(), this._processArguments());
|
|
1711
|
+
} else this.commands.length ? (n(), this.help({ error: !0 })) : (n(), this._processArguments());
|
|
1712
|
+
}
|
|
1713
|
+
/**
|
|
1714
|
+
* Find matching command.
|
|
1715
|
+
*
|
|
1716
|
+
* @private
|
|
1717
|
+
* @return {Command | undefined}
|
|
1718
|
+
*/
|
|
1719
|
+
_findCommand(e) {
|
|
1720
|
+
if (e)
|
|
1721
|
+
return this.commands.find(
|
|
1722
|
+
(t) => t._name === e || t._aliases.includes(e)
|
|
1723
|
+
);
|
|
1724
|
+
}
|
|
1725
|
+
/**
|
|
1726
|
+
* Return an option matching `arg` if any.
|
|
1727
|
+
*
|
|
1728
|
+
* @param {string} arg
|
|
1729
|
+
* @return {Option}
|
|
1730
|
+
* @package
|
|
1731
|
+
*/
|
|
1732
|
+
_findOption(e) {
|
|
1733
|
+
return this.options.find((t) => t.is(e));
|
|
1734
|
+
}
|
|
1735
|
+
/**
|
|
1736
|
+
* Display an error message if a mandatory option does not have a value.
|
|
1737
|
+
* Called after checking for help flags in leaf subcommand.
|
|
1738
|
+
*
|
|
1739
|
+
* @private
|
|
1740
|
+
*/
|
|
1741
|
+
_checkForMissingMandatoryOptions() {
|
|
1742
|
+
this._getCommandAndAncestors().forEach((e) => {
|
|
1743
|
+
e.options.forEach((t) => {
|
|
1744
|
+
t.mandatory && e.getOptionValue(t.attributeName()) === void 0 && e.missingMandatoryOptionValue(t);
|
|
1745
|
+
});
|
|
1746
|
+
});
|
|
1747
|
+
}
|
|
1748
|
+
/**
|
|
1749
|
+
* Display an error message if conflicting options are used together in this.
|
|
1750
|
+
*
|
|
1751
|
+
* @private
|
|
1752
|
+
*/
|
|
1753
|
+
_checkForConflictingLocalOptions() {
|
|
1754
|
+
let e = this.options.filter((i) => {
|
|
1755
|
+
let n = i.attributeName();
|
|
1756
|
+
return this.getOptionValue(n) === void 0 ? !1 : this.getOptionValueSource(n) !== "default";
|
|
1757
|
+
});
|
|
1758
|
+
e.filter(
|
|
1759
|
+
(i) => i.conflictsWith.length > 0
|
|
1760
|
+
).forEach((i) => {
|
|
1761
|
+
let n = e.find(
|
|
1762
|
+
(r) => i.conflictsWith.includes(r.attributeName())
|
|
1763
|
+
);
|
|
1764
|
+
n && this._conflictingOption(i, n);
|
|
1765
|
+
});
|
|
1766
|
+
}
|
|
1767
|
+
/**
|
|
1768
|
+
* Display an error message if conflicting options are used together.
|
|
1769
|
+
* Called after checking for help flags in leaf subcommand.
|
|
1770
|
+
*
|
|
1771
|
+
* @private
|
|
1772
|
+
*/
|
|
1773
|
+
_checkForConflictingOptions() {
|
|
1774
|
+
this._getCommandAndAncestors().forEach((e) => {
|
|
1775
|
+
e._checkForConflictingLocalOptions();
|
|
1776
|
+
});
|
|
1777
|
+
}
|
|
1778
|
+
/**
|
|
1779
|
+
* Parse options from `argv` removing known options,
|
|
1780
|
+
* and return argv split into operands and unknown arguments.
|
|
1781
|
+
*
|
|
1782
|
+
* Examples:
|
|
1783
|
+
*
|
|
1784
|
+
* argv => operands, unknown
|
|
1785
|
+
* --known kkk op => [op], []
|
|
1786
|
+
* op --known kkk => [op], []
|
|
1787
|
+
* sub --unknown uuu op => [sub], [--unknown uuu op]
|
|
1788
|
+
* sub -- --unknown uuu op => [sub --unknown uuu op], []
|
|
1789
|
+
*
|
|
1790
|
+
* @param {string[]} argv
|
|
1791
|
+
* @return {{operands: string[], unknown: string[]}}
|
|
1792
|
+
*/
|
|
1793
|
+
parseOptions(e) {
|
|
1794
|
+
let t = [], i = [], n = t, r = e.slice();
|
|
1795
|
+
function o(a) {
|
|
1796
|
+
return a.length > 1 && a[0] === "-";
|
|
1797
|
+
}
|
|
1798
|
+
c(o, "maybeOption");
|
|
1799
|
+
let l = null;
|
|
1800
|
+
for (; r.length; ) {
|
|
1801
|
+
let a = r.shift();
|
|
1802
|
+
if (a === "--") {
|
|
1803
|
+
n === i && n.push(a), n.push(...r);
|
|
1804
|
+
break;
|
|
1805
|
+
}
|
|
1806
|
+
if (l && !o(a)) {
|
|
1807
|
+
this.emit(`option:${l.name()}`, a);
|
|
1808
|
+
continue;
|
|
1809
|
+
}
|
|
1810
|
+
if (l = null, o(a)) {
|
|
1811
|
+
let u = this._findOption(a);
|
|
1812
|
+
if (u) {
|
|
1813
|
+
if (u.required) {
|
|
1814
|
+
let d = r.shift();
|
|
1815
|
+
d === void 0 && this.optionMissingArgument(u), this.emit(`option:${u.name()}`, d);
|
|
1816
|
+
} else if (u.optional) {
|
|
1817
|
+
let d = null;
|
|
1818
|
+
r.length > 0 && !o(r[0]) && (d = r.shift()), this.emit(`option:${u.name()}`, d);
|
|
1819
|
+
} else
|
|
1820
|
+
this.emit(`option:${u.name()}`);
|
|
1821
|
+
l = u.variadic ? u : null;
|
|
1822
|
+
continue;
|
|
1823
|
+
}
|
|
1824
|
+
}
|
|
1825
|
+
if (a.length > 2 && a[0] === "-" && a[1] !== "-") {
|
|
1826
|
+
let u = this._findOption(`-${a[1]}`);
|
|
1827
|
+
if (u) {
|
|
1828
|
+
u.required || u.optional && this._combineFlagAndOptionalValue ? this.emit(`option:${u.name()}`, a.slice(2)) : (this.emit(`option\
|
|
1829
|
+
:${u.name()}`), r.unshift(`-${a.slice(2)}`));
|
|
1830
|
+
continue;
|
|
1831
|
+
}
|
|
1832
|
+
}
|
|
1833
|
+
if (/^--[^=]+=/.test(a)) {
|
|
1834
|
+
let u = a.indexOf("="), d = this._findOption(a.slice(0, u));
|
|
1835
|
+
if (d && (d.required || d.optional)) {
|
|
1836
|
+
this.emit(`option:${d.name()}`, a.slice(u + 1));
|
|
1837
|
+
continue;
|
|
1838
|
+
}
|
|
1839
|
+
}
|
|
1840
|
+
if (o(a) && (n = i), (this._enablePositionalOptions || this._passThroughOptions) && t.length === 0 && i.length === 0) {
|
|
1841
|
+
if (this._findCommand(a)) {
|
|
1842
|
+
t.push(a), r.length > 0 && i.push(...r);
|
|
1843
|
+
break;
|
|
1844
|
+
} else if (this._getHelpCommand() && a === this._getHelpCommand().name()) {
|
|
1845
|
+
t.push(a), r.length > 0 && t.push(...r);
|
|
1846
|
+
break;
|
|
1847
|
+
} else if (this._defaultCommandName) {
|
|
1848
|
+
i.push(a), r.length > 0 && i.push(...r);
|
|
1849
|
+
break;
|
|
1850
|
+
}
|
|
1851
|
+
}
|
|
1852
|
+
if (this._passThroughOptions) {
|
|
1853
|
+
n.push(a), r.length > 0 && n.push(...r);
|
|
1854
|
+
break;
|
|
1855
|
+
}
|
|
1856
|
+
n.push(a);
|
|
1857
|
+
}
|
|
1858
|
+
return { operands: t, unknown: i };
|
|
1859
|
+
}
|
|
1860
|
+
/**
|
|
1861
|
+
* Return an object containing local option values as key-value pairs.
|
|
1862
|
+
*
|
|
1863
|
+
* @return {object}
|
|
1864
|
+
*/
|
|
1865
|
+
opts() {
|
|
1866
|
+
if (this._storeOptionsAsProperties) {
|
|
1867
|
+
let e = {}, t = this.options.length;
|
|
1868
|
+
for (let i = 0; i < t; i++) {
|
|
1869
|
+
let n = this.options[i].attributeName();
|
|
1870
|
+
e[n] = n === this._versionOptionName ? this._version : this[n];
|
|
1871
|
+
}
|
|
1872
|
+
return e;
|
|
1873
|
+
}
|
|
1874
|
+
return this._optionValues;
|
|
1875
|
+
}
|
|
1876
|
+
/**
|
|
1877
|
+
* Return an object containing merged local and global option values as key-value pairs.
|
|
1878
|
+
*
|
|
1879
|
+
* @return {object}
|
|
1880
|
+
*/
|
|
1881
|
+
optsWithGlobals() {
|
|
1882
|
+
return this._getCommandAndAncestors().reduce(
|
|
1883
|
+
(e, t) => Object.assign(e, t.opts()),
|
|
1884
|
+
{}
|
|
1885
|
+
);
|
|
1886
|
+
}
|
|
1887
|
+
/**
|
|
1888
|
+
* Display error message and exit (or call exitOverride).
|
|
1889
|
+
*
|
|
1890
|
+
* @param {string} message
|
|
1891
|
+
* @param {object} [errorOptions]
|
|
1892
|
+
* @param {string} [errorOptions.code] - an id string representing the error
|
|
1893
|
+
* @param {number} [errorOptions.exitCode] - used with process.exit
|
|
1894
|
+
*/
|
|
1895
|
+
error(e, t) {
|
|
1896
|
+
this._outputConfiguration.outputError(
|
|
1897
|
+
`${e}
|
|
1898
|
+
`,
|
|
1899
|
+
this._outputConfiguration.writeErr
|
|
1900
|
+
), typeof this._showHelpAfterError == "string" ? this._outputConfiguration.writeErr(`${this._showHelpAfterError}
|
|
1901
|
+
`) : this._showHelpAfterError && (this._outputConfiguration.writeErr(`
|
|
1902
|
+
`), this.outputHelp({ error: !0 }));
|
|
1903
|
+
let i = t || {}, n = i.exitCode || 1, r = i.code || "commander.error";
|
|
1904
|
+
this._exit(n, r, e);
|
|
1905
|
+
}
|
|
1906
|
+
/**
|
|
1907
|
+
* Apply any option related environment variables, if option does
|
|
1908
|
+
* not have a value from cli or client code.
|
|
1909
|
+
*
|
|
1910
|
+
* @private
|
|
1911
|
+
*/
|
|
1912
|
+
_parseOptionsEnv() {
|
|
1913
|
+
this.options.forEach((e) => {
|
|
1914
|
+
if (e.envVar && e.envVar in p.env) {
|
|
1915
|
+
let t = e.attributeName();
|
|
1916
|
+
(this.getOptionValue(t) === void 0 || ["default", "config", "env"].includes(
|
|
1917
|
+
this.getOptionValueSource(t)
|
|
1918
|
+
)) && (e.required || e.optional ? this.emit(`optionEnv:${e.name()}`, p.env[e.envVar]) : this.emit(`optionEnv:${e.name()}`));
|
|
1919
|
+
}
|
|
1920
|
+
});
|
|
1921
|
+
}
|
|
1922
|
+
/**
|
|
1923
|
+
* Apply any implied option values, if option is undefined or default value.
|
|
1924
|
+
*
|
|
1925
|
+
* @private
|
|
1926
|
+
*/
|
|
1927
|
+
_parseOptionsImplied() {
|
|
1928
|
+
let e = new Ke(this.options), t = /* @__PURE__ */ c((i) => this.getOptionValue(i) !== void 0 && !["default", "implied"].includes(this.
|
|
1929
|
+
getOptionValueSource(i)), "hasCustomOptionValue");
|
|
1930
|
+
this.options.filter(
|
|
1931
|
+
(i) => i.implied !== void 0 && t(i.attributeName()) && e.valueFromOption(
|
|
1932
|
+
this.getOptionValue(i.attributeName()),
|
|
1933
|
+
i
|
|
1934
|
+
)
|
|
1935
|
+
).forEach((i) => {
|
|
1936
|
+
Object.keys(i.implied).filter((n) => !t(n)).forEach((n) => {
|
|
1937
|
+
this.setOptionValueWithSource(
|
|
1938
|
+
n,
|
|
1939
|
+
i.implied[n],
|
|
1940
|
+
"implied"
|
|
1941
|
+
);
|
|
1942
|
+
});
|
|
1943
|
+
});
|
|
1944
|
+
}
|
|
1945
|
+
/**
|
|
1946
|
+
* Argument `name` is missing.
|
|
1947
|
+
*
|
|
1948
|
+
* @param {string} name
|
|
1949
|
+
* @private
|
|
1950
|
+
*/
|
|
1951
|
+
missingArgument(e) {
|
|
1952
|
+
let t = `error: missing required argument '${e}'`;
|
|
1953
|
+
this.error(t, { code: "commander.missingArgument" });
|
|
1954
|
+
}
|
|
1955
|
+
/**
|
|
1956
|
+
* `Option` is missing an argument.
|
|
1957
|
+
*
|
|
1958
|
+
* @param {Option} option
|
|
1959
|
+
* @private
|
|
1960
|
+
*/
|
|
1961
|
+
optionMissingArgument(e) {
|
|
1962
|
+
let t = `error: option '${e.flags}' argument missing`;
|
|
1963
|
+
this.error(t, { code: "commander.optionMissingArgument" });
|
|
1964
|
+
}
|
|
1965
|
+
/**
|
|
1966
|
+
* `Option` does not have a value, and is a mandatory option.
|
|
1967
|
+
*
|
|
1968
|
+
* @param {Option} option
|
|
1969
|
+
* @private
|
|
1970
|
+
*/
|
|
1971
|
+
missingMandatoryOptionValue(e) {
|
|
1972
|
+
let t = `error: required option '${e.flags}' not specified`;
|
|
1973
|
+
this.error(t, { code: "commander.missingMandatoryOptionValue" });
|
|
1974
|
+
}
|
|
1975
|
+
/**
|
|
1976
|
+
* `Option` conflicts with another option.
|
|
1977
|
+
*
|
|
1978
|
+
* @param {Option} option
|
|
1979
|
+
* @param {Option} conflictingOption
|
|
1980
|
+
* @private
|
|
1981
|
+
*/
|
|
1982
|
+
_conflictingOption(e, t) {
|
|
1983
|
+
let i = /* @__PURE__ */ c((o) => {
|
|
1984
|
+
let l = o.attributeName(), a = this.getOptionValue(l), u = this.options.find(
|
|
1985
|
+
(h) => h.negate && l === h.attributeName()
|
|
1986
|
+
), d = this.options.find(
|
|
1987
|
+
(h) => !h.negate && l === h.attributeName()
|
|
1988
|
+
);
|
|
1989
|
+
return u && (u.presetArg === void 0 && a === !1 || u.presetArg !== void 0 && a === u.presetArg) ? u : d || o;
|
|
1990
|
+
}, "findBestOptionFromValue"), n = /* @__PURE__ */ c((o) => {
|
|
1991
|
+
let l = i(o), a = l.attributeName();
|
|
1992
|
+
return this.getOptionValueSource(a) === "env" ? `environment variable '${l.envVar}'` : `option '${l.flags}'`;
|
|
1993
|
+
}, "getErrorMessage"), r = `error: ${n(e)} cannot be used with ${n(t)}`;
|
|
1994
|
+
this.error(r, { code: "commander.conflictingOption" });
|
|
1995
|
+
}
|
|
1996
|
+
/**
|
|
1997
|
+
* Unknown option `flag`.
|
|
1998
|
+
*
|
|
1999
|
+
* @param {string} flag
|
|
2000
|
+
* @private
|
|
2001
|
+
*/
|
|
2002
|
+
unknownOption(e) {
|
|
2003
|
+
if (this._allowUnknownOption) return;
|
|
2004
|
+
let t = "";
|
|
2005
|
+
if (e.startsWith("--") && this._showSuggestionAfterError) {
|
|
2006
|
+
let n = [], r = this;
|
|
2007
|
+
do {
|
|
2008
|
+
let o = r.createHelp().visibleOptions(r).filter((l) => l.long).map((l) => l.long);
|
|
2009
|
+
n = n.concat(o), r = r.parent;
|
|
2010
|
+
} while (r && !r._enablePositionalOptions);
|
|
2011
|
+
t = de(e, n);
|
|
2012
|
+
}
|
|
2013
|
+
let i = `error: unknown option '${e}'${t}`;
|
|
2014
|
+
this.error(i, { code: "commander.unknownOption" });
|
|
2015
|
+
}
|
|
2016
|
+
/**
|
|
2017
|
+
* Excess arguments, more than expected.
|
|
2018
|
+
*
|
|
2019
|
+
* @param {string[]} receivedArgs
|
|
2020
|
+
* @private
|
|
2021
|
+
*/
|
|
2022
|
+
_excessArguments(e) {
|
|
2023
|
+
if (this._allowExcessArguments) return;
|
|
2024
|
+
let t = this.registeredArguments.length, i = t === 1 ? "" : "s", r = `error: too many arguments${this.parent ? ` for '${this.name()}'` :
|
|
2025
|
+
""}. Expected ${t} argument${i} but got ${e.length}.`;
|
|
2026
|
+
this.error(r, { code: "commander.excessArguments" });
|
|
2027
|
+
}
|
|
2028
|
+
/**
|
|
2029
|
+
* Unknown command.
|
|
2030
|
+
*
|
|
2031
|
+
* @private
|
|
2032
|
+
*/
|
|
2033
|
+
unknownCommand() {
|
|
2034
|
+
let e = this.args[0], t = "";
|
|
2035
|
+
if (this._showSuggestionAfterError) {
|
|
2036
|
+
let n = [];
|
|
2037
|
+
this.createHelp().visibleCommands(this).forEach((r) => {
|
|
2038
|
+
n.push(r.name()), r.alias() && n.push(r.alias());
|
|
2039
|
+
}), t = de(e, n);
|
|
2040
|
+
}
|
|
2041
|
+
let i = `error: unknown command '${e}'${t}`;
|
|
2042
|
+
this.error(i, { code: "commander.unknownCommand" });
|
|
2043
|
+
}
|
|
2044
|
+
/**
|
|
2045
|
+
* Get or set the program version.
|
|
2046
|
+
*
|
|
2047
|
+
* This method auto-registers the "-V, --version" option which will print the version number.
|
|
2048
|
+
*
|
|
2049
|
+
* You can optionally supply the flags and description to override the defaults.
|
|
2050
|
+
*
|
|
2051
|
+
* @param {string} [str]
|
|
2052
|
+
* @param {string} [flags]
|
|
2053
|
+
* @param {string} [description]
|
|
2054
|
+
* @return {(this | string | undefined)} `this` command for chaining, or version string if no arguments
|
|
2055
|
+
*/
|
|
2056
|
+
version(e, t, i) {
|
|
2057
|
+
if (e === void 0) return this._version;
|
|
2058
|
+
this._version = e, t = t || "-V, --version", i = i || "output the version number";
|
|
2059
|
+
let n = this.createOption(t, i);
|
|
2060
|
+
return this._versionOptionName = n.attributeName(), this._registerOption(n), this.on("option:" + n.name(), () => {
|
|
2061
|
+
this._outputConfiguration.writeOut(`${e}
|
|
2062
|
+
`), this._exit(0, "commander.version", e);
|
|
2063
|
+
}), this;
|
|
2064
|
+
}
|
|
2065
|
+
/**
|
|
2066
|
+
* Set the description.
|
|
2067
|
+
*
|
|
2068
|
+
* @param {string} [str]
|
|
2069
|
+
* @param {object} [argsDescription]
|
|
2070
|
+
* @return {(string|Command)}
|
|
2071
|
+
*/
|
|
2072
|
+
description(e, t) {
|
|
2073
|
+
return e === void 0 && t === void 0 ? this._description : (this._description = e, t && (this._argsDescription = t), this);
|
|
2074
|
+
}
|
|
2075
|
+
/**
|
|
2076
|
+
* Set the summary. Used when listed as subcommand of parent.
|
|
2077
|
+
*
|
|
2078
|
+
* @param {string} [str]
|
|
2079
|
+
* @return {(string|Command)}
|
|
2080
|
+
*/
|
|
2081
|
+
summary(e) {
|
|
2082
|
+
return e === void 0 ? this._summary : (this._summary = e, this);
|
|
2083
|
+
}
|
|
2084
|
+
/**
|
|
2085
|
+
* Set an alias for the command.
|
|
2086
|
+
*
|
|
2087
|
+
* You may call more than once to add multiple aliases. Only the first alias is shown in the auto-generated help.
|
|
2088
|
+
*
|
|
2089
|
+
* @param {string} [alias]
|
|
2090
|
+
* @return {(string|Command)}
|
|
2091
|
+
*/
|
|
2092
|
+
alias(e) {
|
|
2093
|
+
if (e === void 0) return this._aliases[0];
|
|
2094
|
+
let t = this;
|
|
2095
|
+
if (this.commands.length !== 0 && this.commands[this.commands.length - 1]._executableHandler && (t = this.commands[this.commands.length -
|
|
2096
|
+
1]), e === t._name)
|
|
2097
|
+
throw new Error("Command alias can't be the same as its name");
|
|
2098
|
+
let i = this.parent?._findCommand(e);
|
|
2099
|
+
if (i) {
|
|
2100
|
+
let n = [i.name()].concat(i.aliases()).join("|");
|
|
2101
|
+
throw new Error(
|
|
2102
|
+
`cannot add alias '${e}' to command '${this.name()}' as already have command '${n}'`
|
|
2103
|
+
);
|
|
2104
|
+
}
|
|
2105
|
+
return t._aliases.push(e), this;
|
|
2106
|
+
}
|
|
2107
|
+
/**
|
|
2108
|
+
* Set aliases for the command.
|
|
2109
|
+
*
|
|
2110
|
+
* Only the first alias is shown in the auto-generated help.
|
|
2111
|
+
*
|
|
2112
|
+
* @param {string[]} [aliases]
|
|
2113
|
+
* @return {(string[]|Command)}
|
|
2114
|
+
*/
|
|
2115
|
+
aliases(e) {
|
|
2116
|
+
return e === void 0 ? this._aliases : (e.forEach((t) => this.alias(t)), this);
|
|
2117
|
+
}
|
|
2118
|
+
/**
|
|
2119
|
+
* Set / get the command usage `str`.
|
|
2120
|
+
*
|
|
2121
|
+
* @param {string} [str]
|
|
2122
|
+
* @return {(string|Command)}
|
|
2123
|
+
*/
|
|
2124
|
+
usage(e) {
|
|
2125
|
+
if (e === void 0) {
|
|
2126
|
+
if (this._usage) return this._usage;
|
|
2127
|
+
let t = this.registeredArguments.map((i) => Ye(i));
|
|
2128
|
+
return [].concat(
|
|
2129
|
+
this.options.length || this._helpOption !== null ? "[options]" : [],
|
|
2130
|
+
this.commands.length ? "[command]" : [],
|
|
2131
|
+
this.registeredArguments.length ? t : []
|
|
2132
|
+
).join(" ");
|
|
2133
|
+
}
|
|
2134
|
+
return this._usage = e, this;
|
|
2135
|
+
}
|
|
2136
|
+
/**
|
|
2137
|
+
* Get or set the name of the command.
|
|
2138
|
+
*
|
|
2139
|
+
* @param {string} [str]
|
|
2140
|
+
* @return {(string|Command)}
|
|
2141
|
+
*/
|
|
2142
|
+
name(e) {
|
|
2143
|
+
return e === void 0 ? this._name : (this._name = e, this);
|
|
2144
|
+
}
|
|
2145
|
+
/**
|
|
2146
|
+
* Set the name of the command from script filename, such as process.argv[1],
|
|
2147
|
+
* or require.main.filename, or __filename.
|
|
2148
|
+
*
|
|
2149
|
+
* (Used internally and public although not documented in README.)
|
|
2150
|
+
*
|
|
2151
|
+
* @example
|
|
2152
|
+
* program.nameFromFilename(require.main.filename);
|
|
2153
|
+
*
|
|
2154
|
+
* @param {string} filename
|
|
2155
|
+
* @return {Command}
|
|
2156
|
+
*/
|
|
2157
|
+
nameFromFilename(e) {
|
|
2158
|
+
return this._name = x.basename(e, x.extname(e)), this;
|
|
2159
|
+
}
|
|
2160
|
+
/**
|
|
2161
|
+
* Get or set the directory for searching for executable subcommands of this command.
|
|
2162
|
+
*
|
|
2163
|
+
* @example
|
|
2164
|
+
* program.executableDir(__dirname);
|
|
2165
|
+
* // or
|
|
2166
|
+
* program.executableDir('subcommands');
|
|
2167
|
+
*
|
|
2168
|
+
* @param {string} [path]
|
|
2169
|
+
* @return {(string|null|Command)}
|
|
2170
|
+
*/
|
|
2171
|
+
executableDir(e) {
|
|
2172
|
+
return e === void 0 ? this._executableDir : (this._executableDir = e, this);
|
|
2173
|
+
}
|
|
2174
|
+
/**
|
|
2175
|
+
* Return program help documentation.
|
|
2176
|
+
*
|
|
2177
|
+
* @param {{ error: boolean }} [contextOptions] - pass {error:true} to wrap for stderr instead of stdout
|
|
2178
|
+
* @return {string}
|
|
2179
|
+
*/
|
|
2180
|
+
helpInformation(e) {
|
|
2181
|
+
let t = this.createHelp();
|
|
2182
|
+
return t.helpWidth === void 0 && (t.helpWidth = e && e.error ? this._outputConfiguration.getErrHelpWidth() : this._outputConfiguration.
|
|
2183
|
+
getOutHelpWidth()), t.formatHelp(this, t);
|
|
2184
|
+
}
|
|
2185
|
+
/**
|
|
2186
|
+
* @private
|
|
2187
|
+
*/
|
|
2188
|
+
_getHelpContext(e) {
|
|
2189
|
+
e = e || {};
|
|
2190
|
+
let t = { error: !!e.error }, i;
|
|
2191
|
+
return t.error ? i = /* @__PURE__ */ c((n) => this._outputConfiguration.writeErr(n), "write") : i = /* @__PURE__ */ c((n) => this._outputConfiguration.
|
|
2192
|
+
writeOut(n), "write"), t.write = e.write || i, t.command = this, t;
|
|
2193
|
+
}
|
|
2194
|
+
/**
|
|
2195
|
+
* Output help information for this command.
|
|
2196
|
+
*
|
|
2197
|
+
* Outputs built-in help, and custom text added using `.addHelpText()`.
|
|
2198
|
+
*
|
|
2199
|
+
* @param {{ error: boolean } | Function} [contextOptions] - pass {error:true} to write to stderr instead of stdout
|
|
2200
|
+
*/
|
|
2201
|
+
outputHelp(e) {
|
|
2202
|
+
let t;
|
|
2203
|
+
typeof e == "function" && (t = e, e = void 0);
|
|
2204
|
+
let i = this._getHelpContext(e);
|
|
2205
|
+
this._getCommandAndAncestors().reverse().forEach((r) => r.emit("beforeAllHelp", i)), this.emit("beforeHelp", i);
|
|
2206
|
+
let n = this.helpInformation(i);
|
|
2207
|
+
if (t && (n = t(n), typeof n != "string" && !Buffer.isBuffer(n)))
|
|
2208
|
+
throw new Error("outputHelp callback must return a string or a Buffer");
|
|
2209
|
+
i.write(n), this._getHelpOption()?.long && this.emit(this._getHelpOption().long), this.emit("afterHelp", i), this._getCommandAndAncestors().
|
|
2210
|
+
forEach(
|
|
2211
|
+
(r) => r.emit("afterAllHelp", i)
|
|
2212
|
+
);
|
|
2213
|
+
}
|
|
2214
|
+
/**
|
|
2215
|
+
* You can pass in flags and a description to customise the built-in help option.
|
|
2216
|
+
* Pass in false to disable the built-in help option.
|
|
2217
|
+
*
|
|
2218
|
+
* @example
|
|
2219
|
+
* program.helpOption('-?, --help' 'show help'); // customise
|
|
2220
|
+
* program.helpOption(false); // disable
|
|
2221
|
+
*
|
|
2222
|
+
* @param {(string | boolean)} flags
|
|
2223
|
+
* @param {string} [description]
|
|
2224
|
+
* @return {Command} `this` command for chaining
|
|
2225
|
+
*/
|
|
2226
|
+
helpOption(e, t) {
|
|
2227
|
+
return typeof e == "boolean" ? (e ? this._helpOption = this._helpOption ?? void 0 : this._helpOption = null, this) : (e = e ?? "-h, --\
|
|
2228
|
+
help", t = t ?? "display help for command", this._helpOption = this.createOption(e, t), this);
|
|
2229
|
+
}
|
|
2230
|
+
/**
|
|
2231
|
+
* Lazy create help option.
|
|
2232
|
+
* Returns null if has been disabled with .helpOption(false).
|
|
2233
|
+
*
|
|
2234
|
+
* @returns {(Option | null)} the help option
|
|
2235
|
+
* @package
|
|
2236
|
+
*/
|
|
2237
|
+
_getHelpOption() {
|
|
2238
|
+
return this._helpOption === void 0 && this.helpOption(void 0, void 0), this._helpOption;
|
|
2239
|
+
}
|
|
2240
|
+
/**
|
|
2241
|
+
* Supply your own option to use for the built-in help option.
|
|
2242
|
+
* This is an alternative to using helpOption() to customise the flags and description etc.
|
|
2243
|
+
*
|
|
2244
|
+
* @param {Option} option
|
|
2245
|
+
* @return {Command} `this` command for chaining
|
|
2246
|
+
*/
|
|
2247
|
+
addHelpOption(e) {
|
|
2248
|
+
return this._helpOption = e, this;
|
|
2249
|
+
}
|
|
2250
|
+
/**
|
|
2251
|
+
* Output help information and exit.
|
|
2252
|
+
*
|
|
2253
|
+
* Outputs built-in help, and custom text added using `.addHelpText()`.
|
|
2254
|
+
*
|
|
2255
|
+
* @param {{ error: boolean }} [contextOptions] - pass {error:true} to write to stderr instead of stdout
|
|
2256
|
+
*/
|
|
2257
|
+
help(e) {
|
|
2258
|
+
this.outputHelp(e);
|
|
2259
|
+
let t = p.exitCode || 0;
|
|
2260
|
+
t === 0 && e && typeof e != "function" && e.error && (t = 1), this._exit(t, "commander.help", "(outputHelp)");
|
|
2261
|
+
}
|
|
2262
|
+
/**
|
|
2263
|
+
* Add additional text to be displayed with the built-in help.
|
|
2264
|
+
*
|
|
2265
|
+
* Position is 'before' or 'after' to affect just this command,
|
|
2266
|
+
* and 'beforeAll' or 'afterAll' to affect this command and all its subcommands.
|
|
2267
|
+
*
|
|
2268
|
+
* @param {string} position - before or after built-in help
|
|
2269
|
+
* @param {(string | Function)} text - string to add, or a function returning a string
|
|
2270
|
+
* @return {Command} `this` command for chaining
|
|
2271
|
+
*/
|
|
2272
|
+
addHelpText(e, t) {
|
|
2273
|
+
let i = ["beforeAll", "before", "after", "afterAll"];
|
|
2274
|
+
if (!i.includes(e))
|
|
2275
|
+
throw new Error(`Unexpected value for position to addHelpText.
|
|
2276
|
+
Expecting one of '${i.join("', '")}'`);
|
|
2277
|
+
let n = `${e}Help`;
|
|
2278
|
+
return this.on(n, (r) => {
|
|
2279
|
+
let o;
|
|
2280
|
+
typeof t == "function" ? o = t({ error: r.error, command: r.command }) : o = t, o && r.write(`${o}
|
|
2281
|
+
`);
|
|
2282
|
+
}), this;
|
|
2283
|
+
}
|
|
2284
|
+
/**
|
|
2285
|
+
* Output help information if help flags specified
|
|
2286
|
+
*
|
|
2287
|
+
* @param {Array} args - array of options to search for help flags
|
|
2288
|
+
* @private
|
|
2289
|
+
*/
|
|
2290
|
+
_outputHelpIfRequested(e) {
|
|
2291
|
+
let t = this._getHelpOption();
|
|
2292
|
+
t && e.find((n) => t.is(n)) && (this.outputHelp(), this._exit(0, "commander.helpDisplayed", "(outputHelp)"));
|
|
2293
|
+
}
|
|
2294
|
+
};
|
|
2295
|
+
function he(s) {
|
|
2296
|
+
return s.map((e) => {
|
|
2297
|
+
if (!e.startsWith("--inspect"))
|
|
2298
|
+
return e;
|
|
2299
|
+
let t, i = "127.0.0.1", n = "9229", r;
|
|
2300
|
+
return (r = e.match(/^(--inspect(-brk)?)$/)) !== null ? t = r[1] : (r = e.match(/^(--inspect(-brk|-port)?)=([^:]+)$/)) !== null ? (t =
|
|
2301
|
+
r[1], /^\d+$/.test(r[3]) ? n = r[3] : i = r[3]) : (r = e.match(/^(--inspect(-brk|-port)?)=([^:]+):(\d+)$/)) !== null && (t = r[1], i =
|
|
2302
|
+
r[3], n = r[4]), t && n !== "0" ? `${t}=${i}:${parseInt(n) + 1}` : e;
|
|
2303
|
+
});
|
|
2304
|
+
}
|
|
2305
|
+
c(he, "incrementNodeInspectorPort");
|
|
2306
|
+
pe.Command = Q;
|
|
2307
|
+
});
|
|
2308
|
+
|
|
2309
|
+
// ../node_modules/commander/index.js
|
|
2310
|
+
var _e = b((g) => {
|
|
2311
|
+
var { Argument: fe } = H(), { Command: X } = me(), { CommanderError: Qe, InvalidArgumentError: ge } = k(), { Help: Xe } = W(), { Option: be } = J();
|
|
2312
|
+
g.program = new X();
|
|
2313
|
+
g.createCommand = (s) => new X(s);
|
|
2314
|
+
g.createOption = (s, e) => new be(s, e);
|
|
2315
|
+
g.createArgument = (s, e) => new fe(s, e);
|
|
2316
|
+
g.Command = X;
|
|
2317
|
+
g.Option = be;
|
|
2318
|
+
g.Argument = fe;
|
|
2319
|
+
g.Help = Xe;
|
|
2320
|
+
g.CommanderError = Qe;
|
|
2321
|
+
g.InvalidArgumentError = ge;
|
|
2322
|
+
g.InvalidOptionArgumentError = ge;
|
|
2323
|
+
});
|
|
2324
|
+
|
|
2325
|
+
// ../node_modules/walk-up-path/dist/cjs/index.js
|
|
2326
|
+
var ye = b((D) => {
|
|
2327
|
+
"use strict";
|
|
2328
|
+
Object.defineProperty(D, "__esModule", { value: !0 });
|
|
2329
|
+
D.walkUp = void 0;
|
|
2330
|
+
var xe = C("path"), Ze = /* @__PURE__ */ c(function* (s) {
|
|
2331
|
+
for (s = (0, xe.resolve)(s); s; ) {
|
|
2332
|
+
yield s;
|
|
2333
|
+
let e = (0, xe.dirname)(s);
|
|
2334
|
+
if (e === s)
|
|
2335
|
+
break;
|
|
2336
|
+
s = e;
|
|
2337
|
+
}
|
|
2338
|
+
}, "walkUp");
|
|
2339
|
+
D.walkUp = Ze;
|
|
2340
|
+
});
|
|
2341
|
+
|
|
2342
|
+
// ../node_modules/picocolors/picocolors.js
|
|
2343
|
+
var ke = b((zt, te) => {
|
|
2344
|
+
var q = process || {}, we = q.argv || [], P = q.env || {}, st = !(P.NO_COLOR || we.includes("--no-color")) && (!!P.FORCE_COLOR || we.includes(
|
|
2345
|
+
"--color") || q.platform === "win32" || (q.stdout || {}).isTTY && P.TERM !== "dumb" || !!P.CI), ot = /* @__PURE__ */ c((s, e, t = s) => (i) => {
|
|
2346
|
+
let n = "" + i, r = n.indexOf(e, s.length);
|
|
2347
|
+
return ~r ? s + at(n, e, t, r) + e : s + n + e;
|
|
2348
|
+
}, "formatter"), at = /* @__PURE__ */ c((s, e, t, i) => {
|
|
2349
|
+
let n = "", r = 0;
|
|
2350
|
+
do
|
|
2351
|
+
n += s.substring(r, i) + t, r = i + e.length, i = s.indexOf(e, r);
|
|
2352
|
+
while (~i);
|
|
2353
|
+
return n + s.substring(r);
|
|
2354
|
+
}, "replaceClose"), Ce = /* @__PURE__ */ c((s = st) => {
|
|
2355
|
+
let e = s ? ot : () => String;
|
|
2356
|
+
return {
|
|
2357
|
+
isColorSupported: s,
|
|
2358
|
+
reset: e("\x1B[0m", "\x1B[0m"),
|
|
2359
|
+
bold: e("\x1B[1m", "\x1B[22m", "\x1B[22m\x1B[1m"),
|
|
2360
|
+
dim: e("\x1B[2m", "\x1B[22m", "\x1B[22m\x1B[2m"),
|
|
2361
|
+
italic: e("\x1B[3m", "\x1B[23m"),
|
|
2362
|
+
underline: e("\x1B[4m", "\x1B[24m"),
|
|
2363
|
+
inverse: e("\x1B[7m", "\x1B[27m"),
|
|
2364
|
+
hidden: e("\x1B[8m", "\x1B[28m"),
|
|
2365
|
+
strikethrough: e("\x1B[9m", "\x1B[29m"),
|
|
2366
|
+
black: e("\x1B[30m", "\x1B[39m"),
|
|
2367
|
+
red: e("\x1B[31m", "\x1B[39m"),
|
|
2368
|
+
green: e("\x1B[32m", "\x1B[39m"),
|
|
2369
|
+
yellow: e("\x1B[33m", "\x1B[39m"),
|
|
2370
|
+
blue: e("\x1B[34m", "\x1B[39m"),
|
|
2371
|
+
magenta: e("\x1B[35m", "\x1B[39m"),
|
|
2372
|
+
cyan: e("\x1B[36m", "\x1B[39m"),
|
|
2373
|
+
white: e("\x1B[37m", "\x1B[39m"),
|
|
2374
|
+
gray: e("\x1B[90m", "\x1B[39m"),
|
|
2375
|
+
bgBlack: e("\x1B[40m", "\x1B[49m"),
|
|
2376
|
+
bgRed: e("\x1B[41m", "\x1B[49m"),
|
|
2377
|
+
bgGreen: e("\x1B[42m", "\x1B[49m"),
|
|
2378
|
+
bgYellow: e("\x1B[43m", "\x1B[49m"),
|
|
2379
|
+
bgBlue: e("\x1B[44m", "\x1B[49m"),
|
|
2380
|
+
bgMagenta: e("\x1B[45m", "\x1B[49m"),
|
|
2381
|
+
bgCyan: e("\x1B[46m", "\x1B[49m"),
|
|
2382
|
+
bgWhite: e("\x1B[47m", "\x1B[49m"),
|
|
2383
|
+
blackBright: e("\x1B[90m", "\x1B[39m"),
|
|
2384
|
+
redBright: e("\x1B[91m", "\x1B[39m"),
|
|
2385
|
+
greenBright: e("\x1B[92m", "\x1B[39m"),
|
|
2386
|
+
yellowBright: e("\x1B[93m", "\x1B[39m"),
|
|
2387
|
+
blueBright: e("\x1B[94m", "\x1B[39m"),
|
|
2388
|
+
magentaBright: e("\x1B[95m", "\x1B[39m"),
|
|
2389
|
+
cyanBright: e("\x1B[96m", "\x1B[39m"),
|
|
2390
|
+
whiteBright: e("\x1B[97m", "\x1B[39m"),
|
|
2391
|
+
bgBlackBright: e("\x1B[100m", "\x1B[49m"),
|
|
2392
|
+
bgRedBright: e("\x1B[101m", "\x1B[49m"),
|
|
2393
|
+
bgGreenBright: e("\x1B[102m", "\x1B[49m"),
|
|
2394
|
+
bgYellowBright: e("\x1B[103m", "\x1B[49m"),
|
|
2395
|
+
bgBlueBright: e("\x1B[104m", "\x1B[49m"),
|
|
2396
|
+
bgMagentaBright: e("\x1B[105m", "\x1B[49m"),
|
|
2397
|
+
bgCyanBright: e("\x1B[106m", "\x1B[49m"),
|
|
2398
|
+
bgWhiteBright: e("\x1B[107m", "\x1B[49m")
|
|
2399
|
+
};
|
|
2400
|
+
}, "createColors");
|
|
2401
|
+
te.exports = Ce();
|
|
2402
|
+
te.exports.createColors = Ce;
|
|
2403
|
+
});
|
|
2404
|
+
|
|
2405
|
+
// ../node_modules/ts-dedent/dist/index.js
|
|
2406
|
+
var $e = b((A) => {
|
|
2407
|
+
"use strict";
|
|
2408
|
+
Object.defineProperty(A, "__esModule", { value: !0 });
|
|
2409
|
+
A.dedent = void 0;
|
|
2410
|
+
function Se(s) {
|
|
2411
|
+
for (var e = [], t = 1; t < arguments.length; t++)
|
|
2412
|
+
e[t - 1] = arguments[t];
|
|
2413
|
+
var i = Array.from(typeof s == "string" ? [s] : s);
|
|
2414
|
+
i[i.length - 1] = i[i.length - 1].replace(/\r?\n([\t ]*)$/, "");
|
|
2415
|
+
var n = i.reduce(function(l, a) {
|
|
2416
|
+
var u = a.match(/\n([\t ]+|(?!\s).)/g);
|
|
2417
|
+
return u ? l.concat(u.map(function(d) {
|
|
2418
|
+
var h, m;
|
|
2419
|
+
return (m = (h = d.match(/[\t ]/g)) === null || h === void 0 ? void 0 : h.length) !== null && m !== void 0 ? m : 0;
|
|
2420
|
+
})) : l;
|
|
2421
|
+
}, []);
|
|
2422
|
+
if (n.length) {
|
|
2423
|
+
var r = new RegExp(`
|
|
2424
|
+
[ ]{` + Math.min.apply(Math, n) + "}", "g");
|
|
2425
|
+
i = i.map(function(l) {
|
|
2426
|
+
return l.replace(r, `
|
|
2427
|
+
`);
|
|
2428
|
+
});
|
|
2429
|
+
}
|
|
2430
|
+
i[0] = i[0].replace(/^\r?\n/, "");
|
|
2431
|
+
var o = i[0];
|
|
2432
|
+
return e.forEach(function(l, a) {
|
|
2433
|
+
var u = o.match(/(?:^|\n)( *)$/), d = u ? u[1] : "", h = l;
|
|
2434
|
+
typeof l == "string" && l.includes(`
|
|
2435
|
+
`) && (h = String(l).split(`
|
|
2436
|
+
`).map(function(m, _) {
|
|
2437
|
+
return _ === 0 ? m : "" + d + m;
|
|
2438
|
+
}).join(`
|
|
2439
|
+
`)), o += h + i[a + 1];
|
|
2440
|
+
}), o;
|
|
2441
|
+
}
|
|
2442
|
+
c(Se, "dedent");
|
|
2443
|
+
A.dedent = Se;
|
|
2444
|
+
A.default = Se;
|
|
2445
|
+
});
|
|
2446
|
+
|
|
2447
|
+
// src/cli/bin/index.ts
|
|
2448
|
+
var E = $(_e(), 1);
|
|
2449
|
+
import { getEnvConfig as re, parseList as vt, versions as Ot } from "storybook/internal/common";
|
|
2450
|
+
import { logger as se } from "storybook/internal/node-logger";
|
|
2451
|
+
import { addToGlobalContext as wt } from "storybook/internal/telemetry";
|
|
2452
|
+
|
|
2453
|
+
// ../node_modules/fd-package-json/dist/esm/main.js
|
|
2454
|
+
var ve = $(ye(), 1);
|
|
2455
|
+
import { resolve as et } from "node:path";
|
|
2456
|
+
import { stat as tt, readFile as it } from "node:fs/promises";
|
|
2457
|
+
import { statSync as Wt, readFileSync as Rt } from "node:fs";
|
|
2458
|
+
async function nt(s) {
|
|
2459
|
+
try {
|
|
2460
|
+
return (await tt(s)).isFile();
|
|
2461
|
+
} catch {
|
|
2462
|
+
return !1;
|
|
2463
|
+
}
|
|
2464
|
+
}
|
|
2465
|
+
c(nt, "fileExists");
|
|
2466
|
+
async function rt(s) {
|
|
2467
|
+
for (let e of (0, ve.walkUp)(s)) {
|
|
2468
|
+
let t = et(e, "package.json");
|
|
2469
|
+
if (await nt(t))
|
|
2470
|
+
return t;
|
|
2471
|
+
}
|
|
2472
|
+
return null;
|
|
2473
|
+
}
|
|
2474
|
+
c(rt, "findPackagePath");
|
|
2475
|
+
async function v(s) {
|
|
2476
|
+
let e = await rt(s);
|
|
2477
|
+
if (!e)
|
|
2478
|
+
return null;
|
|
2479
|
+
try {
|
|
2480
|
+
let t = await it(e, { encoding: "utf8" });
|
|
2481
|
+
return JSON.parse(t);
|
|
2482
|
+
} catch {
|
|
2483
|
+
return null;
|
|
2484
|
+
}
|
|
2485
|
+
}
|
|
2486
|
+
c(v, "findPackage");
|
|
2487
|
+
|
|
2488
|
+
// node_modules/leven/index.js
|
|
2489
|
+
var Z = [], Oe = [];
|
|
2490
|
+
function ee(s, e) {
|
|
2491
|
+
if (s === e)
|
|
2492
|
+
return 0;
|
|
2493
|
+
let t = s;
|
|
2494
|
+
s.length > e.length && (s = e, e = t);
|
|
2495
|
+
let i = s.length, n = e.length;
|
|
2496
|
+
for (; i > 0 && s.charCodeAt(~-i) === e.charCodeAt(~-n); )
|
|
2497
|
+
i--, n--;
|
|
2498
|
+
let r = 0;
|
|
2499
|
+
for (; r < i && s.charCodeAt(r) === e.charCodeAt(r); )
|
|
2500
|
+
r++;
|
|
2501
|
+
if (i -= r, n -= r, i === 0)
|
|
2502
|
+
return n;
|
|
2503
|
+
let o, l, a, u, d = 0, h = 0;
|
|
2504
|
+
for (; d < i; )
|
|
2505
|
+
Oe[d] = s.charCodeAt(r + d), Z[d] = ++d;
|
|
2506
|
+
for (; h < n; )
|
|
2507
|
+
for (o = e.charCodeAt(r + h), a = h++, l = h, d = 0; d < i; d++)
|
|
2508
|
+
u = o === Oe[d] ? a : a + 1, a = Z[d], l = Z[d] = a > l ? u > l ? l + 1 : u : u > a ? a + 1 : u;
|
|
2509
|
+
return l;
|
|
2510
|
+
}
|
|
2511
|
+
c(ee, "leven");
|
|
2512
|
+
|
|
2513
|
+
// src/cli/bin/index.ts
|
|
2514
|
+
var j = $(ke(), 1);
|
|
2515
|
+
|
|
2516
|
+
// ../node_modules/tiny-invariant/dist/esm/tiny-invariant.js
|
|
2517
|
+
var lt = process.env.NODE_ENV === "production", ie = "Invariant failed";
|
|
2518
|
+
function O(s, e) {
|
|
2519
|
+
if (!s) {
|
|
2520
|
+
if (lt)
|
|
2521
|
+
throw new Error(ie);
|
|
2522
|
+
var t = typeof e == "function" ? e() : e, i = t ? "".concat(ie, ": ").concat(t) : ie;
|
|
2523
|
+
throw new Error(i);
|
|
2524
|
+
}
|
|
2525
|
+
}
|
|
2526
|
+
c(O, "invariant");
|
|
2527
|
+
|
|
2528
|
+
// package.json
|
|
2529
|
+
var Ae = "9.0.0-alpha.3";
|
|
2530
|
+
|
|
2531
|
+
// src/cli/build.ts
|
|
2532
|
+
import { cache as ut } from "storybook/internal/common";
|
|
2533
|
+
import { buildStaticStandalone as dt, withTelemetry as ht } from "storybook/internal/core-server";
|
|
2534
|
+
var Ee = /* @__PURE__ */ c(async (s) => {
|
|
2535
|
+
let e = await v(__dirname);
|
|
2536
|
+
O(e, "Failed to find the closest package.json file.");
|
|
2537
|
+
let t = {
|
|
2538
|
+
...s,
|
|
2539
|
+
configDir: s.configDir || "./.storybook",
|
|
2540
|
+
outputDir: s.outputDir || "./storybook-static",
|
|
2541
|
+
ignorePreview: !!s.previewUrl && !s.forceBuildPreview,
|
|
2542
|
+
configType: "PRODUCTION",
|
|
2543
|
+
cache: ut,
|
|
2544
|
+
packageJson: e
|
|
2545
|
+
};
|
|
2546
|
+
await ht(
|
|
2547
|
+
"build",
|
|
2548
|
+
{ cliOptions: s, presetOptions: t },
|
|
2549
|
+
() => dt(t)
|
|
2550
|
+
);
|
|
2551
|
+
}, "build");
|
|
2552
|
+
|
|
2553
|
+
// src/cli/buildIndex.ts
|
|
2554
|
+
import { cache as pt } from "storybook/internal/common";
|
|
2555
|
+
import { buildIndexStandalone as mt, withTelemetry as ft } from "storybook/internal/core-server";
|
|
2556
|
+
var je = /* @__PURE__ */ c(async (s) => {
|
|
2557
|
+
let e = {
|
|
2558
|
+
...s,
|
|
2559
|
+
configDir: s.configDir || ".storybook",
|
|
2560
|
+
outputFile: s.outputFile || "index.json",
|
|
2561
|
+
ignorePreview: !0,
|
|
2562
|
+
configType: "PRODUCTION",
|
|
2563
|
+
cache: pt,
|
|
2564
|
+
packageJson: s.packageJson
|
|
2565
|
+
}, t = {
|
|
2566
|
+
...e,
|
|
2567
|
+
corePresets: [],
|
|
2568
|
+
overridePresets: []
|
|
2569
|
+
};
|
|
2570
|
+
await ft("index", { cliOptions: s, presetOptions: t }, () => mt(e));
|
|
2571
|
+
}, "buildIndex");
|
|
2572
|
+
|
|
2573
|
+
// src/cli/dev.ts
|
|
2574
|
+
import { cache as gt } from "storybook/internal/common";
|
|
2575
|
+
import { buildDevStandalone as bt, withTelemetry as _t } from "storybook/internal/core-server";
|
|
2576
|
+
import { logger as w, instance as xt } from "storybook/internal/node-logger";
|
|
2577
|
+
var ne = $($e(), 1);
|
|
2578
|
+
function yt(s) {
|
|
2579
|
+
xt.heading = "", s instanceof Error ? s.error ? w.error(s.error) : s.stats && s.stats.compilation.errors ? s.stats.compilation.errors.forEach(
|
|
2580
|
+
(e) => w.plain(e)) : w.error(s) : s.compilation?.errors && s.compilation.errors.forEach((e) => w.plain(e)), w.line(), w.warn(
|
|
2581
|
+
s.close ? ne.dedent`
|
|
2582
|
+
FATAL broken build!, will close the process,
|
|
2583
|
+
Fix the error below and restart storybook.
|
|
2584
|
+
` : ne.dedent`
|
|
2585
|
+
Broken build, fix the error above.
|
|
2586
|
+
You may need to refresh the browser.
|
|
2587
|
+
`
|
|
2588
|
+
), w.line();
|
|
2589
|
+
}
|
|
2590
|
+
c(yt, "printError");
|
|
2591
|
+
var Ve = /* @__PURE__ */ c(async (s) => {
|
|
2592
|
+
let { env: e } = process;
|
|
2593
|
+
e.NODE_ENV = e.NODE_ENV || "development";
|
|
2594
|
+
let t = await v(__dirname);
|
|
2595
|
+
O(t, "Failed to find the closest package.json file.");
|
|
2596
|
+
let i = {
|
|
2597
|
+
...s,
|
|
2598
|
+
configDir: s.configDir || "./.storybook",
|
|
2599
|
+
configType: "DEVELOPMENT",
|
|
2600
|
+
ignorePreview: !!s.previewUrl && !s.forceBuildPreview,
|
|
2601
|
+
cache: gt,
|
|
2602
|
+
packageJson: t
|
|
2603
|
+
};
|
|
2604
|
+
await _t(
|
|
2605
|
+
"dev",
|
|
2606
|
+
{
|
|
2607
|
+
cliOptions: s,
|
|
2608
|
+
presetOptions: i,
|
|
2609
|
+
printError: yt
|
|
2610
|
+
},
|
|
2611
|
+
() => bt(i)
|
|
2612
|
+
);
|
|
2613
|
+
}, "dev");
|
|
2614
|
+
|
|
2615
|
+
// src/cli/bin/index.ts
|
|
2616
|
+
wt("cliVersion", Ot.storybook);
|
|
2617
|
+
var S = console, oe = /* @__PURE__ */ c((s) => E.program.command(s).option(
|
|
2618
|
+
"--disable-telemetry",
|
|
2619
|
+
"Disable sending telemetry data",
|
|
2620
|
+
// default value is false, but if the user sets STORYBOOK_DISABLE_TELEMETRY, it can be true
|
|
2621
|
+
process.env.STORYBOOK_DISABLE_TELEMETRY && process.env.STORYBOOK_DISABLE_TELEMETRY !== "false"
|
|
2622
|
+
).option("--debug", "Get more logs in debug mode", !1).option("--enable-crash-reports", "Enable sending crash reports to telemetry data"), "\
|
|
2623
|
+
command");
|
|
2624
|
+
oe("dev").option("-p, --port <number>", "Port to run Storybook", (s) => parseInt(s, 10)).option("-h, --host <string>", "Host to run Storyboo\
|
|
2625
|
+
k").option("-c, --config-dir <dir-name>", "Directory where to load Storybook configurations from").option(
|
|
2626
|
+
"--https",
|
|
2627
|
+
"Serve Storybook over HTTPS. Note: You must provide your own certificate information."
|
|
2628
|
+
).option(
|
|
2629
|
+
"--ssl-ca <ca>",
|
|
2630
|
+
"Provide an SSL certificate authority. (Optional with --https, required if using a self-signed certificate)",
|
|
2631
|
+
vt
|
|
2632
|
+
).option("--ssl-cert <cert>", "Provide an SSL certificate. (Required with --https)").option("--ssl-key <key>", "Provide an SSL key. (Require\
|
|
2633
|
+
d with --https)").option("--smoke-test", "Exit after successful start").option("--ci", "CI mode (skip interactive prompts, don't open browse\
|
|
2634
|
+
r)").option("--no-open", "Do not open Storybook automatically in the browser").option("--loglevel <level>", "Control level of logging during\
|
|
2635
|
+
build").option("--quiet", "Suppress verbose build output").option("--no-version-updates", "Suppress update check", !0).option("--debug-webp\
|
|
2636
|
+
ack", "Display final webpack configurations for debugging purposes").option(
|
|
2637
|
+
"--webpack-stats-json [directory]",
|
|
2638
|
+
"Write Webpack stats JSON to disk (synonym for `--stats-json`)"
|
|
2639
|
+
).option("--stats-json [directory]", "Write stats JSON to disk").option(
|
|
2640
|
+
"--preview-url <string>",
|
|
2641
|
+
"Disables the default storybook preview and lets your use your own"
|
|
2642
|
+
).option("--force-build-preview", "Build the preview iframe even if you are using --preview-url").option("--docs", "Build a documentation-on\
|
|
2643
|
+
ly site using addon-docs").option("--exact-port", "Exit early if the desired port is not available").option(
|
|
2644
|
+
"--initial-path [path]",
|
|
2645
|
+
"URL path to be appended when visiting Storybook for the first time"
|
|
2646
|
+
).action(async (s) => {
|
|
2647
|
+
se.setLevel(s.loglevel);
|
|
2648
|
+
let e = await v(__dirname);
|
|
2649
|
+
O(e, "Failed to find the closest package.json file."), S.log(j.default.bold(`${e.name} v${e.version}`) + j.default.reset(`
|
|
2650
|
+
`)), re(s, {
|
|
2651
|
+
port: "SBCONFIG_PORT",
|
|
2652
|
+
host: "SBCONFIG_HOSTNAME",
|
|
2653
|
+
staticDir: "SBCONFIG_STATIC_DIR",
|
|
2654
|
+
configDir: "SBCONFIG_CONFIG_DIR",
|
|
2655
|
+
ci: "CI"
|
|
2656
|
+
}), parseInt(`${s.port}`, 10) && (s.port = parseInt(`${s.port}`, 10)), await Ve({ ...s, packageJson: e }).catch(() => process.exit(1));
|
|
2657
|
+
});
|
|
2658
|
+
oe("build").option("-o, --output-dir <dir-name>", "Directory where to store built files").option("-c, --config-dir <dir-name>", "Directory w\
|
|
2659
|
+
here to load Storybook configurations from").option("--quiet", "Suppress verbose build output").option("--loglevel <level>", "Control level \
|
|
2660
|
+
of logging during build").option("--debug-webpack", "Display final webpack configurations for debugging purposes").option(
|
|
2661
|
+
"--webpack-stats-json [directory]",
|
|
2662
|
+
"Write Webpack stats JSON to disk (synonym for `--stats-json`)"
|
|
2663
|
+
).option("--stats-json [directory]", "Write stats JSON to disk").option(
|
|
2664
|
+
"--preview-url <string>",
|
|
2665
|
+
"Disables the default storybook preview and lets your use your own"
|
|
2666
|
+
).option("--force-build-preview", "Build the preview iframe even if you are using --preview-url").option("--docs", "Build a documentation-on\
|
|
2667
|
+
ly site using addon-docs").option("--test", "Build stories optimized for testing purposes.").action(async (s) => {
|
|
2668
|
+
let { env: e } = process;
|
|
2669
|
+
e.NODE_ENV = e.NODE_ENV || "production";
|
|
2670
|
+
let t = await v(__dirname);
|
|
2671
|
+
O(t, "Failed to find the closest package.json file."), se.setLevel(s.loglevel), S.log(j.default.bold(`${t.name} v${t.version}
|
|
2672
|
+
`)), re(s, {
|
|
2673
|
+
staticDir: "SBCONFIG_STATIC_DIR",
|
|
2674
|
+
outputDir: "SBCONFIG_OUTPUT_DIR",
|
|
2675
|
+
configDir: "SBCONFIG_CONFIG_DIR"
|
|
2676
|
+
}), await Ee({
|
|
2677
|
+
...s,
|
|
2678
|
+
packageJson: t,
|
|
2679
|
+
test: !!s.test || process.env.SB_TESTBUILD === "true"
|
|
2680
|
+
}).catch(() => process.exit(1));
|
|
2681
|
+
});
|
|
2682
|
+
oe("index").option("-o, --output-file <file-name>", "JSON file to output index").option("-c, --config-dir <dir-name>", "Directory where to l\
|
|
2683
|
+
oad Storybook configurations from").option("--quiet", "Suppress verbose build output").option("--loglevel <level>", "Control level of loggin\
|
|
2684
|
+
g during build").action(async (s) => {
|
|
2685
|
+
let { env: e } = process;
|
|
2686
|
+
e.NODE_ENV = e.NODE_ENV || "production";
|
|
2687
|
+
let t = await v(__dirname);
|
|
2688
|
+
O(t, "Failed to find the closest package.json file."), se.setLevel(s.loglevel), S.log(j.default.bold(`${t.name} v${t.version}
|
|
2689
|
+
`)), re(s, {
|
|
2690
|
+
configDir: "SBCONFIG_CONFIG_DIR",
|
|
2691
|
+
outputFile: "SBCONFIG_OUTPUT_FILE"
|
|
2692
|
+
}), await je({
|
|
2693
|
+
...s,
|
|
2694
|
+
packageJson: t
|
|
2695
|
+
}).catch(() => process.exit(1));
|
|
2696
|
+
});
|
|
2697
|
+
E.program.on("command:*", ([s]) => {
|
|
2698
|
+
S.error(
|
|
2699
|
+
` Invalid command: %s.
|
|
2700
|
+
See --help for a list of available commands.`,
|
|
2701
|
+
s
|
|
2702
|
+
);
|
|
2703
|
+
let t = E.program.commands.map((i) => i.name()).find((i) => ee(i, s) < 3);
|
|
2704
|
+
t && S.info(`
|
|
2705
|
+
Did you mean ${t}?`), process.exit(1);
|
|
2706
|
+
});
|
|
2707
|
+
E.program.usage("<command> [options]").version(String(Ae)).parse(process.argv);
|