@manot40/genql-cli 1.0.0 → 1.0.2
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/LICENSE +21 -21
- package/README.md +41 -41
- package/dist/chunk-BBnsswwY.mjs +31 -0
- package/dist/cli-truncate-D9-H5ZcK.mjs +155 -0
- package/dist/cli.d.mts +0 -0
- package/dist/cli.mjs +4248 -8
- package/dist/get-east-asian-width-BrRn4isQ.mjs +24 -0
- package/dist/index.mjs +1 -1
- package/dist/log-update-C7F4wEC4.mjs +432 -0
- package/dist/main-DnxPgNLv.mjs +4937 -0
- package/dist/runtime/createClient.ts +3 -2
- package/dist/slice-ansi-BXJtqwp2.mjs +282 -0
- package/dist/wrap-ansi-B5Z_xwBN.mjs +3 -0
- package/dist/wrap-ansi-BLh1Umdy.mjs +359 -0
- package/package.json +24 -28
- package/dist/main-BVWRj669.mjs +0 -798
|
@@ -0,0 +1,4937 @@
|
|
|
1
|
+
import { n as __toESM, t as __commonJSMin } from "./chunk-BBnsswwY.mjs";
|
|
2
|
+
import * as tty from "tty";
|
|
3
|
+
import { format } from "util";
|
|
4
|
+
import { EOL } from "os";
|
|
5
|
+
import { StringDecoder } from "string_decoder";
|
|
6
|
+
import { Writable } from "stream";
|
|
7
|
+
import { randomUUID } from "crypto";
|
|
8
|
+
import fs, { glob, mkdir, rm, writeFile } from "node:fs/promises";
|
|
9
|
+
import url from "node:url";
|
|
10
|
+
import path, { resolve } from "node:path";
|
|
11
|
+
import { assertValidSchema, buildClientSchema, getIntrospectionQuery, getNamedType, isEnumType, isInputObjectType, isInterfaceType, isListType, isNamedType, isNonNullType, isObjectType, isScalarType, isUnionType, lexicographicSortSchema, printSchema } from "graphql";
|
|
12
|
+
import path$1 from "path";
|
|
13
|
+
import { GraphQLFileLoader } from "@graphql-tools/graphql-file-loader";
|
|
14
|
+
import { loadSchema } from "@graphql-tools/load";
|
|
15
|
+
|
|
16
|
+
//#region node_modules/eventemitter3/index.js
|
|
17
|
+
var require_eventemitter3 = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
18
|
+
var has = Object.prototype.hasOwnProperty, prefix = "~";
|
|
19
|
+
/**
|
|
20
|
+
* Constructor to create a storage for our `EE` objects.
|
|
21
|
+
* An `Events` instance is a plain object whose properties are event names.
|
|
22
|
+
*
|
|
23
|
+
* @constructor
|
|
24
|
+
* @private
|
|
25
|
+
*/
|
|
26
|
+
function Events() {}
|
|
27
|
+
if (Object.create) {
|
|
28
|
+
Events.prototype = Object.create(null);
|
|
29
|
+
if (!new Events().__proto__) prefix = false;
|
|
30
|
+
}
|
|
31
|
+
/**
|
|
32
|
+
* Representation of a single event listener.
|
|
33
|
+
*
|
|
34
|
+
* @param {Function} fn The listener function.
|
|
35
|
+
* @param {*} context The context to invoke the listener with.
|
|
36
|
+
* @param {Boolean} [once=false] Specify if the listener is a one-time listener.
|
|
37
|
+
* @constructor
|
|
38
|
+
* @private
|
|
39
|
+
*/
|
|
40
|
+
function EE(fn, context, once) {
|
|
41
|
+
this.fn = fn;
|
|
42
|
+
this.context = context;
|
|
43
|
+
this.once = once || false;
|
|
44
|
+
}
|
|
45
|
+
/**
|
|
46
|
+
* Add a listener for a given event.
|
|
47
|
+
*
|
|
48
|
+
* @param {EventEmitter} emitter Reference to the `EventEmitter` instance.
|
|
49
|
+
* @param {(String|Symbol)} event The event name.
|
|
50
|
+
* @param {Function} fn The listener function.
|
|
51
|
+
* @param {*} context The context to invoke the listener with.
|
|
52
|
+
* @param {Boolean} once Specify if the listener is a one-time listener.
|
|
53
|
+
* @returns {EventEmitter}
|
|
54
|
+
* @private
|
|
55
|
+
*/
|
|
56
|
+
function addListener(emitter, event, fn, context, once) {
|
|
57
|
+
if (typeof fn !== "function") throw new TypeError("The listener must be a function");
|
|
58
|
+
var listener = new EE(fn, context || emitter, once), evt = prefix ? prefix + event : event;
|
|
59
|
+
if (!emitter._events[evt]) emitter._events[evt] = listener, emitter._eventsCount++;
|
|
60
|
+
else if (!emitter._events[evt].fn) emitter._events[evt].push(listener);
|
|
61
|
+
else emitter._events[evt] = [emitter._events[evt], listener];
|
|
62
|
+
return emitter;
|
|
63
|
+
}
|
|
64
|
+
/**
|
|
65
|
+
* Clear event by name.
|
|
66
|
+
*
|
|
67
|
+
* @param {EventEmitter} emitter Reference to the `EventEmitter` instance.
|
|
68
|
+
* @param {(String|Symbol)} evt The Event name.
|
|
69
|
+
* @private
|
|
70
|
+
*/
|
|
71
|
+
function clearEvent(emitter, evt) {
|
|
72
|
+
if (--emitter._eventsCount === 0) emitter._events = new Events();
|
|
73
|
+
else delete emitter._events[evt];
|
|
74
|
+
}
|
|
75
|
+
/**
|
|
76
|
+
* Minimal `EventEmitter` interface that is molded against the Node.js
|
|
77
|
+
* `EventEmitter` interface.
|
|
78
|
+
*
|
|
79
|
+
* @constructor
|
|
80
|
+
* @public
|
|
81
|
+
*/
|
|
82
|
+
function EventEmitter() {
|
|
83
|
+
this._events = new Events();
|
|
84
|
+
this._eventsCount = 0;
|
|
85
|
+
}
|
|
86
|
+
/**
|
|
87
|
+
* Return an array listing the events for which the emitter has registered
|
|
88
|
+
* listeners.
|
|
89
|
+
*
|
|
90
|
+
* @returns {Array}
|
|
91
|
+
* @public
|
|
92
|
+
*/
|
|
93
|
+
EventEmitter.prototype.eventNames = function eventNames() {
|
|
94
|
+
var names = [], events, name;
|
|
95
|
+
if (this._eventsCount === 0) return names;
|
|
96
|
+
for (name in events = this._events) if (has.call(events, name)) names.push(prefix ? name.slice(1) : name);
|
|
97
|
+
if (Object.getOwnPropertySymbols) return names.concat(Object.getOwnPropertySymbols(events));
|
|
98
|
+
return names;
|
|
99
|
+
};
|
|
100
|
+
/**
|
|
101
|
+
* Return the listeners registered for a given event.
|
|
102
|
+
*
|
|
103
|
+
* @param {(String|Symbol)} event The event name.
|
|
104
|
+
* @returns {Array} The registered listeners.
|
|
105
|
+
* @public
|
|
106
|
+
*/
|
|
107
|
+
EventEmitter.prototype.listeners = function listeners(event) {
|
|
108
|
+
var evt = prefix ? prefix + event : event, handlers = this._events[evt];
|
|
109
|
+
if (!handlers) return [];
|
|
110
|
+
if (handlers.fn) return [handlers.fn];
|
|
111
|
+
for (var i = 0, l = handlers.length, ee = new Array(l); i < l; i++) ee[i] = handlers[i].fn;
|
|
112
|
+
return ee;
|
|
113
|
+
};
|
|
114
|
+
/**
|
|
115
|
+
* Return the number of listeners listening to a given event.
|
|
116
|
+
*
|
|
117
|
+
* @param {(String|Symbol)} event The event name.
|
|
118
|
+
* @returns {Number} The number of listeners.
|
|
119
|
+
* @public
|
|
120
|
+
*/
|
|
121
|
+
EventEmitter.prototype.listenerCount = function listenerCount(event) {
|
|
122
|
+
var evt = prefix ? prefix + event : event, listeners = this._events[evt];
|
|
123
|
+
if (!listeners) return 0;
|
|
124
|
+
if (listeners.fn) return 1;
|
|
125
|
+
return listeners.length;
|
|
126
|
+
};
|
|
127
|
+
/**
|
|
128
|
+
* Calls each of the listeners registered for a given event.
|
|
129
|
+
*
|
|
130
|
+
* @param {(String|Symbol)} event The event name.
|
|
131
|
+
* @returns {Boolean} `true` if the event had listeners, else `false`.
|
|
132
|
+
* @public
|
|
133
|
+
*/
|
|
134
|
+
EventEmitter.prototype.emit = function emit(event, a1, a2, a3, a4, a5) {
|
|
135
|
+
var evt = prefix ? prefix + event : event;
|
|
136
|
+
if (!this._events[evt]) return false;
|
|
137
|
+
var listeners = this._events[evt], len = arguments.length, args, i;
|
|
138
|
+
if (listeners.fn) {
|
|
139
|
+
if (listeners.once) this.removeListener(event, listeners.fn, void 0, true);
|
|
140
|
+
switch (len) {
|
|
141
|
+
case 1: return listeners.fn.call(listeners.context), true;
|
|
142
|
+
case 2: return listeners.fn.call(listeners.context, a1), true;
|
|
143
|
+
case 3: return listeners.fn.call(listeners.context, a1, a2), true;
|
|
144
|
+
case 4: return listeners.fn.call(listeners.context, a1, a2, a3), true;
|
|
145
|
+
case 5: return listeners.fn.call(listeners.context, a1, a2, a3, a4), true;
|
|
146
|
+
case 6: return listeners.fn.call(listeners.context, a1, a2, a3, a4, a5), true;
|
|
147
|
+
}
|
|
148
|
+
for (i = 1, args = new Array(len - 1); i < len; i++) args[i - 1] = arguments[i];
|
|
149
|
+
listeners.fn.apply(listeners.context, args);
|
|
150
|
+
} else {
|
|
151
|
+
var length = listeners.length, j;
|
|
152
|
+
for (i = 0; i < length; i++) {
|
|
153
|
+
if (listeners[i].once) this.removeListener(event, listeners[i].fn, void 0, true);
|
|
154
|
+
switch (len) {
|
|
155
|
+
case 1:
|
|
156
|
+
listeners[i].fn.call(listeners[i].context);
|
|
157
|
+
break;
|
|
158
|
+
case 2:
|
|
159
|
+
listeners[i].fn.call(listeners[i].context, a1);
|
|
160
|
+
break;
|
|
161
|
+
case 3:
|
|
162
|
+
listeners[i].fn.call(listeners[i].context, a1, a2);
|
|
163
|
+
break;
|
|
164
|
+
case 4:
|
|
165
|
+
listeners[i].fn.call(listeners[i].context, a1, a2, a3);
|
|
166
|
+
break;
|
|
167
|
+
default:
|
|
168
|
+
if (!args) for (j = 1, args = new Array(len - 1); j < len; j++) args[j - 1] = arguments[j];
|
|
169
|
+
listeners[i].fn.apply(listeners[i].context, args);
|
|
170
|
+
}
|
|
171
|
+
}
|
|
172
|
+
}
|
|
173
|
+
return true;
|
|
174
|
+
};
|
|
175
|
+
/**
|
|
176
|
+
* Add a listener for a given event.
|
|
177
|
+
*
|
|
178
|
+
* @param {(String|Symbol)} event The event name.
|
|
179
|
+
* @param {Function} fn The listener function.
|
|
180
|
+
* @param {*} [context=this] The context to invoke the listener with.
|
|
181
|
+
* @returns {EventEmitter} `this`.
|
|
182
|
+
* @public
|
|
183
|
+
*/
|
|
184
|
+
EventEmitter.prototype.on = function on(event, fn, context) {
|
|
185
|
+
return addListener(this, event, fn, context, false);
|
|
186
|
+
};
|
|
187
|
+
/**
|
|
188
|
+
* Add a one-time listener for a given event.
|
|
189
|
+
*
|
|
190
|
+
* @param {(String|Symbol)} event The event name.
|
|
191
|
+
* @param {Function} fn The listener function.
|
|
192
|
+
* @param {*} [context=this] The context to invoke the listener with.
|
|
193
|
+
* @returns {EventEmitter} `this`.
|
|
194
|
+
* @public
|
|
195
|
+
*/
|
|
196
|
+
EventEmitter.prototype.once = function once(event, fn, context) {
|
|
197
|
+
return addListener(this, event, fn, context, true);
|
|
198
|
+
};
|
|
199
|
+
/**
|
|
200
|
+
* Remove the listeners of a given event.
|
|
201
|
+
*
|
|
202
|
+
* @param {(String|Symbol)} event The event name.
|
|
203
|
+
* @param {Function} fn Only remove the listeners that match this function.
|
|
204
|
+
* @param {*} context Only remove the listeners that have this context.
|
|
205
|
+
* @param {Boolean} once Only remove one-time listeners.
|
|
206
|
+
* @returns {EventEmitter} `this`.
|
|
207
|
+
* @public
|
|
208
|
+
*/
|
|
209
|
+
EventEmitter.prototype.removeListener = function removeListener(event, fn, context, once) {
|
|
210
|
+
var evt = prefix ? prefix + event : event;
|
|
211
|
+
if (!this._events[evt]) return this;
|
|
212
|
+
if (!fn) {
|
|
213
|
+
clearEvent(this, evt);
|
|
214
|
+
return this;
|
|
215
|
+
}
|
|
216
|
+
var listeners = this._events[evt];
|
|
217
|
+
if (listeners.fn) {
|
|
218
|
+
if (listeners.fn === fn && (!once || listeners.once) && (!context || listeners.context === context)) clearEvent(this, evt);
|
|
219
|
+
} else {
|
|
220
|
+
for (var i = 0, events = [], length = listeners.length; i < length; i++) if (listeners[i].fn !== fn || once && !listeners[i].once || context && listeners[i].context !== context) events.push(listeners[i]);
|
|
221
|
+
if (events.length) this._events[evt] = events.length === 1 ? events[0] : events;
|
|
222
|
+
else clearEvent(this, evt);
|
|
223
|
+
}
|
|
224
|
+
return this;
|
|
225
|
+
};
|
|
226
|
+
/**
|
|
227
|
+
* Remove all listeners, or those of the specified event.
|
|
228
|
+
*
|
|
229
|
+
* @param {(String|Symbol)} [event] The event name.
|
|
230
|
+
* @returns {EventEmitter} `this`.
|
|
231
|
+
* @public
|
|
232
|
+
*/
|
|
233
|
+
EventEmitter.prototype.removeAllListeners = function removeAllListeners(event) {
|
|
234
|
+
var evt;
|
|
235
|
+
if (event) {
|
|
236
|
+
evt = prefix ? prefix + event : event;
|
|
237
|
+
if (this._events[evt]) clearEvent(this, evt);
|
|
238
|
+
} else {
|
|
239
|
+
this._events = new Events();
|
|
240
|
+
this._eventsCount = 0;
|
|
241
|
+
}
|
|
242
|
+
return this;
|
|
243
|
+
};
|
|
244
|
+
EventEmitter.prototype.off = EventEmitter.prototype.removeListener;
|
|
245
|
+
EventEmitter.prototype.addListener = EventEmitter.prototype.on;
|
|
246
|
+
EventEmitter.prefixed = prefix;
|
|
247
|
+
EventEmitter.EventEmitter = EventEmitter;
|
|
248
|
+
if ("undefined" !== typeof module) module.exports = EventEmitter;
|
|
249
|
+
}));
|
|
250
|
+
|
|
251
|
+
//#endregion
|
|
252
|
+
//#region node_modules/eventemitter3/index.mjs
|
|
253
|
+
var import_eventemitter3 = /* @__PURE__ */ __toESM(require_eventemitter3(), 1);
|
|
254
|
+
var eventemitter3_default = import_eventemitter3.default;
|
|
255
|
+
|
|
256
|
+
//#endregion
|
|
257
|
+
//#region node_modules/colorette/index.js
|
|
258
|
+
const { env = {}, argv = [], platform = "" } = typeof process === "undefined" ? {} : process;
|
|
259
|
+
const isDisabled = "NO_COLOR" in env || argv.includes("--no-color");
|
|
260
|
+
const isForced = "FORCE_COLOR" in env || argv.includes("--color");
|
|
261
|
+
const isWindows = platform === "win32";
|
|
262
|
+
const isDumbTerminal = env.TERM === "dumb";
|
|
263
|
+
const isCompatibleTerminal = tty && tty.isatty && tty.isatty(1) && env.TERM && !isDumbTerminal;
|
|
264
|
+
const isCI = "CI" in env && ("GITHUB_ACTIONS" in env || "GITLAB_CI" in env || "CIRCLECI" in env);
|
|
265
|
+
const isColorSupported = !isDisabled && (isForced || isWindows && !isDumbTerminal || isCompatibleTerminal || isCI);
|
|
266
|
+
const replaceClose = (index, string, close, replace, head = string.substring(0, index) + replace, tail = string.substring(index + close.length), next = tail.indexOf(close)) => head + (next < 0 ? tail : replaceClose(next, tail, close, replace));
|
|
267
|
+
const clearBleed = (index, string, open, close, replace) => index < 0 ? open + string + close : open + replaceClose(index, string, close, replace) + close;
|
|
268
|
+
const filterEmpty = (open, close, replace = open, at = open.length + 1) => (string) => string || !(string === "" || string === void 0) ? clearBleed(("" + string).indexOf(close, at), string, open, close, replace) : "";
|
|
269
|
+
const init = (open, close, replace) => filterEmpty(`\x1b[${open}m`, `\x1b[${close}m`, replace);
|
|
270
|
+
const colors = {
|
|
271
|
+
reset: init(0, 0),
|
|
272
|
+
bold: init(1, 22, "\x1B[22m\x1B[1m"),
|
|
273
|
+
dim: init(2, 22, "\x1B[22m\x1B[2m"),
|
|
274
|
+
italic: init(3, 23),
|
|
275
|
+
underline: init(4, 24),
|
|
276
|
+
inverse: init(7, 27),
|
|
277
|
+
hidden: init(8, 28),
|
|
278
|
+
strikethrough: init(9, 29),
|
|
279
|
+
black: init(30, 39),
|
|
280
|
+
red: init(31, 39),
|
|
281
|
+
green: init(32, 39),
|
|
282
|
+
yellow: init(33, 39),
|
|
283
|
+
blue: init(34, 39),
|
|
284
|
+
magenta: init(35, 39),
|
|
285
|
+
cyan: init(36, 39),
|
|
286
|
+
white: init(37, 39),
|
|
287
|
+
gray: init(90, 39),
|
|
288
|
+
bgBlack: init(40, 49),
|
|
289
|
+
bgRed: init(41, 49),
|
|
290
|
+
bgGreen: init(42, 49),
|
|
291
|
+
bgYellow: init(43, 49),
|
|
292
|
+
bgBlue: init(44, 49),
|
|
293
|
+
bgMagenta: init(45, 49),
|
|
294
|
+
bgCyan: init(46, 49),
|
|
295
|
+
bgWhite: init(47, 49),
|
|
296
|
+
blackBright: init(90, 39),
|
|
297
|
+
redBright: init(91, 39),
|
|
298
|
+
greenBright: init(92, 39),
|
|
299
|
+
yellowBright: init(93, 39),
|
|
300
|
+
blueBright: init(94, 39),
|
|
301
|
+
magentaBright: init(95, 39),
|
|
302
|
+
cyanBright: init(96, 39),
|
|
303
|
+
whiteBright: init(97, 39),
|
|
304
|
+
bgBlackBright: init(100, 49),
|
|
305
|
+
bgRedBright: init(101, 49),
|
|
306
|
+
bgGreenBright: init(102, 49),
|
|
307
|
+
bgYellowBright: init(103, 49),
|
|
308
|
+
bgBlueBright: init(104, 49),
|
|
309
|
+
bgMagentaBright: init(105, 49),
|
|
310
|
+
bgCyanBright: init(106, 49),
|
|
311
|
+
bgWhiteBright: init(107, 49)
|
|
312
|
+
};
|
|
313
|
+
const createColors = ({ useColor = isColorSupported } = {}) => useColor ? colors : Object.keys(colors).reduce((colors$1, key) => ({
|
|
314
|
+
...colors$1,
|
|
315
|
+
[key]: String
|
|
316
|
+
}), {});
|
|
317
|
+
const { reset, bold, dim, italic, underline, inverse, hidden, strikethrough, black, red, green, yellow, blue, magenta, cyan, white, gray, bgBlack, bgRed, bgGreen, bgYellow, bgBlue, bgMagenta, bgCyan, bgWhite, blackBright, redBright, greenBright, yellowBright, blueBright, magentaBright, cyanBright, whiteBright, bgBlackBright, bgRedBright, bgGreenBright, bgYellowBright, bgBlueBright, bgMagentaBright, bgCyanBright, bgWhiteBright } = createColors();
|
|
318
|
+
|
|
319
|
+
//#endregion
|
|
320
|
+
//#region node_modules/rfdc/index.js
|
|
321
|
+
var require_rfdc = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
322
|
+
module.exports = rfdc;
|
|
323
|
+
function copyBuffer(cur) {
|
|
324
|
+
if (cur instanceof Buffer) return Buffer.from(cur);
|
|
325
|
+
return new cur.constructor(cur.buffer.slice(), cur.byteOffset, cur.length);
|
|
326
|
+
}
|
|
327
|
+
function rfdc(opts) {
|
|
328
|
+
opts = opts || {};
|
|
329
|
+
if (opts.circles) return rfdcCircles(opts);
|
|
330
|
+
const constructorHandlers = /* @__PURE__ */ new Map();
|
|
331
|
+
constructorHandlers.set(Date, (o) => new Date(o));
|
|
332
|
+
constructorHandlers.set(Map, (o, fn) => new Map(cloneArray(Array.from(o), fn)));
|
|
333
|
+
constructorHandlers.set(Set, (o, fn) => new Set(cloneArray(Array.from(o), fn)));
|
|
334
|
+
if (opts.constructorHandlers) for (const handler$1 of opts.constructorHandlers) constructorHandlers.set(handler$1[0], handler$1[1]);
|
|
335
|
+
let handler = null;
|
|
336
|
+
return opts.proto ? cloneProto : clone$1;
|
|
337
|
+
function cloneArray(a, fn) {
|
|
338
|
+
const keys = Object.keys(a);
|
|
339
|
+
const a2 = new Array(keys.length);
|
|
340
|
+
for (let i = 0; i < keys.length; i++) {
|
|
341
|
+
const k = keys[i];
|
|
342
|
+
const cur = a[k];
|
|
343
|
+
if (typeof cur !== "object" || cur === null) a2[k] = cur;
|
|
344
|
+
else if (cur.constructor !== Object && (handler = constructorHandlers.get(cur.constructor))) a2[k] = handler(cur, fn);
|
|
345
|
+
else if (ArrayBuffer.isView(cur)) a2[k] = copyBuffer(cur);
|
|
346
|
+
else a2[k] = fn(cur);
|
|
347
|
+
}
|
|
348
|
+
return a2;
|
|
349
|
+
}
|
|
350
|
+
function clone$1(o) {
|
|
351
|
+
if (typeof o !== "object" || o === null) return o;
|
|
352
|
+
if (Array.isArray(o)) return cloneArray(o, clone$1);
|
|
353
|
+
if (o.constructor !== Object && (handler = constructorHandlers.get(o.constructor))) return handler(o, clone$1);
|
|
354
|
+
const o2 = {};
|
|
355
|
+
for (const k in o) {
|
|
356
|
+
if (Object.hasOwnProperty.call(o, k) === false) continue;
|
|
357
|
+
const cur = o[k];
|
|
358
|
+
if (typeof cur !== "object" || cur === null) o2[k] = cur;
|
|
359
|
+
else if (cur.constructor !== Object && (handler = constructorHandlers.get(cur.constructor))) o2[k] = handler(cur, clone$1);
|
|
360
|
+
else if (ArrayBuffer.isView(cur)) o2[k] = copyBuffer(cur);
|
|
361
|
+
else o2[k] = clone$1(cur);
|
|
362
|
+
}
|
|
363
|
+
return o2;
|
|
364
|
+
}
|
|
365
|
+
function cloneProto(o) {
|
|
366
|
+
if (typeof o !== "object" || o === null) return o;
|
|
367
|
+
if (Array.isArray(o)) return cloneArray(o, cloneProto);
|
|
368
|
+
if (o.constructor !== Object && (handler = constructorHandlers.get(o.constructor))) return handler(o, cloneProto);
|
|
369
|
+
const o2 = {};
|
|
370
|
+
for (const k in o) {
|
|
371
|
+
const cur = o[k];
|
|
372
|
+
if (typeof cur !== "object" || cur === null) o2[k] = cur;
|
|
373
|
+
else if (cur.constructor !== Object && (handler = constructorHandlers.get(cur.constructor))) o2[k] = handler(cur, cloneProto);
|
|
374
|
+
else if (ArrayBuffer.isView(cur)) o2[k] = copyBuffer(cur);
|
|
375
|
+
else o2[k] = cloneProto(cur);
|
|
376
|
+
}
|
|
377
|
+
return o2;
|
|
378
|
+
}
|
|
379
|
+
}
|
|
380
|
+
function rfdcCircles(opts) {
|
|
381
|
+
const refs = [];
|
|
382
|
+
const refsNew = [];
|
|
383
|
+
const constructorHandlers = /* @__PURE__ */ new Map();
|
|
384
|
+
constructorHandlers.set(Date, (o) => new Date(o));
|
|
385
|
+
constructorHandlers.set(Map, (o, fn) => new Map(cloneArray(Array.from(o), fn)));
|
|
386
|
+
constructorHandlers.set(Set, (o, fn) => new Set(cloneArray(Array.from(o), fn)));
|
|
387
|
+
if (opts.constructorHandlers) for (const handler$1 of opts.constructorHandlers) constructorHandlers.set(handler$1[0], handler$1[1]);
|
|
388
|
+
let handler = null;
|
|
389
|
+
return opts.proto ? cloneProto : clone$1;
|
|
390
|
+
function cloneArray(a, fn) {
|
|
391
|
+
const keys = Object.keys(a);
|
|
392
|
+
const a2 = new Array(keys.length);
|
|
393
|
+
for (let i = 0; i < keys.length; i++) {
|
|
394
|
+
const k = keys[i];
|
|
395
|
+
const cur = a[k];
|
|
396
|
+
if (typeof cur !== "object" || cur === null) a2[k] = cur;
|
|
397
|
+
else if (cur.constructor !== Object && (handler = constructorHandlers.get(cur.constructor))) a2[k] = handler(cur, fn);
|
|
398
|
+
else if (ArrayBuffer.isView(cur)) a2[k] = copyBuffer(cur);
|
|
399
|
+
else {
|
|
400
|
+
const index = refs.indexOf(cur);
|
|
401
|
+
if (index !== -1) a2[k] = refsNew[index];
|
|
402
|
+
else a2[k] = fn(cur);
|
|
403
|
+
}
|
|
404
|
+
}
|
|
405
|
+
return a2;
|
|
406
|
+
}
|
|
407
|
+
function clone$1(o) {
|
|
408
|
+
if (typeof o !== "object" || o === null) return o;
|
|
409
|
+
if (Array.isArray(o)) return cloneArray(o, clone$1);
|
|
410
|
+
if (o.constructor !== Object && (handler = constructorHandlers.get(o.constructor))) return handler(o, clone$1);
|
|
411
|
+
const o2 = {};
|
|
412
|
+
refs.push(o);
|
|
413
|
+
refsNew.push(o2);
|
|
414
|
+
for (const k in o) {
|
|
415
|
+
if (Object.hasOwnProperty.call(o, k) === false) continue;
|
|
416
|
+
const cur = o[k];
|
|
417
|
+
if (typeof cur !== "object" || cur === null) o2[k] = cur;
|
|
418
|
+
else if (cur.constructor !== Object && (handler = constructorHandlers.get(cur.constructor))) o2[k] = handler(cur, clone$1);
|
|
419
|
+
else if (ArrayBuffer.isView(cur)) o2[k] = copyBuffer(cur);
|
|
420
|
+
else {
|
|
421
|
+
const i = refs.indexOf(cur);
|
|
422
|
+
if (i !== -1) o2[k] = refsNew[i];
|
|
423
|
+
else o2[k] = clone$1(cur);
|
|
424
|
+
}
|
|
425
|
+
}
|
|
426
|
+
refs.pop();
|
|
427
|
+
refsNew.pop();
|
|
428
|
+
return o2;
|
|
429
|
+
}
|
|
430
|
+
function cloneProto(o) {
|
|
431
|
+
if (typeof o !== "object" || o === null) return o;
|
|
432
|
+
if (Array.isArray(o)) return cloneArray(o, cloneProto);
|
|
433
|
+
if (o.constructor !== Object && (handler = constructorHandlers.get(o.constructor))) return handler(o, cloneProto);
|
|
434
|
+
const o2 = {};
|
|
435
|
+
refs.push(o);
|
|
436
|
+
refsNew.push(o2);
|
|
437
|
+
for (const k in o) {
|
|
438
|
+
const cur = o[k];
|
|
439
|
+
if (typeof cur !== "object" || cur === null) o2[k] = cur;
|
|
440
|
+
else if (cur.constructor !== Object && (handler = constructorHandlers.get(cur.constructor))) o2[k] = handler(cur, cloneProto);
|
|
441
|
+
else if (ArrayBuffer.isView(cur)) o2[k] = copyBuffer(cur);
|
|
442
|
+
else {
|
|
443
|
+
const i = refs.indexOf(cur);
|
|
444
|
+
if (i !== -1) o2[k] = refsNew[i];
|
|
445
|
+
else o2[k] = cloneProto(cur);
|
|
446
|
+
}
|
|
447
|
+
}
|
|
448
|
+
refs.pop();
|
|
449
|
+
refsNew.pop();
|
|
450
|
+
return o2;
|
|
451
|
+
}
|
|
452
|
+
}
|
|
453
|
+
}));
|
|
454
|
+
|
|
455
|
+
//#endregion
|
|
456
|
+
//#region node_modules/listr2/dist/index.js
|
|
457
|
+
var import_rfdc = /* @__PURE__ */ __toESM(require_rfdc(), 1);
|
|
458
|
+
/**
|
|
459
|
+
* Indicates an UNICODE characters is coming up.
|
|
460
|
+
*/
|
|
461
|
+
const ANSI_ESCAPE = "\x1B[";
|
|
462
|
+
/**
|
|
463
|
+
* Generic ANSI escape characters for terminal based operations.
|
|
464
|
+
*/
|
|
465
|
+
const ANSI_ESCAPE_CODES = {
|
|
466
|
+
CURSOR_HIDE: ANSI_ESCAPE + "?25l",
|
|
467
|
+
CURSOR_SHOW: ANSI_ESCAPE + "?25h"
|
|
468
|
+
};
|
|
469
|
+
/**
|
|
470
|
+
* Environment variables for Listr.
|
|
471
|
+
*/
|
|
472
|
+
let ListrEnvironmentVariables = /* @__PURE__ */ function(ListrEnvironmentVariables$1) {
|
|
473
|
+
ListrEnvironmentVariables$1["FORCE_UNICODE"] = "LISTR_FORCE_UNICODE";
|
|
474
|
+
ListrEnvironmentVariables$1["FORCE_TTY"] = "LISTR_FORCE_TTY";
|
|
475
|
+
ListrEnvironmentVariables$1["DISABLE_COLOR"] = "NO_COLOR";
|
|
476
|
+
ListrEnvironmentVariables$1["FORCE_COLOR"] = "FORCE_COLOR";
|
|
477
|
+
return ListrEnvironmentVariables$1;
|
|
478
|
+
}({});
|
|
479
|
+
/**
|
|
480
|
+
* The actual error type that is collected and to help identify where the error is triggered from.
|
|
481
|
+
*/
|
|
482
|
+
let ListrErrorTypes = /* @__PURE__ */ function(ListrErrorTypes$1) {
|
|
483
|
+
/** Task has failed and will try to retry. */
|
|
484
|
+
ListrErrorTypes$1["WILL_RETRY"] = "WILL_RETRY";
|
|
485
|
+
/** Task has failed and will try to rollback. */
|
|
486
|
+
ListrErrorTypes$1["WILL_ROLLBACK"] = "WILL_ROLLBACK";
|
|
487
|
+
/** Task has failed, ran the rollback action but the rollback action itself has failed. */
|
|
488
|
+
ListrErrorTypes$1["HAS_FAILED_TO_ROLLBACK"] = "HAS_FAILED_TO_ROLLBACK";
|
|
489
|
+
/** Task has failed. */
|
|
490
|
+
ListrErrorTypes$1["HAS_FAILED"] = "HAS_FAILED";
|
|
491
|
+
/** Task has failed, but exitOnError is set to false, so will ignore this error. */
|
|
492
|
+
ListrErrorTypes$1["HAS_FAILED_WITHOUT_ERROR"] = "HAS_FAILED_WITHOUT_ERROR";
|
|
493
|
+
return ListrErrorTypes$1;
|
|
494
|
+
}({});
|
|
495
|
+
/**
|
|
496
|
+
* Events that are triggered by Listr.
|
|
497
|
+
*
|
|
498
|
+
* These are stateful and singleton events by being attached to the main Listr class and propagating to the subtasks.
|
|
499
|
+
*
|
|
500
|
+
* @see {@link https://listr2.kilic.dev/listr/events.html}
|
|
501
|
+
*/
|
|
502
|
+
let ListrEventType = /* @__PURE__ */ function(ListrEventType$1) {
|
|
503
|
+
/** Indicates that underlying renderer should refresh the current render. */
|
|
504
|
+
ListrEventType$1["SHOULD_REFRESH_RENDER"] = "SHOUD_REFRESH_RENDER";
|
|
505
|
+
return ListrEventType$1;
|
|
506
|
+
}({});
|
|
507
|
+
let ListrRendererSelection = /* @__PURE__ */ function(ListrRendererSelection$1) {
|
|
508
|
+
ListrRendererSelection$1["PRIMARY"] = "PRIMARY";
|
|
509
|
+
ListrRendererSelection$1["SECONDARY"] = "SECONDARY";
|
|
510
|
+
ListrRendererSelection$1["SILENT"] = "SILENT";
|
|
511
|
+
return ListrRendererSelection$1;
|
|
512
|
+
}({});
|
|
513
|
+
/**
|
|
514
|
+
* Internal events that are fired from the Task.
|
|
515
|
+
*
|
|
516
|
+
* @see {@link https://listr2.kilic.dev/task/events.html}
|
|
517
|
+
*/
|
|
518
|
+
let ListrTaskEventType = /* @__PURE__ */ function(ListrTaskEventType$1) {
|
|
519
|
+
/** Title has changed for the current Task. */
|
|
520
|
+
ListrTaskEventType$1["TITLE"] = "TITLE";
|
|
521
|
+
/**
|
|
522
|
+
* State has changed for the current Task.
|
|
523
|
+
*
|
|
524
|
+
* @see {@link module:listr2.ListrTaskState}
|
|
525
|
+
*/
|
|
526
|
+
ListrTaskEventType$1["STATE"] = "STATE";
|
|
527
|
+
/** The current Task has been marked as enabled. */
|
|
528
|
+
ListrTaskEventType$1["ENABLED"] = "ENABLED";
|
|
529
|
+
/** The current Task is currently processing subtasks. */
|
|
530
|
+
ListrTaskEventType$1["SUBTASK"] = "SUBTASK";
|
|
531
|
+
/** The current Task is now processing a prompt. */
|
|
532
|
+
ListrTaskEventType$1["PROMPT"] = "PROMPT";
|
|
533
|
+
/** The current Task is now dumping output. */
|
|
534
|
+
ListrTaskEventType$1["OUTPUT"] = "OUTPUT";
|
|
535
|
+
/**
|
|
536
|
+
* The current Task is now dumping a message.
|
|
537
|
+
*
|
|
538
|
+
* @see {module:Listr2.ListrTaskMessage}
|
|
539
|
+
*/
|
|
540
|
+
ListrTaskEventType$1["MESSAGE"] = "MESSAGE";
|
|
541
|
+
/** The current Task is closed and no further action in expected. */
|
|
542
|
+
ListrTaskEventType$1["CLOSED"] = "CLOSED";
|
|
543
|
+
return ListrTaskEventType$1;
|
|
544
|
+
}({});
|
|
545
|
+
/**
|
|
546
|
+
* Tasks can be in various states during the execution.
|
|
547
|
+
*
|
|
548
|
+
* Whenever a state change occurs, the task will emit a {@link module:listr2.ListrTaskEventType.STATE} with the appropriate state.
|
|
549
|
+
*/
|
|
550
|
+
let ListrTaskState = /* @__PURE__ */ function(ListrTaskState$1) {
|
|
551
|
+
/** Task has not started yet, waiting for pick-up. */
|
|
552
|
+
ListrTaskState$1["WAITING"] = "WAITING";
|
|
553
|
+
/** Task has started. */
|
|
554
|
+
ListrTaskState$1["STARTED"] = "STARTED";
|
|
555
|
+
/** Task has been completed. */
|
|
556
|
+
ListrTaskState$1["COMPLETED"] = "COMPLETED";
|
|
557
|
+
/** Task has failed. */
|
|
558
|
+
ListrTaskState$1["FAILED"] = "FAILED";
|
|
559
|
+
/** Task has been skipped. */
|
|
560
|
+
ListrTaskState$1["SKIPPED"] = "SKIPPED";
|
|
561
|
+
/** Task is currently trying to rollback. */
|
|
562
|
+
ListrTaskState$1["ROLLING_BACK"] = "ROLLING_BACK";
|
|
563
|
+
/** Task has rolledback successfully after failing. */
|
|
564
|
+
ListrTaskState$1["ROLLED_BACK"] = "ROLLED_BACK";
|
|
565
|
+
/** Task is currently retrying. */
|
|
566
|
+
ListrTaskState$1["RETRY"] = "RETRY";
|
|
567
|
+
/** Task is currently paused. */
|
|
568
|
+
ListrTaskState$1["PAUSED"] = "PAUSED";
|
|
569
|
+
/** Task is currently trying to process a prompt. */
|
|
570
|
+
ListrTaskState$1["PROMPT"] = "PROMPT";
|
|
571
|
+
/** Task has successfully processed the prompt. */
|
|
572
|
+
ListrTaskState$1["PROMPT_COMPLETED"] = "PROMPT_COMPLETED";
|
|
573
|
+
/** Task has failed to process the prompt. */
|
|
574
|
+
ListrTaskState$1["PROMPT_FAILED"] = "PROMPT_FAILED";
|
|
575
|
+
return ListrTaskState$1;
|
|
576
|
+
}({});
|
|
577
|
+
var EventManager = class {
|
|
578
|
+
emitter = new eventemitter3_default();
|
|
579
|
+
emit(dispatch, args) {
|
|
580
|
+
this.emitter.emit(dispatch, args);
|
|
581
|
+
}
|
|
582
|
+
on(dispatch, handler) {
|
|
583
|
+
this.emitter.addListener(dispatch, handler);
|
|
584
|
+
}
|
|
585
|
+
once(dispatch, handler) {
|
|
586
|
+
this.emitter.once(dispatch, handler);
|
|
587
|
+
}
|
|
588
|
+
off(dispatch, handler) {
|
|
589
|
+
this.emitter.off(dispatch, handler);
|
|
590
|
+
}
|
|
591
|
+
complete() {
|
|
592
|
+
this.emitter.removeAllListeners();
|
|
593
|
+
}
|
|
594
|
+
};
|
|
595
|
+
/**
|
|
596
|
+
* Tests to see if the object is an RxJS {@link Observable}
|
|
597
|
+
* @param obj the object to test
|
|
598
|
+
*/
|
|
599
|
+
function isObservable(obj) {
|
|
600
|
+
return !!obj && typeof obj === "object" && typeof obj.subscribe === "function";
|
|
601
|
+
}
|
|
602
|
+
/**
|
|
603
|
+
* Tests to see if the object is an Readable or NodeJS.ReadableStream {@link Readable, NodeJS.ReadableStream}
|
|
604
|
+
* @param obj the object to test
|
|
605
|
+
*/
|
|
606
|
+
function isReadable(obj) {
|
|
607
|
+
return !!obj && typeof obj === "object" && obj.readable === true && typeof obj.read === "function" && typeof obj.on === "function";
|
|
608
|
+
}
|
|
609
|
+
function isUnicodeSupported() {
|
|
610
|
+
/* istanbul ignore next */
|
|
611
|
+
return !!process.env[ListrEnvironmentVariables.FORCE_UNICODE] || process.platform !== "win32" || !!process.env.CI || !!process.env.WT_SESSION || process.env.TERM_PROGRAM === "vscode" || process.env.TERM === "xterm-256color" || process.env.TERM === "alacritty";
|
|
612
|
+
}
|
|
613
|
+
const CLEAR_LINE_REGEX = "(?:\\u001b|\\u009b)\\[[\\=><~/#&.:=?%@~_-]*[0-9]*[\\a-ln-tqyz=><~/#&.:=?%@~_-]+";
|
|
614
|
+
const BELL_REGEX = /\u0007/;
|
|
615
|
+
function cleanseAnsi(chunk) {
|
|
616
|
+
return String(chunk).replace(new RegExp(CLEAR_LINE_REGEX, "gmi"), "").replace(new RegExp(BELL_REGEX, "gmi"), "").trim();
|
|
617
|
+
}
|
|
618
|
+
/**
|
|
619
|
+
* Creates color palette through underlying dependency of `colorette`.
|
|
620
|
+
*
|
|
621
|
+
* @see {@link https://www.npmjs.com/package/colorette}
|
|
622
|
+
*/
|
|
623
|
+
const color = createColors();
|
|
624
|
+
function indent(string, count) {
|
|
625
|
+
return string.replace(/^(?!\s*$)/gm, " ".repeat(count));
|
|
626
|
+
}
|
|
627
|
+
const FIGURES_MAIN = {
|
|
628
|
+
warning: "⚠",
|
|
629
|
+
cross: "✖",
|
|
630
|
+
arrowDown: "↓",
|
|
631
|
+
tick: "✔",
|
|
632
|
+
arrowRight: "→",
|
|
633
|
+
pointer: "❯",
|
|
634
|
+
checkboxOn: "☒",
|
|
635
|
+
arrowLeft: "←",
|
|
636
|
+
squareSmallFilled: "◼",
|
|
637
|
+
pointerSmall: "›"
|
|
638
|
+
};
|
|
639
|
+
const FIGURES_FALLBACK = {
|
|
640
|
+
...FIGURES_MAIN,
|
|
641
|
+
warning: "‼",
|
|
642
|
+
cross: "×",
|
|
643
|
+
tick: "√",
|
|
644
|
+
pointer: ">",
|
|
645
|
+
checkboxOn: "[×]",
|
|
646
|
+
squareSmallFilled: "■"
|
|
647
|
+
};
|
|
648
|
+
const figures = isUnicodeSupported() ? FIGURES_MAIN : FIGURES_FALLBACK;
|
|
649
|
+
function splat(message, ...splat$1) {
|
|
650
|
+
return format(String(message), ...splat$1);
|
|
651
|
+
}
|
|
652
|
+
/** Default ListrLogLevels for the logger */
|
|
653
|
+
let ListrLogLevels = /* @__PURE__ */ function(ListrLogLevels$1) {
|
|
654
|
+
ListrLogLevels$1["STARTED"] = "STARTED";
|
|
655
|
+
ListrLogLevels$1["COMPLETED"] = "COMPLETED";
|
|
656
|
+
ListrLogLevels$1["FAILED"] = "FAILED";
|
|
657
|
+
ListrLogLevels$1["SKIPPED"] = "SKIPPED";
|
|
658
|
+
ListrLogLevels$1["OUTPUT"] = "OUTPUT";
|
|
659
|
+
ListrLogLevels$1["TITLE"] = "TITLE";
|
|
660
|
+
ListrLogLevels$1["ROLLBACK"] = "ROLLBACK";
|
|
661
|
+
ListrLogLevels$1["RETRY"] = "RETRY";
|
|
662
|
+
ListrLogLevels$1["PROMPT"] = "PROMPT";
|
|
663
|
+
ListrLogLevels$1["PAUSED"] = "PAUSED";
|
|
664
|
+
return ListrLogLevels$1;
|
|
665
|
+
}({});
|
|
666
|
+
const LISTR_LOGGER_STYLE = {
|
|
667
|
+
icon: {
|
|
668
|
+
[ListrLogLevels.STARTED]: figures.pointer,
|
|
669
|
+
[ListrLogLevels.FAILED]: figures.cross,
|
|
670
|
+
[ListrLogLevels.SKIPPED]: figures.arrowDown,
|
|
671
|
+
[ListrLogLevels.COMPLETED]: figures.tick,
|
|
672
|
+
[ListrLogLevels.OUTPUT]: figures.pointerSmall,
|
|
673
|
+
[ListrLogLevels.TITLE]: figures.arrowRight,
|
|
674
|
+
[ListrLogLevels.RETRY]: figures.warning,
|
|
675
|
+
[ListrLogLevels.ROLLBACK]: figures.arrowLeft,
|
|
676
|
+
[ListrLogLevels.PAUSED]: figures.squareSmallFilled
|
|
677
|
+
},
|
|
678
|
+
color: {
|
|
679
|
+
[ListrLogLevels.STARTED]: color.yellow,
|
|
680
|
+
[ListrLogLevels.FAILED]: color.red,
|
|
681
|
+
[ListrLogLevels.SKIPPED]: color.yellow,
|
|
682
|
+
[ListrLogLevels.COMPLETED]: color.green,
|
|
683
|
+
[ListrLogLevels.RETRY]: color.yellowBright,
|
|
684
|
+
[ListrLogLevels.ROLLBACK]: color.redBright,
|
|
685
|
+
[ListrLogLevels.PAUSED]: color.yellowBright
|
|
686
|
+
}
|
|
687
|
+
};
|
|
688
|
+
const LISTR_LOGGER_STDERR_LEVELS = [
|
|
689
|
+
ListrLogLevels.RETRY,
|
|
690
|
+
ListrLogLevels.ROLLBACK,
|
|
691
|
+
ListrLogLevels.FAILED
|
|
692
|
+
];
|
|
693
|
+
/**
|
|
694
|
+
* Creates a new Listr2 logger.
|
|
695
|
+
*
|
|
696
|
+
* This logger is used throughout the renderers for consistency.
|
|
697
|
+
*
|
|
698
|
+
* @see {@link https://listr2.kilic.dev/renderer/logger.html}
|
|
699
|
+
*/
|
|
700
|
+
var ListrLogger = class {
|
|
701
|
+
process;
|
|
702
|
+
constructor(options) {
|
|
703
|
+
this.options = options;
|
|
704
|
+
this.options = {
|
|
705
|
+
useIcons: true,
|
|
706
|
+
toStderr: [],
|
|
707
|
+
...options ?? {}
|
|
708
|
+
};
|
|
709
|
+
this.options.fields ??= {};
|
|
710
|
+
this.options.fields.prefix ??= [];
|
|
711
|
+
this.options.fields.suffix ??= [];
|
|
712
|
+
this.process = this.options.processOutput ?? new ProcessOutput();
|
|
713
|
+
}
|
|
714
|
+
log(level, message, options) {
|
|
715
|
+
const output = this.format(level, message, options);
|
|
716
|
+
if (this.options.toStderr.includes(level)) {
|
|
717
|
+
this.process.toStderr(output);
|
|
718
|
+
return;
|
|
719
|
+
}
|
|
720
|
+
this.process.toStdout(output);
|
|
721
|
+
}
|
|
722
|
+
toStdout(message, options, eol = true) {
|
|
723
|
+
this.process.toStdout(this.format(null, message, options), eol);
|
|
724
|
+
}
|
|
725
|
+
toStderr(message, options, eol = true) {
|
|
726
|
+
this.process.toStderr(this.format(null, message, options), eol);
|
|
727
|
+
}
|
|
728
|
+
wrap(message, options) {
|
|
729
|
+
if (!message) return message;
|
|
730
|
+
return this.applyFormat(`[${message}]`, options);
|
|
731
|
+
}
|
|
732
|
+
splat(...args) {
|
|
733
|
+
const message = args.shift() ?? "";
|
|
734
|
+
return args.length === 0 ? message : splat(message, args);
|
|
735
|
+
}
|
|
736
|
+
suffix(message, ...suffixes) {
|
|
737
|
+
suffixes.filter(Boolean).forEach((suffix) => {
|
|
738
|
+
message += this.spacing(message);
|
|
739
|
+
if (typeof suffix === "string") message += this.wrap(suffix);
|
|
740
|
+
else if (typeof suffix === "object") {
|
|
741
|
+
suffix.args ??= [];
|
|
742
|
+
if (typeof suffix.condition === "function" ? !suffix.condition(...suffix.args) : !(suffix.condition ?? true)) return message;
|
|
743
|
+
message += this.wrap(typeof suffix.field === "function" ? suffix.field(...suffix.args) : suffix.field, { format: suffix?.format(...suffix.args) });
|
|
744
|
+
}
|
|
745
|
+
});
|
|
746
|
+
return message;
|
|
747
|
+
}
|
|
748
|
+
prefix(message, ...prefixes) {
|
|
749
|
+
prefixes.filter(Boolean).forEach((prefix) => {
|
|
750
|
+
message = this.spacing(message) + message;
|
|
751
|
+
if (typeof prefix === "string") message = this.wrap(prefix) + message;
|
|
752
|
+
else if (typeof prefix === "object") {
|
|
753
|
+
prefix.args ??= [];
|
|
754
|
+
if (typeof prefix.condition === "function" ? !prefix.condition(...prefix.args) : !(prefix.condition ?? true)) return message;
|
|
755
|
+
message = this.wrap(typeof prefix.field === "function" ? prefix.field(...prefix.args) : prefix.field, { format: prefix?.format() }) + message;
|
|
756
|
+
}
|
|
757
|
+
});
|
|
758
|
+
return message;
|
|
759
|
+
}
|
|
760
|
+
fields(message, options) {
|
|
761
|
+
if (this.options?.fields?.prefix) message = this.prefix(message, ...this.options.fields.prefix);
|
|
762
|
+
if (options?.prefix) message = this.prefix(message, ...options.prefix);
|
|
763
|
+
if (options?.suffix) message = this.suffix(message, ...options.suffix);
|
|
764
|
+
if (this.options?.fields?.suffix) message = this.suffix(message, ...this.options.fields.suffix);
|
|
765
|
+
return message;
|
|
766
|
+
}
|
|
767
|
+
icon(level, icon) {
|
|
768
|
+
if (!level) return null;
|
|
769
|
+
if (!icon) {
|
|
770
|
+
const i = this.options.icon?.[level];
|
|
771
|
+
icon = typeof i === "function" ? i() : i;
|
|
772
|
+
}
|
|
773
|
+
const coloring = this.options.color?.[level];
|
|
774
|
+
if (icon && coloring) icon = coloring(icon);
|
|
775
|
+
return icon;
|
|
776
|
+
}
|
|
777
|
+
format(level, message, options) {
|
|
778
|
+
if (!Array.isArray(message)) message = [message];
|
|
779
|
+
message = this.splat(message.shift(), ...message).toString().split(EOL).filter((m) => !m || m.trim() !== "").map((m) => {
|
|
780
|
+
return this.style(level, this.fields(m, {
|
|
781
|
+
prefix: Array.isArray(options?.prefix) ? options.prefix : [options?.prefix],
|
|
782
|
+
suffix: Array.isArray(options?.suffix) ? options.suffix : [options?.suffix]
|
|
783
|
+
}));
|
|
784
|
+
}).join(EOL);
|
|
785
|
+
return message;
|
|
786
|
+
}
|
|
787
|
+
style(level, message) {
|
|
788
|
+
if (!level || !message) return message;
|
|
789
|
+
const icon = this.icon(level, !this.options.useIcons && this.wrap(level));
|
|
790
|
+
if (icon) message = icon + " " + message;
|
|
791
|
+
return message;
|
|
792
|
+
}
|
|
793
|
+
applyFormat(message, options) {
|
|
794
|
+
if (options?.format) return options.format(message);
|
|
795
|
+
return message;
|
|
796
|
+
}
|
|
797
|
+
spacing(message) {
|
|
798
|
+
return typeof message === "undefined" || message.trim() === "" ? "" : " ";
|
|
799
|
+
}
|
|
800
|
+
};
|
|
801
|
+
var ProcessOutputBuffer = class {
|
|
802
|
+
buffer = [];
|
|
803
|
+
decoder = new StringDecoder();
|
|
804
|
+
constructor(options) {
|
|
805
|
+
this.options = options;
|
|
806
|
+
}
|
|
807
|
+
get all() {
|
|
808
|
+
return this.buffer;
|
|
809
|
+
}
|
|
810
|
+
get last() {
|
|
811
|
+
return this.buffer.at(-1);
|
|
812
|
+
}
|
|
813
|
+
get length() {
|
|
814
|
+
return this.buffer.length;
|
|
815
|
+
}
|
|
816
|
+
write(data, ...args) {
|
|
817
|
+
const callback = args[args.length - 1];
|
|
818
|
+
this.buffer.push({
|
|
819
|
+
time: Date.now(),
|
|
820
|
+
stream: this.options?.stream,
|
|
821
|
+
entry: this.decoder.write(typeof data === "string" ? Buffer.from(data, typeof args[0] === "string" ? args[0] : void 0) : Buffer.from(data))
|
|
822
|
+
});
|
|
823
|
+
if (this.options?.limit) this.buffer = this.buffer.slice(-this.options.limit);
|
|
824
|
+
if (typeof callback === "function") callback();
|
|
825
|
+
return true;
|
|
826
|
+
}
|
|
827
|
+
reset() {
|
|
828
|
+
this.buffer = [];
|
|
829
|
+
}
|
|
830
|
+
};
|
|
831
|
+
var ProcessOutputStream = class {
|
|
832
|
+
method;
|
|
833
|
+
buffer;
|
|
834
|
+
constructor(stream) {
|
|
835
|
+
this.stream = stream;
|
|
836
|
+
this.method = stream.write;
|
|
837
|
+
this.buffer = new ProcessOutputBuffer({ stream });
|
|
838
|
+
}
|
|
839
|
+
get out() {
|
|
840
|
+
return Object.assign({}, this.stream, { write: this.write.bind(this) });
|
|
841
|
+
}
|
|
842
|
+
hijack() {
|
|
843
|
+
this.stream.write = this.buffer.write.bind(this.buffer);
|
|
844
|
+
}
|
|
845
|
+
release() {
|
|
846
|
+
this.stream.write = this.method;
|
|
847
|
+
const buffer = [...this.buffer.all];
|
|
848
|
+
this.buffer.reset();
|
|
849
|
+
return buffer;
|
|
850
|
+
}
|
|
851
|
+
write(...args) {
|
|
852
|
+
return this.method.apply(this.stream, args);
|
|
853
|
+
}
|
|
854
|
+
};
|
|
855
|
+
/**
|
|
856
|
+
* Creates a new Listr2 process-output controller.
|
|
857
|
+
*
|
|
858
|
+
* This is used to control the flow to `process.stdout` and `process.stderr` for all renderers.
|
|
859
|
+
*
|
|
860
|
+
* @see {@link https://listr2.kilic.dev/renderer/process-output.html}
|
|
861
|
+
*/
|
|
862
|
+
var ProcessOutput = class {
|
|
863
|
+
stream;
|
|
864
|
+
active;
|
|
865
|
+
constructor(stdout, stderr, options) {
|
|
866
|
+
this.options = options;
|
|
867
|
+
this.stream = {
|
|
868
|
+
stdout: new ProcessOutputStream(stdout ?? process.stdout),
|
|
869
|
+
stderr: new ProcessOutputStream(stderr ?? process.stderr)
|
|
870
|
+
};
|
|
871
|
+
this.options = {
|
|
872
|
+
dump: ["stdout", "stderr"],
|
|
873
|
+
leaveEmptyLine: true,
|
|
874
|
+
...options
|
|
875
|
+
};
|
|
876
|
+
}
|
|
877
|
+
get stdout() {
|
|
878
|
+
return this.stream.stdout.out;
|
|
879
|
+
}
|
|
880
|
+
get stderr() {
|
|
881
|
+
return this.stream.stderr.out;
|
|
882
|
+
}
|
|
883
|
+
hijack() {
|
|
884
|
+
if (this.active) throw new Error("ProcessOutput has been already hijacked!");
|
|
885
|
+
this.stream.stdout.write(ANSI_ESCAPE_CODES.CURSOR_HIDE);
|
|
886
|
+
Object.values(this.stream).forEach((stream) => stream.hijack());
|
|
887
|
+
this.active = true;
|
|
888
|
+
}
|
|
889
|
+
release() {
|
|
890
|
+
const output = Object.entries(this.stream).map(([name, stream]) => ({
|
|
891
|
+
name,
|
|
892
|
+
buffer: stream.release()
|
|
893
|
+
})).filter((output$1) => this.options.dump.includes(output$1.name)).flatMap((output$1) => output$1.buffer).sort((a, b) => a.time - b.time).map((message) => {
|
|
894
|
+
return {
|
|
895
|
+
...message,
|
|
896
|
+
entry: cleanseAnsi(message.entry)
|
|
897
|
+
};
|
|
898
|
+
}).filter((message) => message.entry);
|
|
899
|
+
if (output.length > 0) {
|
|
900
|
+
if (this.options.leaveEmptyLine) this.stdout.write(EOL);
|
|
901
|
+
output.forEach((message) => {
|
|
902
|
+
(message.stream ?? this.stdout).write(message.entry + EOL);
|
|
903
|
+
});
|
|
904
|
+
}
|
|
905
|
+
this.stream.stdout.write(ANSI_ESCAPE_CODES.CURSOR_SHOW);
|
|
906
|
+
this.active = false;
|
|
907
|
+
}
|
|
908
|
+
toStdout(buffer, eol = true) {
|
|
909
|
+
if (eol) buffer = buffer + EOL;
|
|
910
|
+
return this.stream.stdout.write(buffer);
|
|
911
|
+
}
|
|
912
|
+
toStderr(buffer, eol = true) {
|
|
913
|
+
if (eol) buffer = buffer + EOL;
|
|
914
|
+
return this.stream.stderr.write(buffer);
|
|
915
|
+
}
|
|
916
|
+
};
|
|
917
|
+
/* istanbul ignore next */
|
|
918
|
+
function createWritable(cb) {
|
|
919
|
+
const writable = new Writable();
|
|
920
|
+
writable.rows = Infinity;
|
|
921
|
+
writable.columns = Infinity;
|
|
922
|
+
writable.write = (chunk) => {
|
|
923
|
+
cb(chunk.toString());
|
|
924
|
+
return true;
|
|
925
|
+
};
|
|
926
|
+
return writable;
|
|
927
|
+
}
|
|
928
|
+
/* istanbul ignore next */
|
|
929
|
+
var Spinner = class {
|
|
930
|
+
spinner = !isUnicodeSupported() ? [
|
|
931
|
+
"-",
|
|
932
|
+
"\\",
|
|
933
|
+
"|",
|
|
934
|
+
"/"
|
|
935
|
+
] : [
|
|
936
|
+
"⠋",
|
|
937
|
+
"⠙",
|
|
938
|
+
"⠹",
|
|
939
|
+
"⠸",
|
|
940
|
+
"⠼",
|
|
941
|
+
"⠴",
|
|
942
|
+
"⠦",
|
|
943
|
+
"⠧",
|
|
944
|
+
"⠇",
|
|
945
|
+
"⠏"
|
|
946
|
+
];
|
|
947
|
+
id;
|
|
948
|
+
spinnerPosition = 0;
|
|
949
|
+
spin() {
|
|
950
|
+
this.spinnerPosition = ++this.spinnerPosition % this.spinner.length;
|
|
951
|
+
}
|
|
952
|
+
fetch() {
|
|
953
|
+
return this.spinner[this.spinnerPosition];
|
|
954
|
+
}
|
|
955
|
+
isRunning() {
|
|
956
|
+
return !!this.id;
|
|
957
|
+
}
|
|
958
|
+
start(cb, interval = 100) {
|
|
959
|
+
this.id = setInterval(() => {
|
|
960
|
+
this.spin();
|
|
961
|
+
if (cb) cb();
|
|
962
|
+
}, interval);
|
|
963
|
+
}
|
|
964
|
+
stop() {
|
|
965
|
+
clearInterval(this.id);
|
|
966
|
+
}
|
|
967
|
+
};
|
|
968
|
+
let ListrDefaultRendererLogLevels = /* @__PURE__ */ function(ListrDefaultRendererLogLevels$1) {
|
|
969
|
+
ListrDefaultRendererLogLevels$1["SKIPPED_WITH_COLLAPSE"] = "SKIPPED_WITH_COLLAPSE";
|
|
970
|
+
ListrDefaultRendererLogLevels$1["SKIPPED_WITHOUT_COLLAPSE"] = "SKIPPED_WITHOUT_COLLAPSE";
|
|
971
|
+
ListrDefaultRendererLogLevels$1["OUTPUT"] = "OUTPUT";
|
|
972
|
+
ListrDefaultRendererLogLevels$1["OUTPUT_WITH_BOTTOMBAR"] = "OUTPUT_WITH_BOTTOMBAR";
|
|
973
|
+
ListrDefaultRendererLogLevels$1["PENDING"] = "PENDING";
|
|
974
|
+
ListrDefaultRendererLogLevels$1["COMPLETED"] = "COMPLETED";
|
|
975
|
+
ListrDefaultRendererLogLevels$1["COMPLETED_WITH_FAILED_SUBTASKS"] = "COMPLETED_WITH_FAILED_SUBTASKS";
|
|
976
|
+
ListrDefaultRendererLogLevels$1["COMPLETED_WITH_FAILED_SISTER_TASKS"] = "COMPLETED_WITH_SISTER_TASKS_FAILED";
|
|
977
|
+
ListrDefaultRendererLogLevels$1["RETRY"] = "RETRY";
|
|
978
|
+
ListrDefaultRendererLogLevels$1["ROLLING_BACK"] = "ROLLING_BACK";
|
|
979
|
+
ListrDefaultRendererLogLevels$1["ROLLED_BACK"] = "ROLLED_BACK";
|
|
980
|
+
ListrDefaultRendererLogLevels$1["FAILED"] = "FAILED";
|
|
981
|
+
ListrDefaultRendererLogLevels$1["FAILED_WITH_FAILED_SUBTASKS"] = "FAILED_WITH_SUBTASKS";
|
|
982
|
+
ListrDefaultRendererLogLevels$1["WAITING"] = "WAITING";
|
|
983
|
+
ListrDefaultRendererLogLevels$1["PAUSED"] = "PAUSED";
|
|
984
|
+
return ListrDefaultRendererLogLevels$1;
|
|
985
|
+
}({});
|
|
986
|
+
const LISTR_DEFAULT_RENDERER_STYLE = {
|
|
987
|
+
icon: {
|
|
988
|
+
[ListrDefaultRendererLogLevels.SKIPPED_WITH_COLLAPSE]: figures.arrowDown,
|
|
989
|
+
[ListrDefaultRendererLogLevels.SKIPPED_WITHOUT_COLLAPSE]: figures.warning,
|
|
990
|
+
[ListrDefaultRendererLogLevels.OUTPUT]: figures.pointerSmall,
|
|
991
|
+
[ListrDefaultRendererLogLevels.OUTPUT_WITH_BOTTOMBAR]: figures.pointerSmall,
|
|
992
|
+
[ListrDefaultRendererLogLevels.PENDING]: figures.pointer,
|
|
993
|
+
[ListrDefaultRendererLogLevels.COMPLETED]: figures.tick,
|
|
994
|
+
[ListrDefaultRendererLogLevels.COMPLETED_WITH_FAILED_SUBTASKS]: figures.warning,
|
|
995
|
+
[ListrDefaultRendererLogLevels.COMPLETED_WITH_FAILED_SISTER_TASKS]: figures.squareSmallFilled,
|
|
996
|
+
[ListrDefaultRendererLogLevels.RETRY]: figures.warning,
|
|
997
|
+
[ListrDefaultRendererLogLevels.ROLLING_BACK]: figures.warning,
|
|
998
|
+
[ListrDefaultRendererLogLevels.ROLLED_BACK]: figures.arrowLeft,
|
|
999
|
+
[ListrDefaultRendererLogLevels.FAILED]: figures.cross,
|
|
1000
|
+
[ListrDefaultRendererLogLevels.FAILED_WITH_FAILED_SUBTASKS]: figures.pointer,
|
|
1001
|
+
[ListrDefaultRendererLogLevels.WAITING]: figures.squareSmallFilled,
|
|
1002
|
+
[ListrDefaultRendererLogLevels.PAUSED]: figures.squareSmallFilled
|
|
1003
|
+
},
|
|
1004
|
+
color: {
|
|
1005
|
+
[ListrDefaultRendererLogLevels.SKIPPED_WITH_COLLAPSE]: color.yellow,
|
|
1006
|
+
[ListrDefaultRendererLogLevels.SKIPPED_WITHOUT_COLLAPSE]: color.yellow,
|
|
1007
|
+
[ListrDefaultRendererLogLevels.PENDING]: color.yellow,
|
|
1008
|
+
[ListrDefaultRendererLogLevels.COMPLETED]: color.green,
|
|
1009
|
+
[ListrDefaultRendererLogLevels.COMPLETED_WITH_FAILED_SUBTASKS]: color.yellow,
|
|
1010
|
+
[ListrDefaultRendererLogLevels.COMPLETED_WITH_FAILED_SISTER_TASKS]: color.red,
|
|
1011
|
+
[ListrDefaultRendererLogLevels.RETRY]: color.yellowBright,
|
|
1012
|
+
[ListrDefaultRendererLogLevels.ROLLING_BACK]: color.redBright,
|
|
1013
|
+
[ListrDefaultRendererLogLevels.ROLLED_BACK]: color.redBright,
|
|
1014
|
+
[ListrDefaultRendererLogLevels.FAILED]: color.red,
|
|
1015
|
+
[ListrDefaultRendererLogLevels.FAILED_WITH_FAILED_SUBTASKS]: color.red,
|
|
1016
|
+
[ListrDefaultRendererLogLevels.WAITING]: color.dim,
|
|
1017
|
+
[ListrDefaultRendererLogLevels.PAUSED]: color.yellowBright
|
|
1018
|
+
}
|
|
1019
|
+
};
|
|
1020
|
+
/**
|
|
1021
|
+
* A basic function to parse minutes and tasks passed given a duration.
|
|
1022
|
+
* Useful for renderers to show the task time.
|
|
1023
|
+
*/
|
|
1024
|
+
/* istanbul ignore next */
|
|
1025
|
+
function parseTimer(duration) {
|
|
1026
|
+
const seconds = Math.floor(duration / 1e3);
|
|
1027
|
+
const minutes = Math.floor(seconds / 60);
|
|
1028
|
+
let parsedTime;
|
|
1029
|
+
if (seconds === 0 && minutes === 0) parsedTime = `0.${Math.floor(duration / 100)}s`;
|
|
1030
|
+
if (seconds > 0) parsedTime = `${seconds % 60}s`;
|
|
1031
|
+
if (minutes > 0) parsedTime = `${minutes}m${parsedTime}`;
|
|
1032
|
+
return parsedTime;
|
|
1033
|
+
}
|
|
1034
|
+
/* istanbul ignore next */
|
|
1035
|
+
const PRESET_TIMER = {
|
|
1036
|
+
condition: true,
|
|
1037
|
+
field: parseTimer,
|
|
1038
|
+
format: () => color.dim
|
|
1039
|
+
};
|
|
1040
|
+
var DefaultRenderer = class DefaultRenderer$1 {
|
|
1041
|
+
static nonTTY = false;
|
|
1042
|
+
static rendererOptions = {
|
|
1043
|
+
indentation: 2,
|
|
1044
|
+
clearOutput: false,
|
|
1045
|
+
showSubtasks: true,
|
|
1046
|
+
collapseSubtasks: true,
|
|
1047
|
+
collapseSkips: true,
|
|
1048
|
+
showSkipMessage: true,
|
|
1049
|
+
suffixSkips: false,
|
|
1050
|
+
collapseErrors: true,
|
|
1051
|
+
showErrorMessage: true,
|
|
1052
|
+
suffixRetries: true,
|
|
1053
|
+
lazy: false,
|
|
1054
|
+
removeEmptyLines: true,
|
|
1055
|
+
formatOutput: "wrap",
|
|
1056
|
+
pausedTimer: {
|
|
1057
|
+
...PRESET_TIMER,
|
|
1058
|
+
format: () => color.yellowBright
|
|
1059
|
+
}
|
|
1060
|
+
};
|
|
1061
|
+
static rendererTaskOptions = { outputBar: true };
|
|
1062
|
+
prompt;
|
|
1063
|
+
activePrompt;
|
|
1064
|
+
spinner;
|
|
1065
|
+
logger;
|
|
1066
|
+
updater;
|
|
1067
|
+
truncate;
|
|
1068
|
+
wrap;
|
|
1069
|
+
buffer = {
|
|
1070
|
+
output: /* @__PURE__ */ new Map(),
|
|
1071
|
+
bottom: /* @__PURE__ */ new Map()
|
|
1072
|
+
};
|
|
1073
|
+
cache = {
|
|
1074
|
+
render: /* @__PURE__ */ new Map(),
|
|
1075
|
+
rendererOptions: /* @__PURE__ */ new Map(),
|
|
1076
|
+
rendererTaskOptions: /* @__PURE__ */ new Map()
|
|
1077
|
+
};
|
|
1078
|
+
constructor(tasks, options, events) {
|
|
1079
|
+
this.tasks = tasks;
|
|
1080
|
+
this.options = options;
|
|
1081
|
+
this.events = events;
|
|
1082
|
+
this.options = {
|
|
1083
|
+
...DefaultRenderer$1.rendererOptions,
|
|
1084
|
+
...this.options,
|
|
1085
|
+
icon: {
|
|
1086
|
+
...LISTR_DEFAULT_RENDERER_STYLE.icon,
|
|
1087
|
+
...options?.icon ?? {}
|
|
1088
|
+
},
|
|
1089
|
+
color: {
|
|
1090
|
+
...LISTR_DEFAULT_RENDERER_STYLE.color,
|
|
1091
|
+
...options?.color ?? {}
|
|
1092
|
+
}
|
|
1093
|
+
};
|
|
1094
|
+
this.spinner = this.options.spinner ?? new Spinner();
|
|
1095
|
+
this.logger = this.options.logger ?? new ListrLogger({
|
|
1096
|
+
useIcons: true,
|
|
1097
|
+
toStderr: []
|
|
1098
|
+
});
|
|
1099
|
+
this.logger.options.icon = this.options.icon;
|
|
1100
|
+
this.logger.options.color = this.options.color;
|
|
1101
|
+
}
|
|
1102
|
+
async render() {
|
|
1103
|
+
const { createLogUpdate } = await import("./log-update-C7F4wEC4.mjs");
|
|
1104
|
+
const { default: truncate } = await import("./cli-truncate-D9-H5ZcK.mjs");
|
|
1105
|
+
const { default: wrap } = await import("./wrap-ansi-B5Z_xwBN.mjs");
|
|
1106
|
+
this.updater = createLogUpdate(this.logger.process.stdout);
|
|
1107
|
+
this.truncate = truncate;
|
|
1108
|
+
this.wrap = wrap;
|
|
1109
|
+
this.logger.process.hijack();
|
|
1110
|
+
/* istanbul ignore if */
|
|
1111
|
+
if (!this.options?.lazy) this.spinner.start(() => {
|
|
1112
|
+
this.update();
|
|
1113
|
+
});
|
|
1114
|
+
this.events.on(ListrEventType.SHOULD_REFRESH_RENDER, () => {
|
|
1115
|
+
this.update();
|
|
1116
|
+
});
|
|
1117
|
+
}
|
|
1118
|
+
update() {
|
|
1119
|
+
this.updater(this.create());
|
|
1120
|
+
}
|
|
1121
|
+
end() {
|
|
1122
|
+
this.spinner.stop();
|
|
1123
|
+
this.updater.clear();
|
|
1124
|
+
this.updater.done();
|
|
1125
|
+
if (!this.options.clearOutput) this.logger.process.toStdout(this.create({ prompt: false }));
|
|
1126
|
+
this.logger.process.release();
|
|
1127
|
+
}
|
|
1128
|
+
create(options) {
|
|
1129
|
+
options = {
|
|
1130
|
+
tasks: true,
|
|
1131
|
+
bottomBar: true,
|
|
1132
|
+
prompt: true,
|
|
1133
|
+
...options
|
|
1134
|
+
};
|
|
1135
|
+
const render = [];
|
|
1136
|
+
const renderTasks = this.renderer(this.tasks);
|
|
1137
|
+
const renderBottomBar = this.renderBottomBar();
|
|
1138
|
+
const renderPrompt = this.renderPrompt();
|
|
1139
|
+
if (options.tasks && renderTasks.length > 0) render.push(...renderTasks);
|
|
1140
|
+
if (options.bottomBar && renderBottomBar.length > 0) {
|
|
1141
|
+
if (render.length > 0) render.push("");
|
|
1142
|
+
render.push(...renderBottomBar);
|
|
1143
|
+
}
|
|
1144
|
+
if (options.prompt && renderPrompt.length > 0) {
|
|
1145
|
+
if (render.length > 0) render.push("");
|
|
1146
|
+
render.push(...renderPrompt);
|
|
1147
|
+
}
|
|
1148
|
+
return render.join(EOL);
|
|
1149
|
+
}
|
|
1150
|
+
style(task, output = false) {
|
|
1151
|
+
const rendererOptions = this.cache.rendererOptions.get(task.id);
|
|
1152
|
+
if (task.isSkipped()) {
|
|
1153
|
+
if (output || rendererOptions.collapseSkips) return this.logger.icon(ListrDefaultRendererLogLevels.SKIPPED_WITH_COLLAPSE);
|
|
1154
|
+
else if (rendererOptions.collapseSkips === false) return this.logger.icon(ListrDefaultRendererLogLevels.SKIPPED_WITHOUT_COLLAPSE);
|
|
1155
|
+
}
|
|
1156
|
+
if (output) {
|
|
1157
|
+
if (this.shouldOutputToBottomBar(task)) return this.logger.icon(ListrDefaultRendererLogLevels.OUTPUT_WITH_BOTTOMBAR);
|
|
1158
|
+
return this.logger.icon(ListrDefaultRendererLogLevels.OUTPUT);
|
|
1159
|
+
}
|
|
1160
|
+
if (task.hasSubtasks()) {
|
|
1161
|
+
if (task.isStarted() || task.isPrompt() && rendererOptions.showSubtasks !== false && !task.subtasks.every((subtask) => !subtask.hasTitle())) return this.logger.icon(ListrDefaultRendererLogLevels.PENDING);
|
|
1162
|
+
else if (task.isCompleted() && task.subtasks.some((subtask) => subtask.hasFailed())) return this.logger.icon(ListrDefaultRendererLogLevels.COMPLETED_WITH_FAILED_SUBTASKS);
|
|
1163
|
+
else if (task.hasFailed()) return this.logger.icon(ListrDefaultRendererLogLevels.FAILED_WITH_FAILED_SUBTASKS);
|
|
1164
|
+
}
|
|
1165
|
+
if (task.isStarted() || task.isPrompt()) return this.logger.icon(ListrDefaultRendererLogLevels.PENDING, !this.options?.lazy && this.spinner.fetch());
|
|
1166
|
+
else if (task.isCompleted()) return this.logger.icon(ListrDefaultRendererLogLevels.COMPLETED);
|
|
1167
|
+
else if (task.isRetrying()) return this.logger.icon(ListrDefaultRendererLogLevels.RETRY, !this.options?.lazy && this.spinner.fetch());
|
|
1168
|
+
else if (task.isRollingBack()) return this.logger.icon(ListrDefaultRendererLogLevels.ROLLING_BACK, !this.options?.lazy && this.spinner.fetch());
|
|
1169
|
+
else if (task.hasRolledBack()) return this.logger.icon(ListrDefaultRendererLogLevels.ROLLED_BACK);
|
|
1170
|
+
else if (task.hasFailed()) return this.logger.icon(ListrDefaultRendererLogLevels.FAILED);
|
|
1171
|
+
else if (task.isPaused()) return this.logger.icon(ListrDefaultRendererLogLevels.PAUSED);
|
|
1172
|
+
return this.logger.icon(ListrDefaultRendererLogLevels.WAITING);
|
|
1173
|
+
}
|
|
1174
|
+
format(message, icon, level) {
|
|
1175
|
+
if (message.trim() === "") return [];
|
|
1176
|
+
if (icon) message = icon + " " + message;
|
|
1177
|
+
let parsed;
|
|
1178
|
+
const columns = (process.stdout.columns ?? 80) - level * this.options.indentation - 2;
|
|
1179
|
+
switch (this.options.formatOutput) {
|
|
1180
|
+
case "truncate":
|
|
1181
|
+
parsed = message.split(EOL).map((s, i) => {
|
|
1182
|
+
return this.truncate(this.indent(s, i), columns);
|
|
1183
|
+
});
|
|
1184
|
+
break;
|
|
1185
|
+
case "wrap":
|
|
1186
|
+
parsed = this.wrap(message, columns, {
|
|
1187
|
+
hard: true,
|
|
1188
|
+
trim: false
|
|
1189
|
+
}).split(EOL).map((s, i) => this.indent(s, i));
|
|
1190
|
+
break;
|
|
1191
|
+
default: throw new ListrRendererError("Format option for the renderer is wrong.");
|
|
1192
|
+
}
|
|
1193
|
+
if (this.options.removeEmptyLines) parsed = parsed.filter(Boolean);
|
|
1194
|
+
return parsed.map((str) => indent(str, level * this.options.indentation));
|
|
1195
|
+
}
|
|
1196
|
+
shouldOutputToOutputBar(task) {
|
|
1197
|
+
const outputBar = this.cache.rendererTaskOptions.get(task.id).outputBar;
|
|
1198
|
+
return typeof outputBar === "number" && outputBar !== 0 || typeof outputBar === "boolean" && outputBar !== false;
|
|
1199
|
+
}
|
|
1200
|
+
shouldOutputToBottomBar(task) {
|
|
1201
|
+
const bottomBar = this.cache.rendererTaskOptions.get(task.id).bottomBar;
|
|
1202
|
+
return typeof bottomBar === "number" && bottomBar !== 0 || typeof bottomBar === "boolean" && bottomBar !== false || !task.hasTitle();
|
|
1203
|
+
}
|
|
1204
|
+
renderer(tasks, level = 0) {
|
|
1205
|
+
return tasks.flatMap((task) => {
|
|
1206
|
+
if (!task.isEnabled()) return [];
|
|
1207
|
+
if (this.cache.render.has(task.id)) return this.cache.render.get(task.id);
|
|
1208
|
+
this.calculate(task);
|
|
1209
|
+
this.setupBuffer(task);
|
|
1210
|
+
const rendererOptions = this.cache.rendererOptions.get(task.id);
|
|
1211
|
+
const rendererTaskOptions = this.cache.rendererTaskOptions.get(task.id);
|
|
1212
|
+
const output = [];
|
|
1213
|
+
if (task.isPrompt()) {
|
|
1214
|
+
if (this.activePrompt && this.activePrompt !== task.id) throw new ListrRendererError("Only one prompt can be active at the given time, please re-evaluate your task design.");
|
|
1215
|
+
else if (!this.activePrompt) {
|
|
1216
|
+
task.on(ListrTaskEventType.PROMPT, (prompt) => {
|
|
1217
|
+
const cleansed = cleanseAnsi(prompt);
|
|
1218
|
+
if (cleansed) this.prompt = cleansed;
|
|
1219
|
+
});
|
|
1220
|
+
task.on(ListrTaskEventType.STATE, (state) => {
|
|
1221
|
+
if (state === ListrTaskState.PROMPT_COMPLETED || task.hasFinalized() || task.hasReset()) {
|
|
1222
|
+
this.prompt = null;
|
|
1223
|
+
this.activePrompt = null;
|
|
1224
|
+
task.off(ListrTaskEventType.PROMPT);
|
|
1225
|
+
}
|
|
1226
|
+
});
|
|
1227
|
+
this.activePrompt = task.id;
|
|
1228
|
+
}
|
|
1229
|
+
}
|
|
1230
|
+
if (task.hasTitle()) if (!(tasks.some((task$1) => task$1.hasFailed()) && !task.hasFailed() && task.options.exitOnError !== false && !(task.isCompleted() || task.isSkipped()))) if (task.hasFailed() && rendererOptions.collapseErrors) output.push(...this.format(!task.hasSubtasks() && task.message.error && rendererOptions.showErrorMessage ? task.message.error : task.title, this.style(task), level));
|
|
1231
|
+
else if (task.isSkipped() && rendererOptions.collapseSkips) output.push(...this.format(this.logger.suffix(task.message.skip && rendererOptions.showSkipMessage ? task.message.skip : task.title, {
|
|
1232
|
+
field: ListrLogLevels.SKIPPED,
|
|
1233
|
+
condition: rendererOptions.suffixSkips,
|
|
1234
|
+
format: () => color.dim
|
|
1235
|
+
}), this.style(task), level));
|
|
1236
|
+
else if (task.isRetrying()) output.push(...this.format(this.logger.suffix(task.title, {
|
|
1237
|
+
field: `${ListrLogLevels.RETRY}:${task.message.retry.count}`,
|
|
1238
|
+
format: () => color.yellow,
|
|
1239
|
+
condition: rendererOptions.suffixRetries
|
|
1240
|
+
}), this.style(task), level));
|
|
1241
|
+
else if (task.isCompleted() && task.hasTitle() && assertFunctionOrSelf(rendererTaskOptions.timer?.condition, task.message.duration)) output.push(...this.format(this.logger.suffix(task?.title, {
|
|
1242
|
+
...rendererTaskOptions.timer,
|
|
1243
|
+
args: [task.message.duration]
|
|
1244
|
+
}), this.style(task), level));
|
|
1245
|
+
else if (task.isPaused()) output.push(...this.format(this.logger.suffix(task.title, {
|
|
1246
|
+
...rendererOptions.pausedTimer,
|
|
1247
|
+
args: [task.message.paused - Date.now()]
|
|
1248
|
+
}), this.style(task), level));
|
|
1249
|
+
else output.push(...this.format(task.title, this.style(task), level));
|
|
1250
|
+
else output.push(...this.format(task.title, this.logger.icon(ListrDefaultRendererLogLevels.COMPLETED_WITH_FAILED_SISTER_TASKS), level));
|
|
1251
|
+
if (!task.hasSubtasks() || !rendererOptions.showSubtasks) {
|
|
1252
|
+
if (task.hasFailed() && rendererOptions.collapseErrors === false && (rendererOptions.showErrorMessage || !rendererOptions.showSubtasks)) output.push(...this.dump(task, level, ListrLogLevels.FAILED));
|
|
1253
|
+
else if (task.isSkipped() && rendererOptions.collapseSkips === false && (rendererOptions.showSkipMessage || !rendererOptions.showSubtasks)) output.push(...this.dump(task, level, ListrLogLevels.SKIPPED));
|
|
1254
|
+
}
|
|
1255
|
+
if (task.isPending() || rendererTaskOptions.persistentOutput) output.push(...this.renderOutputBar(task, level));
|
|
1256
|
+
if (rendererOptions.showSubtasks !== false && task.hasSubtasks() && (task.isPending() || task.hasFinalized() && !task.hasTitle() || task.isCompleted() && rendererOptions.collapseSubtasks === false && !task.subtasks.some((subtask) => this.cache.rendererOptions.get(subtask.id)?.collapseSubtasks === true) || task.subtasks.some((subtask) => this.cache.rendererOptions.get(subtask.id)?.collapseSubtasks === false) || task.subtasks.some((subtask) => subtask.hasFailed()) || task.subtasks.some((subtask) => subtask.hasRolledBack()))) {
|
|
1257
|
+
const subtaskLevel = !task.hasTitle() ? level : level + 1;
|
|
1258
|
+
const subtaskRender = this.renderer(task.subtasks, subtaskLevel);
|
|
1259
|
+
output.push(...subtaskRender);
|
|
1260
|
+
}
|
|
1261
|
+
if (task.hasFinalized()) {
|
|
1262
|
+
if (!rendererTaskOptions.persistentOutput) {
|
|
1263
|
+
this.buffer.bottom.delete(task.id);
|
|
1264
|
+
this.buffer.output.delete(task.id);
|
|
1265
|
+
}
|
|
1266
|
+
}
|
|
1267
|
+
if (task.isClosed()) {
|
|
1268
|
+
this.cache.render.set(task.id, output);
|
|
1269
|
+
this.reset(task);
|
|
1270
|
+
}
|
|
1271
|
+
return output;
|
|
1272
|
+
});
|
|
1273
|
+
}
|
|
1274
|
+
renderOutputBar(task, level) {
|
|
1275
|
+
const output = this.buffer.output.get(task.id);
|
|
1276
|
+
if (!output) return [];
|
|
1277
|
+
return output.all.flatMap((o) => this.dump(task, level, ListrLogLevels.OUTPUT, o.entry));
|
|
1278
|
+
}
|
|
1279
|
+
renderBottomBar() {
|
|
1280
|
+
if (this.buffer.bottom.size === 0) return [];
|
|
1281
|
+
return Array.from(this.buffer.bottom.values()).flatMap((output) => output.all).sort((a, b) => a.time - b.time).map((output) => output.entry);
|
|
1282
|
+
}
|
|
1283
|
+
renderPrompt() {
|
|
1284
|
+
if (!this.prompt) return [];
|
|
1285
|
+
return [this.prompt];
|
|
1286
|
+
}
|
|
1287
|
+
calculate(task) {
|
|
1288
|
+
if (this.cache.rendererOptions.has(task.id) && this.cache.rendererTaskOptions.has(task.id)) return;
|
|
1289
|
+
const rendererOptions = {
|
|
1290
|
+
...this.options,
|
|
1291
|
+
...task.rendererOptions
|
|
1292
|
+
};
|
|
1293
|
+
this.cache.rendererOptions.set(task.id, rendererOptions);
|
|
1294
|
+
this.cache.rendererTaskOptions.set(task.id, {
|
|
1295
|
+
...DefaultRenderer$1.rendererTaskOptions,
|
|
1296
|
+
timer: rendererOptions.timer,
|
|
1297
|
+
...task.rendererTaskOptions
|
|
1298
|
+
});
|
|
1299
|
+
}
|
|
1300
|
+
setupBuffer(task) {
|
|
1301
|
+
if (this.buffer.bottom.has(task.id) || this.buffer.output.has(task.id)) return;
|
|
1302
|
+
const rendererTaskOptions = this.cache.rendererTaskOptions.get(task.id);
|
|
1303
|
+
if (this.shouldOutputToBottomBar(task) && !this.buffer.bottom.has(task.id)) {
|
|
1304
|
+
this.buffer.bottom.set(task.id, new ProcessOutputBuffer({ limit: typeof rendererTaskOptions.bottomBar === "number" ? rendererTaskOptions.bottomBar : 1 }));
|
|
1305
|
+
task.on(ListrTaskEventType.OUTPUT, (output) => {
|
|
1306
|
+
const data = this.dump(task, -1, ListrLogLevels.OUTPUT, output);
|
|
1307
|
+
this.buffer.bottom.get(task.id).write(data.join(EOL));
|
|
1308
|
+
});
|
|
1309
|
+
task.on(ListrTaskEventType.STATE, (state) => {
|
|
1310
|
+
switch (state) {
|
|
1311
|
+
case ListrTaskState.RETRY || ListrTaskState.ROLLING_BACK:
|
|
1312
|
+
this.buffer.bottom.delete(task.id);
|
|
1313
|
+
break;
|
|
1314
|
+
}
|
|
1315
|
+
});
|
|
1316
|
+
} else if (this.shouldOutputToOutputBar(task) && !this.buffer.output.has(task.id)) {
|
|
1317
|
+
this.buffer.output.set(task.id, new ProcessOutputBuffer({ limit: typeof rendererTaskOptions.outputBar === "number" ? rendererTaskOptions.outputBar : 1 }));
|
|
1318
|
+
task.on(ListrTaskEventType.OUTPUT, (output) => {
|
|
1319
|
+
this.buffer.output.get(task.id).write(output);
|
|
1320
|
+
});
|
|
1321
|
+
task.on(ListrTaskEventType.STATE, (state) => {
|
|
1322
|
+
switch (state) {
|
|
1323
|
+
case ListrTaskState.RETRY || ListrTaskState.ROLLING_BACK:
|
|
1324
|
+
this.buffer.output.delete(task.id);
|
|
1325
|
+
break;
|
|
1326
|
+
}
|
|
1327
|
+
});
|
|
1328
|
+
}
|
|
1329
|
+
}
|
|
1330
|
+
reset(task) {
|
|
1331
|
+
this.cache.rendererOptions.delete(task.id);
|
|
1332
|
+
this.cache.rendererTaskOptions.delete(task.id);
|
|
1333
|
+
this.buffer.output.delete(task.id);
|
|
1334
|
+
}
|
|
1335
|
+
dump(task, level, source = ListrLogLevels.OUTPUT, data) {
|
|
1336
|
+
if (!data) switch (source) {
|
|
1337
|
+
case ListrLogLevels.OUTPUT:
|
|
1338
|
+
data = task.output;
|
|
1339
|
+
break;
|
|
1340
|
+
case ListrLogLevels.SKIPPED:
|
|
1341
|
+
data = task.message.skip;
|
|
1342
|
+
break;
|
|
1343
|
+
case ListrLogLevels.FAILED:
|
|
1344
|
+
data = task.message.error;
|
|
1345
|
+
break;
|
|
1346
|
+
}
|
|
1347
|
+
if (task.hasTitle() && source === ListrLogLevels.FAILED && data === task.title || typeof data !== "string") return [];
|
|
1348
|
+
if (source === ListrLogLevels.OUTPUT) data = cleanseAnsi(data);
|
|
1349
|
+
return this.format(data, this.style(task, true), level + 1);
|
|
1350
|
+
}
|
|
1351
|
+
indent(str, i) {
|
|
1352
|
+
return i > 0 ? indent(str.trimEnd(), this.options.indentation) : str.trimEnd();
|
|
1353
|
+
}
|
|
1354
|
+
};
|
|
1355
|
+
var SilentRenderer = class {
|
|
1356
|
+
static nonTTY = true;
|
|
1357
|
+
static rendererOptions;
|
|
1358
|
+
static rendererTaskOptions;
|
|
1359
|
+
constructor(tasks, options) {
|
|
1360
|
+
this.tasks = tasks;
|
|
1361
|
+
this.options = options;
|
|
1362
|
+
}
|
|
1363
|
+
render() {}
|
|
1364
|
+
end() {}
|
|
1365
|
+
};
|
|
1366
|
+
var SimpleRenderer = class SimpleRenderer$1 {
|
|
1367
|
+
static nonTTY = true;
|
|
1368
|
+
static rendererOptions = { pausedTimer: {
|
|
1369
|
+
...PRESET_TIMER,
|
|
1370
|
+
field: (time) => `${ListrLogLevels.PAUSED}:${time}`,
|
|
1371
|
+
format: () => color.yellowBright
|
|
1372
|
+
} };
|
|
1373
|
+
static rendererTaskOptions = {};
|
|
1374
|
+
logger;
|
|
1375
|
+
cache = {
|
|
1376
|
+
rendererOptions: /* @__PURE__ */ new Map(),
|
|
1377
|
+
rendererTaskOptions: /* @__PURE__ */ new Map()
|
|
1378
|
+
};
|
|
1379
|
+
constructor(tasks, options) {
|
|
1380
|
+
this.tasks = tasks;
|
|
1381
|
+
this.options = options;
|
|
1382
|
+
this.options = {
|
|
1383
|
+
...SimpleRenderer$1.rendererOptions,
|
|
1384
|
+
...options,
|
|
1385
|
+
icon: {
|
|
1386
|
+
...LISTR_LOGGER_STYLE.icon,
|
|
1387
|
+
...options?.icon ?? {}
|
|
1388
|
+
},
|
|
1389
|
+
color: {
|
|
1390
|
+
...LISTR_LOGGER_STYLE.color,
|
|
1391
|
+
...options?.color ?? {}
|
|
1392
|
+
}
|
|
1393
|
+
};
|
|
1394
|
+
this.logger = this.options.logger ?? new ListrLogger({
|
|
1395
|
+
useIcons: true,
|
|
1396
|
+
toStderr: LISTR_LOGGER_STDERR_LEVELS
|
|
1397
|
+
});
|
|
1398
|
+
this.logger.options.icon = this.options.icon;
|
|
1399
|
+
this.logger.options.color = this.options.color;
|
|
1400
|
+
if (this.options.timestamp) this.logger.options.fields.prefix.unshift(this.options.timestamp);
|
|
1401
|
+
}
|
|
1402
|
+
end() {}
|
|
1403
|
+
render() {
|
|
1404
|
+
this.renderer(this.tasks);
|
|
1405
|
+
}
|
|
1406
|
+
renderer(tasks) {
|
|
1407
|
+
tasks.forEach((task) => {
|
|
1408
|
+
this.calculate(task);
|
|
1409
|
+
task.once(ListrTaskEventType.CLOSED, () => {
|
|
1410
|
+
this.reset(task);
|
|
1411
|
+
});
|
|
1412
|
+
const rendererOptions = this.cache.rendererOptions.get(task.id);
|
|
1413
|
+
const rendererTaskOptions = this.cache.rendererTaskOptions.get(task.id);
|
|
1414
|
+
task.on(ListrTaskEventType.SUBTASK, (subtasks) => {
|
|
1415
|
+
this.renderer(subtasks);
|
|
1416
|
+
});
|
|
1417
|
+
task.on(ListrTaskEventType.STATE, (state) => {
|
|
1418
|
+
if (!task.hasTitle()) return;
|
|
1419
|
+
if (state === ListrTaskState.STARTED) this.logger.log(ListrLogLevels.STARTED, task.title);
|
|
1420
|
+
else if (state === ListrTaskState.COMPLETED) {
|
|
1421
|
+
const timer = rendererTaskOptions?.timer;
|
|
1422
|
+
this.logger.log(ListrLogLevels.COMPLETED, task.title, timer && { suffix: {
|
|
1423
|
+
...timer,
|
|
1424
|
+
condition: !!task.message?.duration && timer.condition,
|
|
1425
|
+
args: [task.message.duration]
|
|
1426
|
+
} });
|
|
1427
|
+
} else if (state === ListrTaskState.PROMPT) {
|
|
1428
|
+
this.logger.process.hijack();
|
|
1429
|
+
task.on(ListrTaskEventType.PROMPT, (prompt) => {
|
|
1430
|
+
this.logger.process.toStderr(prompt, false);
|
|
1431
|
+
});
|
|
1432
|
+
} else if (state === ListrTaskState.PROMPT_COMPLETED) {
|
|
1433
|
+
task.off(ListrTaskEventType.PROMPT);
|
|
1434
|
+
this.logger.process.release();
|
|
1435
|
+
}
|
|
1436
|
+
});
|
|
1437
|
+
task.on(ListrTaskEventType.OUTPUT, (output) => {
|
|
1438
|
+
this.logger.log(ListrLogLevels.OUTPUT, output);
|
|
1439
|
+
});
|
|
1440
|
+
task.on(ListrTaskEventType.MESSAGE, (message) => {
|
|
1441
|
+
if (message.error) this.logger.log(ListrLogLevels.FAILED, task.title, { suffix: {
|
|
1442
|
+
field: `${ListrLogLevels.FAILED}: ${message.error}`,
|
|
1443
|
+
format: () => color.red
|
|
1444
|
+
} });
|
|
1445
|
+
else if (message.skip) this.logger.log(ListrLogLevels.SKIPPED, task.title, { suffix: {
|
|
1446
|
+
field: `${ListrLogLevels.SKIPPED}: ${message.skip}`,
|
|
1447
|
+
format: () => color.yellow
|
|
1448
|
+
} });
|
|
1449
|
+
else if (message.rollback) this.logger.log(ListrLogLevels.ROLLBACK, task.title, { suffix: {
|
|
1450
|
+
field: `${ListrLogLevels.ROLLBACK}: ${message.rollback}`,
|
|
1451
|
+
format: () => color.red
|
|
1452
|
+
} });
|
|
1453
|
+
else if (message.retry) this.logger.log(ListrLogLevels.RETRY, task.title, { suffix: {
|
|
1454
|
+
field: `${ListrLogLevels.RETRY}:${message.retry.count}`,
|
|
1455
|
+
format: () => color.red
|
|
1456
|
+
} });
|
|
1457
|
+
else if (message.paused) {
|
|
1458
|
+
const timer = rendererOptions?.pausedTimer;
|
|
1459
|
+
this.logger.log(ListrLogLevels.PAUSED, task.title, timer && { suffix: {
|
|
1460
|
+
...timer,
|
|
1461
|
+
condition: !!message?.paused && timer.condition,
|
|
1462
|
+
args: [message.paused - Date.now()]
|
|
1463
|
+
} });
|
|
1464
|
+
}
|
|
1465
|
+
});
|
|
1466
|
+
});
|
|
1467
|
+
}
|
|
1468
|
+
calculate(task) {
|
|
1469
|
+
if (this.cache.rendererOptions.has(task.id) && this.cache.rendererTaskOptions.has(task.id)) return;
|
|
1470
|
+
const rendererOptions = {
|
|
1471
|
+
...this.options,
|
|
1472
|
+
...task.rendererOptions
|
|
1473
|
+
};
|
|
1474
|
+
this.cache.rendererOptions.set(task.id, rendererOptions);
|
|
1475
|
+
this.cache.rendererTaskOptions.set(task.id, {
|
|
1476
|
+
...SimpleRenderer$1.rendererTaskOptions,
|
|
1477
|
+
timer: rendererOptions.timer,
|
|
1478
|
+
...task.rendererTaskOptions
|
|
1479
|
+
});
|
|
1480
|
+
}
|
|
1481
|
+
reset(task) {
|
|
1482
|
+
this.cache.rendererOptions.delete(task.id);
|
|
1483
|
+
this.cache.rendererTaskOptions.delete(task.id);
|
|
1484
|
+
}
|
|
1485
|
+
};
|
|
1486
|
+
var TestRendererSerializer = class {
|
|
1487
|
+
constructor(options) {
|
|
1488
|
+
this.options = options;
|
|
1489
|
+
}
|
|
1490
|
+
serialize(event, data, task) {
|
|
1491
|
+
return JSON.stringify(this.generate(event, data, task));
|
|
1492
|
+
}
|
|
1493
|
+
generate(event, data, task) {
|
|
1494
|
+
const output = {
|
|
1495
|
+
event,
|
|
1496
|
+
data
|
|
1497
|
+
};
|
|
1498
|
+
if (typeof this.options?.task !== "boolean") {
|
|
1499
|
+
const t = Object.fromEntries(this.options.task.map((entity) => {
|
|
1500
|
+
const property = task[entity];
|
|
1501
|
+
if (typeof property === "function") return [entity, property.call(task)];
|
|
1502
|
+
return [entity, property];
|
|
1503
|
+
}));
|
|
1504
|
+
if (Object.keys(task).length > 0) output.task = t;
|
|
1505
|
+
}
|
|
1506
|
+
return output;
|
|
1507
|
+
}
|
|
1508
|
+
};
|
|
1509
|
+
var TestRenderer = class TestRenderer$1 {
|
|
1510
|
+
static nonTTY = true;
|
|
1511
|
+
static rendererOptions = {
|
|
1512
|
+
subtasks: true,
|
|
1513
|
+
state: Object.values(ListrTaskState),
|
|
1514
|
+
output: true,
|
|
1515
|
+
prompt: true,
|
|
1516
|
+
title: true,
|
|
1517
|
+
messages: [
|
|
1518
|
+
"skip",
|
|
1519
|
+
"error",
|
|
1520
|
+
"retry",
|
|
1521
|
+
"rollback",
|
|
1522
|
+
"paused"
|
|
1523
|
+
],
|
|
1524
|
+
messagesToStderr: [
|
|
1525
|
+
"error",
|
|
1526
|
+
"rollback",
|
|
1527
|
+
"retry"
|
|
1528
|
+
],
|
|
1529
|
+
task: [
|
|
1530
|
+
"hasRolledBack",
|
|
1531
|
+
"isRollingBack",
|
|
1532
|
+
"isCompleted",
|
|
1533
|
+
"isSkipped",
|
|
1534
|
+
"hasFinalized",
|
|
1535
|
+
"hasSubtasks",
|
|
1536
|
+
"title",
|
|
1537
|
+
"hasReset",
|
|
1538
|
+
"hasTitle",
|
|
1539
|
+
"isPrompt",
|
|
1540
|
+
"isPaused",
|
|
1541
|
+
"isPending",
|
|
1542
|
+
"isSkipped",
|
|
1543
|
+
"isStarted",
|
|
1544
|
+
"hasFailed",
|
|
1545
|
+
"isEnabled",
|
|
1546
|
+
"isRetrying",
|
|
1547
|
+
"path"
|
|
1548
|
+
]
|
|
1549
|
+
};
|
|
1550
|
+
static rendererTaskOptions;
|
|
1551
|
+
logger;
|
|
1552
|
+
serializer;
|
|
1553
|
+
constructor(tasks, options) {
|
|
1554
|
+
this.tasks = tasks;
|
|
1555
|
+
this.options = options;
|
|
1556
|
+
this.options = {
|
|
1557
|
+
...TestRenderer$1.rendererOptions,
|
|
1558
|
+
...this.options
|
|
1559
|
+
};
|
|
1560
|
+
this.logger = this.options.logger ?? new ListrLogger({ useIcons: false });
|
|
1561
|
+
this.serializer = new TestRendererSerializer(this.options);
|
|
1562
|
+
}
|
|
1563
|
+
render() {
|
|
1564
|
+
this.renderer(this.tasks);
|
|
1565
|
+
}
|
|
1566
|
+
end() {}
|
|
1567
|
+
renderer(tasks) {
|
|
1568
|
+
tasks.forEach((task) => {
|
|
1569
|
+
if (this.options.subtasks) task.on(ListrTaskEventType.SUBTASK, (subtasks) => {
|
|
1570
|
+
this.renderer(subtasks);
|
|
1571
|
+
});
|
|
1572
|
+
if (this.options.state) task.on(ListrTaskEventType.STATE, (state) => {
|
|
1573
|
+
this.logger.toStdout(this.serializer.serialize(ListrTaskEventType.STATE, state, task));
|
|
1574
|
+
});
|
|
1575
|
+
if (this.options.output) task.on(ListrTaskEventType.OUTPUT, (data) => {
|
|
1576
|
+
this.logger.toStdout(this.serializer.serialize(ListrTaskEventType.OUTPUT, data, task));
|
|
1577
|
+
});
|
|
1578
|
+
if (this.options.prompt) task.on(ListrTaskEventType.PROMPT, (prompt) => {
|
|
1579
|
+
this.logger.toStdout(this.serializer.serialize(ListrTaskEventType.PROMPT, prompt, task));
|
|
1580
|
+
});
|
|
1581
|
+
if (this.options.title) task.on(ListrTaskEventType.TITLE, (title) => {
|
|
1582
|
+
this.logger.toStdout(this.serializer.serialize(ListrTaskEventType.TITLE, title, task));
|
|
1583
|
+
});
|
|
1584
|
+
task.on(ListrTaskEventType.MESSAGE, (message) => {
|
|
1585
|
+
const parsed = Object.fromEntries(Object.entries(message).map(([key, value]) => {
|
|
1586
|
+
if (this.options.messages.includes(key)) return [key, value];
|
|
1587
|
+
}).filter(Boolean));
|
|
1588
|
+
if (Object.keys(parsed).length > 0) {
|
|
1589
|
+
const output = this.serializer.serialize(ListrTaskEventType.MESSAGE, parsed, task);
|
|
1590
|
+
if (this.options.messagesToStderr.some((state) => Object.keys(parsed).includes(state))) this.logger.toStderr(output);
|
|
1591
|
+
else this.logger.toStdout(output);
|
|
1592
|
+
}
|
|
1593
|
+
});
|
|
1594
|
+
});
|
|
1595
|
+
}
|
|
1596
|
+
};
|
|
1597
|
+
var VerboseRenderer = class VerboseRenderer$1 {
|
|
1598
|
+
static nonTTY = true;
|
|
1599
|
+
static rendererOptions = {
|
|
1600
|
+
logTitleChange: false,
|
|
1601
|
+
pausedTimer: {
|
|
1602
|
+
...PRESET_TIMER,
|
|
1603
|
+
format: () => color.yellowBright
|
|
1604
|
+
}
|
|
1605
|
+
};
|
|
1606
|
+
static rendererTaskOptions;
|
|
1607
|
+
logger;
|
|
1608
|
+
cache = {
|
|
1609
|
+
rendererOptions: /* @__PURE__ */ new Map(),
|
|
1610
|
+
rendererTaskOptions: /* @__PURE__ */ new Map()
|
|
1611
|
+
};
|
|
1612
|
+
constructor(tasks, options) {
|
|
1613
|
+
this.tasks = tasks;
|
|
1614
|
+
this.options = options;
|
|
1615
|
+
this.options = {
|
|
1616
|
+
...VerboseRenderer$1.rendererOptions,
|
|
1617
|
+
...this.options,
|
|
1618
|
+
icon: {
|
|
1619
|
+
...LISTR_LOGGER_STYLE.icon,
|
|
1620
|
+
...options?.icon ?? {}
|
|
1621
|
+
},
|
|
1622
|
+
color: {
|
|
1623
|
+
...LISTR_LOGGER_STYLE.color,
|
|
1624
|
+
...options?.color ?? {}
|
|
1625
|
+
}
|
|
1626
|
+
};
|
|
1627
|
+
this.logger = this.options.logger ?? new ListrLogger({
|
|
1628
|
+
useIcons: false,
|
|
1629
|
+
toStderr: LISTR_LOGGER_STDERR_LEVELS
|
|
1630
|
+
});
|
|
1631
|
+
this.logger.options.icon = this.options.icon;
|
|
1632
|
+
this.logger.options.color = this.options.color;
|
|
1633
|
+
if (this.options.timestamp) this.logger.options.fields.prefix.unshift(this.options.timestamp);
|
|
1634
|
+
}
|
|
1635
|
+
render() {
|
|
1636
|
+
this.renderer(this.tasks);
|
|
1637
|
+
}
|
|
1638
|
+
end() {}
|
|
1639
|
+
renderer(tasks) {
|
|
1640
|
+
tasks.forEach((task) => {
|
|
1641
|
+
this.calculate(task);
|
|
1642
|
+
task.once(ListrTaskEventType.CLOSED, () => {
|
|
1643
|
+
this.reset(task);
|
|
1644
|
+
});
|
|
1645
|
+
const rendererOptions = this.cache.rendererOptions.get(task.id);
|
|
1646
|
+
const rendererTaskOptions = this.cache.rendererTaskOptions.get(task.id);
|
|
1647
|
+
task.on(ListrTaskEventType.SUBTASK, (subtasks) => {
|
|
1648
|
+
this.renderer(subtasks);
|
|
1649
|
+
});
|
|
1650
|
+
task.on(ListrTaskEventType.STATE, (state) => {
|
|
1651
|
+
if (!task.hasTitle()) return;
|
|
1652
|
+
if (state === ListrTaskState.STARTED) this.logger.log(ListrLogLevels.STARTED, task.title);
|
|
1653
|
+
else if (state === ListrTaskState.COMPLETED) {
|
|
1654
|
+
const timer = rendererTaskOptions.timer;
|
|
1655
|
+
this.logger.log(ListrLogLevels.COMPLETED, task.title, timer && { suffix: {
|
|
1656
|
+
...timer,
|
|
1657
|
+
condition: !!task.message?.duration && timer.condition,
|
|
1658
|
+
args: [task.message.duration]
|
|
1659
|
+
} });
|
|
1660
|
+
}
|
|
1661
|
+
});
|
|
1662
|
+
task.on(ListrTaskEventType.OUTPUT, (data) => {
|
|
1663
|
+
this.logger.log(ListrLogLevels.OUTPUT, data);
|
|
1664
|
+
});
|
|
1665
|
+
task.on(ListrTaskEventType.PROMPT, (prompt) => {
|
|
1666
|
+
const cleansed = cleanseAnsi(prompt);
|
|
1667
|
+
if (cleansed) this.logger.log(ListrLogLevels.PROMPT, cleansed);
|
|
1668
|
+
});
|
|
1669
|
+
if (this.options?.logTitleChange !== false) task.on(ListrTaskEventType.TITLE, (title) => {
|
|
1670
|
+
this.logger.log(ListrLogLevels.TITLE, title);
|
|
1671
|
+
});
|
|
1672
|
+
task.on(ListrTaskEventType.MESSAGE, (message) => {
|
|
1673
|
+
if (message?.error) this.logger.log(ListrLogLevels.FAILED, message.error);
|
|
1674
|
+
else if (message?.skip) this.logger.log(ListrLogLevels.SKIPPED, message.skip);
|
|
1675
|
+
else if (message?.rollback) this.logger.log(ListrLogLevels.ROLLBACK, message.rollback);
|
|
1676
|
+
else if (message?.retry) this.logger.log(ListrLogLevels.RETRY, task.title, { suffix: message.retry.count.toString() });
|
|
1677
|
+
else if (message?.paused) {
|
|
1678
|
+
const timer = rendererOptions?.pausedTimer;
|
|
1679
|
+
this.logger.log(ListrLogLevels.PAUSED, task.title, timer && { suffix: {
|
|
1680
|
+
...timer,
|
|
1681
|
+
condition: !!message?.paused && timer.condition,
|
|
1682
|
+
args: [message.paused - Date.now()]
|
|
1683
|
+
} });
|
|
1684
|
+
}
|
|
1685
|
+
});
|
|
1686
|
+
});
|
|
1687
|
+
}
|
|
1688
|
+
calculate(task) {
|
|
1689
|
+
if (this.cache.rendererOptions.has(task.id) && this.cache.rendererTaskOptions.has(task.id)) return;
|
|
1690
|
+
const rendererOptions = {
|
|
1691
|
+
...this.options,
|
|
1692
|
+
...task.rendererOptions
|
|
1693
|
+
};
|
|
1694
|
+
this.cache.rendererOptions.set(task.id, rendererOptions);
|
|
1695
|
+
this.cache.rendererTaskOptions.set(task.id, {
|
|
1696
|
+
...VerboseRenderer$1.rendererTaskOptions,
|
|
1697
|
+
timer: rendererOptions.timer,
|
|
1698
|
+
...task.rendererTaskOptions
|
|
1699
|
+
});
|
|
1700
|
+
}
|
|
1701
|
+
reset(task) {
|
|
1702
|
+
this.cache.rendererOptions.delete(task.id);
|
|
1703
|
+
this.cache.rendererTaskOptions.delete(task.id);
|
|
1704
|
+
}
|
|
1705
|
+
};
|
|
1706
|
+
const RENDERERS = {
|
|
1707
|
+
default: DefaultRenderer,
|
|
1708
|
+
simple: SimpleRenderer,
|
|
1709
|
+
verbose: VerboseRenderer,
|
|
1710
|
+
test: TestRenderer,
|
|
1711
|
+
silent: SilentRenderer
|
|
1712
|
+
};
|
|
1713
|
+
function isRendererSupported(renderer) {
|
|
1714
|
+
return process.stdout.isTTY === true || renderer.nonTTY === true;
|
|
1715
|
+
}
|
|
1716
|
+
function getRendererClass(renderer) {
|
|
1717
|
+
if (typeof renderer === "string") return RENDERERS[renderer] ?? RENDERERS.default;
|
|
1718
|
+
return typeof renderer === "function" ? renderer : RENDERERS.default;
|
|
1719
|
+
}
|
|
1720
|
+
function getRenderer(options) {
|
|
1721
|
+
if (assertFunctionOrSelf(options?.silentRendererCondition)) return {
|
|
1722
|
+
renderer: getRendererClass("silent"),
|
|
1723
|
+
selection: ListrRendererSelection.SILENT
|
|
1724
|
+
};
|
|
1725
|
+
const r = {
|
|
1726
|
+
renderer: getRendererClass(options.renderer),
|
|
1727
|
+
options: options.rendererOptions,
|
|
1728
|
+
selection: ListrRendererSelection.PRIMARY
|
|
1729
|
+
};
|
|
1730
|
+
if (!isRendererSupported(r.renderer) || assertFunctionOrSelf(options?.fallbackRendererCondition)) return {
|
|
1731
|
+
renderer: getRendererClass(options.fallbackRenderer),
|
|
1732
|
+
options: options.fallbackRendererOptions,
|
|
1733
|
+
selection: ListrRendererSelection.SECONDARY
|
|
1734
|
+
};
|
|
1735
|
+
return r;
|
|
1736
|
+
}
|
|
1737
|
+
/**
|
|
1738
|
+
* This function asserts the given value as a function or itself.
|
|
1739
|
+
* If the value itself is a function it will evaluate it with the passed in arguments,
|
|
1740
|
+
* elsewise it will directly return itself.
|
|
1741
|
+
*/
|
|
1742
|
+
function assertFunctionOrSelf(functionOrSelf, ...args) {
|
|
1743
|
+
if (typeof functionOrSelf === "function") return functionOrSelf(...args);
|
|
1744
|
+
else return functionOrSelf;
|
|
1745
|
+
}
|
|
1746
|
+
const clone = (0, import_rfdc.default)({ circles: true });
|
|
1747
|
+
/**
|
|
1748
|
+
* Deep clones a object in the easiest manner.
|
|
1749
|
+
*/
|
|
1750
|
+
function cloneObject(obj) {
|
|
1751
|
+
return clone(obj);
|
|
1752
|
+
}
|
|
1753
|
+
var Concurrency = class {
|
|
1754
|
+
concurrency;
|
|
1755
|
+
count;
|
|
1756
|
+
queue;
|
|
1757
|
+
constructor(options) {
|
|
1758
|
+
this.concurrency = options.concurrency;
|
|
1759
|
+
this.count = 0;
|
|
1760
|
+
this.queue = /* @__PURE__ */ new Set();
|
|
1761
|
+
}
|
|
1762
|
+
add(fn) {
|
|
1763
|
+
if (this.count < this.concurrency) return this.run(fn);
|
|
1764
|
+
return new Promise((resolve$2) => {
|
|
1765
|
+
const callback = () => resolve$2(this.run(fn));
|
|
1766
|
+
this.queue.add(callback);
|
|
1767
|
+
});
|
|
1768
|
+
}
|
|
1769
|
+
flush() {
|
|
1770
|
+
for (const callback of this.queue) {
|
|
1771
|
+
if (this.count >= this.concurrency) break;
|
|
1772
|
+
this.queue.delete(callback);
|
|
1773
|
+
callback();
|
|
1774
|
+
}
|
|
1775
|
+
}
|
|
1776
|
+
run(fn) {
|
|
1777
|
+
this.count++;
|
|
1778
|
+
const promise = fn();
|
|
1779
|
+
const cleanup = () => {
|
|
1780
|
+
this.count--;
|
|
1781
|
+
this.flush();
|
|
1782
|
+
};
|
|
1783
|
+
promise.then(cleanup, () => {
|
|
1784
|
+
this.queue.clear();
|
|
1785
|
+
});
|
|
1786
|
+
return promise;
|
|
1787
|
+
}
|
|
1788
|
+
};
|
|
1789
|
+
function delay(time) {
|
|
1790
|
+
return new Promise((resolve$2) => {
|
|
1791
|
+
setTimeout(resolve$2, time);
|
|
1792
|
+
});
|
|
1793
|
+
}
|
|
1794
|
+
/**
|
|
1795
|
+
* Internal error handling mechanism for Listr collects the errors and details for a failed task.
|
|
1796
|
+
*
|
|
1797
|
+
* @see {@link https://listr2.kilic.dev/task/error-handling.html}
|
|
1798
|
+
*/
|
|
1799
|
+
var ListrError = class extends Error {
|
|
1800
|
+
path;
|
|
1801
|
+
ctx;
|
|
1802
|
+
constructor(error, type, task) {
|
|
1803
|
+
super(error.message);
|
|
1804
|
+
this.error = error;
|
|
1805
|
+
this.type = type;
|
|
1806
|
+
this.task = task;
|
|
1807
|
+
this.name = "ListrError";
|
|
1808
|
+
this.path = task.path;
|
|
1809
|
+
if (task?.options.collectErrors === "full") {
|
|
1810
|
+
this.task = cloneObject(task);
|
|
1811
|
+
this.ctx = cloneObject(task.listr.ctx);
|
|
1812
|
+
}
|
|
1813
|
+
this.stack = error?.stack;
|
|
1814
|
+
}
|
|
1815
|
+
};
|
|
1816
|
+
/**
|
|
1817
|
+
* Internal error coming from renderer.
|
|
1818
|
+
*/
|
|
1819
|
+
var ListrRendererError = class extends Error {};
|
|
1820
|
+
/**
|
|
1821
|
+
* Internal error handling mechanism for Listr prompts to identify the failing cause is coming from a prompt.
|
|
1822
|
+
*
|
|
1823
|
+
* @see {@link https://listr2.kilic.dev/task/prompts.html}
|
|
1824
|
+
*/
|
|
1825
|
+
var PromptError = class extends Error {};
|
|
1826
|
+
/**
|
|
1827
|
+
* The original Task that is defined by the user is wrapped with the TaskWrapper to provide additional functionality.
|
|
1828
|
+
*
|
|
1829
|
+
* @see {@link https://listr2.kilic.dev/task/task.html}
|
|
1830
|
+
*/
|
|
1831
|
+
var TaskWrapper = class {
|
|
1832
|
+
constructor(task) {
|
|
1833
|
+
this.task = task;
|
|
1834
|
+
}
|
|
1835
|
+
/* istanbul ignore next */
|
|
1836
|
+
get title() {
|
|
1837
|
+
return this.task.title;
|
|
1838
|
+
}
|
|
1839
|
+
/**
|
|
1840
|
+
* Title of the current task.
|
|
1841
|
+
*
|
|
1842
|
+
* @see {@link https://listr2.kilic.dev/task/title.html}
|
|
1843
|
+
*/
|
|
1844
|
+
set title(title) {
|
|
1845
|
+
title = Array.isArray(title) ? title : [title];
|
|
1846
|
+
this.task.title$ = splat(title.shift(), ...title);
|
|
1847
|
+
}
|
|
1848
|
+
/* istanbul ignore next */
|
|
1849
|
+
get output() {
|
|
1850
|
+
return this.task.output;
|
|
1851
|
+
}
|
|
1852
|
+
/* istanbul ignore next */
|
|
1853
|
+
/**
|
|
1854
|
+
* Send output from the current task to the renderer.
|
|
1855
|
+
*
|
|
1856
|
+
* @see {@link https://listr2.kilic.dev/task/output.html}
|
|
1857
|
+
*/
|
|
1858
|
+
set output(output) {
|
|
1859
|
+
output = Array.isArray(output) ? output : [output];
|
|
1860
|
+
this.task.output$ = splat(output.shift(), ...output);
|
|
1861
|
+
}
|
|
1862
|
+
/* istanbul ignore next */
|
|
1863
|
+
/** Send an output to the output channel as prompt. */
|
|
1864
|
+
set promptOutput(output) {
|
|
1865
|
+
this.task.promptOutput$ = output;
|
|
1866
|
+
}
|
|
1867
|
+
/**
|
|
1868
|
+
* Creates a new set of Listr subtasks.
|
|
1869
|
+
*
|
|
1870
|
+
* @see {@link https://listr2.kilic.dev/task/subtasks.html}
|
|
1871
|
+
*/
|
|
1872
|
+
newListr(task, options) {
|
|
1873
|
+
let tasks;
|
|
1874
|
+
if (typeof task === "function") tasks = task(this);
|
|
1875
|
+
else tasks = task;
|
|
1876
|
+
return new Listr(tasks, options, this.task);
|
|
1877
|
+
}
|
|
1878
|
+
/**
|
|
1879
|
+
* Report an error that has to be collected and handled.
|
|
1880
|
+
*
|
|
1881
|
+
* @see {@link https://listr2.kilic.dev/task/error-handling.html}
|
|
1882
|
+
*/
|
|
1883
|
+
report(error, type) {
|
|
1884
|
+
if (this.task.options.collectErrors !== false) this.task.listr.errors.push(new ListrError(error, type, this.task));
|
|
1885
|
+
this.task.message$ = { error: error.message ?? this.task?.title };
|
|
1886
|
+
}
|
|
1887
|
+
/**
|
|
1888
|
+
* Skip the current task.
|
|
1889
|
+
*
|
|
1890
|
+
* @see {@link https://listr2.kilic.dev/task/skip.html}
|
|
1891
|
+
*/
|
|
1892
|
+
skip(message, ...metadata) {
|
|
1893
|
+
this.task.state$ = ListrTaskState.SKIPPED;
|
|
1894
|
+
if (message) this.task.message$ = { skip: message ? splat(message, ...metadata) : this.task?.title };
|
|
1895
|
+
}
|
|
1896
|
+
/**
|
|
1897
|
+
* Check whether this task is currently in a retry state.
|
|
1898
|
+
*
|
|
1899
|
+
* @see {@link https://listr2.kilic.dev/task/retry.html}
|
|
1900
|
+
*/
|
|
1901
|
+
isRetrying() {
|
|
1902
|
+
return this.task.isRetrying() ? this.task.retry : { count: 0 };
|
|
1903
|
+
}
|
|
1904
|
+
/* istanbul ignore next */
|
|
1905
|
+
/**
|
|
1906
|
+
* Create a new prompt for getting user input through the prompt adapter.
|
|
1907
|
+
* This will create a new prompt through the adapter if the task is not currently rendering a prompt or will return the active instance.
|
|
1908
|
+
*
|
|
1909
|
+
* This part of the application requires optional peer dependencies, please refer to documentation.
|
|
1910
|
+
*
|
|
1911
|
+
* @see {@link https://listr2.kilic.dev/task/prompt.html}
|
|
1912
|
+
*/
|
|
1913
|
+
prompt(adapter) {
|
|
1914
|
+
if (this.task.prompt) return this.task.prompt;
|
|
1915
|
+
return new adapter(this.task, this);
|
|
1916
|
+
}
|
|
1917
|
+
/* istanbul ignore next */
|
|
1918
|
+
/**
|
|
1919
|
+
* Generates a fake stdout for your use case, where it will be tunnelled through Listr to handle the rendering process.
|
|
1920
|
+
*
|
|
1921
|
+
* @see {@link https://listr2.kilic.dev/renderer/process-output.html}
|
|
1922
|
+
*/
|
|
1923
|
+
stdout(type) {
|
|
1924
|
+
return createWritable((chunk) => {
|
|
1925
|
+
switch (type) {
|
|
1926
|
+
case ListrTaskEventType.PROMPT:
|
|
1927
|
+
this.promptOutput = chunk;
|
|
1928
|
+
break;
|
|
1929
|
+
default: this.output = chunk;
|
|
1930
|
+
}
|
|
1931
|
+
});
|
|
1932
|
+
}
|
|
1933
|
+
/** Run this task. */
|
|
1934
|
+
run(ctx) {
|
|
1935
|
+
return this.task.run(ctx, this);
|
|
1936
|
+
}
|
|
1937
|
+
};
|
|
1938
|
+
var ListrTaskEventManager = class extends EventManager {};
|
|
1939
|
+
/**
|
|
1940
|
+
* Creates and handles a runnable instance of the Task.
|
|
1941
|
+
*/
|
|
1942
|
+
var Task = class extends ListrTaskEventManager {
|
|
1943
|
+
/** Unique id per task, can be used for identifying a Task. */
|
|
1944
|
+
id = randomUUID();
|
|
1945
|
+
/** The current state of the task. */
|
|
1946
|
+
state = ListrTaskState.WAITING;
|
|
1947
|
+
/** Subtasks of the current task. */
|
|
1948
|
+
subtasks;
|
|
1949
|
+
/** Title of the task. */
|
|
1950
|
+
title;
|
|
1951
|
+
/** Initial/Untouched version of the title for using whenever task has a reset. */
|
|
1952
|
+
initialTitle;
|
|
1953
|
+
/** Output channel for the task. */
|
|
1954
|
+
output;
|
|
1955
|
+
/** Current state of the retry process whenever the task is retrying. */
|
|
1956
|
+
retry;
|
|
1957
|
+
/**
|
|
1958
|
+
* A channel for messages.
|
|
1959
|
+
*
|
|
1960
|
+
* This requires a separate channel for messages like error, skip or runtime messages to further utilize in the renderers.
|
|
1961
|
+
*/
|
|
1962
|
+
message = {};
|
|
1963
|
+
/** Current prompt instance or prompt error whenever the task is prompting. */
|
|
1964
|
+
prompt;
|
|
1965
|
+
/** Parent task of the current task. */
|
|
1966
|
+
parent;
|
|
1967
|
+
/** Enable flag of this task. */
|
|
1968
|
+
enabled;
|
|
1969
|
+
/** User provided Task callback function to run. */
|
|
1970
|
+
taskFn;
|
|
1971
|
+
/** Marks the task as closed. This is different from finalized since this is not really related to task itself. */
|
|
1972
|
+
closed;
|
|
1973
|
+
constructor(listr, task, options, rendererOptions, rendererTaskOptions) {
|
|
1974
|
+
super();
|
|
1975
|
+
this.listr = listr;
|
|
1976
|
+
this.task = task;
|
|
1977
|
+
this.options = options;
|
|
1978
|
+
this.rendererOptions = rendererOptions;
|
|
1979
|
+
this.rendererTaskOptions = rendererTaskOptions;
|
|
1980
|
+
if (task.title) {
|
|
1981
|
+
const title = Array.isArray(task?.title) ? task.title : [task.title];
|
|
1982
|
+
this.title = splat(title.shift(), ...title);
|
|
1983
|
+
this.initialTitle = this.title;
|
|
1984
|
+
}
|
|
1985
|
+
this.taskFn = task.task;
|
|
1986
|
+
this.parent = listr.parentTask;
|
|
1987
|
+
}
|
|
1988
|
+
/**
|
|
1989
|
+
* Update the current state of the Task and emit the neccassary events.
|
|
1990
|
+
*/
|
|
1991
|
+
set state$(state) {
|
|
1992
|
+
this.state = state;
|
|
1993
|
+
this.emit(ListrTaskEventType.STATE, state);
|
|
1994
|
+
if (this.hasSubtasks() && this.hasFailed()) {
|
|
1995
|
+
for (const subtask of this.subtasks) if (subtask.state === ListrTaskState.STARTED) subtask.state$ = ListrTaskState.FAILED;
|
|
1996
|
+
}
|
|
1997
|
+
this.listr.events.emit(ListrEventType.SHOULD_REFRESH_RENDER);
|
|
1998
|
+
}
|
|
1999
|
+
/**
|
|
2000
|
+
* Update the current output of the Task and emit the neccassary events.
|
|
2001
|
+
*/
|
|
2002
|
+
set output$(data) {
|
|
2003
|
+
this.output = data;
|
|
2004
|
+
this.emit(ListrTaskEventType.OUTPUT, data);
|
|
2005
|
+
this.listr.events.emit(ListrEventType.SHOULD_REFRESH_RENDER);
|
|
2006
|
+
}
|
|
2007
|
+
/**
|
|
2008
|
+
* Update the current prompt output of the Task and emit the neccassary events.
|
|
2009
|
+
*/
|
|
2010
|
+
set promptOutput$(data) {
|
|
2011
|
+
this.emit(ListrTaskEventType.PROMPT, data);
|
|
2012
|
+
if (cleanseAnsi(data)) this.listr.events.emit(ListrEventType.SHOULD_REFRESH_RENDER);
|
|
2013
|
+
}
|
|
2014
|
+
/**
|
|
2015
|
+
* Update or extend the current message of the Task and emit the neccassary events.
|
|
2016
|
+
*/
|
|
2017
|
+
set message$(data) {
|
|
2018
|
+
this.message = {
|
|
2019
|
+
...this.message,
|
|
2020
|
+
...data
|
|
2021
|
+
};
|
|
2022
|
+
this.emit(ListrTaskEventType.MESSAGE, data);
|
|
2023
|
+
this.listr.events.emit(ListrEventType.SHOULD_REFRESH_RENDER);
|
|
2024
|
+
}
|
|
2025
|
+
/**
|
|
2026
|
+
* Update the current title of the Task and emit the neccassary events.
|
|
2027
|
+
*/
|
|
2028
|
+
set title$(title) {
|
|
2029
|
+
this.title = title;
|
|
2030
|
+
this.emit(ListrTaskEventType.TITLE, title);
|
|
2031
|
+
this.listr.events.emit(ListrEventType.SHOULD_REFRESH_RENDER);
|
|
2032
|
+
}
|
|
2033
|
+
/**
|
|
2034
|
+
* Current task path in the hierarchy.
|
|
2035
|
+
*/
|
|
2036
|
+
get path() {
|
|
2037
|
+
return [...this.listr.path, this.initialTitle];
|
|
2038
|
+
}
|
|
2039
|
+
/**
|
|
2040
|
+
* Checks whether the current task with the given context should be set as enabled.
|
|
2041
|
+
*/
|
|
2042
|
+
async check(ctx) {
|
|
2043
|
+
if (this.state === ListrTaskState.WAITING) {
|
|
2044
|
+
this.enabled = await assertFunctionOrSelf(this.task?.enabled ?? true, ctx);
|
|
2045
|
+
this.emit(ListrTaskEventType.ENABLED, this.enabled);
|
|
2046
|
+
this.listr.events.emit(ListrEventType.SHOULD_REFRESH_RENDER);
|
|
2047
|
+
}
|
|
2048
|
+
return this.enabled;
|
|
2049
|
+
}
|
|
2050
|
+
/** Returns whether this task has subtasks. */
|
|
2051
|
+
hasSubtasks() {
|
|
2052
|
+
return this.subtasks?.length > 0;
|
|
2053
|
+
}
|
|
2054
|
+
/** Returns whether this task is finalized in someform. */
|
|
2055
|
+
hasFinalized() {
|
|
2056
|
+
return this.isCompleted() || this.hasFailed() || this.isSkipped() || this.hasRolledBack();
|
|
2057
|
+
}
|
|
2058
|
+
/** Returns whether this task is in progress. */
|
|
2059
|
+
isPending() {
|
|
2060
|
+
return this.isStarted() || this.isPrompt() || this.hasReset();
|
|
2061
|
+
}
|
|
2062
|
+
/** Returns whether this task has started. */
|
|
2063
|
+
isStarted() {
|
|
2064
|
+
return this.state === ListrTaskState.STARTED;
|
|
2065
|
+
}
|
|
2066
|
+
/** Returns whether this task is skipped. */
|
|
2067
|
+
isSkipped() {
|
|
2068
|
+
return this.state === ListrTaskState.SKIPPED;
|
|
2069
|
+
}
|
|
2070
|
+
/** Returns whether this task has been completed. */
|
|
2071
|
+
isCompleted() {
|
|
2072
|
+
return this.state === ListrTaskState.COMPLETED;
|
|
2073
|
+
}
|
|
2074
|
+
/** Returns whether this task has been failed. */
|
|
2075
|
+
hasFailed() {
|
|
2076
|
+
return this.state === ListrTaskState.FAILED;
|
|
2077
|
+
}
|
|
2078
|
+
/** Returns whether this task has an active rollback task going on. */
|
|
2079
|
+
isRollingBack() {
|
|
2080
|
+
return this.state === ListrTaskState.ROLLING_BACK;
|
|
2081
|
+
}
|
|
2082
|
+
/** Returns whether the rollback action was successful. */
|
|
2083
|
+
hasRolledBack() {
|
|
2084
|
+
return this.state === ListrTaskState.ROLLED_BACK;
|
|
2085
|
+
}
|
|
2086
|
+
/** Returns whether this task has an actively retrying task going on. */
|
|
2087
|
+
isRetrying() {
|
|
2088
|
+
return this.state === ListrTaskState.RETRY;
|
|
2089
|
+
}
|
|
2090
|
+
/** Returns whether this task has some kind of reset like retry and rollback going on. */
|
|
2091
|
+
hasReset() {
|
|
2092
|
+
return this.state === ListrTaskState.RETRY || this.state === ListrTaskState.ROLLING_BACK;
|
|
2093
|
+
}
|
|
2094
|
+
/** Returns whether enabled function resolves to true. */
|
|
2095
|
+
isEnabled() {
|
|
2096
|
+
return this.enabled;
|
|
2097
|
+
}
|
|
2098
|
+
/** Returns whether this task actually has a title. */
|
|
2099
|
+
hasTitle() {
|
|
2100
|
+
return typeof this?.title === "string";
|
|
2101
|
+
}
|
|
2102
|
+
/** Returns whether this task has a prompt inside. */
|
|
2103
|
+
isPrompt() {
|
|
2104
|
+
return this.state === ListrTaskState.PROMPT;
|
|
2105
|
+
}
|
|
2106
|
+
/** Returns whether this task is currently paused. */
|
|
2107
|
+
isPaused() {
|
|
2108
|
+
return this.state === ListrTaskState.PAUSED;
|
|
2109
|
+
}
|
|
2110
|
+
/** Returns whether this task is closed. */
|
|
2111
|
+
isClosed() {
|
|
2112
|
+
return this.closed;
|
|
2113
|
+
}
|
|
2114
|
+
/** Pause the given task for certain time. */
|
|
2115
|
+
async pause(time) {
|
|
2116
|
+
const state = this.state;
|
|
2117
|
+
this.state$ = ListrTaskState.PAUSED;
|
|
2118
|
+
this.message$ = { paused: Date.now() + time };
|
|
2119
|
+
await delay(time);
|
|
2120
|
+
this.state$ = state;
|
|
2121
|
+
this.message$ = { paused: null };
|
|
2122
|
+
}
|
|
2123
|
+
/** Run the current task. */
|
|
2124
|
+
async run(context, wrapper) {
|
|
2125
|
+
const handleResult = (result) => {
|
|
2126
|
+
if (result instanceof Listr) {
|
|
2127
|
+
result.options = {
|
|
2128
|
+
...this.options,
|
|
2129
|
+
...result.options
|
|
2130
|
+
};
|
|
2131
|
+
result.rendererClass = getRendererClass("silent");
|
|
2132
|
+
this.subtasks = result.tasks;
|
|
2133
|
+
result.errors = this.listr.errors;
|
|
2134
|
+
this.emit(ListrTaskEventType.SUBTASK, this.subtasks);
|
|
2135
|
+
result = result.run(context);
|
|
2136
|
+
} else if (result instanceof Promise) result = result.then(handleResult);
|
|
2137
|
+
else if (isReadable(result)) result = new Promise((resolve$2, reject) => {
|
|
2138
|
+
result.on("data", (data) => {
|
|
2139
|
+
this.output$ = data.toString();
|
|
2140
|
+
});
|
|
2141
|
+
result.on("error", (error) => reject(error));
|
|
2142
|
+
result.on("end", () => resolve$2(null));
|
|
2143
|
+
});
|
|
2144
|
+
else if (isObservable(result)) result = new Promise((resolve$2, reject) => {
|
|
2145
|
+
result.subscribe({
|
|
2146
|
+
next: (data) => {
|
|
2147
|
+
this.output$ = data;
|
|
2148
|
+
},
|
|
2149
|
+
error: reject,
|
|
2150
|
+
complete: resolve$2
|
|
2151
|
+
});
|
|
2152
|
+
});
|
|
2153
|
+
return result;
|
|
2154
|
+
};
|
|
2155
|
+
const startTime = Date.now();
|
|
2156
|
+
this.state$ = ListrTaskState.STARTED;
|
|
2157
|
+
const skipped = await assertFunctionOrSelf(this.task?.skip ?? false, context);
|
|
2158
|
+
if (skipped) {
|
|
2159
|
+
if (typeof skipped === "string") this.message$ = { skip: skipped };
|
|
2160
|
+
else if (this.hasTitle()) this.message$ = { skip: this.title };
|
|
2161
|
+
else this.message$ = { skip: "Skipped task without a title." };
|
|
2162
|
+
this.state$ = ListrTaskState.SKIPPED;
|
|
2163
|
+
return;
|
|
2164
|
+
}
|
|
2165
|
+
try {
|
|
2166
|
+
const retryCount = typeof this.task?.retry === "number" && this.task.retry > 0 ? this.task.retry + 1 : typeof this.task?.retry === "object" && this.task.retry.tries > 0 ? this.task.retry.tries + 1 : 1;
|
|
2167
|
+
const retryDelay = typeof this.task.retry === "object" && this.task.retry.delay;
|
|
2168
|
+
for (let retries = 1; retries <= retryCount; retries++) try {
|
|
2169
|
+
await handleResult(this.taskFn(context, wrapper));
|
|
2170
|
+
break;
|
|
2171
|
+
} catch (err) {
|
|
2172
|
+
if (retries !== retryCount) {
|
|
2173
|
+
this.retry = {
|
|
2174
|
+
count: retries,
|
|
2175
|
+
error: err
|
|
2176
|
+
};
|
|
2177
|
+
this.message$ = { retry: this.retry };
|
|
2178
|
+
this.title$ = this.initialTitle;
|
|
2179
|
+
this.output = void 0;
|
|
2180
|
+
wrapper.report(err, ListrErrorTypes.WILL_RETRY);
|
|
2181
|
+
this.state$ = ListrTaskState.RETRY;
|
|
2182
|
+
if (retryDelay) await this.pause(retryDelay);
|
|
2183
|
+
} else throw err;
|
|
2184
|
+
}
|
|
2185
|
+
if (this.isStarted() || this.isRetrying()) {
|
|
2186
|
+
this.message$ = { duration: Date.now() - startTime };
|
|
2187
|
+
this.state$ = ListrTaskState.COMPLETED;
|
|
2188
|
+
}
|
|
2189
|
+
} catch (error) {
|
|
2190
|
+
if (this.prompt instanceof PromptError) error = this.prompt;
|
|
2191
|
+
if (this.task?.rollback) {
|
|
2192
|
+
wrapper.report(error, ListrErrorTypes.WILL_ROLLBACK);
|
|
2193
|
+
try {
|
|
2194
|
+
this.state$ = ListrTaskState.ROLLING_BACK;
|
|
2195
|
+
await this.task.rollback(context, wrapper);
|
|
2196
|
+
this.message$ = { rollback: this.title };
|
|
2197
|
+
this.state$ = ListrTaskState.ROLLED_BACK;
|
|
2198
|
+
} catch (err) {
|
|
2199
|
+
this.state$ = ListrTaskState.FAILED;
|
|
2200
|
+
wrapper.report(err, ListrErrorTypes.HAS_FAILED_TO_ROLLBACK);
|
|
2201
|
+
this.close();
|
|
2202
|
+
throw err;
|
|
2203
|
+
}
|
|
2204
|
+
if (this.listr.options?.exitAfterRollback !== false) {
|
|
2205
|
+
this.close();
|
|
2206
|
+
throw error;
|
|
2207
|
+
}
|
|
2208
|
+
} else {
|
|
2209
|
+
this.state$ = ListrTaskState.FAILED;
|
|
2210
|
+
if (this.listr.options.exitOnError !== false && await assertFunctionOrSelf(this.task?.exitOnError, context) !== false) {
|
|
2211
|
+
wrapper.report(error, ListrErrorTypes.HAS_FAILED);
|
|
2212
|
+
this.close();
|
|
2213
|
+
throw error;
|
|
2214
|
+
} else if (!this.hasSubtasks()) wrapper.report(error, ListrErrorTypes.HAS_FAILED_WITHOUT_ERROR);
|
|
2215
|
+
}
|
|
2216
|
+
} finally {
|
|
2217
|
+
this.close();
|
|
2218
|
+
}
|
|
2219
|
+
}
|
|
2220
|
+
close() {
|
|
2221
|
+
this.emit(ListrTaskEventType.CLOSED);
|
|
2222
|
+
this.listr.events.emit(ListrEventType.SHOULD_REFRESH_RENDER);
|
|
2223
|
+
this.complete();
|
|
2224
|
+
}
|
|
2225
|
+
};
|
|
2226
|
+
var ListrEventManager = class extends EventManager {};
|
|
2227
|
+
/**
|
|
2228
|
+
* Create a new task list with Listr.
|
|
2229
|
+
*
|
|
2230
|
+
* @see {@link https://listr2.kilic.dev/listr/listr.html}
|
|
2231
|
+
*/
|
|
2232
|
+
var Listr = class {
|
|
2233
|
+
tasks = [];
|
|
2234
|
+
errors = [];
|
|
2235
|
+
ctx;
|
|
2236
|
+
events;
|
|
2237
|
+
path = [];
|
|
2238
|
+
rendererClass;
|
|
2239
|
+
rendererClassOptions;
|
|
2240
|
+
rendererSelection;
|
|
2241
|
+
boundSignalHandler;
|
|
2242
|
+
concurrency;
|
|
2243
|
+
renderer;
|
|
2244
|
+
constructor(task, options, parentTask) {
|
|
2245
|
+
this.task = task;
|
|
2246
|
+
this.options = options;
|
|
2247
|
+
this.parentTask = parentTask;
|
|
2248
|
+
this.options = {
|
|
2249
|
+
concurrent: false,
|
|
2250
|
+
renderer: "default",
|
|
2251
|
+
fallbackRenderer: "simple",
|
|
2252
|
+
exitOnError: true,
|
|
2253
|
+
exitAfterRollback: true,
|
|
2254
|
+
collectErrors: false,
|
|
2255
|
+
registerSignalListeners: true,
|
|
2256
|
+
...this.parentTask?.options ?? {},
|
|
2257
|
+
...options
|
|
2258
|
+
};
|
|
2259
|
+
if (this.options.concurrent === true) this.options.concurrent = Infinity;
|
|
2260
|
+
else if (typeof this.options.concurrent !== "number") this.options.concurrent = 1;
|
|
2261
|
+
this.concurrency = new Concurrency({ concurrency: this.options.concurrent });
|
|
2262
|
+
if (parentTask) {
|
|
2263
|
+
this.path = [...parentTask.listr.path, parentTask.title];
|
|
2264
|
+
this.errors = parentTask.listr.errors;
|
|
2265
|
+
}
|
|
2266
|
+
if (this.parentTask?.listr.events instanceof ListrEventManager) this.events = this.parentTask.listr.events;
|
|
2267
|
+
else this.events = new ListrEventManager();
|
|
2268
|
+
/* istanbul ignore if */
|
|
2269
|
+
if (this.options?.forceTTY || process.env[ListrEnvironmentVariables.FORCE_TTY]) {
|
|
2270
|
+
process.stdout.isTTY = true;
|
|
2271
|
+
process.stderr.isTTY = true;
|
|
2272
|
+
}
|
|
2273
|
+
/* istanbul ignore if */
|
|
2274
|
+
if (this.options?.forceUnicode) process.env[ListrEnvironmentVariables.FORCE_UNICODE] = "1";
|
|
2275
|
+
const renderer = getRenderer({
|
|
2276
|
+
renderer: this.options.renderer,
|
|
2277
|
+
rendererOptions: this.options.rendererOptions,
|
|
2278
|
+
fallbackRenderer: this.options.fallbackRenderer,
|
|
2279
|
+
fallbackRendererOptions: this.options.fallbackRendererOptions,
|
|
2280
|
+
fallbackRendererCondition: this.options?.fallbackRendererCondition,
|
|
2281
|
+
silentRendererCondition: this.options?.silentRendererCondition
|
|
2282
|
+
});
|
|
2283
|
+
this.rendererClass = renderer.renderer;
|
|
2284
|
+
this.rendererClassOptions = renderer.options;
|
|
2285
|
+
this.rendererSelection = renderer.selection;
|
|
2286
|
+
/* istanbul ignore next */
|
|
2287
|
+
this.add(task ?? []);
|
|
2288
|
+
/* istanbul ignore if */
|
|
2289
|
+
if (this.options.registerSignalListeners) {
|
|
2290
|
+
this.boundSignalHandler = this.signalHandler.bind(this);
|
|
2291
|
+
process.once("SIGINT", this.boundSignalHandler).setMaxListeners(0);
|
|
2292
|
+
}
|
|
2293
|
+
}
|
|
2294
|
+
/**
|
|
2295
|
+
* Whether this is the root task.
|
|
2296
|
+
*/
|
|
2297
|
+
isRoot() {
|
|
2298
|
+
return !this.parentTask;
|
|
2299
|
+
}
|
|
2300
|
+
/**
|
|
2301
|
+
* Whether this is a subtask of another task list.
|
|
2302
|
+
*/
|
|
2303
|
+
isSubtask() {
|
|
2304
|
+
return !!this.parentTask;
|
|
2305
|
+
}
|
|
2306
|
+
/**
|
|
2307
|
+
* Add tasks to current task list.
|
|
2308
|
+
*
|
|
2309
|
+
* @see {@link https://listr2.kilic.dev/task/task.html}
|
|
2310
|
+
*/
|
|
2311
|
+
add(tasks) {
|
|
2312
|
+
this.tasks.push(...this.generate(tasks));
|
|
2313
|
+
}
|
|
2314
|
+
/**
|
|
2315
|
+
* Run the task list.
|
|
2316
|
+
*
|
|
2317
|
+
* @see {@link https://listr2.kilic.dev/listr/listr.html#run-the-generated-task-list}
|
|
2318
|
+
*/
|
|
2319
|
+
async run(context) {
|
|
2320
|
+
if (!this.renderer) this.renderer = new this.rendererClass(this.tasks, this.rendererClassOptions, this.events);
|
|
2321
|
+
await this.renderer.render();
|
|
2322
|
+
this.ctx = this.options?.ctx ?? context ?? {};
|
|
2323
|
+
try {
|
|
2324
|
+
await Promise.all(this.tasks.map((task) => task.check(this.ctx)));
|
|
2325
|
+
await Promise.all(this.tasks.map((task) => this.concurrency.add(() => this.runTask(task))));
|
|
2326
|
+
this.renderer.end();
|
|
2327
|
+
this.removeSignalHandler();
|
|
2328
|
+
} catch (err) {
|
|
2329
|
+
if (this.options.exitOnError !== false) {
|
|
2330
|
+
this.renderer.end(err);
|
|
2331
|
+
this.removeSignalHandler();
|
|
2332
|
+
throw err;
|
|
2333
|
+
}
|
|
2334
|
+
}
|
|
2335
|
+
return this.ctx;
|
|
2336
|
+
}
|
|
2337
|
+
generate(tasks) {
|
|
2338
|
+
tasks = Array.isArray(tasks) ? tasks : [tasks];
|
|
2339
|
+
return tasks.map((task) => {
|
|
2340
|
+
let rendererTaskOptions;
|
|
2341
|
+
if (this.rendererSelection === ListrRendererSelection.PRIMARY) rendererTaskOptions = task.rendererOptions;
|
|
2342
|
+
else if (this.rendererSelection === ListrRendererSelection.SECONDARY) rendererTaskOptions = task.fallbackRendererOptions;
|
|
2343
|
+
return new Task(this, task, this.options, this.rendererClassOptions, rendererTaskOptions);
|
|
2344
|
+
});
|
|
2345
|
+
}
|
|
2346
|
+
async runTask(task) {
|
|
2347
|
+
if (!await task.check(this.ctx)) return;
|
|
2348
|
+
return new TaskWrapper(task).run(this.ctx);
|
|
2349
|
+
}
|
|
2350
|
+
signalHandler() {
|
|
2351
|
+
this.tasks?.forEach(async (task) => {
|
|
2352
|
+
if (task.isPending()) task.state$ = ListrTaskState.FAILED;
|
|
2353
|
+
});
|
|
2354
|
+
if (this.isRoot()) {
|
|
2355
|
+
this.renderer?.end(/* @__PURE__ */ new Error("Interrupted."));
|
|
2356
|
+
process.exit(127);
|
|
2357
|
+
}
|
|
2358
|
+
}
|
|
2359
|
+
removeSignalHandler() {
|
|
2360
|
+
if (this.boundSignalHandler) process.removeListener("SIGINT", this.boundSignalHandler);
|
|
2361
|
+
}
|
|
2362
|
+
};
|
|
2363
|
+
|
|
2364
|
+
//#endregion
|
|
2365
|
+
//#region node_modules/lodash-es/_freeGlobal.js
|
|
2366
|
+
/** Detect free variable `global` from Node.js. */
|
|
2367
|
+
var freeGlobal = typeof global == "object" && global && global.Object === Object && global;
|
|
2368
|
+
var _freeGlobal_default = freeGlobal;
|
|
2369
|
+
|
|
2370
|
+
//#endregion
|
|
2371
|
+
//#region node_modules/lodash-es/_root.js
|
|
2372
|
+
/** Detect free variable `self`. */
|
|
2373
|
+
var freeSelf = typeof self == "object" && self && self.Object === Object && self;
|
|
2374
|
+
/** Used as a reference to the global object. */
|
|
2375
|
+
var root = _freeGlobal_default || freeSelf || Function("return this")();
|
|
2376
|
+
var _root_default = root;
|
|
2377
|
+
|
|
2378
|
+
//#endregion
|
|
2379
|
+
//#region node_modules/lodash-es/_Symbol.js
|
|
2380
|
+
/** Built-in value references. */
|
|
2381
|
+
var Symbol = _root_default.Symbol;
|
|
2382
|
+
var _Symbol_default = Symbol;
|
|
2383
|
+
|
|
2384
|
+
//#endregion
|
|
2385
|
+
//#region node_modules/lodash-es/_arrayMap.js
|
|
2386
|
+
/**
|
|
2387
|
+
* A specialized version of `_.map` for arrays without support for iteratee
|
|
2388
|
+
* shorthands.
|
|
2389
|
+
*
|
|
2390
|
+
* @private
|
|
2391
|
+
* @param {Array} [array] The array to iterate over.
|
|
2392
|
+
* @param {Function} iteratee The function invoked per iteration.
|
|
2393
|
+
* @returns {Array} Returns the new mapped array.
|
|
2394
|
+
*/
|
|
2395
|
+
function arrayMap(array, iteratee) {
|
|
2396
|
+
var index = -1, length = array == null ? 0 : array.length, result = Array(length);
|
|
2397
|
+
while (++index < length) result[index] = iteratee(array[index], index, array);
|
|
2398
|
+
return result;
|
|
2399
|
+
}
|
|
2400
|
+
var _arrayMap_default = arrayMap;
|
|
2401
|
+
|
|
2402
|
+
//#endregion
|
|
2403
|
+
//#region node_modules/lodash-es/isArray.js
|
|
2404
|
+
/**
|
|
2405
|
+
* Checks if `value` is classified as an `Array` object.
|
|
2406
|
+
*
|
|
2407
|
+
* @static
|
|
2408
|
+
* @memberOf _
|
|
2409
|
+
* @since 0.1.0
|
|
2410
|
+
* @category Lang
|
|
2411
|
+
* @param {*} value The value to check.
|
|
2412
|
+
* @returns {boolean} Returns `true` if `value` is an array, else `false`.
|
|
2413
|
+
* @example
|
|
2414
|
+
*
|
|
2415
|
+
* _.isArray([1, 2, 3]);
|
|
2416
|
+
* // => true
|
|
2417
|
+
*
|
|
2418
|
+
* _.isArray(document.body.children);
|
|
2419
|
+
* // => false
|
|
2420
|
+
*
|
|
2421
|
+
* _.isArray('abc');
|
|
2422
|
+
* // => false
|
|
2423
|
+
*
|
|
2424
|
+
* _.isArray(_.noop);
|
|
2425
|
+
* // => false
|
|
2426
|
+
*/
|
|
2427
|
+
var isArray = Array.isArray;
|
|
2428
|
+
var isArray_default = isArray;
|
|
2429
|
+
|
|
2430
|
+
//#endregion
|
|
2431
|
+
//#region node_modules/lodash-es/_getRawTag.js
|
|
2432
|
+
/** Used for built-in method references. */
|
|
2433
|
+
var objectProto$1 = Object.prototype;
|
|
2434
|
+
/** Used to check objects for own properties. */
|
|
2435
|
+
var hasOwnProperty$3 = objectProto$1.hasOwnProperty;
|
|
2436
|
+
/**
|
|
2437
|
+
* Used to resolve the
|
|
2438
|
+
* [`toStringTag`](http://ecma-international.org/ecma-262/7.0/#sec-object.prototype.tostring)
|
|
2439
|
+
* of values.
|
|
2440
|
+
*/
|
|
2441
|
+
var nativeObjectToString$1 = objectProto$1.toString;
|
|
2442
|
+
/** Built-in value references. */
|
|
2443
|
+
var symToStringTag$1 = _Symbol_default ? _Symbol_default.toStringTag : void 0;
|
|
2444
|
+
/**
|
|
2445
|
+
* A specialized version of `baseGetTag` which ignores `Symbol.toStringTag` values.
|
|
2446
|
+
*
|
|
2447
|
+
* @private
|
|
2448
|
+
* @param {*} value The value to query.
|
|
2449
|
+
* @returns {string} Returns the raw `toStringTag`.
|
|
2450
|
+
*/
|
|
2451
|
+
function getRawTag(value) {
|
|
2452
|
+
var isOwn = hasOwnProperty$3.call(value, symToStringTag$1), tag = value[symToStringTag$1];
|
|
2453
|
+
try {
|
|
2454
|
+
value[symToStringTag$1] = void 0;
|
|
2455
|
+
var unmasked = true;
|
|
2456
|
+
} catch (e) {}
|
|
2457
|
+
var result = nativeObjectToString$1.call(value);
|
|
2458
|
+
if (unmasked) if (isOwn) value[symToStringTag$1] = tag;
|
|
2459
|
+
else delete value[symToStringTag$1];
|
|
2460
|
+
return result;
|
|
2461
|
+
}
|
|
2462
|
+
var _getRawTag_default = getRawTag;
|
|
2463
|
+
|
|
2464
|
+
//#endregion
|
|
2465
|
+
//#region node_modules/lodash-es/_objectToString.js
|
|
2466
|
+
/**
|
|
2467
|
+
* Used to resolve the
|
|
2468
|
+
* [`toStringTag`](http://ecma-international.org/ecma-262/7.0/#sec-object.prototype.tostring)
|
|
2469
|
+
* of values.
|
|
2470
|
+
*/
|
|
2471
|
+
var nativeObjectToString = Object.prototype.toString;
|
|
2472
|
+
/**
|
|
2473
|
+
* Converts `value` to a string using `Object.prototype.toString`.
|
|
2474
|
+
*
|
|
2475
|
+
* @private
|
|
2476
|
+
* @param {*} value The value to convert.
|
|
2477
|
+
* @returns {string} Returns the converted string.
|
|
2478
|
+
*/
|
|
2479
|
+
function objectToString(value) {
|
|
2480
|
+
return nativeObjectToString.call(value);
|
|
2481
|
+
}
|
|
2482
|
+
var _objectToString_default = objectToString;
|
|
2483
|
+
|
|
2484
|
+
//#endregion
|
|
2485
|
+
//#region node_modules/lodash-es/_baseGetTag.js
|
|
2486
|
+
/** `Object#toString` result references. */
|
|
2487
|
+
var nullTag = "[object Null]", undefinedTag = "[object Undefined]";
|
|
2488
|
+
/** Built-in value references. */
|
|
2489
|
+
var symToStringTag = _Symbol_default ? _Symbol_default.toStringTag : void 0;
|
|
2490
|
+
/**
|
|
2491
|
+
* The base implementation of `getTag` without fallbacks for buggy environments.
|
|
2492
|
+
*
|
|
2493
|
+
* @private
|
|
2494
|
+
* @param {*} value The value to query.
|
|
2495
|
+
* @returns {string} Returns the `toStringTag`.
|
|
2496
|
+
*/
|
|
2497
|
+
function baseGetTag(value) {
|
|
2498
|
+
if (value == null) return value === void 0 ? undefinedTag : nullTag;
|
|
2499
|
+
return symToStringTag && symToStringTag in Object(value) ? _getRawTag_default(value) : _objectToString_default(value);
|
|
2500
|
+
}
|
|
2501
|
+
var _baseGetTag_default = baseGetTag;
|
|
2502
|
+
|
|
2503
|
+
//#endregion
|
|
2504
|
+
//#region node_modules/lodash-es/isObjectLike.js
|
|
2505
|
+
/**
|
|
2506
|
+
* Checks if `value` is object-like. A value is object-like if it's not `null`
|
|
2507
|
+
* and has a `typeof` result of "object".
|
|
2508
|
+
*
|
|
2509
|
+
* @static
|
|
2510
|
+
* @memberOf _
|
|
2511
|
+
* @since 4.0.0
|
|
2512
|
+
* @category Lang
|
|
2513
|
+
* @param {*} value The value to check.
|
|
2514
|
+
* @returns {boolean} Returns `true` if `value` is object-like, else `false`.
|
|
2515
|
+
* @example
|
|
2516
|
+
*
|
|
2517
|
+
* _.isObjectLike({});
|
|
2518
|
+
* // => true
|
|
2519
|
+
*
|
|
2520
|
+
* _.isObjectLike([1, 2, 3]);
|
|
2521
|
+
* // => true
|
|
2522
|
+
*
|
|
2523
|
+
* _.isObjectLike(_.noop);
|
|
2524
|
+
* // => false
|
|
2525
|
+
*
|
|
2526
|
+
* _.isObjectLike(null);
|
|
2527
|
+
* // => false
|
|
2528
|
+
*/
|
|
2529
|
+
function isObjectLike(value) {
|
|
2530
|
+
return value != null && typeof value == "object";
|
|
2531
|
+
}
|
|
2532
|
+
var isObjectLike_default = isObjectLike;
|
|
2533
|
+
|
|
2534
|
+
//#endregion
|
|
2535
|
+
//#region node_modules/lodash-es/isSymbol.js
|
|
2536
|
+
/** `Object#toString` result references. */
|
|
2537
|
+
var symbolTag = "[object Symbol]";
|
|
2538
|
+
/**
|
|
2539
|
+
* Checks if `value` is classified as a `Symbol` primitive or object.
|
|
2540
|
+
*
|
|
2541
|
+
* @static
|
|
2542
|
+
* @memberOf _
|
|
2543
|
+
* @since 4.0.0
|
|
2544
|
+
* @category Lang
|
|
2545
|
+
* @param {*} value The value to check.
|
|
2546
|
+
* @returns {boolean} Returns `true` if `value` is a symbol, else `false`.
|
|
2547
|
+
* @example
|
|
2548
|
+
*
|
|
2549
|
+
* _.isSymbol(Symbol.iterator);
|
|
2550
|
+
* // => true
|
|
2551
|
+
*
|
|
2552
|
+
* _.isSymbol('abc');
|
|
2553
|
+
* // => false
|
|
2554
|
+
*/
|
|
2555
|
+
function isSymbol(value) {
|
|
2556
|
+
return typeof value == "symbol" || isObjectLike_default(value) && _baseGetTag_default(value) == symbolTag;
|
|
2557
|
+
}
|
|
2558
|
+
var isSymbol_default = isSymbol;
|
|
2559
|
+
|
|
2560
|
+
//#endregion
|
|
2561
|
+
//#region node_modules/lodash-es/_baseToString.js
|
|
2562
|
+
/** Used as references for various `Number` constants. */
|
|
2563
|
+
var INFINITY = Infinity;
|
|
2564
|
+
/** Used to convert symbols to primitives and strings. */
|
|
2565
|
+
var symbolProto = _Symbol_default ? _Symbol_default.prototype : void 0, symbolToString = symbolProto ? symbolProto.toString : void 0;
|
|
2566
|
+
/**
|
|
2567
|
+
* The base implementation of `_.toString` which doesn't convert nullish
|
|
2568
|
+
* values to empty strings.
|
|
2569
|
+
*
|
|
2570
|
+
* @private
|
|
2571
|
+
* @param {*} value The value to process.
|
|
2572
|
+
* @returns {string} Returns the string.
|
|
2573
|
+
*/
|
|
2574
|
+
function baseToString(value) {
|
|
2575
|
+
if (typeof value == "string") return value;
|
|
2576
|
+
if (isArray_default(value)) return _arrayMap_default(value, baseToString) + "";
|
|
2577
|
+
if (isSymbol_default(value)) return symbolToString ? symbolToString.call(value) : "";
|
|
2578
|
+
var result = value + "";
|
|
2579
|
+
return result == "0" && 1 / value == -INFINITY ? "-0" : result;
|
|
2580
|
+
}
|
|
2581
|
+
var _baseToString_default = baseToString;
|
|
2582
|
+
|
|
2583
|
+
//#endregion
|
|
2584
|
+
//#region node_modules/lodash-es/toString.js
|
|
2585
|
+
/**
|
|
2586
|
+
* Converts `value` to a string. An empty string is returned for `null`
|
|
2587
|
+
* and `undefined` values. The sign of `-0` is preserved.
|
|
2588
|
+
*
|
|
2589
|
+
* @static
|
|
2590
|
+
* @memberOf _
|
|
2591
|
+
* @since 4.0.0
|
|
2592
|
+
* @category Lang
|
|
2593
|
+
* @param {*} value The value to convert.
|
|
2594
|
+
* @returns {string} Returns the converted string.
|
|
2595
|
+
* @example
|
|
2596
|
+
*
|
|
2597
|
+
* _.toString(null);
|
|
2598
|
+
* // => ''
|
|
2599
|
+
*
|
|
2600
|
+
* _.toString(-0);
|
|
2601
|
+
* // => '-0'
|
|
2602
|
+
*
|
|
2603
|
+
* _.toString([1, 2, 3]);
|
|
2604
|
+
* // => '1,2,3'
|
|
2605
|
+
*/
|
|
2606
|
+
function toString(value) {
|
|
2607
|
+
return value == null ? "" : _baseToString_default(value);
|
|
2608
|
+
}
|
|
2609
|
+
var toString_default = toString;
|
|
2610
|
+
|
|
2611
|
+
//#endregion
|
|
2612
|
+
//#region node_modules/lodash-es/_baseSlice.js
|
|
2613
|
+
/**
|
|
2614
|
+
* The base implementation of `_.slice` without an iteratee call guard.
|
|
2615
|
+
*
|
|
2616
|
+
* @private
|
|
2617
|
+
* @param {Array} array The array to slice.
|
|
2618
|
+
* @param {number} [start=0] The start position.
|
|
2619
|
+
* @param {number} [end=array.length] The end position.
|
|
2620
|
+
* @returns {Array} Returns the slice of `array`.
|
|
2621
|
+
*/
|
|
2622
|
+
function baseSlice(array, start, end) {
|
|
2623
|
+
var index = -1, length = array.length;
|
|
2624
|
+
if (start < 0) start = -start > length ? 0 : length + start;
|
|
2625
|
+
end = end > length ? length : end;
|
|
2626
|
+
if (end < 0) end += length;
|
|
2627
|
+
length = start > end ? 0 : end - start >>> 0;
|
|
2628
|
+
start >>>= 0;
|
|
2629
|
+
var result = Array(length);
|
|
2630
|
+
while (++index < length) result[index] = array[index + start];
|
|
2631
|
+
return result;
|
|
2632
|
+
}
|
|
2633
|
+
var _baseSlice_default = baseSlice;
|
|
2634
|
+
|
|
2635
|
+
//#endregion
|
|
2636
|
+
//#region node_modules/lodash-es/_castSlice.js
|
|
2637
|
+
/**
|
|
2638
|
+
* Casts `array` to a slice if it's needed.
|
|
2639
|
+
*
|
|
2640
|
+
* @private
|
|
2641
|
+
* @param {Array} array The array to inspect.
|
|
2642
|
+
* @param {number} start The start position.
|
|
2643
|
+
* @param {number} [end=array.length] The end position.
|
|
2644
|
+
* @returns {Array} Returns the cast slice.
|
|
2645
|
+
*/
|
|
2646
|
+
function castSlice(array, start, end) {
|
|
2647
|
+
var length = array.length;
|
|
2648
|
+
end = end === void 0 ? length : end;
|
|
2649
|
+
return !start && end >= length ? array : _baseSlice_default(array, start, end);
|
|
2650
|
+
}
|
|
2651
|
+
var _castSlice_default = castSlice;
|
|
2652
|
+
|
|
2653
|
+
//#endregion
|
|
2654
|
+
//#region node_modules/lodash-es/_hasUnicode.js
|
|
2655
|
+
/** Used to detect strings with [zero-width joiners or code points from the astral planes](http://eev.ee/blog/2015/09/12/dark-corners-of-unicode/). */
|
|
2656
|
+
var reHasUnicode = RegExp("[\\u200d\\ud800-\\udfff\\u0300-\\u036f\\ufe20-\\ufe2f\\u20d0-\\u20ff\\ufe0e\\ufe0f]");
|
|
2657
|
+
/**
|
|
2658
|
+
* Checks if `string` contains Unicode symbols.
|
|
2659
|
+
*
|
|
2660
|
+
* @private
|
|
2661
|
+
* @param {string} string The string to inspect.
|
|
2662
|
+
* @returns {boolean} Returns `true` if a symbol is found, else `false`.
|
|
2663
|
+
*/
|
|
2664
|
+
function hasUnicode(string) {
|
|
2665
|
+
return reHasUnicode.test(string);
|
|
2666
|
+
}
|
|
2667
|
+
var _hasUnicode_default = hasUnicode;
|
|
2668
|
+
|
|
2669
|
+
//#endregion
|
|
2670
|
+
//#region node_modules/lodash-es/_asciiToArray.js
|
|
2671
|
+
/**
|
|
2672
|
+
* Converts an ASCII `string` to an array.
|
|
2673
|
+
*
|
|
2674
|
+
* @private
|
|
2675
|
+
* @param {string} string The string to convert.
|
|
2676
|
+
* @returns {Array} Returns the converted array.
|
|
2677
|
+
*/
|
|
2678
|
+
function asciiToArray(string) {
|
|
2679
|
+
return string.split("");
|
|
2680
|
+
}
|
|
2681
|
+
var _asciiToArray_default = asciiToArray;
|
|
2682
|
+
|
|
2683
|
+
//#endregion
|
|
2684
|
+
//#region node_modules/lodash-es/_unicodeToArray.js
|
|
2685
|
+
/** Used to compose unicode character classes. */
|
|
2686
|
+
var rsAstralRange$1 = "\\ud800-\\udfff", rsComboRange$1 = "\\u0300-\\u036f\\ufe20-\\ufe2f\\u20d0-\\u20ff", rsVarRange$1 = "\\ufe0e\\ufe0f";
|
|
2687
|
+
/** Used to compose unicode capture groups. */
|
|
2688
|
+
var rsAstral = "[" + rsAstralRange$1 + "]", rsCombo$1 = "[" + rsComboRange$1 + "]", rsFitz = "\\ud83c[\\udffb-\\udfff]", rsModifier$1 = "(?:" + rsCombo$1 + "|" + rsFitz + ")", rsNonAstral$1 = "[^" + rsAstralRange$1 + "]", rsRegional$1 = "(?:\\ud83c[\\udde6-\\uddff]){2}", rsSurrPair$1 = "[\\ud800-\\udbff][\\udc00-\\udfff]", rsZWJ$1 = "\\u200d";
|
|
2689
|
+
/** Used to compose unicode regexes. */
|
|
2690
|
+
var reOptMod$1 = rsModifier$1 + "?", rsOptVar$1 = "[" + rsVarRange$1 + "]?", rsOptJoin$1 = "(?:" + rsZWJ$1 + "(?:" + [
|
|
2691
|
+
rsNonAstral$1,
|
|
2692
|
+
rsRegional$1,
|
|
2693
|
+
rsSurrPair$1
|
|
2694
|
+
].join("|") + ")" + rsOptVar$1 + reOptMod$1 + ")*", rsSeq$1 = rsOptVar$1 + reOptMod$1 + rsOptJoin$1, rsSymbol = "(?:" + [
|
|
2695
|
+
rsNonAstral$1 + rsCombo$1 + "?",
|
|
2696
|
+
rsCombo$1,
|
|
2697
|
+
rsRegional$1,
|
|
2698
|
+
rsSurrPair$1,
|
|
2699
|
+
rsAstral
|
|
2700
|
+
].join("|") + ")";
|
|
2701
|
+
/** Used to match [string symbols](https://mathiasbynens.be/notes/javascript-unicode). */
|
|
2702
|
+
var reUnicode = RegExp(rsFitz + "(?=" + rsFitz + ")|" + rsSymbol + rsSeq$1, "g");
|
|
2703
|
+
/**
|
|
2704
|
+
* Converts a Unicode `string` to an array.
|
|
2705
|
+
*
|
|
2706
|
+
* @private
|
|
2707
|
+
* @param {string} string The string to convert.
|
|
2708
|
+
* @returns {Array} Returns the converted array.
|
|
2709
|
+
*/
|
|
2710
|
+
function unicodeToArray(string) {
|
|
2711
|
+
return string.match(reUnicode) || [];
|
|
2712
|
+
}
|
|
2713
|
+
var _unicodeToArray_default = unicodeToArray;
|
|
2714
|
+
|
|
2715
|
+
//#endregion
|
|
2716
|
+
//#region node_modules/lodash-es/_stringToArray.js
|
|
2717
|
+
/**
|
|
2718
|
+
* Converts `string` to an array.
|
|
2719
|
+
*
|
|
2720
|
+
* @private
|
|
2721
|
+
* @param {string} string The string to convert.
|
|
2722
|
+
* @returns {Array} Returns the converted array.
|
|
2723
|
+
*/
|
|
2724
|
+
function stringToArray(string) {
|
|
2725
|
+
return _hasUnicode_default(string) ? _unicodeToArray_default(string) : _asciiToArray_default(string);
|
|
2726
|
+
}
|
|
2727
|
+
var _stringToArray_default = stringToArray;
|
|
2728
|
+
|
|
2729
|
+
//#endregion
|
|
2730
|
+
//#region node_modules/lodash-es/_createCaseFirst.js
|
|
2731
|
+
/**
|
|
2732
|
+
* Creates a function like `_.lowerFirst`.
|
|
2733
|
+
*
|
|
2734
|
+
* @private
|
|
2735
|
+
* @param {string} methodName The name of the `String` case method to use.
|
|
2736
|
+
* @returns {Function} Returns the new case function.
|
|
2737
|
+
*/
|
|
2738
|
+
function createCaseFirst(methodName) {
|
|
2739
|
+
return function(string) {
|
|
2740
|
+
string = toString_default(string);
|
|
2741
|
+
var strSymbols = _hasUnicode_default(string) ? _stringToArray_default(string) : void 0;
|
|
2742
|
+
var chr = strSymbols ? strSymbols[0] : string.charAt(0);
|
|
2743
|
+
var trailing = strSymbols ? _castSlice_default(strSymbols, 1).join("") : string.slice(1);
|
|
2744
|
+
return chr[methodName]() + trailing;
|
|
2745
|
+
};
|
|
2746
|
+
}
|
|
2747
|
+
var _createCaseFirst_default = createCaseFirst;
|
|
2748
|
+
|
|
2749
|
+
//#endregion
|
|
2750
|
+
//#region node_modules/lodash-es/upperFirst.js
|
|
2751
|
+
/**
|
|
2752
|
+
* Converts the first character of `string` to upper case.
|
|
2753
|
+
*
|
|
2754
|
+
* @static
|
|
2755
|
+
* @memberOf _
|
|
2756
|
+
* @since 4.0.0
|
|
2757
|
+
* @category String
|
|
2758
|
+
* @param {string} [string=''] The string to convert.
|
|
2759
|
+
* @returns {string} Returns the converted string.
|
|
2760
|
+
* @example
|
|
2761
|
+
*
|
|
2762
|
+
* _.upperFirst('fred');
|
|
2763
|
+
* // => 'Fred'
|
|
2764
|
+
*
|
|
2765
|
+
* _.upperFirst('FRED');
|
|
2766
|
+
* // => 'FRED'
|
|
2767
|
+
*/
|
|
2768
|
+
var upperFirst = _createCaseFirst_default("toUpperCase");
|
|
2769
|
+
var upperFirst_default = upperFirst;
|
|
2770
|
+
|
|
2771
|
+
//#endregion
|
|
2772
|
+
//#region node_modules/lodash-es/capitalize.js
|
|
2773
|
+
/**
|
|
2774
|
+
* Converts the first character of `string` to upper case and the remaining
|
|
2775
|
+
* to lower case.
|
|
2776
|
+
*
|
|
2777
|
+
* @static
|
|
2778
|
+
* @memberOf _
|
|
2779
|
+
* @since 3.0.0
|
|
2780
|
+
* @category String
|
|
2781
|
+
* @param {string} [string=''] The string to capitalize.
|
|
2782
|
+
* @returns {string} Returns the capitalized string.
|
|
2783
|
+
* @example
|
|
2784
|
+
*
|
|
2785
|
+
* _.capitalize('FRED');
|
|
2786
|
+
* // => 'Fred'
|
|
2787
|
+
*/
|
|
2788
|
+
function capitalize$1(string) {
|
|
2789
|
+
return upperFirst_default(toString_default(string).toLowerCase());
|
|
2790
|
+
}
|
|
2791
|
+
var capitalize_default = capitalize$1;
|
|
2792
|
+
|
|
2793
|
+
//#endregion
|
|
2794
|
+
//#region node_modules/lodash-es/_arrayReduce.js
|
|
2795
|
+
/**
|
|
2796
|
+
* A specialized version of `_.reduce` for arrays without support for
|
|
2797
|
+
* iteratee shorthands.
|
|
2798
|
+
*
|
|
2799
|
+
* @private
|
|
2800
|
+
* @param {Array} [array] The array to iterate over.
|
|
2801
|
+
* @param {Function} iteratee The function invoked per iteration.
|
|
2802
|
+
* @param {*} [accumulator] The initial value.
|
|
2803
|
+
* @param {boolean} [initAccum] Specify using the first element of `array` as
|
|
2804
|
+
* the initial value.
|
|
2805
|
+
* @returns {*} Returns the accumulated value.
|
|
2806
|
+
*/
|
|
2807
|
+
function arrayReduce(array, iteratee, accumulator, initAccum) {
|
|
2808
|
+
var index = -1, length = array == null ? 0 : array.length;
|
|
2809
|
+
if (initAccum && length) accumulator = array[++index];
|
|
2810
|
+
while (++index < length) accumulator = iteratee(accumulator, array[index], index, array);
|
|
2811
|
+
return accumulator;
|
|
2812
|
+
}
|
|
2813
|
+
var _arrayReduce_default = arrayReduce;
|
|
2814
|
+
|
|
2815
|
+
//#endregion
|
|
2816
|
+
//#region node_modules/lodash-es/_basePropertyOf.js
|
|
2817
|
+
/**
|
|
2818
|
+
* The base implementation of `_.propertyOf` without support for deep paths.
|
|
2819
|
+
*
|
|
2820
|
+
* @private
|
|
2821
|
+
* @param {Object} object The object to query.
|
|
2822
|
+
* @returns {Function} Returns the new accessor function.
|
|
2823
|
+
*/
|
|
2824
|
+
function basePropertyOf(object) {
|
|
2825
|
+
return function(key) {
|
|
2826
|
+
return object == null ? void 0 : object[key];
|
|
2827
|
+
};
|
|
2828
|
+
}
|
|
2829
|
+
var _basePropertyOf_default = basePropertyOf;
|
|
2830
|
+
|
|
2831
|
+
//#endregion
|
|
2832
|
+
//#region node_modules/lodash-es/_deburrLetter.js
|
|
2833
|
+
/**
|
|
2834
|
+
* Used by `_.deburr` to convert Latin-1 Supplement and Latin Extended-A
|
|
2835
|
+
* letters to basic Latin letters.
|
|
2836
|
+
*
|
|
2837
|
+
* @private
|
|
2838
|
+
* @param {string} letter The matched letter to deburr.
|
|
2839
|
+
* @returns {string} Returns the deburred letter.
|
|
2840
|
+
*/
|
|
2841
|
+
var deburrLetter = _basePropertyOf_default({
|
|
2842
|
+
"À": "A",
|
|
2843
|
+
"Á": "A",
|
|
2844
|
+
"Â": "A",
|
|
2845
|
+
"Ã": "A",
|
|
2846
|
+
"Ä": "A",
|
|
2847
|
+
"Å": "A",
|
|
2848
|
+
"à": "a",
|
|
2849
|
+
"á": "a",
|
|
2850
|
+
"â": "a",
|
|
2851
|
+
"ã": "a",
|
|
2852
|
+
"ä": "a",
|
|
2853
|
+
"å": "a",
|
|
2854
|
+
"Ç": "C",
|
|
2855
|
+
"ç": "c",
|
|
2856
|
+
"Ð": "D",
|
|
2857
|
+
"ð": "d",
|
|
2858
|
+
"È": "E",
|
|
2859
|
+
"É": "E",
|
|
2860
|
+
"Ê": "E",
|
|
2861
|
+
"Ë": "E",
|
|
2862
|
+
"è": "e",
|
|
2863
|
+
"é": "e",
|
|
2864
|
+
"ê": "e",
|
|
2865
|
+
"ë": "e",
|
|
2866
|
+
"Ì": "I",
|
|
2867
|
+
"Í": "I",
|
|
2868
|
+
"Î": "I",
|
|
2869
|
+
"Ï": "I",
|
|
2870
|
+
"ì": "i",
|
|
2871
|
+
"í": "i",
|
|
2872
|
+
"î": "i",
|
|
2873
|
+
"ï": "i",
|
|
2874
|
+
"Ñ": "N",
|
|
2875
|
+
"ñ": "n",
|
|
2876
|
+
"Ò": "O",
|
|
2877
|
+
"Ó": "O",
|
|
2878
|
+
"Ô": "O",
|
|
2879
|
+
"Õ": "O",
|
|
2880
|
+
"Ö": "O",
|
|
2881
|
+
"Ø": "O",
|
|
2882
|
+
"ò": "o",
|
|
2883
|
+
"ó": "o",
|
|
2884
|
+
"ô": "o",
|
|
2885
|
+
"õ": "o",
|
|
2886
|
+
"ö": "o",
|
|
2887
|
+
"ø": "o",
|
|
2888
|
+
"Ù": "U",
|
|
2889
|
+
"Ú": "U",
|
|
2890
|
+
"Û": "U",
|
|
2891
|
+
"Ü": "U",
|
|
2892
|
+
"ù": "u",
|
|
2893
|
+
"ú": "u",
|
|
2894
|
+
"û": "u",
|
|
2895
|
+
"ü": "u",
|
|
2896
|
+
"Ý": "Y",
|
|
2897
|
+
"ý": "y",
|
|
2898
|
+
"ÿ": "y",
|
|
2899
|
+
"Æ": "Ae",
|
|
2900
|
+
"æ": "ae",
|
|
2901
|
+
"Þ": "Th",
|
|
2902
|
+
"þ": "th",
|
|
2903
|
+
"ß": "ss",
|
|
2904
|
+
"Ā": "A",
|
|
2905
|
+
"Ă": "A",
|
|
2906
|
+
"Ą": "A",
|
|
2907
|
+
"ā": "a",
|
|
2908
|
+
"ă": "a",
|
|
2909
|
+
"ą": "a",
|
|
2910
|
+
"Ć": "C",
|
|
2911
|
+
"Ĉ": "C",
|
|
2912
|
+
"Ċ": "C",
|
|
2913
|
+
"Č": "C",
|
|
2914
|
+
"ć": "c",
|
|
2915
|
+
"ĉ": "c",
|
|
2916
|
+
"ċ": "c",
|
|
2917
|
+
"č": "c",
|
|
2918
|
+
"Ď": "D",
|
|
2919
|
+
"Đ": "D",
|
|
2920
|
+
"ď": "d",
|
|
2921
|
+
"đ": "d",
|
|
2922
|
+
"Ē": "E",
|
|
2923
|
+
"Ĕ": "E",
|
|
2924
|
+
"Ė": "E",
|
|
2925
|
+
"Ę": "E",
|
|
2926
|
+
"Ě": "E",
|
|
2927
|
+
"ē": "e",
|
|
2928
|
+
"ĕ": "e",
|
|
2929
|
+
"ė": "e",
|
|
2930
|
+
"ę": "e",
|
|
2931
|
+
"ě": "e",
|
|
2932
|
+
"Ĝ": "G",
|
|
2933
|
+
"Ğ": "G",
|
|
2934
|
+
"Ġ": "G",
|
|
2935
|
+
"Ģ": "G",
|
|
2936
|
+
"ĝ": "g",
|
|
2937
|
+
"ğ": "g",
|
|
2938
|
+
"ġ": "g",
|
|
2939
|
+
"ģ": "g",
|
|
2940
|
+
"Ĥ": "H",
|
|
2941
|
+
"Ħ": "H",
|
|
2942
|
+
"ĥ": "h",
|
|
2943
|
+
"ħ": "h",
|
|
2944
|
+
"Ĩ": "I",
|
|
2945
|
+
"Ī": "I",
|
|
2946
|
+
"Ĭ": "I",
|
|
2947
|
+
"Į": "I",
|
|
2948
|
+
"İ": "I",
|
|
2949
|
+
"ĩ": "i",
|
|
2950
|
+
"ī": "i",
|
|
2951
|
+
"ĭ": "i",
|
|
2952
|
+
"į": "i",
|
|
2953
|
+
"ı": "i",
|
|
2954
|
+
"Ĵ": "J",
|
|
2955
|
+
"ĵ": "j",
|
|
2956
|
+
"Ķ": "K",
|
|
2957
|
+
"ķ": "k",
|
|
2958
|
+
"ĸ": "k",
|
|
2959
|
+
"Ĺ": "L",
|
|
2960
|
+
"Ļ": "L",
|
|
2961
|
+
"Ľ": "L",
|
|
2962
|
+
"Ŀ": "L",
|
|
2963
|
+
"Ł": "L",
|
|
2964
|
+
"ĺ": "l",
|
|
2965
|
+
"ļ": "l",
|
|
2966
|
+
"ľ": "l",
|
|
2967
|
+
"ŀ": "l",
|
|
2968
|
+
"ł": "l",
|
|
2969
|
+
"Ń": "N",
|
|
2970
|
+
"Ņ": "N",
|
|
2971
|
+
"Ň": "N",
|
|
2972
|
+
"Ŋ": "N",
|
|
2973
|
+
"ń": "n",
|
|
2974
|
+
"ņ": "n",
|
|
2975
|
+
"ň": "n",
|
|
2976
|
+
"ŋ": "n",
|
|
2977
|
+
"Ō": "O",
|
|
2978
|
+
"Ŏ": "O",
|
|
2979
|
+
"Ő": "O",
|
|
2980
|
+
"ō": "o",
|
|
2981
|
+
"ŏ": "o",
|
|
2982
|
+
"ő": "o",
|
|
2983
|
+
"Ŕ": "R",
|
|
2984
|
+
"Ŗ": "R",
|
|
2985
|
+
"Ř": "R",
|
|
2986
|
+
"ŕ": "r",
|
|
2987
|
+
"ŗ": "r",
|
|
2988
|
+
"ř": "r",
|
|
2989
|
+
"Ś": "S",
|
|
2990
|
+
"Ŝ": "S",
|
|
2991
|
+
"Ş": "S",
|
|
2992
|
+
"Š": "S",
|
|
2993
|
+
"ś": "s",
|
|
2994
|
+
"ŝ": "s",
|
|
2995
|
+
"ş": "s",
|
|
2996
|
+
"š": "s",
|
|
2997
|
+
"Ţ": "T",
|
|
2998
|
+
"Ť": "T",
|
|
2999
|
+
"Ŧ": "T",
|
|
3000
|
+
"ţ": "t",
|
|
3001
|
+
"ť": "t",
|
|
3002
|
+
"ŧ": "t",
|
|
3003
|
+
"Ũ": "U",
|
|
3004
|
+
"Ū": "U",
|
|
3005
|
+
"Ŭ": "U",
|
|
3006
|
+
"Ů": "U",
|
|
3007
|
+
"Ű": "U",
|
|
3008
|
+
"Ų": "U",
|
|
3009
|
+
"ũ": "u",
|
|
3010
|
+
"ū": "u",
|
|
3011
|
+
"ŭ": "u",
|
|
3012
|
+
"ů": "u",
|
|
3013
|
+
"ű": "u",
|
|
3014
|
+
"ų": "u",
|
|
3015
|
+
"Ŵ": "W",
|
|
3016
|
+
"ŵ": "w",
|
|
3017
|
+
"Ŷ": "Y",
|
|
3018
|
+
"ŷ": "y",
|
|
3019
|
+
"Ÿ": "Y",
|
|
3020
|
+
"Ź": "Z",
|
|
3021
|
+
"Ż": "Z",
|
|
3022
|
+
"Ž": "Z",
|
|
3023
|
+
"ź": "z",
|
|
3024
|
+
"ż": "z",
|
|
3025
|
+
"ž": "z",
|
|
3026
|
+
"IJ": "IJ",
|
|
3027
|
+
"ij": "ij",
|
|
3028
|
+
"Œ": "Oe",
|
|
3029
|
+
"œ": "oe",
|
|
3030
|
+
"ʼn": "'n",
|
|
3031
|
+
"ſ": "s"
|
|
3032
|
+
});
|
|
3033
|
+
var _deburrLetter_default = deburrLetter;
|
|
3034
|
+
|
|
3035
|
+
//#endregion
|
|
3036
|
+
//#region node_modules/lodash-es/deburr.js
|
|
3037
|
+
/** Used to match Latin Unicode letters (excluding mathematical operators). */
|
|
3038
|
+
var reLatin = /[\xc0-\xd6\xd8-\xf6\xf8-\xff\u0100-\u017f]/g;
|
|
3039
|
+
/**
|
|
3040
|
+
* Used to match [combining diacritical marks](https://en.wikipedia.org/wiki/Combining_Diacritical_Marks) and
|
|
3041
|
+
* [combining diacritical marks for symbols](https://en.wikipedia.org/wiki/Combining_Diacritical_Marks_for_Symbols).
|
|
3042
|
+
*/
|
|
3043
|
+
var reComboMark = RegExp("[\\u0300-\\u036f\\ufe20-\\ufe2f\\u20d0-\\u20ff]", "g");
|
|
3044
|
+
/**
|
|
3045
|
+
* Deburrs `string` by converting
|
|
3046
|
+
* [Latin-1 Supplement](https://en.wikipedia.org/wiki/Latin-1_Supplement_(Unicode_block)#Character_table)
|
|
3047
|
+
* and [Latin Extended-A](https://en.wikipedia.org/wiki/Latin_Extended-A)
|
|
3048
|
+
* letters to basic Latin letters and removing
|
|
3049
|
+
* [combining diacritical marks](https://en.wikipedia.org/wiki/Combining_Diacritical_Marks).
|
|
3050
|
+
*
|
|
3051
|
+
* @static
|
|
3052
|
+
* @memberOf _
|
|
3053
|
+
* @since 3.0.0
|
|
3054
|
+
* @category String
|
|
3055
|
+
* @param {string} [string=''] The string to deburr.
|
|
3056
|
+
* @returns {string} Returns the deburred string.
|
|
3057
|
+
* @example
|
|
3058
|
+
*
|
|
3059
|
+
* _.deburr('déjà vu');
|
|
3060
|
+
* // => 'deja vu'
|
|
3061
|
+
*/
|
|
3062
|
+
function deburr(string) {
|
|
3063
|
+
string = toString_default(string);
|
|
3064
|
+
return string && string.replace(reLatin, _deburrLetter_default).replace(reComboMark, "");
|
|
3065
|
+
}
|
|
3066
|
+
var deburr_default = deburr;
|
|
3067
|
+
|
|
3068
|
+
//#endregion
|
|
3069
|
+
//#region node_modules/lodash-es/_asciiWords.js
|
|
3070
|
+
/** Used to match words composed of alphanumeric characters. */
|
|
3071
|
+
var reAsciiWord = /[^\x00-\x2f\x3a-\x40\x5b-\x60\x7b-\x7f]+/g;
|
|
3072
|
+
/**
|
|
3073
|
+
* Splits an ASCII `string` into an array of its words.
|
|
3074
|
+
*
|
|
3075
|
+
* @private
|
|
3076
|
+
* @param {string} The string to inspect.
|
|
3077
|
+
* @returns {Array} Returns the words of `string`.
|
|
3078
|
+
*/
|
|
3079
|
+
function asciiWords(string) {
|
|
3080
|
+
return string.match(reAsciiWord) || [];
|
|
3081
|
+
}
|
|
3082
|
+
var _asciiWords_default = asciiWords;
|
|
3083
|
+
|
|
3084
|
+
//#endregion
|
|
3085
|
+
//#region node_modules/lodash-es/_hasUnicodeWord.js
|
|
3086
|
+
/** Used to detect strings that need a more robust regexp to match words. */
|
|
3087
|
+
var reHasUnicodeWord = /[a-z][A-Z]|[A-Z]{2}[a-z]|[0-9][a-zA-Z]|[a-zA-Z][0-9]|[^a-zA-Z0-9 ]/;
|
|
3088
|
+
/**
|
|
3089
|
+
* Checks if `string` contains a word composed of Unicode symbols.
|
|
3090
|
+
*
|
|
3091
|
+
* @private
|
|
3092
|
+
* @param {string} string The string to inspect.
|
|
3093
|
+
* @returns {boolean} Returns `true` if a word is found, else `false`.
|
|
3094
|
+
*/
|
|
3095
|
+
function hasUnicodeWord(string) {
|
|
3096
|
+
return reHasUnicodeWord.test(string);
|
|
3097
|
+
}
|
|
3098
|
+
var _hasUnicodeWord_default = hasUnicodeWord;
|
|
3099
|
+
|
|
3100
|
+
//#endregion
|
|
3101
|
+
//#region node_modules/lodash-es/_unicodeWords.js
|
|
3102
|
+
/** Used to compose unicode character classes. */
|
|
3103
|
+
var rsAstralRange = "\\ud800-\\udfff", rsComboRange = "\\u0300-\\u036f\\ufe20-\\ufe2f\\u20d0-\\u20ff", rsDingbatRange = "\\u2700-\\u27bf", rsLowerRange = "a-z\\xdf-\\xf6\\xf8-\\xff", rsMathOpRange = "\\xac\\xb1\\xd7\\xf7", rsNonCharRange = "\\x00-\\x2f\\x3a-\\x40\\x5b-\\x60\\x7b-\\xbf", rsPunctuationRange = "\\u2000-\\u206f", rsSpaceRange = " \\t\\x0b\\f\\xa0\\ufeff\\n\\r\\u2028\\u2029\\u1680\\u180e\\u2000\\u2001\\u2002\\u2003\\u2004\\u2005\\u2006\\u2007\\u2008\\u2009\\u200a\\u202f\\u205f\\u3000", rsUpperRange = "A-Z\\xc0-\\xd6\\xd8-\\xde", rsVarRange = "\\ufe0e\\ufe0f", rsBreakRange = rsMathOpRange + rsNonCharRange + rsPunctuationRange + rsSpaceRange;
|
|
3104
|
+
/** Used to compose unicode capture groups. */
|
|
3105
|
+
var rsApos = "['’]", rsBreak = "[" + rsBreakRange + "]", rsCombo = "[" + rsComboRange + "]", rsDigits = "\\d+", rsDingbat = "[" + rsDingbatRange + "]", rsLower = "[" + rsLowerRange + "]", rsMisc = "[^" + rsAstralRange + rsBreakRange + rsDigits + rsDingbatRange + rsLowerRange + rsUpperRange + "]", rsModifier = "(?:" + rsCombo + "|\\ud83c[\\udffb-\\udfff])", rsNonAstral = "[^" + rsAstralRange + "]", rsRegional = "(?:\\ud83c[\\udde6-\\uddff]){2}", rsSurrPair = "[\\ud800-\\udbff][\\udc00-\\udfff]", rsUpper = "[" + rsUpperRange + "]", rsZWJ = "\\u200d";
|
|
3106
|
+
/** Used to compose unicode regexes. */
|
|
3107
|
+
var rsMiscLower = "(?:" + rsLower + "|" + rsMisc + ")", rsMiscUpper = "(?:" + rsUpper + "|" + rsMisc + ")", rsOptContrLower = "(?:" + rsApos + "(?:d|ll|m|re|s|t|ve))?", rsOptContrUpper = "(?:" + rsApos + "(?:D|LL|M|RE|S|T|VE))?", reOptMod = rsModifier + "?", rsOptVar = "[" + rsVarRange + "]?", rsOptJoin = "(?:" + rsZWJ + "(?:" + [
|
|
3108
|
+
rsNonAstral,
|
|
3109
|
+
rsRegional,
|
|
3110
|
+
rsSurrPair
|
|
3111
|
+
].join("|") + ")" + rsOptVar + reOptMod + ")*", rsOrdLower = "\\d*(?:1st|2nd|3rd|(?![123])\\dth)(?=\\b|[A-Z_])", rsOrdUpper = "\\d*(?:1ST|2ND|3RD|(?![123])\\dTH)(?=\\b|[a-z_])", rsSeq = rsOptVar + reOptMod + rsOptJoin, rsEmoji = "(?:" + [
|
|
3112
|
+
rsDingbat,
|
|
3113
|
+
rsRegional,
|
|
3114
|
+
rsSurrPair
|
|
3115
|
+
].join("|") + ")" + rsSeq;
|
|
3116
|
+
/** Used to match complex or compound words. */
|
|
3117
|
+
var reUnicodeWord = RegExp([
|
|
3118
|
+
rsUpper + "?" + rsLower + "+" + rsOptContrLower + "(?=" + [
|
|
3119
|
+
rsBreak,
|
|
3120
|
+
rsUpper,
|
|
3121
|
+
"$"
|
|
3122
|
+
].join("|") + ")",
|
|
3123
|
+
rsMiscUpper + "+" + rsOptContrUpper + "(?=" + [
|
|
3124
|
+
rsBreak,
|
|
3125
|
+
rsUpper + rsMiscLower,
|
|
3126
|
+
"$"
|
|
3127
|
+
].join("|") + ")",
|
|
3128
|
+
rsUpper + "?" + rsMiscLower + "+" + rsOptContrLower,
|
|
3129
|
+
rsUpper + "+" + rsOptContrUpper,
|
|
3130
|
+
rsOrdUpper,
|
|
3131
|
+
rsOrdLower,
|
|
3132
|
+
rsDigits,
|
|
3133
|
+
rsEmoji
|
|
3134
|
+
].join("|"), "g");
|
|
3135
|
+
/**
|
|
3136
|
+
* Splits a Unicode `string` into an array of its words.
|
|
3137
|
+
*
|
|
3138
|
+
* @private
|
|
3139
|
+
* @param {string} The string to inspect.
|
|
3140
|
+
* @returns {Array} Returns the words of `string`.
|
|
3141
|
+
*/
|
|
3142
|
+
function unicodeWords(string) {
|
|
3143
|
+
return string.match(reUnicodeWord) || [];
|
|
3144
|
+
}
|
|
3145
|
+
var _unicodeWords_default = unicodeWords;
|
|
3146
|
+
|
|
3147
|
+
//#endregion
|
|
3148
|
+
//#region node_modules/lodash-es/words.js
|
|
3149
|
+
/**
|
|
3150
|
+
* Splits `string` into an array of its words.
|
|
3151
|
+
*
|
|
3152
|
+
* @static
|
|
3153
|
+
* @memberOf _
|
|
3154
|
+
* @since 3.0.0
|
|
3155
|
+
* @category String
|
|
3156
|
+
* @param {string} [string=''] The string to inspect.
|
|
3157
|
+
* @param {RegExp|string} [pattern] The pattern to match words.
|
|
3158
|
+
* @param- {Object} [guard] Enables use as an iteratee for methods like `_.map`.
|
|
3159
|
+
* @returns {Array} Returns the words of `string`.
|
|
3160
|
+
* @example
|
|
3161
|
+
*
|
|
3162
|
+
* _.words('fred, barney, & pebbles');
|
|
3163
|
+
* // => ['fred', 'barney', 'pebbles']
|
|
3164
|
+
*
|
|
3165
|
+
* _.words('fred, barney, & pebbles', /[^, ]+/g);
|
|
3166
|
+
* // => ['fred', 'barney', '&', 'pebbles']
|
|
3167
|
+
*/
|
|
3168
|
+
function words(string, pattern, guard) {
|
|
3169
|
+
string = toString_default(string);
|
|
3170
|
+
pattern = guard ? void 0 : pattern;
|
|
3171
|
+
if (pattern === void 0) return _hasUnicodeWord_default(string) ? _unicodeWords_default(string) : _asciiWords_default(string);
|
|
3172
|
+
return string.match(pattern) || [];
|
|
3173
|
+
}
|
|
3174
|
+
var words_default = words;
|
|
3175
|
+
|
|
3176
|
+
//#endregion
|
|
3177
|
+
//#region node_modules/lodash-es/_createCompounder.js
|
|
3178
|
+
/** Used to match apostrophes. */
|
|
3179
|
+
var reApos = RegExp("['’]", "g");
|
|
3180
|
+
/**
|
|
3181
|
+
* Creates a function like `_.camelCase`.
|
|
3182
|
+
*
|
|
3183
|
+
* @private
|
|
3184
|
+
* @param {Function} callback The function to combine each word.
|
|
3185
|
+
* @returns {Function} Returns the new compounder function.
|
|
3186
|
+
*/
|
|
3187
|
+
function createCompounder(callback) {
|
|
3188
|
+
return function(string) {
|
|
3189
|
+
return _arrayReduce_default(words_default(deburr_default(string).replace(reApos, "")), callback, "");
|
|
3190
|
+
};
|
|
3191
|
+
}
|
|
3192
|
+
var _createCompounder_default = createCompounder;
|
|
3193
|
+
|
|
3194
|
+
//#endregion
|
|
3195
|
+
//#region node_modules/lodash-es/camelCase.js
|
|
3196
|
+
/**
|
|
3197
|
+
* Converts `string` to [camel case](https://en.wikipedia.org/wiki/CamelCase).
|
|
3198
|
+
*
|
|
3199
|
+
* @static
|
|
3200
|
+
* @memberOf _
|
|
3201
|
+
* @since 3.0.0
|
|
3202
|
+
* @category String
|
|
3203
|
+
* @param {string} [string=''] The string to convert.
|
|
3204
|
+
* @returns {string} Returns the camel cased string.
|
|
3205
|
+
* @example
|
|
3206
|
+
*
|
|
3207
|
+
* _.camelCase('Foo Bar');
|
|
3208
|
+
* // => 'fooBar'
|
|
3209
|
+
*
|
|
3210
|
+
* _.camelCase('--foo-bar--');
|
|
3211
|
+
* // => 'fooBar'
|
|
3212
|
+
*
|
|
3213
|
+
* _.camelCase('__FOO_BAR__');
|
|
3214
|
+
* // => 'fooBar'
|
|
3215
|
+
*/
|
|
3216
|
+
var camelCase$1 = _createCompounder_default(function(result, word, index) {
|
|
3217
|
+
word = word.toLowerCase();
|
|
3218
|
+
return result + (index ? capitalize_default(word) : word);
|
|
3219
|
+
});
|
|
3220
|
+
var camelCase_default = camelCase$1;
|
|
3221
|
+
|
|
3222
|
+
//#endregion
|
|
3223
|
+
//#region src/utils.ts
|
|
3224
|
+
function camelCase(str) {
|
|
3225
|
+
if (!str) return str;
|
|
3226
|
+
if (str.startsWith("_")) {
|
|
3227
|
+
const leadingChars = str.match(/^_+/);
|
|
3228
|
+
return leadingChars[0] + camelCase_default(str.slice(leadingChars[0].length));
|
|
3229
|
+
}
|
|
3230
|
+
if (str.endsWith("_")) {
|
|
3231
|
+
const leadingChars = str.match(/_+$/);
|
|
3232
|
+
return camelCase_default(str.slice(0, str.length - leadingChars[0].length)) + leadingChars[0];
|
|
3233
|
+
}
|
|
3234
|
+
return camelCase_default(str);
|
|
3235
|
+
}
|
|
3236
|
+
function capitalize(str) {
|
|
3237
|
+
if (!str) return str;
|
|
3238
|
+
return str.charAt(0).toUpperCase() + str.slice(1);
|
|
3239
|
+
}
|
|
3240
|
+
|
|
3241
|
+
//#endregion
|
|
3242
|
+
//#region src/helpers/files.ts
|
|
3243
|
+
const ensurePath = async (path$2, clear = false) => {
|
|
3244
|
+
if (clear) await rimraf(resolve(...path$2));
|
|
3245
|
+
await mkdir(resolve(...path$2), { recursive: true });
|
|
3246
|
+
};
|
|
3247
|
+
const writeFileToPath = async (path$2, content) => {
|
|
3248
|
+
await mkdir(resolve(...path$2, ".."), { recursive: true });
|
|
3249
|
+
await writeFile(resolve(...path$2), content, "utf-8");
|
|
3250
|
+
};
|
|
3251
|
+
/**
|
|
3252
|
+
* Remove files/directories matching a glob pattern.
|
|
3253
|
+
*
|
|
3254
|
+
* @param pattern Glob pattern (e.g. "dist/**")
|
|
3255
|
+
* @param cwd Optional working directory
|
|
3256
|
+
*/
|
|
3257
|
+
async function rimraf(pattern, cwd = process.cwd()) {
|
|
3258
|
+
const matches = glob(pattern, { cwd });
|
|
3259
|
+
for await (const match of matches) await rm(resolve(cwd, match), {
|
|
3260
|
+
force: true,
|
|
3261
|
+
recursive: true
|
|
3262
|
+
});
|
|
3263
|
+
}
|
|
3264
|
+
|
|
3265
|
+
//#endregion
|
|
3266
|
+
//#region src/config.ts
|
|
3267
|
+
const RUNTIME_LIB_NAME = "./runtime";
|
|
3268
|
+
|
|
3269
|
+
//#endregion
|
|
3270
|
+
//#region src/render/requestTypes/requestTypeName.ts
|
|
3271
|
+
const requestTypeName = (type) => {
|
|
3272
|
+
if (!type) return "";
|
|
3273
|
+
return `${type.name}GenqlSelection`;
|
|
3274
|
+
};
|
|
3275
|
+
|
|
3276
|
+
//#endregion
|
|
3277
|
+
//#region src/render/client/renderClient.ts
|
|
3278
|
+
const renderClientCode = (ctx) => {
|
|
3279
|
+
const url$1 = ctx.config?.endpoint ? `"${ctx.config.endpoint}"` : "undefined";
|
|
3280
|
+
const fetchImport = ctx.config?.fetchImport;
|
|
3281
|
+
return `
|
|
3282
|
+
function(options${url$1 ? "?" : ""}: ClientOptions): Client {
|
|
3283
|
+
return createClientOriginal({
|
|
3284
|
+
url: ${url$1},
|
|
3285
|
+
${fetchImport ? `fetch,` : ""}
|
|
3286
|
+
...options,
|
|
3287
|
+
queryRoot: typeMap.Query!,
|
|
3288
|
+
mutationRoot: typeMap.Mutation!,
|
|
3289
|
+
subscriptionRoot: typeMap.Subscription!,
|
|
3290
|
+
}) as any
|
|
3291
|
+
}`;
|
|
3292
|
+
};
|
|
3293
|
+
const renderClientEsm = (schema, ctx) => {
|
|
3294
|
+
const queryType = schema.getQueryType();
|
|
3295
|
+
const mutationType = schema.getMutationType();
|
|
3296
|
+
const subscriptionType = schema.getSubscriptionType();
|
|
3297
|
+
const fetchImport = ctx.config?.fetchImport || "";
|
|
3298
|
+
ctx.addCodeBlock(`
|
|
3299
|
+
${fetchImport}
|
|
3300
|
+
${renderClientTypesImports({
|
|
3301
|
+
mutationType,
|
|
3302
|
+
queryType,
|
|
3303
|
+
subscriptionType
|
|
3304
|
+
})}
|
|
3305
|
+
import {
|
|
3306
|
+
linkTypeMap,
|
|
3307
|
+
createClient as createClientOriginal,
|
|
3308
|
+
generateGraphqlOperation,
|
|
3309
|
+
type FieldsSelection, type GraphqlOperation, type ClientOptions, GenqlError
|
|
3310
|
+
} from '${RUNTIME_LIB_NAME}'
|
|
3311
|
+
export type { FieldsSelection } from '${RUNTIME_LIB_NAME}'
|
|
3312
|
+
export { GenqlError }
|
|
3313
|
+
|
|
3314
|
+
import types from './types'
|
|
3315
|
+
export * from './schema'
|
|
3316
|
+
const typeMap = linkTypeMap(types as any)
|
|
3317
|
+
|
|
3318
|
+
${renderClientType({
|
|
3319
|
+
mutationType,
|
|
3320
|
+
queryType,
|
|
3321
|
+
subscriptionType
|
|
3322
|
+
})}
|
|
3323
|
+
|
|
3324
|
+
export const createClient = ${renderClientCode(ctx)}
|
|
3325
|
+
|
|
3326
|
+
export const everything = {
|
|
3327
|
+
__scalar: true
|
|
3328
|
+
}
|
|
3329
|
+
`);
|
|
3330
|
+
if (queryType) ctx.addCodeBlock(`
|
|
3331
|
+
export type QueryResult<fields extends ${requestTypeName(queryType)}> = FieldsSelection<${queryType.name}, fields>
|
|
3332
|
+
export const generateQueryOp: (fields: ${requestTypeName(queryType)} & { __name?: string }) => GraphqlOperation = function(fields) {
|
|
3333
|
+
return generateGraphqlOperation('query', typeMap.Query!, fields as any)
|
|
3334
|
+
}
|
|
3335
|
+
`);
|
|
3336
|
+
if (mutationType) ctx.addCodeBlock(`
|
|
3337
|
+
export type MutationResult<fields extends ${requestTypeName(mutationType)}> = FieldsSelection<${mutationType.name}, fields>
|
|
3338
|
+
export const generateMutationOp: (fields: ${requestTypeName(mutationType)} & { __name?: string }) => GraphqlOperation = function(fields) {
|
|
3339
|
+
return generateGraphqlOperation('mutation', typeMap.Mutation!, fields as any)
|
|
3340
|
+
}
|
|
3341
|
+
`);
|
|
3342
|
+
if (subscriptionType) ctx.addCodeBlock(`
|
|
3343
|
+
export type SubscriptionResult<fields extends ${requestTypeName(subscriptionType)}> = FieldsSelection<${subscriptionType.name}, fields>
|
|
3344
|
+
export const generateSubscriptionOp: (fields: ${requestTypeName(subscriptionType)} & { __name?: string }) => GraphqlOperation = function(fields) {
|
|
3345
|
+
return generateGraphqlOperation('subscription', typeMap.Subscription!, fields as any)
|
|
3346
|
+
}
|
|
3347
|
+
`);
|
|
3348
|
+
};
|
|
3349
|
+
function renderClientTypesImports({ queryType, mutationType, subscriptionType }) {
|
|
3350
|
+
const imports = [];
|
|
3351
|
+
if (queryType) imports.push(requestTypeName(queryType), queryType.name);
|
|
3352
|
+
if (mutationType) imports.push(requestTypeName(mutationType), mutationType.name);
|
|
3353
|
+
if (subscriptionType) imports.push(requestTypeName(subscriptionType), subscriptionType.name);
|
|
3354
|
+
if (imports.length > 0) return `import type {${imports.join(",")}} from './schema'`;
|
|
3355
|
+
return "";
|
|
3356
|
+
}
|
|
3357
|
+
function renderClientType({ queryType, mutationType, subscriptionType }) {
|
|
3358
|
+
let interfaceContent = "";
|
|
3359
|
+
if (queryType) interfaceContent += `
|
|
3360
|
+
query<R extends ${requestTypeName(queryType)}>(
|
|
3361
|
+
request: R & { __name?: string },
|
|
3362
|
+
): Promise<FieldsSelection<${queryType.name}, R>>
|
|
3363
|
+
`;
|
|
3364
|
+
if (mutationType) interfaceContent += `
|
|
3365
|
+
mutation<R extends ${requestTypeName(mutationType)}>(
|
|
3366
|
+
request: R & { __name?: string },
|
|
3367
|
+
): Promise<FieldsSelection<${mutationType.name}, R>>
|
|
3368
|
+
`;
|
|
3369
|
+
return `
|
|
3370
|
+
export interface Client {
|
|
3371
|
+
${interfaceContent}
|
|
3372
|
+
}
|
|
3373
|
+
`;
|
|
3374
|
+
}
|
|
3375
|
+
|
|
3376
|
+
//#endregion
|
|
3377
|
+
//#region src/render/common/excludedTypes.ts
|
|
3378
|
+
const excludedTypes = [
|
|
3379
|
+
"__Schema",
|
|
3380
|
+
"__Type",
|
|
3381
|
+
"__TypeKind",
|
|
3382
|
+
"__Field",
|
|
3383
|
+
"__InputValue",
|
|
3384
|
+
"__EnumValue",
|
|
3385
|
+
"__Directive",
|
|
3386
|
+
"__DirectiveLocation"
|
|
3387
|
+
];
|
|
3388
|
+
|
|
3389
|
+
//#endregion
|
|
3390
|
+
//#region src/helpers/prettify.ts
|
|
3391
|
+
function prettify(code, parser) {
|
|
3392
|
+
const hasPrettier = import.meta.resolve("prettier");
|
|
3393
|
+
if (parser === "skip" || !hasPrettier) return code;
|
|
3394
|
+
return new Promise(async (resolve$2, reject) => {
|
|
3395
|
+
try {
|
|
3396
|
+
const prettier = await import("prettier/standalone.js").then(({ default: mod }) => mod);
|
|
3397
|
+
const parserTS = await import("prettier/plugins/typescript.js").then(({ default: mod }) => mod);
|
|
3398
|
+
const parserEstree = await import("prettier/plugins/estree.js").then(({ default: mod }) => mod);
|
|
3399
|
+
const parserGraphQL = await import("prettier/plugins/graphql.js").then(({ default: mod }) => mod);
|
|
3400
|
+
resolve$2(await prettier.format(code, {
|
|
3401
|
+
parser,
|
|
3402
|
+
plugins: [
|
|
3403
|
+
parserGraphQL,
|
|
3404
|
+
parserTS,
|
|
3405
|
+
parserEstree
|
|
3406
|
+
],
|
|
3407
|
+
semi: false,
|
|
3408
|
+
singleQuote: true,
|
|
3409
|
+
trailingComma: "all",
|
|
3410
|
+
printWidth: 80
|
|
3411
|
+
}));
|
|
3412
|
+
} catch (e) {
|
|
3413
|
+
reject(e);
|
|
3414
|
+
}
|
|
3415
|
+
});
|
|
3416
|
+
}
|
|
3417
|
+
|
|
3418
|
+
//#endregion
|
|
3419
|
+
//#region src/render/common/relativeImportPath.ts
|
|
3420
|
+
const relativeImportPath = (from, to) => {
|
|
3421
|
+
const fromResolved = path$1.relative(from, to);
|
|
3422
|
+
return fromResolved[0] === "." ? fromResolved : `./${fromResolved}`;
|
|
3423
|
+
};
|
|
3424
|
+
|
|
3425
|
+
//#endregion
|
|
3426
|
+
//#region src/render/common/RenderContext.ts
|
|
3427
|
+
var RenderContext = class {
|
|
3428
|
+
codeBlocks = [];
|
|
3429
|
+
imports = {};
|
|
3430
|
+
importAliasCounter = 0;
|
|
3431
|
+
constructor(schema, config) {
|
|
3432
|
+
this.schema = schema;
|
|
3433
|
+
this.config = config;
|
|
3434
|
+
}
|
|
3435
|
+
addCodeBlock(block) {
|
|
3436
|
+
if (block) this.codeBlocks.push(block);
|
|
3437
|
+
}
|
|
3438
|
+
addImport(from, isDefault, module$1, fromAbsolute, noAlias) {
|
|
3439
|
+
if (this.config && this.config.output) from = fromAbsolute ? from : relativeImportPath(this.config.output, from);
|
|
3440
|
+
if (!this.imports[from]) this.imports[from] = [];
|
|
3441
|
+
const imports = this.imports[from];
|
|
3442
|
+
const existing = imports.find((i) => isDefault && i.isDefault || !isDefault && i.module === module$1);
|
|
3443
|
+
if (existing) return existing.alias;
|
|
3444
|
+
this.importAliasCounter++;
|
|
3445
|
+
const alias = noAlias ? void 0 : `a${this.importAliasCounter}`;
|
|
3446
|
+
imports.push({
|
|
3447
|
+
isDefault,
|
|
3448
|
+
module: module$1,
|
|
3449
|
+
alias
|
|
3450
|
+
});
|
|
3451
|
+
return alias;
|
|
3452
|
+
}
|
|
3453
|
+
getImportBlock() {
|
|
3454
|
+
const imports = [];
|
|
3455
|
+
Object.keys(this.imports).forEach((from) => {
|
|
3456
|
+
let defaultImport = this.imports[from].find((i) => i.isDefault);
|
|
3457
|
+
const namedImports = this.imports[from].filter((i) => !i.isDefault);
|
|
3458
|
+
const statements = [];
|
|
3459
|
+
if (defaultImport) statements.push(defaultImport.alias || "");
|
|
3460
|
+
if (namedImports.length > 0) statements.push(`{${namedImports.map((i) => i.alias ? `${i.module} as ${i.alias}` : i.module).join(",")}}`);
|
|
3461
|
+
imports.push(`import ${statements.join(",")} from '${from}'`);
|
|
3462
|
+
});
|
|
3463
|
+
if (imports.length > 0) return imports.join("\n");
|
|
3464
|
+
else return;
|
|
3465
|
+
}
|
|
3466
|
+
toCode(parser, pretty = false) {
|
|
3467
|
+
const blocks = [...this.codeBlocks];
|
|
3468
|
+
if (parser && (parser === "typescript" || parser === "babel")) {
|
|
3469
|
+
const importBlock = this.getImportBlock();
|
|
3470
|
+
if (importBlock) blocks.unshift(importBlock);
|
|
3471
|
+
}
|
|
3472
|
+
if (parser) {
|
|
3473
|
+
const whiteSpaced = blocks.join("\n\n");
|
|
3474
|
+
if (pretty && parser !== "skip") return prettify(whiteSpaced, parser);
|
|
3475
|
+
return whiteSpaced;
|
|
3476
|
+
}
|
|
3477
|
+
return blocks.join("");
|
|
3478
|
+
}
|
|
3479
|
+
};
|
|
3480
|
+
|
|
3481
|
+
//#endregion
|
|
3482
|
+
//#region src/render/common/comment.ts
|
|
3483
|
+
const comment = (comment$1) => {
|
|
3484
|
+
const lines = [];
|
|
3485
|
+
if (comment$1.deprecated) lines.push(`@deprecated ${comment$1.deprecated.replace(/\s/g, " ")}`);
|
|
3486
|
+
if (comment$1.text) lines.push(...comment$1.text.split("\n"));
|
|
3487
|
+
return lines.length > 0 ? lines.length === 1 ? `\n/** ${lines[0]} */\n` : `\n/**\n${lines.map((l) => ` * ${l}`).join("\n")}\n */\n` : "";
|
|
3488
|
+
};
|
|
3489
|
+
const typeComment = (type) => comment({ text: type.description });
|
|
3490
|
+
const fieldComment = (field) => comment({
|
|
3491
|
+
deprecated: field.deprecationReason,
|
|
3492
|
+
text: field.description
|
|
3493
|
+
});
|
|
3494
|
+
const argumentComment = (arg) => comment({ text: arg.description });
|
|
3495
|
+
|
|
3496
|
+
//#endregion
|
|
3497
|
+
//#region src/render/common/renderTyping.ts
|
|
3498
|
+
const renderTyping = (type, nonNull = false, wrap = (x) => x) => {
|
|
3499
|
+
if (isNamedType(type)) {
|
|
3500
|
+
let typeName = type.name;
|
|
3501
|
+
if (isScalarType(type)) typeName = `Scalars['${typeName}']`;
|
|
3502
|
+
const typing = wrap(typeName);
|
|
3503
|
+
return nonNull ? typing : `(${typing} | null)`;
|
|
3504
|
+
}
|
|
3505
|
+
if (isListType(type)) {
|
|
3506
|
+
const typing = `${renderTyping(type.ofType, false, wrap)}[]`;
|
|
3507
|
+
return nonNull ? typing : `(${typing} | null)`;
|
|
3508
|
+
}
|
|
3509
|
+
return renderTyping(type.ofType, true, wrap);
|
|
3510
|
+
};
|
|
3511
|
+
|
|
3512
|
+
//#endregion
|
|
3513
|
+
//#region src/render/common/support.ts
|
|
3514
|
+
function sortKeys(obj) {
|
|
3515
|
+
obj = obj || {};
|
|
3516
|
+
const ordered = {};
|
|
3517
|
+
Object.keys(obj).sort().forEach(function(key) {
|
|
3518
|
+
ordered[key] = obj[key];
|
|
3519
|
+
});
|
|
3520
|
+
return ordered;
|
|
3521
|
+
}
|
|
3522
|
+
|
|
3523
|
+
//#endregion
|
|
3524
|
+
//#region src/render/requestTypes/inputObjectType.ts
|
|
3525
|
+
const inputObjectType = (type, ctx) => {
|
|
3526
|
+
let fields = type.getFields();
|
|
3527
|
+
if (ctx.config?.sortProperties) fields = sortKeys(fields);
|
|
3528
|
+
const fieldStrings = Object.keys(fields).map((fieldName) => {
|
|
3529
|
+
const field = fields[fieldName];
|
|
3530
|
+
return `${argumentComment(field)}${field.name}${isNonNullType(field.type) && field.defaultValue == null ? ":" : "?:"} ${renderTyping(field.type)}`;
|
|
3531
|
+
});
|
|
3532
|
+
ctx.addCodeBlock(`${typeComment(type)}export interface ${type.name} {${fieldStrings.join(",")}}`);
|
|
3533
|
+
};
|
|
3534
|
+
|
|
3535
|
+
//#endregion
|
|
3536
|
+
//#region src/render/requestTypes/objectType.ts
|
|
3537
|
+
const INDENTATION$1 = " ";
|
|
3538
|
+
const objectType$2 = (type, ctx) => {
|
|
3539
|
+
let fields = type.getFields();
|
|
3540
|
+
if (ctx.config?.sortProperties) fields = sortKeys(fields);
|
|
3541
|
+
let fieldStrings = Object.keys(fields).map((fieldName) => {
|
|
3542
|
+
const field = fields[fieldName];
|
|
3543
|
+
const types = [];
|
|
3544
|
+
const resolvedType = getNamedType(field.type);
|
|
3545
|
+
const resolvable = !(isEnumType(resolvedType) || isScalarType(resolvedType));
|
|
3546
|
+
const argsPresent = field.args.length > 0;
|
|
3547
|
+
const argsString = toArgsString(field);
|
|
3548
|
+
const argsOptional = !argsString.match(/[^?]:/);
|
|
3549
|
+
if (argsPresent) if (resolvable) types.push(`(${requestTypeName(resolvedType)} & { __args${argsOptional ? "?" : ""}: ${argsString} })`);
|
|
3550
|
+
else types.push(`{ __args: ${argsString} }`);
|
|
3551
|
+
if (argsOptional && !resolvable) types.push("boolean | number");
|
|
3552
|
+
if (!argsPresent && resolvable) types.push(requestTypeName(resolvedType));
|
|
3553
|
+
return `${fieldComment(field)}${field.name}?: ${types.join(" | ")}`;
|
|
3554
|
+
});
|
|
3555
|
+
if (isInterfaceType(type) && ctx.schema) {
|
|
3556
|
+
let interfaceProperties = ctx.schema.getPossibleTypes(type).map((t) => `on_${t.name}?: ${requestTypeName(t)}`);
|
|
3557
|
+
if (ctx.config?.sortProperties) interfaceProperties = interfaceProperties.sort();
|
|
3558
|
+
fieldStrings = fieldStrings.concat(interfaceProperties);
|
|
3559
|
+
}
|
|
3560
|
+
fieldStrings.push("__typename?: boolean | number");
|
|
3561
|
+
fieldStrings.push("__scalar?: boolean | number");
|
|
3562
|
+
fieldStrings = fieldStrings.map((x) => x.split("\n").filter(Boolean).map((l) => INDENTATION$1 + l).join("\n"));
|
|
3563
|
+
ctx.addCodeBlock(`${typeComment(type)}export interface ${requestTypeName(type)}{\n${fieldStrings.join("\n")}\n}`);
|
|
3564
|
+
};
|
|
3565
|
+
const toArgsString = (field) => {
|
|
3566
|
+
return `{${field.args.map((a) => `${argumentComment(a)}${a.name}${isNonNullType(a.type) && a.defaultValue == null ? ":" : "?:"} ${renderTyping(a.type)}`).join(", ")}}`;
|
|
3567
|
+
};
|
|
3568
|
+
|
|
3569
|
+
//#endregion
|
|
3570
|
+
//#region node_modules/lodash-es/isObject.js
|
|
3571
|
+
/**
|
|
3572
|
+
* Checks if `value` is the
|
|
3573
|
+
* [language type](http://www.ecma-international.org/ecma-262/7.0/#sec-ecmascript-language-types)
|
|
3574
|
+
* of `Object`. (e.g. arrays, functions, objects, regexes, `new Number(0)`, and `new String('')`)
|
|
3575
|
+
*
|
|
3576
|
+
* @static
|
|
3577
|
+
* @memberOf _
|
|
3578
|
+
* @since 0.1.0
|
|
3579
|
+
* @category Lang
|
|
3580
|
+
* @param {*} value The value to check.
|
|
3581
|
+
* @returns {boolean} Returns `true` if `value` is an object, else `false`.
|
|
3582
|
+
* @example
|
|
3583
|
+
*
|
|
3584
|
+
* _.isObject({});
|
|
3585
|
+
* // => true
|
|
3586
|
+
*
|
|
3587
|
+
* _.isObject([1, 2, 3]);
|
|
3588
|
+
* // => true
|
|
3589
|
+
*
|
|
3590
|
+
* _.isObject(_.noop);
|
|
3591
|
+
* // => true
|
|
3592
|
+
*
|
|
3593
|
+
* _.isObject(null);
|
|
3594
|
+
* // => false
|
|
3595
|
+
*/
|
|
3596
|
+
function isObject(value) {
|
|
3597
|
+
var type = typeof value;
|
|
3598
|
+
return value != null && (type == "object" || type == "function");
|
|
3599
|
+
}
|
|
3600
|
+
var isObject_default = isObject;
|
|
3601
|
+
|
|
3602
|
+
//#endregion
|
|
3603
|
+
//#region node_modules/lodash-es/isFunction.js
|
|
3604
|
+
/** `Object#toString` result references. */
|
|
3605
|
+
var asyncTag = "[object AsyncFunction]", funcTag = "[object Function]", genTag = "[object GeneratorFunction]", proxyTag = "[object Proxy]";
|
|
3606
|
+
/**
|
|
3607
|
+
* Checks if `value` is classified as a `Function` object.
|
|
3608
|
+
*
|
|
3609
|
+
* @static
|
|
3610
|
+
* @memberOf _
|
|
3611
|
+
* @since 0.1.0
|
|
3612
|
+
* @category Lang
|
|
3613
|
+
* @param {*} value The value to check.
|
|
3614
|
+
* @returns {boolean} Returns `true` if `value` is a function, else `false`.
|
|
3615
|
+
* @example
|
|
3616
|
+
*
|
|
3617
|
+
* _.isFunction(_);
|
|
3618
|
+
* // => true
|
|
3619
|
+
*
|
|
3620
|
+
* _.isFunction(/abc/);
|
|
3621
|
+
* // => false
|
|
3622
|
+
*/
|
|
3623
|
+
function isFunction(value) {
|
|
3624
|
+
if (!isObject_default(value)) return false;
|
|
3625
|
+
var tag = _baseGetTag_default(value);
|
|
3626
|
+
return tag == funcTag || tag == genTag || tag == asyncTag || tag == proxyTag;
|
|
3627
|
+
}
|
|
3628
|
+
var isFunction_default = isFunction;
|
|
3629
|
+
|
|
3630
|
+
//#endregion
|
|
3631
|
+
//#region node_modules/lodash-es/_coreJsData.js
|
|
3632
|
+
/** Used to detect overreaching core-js shims. */
|
|
3633
|
+
var coreJsData = _root_default["__core-js_shared__"];
|
|
3634
|
+
var _coreJsData_default = coreJsData;
|
|
3635
|
+
|
|
3636
|
+
//#endregion
|
|
3637
|
+
//#region node_modules/lodash-es/_isMasked.js
|
|
3638
|
+
/** Used to detect methods masquerading as native. */
|
|
3639
|
+
var maskSrcKey = function() {
|
|
3640
|
+
var uid = /[^.]+$/.exec(_coreJsData_default && _coreJsData_default.keys && _coreJsData_default.keys.IE_PROTO || "");
|
|
3641
|
+
return uid ? "Symbol(src)_1." + uid : "";
|
|
3642
|
+
}();
|
|
3643
|
+
/**
|
|
3644
|
+
* Checks if `func` has its source masked.
|
|
3645
|
+
*
|
|
3646
|
+
* @private
|
|
3647
|
+
* @param {Function} func The function to check.
|
|
3648
|
+
* @returns {boolean} Returns `true` if `func` is masked, else `false`.
|
|
3649
|
+
*/
|
|
3650
|
+
function isMasked(func) {
|
|
3651
|
+
return !!maskSrcKey && maskSrcKey in func;
|
|
3652
|
+
}
|
|
3653
|
+
var _isMasked_default = isMasked;
|
|
3654
|
+
|
|
3655
|
+
//#endregion
|
|
3656
|
+
//#region node_modules/lodash-es/_toSource.js
|
|
3657
|
+
/** Used to resolve the decompiled source of functions. */
|
|
3658
|
+
var funcToString$1 = Function.prototype.toString;
|
|
3659
|
+
/**
|
|
3660
|
+
* Converts `func` to its source code.
|
|
3661
|
+
*
|
|
3662
|
+
* @private
|
|
3663
|
+
* @param {Function} func The function to convert.
|
|
3664
|
+
* @returns {string} Returns the source code.
|
|
3665
|
+
*/
|
|
3666
|
+
function toSource(func) {
|
|
3667
|
+
if (func != null) {
|
|
3668
|
+
try {
|
|
3669
|
+
return funcToString$1.call(func);
|
|
3670
|
+
} catch (e) {}
|
|
3671
|
+
try {
|
|
3672
|
+
return func + "";
|
|
3673
|
+
} catch (e) {}
|
|
3674
|
+
}
|
|
3675
|
+
return "";
|
|
3676
|
+
}
|
|
3677
|
+
var _toSource_default = toSource;
|
|
3678
|
+
|
|
3679
|
+
//#endregion
|
|
3680
|
+
//#region node_modules/lodash-es/_baseIsNative.js
|
|
3681
|
+
/**
|
|
3682
|
+
* Used to match `RegExp`
|
|
3683
|
+
* [syntax characters](http://ecma-international.org/ecma-262/7.0/#sec-patterns).
|
|
3684
|
+
*/
|
|
3685
|
+
var reRegExpChar = /[\\^$.*+?()[\]{}|]/g;
|
|
3686
|
+
/** Used to detect host constructors (Safari). */
|
|
3687
|
+
var reIsHostCtor = /^\[object .+?Constructor\]$/;
|
|
3688
|
+
/** Used for built-in method references. */
|
|
3689
|
+
var funcProto = Function.prototype, objectProto = Object.prototype;
|
|
3690
|
+
/** Used to resolve the decompiled source of functions. */
|
|
3691
|
+
var funcToString = funcProto.toString;
|
|
3692
|
+
/** Used to check objects for own properties. */
|
|
3693
|
+
var hasOwnProperty$2 = objectProto.hasOwnProperty;
|
|
3694
|
+
/** Used to detect if a method is native. */
|
|
3695
|
+
var reIsNative = RegExp("^" + funcToString.call(hasOwnProperty$2).replace(reRegExpChar, "\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g, "$1.*?") + "$");
|
|
3696
|
+
/**
|
|
3697
|
+
* The base implementation of `_.isNative` without bad shim checks.
|
|
3698
|
+
*
|
|
3699
|
+
* @private
|
|
3700
|
+
* @param {*} value The value to check.
|
|
3701
|
+
* @returns {boolean} Returns `true` if `value` is a native function,
|
|
3702
|
+
* else `false`.
|
|
3703
|
+
*/
|
|
3704
|
+
function baseIsNative(value) {
|
|
3705
|
+
if (!isObject_default(value) || _isMasked_default(value)) return false;
|
|
3706
|
+
return (isFunction_default(value) ? reIsNative : reIsHostCtor).test(_toSource_default(value));
|
|
3707
|
+
}
|
|
3708
|
+
var _baseIsNative_default = baseIsNative;
|
|
3709
|
+
|
|
3710
|
+
//#endregion
|
|
3711
|
+
//#region node_modules/lodash-es/_getValue.js
|
|
3712
|
+
/**
|
|
3713
|
+
* Gets the value at `key` of `object`.
|
|
3714
|
+
*
|
|
3715
|
+
* @private
|
|
3716
|
+
* @param {Object} [object] The object to query.
|
|
3717
|
+
* @param {string} key The key of the property to get.
|
|
3718
|
+
* @returns {*} Returns the property value.
|
|
3719
|
+
*/
|
|
3720
|
+
function getValue(object, key) {
|
|
3721
|
+
return object == null ? void 0 : object[key];
|
|
3722
|
+
}
|
|
3723
|
+
var _getValue_default = getValue;
|
|
3724
|
+
|
|
3725
|
+
//#endregion
|
|
3726
|
+
//#region node_modules/lodash-es/_getNative.js
|
|
3727
|
+
/**
|
|
3728
|
+
* Gets the native function at `key` of `object`.
|
|
3729
|
+
*
|
|
3730
|
+
* @private
|
|
3731
|
+
* @param {Object} object The object to query.
|
|
3732
|
+
* @param {string} key The key of the method to get.
|
|
3733
|
+
* @returns {*} Returns the function if it's native, else `undefined`.
|
|
3734
|
+
*/
|
|
3735
|
+
function getNative(object, key) {
|
|
3736
|
+
var value = _getValue_default(object, key);
|
|
3737
|
+
return _baseIsNative_default(value) ? value : void 0;
|
|
3738
|
+
}
|
|
3739
|
+
var _getNative_default = getNative;
|
|
3740
|
+
|
|
3741
|
+
//#endregion
|
|
3742
|
+
//#region node_modules/lodash-es/_nativeCreate.js
|
|
3743
|
+
var nativeCreate = _getNative_default(Object, "create");
|
|
3744
|
+
var _nativeCreate_default = nativeCreate;
|
|
3745
|
+
|
|
3746
|
+
//#endregion
|
|
3747
|
+
//#region node_modules/lodash-es/_hashClear.js
|
|
3748
|
+
/**
|
|
3749
|
+
* Removes all key-value entries from the hash.
|
|
3750
|
+
*
|
|
3751
|
+
* @private
|
|
3752
|
+
* @name clear
|
|
3753
|
+
* @memberOf Hash
|
|
3754
|
+
*/
|
|
3755
|
+
function hashClear() {
|
|
3756
|
+
this.__data__ = _nativeCreate_default ? _nativeCreate_default(null) : {};
|
|
3757
|
+
this.size = 0;
|
|
3758
|
+
}
|
|
3759
|
+
var _hashClear_default = hashClear;
|
|
3760
|
+
|
|
3761
|
+
//#endregion
|
|
3762
|
+
//#region node_modules/lodash-es/_hashDelete.js
|
|
3763
|
+
/**
|
|
3764
|
+
* Removes `key` and its value from the hash.
|
|
3765
|
+
*
|
|
3766
|
+
* @private
|
|
3767
|
+
* @name delete
|
|
3768
|
+
* @memberOf Hash
|
|
3769
|
+
* @param {Object} hash The hash to modify.
|
|
3770
|
+
* @param {string} key The key of the value to remove.
|
|
3771
|
+
* @returns {boolean} Returns `true` if the entry was removed, else `false`.
|
|
3772
|
+
*/
|
|
3773
|
+
function hashDelete(key) {
|
|
3774
|
+
var result = this.has(key) && delete this.__data__[key];
|
|
3775
|
+
this.size -= result ? 1 : 0;
|
|
3776
|
+
return result;
|
|
3777
|
+
}
|
|
3778
|
+
var _hashDelete_default = hashDelete;
|
|
3779
|
+
|
|
3780
|
+
//#endregion
|
|
3781
|
+
//#region node_modules/lodash-es/_hashGet.js
|
|
3782
|
+
/** Used to stand-in for `undefined` hash values. */
|
|
3783
|
+
var HASH_UNDEFINED$2 = "__lodash_hash_undefined__";
|
|
3784
|
+
/** Used to check objects for own properties. */
|
|
3785
|
+
var hasOwnProperty$1 = Object.prototype.hasOwnProperty;
|
|
3786
|
+
/**
|
|
3787
|
+
* Gets the hash value for `key`.
|
|
3788
|
+
*
|
|
3789
|
+
* @private
|
|
3790
|
+
* @name get
|
|
3791
|
+
* @memberOf Hash
|
|
3792
|
+
* @param {string} key The key of the value to get.
|
|
3793
|
+
* @returns {*} Returns the entry value.
|
|
3794
|
+
*/
|
|
3795
|
+
function hashGet(key) {
|
|
3796
|
+
var data = this.__data__;
|
|
3797
|
+
if (_nativeCreate_default) {
|
|
3798
|
+
var result = data[key];
|
|
3799
|
+
return result === HASH_UNDEFINED$2 ? void 0 : result;
|
|
3800
|
+
}
|
|
3801
|
+
return hasOwnProperty$1.call(data, key) ? data[key] : void 0;
|
|
3802
|
+
}
|
|
3803
|
+
var _hashGet_default = hashGet;
|
|
3804
|
+
|
|
3805
|
+
//#endregion
|
|
3806
|
+
//#region node_modules/lodash-es/_hashHas.js
|
|
3807
|
+
/** Used to check objects for own properties. */
|
|
3808
|
+
var hasOwnProperty = Object.prototype.hasOwnProperty;
|
|
3809
|
+
/**
|
|
3810
|
+
* Checks if a hash value for `key` exists.
|
|
3811
|
+
*
|
|
3812
|
+
* @private
|
|
3813
|
+
* @name has
|
|
3814
|
+
* @memberOf Hash
|
|
3815
|
+
* @param {string} key The key of the entry to check.
|
|
3816
|
+
* @returns {boolean} Returns `true` if an entry for `key` exists, else `false`.
|
|
3817
|
+
*/
|
|
3818
|
+
function hashHas(key) {
|
|
3819
|
+
var data = this.__data__;
|
|
3820
|
+
return _nativeCreate_default ? data[key] !== void 0 : hasOwnProperty.call(data, key);
|
|
3821
|
+
}
|
|
3822
|
+
var _hashHas_default = hashHas;
|
|
3823
|
+
|
|
3824
|
+
//#endregion
|
|
3825
|
+
//#region node_modules/lodash-es/_hashSet.js
|
|
3826
|
+
/** Used to stand-in for `undefined` hash values. */
|
|
3827
|
+
var HASH_UNDEFINED$1 = "__lodash_hash_undefined__";
|
|
3828
|
+
/**
|
|
3829
|
+
* Sets the hash `key` to `value`.
|
|
3830
|
+
*
|
|
3831
|
+
* @private
|
|
3832
|
+
* @name set
|
|
3833
|
+
* @memberOf Hash
|
|
3834
|
+
* @param {string} key The key of the value to set.
|
|
3835
|
+
* @param {*} value The value to set.
|
|
3836
|
+
* @returns {Object} Returns the hash instance.
|
|
3837
|
+
*/
|
|
3838
|
+
function hashSet(key, value) {
|
|
3839
|
+
var data = this.__data__;
|
|
3840
|
+
this.size += this.has(key) ? 0 : 1;
|
|
3841
|
+
data[key] = _nativeCreate_default && value === void 0 ? HASH_UNDEFINED$1 : value;
|
|
3842
|
+
return this;
|
|
3843
|
+
}
|
|
3844
|
+
var _hashSet_default = hashSet;
|
|
3845
|
+
|
|
3846
|
+
//#endregion
|
|
3847
|
+
//#region node_modules/lodash-es/_Hash.js
|
|
3848
|
+
/**
|
|
3849
|
+
* Creates a hash object.
|
|
3850
|
+
*
|
|
3851
|
+
* @private
|
|
3852
|
+
* @constructor
|
|
3853
|
+
* @param {Array} [entries] The key-value pairs to cache.
|
|
3854
|
+
*/
|
|
3855
|
+
function Hash(entries) {
|
|
3856
|
+
var index = -1, length = entries == null ? 0 : entries.length;
|
|
3857
|
+
this.clear();
|
|
3858
|
+
while (++index < length) {
|
|
3859
|
+
var entry = entries[index];
|
|
3860
|
+
this.set(entry[0], entry[1]);
|
|
3861
|
+
}
|
|
3862
|
+
}
|
|
3863
|
+
Hash.prototype.clear = _hashClear_default;
|
|
3864
|
+
Hash.prototype["delete"] = _hashDelete_default;
|
|
3865
|
+
Hash.prototype.get = _hashGet_default;
|
|
3866
|
+
Hash.prototype.has = _hashHas_default;
|
|
3867
|
+
Hash.prototype.set = _hashSet_default;
|
|
3868
|
+
var _Hash_default = Hash;
|
|
3869
|
+
|
|
3870
|
+
//#endregion
|
|
3871
|
+
//#region node_modules/lodash-es/_listCacheClear.js
|
|
3872
|
+
/**
|
|
3873
|
+
* Removes all key-value entries from the list cache.
|
|
3874
|
+
*
|
|
3875
|
+
* @private
|
|
3876
|
+
* @name clear
|
|
3877
|
+
* @memberOf ListCache
|
|
3878
|
+
*/
|
|
3879
|
+
function listCacheClear() {
|
|
3880
|
+
this.__data__ = [];
|
|
3881
|
+
this.size = 0;
|
|
3882
|
+
}
|
|
3883
|
+
var _listCacheClear_default = listCacheClear;
|
|
3884
|
+
|
|
3885
|
+
//#endregion
|
|
3886
|
+
//#region node_modules/lodash-es/eq.js
|
|
3887
|
+
/**
|
|
3888
|
+
* Performs a
|
|
3889
|
+
* [`SameValueZero`](http://ecma-international.org/ecma-262/7.0/#sec-samevaluezero)
|
|
3890
|
+
* comparison between two values to determine if they are equivalent.
|
|
3891
|
+
*
|
|
3892
|
+
* @static
|
|
3893
|
+
* @memberOf _
|
|
3894
|
+
* @since 4.0.0
|
|
3895
|
+
* @category Lang
|
|
3896
|
+
* @param {*} value The value to compare.
|
|
3897
|
+
* @param {*} other The other value to compare.
|
|
3898
|
+
* @returns {boolean} Returns `true` if the values are equivalent, else `false`.
|
|
3899
|
+
* @example
|
|
3900
|
+
*
|
|
3901
|
+
* var object = { 'a': 1 };
|
|
3902
|
+
* var other = { 'a': 1 };
|
|
3903
|
+
*
|
|
3904
|
+
* _.eq(object, object);
|
|
3905
|
+
* // => true
|
|
3906
|
+
*
|
|
3907
|
+
* _.eq(object, other);
|
|
3908
|
+
* // => false
|
|
3909
|
+
*
|
|
3910
|
+
* _.eq('a', 'a');
|
|
3911
|
+
* // => true
|
|
3912
|
+
*
|
|
3913
|
+
* _.eq('a', Object('a'));
|
|
3914
|
+
* // => false
|
|
3915
|
+
*
|
|
3916
|
+
* _.eq(NaN, NaN);
|
|
3917
|
+
* // => true
|
|
3918
|
+
*/
|
|
3919
|
+
function eq(value, other) {
|
|
3920
|
+
return value === other || value !== value && other !== other;
|
|
3921
|
+
}
|
|
3922
|
+
var eq_default = eq;
|
|
3923
|
+
|
|
3924
|
+
//#endregion
|
|
3925
|
+
//#region node_modules/lodash-es/_assocIndexOf.js
|
|
3926
|
+
/**
|
|
3927
|
+
* Gets the index at which the `key` is found in `array` of key-value pairs.
|
|
3928
|
+
*
|
|
3929
|
+
* @private
|
|
3930
|
+
* @param {Array} array The array to inspect.
|
|
3931
|
+
* @param {*} key The key to search for.
|
|
3932
|
+
* @returns {number} Returns the index of the matched value, else `-1`.
|
|
3933
|
+
*/
|
|
3934
|
+
function assocIndexOf(array, key) {
|
|
3935
|
+
var length = array.length;
|
|
3936
|
+
while (length--) if (eq_default(array[length][0], key)) return length;
|
|
3937
|
+
return -1;
|
|
3938
|
+
}
|
|
3939
|
+
var _assocIndexOf_default = assocIndexOf;
|
|
3940
|
+
|
|
3941
|
+
//#endregion
|
|
3942
|
+
//#region node_modules/lodash-es/_listCacheDelete.js
|
|
3943
|
+
/** Built-in value references. */
|
|
3944
|
+
var splice = Array.prototype.splice;
|
|
3945
|
+
/**
|
|
3946
|
+
* Removes `key` and its value from the list cache.
|
|
3947
|
+
*
|
|
3948
|
+
* @private
|
|
3949
|
+
* @name delete
|
|
3950
|
+
* @memberOf ListCache
|
|
3951
|
+
* @param {string} key The key of the value to remove.
|
|
3952
|
+
* @returns {boolean} Returns `true` if the entry was removed, else `false`.
|
|
3953
|
+
*/
|
|
3954
|
+
function listCacheDelete(key) {
|
|
3955
|
+
var data = this.__data__, index = _assocIndexOf_default(data, key);
|
|
3956
|
+
if (index < 0) return false;
|
|
3957
|
+
if (index == data.length - 1) data.pop();
|
|
3958
|
+
else splice.call(data, index, 1);
|
|
3959
|
+
--this.size;
|
|
3960
|
+
return true;
|
|
3961
|
+
}
|
|
3962
|
+
var _listCacheDelete_default = listCacheDelete;
|
|
3963
|
+
|
|
3964
|
+
//#endregion
|
|
3965
|
+
//#region node_modules/lodash-es/_listCacheGet.js
|
|
3966
|
+
/**
|
|
3967
|
+
* Gets the list cache value for `key`.
|
|
3968
|
+
*
|
|
3969
|
+
* @private
|
|
3970
|
+
* @name get
|
|
3971
|
+
* @memberOf ListCache
|
|
3972
|
+
* @param {string} key The key of the value to get.
|
|
3973
|
+
* @returns {*} Returns the entry value.
|
|
3974
|
+
*/
|
|
3975
|
+
function listCacheGet(key) {
|
|
3976
|
+
var data = this.__data__, index = _assocIndexOf_default(data, key);
|
|
3977
|
+
return index < 0 ? void 0 : data[index][1];
|
|
3978
|
+
}
|
|
3979
|
+
var _listCacheGet_default = listCacheGet;
|
|
3980
|
+
|
|
3981
|
+
//#endregion
|
|
3982
|
+
//#region node_modules/lodash-es/_listCacheHas.js
|
|
3983
|
+
/**
|
|
3984
|
+
* Checks if a list cache value for `key` exists.
|
|
3985
|
+
*
|
|
3986
|
+
* @private
|
|
3987
|
+
* @name has
|
|
3988
|
+
* @memberOf ListCache
|
|
3989
|
+
* @param {string} key The key of the entry to check.
|
|
3990
|
+
* @returns {boolean} Returns `true` if an entry for `key` exists, else `false`.
|
|
3991
|
+
*/
|
|
3992
|
+
function listCacheHas(key) {
|
|
3993
|
+
return _assocIndexOf_default(this.__data__, key) > -1;
|
|
3994
|
+
}
|
|
3995
|
+
var _listCacheHas_default = listCacheHas;
|
|
3996
|
+
|
|
3997
|
+
//#endregion
|
|
3998
|
+
//#region node_modules/lodash-es/_listCacheSet.js
|
|
3999
|
+
/**
|
|
4000
|
+
* Sets the list cache `key` to `value`.
|
|
4001
|
+
*
|
|
4002
|
+
* @private
|
|
4003
|
+
* @name set
|
|
4004
|
+
* @memberOf ListCache
|
|
4005
|
+
* @param {string} key The key of the value to set.
|
|
4006
|
+
* @param {*} value The value to set.
|
|
4007
|
+
* @returns {Object} Returns the list cache instance.
|
|
4008
|
+
*/
|
|
4009
|
+
function listCacheSet(key, value) {
|
|
4010
|
+
var data = this.__data__, index = _assocIndexOf_default(data, key);
|
|
4011
|
+
if (index < 0) {
|
|
4012
|
+
++this.size;
|
|
4013
|
+
data.push([key, value]);
|
|
4014
|
+
} else data[index][1] = value;
|
|
4015
|
+
return this;
|
|
4016
|
+
}
|
|
4017
|
+
var _listCacheSet_default = listCacheSet;
|
|
4018
|
+
|
|
4019
|
+
//#endregion
|
|
4020
|
+
//#region node_modules/lodash-es/_ListCache.js
|
|
4021
|
+
/**
|
|
4022
|
+
* Creates an list cache object.
|
|
4023
|
+
*
|
|
4024
|
+
* @private
|
|
4025
|
+
* @constructor
|
|
4026
|
+
* @param {Array} [entries] The key-value pairs to cache.
|
|
4027
|
+
*/
|
|
4028
|
+
function ListCache(entries) {
|
|
4029
|
+
var index = -1, length = entries == null ? 0 : entries.length;
|
|
4030
|
+
this.clear();
|
|
4031
|
+
while (++index < length) {
|
|
4032
|
+
var entry = entries[index];
|
|
4033
|
+
this.set(entry[0], entry[1]);
|
|
4034
|
+
}
|
|
4035
|
+
}
|
|
4036
|
+
ListCache.prototype.clear = _listCacheClear_default;
|
|
4037
|
+
ListCache.prototype["delete"] = _listCacheDelete_default;
|
|
4038
|
+
ListCache.prototype.get = _listCacheGet_default;
|
|
4039
|
+
ListCache.prototype.has = _listCacheHas_default;
|
|
4040
|
+
ListCache.prototype.set = _listCacheSet_default;
|
|
4041
|
+
var _ListCache_default = ListCache;
|
|
4042
|
+
|
|
4043
|
+
//#endregion
|
|
4044
|
+
//#region node_modules/lodash-es/_Map.js
|
|
4045
|
+
var Map$1 = _getNative_default(_root_default, "Map");
|
|
4046
|
+
var _Map_default = Map$1;
|
|
4047
|
+
|
|
4048
|
+
//#endregion
|
|
4049
|
+
//#region node_modules/lodash-es/_mapCacheClear.js
|
|
4050
|
+
/**
|
|
4051
|
+
* Removes all key-value entries from the map.
|
|
4052
|
+
*
|
|
4053
|
+
* @private
|
|
4054
|
+
* @name clear
|
|
4055
|
+
* @memberOf MapCache
|
|
4056
|
+
*/
|
|
4057
|
+
function mapCacheClear() {
|
|
4058
|
+
this.size = 0;
|
|
4059
|
+
this.__data__ = {
|
|
4060
|
+
"hash": new _Hash_default(),
|
|
4061
|
+
"map": new (_Map_default || _ListCache_default)(),
|
|
4062
|
+
"string": new _Hash_default()
|
|
4063
|
+
};
|
|
4064
|
+
}
|
|
4065
|
+
var _mapCacheClear_default = mapCacheClear;
|
|
4066
|
+
|
|
4067
|
+
//#endregion
|
|
4068
|
+
//#region node_modules/lodash-es/_isKeyable.js
|
|
4069
|
+
/**
|
|
4070
|
+
* Checks if `value` is suitable for use as unique object key.
|
|
4071
|
+
*
|
|
4072
|
+
* @private
|
|
4073
|
+
* @param {*} value The value to check.
|
|
4074
|
+
* @returns {boolean} Returns `true` if `value` is suitable, else `false`.
|
|
4075
|
+
*/
|
|
4076
|
+
function isKeyable(value) {
|
|
4077
|
+
var type = typeof value;
|
|
4078
|
+
return type == "string" || type == "number" || type == "symbol" || type == "boolean" ? value !== "__proto__" : value === null;
|
|
4079
|
+
}
|
|
4080
|
+
var _isKeyable_default = isKeyable;
|
|
4081
|
+
|
|
4082
|
+
//#endregion
|
|
4083
|
+
//#region node_modules/lodash-es/_getMapData.js
|
|
4084
|
+
/**
|
|
4085
|
+
* Gets the data for `map`.
|
|
4086
|
+
*
|
|
4087
|
+
* @private
|
|
4088
|
+
* @param {Object} map The map to query.
|
|
4089
|
+
* @param {string} key The reference key.
|
|
4090
|
+
* @returns {*} Returns the map data.
|
|
4091
|
+
*/
|
|
4092
|
+
function getMapData(map, key) {
|
|
4093
|
+
var data = map.__data__;
|
|
4094
|
+
return _isKeyable_default(key) ? data[typeof key == "string" ? "string" : "hash"] : data.map;
|
|
4095
|
+
}
|
|
4096
|
+
var _getMapData_default = getMapData;
|
|
4097
|
+
|
|
4098
|
+
//#endregion
|
|
4099
|
+
//#region node_modules/lodash-es/_mapCacheDelete.js
|
|
4100
|
+
/**
|
|
4101
|
+
* Removes `key` and its value from the map.
|
|
4102
|
+
*
|
|
4103
|
+
* @private
|
|
4104
|
+
* @name delete
|
|
4105
|
+
* @memberOf MapCache
|
|
4106
|
+
* @param {string} key The key of the value to remove.
|
|
4107
|
+
* @returns {boolean} Returns `true` if the entry was removed, else `false`.
|
|
4108
|
+
*/
|
|
4109
|
+
function mapCacheDelete(key) {
|
|
4110
|
+
var result = _getMapData_default(this, key)["delete"](key);
|
|
4111
|
+
this.size -= result ? 1 : 0;
|
|
4112
|
+
return result;
|
|
4113
|
+
}
|
|
4114
|
+
var _mapCacheDelete_default = mapCacheDelete;
|
|
4115
|
+
|
|
4116
|
+
//#endregion
|
|
4117
|
+
//#region node_modules/lodash-es/_mapCacheGet.js
|
|
4118
|
+
/**
|
|
4119
|
+
* Gets the map value for `key`.
|
|
4120
|
+
*
|
|
4121
|
+
* @private
|
|
4122
|
+
* @name get
|
|
4123
|
+
* @memberOf MapCache
|
|
4124
|
+
* @param {string} key The key of the value to get.
|
|
4125
|
+
* @returns {*} Returns the entry value.
|
|
4126
|
+
*/
|
|
4127
|
+
function mapCacheGet(key) {
|
|
4128
|
+
return _getMapData_default(this, key).get(key);
|
|
4129
|
+
}
|
|
4130
|
+
var _mapCacheGet_default = mapCacheGet;
|
|
4131
|
+
|
|
4132
|
+
//#endregion
|
|
4133
|
+
//#region node_modules/lodash-es/_mapCacheHas.js
|
|
4134
|
+
/**
|
|
4135
|
+
* Checks if a map value for `key` exists.
|
|
4136
|
+
*
|
|
4137
|
+
* @private
|
|
4138
|
+
* @name has
|
|
4139
|
+
* @memberOf MapCache
|
|
4140
|
+
* @param {string} key The key of the entry to check.
|
|
4141
|
+
* @returns {boolean} Returns `true` if an entry for `key` exists, else `false`.
|
|
4142
|
+
*/
|
|
4143
|
+
function mapCacheHas(key) {
|
|
4144
|
+
return _getMapData_default(this, key).has(key);
|
|
4145
|
+
}
|
|
4146
|
+
var _mapCacheHas_default = mapCacheHas;
|
|
4147
|
+
|
|
4148
|
+
//#endregion
|
|
4149
|
+
//#region node_modules/lodash-es/_mapCacheSet.js
|
|
4150
|
+
/**
|
|
4151
|
+
* Sets the map `key` to `value`.
|
|
4152
|
+
*
|
|
4153
|
+
* @private
|
|
4154
|
+
* @name set
|
|
4155
|
+
* @memberOf MapCache
|
|
4156
|
+
* @param {string} key The key of the value to set.
|
|
4157
|
+
* @param {*} value The value to set.
|
|
4158
|
+
* @returns {Object} Returns the map cache instance.
|
|
4159
|
+
*/
|
|
4160
|
+
function mapCacheSet(key, value) {
|
|
4161
|
+
var data = _getMapData_default(this, key), size = data.size;
|
|
4162
|
+
data.set(key, value);
|
|
4163
|
+
this.size += data.size == size ? 0 : 1;
|
|
4164
|
+
return this;
|
|
4165
|
+
}
|
|
4166
|
+
var _mapCacheSet_default = mapCacheSet;
|
|
4167
|
+
|
|
4168
|
+
//#endregion
|
|
4169
|
+
//#region node_modules/lodash-es/_MapCache.js
|
|
4170
|
+
/**
|
|
4171
|
+
* Creates a map cache object to store key-value pairs.
|
|
4172
|
+
*
|
|
4173
|
+
* @private
|
|
4174
|
+
* @constructor
|
|
4175
|
+
* @param {Array} [entries] The key-value pairs to cache.
|
|
4176
|
+
*/
|
|
4177
|
+
function MapCache(entries) {
|
|
4178
|
+
var index = -1, length = entries == null ? 0 : entries.length;
|
|
4179
|
+
this.clear();
|
|
4180
|
+
while (++index < length) {
|
|
4181
|
+
var entry = entries[index];
|
|
4182
|
+
this.set(entry[0], entry[1]);
|
|
4183
|
+
}
|
|
4184
|
+
}
|
|
4185
|
+
MapCache.prototype.clear = _mapCacheClear_default;
|
|
4186
|
+
MapCache.prototype["delete"] = _mapCacheDelete_default;
|
|
4187
|
+
MapCache.prototype.get = _mapCacheGet_default;
|
|
4188
|
+
MapCache.prototype.has = _mapCacheHas_default;
|
|
4189
|
+
MapCache.prototype.set = _mapCacheSet_default;
|
|
4190
|
+
var _MapCache_default = MapCache;
|
|
4191
|
+
|
|
4192
|
+
//#endregion
|
|
4193
|
+
//#region node_modules/lodash-es/_setCacheAdd.js
|
|
4194
|
+
/** Used to stand-in for `undefined` hash values. */
|
|
4195
|
+
var HASH_UNDEFINED = "__lodash_hash_undefined__";
|
|
4196
|
+
/**
|
|
4197
|
+
* Adds `value` to the array cache.
|
|
4198
|
+
*
|
|
4199
|
+
* @private
|
|
4200
|
+
* @name add
|
|
4201
|
+
* @memberOf SetCache
|
|
4202
|
+
* @alias push
|
|
4203
|
+
* @param {*} value The value to cache.
|
|
4204
|
+
* @returns {Object} Returns the cache instance.
|
|
4205
|
+
*/
|
|
4206
|
+
function setCacheAdd(value) {
|
|
4207
|
+
this.__data__.set(value, HASH_UNDEFINED);
|
|
4208
|
+
return this;
|
|
4209
|
+
}
|
|
4210
|
+
var _setCacheAdd_default = setCacheAdd;
|
|
4211
|
+
|
|
4212
|
+
//#endregion
|
|
4213
|
+
//#region node_modules/lodash-es/_setCacheHas.js
|
|
4214
|
+
/**
|
|
4215
|
+
* Checks if `value` is in the array cache.
|
|
4216
|
+
*
|
|
4217
|
+
* @private
|
|
4218
|
+
* @name has
|
|
4219
|
+
* @memberOf SetCache
|
|
4220
|
+
* @param {*} value The value to search for.
|
|
4221
|
+
* @returns {number} Returns `true` if `value` is found, else `false`.
|
|
4222
|
+
*/
|
|
4223
|
+
function setCacheHas(value) {
|
|
4224
|
+
return this.__data__.has(value);
|
|
4225
|
+
}
|
|
4226
|
+
var _setCacheHas_default = setCacheHas;
|
|
4227
|
+
|
|
4228
|
+
//#endregion
|
|
4229
|
+
//#region node_modules/lodash-es/_SetCache.js
|
|
4230
|
+
/**
|
|
4231
|
+
*
|
|
4232
|
+
* Creates an array cache object to store unique values.
|
|
4233
|
+
*
|
|
4234
|
+
* @private
|
|
4235
|
+
* @constructor
|
|
4236
|
+
* @param {Array} [values] The values to cache.
|
|
4237
|
+
*/
|
|
4238
|
+
function SetCache(values) {
|
|
4239
|
+
var index = -1, length = values == null ? 0 : values.length;
|
|
4240
|
+
this.__data__ = new _MapCache_default();
|
|
4241
|
+
while (++index < length) this.add(values[index]);
|
|
4242
|
+
}
|
|
4243
|
+
SetCache.prototype.add = SetCache.prototype.push = _setCacheAdd_default;
|
|
4244
|
+
SetCache.prototype.has = _setCacheHas_default;
|
|
4245
|
+
var _SetCache_default = SetCache;
|
|
4246
|
+
|
|
4247
|
+
//#endregion
|
|
4248
|
+
//#region node_modules/lodash-es/_baseFindIndex.js
|
|
4249
|
+
/**
|
|
4250
|
+
* The base implementation of `_.findIndex` and `_.findLastIndex` without
|
|
4251
|
+
* support for iteratee shorthands.
|
|
4252
|
+
*
|
|
4253
|
+
* @private
|
|
4254
|
+
* @param {Array} array The array to inspect.
|
|
4255
|
+
* @param {Function} predicate The function invoked per iteration.
|
|
4256
|
+
* @param {number} fromIndex The index to search from.
|
|
4257
|
+
* @param {boolean} [fromRight] Specify iterating from right to left.
|
|
4258
|
+
* @returns {number} Returns the index of the matched value, else `-1`.
|
|
4259
|
+
*/
|
|
4260
|
+
function baseFindIndex(array, predicate, fromIndex, fromRight) {
|
|
4261
|
+
var length = array.length, index = fromIndex + (fromRight ? 1 : -1);
|
|
4262
|
+
while (fromRight ? index-- : ++index < length) if (predicate(array[index], index, array)) return index;
|
|
4263
|
+
return -1;
|
|
4264
|
+
}
|
|
4265
|
+
var _baseFindIndex_default = baseFindIndex;
|
|
4266
|
+
|
|
4267
|
+
//#endregion
|
|
4268
|
+
//#region node_modules/lodash-es/_baseIsNaN.js
|
|
4269
|
+
/**
|
|
4270
|
+
* The base implementation of `_.isNaN` without support for number objects.
|
|
4271
|
+
*
|
|
4272
|
+
* @private
|
|
4273
|
+
* @param {*} value The value to check.
|
|
4274
|
+
* @returns {boolean} Returns `true` if `value` is `NaN`, else `false`.
|
|
4275
|
+
*/
|
|
4276
|
+
function baseIsNaN(value) {
|
|
4277
|
+
return value !== value;
|
|
4278
|
+
}
|
|
4279
|
+
var _baseIsNaN_default = baseIsNaN;
|
|
4280
|
+
|
|
4281
|
+
//#endregion
|
|
4282
|
+
//#region node_modules/lodash-es/_strictIndexOf.js
|
|
4283
|
+
/**
|
|
4284
|
+
* A specialized version of `_.indexOf` which performs strict equality
|
|
4285
|
+
* comparisons of values, i.e. `===`.
|
|
4286
|
+
*
|
|
4287
|
+
* @private
|
|
4288
|
+
* @param {Array} array The array to inspect.
|
|
4289
|
+
* @param {*} value The value to search for.
|
|
4290
|
+
* @param {number} fromIndex The index to search from.
|
|
4291
|
+
* @returns {number} Returns the index of the matched value, else `-1`.
|
|
4292
|
+
*/
|
|
4293
|
+
function strictIndexOf(array, value, fromIndex) {
|
|
4294
|
+
var index = fromIndex - 1, length = array.length;
|
|
4295
|
+
while (++index < length) if (array[index] === value) return index;
|
|
4296
|
+
return -1;
|
|
4297
|
+
}
|
|
4298
|
+
var _strictIndexOf_default = strictIndexOf;
|
|
4299
|
+
|
|
4300
|
+
//#endregion
|
|
4301
|
+
//#region node_modules/lodash-es/_baseIndexOf.js
|
|
4302
|
+
/**
|
|
4303
|
+
* The base implementation of `_.indexOf` without `fromIndex` bounds checks.
|
|
4304
|
+
*
|
|
4305
|
+
* @private
|
|
4306
|
+
* @param {Array} array The array to inspect.
|
|
4307
|
+
* @param {*} value The value to search for.
|
|
4308
|
+
* @param {number} fromIndex The index to search from.
|
|
4309
|
+
* @returns {number} Returns the index of the matched value, else `-1`.
|
|
4310
|
+
*/
|
|
4311
|
+
function baseIndexOf(array, value, fromIndex) {
|
|
4312
|
+
return value === value ? _strictIndexOf_default(array, value, fromIndex) : _baseFindIndex_default(array, _baseIsNaN_default, fromIndex);
|
|
4313
|
+
}
|
|
4314
|
+
var _baseIndexOf_default = baseIndexOf;
|
|
4315
|
+
|
|
4316
|
+
//#endregion
|
|
4317
|
+
//#region node_modules/lodash-es/_arrayIncludes.js
|
|
4318
|
+
/**
|
|
4319
|
+
* A specialized version of `_.includes` for arrays without support for
|
|
4320
|
+
* specifying an index to search from.
|
|
4321
|
+
*
|
|
4322
|
+
* @private
|
|
4323
|
+
* @param {Array} [array] The array to inspect.
|
|
4324
|
+
* @param {*} target The value to search for.
|
|
4325
|
+
* @returns {boolean} Returns `true` if `target` is found, else `false`.
|
|
4326
|
+
*/
|
|
4327
|
+
function arrayIncludes(array, value) {
|
|
4328
|
+
return !!(array == null ? 0 : array.length) && _baseIndexOf_default(array, value, 0) > -1;
|
|
4329
|
+
}
|
|
4330
|
+
var _arrayIncludes_default = arrayIncludes;
|
|
4331
|
+
|
|
4332
|
+
//#endregion
|
|
4333
|
+
//#region node_modules/lodash-es/_arrayIncludesWith.js
|
|
4334
|
+
/**
|
|
4335
|
+
* This function is like `arrayIncludes` except that it accepts a comparator.
|
|
4336
|
+
*
|
|
4337
|
+
* @private
|
|
4338
|
+
* @param {Array} [array] The array to inspect.
|
|
4339
|
+
* @param {*} target The value to search for.
|
|
4340
|
+
* @param {Function} comparator The comparator invoked per element.
|
|
4341
|
+
* @returns {boolean} Returns `true` if `target` is found, else `false`.
|
|
4342
|
+
*/
|
|
4343
|
+
function arrayIncludesWith(array, value, comparator) {
|
|
4344
|
+
var index = -1, length = array == null ? 0 : array.length;
|
|
4345
|
+
while (++index < length) if (comparator(value, array[index])) return true;
|
|
4346
|
+
return false;
|
|
4347
|
+
}
|
|
4348
|
+
var _arrayIncludesWith_default = arrayIncludesWith;
|
|
4349
|
+
|
|
4350
|
+
//#endregion
|
|
4351
|
+
//#region node_modules/lodash-es/_cacheHas.js
|
|
4352
|
+
/**
|
|
4353
|
+
* Checks if a `cache` value for `key` exists.
|
|
4354
|
+
*
|
|
4355
|
+
* @private
|
|
4356
|
+
* @param {Object} cache The cache to query.
|
|
4357
|
+
* @param {string} key The key of the entry to check.
|
|
4358
|
+
* @returns {boolean} Returns `true` if an entry for `key` exists, else `false`.
|
|
4359
|
+
*/
|
|
4360
|
+
function cacheHas(cache, key) {
|
|
4361
|
+
return cache.has(key);
|
|
4362
|
+
}
|
|
4363
|
+
var _cacheHas_default = cacheHas;
|
|
4364
|
+
|
|
4365
|
+
//#endregion
|
|
4366
|
+
//#region node_modules/lodash-es/_Set.js
|
|
4367
|
+
var Set$1 = _getNative_default(_root_default, "Set");
|
|
4368
|
+
var _Set_default = Set$1;
|
|
4369
|
+
|
|
4370
|
+
//#endregion
|
|
4371
|
+
//#region node_modules/lodash-es/noop.js
|
|
4372
|
+
/**
|
|
4373
|
+
* This method returns `undefined`.
|
|
4374
|
+
*
|
|
4375
|
+
* @static
|
|
4376
|
+
* @memberOf _
|
|
4377
|
+
* @since 2.3.0
|
|
4378
|
+
* @category Util
|
|
4379
|
+
* @example
|
|
4380
|
+
*
|
|
4381
|
+
* _.times(2, _.noop);
|
|
4382
|
+
* // => [undefined, undefined]
|
|
4383
|
+
*/
|
|
4384
|
+
function noop() {}
|
|
4385
|
+
var noop_default = noop;
|
|
4386
|
+
|
|
4387
|
+
//#endregion
|
|
4388
|
+
//#region node_modules/lodash-es/_setToArray.js
|
|
4389
|
+
/**
|
|
4390
|
+
* Converts `set` to an array of its values.
|
|
4391
|
+
*
|
|
4392
|
+
* @private
|
|
4393
|
+
* @param {Object} set The set to convert.
|
|
4394
|
+
* @returns {Array} Returns the values.
|
|
4395
|
+
*/
|
|
4396
|
+
function setToArray(set) {
|
|
4397
|
+
var index = -1, result = Array(set.size);
|
|
4398
|
+
set.forEach(function(value) {
|
|
4399
|
+
result[++index] = value;
|
|
4400
|
+
});
|
|
4401
|
+
return result;
|
|
4402
|
+
}
|
|
4403
|
+
var _setToArray_default = setToArray;
|
|
4404
|
+
|
|
4405
|
+
//#endregion
|
|
4406
|
+
//#region node_modules/lodash-es/_createSet.js
|
|
4407
|
+
/**
|
|
4408
|
+
* Creates a set object of `values`.
|
|
4409
|
+
*
|
|
4410
|
+
* @private
|
|
4411
|
+
* @param {Array} values The values to add to the set.
|
|
4412
|
+
* @returns {Object} Returns the new set.
|
|
4413
|
+
*/
|
|
4414
|
+
var createSet = !(_Set_default && 1 / _setToArray_default(new _Set_default([, -0]))[1] == Infinity) ? noop_default : function(values) {
|
|
4415
|
+
return new _Set_default(values);
|
|
4416
|
+
};
|
|
4417
|
+
var _createSet_default = createSet;
|
|
4418
|
+
|
|
4419
|
+
//#endregion
|
|
4420
|
+
//#region node_modules/lodash-es/_baseUniq.js
|
|
4421
|
+
/** Used as the size to enable large array optimizations. */
|
|
4422
|
+
var LARGE_ARRAY_SIZE = 200;
|
|
4423
|
+
/**
|
|
4424
|
+
* The base implementation of `_.uniqBy` without support for iteratee shorthands.
|
|
4425
|
+
*
|
|
4426
|
+
* @private
|
|
4427
|
+
* @param {Array} array The array to inspect.
|
|
4428
|
+
* @param {Function} [iteratee] The iteratee invoked per element.
|
|
4429
|
+
* @param {Function} [comparator] The comparator invoked per element.
|
|
4430
|
+
* @returns {Array} Returns the new duplicate free array.
|
|
4431
|
+
*/
|
|
4432
|
+
function baseUniq(array, iteratee, comparator) {
|
|
4433
|
+
var index = -1, includes = _arrayIncludes_default, length = array.length, isCommon = true, result = [], seen = result;
|
|
4434
|
+
if (comparator) {
|
|
4435
|
+
isCommon = false;
|
|
4436
|
+
includes = _arrayIncludesWith_default;
|
|
4437
|
+
} else if (length >= LARGE_ARRAY_SIZE) {
|
|
4438
|
+
var set = iteratee ? null : _createSet_default(array);
|
|
4439
|
+
if (set) return _setToArray_default(set);
|
|
4440
|
+
isCommon = false;
|
|
4441
|
+
includes = _cacheHas_default;
|
|
4442
|
+
seen = new _SetCache_default();
|
|
4443
|
+
} else seen = iteratee ? [] : result;
|
|
4444
|
+
outer: while (++index < length) {
|
|
4445
|
+
var value = array[index], computed = iteratee ? iteratee(value) : value;
|
|
4446
|
+
value = comparator || value !== 0 ? value : 0;
|
|
4447
|
+
if (isCommon && computed === computed) {
|
|
4448
|
+
var seenIndex = seen.length;
|
|
4449
|
+
while (seenIndex--) if (seen[seenIndex] === computed) continue outer;
|
|
4450
|
+
if (iteratee) seen.push(computed);
|
|
4451
|
+
result.push(value);
|
|
4452
|
+
} else if (!includes(seen, computed, comparator)) {
|
|
4453
|
+
if (seen !== result) seen.push(computed);
|
|
4454
|
+
result.push(value);
|
|
4455
|
+
}
|
|
4456
|
+
}
|
|
4457
|
+
return result;
|
|
4458
|
+
}
|
|
4459
|
+
var _baseUniq_default = baseUniq;
|
|
4460
|
+
|
|
4461
|
+
//#endregion
|
|
4462
|
+
//#region node_modules/lodash-es/uniq.js
|
|
4463
|
+
/**
|
|
4464
|
+
* Creates a duplicate-free version of an array, using
|
|
4465
|
+
* [`SameValueZero`](http://ecma-international.org/ecma-262/7.0/#sec-samevaluezero)
|
|
4466
|
+
* for equality comparisons, in which only the first occurrence of each element
|
|
4467
|
+
* is kept. The order of result values is determined by the order they occur
|
|
4468
|
+
* in the array.
|
|
4469
|
+
*
|
|
4470
|
+
* @static
|
|
4471
|
+
* @memberOf _
|
|
4472
|
+
* @since 0.1.0
|
|
4473
|
+
* @category Array
|
|
4474
|
+
* @param {Array} array The array to inspect.
|
|
4475
|
+
* @returns {Array} Returns the new duplicate free array.
|
|
4476
|
+
* @example
|
|
4477
|
+
*
|
|
4478
|
+
* _.uniq([2, 1, 2]);
|
|
4479
|
+
* // => [2, 1]
|
|
4480
|
+
*/
|
|
4481
|
+
function uniq(array) {
|
|
4482
|
+
return array && array.length ? _baseUniq_default(array) : [];
|
|
4483
|
+
}
|
|
4484
|
+
var uniq_default = uniq;
|
|
4485
|
+
|
|
4486
|
+
//#endregion
|
|
4487
|
+
//#region src/render/requestTypes/unionType.ts
|
|
4488
|
+
const unionType$2 = (type, ctx) => {
|
|
4489
|
+
let types = [...type.getTypes()];
|
|
4490
|
+
if (ctx.config?.sortProperties) types = types.sort();
|
|
4491
|
+
const fieldStrings = types.map((t) => `on_${t.name}?:${requestTypeName(t)}`);
|
|
4492
|
+
const commonInterfaces = uniq_default(types.map((x) => x.getInterfaces()).flat());
|
|
4493
|
+
fieldStrings.push(...commonInterfaces.map((type$1) => {
|
|
4494
|
+
return `on_${type$1.name}?: ${requestTypeName(type$1)}`;
|
|
4495
|
+
}));
|
|
4496
|
+
fieldStrings.push("__typename?: boolean | number");
|
|
4497
|
+
ctx.addCodeBlock(`${typeComment(type)}export interface ${requestTypeName(type)}{\n${fieldStrings.map((x) => " " + x).join(",\n")}\n}`);
|
|
4498
|
+
};
|
|
4499
|
+
|
|
4500
|
+
//#endregion
|
|
4501
|
+
//#region src/render/requestTypes/renderRequestTypes.ts
|
|
4502
|
+
const renderRequestTypes = (schema, ctx) => {
|
|
4503
|
+
let typeMap = schema.getTypeMap();
|
|
4504
|
+
if (ctx.config?.sortProperties) typeMap = sortKeys(typeMap);
|
|
4505
|
+
for (const name in typeMap) {
|
|
4506
|
+
if (excludedTypes.includes(name)) continue;
|
|
4507
|
+
const type = typeMap[name];
|
|
4508
|
+
if (isObjectType(type) || isInterfaceType(type)) objectType$2(type, ctx);
|
|
4509
|
+
if (isInputObjectType(type)) inputObjectType(type, ctx);
|
|
4510
|
+
if (isUnionType(type)) unionType$2(type, ctx);
|
|
4511
|
+
}
|
|
4512
|
+
const aliases = [
|
|
4513
|
+
{
|
|
4514
|
+
type: schema.getQueryType(),
|
|
4515
|
+
name: "QueryGenqlSelection"
|
|
4516
|
+
},
|
|
4517
|
+
{
|
|
4518
|
+
type: schema.getMutationType(),
|
|
4519
|
+
name: "MutationGenqlSelection"
|
|
4520
|
+
},
|
|
4521
|
+
{
|
|
4522
|
+
type: schema.getSubscriptionType(),
|
|
4523
|
+
name: "SubscriptionGenqlSelection"
|
|
4524
|
+
}
|
|
4525
|
+
].map(renderAlias$1).filter(Boolean).join("\n");
|
|
4526
|
+
ctx.addCodeBlock(aliases);
|
|
4527
|
+
};
|
|
4528
|
+
function renderAlias$1({ type, name }) {
|
|
4529
|
+
if (type && requestTypeName(type) !== name) return `export type ${name} = ${requestTypeName(type)}`;
|
|
4530
|
+
return "";
|
|
4531
|
+
}
|
|
4532
|
+
|
|
4533
|
+
//#endregion
|
|
4534
|
+
//#region src/render/responseTypes/enumType.ts
|
|
4535
|
+
const enumType = (type, ctx) => {
|
|
4536
|
+
const values = type.getValues().map((v) => `'${v.name}'`);
|
|
4537
|
+
ctx.addCodeBlock(`${typeComment(type)}export type ${type.name} = ${values.join(" | ")}`);
|
|
4538
|
+
};
|
|
4539
|
+
|
|
4540
|
+
//#endregion
|
|
4541
|
+
//#region src/render/responseTypes/objectType.ts
|
|
4542
|
+
const INDENTATION = " ";
|
|
4543
|
+
const objectType$1 = (type, ctx) => {
|
|
4544
|
+
let fieldsMap = type.getFields();
|
|
4545
|
+
if (ctx.config?.sortProperties) fieldsMap = sortKeys(fieldsMap);
|
|
4546
|
+
const fields = Object.keys(fieldsMap).map((fieldName) => fieldsMap[fieldName]);
|
|
4547
|
+
if (!ctx.schema) throw new Error("no schema provided");
|
|
4548
|
+
const typeNames = isObjectType(type) ? [type.name] : ctx.schema.getPossibleTypes(type).map((t) => t.name);
|
|
4549
|
+
let fieldStrings = fields.map((f) => {
|
|
4550
|
+
return `${fieldComment(f)}${f.name}: ${renderTyping(f.type)}`;
|
|
4551
|
+
}).concat([`__typename: ${typeNames.length > 0 ? typeNames.map((t) => `'${t}'`).join("|") : "string"}`]);
|
|
4552
|
+
fieldStrings = fieldStrings.map((x) => x.split("\n").filter(Boolean).map((l) => INDENTATION + l).join("\n"));
|
|
4553
|
+
ctx.addCodeBlock(`${typeComment(type)}export interface ${type.name} {\n${fieldStrings.join("\n")}\n}`);
|
|
4554
|
+
};
|
|
4555
|
+
|
|
4556
|
+
//#endregion
|
|
4557
|
+
//#region src/render/responseTypes/typeMappedAlias.ts
|
|
4558
|
+
const knownTypes = {
|
|
4559
|
+
Int: "number",
|
|
4560
|
+
Float: "number",
|
|
4561
|
+
String: "string",
|
|
4562
|
+
Boolean: "boolean",
|
|
4563
|
+
ID: "string"
|
|
4564
|
+
};
|
|
4565
|
+
const getTypeMappedAlias = (type, ctx) => {
|
|
4566
|
+
return {
|
|
4567
|
+
...knownTypes,
|
|
4568
|
+
...ctx?.config?.scalarTypes || {}
|
|
4569
|
+
}?.[type.name] || "any";
|
|
4570
|
+
};
|
|
4571
|
+
|
|
4572
|
+
//#endregion
|
|
4573
|
+
//#region src/render/responseTypes/scalarType.ts
|
|
4574
|
+
function renderScalarTypes(ctx, types) {
|
|
4575
|
+
let content = "";
|
|
4576
|
+
types.forEach((type) => {
|
|
4577
|
+
content += ` ${type.name}: ${getTypeMappedAlias(type, ctx)},\n`;
|
|
4578
|
+
});
|
|
4579
|
+
return `export type Scalars = {\n${content}}`;
|
|
4580
|
+
}
|
|
4581
|
+
|
|
4582
|
+
//#endregion
|
|
4583
|
+
//#region src/render/responseTypes/unionType.ts
|
|
4584
|
+
const unionType$1 = (type, ctx) => {
|
|
4585
|
+
let typeNames = type.getTypes().map((t) => t.name);
|
|
4586
|
+
if (ctx.config?.sortProperties) typeNames = typeNames.sort();
|
|
4587
|
+
ctx.addCodeBlock(`${typeComment(type)}export type ${type.name} = (${typeNames.join(" | ")}) & { __isUnion?: true }`);
|
|
4588
|
+
};
|
|
4589
|
+
|
|
4590
|
+
//#endregion
|
|
4591
|
+
//#region src/render/responseTypes/interfaceType.ts
|
|
4592
|
+
const interfaceType = (type, ctx) => {
|
|
4593
|
+
if (!ctx.schema) throw new Error("schema is required to render unionType");
|
|
4594
|
+
const typeNames = ctx.schema.getPossibleTypes(type).map((t) => t.name);
|
|
4595
|
+
if (!typeNames.length) objectType$1(type, ctx);
|
|
4596
|
+
else ctx.addCodeBlock(`${typeComment(type)}export type ${type.name} = (${typeNames.join(" | ")}) & { __isUnion?: true }`);
|
|
4597
|
+
};
|
|
4598
|
+
|
|
4599
|
+
//#endregion
|
|
4600
|
+
//#region src/render/responseTypes/renderResponseTypes.ts
|
|
4601
|
+
const renderResponseTypes = (schema, ctx) => {
|
|
4602
|
+
let typeMap = schema.getTypeMap();
|
|
4603
|
+
if (ctx.config?.sortProperties) typeMap = sortKeys(typeMap);
|
|
4604
|
+
ctx.addCodeBlock(renderScalarTypes(ctx, Object.values(typeMap).filter((type) => isScalarType(type))));
|
|
4605
|
+
for (const name in typeMap) {
|
|
4606
|
+
if (excludedTypes.includes(name)) continue;
|
|
4607
|
+
const type = typeMap[name];
|
|
4608
|
+
if (isEnumType(type)) enumType(type, ctx);
|
|
4609
|
+
if (isUnionType(type)) unionType$1(type, ctx);
|
|
4610
|
+
if (isObjectType(type)) objectType$1(type, ctx);
|
|
4611
|
+
if (isInterfaceType(type)) interfaceType(type, ctx);
|
|
4612
|
+
}
|
|
4613
|
+
const aliases = [
|
|
4614
|
+
{
|
|
4615
|
+
type: schema.getQueryType(),
|
|
4616
|
+
name: "Query"
|
|
4617
|
+
},
|
|
4618
|
+
{
|
|
4619
|
+
type: schema.getMutationType(),
|
|
4620
|
+
name: "Mutation"
|
|
4621
|
+
},
|
|
4622
|
+
{
|
|
4623
|
+
type: schema.getSubscriptionType(),
|
|
4624
|
+
name: "Subscription"
|
|
4625
|
+
}
|
|
4626
|
+
].map(renderAlias).filter(Boolean).join("\n");
|
|
4627
|
+
ctx.addCodeBlock(aliases);
|
|
4628
|
+
};
|
|
4629
|
+
function renderAlias({ type, name }) {
|
|
4630
|
+
if (type && type.name !== name) return `export type ${name} = ${type.name}`;
|
|
4631
|
+
return "";
|
|
4632
|
+
}
|
|
4633
|
+
|
|
4634
|
+
//#endregion
|
|
4635
|
+
//#region src/render/schema/renderSchema.ts
|
|
4636
|
+
const renderSchema = (schema, ctx) => {
|
|
4637
|
+
ctx.addCodeBlock(printSchema(schema));
|
|
4638
|
+
};
|
|
4639
|
+
|
|
4640
|
+
//#endregion
|
|
4641
|
+
//#region src/render/typeGuards/renderTypeGuards.ts
|
|
4642
|
+
const renderTypeGuard = (target, possible) => {
|
|
4643
|
+
return `
|
|
4644
|
+
const ${target}_possibleTypes: string[] = [${possible.map((t) => `'${t}'`).join(",")}]
|
|
4645
|
+
export const is${target} = (obj?: { __typename?: any } | null): obj is ${target} => {
|
|
4646
|
+
if (!obj?.__typename) throw new Error('__typename is missing in "is${target}"')
|
|
4647
|
+
return ${target}_possibleTypes.includes(obj.__typename)
|
|
4648
|
+
}
|
|
4649
|
+
`;
|
|
4650
|
+
};
|
|
4651
|
+
const renderTypeGuards = (schema, ctx) => {
|
|
4652
|
+
const typeMap = schema.getTypeMap();
|
|
4653
|
+
for (const name in typeMap) {
|
|
4654
|
+
if (excludedTypes.includes(name)) continue;
|
|
4655
|
+
const type = typeMap[name];
|
|
4656
|
+
if (isUnionType(type)) {
|
|
4657
|
+
const types = type.getTypes().map((t) => t.name);
|
|
4658
|
+
ctx.addCodeBlock(renderTypeGuard(type.name, types));
|
|
4659
|
+
} else if (isInterfaceType(type)) {
|
|
4660
|
+
const types = schema.getPossibleTypes(type).map((t) => t.name);
|
|
4661
|
+
ctx.addCodeBlock(renderTypeGuard(type.name, types));
|
|
4662
|
+
} else if (isObjectType(type)) ctx.addCodeBlock(renderTypeGuard(type.name, [type.name]));
|
|
4663
|
+
}
|
|
4664
|
+
};
|
|
4665
|
+
|
|
4666
|
+
//#endregion
|
|
4667
|
+
//#region src/render/typeMap/support.ts
|
|
4668
|
+
function isEmpty(x) {
|
|
4669
|
+
if (!x) return true;
|
|
4670
|
+
return Object.keys(x).length === 0;
|
|
4671
|
+
}
|
|
4672
|
+
|
|
4673
|
+
//#endregion
|
|
4674
|
+
//#region src/render/typeMap/objectType.ts
|
|
4675
|
+
const objectType = (type, ctx) => {
|
|
4676
|
+
const typeObj = Object.keys(type.getFields()).reduce((r, f) => {
|
|
4677
|
+
const field = type.getFields()[f];
|
|
4678
|
+
const fieldObj = { type: getNamedType(field.type).name };
|
|
4679
|
+
r[f] = fieldObj;
|
|
4680
|
+
const args = field.args || [];
|
|
4681
|
+
if (args.length > 0) fieldObj.args = args.reduce((r$1, a) => {
|
|
4682
|
+
const concreteType = a.type.toString();
|
|
4683
|
+
const typename = getNamedType(a.type).name;
|
|
4684
|
+
r$1[a.name] = [typename];
|
|
4685
|
+
if (typename !== concreteType) r$1[a.name]?.push(concreteType);
|
|
4686
|
+
return r$1;
|
|
4687
|
+
}, {});
|
|
4688
|
+
return r;
|
|
4689
|
+
}, {});
|
|
4690
|
+
if (isInterfaceType(type) && ctx.schema) ctx.schema.getPossibleTypes(type).map((t) => {
|
|
4691
|
+
if (!isEmpty(typeObj)) typeObj[`on_${t.name}`] = { type: t.name };
|
|
4692
|
+
});
|
|
4693
|
+
if (!isEmpty(typeObj)) typeObj.__typename = { type: "String" };
|
|
4694
|
+
return typeObj;
|
|
4695
|
+
};
|
|
4696
|
+
|
|
4697
|
+
//#endregion
|
|
4698
|
+
//#region src/render/typeMap/unionType.ts
|
|
4699
|
+
const unionType = (type, _) => {
|
|
4700
|
+
const types = type.getTypes();
|
|
4701
|
+
const typeObj = types.reduce((r, t) => {
|
|
4702
|
+
r[`on_${t.name}`] = { type: t.name };
|
|
4703
|
+
return r;
|
|
4704
|
+
}, {});
|
|
4705
|
+
uniq_default(types.map((x) => x.getInterfaces()).flat()).forEach((t) => {
|
|
4706
|
+
typeObj[`on_${t.name}`] = { type: t.name };
|
|
4707
|
+
});
|
|
4708
|
+
typeObj.__typename = { type: "String" };
|
|
4709
|
+
return typeObj;
|
|
4710
|
+
};
|
|
4711
|
+
|
|
4712
|
+
//#endregion
|
|
4713
|
+
//#region src/render/typeMap/renderTypeMap.ts
|
|
4714
|
+
const renderTypeMap = (schema, ctx) => {
|
|
4715
|
+
const result = {
|
|
4716
|
+
scalars: [],
|
|
4717
|
+
types: {}
|
|
4718
|
+
};
|
|
4719
|
+
Object.keys(schema.getTypeMap()).filter((t) => !excludedTypes.includes(t)).map((t) => schema.getTypeMap()[t]).map((t) => {
|
|
4720
|
+
if (isObjectType(t) || isInterfaceType(t) || isInputObjectType(t)) result.types[t.name] = objectType(t, ctx);
|
|
4721
|
+
else if (isUnionType(t)) result.types[t.name] = unionType(t, ctx);
|
|
4722
|
+
else if (isScalarType(t) || isEnumType(t)) {
|
|
4723
|
+
result.scalars.push(t.name);
|
|
4724
|
+
result.types[t.name] = {};
|
|
4725
|
+
}
|
|
4726
|
+
});
|
|
4727
|
+
const q = schema.getQueryType();
|
|
4728
|
+
if (q?.name && q?.name !== "Query") {
|
|
4729
|
+
delete result.types[q.name];
|
|
4730
|
+
result.types.Query = objectType(q, ctx);
|
|
4731
|
+
}
|
|
4732
|
+
const m = schema.getMutationType();
|
|
4733
|
+
if (m?.name && m.name !== "Mutation") {
|
|
4734
|
+
delete result.types[m.name];
|
|
4735
|
+
result.types.Mutation = objectType(m, ctx);
|
|
4736
|
+
}
|
|
4737
|
+
const s = schema.getSubscriptionType();
|
|
4738
|
+
if (s?.name && s.name !== "Subscription") {
|
|
4739
|
+
delete result.types[s.name];
|
|
4740
|
+
result.types.Subscription = objectType(s, ctx);
|
|
4741
|
+
}
|
|
4742
|
+
ctx.addCodeBlock(JSON.stringify(replaceTypeNamesWithIndexes(result), null, 4));
|
|
4743
|
+
};
|
|
4744
|
+
function replaceTypeNamesWithIndexes(typeMap) {
|
|
4745
|
+
const nameToIndex = Object.assign({}, ...Object.keys(typeMap.types).map((k, i) => ({ [k]: i })));
|
|
4746
|
+
return {
|
|
4747
|
+
scalars: typeMap.scalars.map((x) => nameToIndex[x]),
|
|
4748
|
+
types: Object.assign({}, ...Object.keys(typeMap.types || {}).map((k) => {
|
|
4749
|
+
const fieldsMap = typeMap.types[k] || {};
|
|
4750
|
+
const fields = Object.assign({}, ...Object.keys(fieldsMap).map((f) => {
|
|
4751
|
+
const content = fieldsMap[f];
|
|
4752
|
+
if (!content) throw new Error("no content in field " + f);
|
|
4753
|
+
const [typeName, args] = [content.type, content.args];
|
|
4754
|
+
const res = [typeName ? nameToIndex[typeName] : -1];
|
|
4755
|
+
if (args) res[1] = Object.assign({}, ...Object.keys(args || {}).map((k$1) => {
|
|
4756
|
+
const arg = args?.[k$1];
|
|
4757
|
+
if (!arg) throw new Error("replaceTypeNamesWithIndexes: no arg for " + k$1);
|
|
4758
|
+
return { [k$1]: [nameToIndex[arg[0]], ...arg.slice(1)] };
|
|
4759
|
+
}));
|
|
4760
|
+
return { [f]: res };
|
|
4761
|
+
}));
|
|
4762
|
+
return { [k]: { ...fields } };
|
|
4763
|
+
}))
|
|
4764
|
+
};
|
|
4765
|
+
}
|
|
4766
|
+
|
|
4767
|
+
//#endregion
|
|
4768
|
+
//#region src/tasks/clientTasks.ts
|
|
4769
|
+
const typeMapFileEsm = "types.ts";
|
|
4770
|
+
const schemaTypesFile = "schema.ts";
|
|
4771
|
+
const schemaGqlFile = "schema.graphql";
|
|
4772
|
+
const cliRoot = path.dirname(url.fileURLToPath(import.meta.url));
|
|
4773
|
+
const runtimeFolderPath = path.resolve(cliRoot, "runtime");
|
|
4774
|
+
const clientTasks = (config) => {
|
|
4775
|
+
const clientFileEsm = "index.ts";
|
|
4776
|
+
if (!config.output) throw new Error("`output` must be defined in the config");
|
|
4777
|
+
const output = config.output;
|
|
4778
|
+
const tasks = [
|
|
4779
|
+
{
|
|
4780
|
+
title: `writing ${schemaGqlFile}`,
|
|
4781
|
+
async task(ctx) {
|
|
4782
|
+
const renderCtx = new RenderContext(ctx.schema, config);
|
|
4783
|
+
renderSchema(ctx.schema, renderCtx);
|
|
4784
|
+
await writeFileToPath([output, schemaGqlFile], await renderCtx.toCode("graphql"));
|
|
4785
|
+
}
|
|
4786
|
+
},
|
|
4787
|
+
{
|
|
4788
|
+
title: `copy runtime files`,
|
|
4789
|
+
async task() {
|
|
4790
|
+
const files = await fs.readdir(runtimeFolderPath);
|
|
4791
|
+
const target = path.resolve(output, "runtime");
|
|
4792
|
+
if (!await fs.access(target).then(() => true).catch(() => false)) await fs.mkdir(target, { recursive: true });
|
|
4793
|
+
for (const file of files) {
|
|
4794
|
+
const raw = await fs.readFile(path.resolve(runtimeFolderPath, file), "utf-8");
|
|
4795
|
+
await fs.writeFile(path.resolve(output, "runtime", file), `// @ts-nocheck\n${raw};`, "utf-8");
|
|
4796
|
+
}
|
|
4797
|
+
}
|
|
4798
|
+
},
|
|
4799
|
+
{
|
|
4800
|
+
title: `writing ${schemaTypesFile}`,
|
|
4801
|
+
async task(ctx) {
|
|
4802
|
+
const renderCtx = new RenderContext(ctx.schema, config);
|
|
4803
|
+
renderResponseTypes(ctx.schema, renderCtx);
|
|
4804
|
+
renderRequestTypes(ctx.schema, renderCtx);
|
|
4805
|
+
renderTypeGuards(ctx.schema, renderCtx);
|
|
4806
|
+
renderEnumsMaps(ctx.schema, renderCtx);
|
|
4807
|
+
const code = await renderCtx.toCode("typescript");
|
|
4808
|
+
await writeFileToPath([output, schemaTypesFile], "// @ts-nocheck\n/* istanbul ignore file */\n/* tslint:disable */\n/* eslint-disable */\n\n" + code);
|
|
4809
|
+
}
|
|
4810
|
+
},
|
|
4811
|
+
{
|
|
4812
|
+
title: `writing types map`,
|
|
4813
|
+
async task(ctx) {
|
|
4814
|
+
const renderCtx = new RenderContext(ctx.schema, config);
|
|
4815
|
+
renderTypeMap(ctx.schema, renderCtx);
|
|
4816
|
+
const code = await renderCtx.toCode();
|
|
4817
|
+
await writeFileToPath([output, typeMapFileEsm], `export default ${code}`);
|
|
4818
|
+
}
|
|
4819
|
+
},
|
|
4820
|
+
{
|
|
4821
|
+
title: `writing ${clientFileEsm}`,
|
|
4822
|
+
async task(ctx) {
|
|
4823
|
+
const renderCtx = new RenderContext(ctx.schema, config);
|
|
4824
|
+
renderClientEsm(ctx.schema, renderCtx);
|
|
4825
|
+
const code = await renderCtx.toCode("typescript", true);
|
|
4826
|
+
await writeFileToPath([output, clientFileEsm], "// @ts-nocheck\n" + code);
|
|
4827
|
+
}
|
|
4828
|
+
}
|
|
4829
|
+
];
|
|
4830
|
+
return [{
|
|
4831
|
+
title: "preparing client directory",
|
|
4832
|
+
task: () => ensurePath([output], true)
|
|
4833
|
+
}, {
|
|
4834
|
+
title: `writing files`,
|
|
4835
|
+
task() {
|
|
4836
|
+
return new Listr(tasks.filter((x) => Boolean(x)), { concurrent: true });
|
|
4837
|
+
}
|
|
4838
|
+
}];
|
|
4839
|
+
};
|
|
4840
|
+
function renderEnumsMaps(schema, ctx) {
|
|
4841
|
+
let typeMap = schema.getTypeMap();
|
|
4842
|
+
const enums = [];
|
|
4843
|
+
for (const name in typeMap) {
|
|
4844
|
+
if (excludedTypes.includes(name)) continue;
|
|
4845
|
+
const type = typeMap[name];
|
|
4846
|
+
if (isEnumType(type)) enums.push(type);
|
|
4847
|
+
}
|
|
4848
|
+
if (enums.length === 0) return;
|
|
4849
|
+
ctx.addCodeBlock(enums.map((type) => `export const ${"enum" + capitalize(camelCase(type.name))} = {\n` + type.getValues().map((v) => {
|
|
4850
|
+
if (!v?.name) return "";
|
|
4851
|
+
return ` ${v.name}: '${v.name}' as const`;
|
|
4852
|
+
}).join(",\n") + `\n}\n`).join("\n"));
|
|
4853
|
+
}
|
|
4854
|
+
|
|
4855
|
+
//#endregion
|
|
4856
|
+
//#region src/schema/fetchSchema.ts
|
|
4857
|
+
const fetchSchema = async (queryFetchOptions) => {
|
|
4858
|
+
const { headers, endpoint, usePost = true, timeout = 20 * 1e3, options } = queryFetchOptions;
|
|
4859
|
+
const controller = new AbortController();
|
|
4860
|
+
const id = setTimeout(() => controller.abort(), timeout);
|
|
4861
|
+
const query = new URLSearchParams({ query: getIntrospectionQuery() });
|
|
4862
|
+
const fetchOptions = {
|
|
4863
|
+
signal: controller.signal,
|
|
4864
|
+
headers
|
|
4865
|
+
};
|
|
4866
|
+
if (usePost) {
|
|
4867
|
+
fetchOptions.headers = {
|
|
4868
|
+
...headers,
|
|
4869
|
+
"Content-Type": "application/json"
|
|
4870
|
+
};
|
|
4871
|
+
fetchOptions.method = "POST";
|
|
4872
|
+
fetchOptions.body = JSON.stringify({ query: getIntrospectionQuery() });
|
|
4873
|
+
}
|
|
4874
|
+
const res = await fetch(usePost ? endpoint : `${endpoint}?${query.toString()}`, fetchOptions);
|
|
4875
|
+
clearTimeout(id);
|
|
4876
|
+
if (!res.ok) throw new Error(`Introspection for ${endpoint} failed, ${res.status} ${res.statusText}`);
|
|
4877
|
+
const result = await res.json().catch(() => {
|
|
4878
|
+
const contentType = res.headers.get("Content-Type");
|
|
4879
|
+
throw new Error(`Endpoint '${endpoint}' did not return valid json, content type is ${contentType}, check that your endpoint points to a valid graphql API`);
|
|
4880
|
+
});
|
|
4881
|
+
if (!result.data) throw new Error(`introspection for ${endpoint} failed: ${JSON.stringify(result).slice(0, 400)}...`);
|
|
4882
|
+
return buildClientSchema(result.data, options);
|
|
4883
|
+
};
|
|
4884
|
+
|
|
4885
|
+
//#endregion
|
|
4886
|
+
//#region src/tasks/schemaTask.ts
|
|
4887
|
+
const schemaTask = (config) => {
|
|
4888
|
+
const processSchema = (schema) => {
|
|
4889
|
+
if (config.sortProperties) return lexicographicSortSchema(schema);
|
|
4890
|
+
return schema;
|
|
4891
|
+
};
|
|
4892
|
+
if (config.endpoint) {
|
|
4893
|
+
const endpoint = config.endpoint;
|
|
4894
|
+
return {
|
|
4895
|
+
title: `fetching schema using ${config.useGet ? "GET" : "POST"} ${endpoint} and headers ${JSON.stringify(config.headers)}`,
|
|
4896
|
+
task: async (ctx) => {
|
|
4897
|
+
ctx.schema = processSchema(await fetchSchema({
|
|
4898
|
+
endpoint,
|
|
4899
|
+
usePost: !config.useGet,
|
|
4900
|
+
headers: config.headers
|
|
4901
|
+
}));
|
|
4902
|
+
}
|
|
4903
|
+
};
|
|
4904
|
+
} else if (config.schema) {
|
|
4905
|
+
const schema = config.schema;
|
|
4906
|
+
return {
|
|
4907
|
+
title: "loading schema",
|
|
4908
|
+
task: async (ctx) => {
|
|
4909
|
+
ctx.schema = processSchema(await loadSchema(schema, { loaders: [new GraphQLFileLoader()] }));
|
|
4910
|
+
try {
|
|
4911
|
+
assertValidSchema(ctx.schema);
|
|
4912
|
+
} catch (e) {
|
|
4913
|
+
if (e["message"] === "Query root type must be provided.") return;
|
|
4914
|
+
throw e;
|
|
4915
|
+
}
|
|
4916
|
+
}
|
|
4917
|
+
};
|
|
4918
|
+
} else throw new Error("either `endpoint`, `fetcher` or `schema` must be defined in the config");
|
|
4919
|
+
};
|
|
4920
|
+
|
|
4921
|
+
//#endregion
|
|
4922
|
+
//#region src/main.ts
|
|
4923
|
+
const generate = (config) => {
|
|
4924
|
+
if (!config.output) throw new Error("`output` must be defined in the config");
|
|
4925
|
+
return new Listr([{
|
|
4926
|
+
title: `generating the client in \`${config.output}\``,
|
|
4927
|
+
task: () => new Listr([schemaTask(config), ...clientTasks(config)])
|
|
4928
|
+
}], {
|
|
4929
|
+
renderer: config.verbose ? "verbose" : "default",
|
|
4930
|
+
exitOnError: true
|
|
4931
|
+
}).run().catch((e) => {
|
|
4932
|
+
throw e?.errors?.[0];
|
|
4933
|
+
});
|
|
4934
|
+
};
|
|
4935
|
+
|
|
4936
|
+
//#endregion
|
|
4937
|
+
export { generate as t };
|