@ttmg/cli 0.3.2-beta.7 → 0.3.2-beta.8

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.
Files changed (30) hide show
  1. package/dist/index.js +1896 -5
  2. package/dist/index.js.map +1 -1
  3. package/dist/package.json +4 -2
  4. package/dist/public/assets/{index-CW9D9cbx.js → index-B7gDE9jg.js} +1 -1
  5. package/dist/public/assets/{index-C0C36jb2.js → index-BGB_3rmy.js} +5 -5
  6. package/dist/public/assets/index-BGB_3rmy.js.br +0 -0
  7. package/dist/public/assets/{index-uov949jQ.js → index-BGxy8aq-.js} +1 -1
  8. package/dist/public/assets/index-BGxy8aq-.js.br +0 -0
  9. package/dist/public/assets/{index-BkVEWAPY.js → index-Be7GH3NR.js} +1 -1
  10. package/dist/public/assets/{index-DqL2KSXM.js → index-C-hKdJe4.js} +1 -1
  11. package/dist/public/assets/{index-B6sOtD-C.js → index-CZeMe3yb.js} +1 -1
  12. package/dist/public/assets/index-CZeMe3yb.js.br +0 -0
  13. package/dist/public/assets/{index-GteNW6eR.js → index-DCvzzS3c.js} +1 -1
  14. package/dist/public/assets/index-DCvzzS3c.js.br +0 -0
  15. package/dist/public/assets/{index-Dg2qShwB.js → index-DTYGiGBE.js} +1 -1
  16. package/dist/public/assets/{index-DwEKoL_q.js → index-DZh72DCT.js} +1 -1
  17. package/dist/public/assets/{index-DQ4KFxPV.js → index-NjsKimh-.js} +1 -1
  18. package/dist/public/assets/{index-DfNs0hDP.js → index-dPxUjVAV.js} +1 -1
  19. package/dist/public/assets/index-sz2rmYug.js +1 -0
  20. package/dist/public/index.html +1 -1
  21. package/dist/scripts/build.js +6 -0
  22. package/dist/scripts/test-protocol.js +29 -0
  23. package/dist/scripts/test-regression.js +94 -0
  24. package/dist/scripts/test-regression.ts +93 -0
  25. package/package.json +4 -2
  26. package/dist/public/assets/index-B6sOtD-C.js.br +0 -0
  27. package/dist/public/assets/index-C0C36jb2.js.br +0 -0
  28. package/dist/public/assets/index-CaSOlQza.js +0 -1
  29. package/dist/public/assets/index-GteNW6eR.js.br +0 -0
  30. package/dist/public/assets/index-uov949jQ.js.br +0 -0
package/dist/index.js CHANGED
@@ -6,6 +6,13 @@ var inquirer = require('inquirer');
6
6
  var path = require('path');
7
7
  var os = require('os');
8
8
  var axios = require('axios');
9
+ var require$$0$1 = require('net');
10
+ var require$$1$2 = require('tls');
11
+ var require$$2 = require('url');
12
+ var require$$3 = require('assert');
13
+ var require$$1 = require('tty');
14
+ var require$$1$1 = require('util');
15
+ var require$$0 = require('events');
9
16
  var fs = require('fs');
10
17
  var handlebars = require('handlebars');
11
18
  var esbuild = require('esbuild');
@@ -82,6 +89,1738 @@ async function openUrl(url) {
82
89
  }
83
90
  }
84
91
 
92
+ var agent = {};
93
+
94
+ var src$1 = {exports: {}};
95
+
96
+ var browser = {exports: {}};
97
+
98
+ /**
99
+ * Helpers.
100
+ */
101
+
102
+ var ms;
103
+ var hasRequiredMs;
104
+
105
+ function requireMs () {
106
+ if (hasRequiredMs) return ms;
107
+ hasRequiredMs = 1;
108
+ var s = 1000;
109
+ var m = s * 60;
110
+ var h = m * 60;
111
+ var d = h * 24;
112
+ var w = d * 7;
113
+ var y = d * 365.25;
114
+
115
+ /**
116
+ * Parse or format the given `val`.
117
+ *
118
+ * Options:
119
+ *
120
+ * - `long` verbose formatting [false]
121
+ *
122
+ * @param {String|Number} val
123
+ * @param {Object} [options]
124
+ * @throws {Error} throw an error if val is not a non-empty string or a number
125
+ * @return {String|Number}
126
+ * @api public
127
+ */
128
+
129
+ ms = function (val, options) {
130
+ options = options || {};
131
+ var type = typeof val;
132
+ if (type === 'string' && val.length > 0) {
133
+ return parse(val);
134
+ } else if (type === 'number' && isFinite(val)) {
135
+ return options.long ? fmtLong(val) : fmtShort(val);
136
+ }
137
+ throw new Error(
138
+ 'val is not a non-empty string or a valid number. val=' +
139
+ JSON.stringify(val)
140
+ );
141
+ };
142
+
143
+ /**
144
+ * Parse the given `str` and return milliseconds.
145
+ *
146
+ * @param {String} str
147
+ * @return {Number}
148
+ * @api private
149
+ */
150
+
151
+ function parse(str) {
152
+ str = String(str);
153
+ if (str.length > 100) {
154
+ return;
155
+ }
156
+ var match = /^(-?(?:\d+)?\.?\d+) *(milliseconds?|msecs?|ms|seconds?|secs?|s|minutes?|mins?|m|hours?|hrs?|h|days?|d|weeks?|w|years?|yrs?|y)?$/i.exec(
157
+ str
158
+ );
159
+ if (!match) {
160
+ return;
161
+ }
162
+ var n = parseFloat(match[1]);
163
+ var type = (match[2] || 'ms').toLowerCase();
164
+ switch (type) {
165
+ case 'years':
166
+ case 'year':
167
+ case 'yrs':
168
+ case 'yr':
169
+ case 'y':
170
+ return n * y;
171
+ case 'weeks':
172
+ case 'week':
173
+ case 'w':
174
+ return n * w;
175
+ case 'days':
176
+ case 'day':
177
+ case 'd':
178
+ return n * d;
179
+ case 'hours':
180
+ case 'hour':
181
+ case 'hrs':
182
+ case 'hr':
183
+ case 'h':
184
+ return n * h;
185
+ case 'minutes':
186
+ case 'minute':
187
+ case 'mins':
188
+ case 'min':
189
+ case 'm':
190
+ return n * m;
191
+ case 'seconds':
192
+ case 'second':
193
+ case 'secs':
194
+ case 'sec':
195
+ case 's':
196
+ return n * s;
197
+ case 'milliseconds':
198
+ case 'millisecond':
199
+ case 'msecs':
200
+ case 'msec':
201
+ case 'ms':
202
+ return n;
203
+ default:
204
+ return undefined;
205
+ }
206
+ }
207
+
208
+ /**
209
+ * Short format for `ms`.
210
+ *
211
+ * @param {Number} ms
212
+ * @return {String}
213
+ * @api private
214
+ */
215
+
216
+ function fmtShort(ms) {
217
+ var msAbs = Math.abs(ms);
218
+ if (msAbs >= d) {
219
+ return Math.round(ms / d) + 'd';
220
+ }
221
+ if (msAbs >= h) {
222
+ return Math.round(ms / h) + 'h';
223
+ }
224
+ if (msAbs >= m) {
225
+ return Math.round(ms / m) + 'm';
226
+ }
227
+ if (msAbs >= s) {
228
+ return Math.round(ms / s) + 's';
229
+ }
230
+ return ms + 'ms';
231
+ }
232
+
233
+ /**
234
+ * Long format for `ms`.
235
+ *
236
+ * @param {Number} ms
237
+ * @return {String}
238
+ * @api private
239
+ */
240
+
241
+ function fmtLong(ms) {
242
+ var msAbs = Math.abs(ms);
243
+ if (msAbs >= d) {
244
+ return plural(ms, msAbs, d, 'day');
245
+ }
246
+ if (msAbs >= h) {
247
+ return plural(ms, msAbs, h, 'hour');
248
+ }
249
+ if (msAbs >= m) {
250
+ return plural(ms, msAbs, m, 'minute');
251
+ }
252
+ if (msAbs >= s) {
253
+ return plural(ms, msAbs, s, 'second');
254
+ }
255
+ return ms + ' ms';
256
+ }
257
+
258
+ /**
259
+ * Pluralization helper.
260
+ */
261
+
262
+ function plural(ms, msAbs, n, name) {
263
+ var isPlural = msAbs >= n * 1.5;
264
+ return Math.round(ms / n) + ' ' + name + (isPlural ? 's' : '');
265
+ }
266
+ return ms;
267
+ }
268
+
269
+ var common;
270
+ var hasRequiredCommon;
271
+
272
+ function requireCommon () {
273
+ if (hasRequiredCommon) return common;
274
+ hasRequiredCommon = 1;
275
+ /**
276
+ * This is the common logic for both the Node.js and web browser
277
+ * implementations of `debug()`.
278
+ */
279
+
280
+ function setup(env) {
281
+ createDebug.debug = createDebug;
282
+ createDebug.default = createDebug;
283
+ createDebug.coerce = coerce;
284
+ createDebug.disable = disable;
285
+ createDebug.enable = enable;
286
+ createDebug.enabled = enabled;
287
+ createDebug.humanize = requireMs();
288
+ createDebug.destroy = destroy;
289
+
290
+ Object.keys(env).forEach(key => {
291
+ createDebug[key] = env[key];
292
+ });
293
+
294
+ /**
295
+ * The currently active debug mode names, and names to skip.
296
+ */
297
+
298
+ createDebug.names = [];
299
+ createDebug.skips = [];
300
+
301
+ /**
302
+ * Map of special "%n" handling functions, for the debug "format" argument.
303
+ *
304
+ * Valid key names are a single, lower or upper-case letter, i.e. "n" and "N".
305
+ */
306
+ createDebug.formatters = {};
307
+
308
+ /**
309
+ * Selects a color for a debug namespace
310
+ * @param {String} namespace The namespace string for the debug instance to be colored
311
+ * @return {Number|String} An ANSI color code for the given namespace
312
+ * @api private
313
+ */
314
+ function selectColor(namespace) {
315
+ let hash = 0;
316
+
317
+ for (let i = 0; i < namespace.length; i++) {
318
+ hash = ((hash << 5) - hash) + namespace.charCodeAt(i);
319
+ hash |= 0; // Convert to 32bit integer
320
+ }
321
+
322
+ return createDebug.colors[Math.abs(hash) % createDebug.colors.length];
323
+ }
324
+ createDebug.selectColor = selectColor;
325
+
326
+ /**
327
+ * Create a debugger with the given `namespace`.
328
+ *
329
+ * @param {String} namespace
330
+ * @return {Function}
331
+ * @api public
332
+ */
333
+ function createDebug(namespace) {
334
+ let prevTime;
335
+ let enableOverride = null;
336
+ let namespacesCache;
337
+ let enabledCache;
338
+
339
+ function debug(...args) {
340
+ // Disabled?
341
+ if (!debug.enabled) {
342
+ return;
343
+ }
344
+
345
+ const self = debug;
346
+
347
+ // Set `diff` timestamp
348
+ const curr = Number(new Date());
349
+ const ms = curr - (prevTime || curr);
350
+ self.diff = ms;
351
+ self.prev = prevTime;
352
+ self.curr = curr;
353
+ prevTime = curr;
354
+
355
+ args[0] = createDebug.coerce(args[0]);
356
+
357
+ if (typeof args[0] !== 'string') {
358
+ // Anything else let's inspect with %O
359
+ args.unshift('%O');
360
+ }
361
+
362
+ // Apply any `formatters` transformations
363
+ let index = 0;
364
+ args[0] = args[0].replace(/%([a-zA-Z%])/g, (match, format) => {
365
+ // If we encounter an escaped % then don't increase the array index
366
+ if (match === '%%') {
367
+ return '%';
368
+ }
369
+ index++;
370
+ const formatter = createDebug.formatters[format];
371
+ if (typeof formatter === 'function') {
372
+ const val = args[index];
373
+ match = formatter.call(self, val);
374
+
375
+ // Now we need to remove `args[index]` since it's inlined in the `format`
376
+ args.splice(index, 1);
377
+ index--;
378
+ }
379
+ return match;
380
+ });
381
+
382
+ // Apply env-specific formatting (colors, etc.)
383
+ createDebug.formatArgs.call(self, args);
384
+
385
+ const logFn = self.log || createDebug.log;
386
+ logFn.apply(self, args);
387
+ }
388
+
389
+ debug.namespace = namespace;
390
+ debug.useColors = createDebug.useColors();
391
+ debug.color = createDebug.selectColor(namespace);
392
+ debug.extend = extend;
393
+ debug.destroy = createDebug.destroy; // XXX Temporary. Will be removed in the next major release.
394
+
395
+ Object.defineProperty(debug, 'enabled', {
396
+ enumerable: true,
397
+ configurable: false,
398
+ get: () => {
399
+ if (enableOverride !== null) {
400
+ return enableOverride;
401
+ }
402
+ if (namespacesCache !== createDebug.namespaces) {
403
+ namespacesCache = createDebug.namespaces;
404
+ enabledCache = createDebug.enabled(namespace);
405
+ }
406
+
407
+ return enabledCache;
408
+ },
409
+ set: v => {
410
+ enableOverride = v;
411
+ }
412
+ });
413
+
414
+ // Env-specific initialization logic for debug instances
415
+ if (typeof createDebug.init === 'function') {
416
+ createDebug.init(debug);
417
+ }
418
+
419
+ return debug;
420
+ }
421
+
422
+ function extend(namespace, delimiter) {
423
+ const newDebug = createDebug(this.namespace + (typeof delimiter === 'undefined' ? ':' : delimiter) + namespace);
424
+ newDebug.log = this.log;
425
+ return newDebug;
426
+ }
427
+
428
+ /**
429
+ * Enables a debug mode by namespaces. This can include modes
430
+ * separated by a colon and wildcards.
431
+ *
432
+ * @param {String} namespaces
433
+ * @api public
434
+ */
435
+ function enable(namespaces) {
436
+ createDebug.save(namespaces);
437
+ createDebug.namespaces = namespaces;
438
+
439
+ createDebug.names = [];
440
+ createDebug.skips = [];
441
+
442
+ const split = (typeof namespaces === 'string' ? namespaces : '')
443
+ .trim()
444
+ .replace(/\s+/g, ',')
445
+ .split(',')
446
+ .filter(Boolean);
447
+
448
+ for (const ns of split) {
449
+ if (ns[0] === '-') {
450
+ createDebug.skips.push(ns.slice(1));
451
+ } else {
452
+ createDebug.names.push(ns);
453
+ }
454
+ }
455
+ }
456
+
457
+ /**
458
+ * Checks if the given string matches a namespace template, honoring
459
+ * asterisks as wildcards.
460
+ *
461
+ * @param {String} search
462
+ * @param {String} template
463
+ * @return {Boolean}
464
+ */
465
+ function matchesTemplate(search, template) {
466
+ let searchIndex = 0;
467
+ let templateIndex = 0;
468
+ let starIndex = -1;
469
+ let matchIndex = 0;
470
+
471
+ while (searchIndex < search.length) {
472
+ if (templateIndex < template.length && (template[templateIndex] === search[searchIndex] || template[templateIndex] === '*')) {
473
+ // Match character or proceed with wildcard
474
+ if (template[templateIndex] === '*') {
475
+ starIndex = templateIndex;
476
+ matchIndex = searchIndex;
477
+ templateIndex++; // Skip the '*'
478
+ } else {
479
+ searchIndex++;
480
+ templateIndex++;
481
+ }
482
+ } else if (starIndex !== -1) { // eslint-disable-line no-negated-condition
483
+ // Backtrack to the last '*' and try to match more characters
484
+ templateIndex = starIndex + 1;
485
+ matchIndex++;
486
+ searchIndex = matchIndex;
487
+ } else {
488
+ return false; // No match
489
+ }
490
+ }
491
+
492
+ // Handle trailing '*' in template
493
+ while (templateIndex < template.length && template[templateIndex] === '*') {
494
+ templateIndex++;
495
+ }
496
+
497
+ return templateIndex === template.length;
498
+ }
499
+
500
+ /**
501
+ * Disable debug output.
502
+ *
503
+ * @return {String} namespaces
504
+ * @api public
505
+ */
506
+ function disable() {
507
+ const namespaces = [
508
+ ...createDebug.names,
509
+ ...createDebug.skips.map(namespace => '-' + namespace)
510
+ ].join(',');
511
+ createDebug.enable('');
512
+ return namespaces;
513
+ }
514
+
515
+ /**
516
+ * Returns true if the given mode name is enabled, false otherwise.
517
+ *
518
+ * @param {String} name
519
+ * @return {Boolean}
520
+ * @api public
521
+ */
522
+ function enabled(name) {
523
+ for (const skip of createDebug.skips) {
524
+ if (matchesTemplate(name, skip)) {
525
+ return false;
526
+ }
527
+ }
528
+
529
+ for (const ns of createDebug.names) {
530
+ if (matchesTemplate(name, ns)) {
531
+ return true;
532
+ }
533
+ }
534
+
535
+ return false;
536
+ }
537
+
538
+ /**
539
+ * Coerce `val`.
540
+ *
541
+ * @param {Mixed} val
542
+ * @return {Mixed}
543
+ * @api private
544
+ */
545
+ function coerce(val) {
546
+ if (val instanceof Error) {
547
+ return val.stack || val.message;
548
+ }
549
+ return val;
550
+ }
551
+
552
+ /**
553
+ * XXX DO NOT USE. This is a temporary stub function.
554
+ * XXX It WILL be removed in the next major release.
555
+ */
556
+ function destroy() {
557
+ console.warn('Instance method `debug.destroy()` is deprecated and no longer does anything. It will be removed in the next major version of `debug`.');
558
+ }
559
+
560
+ createDebug.enable(createDebug.load());
561
+
562
+ return createDebug;
563
+ }
564
+
565
+ common = setup;
566
+ return common;
567
+ }
568
+
569
+ /* eslint-env browser */
570
+
571
+ var hasRequiredBrowser;
572
+
573
+ function requireBrowser () {
574
+ if (hasRequiredBrowser) return browser.exports;
575
+ hasRequiredBrowser = 1;
576
+ (function (module, exports$1) {
577
+ /**
578
+ * This is the web browser implementation of `debug()`.
579
+ */
580
+
581
+ exports$1.formatArgs = formatArgs;
582
+ exports$1.save = save;
583
+ exports$1.load = load;
584
+ exports$1.useColors = useColors;
585
+ exports$1.storage = localstorage();
586
+ exports$1.destroy = (() => {
587
+ let warned = false;
588
+
589
+ return () => {
590
+ if (!warned) {
591
+ warned = true;
592
+ console.warn('Instance method `debug.destroy()` is deprecated and no longer does anything. It will be removed in the next major version of `debug`.');
593
+ }
594
+ };
595
+ })();
596
+
597
+ /**
598
+ * Colors.
599
+ */
600
+
601
+ exports$1.colors = [
602
+ '#0000CC',
603
+ '#0000FF',
604
+ '#0033CC',
605
+ '#0033FF',
606
+ '#0066CC',
607
+ '#0066FF',
608
+ '#0099CC',
609
+ '#0099FF',
610
+ '#00CC00',
611
+ '#00CC33',
612
+ '#00CC66',
613
+ '#00CC99',
614
+ '#00CCCC',
615
+ '#00CCFF',
616
+ '#3300CC',
617
+ '#3300FF',
618
+ '#3333CC',
619
+ '#3333FF',
620
+ '#3366CC',
621
+ '#3366FF',
622
+ '#3399CC',
623
+ '#3399FF',
624
+ '#33CC00',
625
+ '#33CC33',
626
+ '#33CC66',
627
+ '#33CC99',
628
+ '#33CCCC',
629
+ '#33CCFF',
630
+ '#6600CC',
631
+ '#6600FF',
632
+ '#6633CC',
633
+ '#6633FF',
634
+ '#66CC00',
635
+ '#66CC33',
636
+ '#9900CC',
637
+ '#9900FF',
638
+ '#9933CC',
639
+ '#9933FF',
640
+ '#99CC00',
641
+ '#99CC33',
642
+ '#CC0000',
643
+ '#CC0033',
644
+ '#CC0066',
645
+ '#CC0099',
646
+ '#CC00CC',
647
+ '#CC00FF',
648
+ '#CC3300',
649
+ '#CC3333',
650
+ '#CC3366',
651
+ '#CC3399',
652
+ '#CC33CC',
653
+ '#CC33FF',
654
+ '#CC6600',
655
+ '#CC6633',
656
+ '#CC9900',
657
+ '#CC9933',
658
+ '#CCCC00',
659
+ '#CCCC33',
660
+ '#FF0000',
661
+ '#FF0033',
662
+ '#FF0066',
663
+ '#FF0099',
664
+ '#FF00CC',
665
+ '#FF00FF',
666
+ '#FF3300',
667
+ '#FF3333',
668
+ '#FF3366',
669
+ '#FF3399',
670
+ '#FF33CC',
671
+ '#FF33FF',
672
+ '#FF6600',
673
+ '#FF6633',
674
+ '#FF9900',
675
+ '#FF9933',
676
+ '#FFCC00',
677
+ '#FFCC33'
678
+ ];
679
+
680
+ /**
681
+ * Currently only WebKit-based Web Inspectors, Firefox >= v31,
682
+ * and the Firebug extension (any Firefox version) are known
683
+ * to support "%c" CSS customizations.
684
+ *
685
+ * TODO: add a `localStorage` variable to explicitly enable/disable colors
686
+ */
687
+
688
+ // eslint-disable-next-line complexity
689
+ function useColors() {
690
+ // NB: In an Electron preload script, document will be defined but not fully
691
+ // initialized. Since we know we're in Chrome, we'll just detect this case
692
+ // explicitly
693
+ if (typeof window !== 'undefined' && window.process && (window.process.type === 'renderer' || window.process.__nwjs)) {
694
+ return true;
695
+ }
696
+
697
+ // Internet Explorer and Edge do not support colors.
698
+ if (typeof navigator !== 'undefined' && navigator.userAgent && navigator.userAgent.toLowerCase().match(/(edge|trident)\/(\d+)/)) {
699
+ return false;
700
+ }
701
+
702
+ let m;
703
+
704
+ // Is webkit? http://stackoverflow.com/a/16459606/376773
705
+ // document is undefined in react-native: https://github.com/facebook/react-native/pull/1632
706
+ // eslint-disable-next-line no-return-assign
707
+ return (typeof document !== 'undefined' && document.documentElement && document.documentElement.style && document.documentElement.style.WebkitAppearance) ||
708
+ // Is firebug? http://stackoverflow.com/a/398120/376773
709
+ (typeof window !== 'undefined' && window.console && (window.console.firebug || (window.console.exception && window.console.table))) ||
710
+ // Is firefox >= v31?
711
+ // https://developer.mozilla.org/en-US/docs/Tools/Web_Console#Styling_messages
712
+ (typeof navigator !== 'undefined' && navigator.userAgent && (m = navigator.userAgent.toLowerCase().match(/firefox\/(\d+)/)) && parseInt(m[1], 10) >= 31) ||
713
+ // Double check webkit in userAgent just in case we are in a worker
714
+ (typeof navigator !== 'undefined' && navigator.userAgent && navigator.userAgent.toLowerCase().match(/applewebkit\/(\d+)/));
715
+ }
716
+
717
+ /**
718
+ * Colorize log arguments if enabled.
719
+ *
720
+ * @api public
721
+ */
722
+
723
+ function formatArgs(args) {
724
+ args[0] = (this.useColors ? '%c' : '') +
725
+ this.namespace +
726
+ (this.useColors ? ' %c' : ' ') +
727
+ args[0] +
728
+ (this.useColors ? '%c ' : ' ') +
729
+ '+' + module.exports.humanize(this.diff);
730
+
731
+ if (!this.useColors) {
732
+ return;
733
+ }
734
+
735
+ const c = 'color: ' + this.color;
736
+ args.splice(1, 0, c, 'color: inherit');
737
+
738
+ // The final "%c" is somewhat tricky, because there could be other
739
+ // arguments passed either before or after the %c, so we need to
740
+ // figure out the correct index to insert the CSS into
741
+ let index = 0;
742
+ let lastC = 0;
743
+ args[0].replace(/%[a-zA-Z%]/g, match => {
744
+ if (match === '%%') {
745
+ return;
746
+ }
747
+ index++;
748
+ if (match === '%c') {
749
+ // We only are interested in the *last* %c
750
+ // (the user may have provided their own)
751
+ lastC = index;
752
+ }
753
+ });
754
+
755
+ args.splice(lastC, 0, c);
756
+ }
757
+
758
+ /**
759
+ * Invokes `console.debug()` when available.
760
+ * No-op when `console.debug` is not a "function".
761
+ * If `console.debug` is not available, falls back
762
+ * to `console.log`.
763
+ *
764
+ * @api public
765
+ */
766
+ exports$1.log = console.debug || console.log || (() => {});
767
+
768
+ /**
769
+ * Save `namespaces`.
770
+ *
771
+ * @param {String} namespaces
772
+ * @api private
773
+ */
774
+ function save(namespaces) {
775
+ try {
776
+ if (namespaces) {
777
+ exports$1.storage.setItem('debug', namespaces);
778
+ } else {
779
+ exports$1.storage.removeItem('debug');
780
+ }
781
+ } catch (error) {
782
+ // Swallow
783
+ // XXX (@Qix-) should we be logging these?
784
+ }
785
+ }
786
+
787
+ /**
788
+ * Load `namespaces`.
789
+ *
790
+ * @return {String} returns the previously persisted debug modes
791
+ * @api private
792
+ */
793
+ function load() {
794
+ let r;
795
+ try {
796
+ r = exports$1.storage.getItem('debug') || exports$1.storage.getItem('DEBUG') ;
797
+ } catch (error) {
798
+ // Swallow
799
+ // XXX (@Qix-) should we be logging these?
800
+ }
801
+
802
+ // If debug isn't set in LS, and we're in Electron, try to load $DEBUG
803
+ if (!r && typeof process !== 'undefined' && 'env' in process) {
804
+ r = process.env.DEBUG;
805
+ }
806
+
807
+ return r;
808
+ }
809
+
810
+ /**
811
+ * Localstorage attempts to return the localstorage.
812
+ *
813
+ * This is necessary because safari throws
814
+ * when a user disables cookies/localstorage
815
+ * and you attempt to access it.
816
+ *
817
+ * @return {LocalStorage}
818
+ * @api private
819
+ */
820
+
821
+ function localstorage() {
822
+ try {
823
+ // TVMLKit (Apple TV JS Runtime) does not have a window object, just localStorage in the global context
824
+ // The Browser also has localStorage in the global context.
825
+ return localStorage;
826
+ } catch (error) {
827
+ // Swallow
828
+ // XXX (@Qix-) should we be logging these?
829
+ }
830
+ }
831
+
832
+ module.exports = requireCommon()(exports$1);
833
+
834
+ const {formatters} = module.exports;
835
+
836
+ /**
837
+ * Map %j to `JSON.stringify()`, since no Web Inspectors do that by default.
838
+ */
839
+
840
+ formatters.j = function (v) {
841
+ try {
842
+ return JSON.stringify(v);
843
+ } catch (error) {
844
+ return '[UnexpectedJSONParseError]: ' + error.message;
845
+ }
846
+ };
847
+ } (browser, browser.exports));
848
+ return browser.exports;
849
+ }
850
+
851
+ var node = {exports: {}};
852
+
853
+ var hasFlag;
854
+ var hasRequiredHasFlag;
855
+
856
+ function requireHasFlag () {
857
+ if (hasRequiredHasFlag) return hasFlag;
858
+ hasRequiredHasFlag = 1;
859
+
860
+ hasFlag = (flag, argv = process.argv) => {
861
+ const prefix = flag.startsWith('-') ? '' : (flag.length === 1 ? '-' : '--');
862
+ const position = argv.indexOf(prefix + flag);
863
+ const terminatorPosition = argv.indexOf('--');
864
+ return position !== -1 && (terminatorPosition === -1 || position < terminatorPosition);
865
+ };
866
+ return hasFlag;
867
+ }
868
+
869
+ var supportsColor_1;
870
+ var hasRequiredSupportsColor;
871
+
872
+ function requireSupportsColor () {
873
+ if (hasRequiredSupportsColor) return supportsColor_1;
874
+ hasRequiredSupportsColor = 1;
875
+ const os$1 = os;
876
+ const tty = require$$1;
877
+ const hasFlag = requireHasFlag();
878
+
879
+ const {env} = process;
880
+
881
+ let forceColor;
882
+ if (hasFlag('no-color') ||
883
+ hasFlag('no-colors') ||
884
+ hasFlag('color=false') ||
885
+ hasFlag('color=never')) {
886
+ forceColor = 0;
887
+ } else if (hasFlag('color') ||
888
+ hasFlag('colors') ||
889
+ hasFlag('color=true') ||
890
+ hasFlag('color=always')) {
891
+ forceColor = 1;
892
+ }
893
+
894
+ if ('FORCE_COLOR' in env) {
895
+ if (env.FORCE_COLOR === 'true') {
896
+ forceColor = 1;
897
+ } else if (env.FORCE_COLOR === 'false') {
898
+ forceColor = 0;
899
+ } else {
900
+ forceColor = env.FORCE_COLOR.length === 0 ? 1 : Math.min(parseInt(env.FORCE_COLOR, 10), 3);
901
+ }
902
+ }
903
+
904
+ function translateLevel(level) {
905
+ if (level === 0) {
906
+ return false;
907
+ }
908
+
909
+ return {
910
+ level,
911
+ hasBasic: true,
912
+ has256: level >= 2,
913
+ has16m: level >= 3
914
+ };
915
+ }
916
+
917
+ function supportsColor(haveStream, streamIsTTY) {
918
+ if (forceColor === 0) {
919
+ return 0;
920
+ }
921
+
922
+ if (hasFlag('color=16m') ||
923
+ hasFlag('color=full') ||
924
+ hasFlag('color=truecolor')) {
925
+ return 3;
926
+ }
927
+
928
+ if (hasFlag('color=256')) {
929
+ return 2;
930
+ }
931
+
932
+ if (haveStream && !streamIsTTY && forceColor === undefined) {
933
+ return 0;
934
+ }
935
+
936
+ const min = forceColor || 0;
937
+
938
+ if (env.TERM === 'dumb') {
939
+ return min;
940
+ }
941
+
942
+ if (process.platform === 'win32') {
943
+ // Windows 10 build 10586 is the first Windows release that supports 256 colors.
944
+ // Windows 10 build 14931 is the first release that supports 16m/TrueColor.
945
+ const osRelease = os$1.release().split('.');
946
+ if (
947
+ Number(osRelease[0]) >= 10 &&
948
+ Number(osRelease[2]) >= 10586
949
+ ) {
950
+ return Number(osRelease[2]) >= 14931 ? 3 : 2;
951
+ }
952
+
953
+ return 1;
954
+ }
955
+
956
+ if ('CI' in env) {
957
+ if (['TRAVIS', 'CIRCLECI', 'APPVEYOR', 'GITLAB_CI', 'GITHUB_ACTIONS', 'BUILDKITE'].some(sign => sign in env) || env.CI_NAME === 'codeship') {
958
+ return 1;
959
+ }
960
+
961
+ return min;
962
+ }
963
+
964
+ if ('TEAMCITY_VERSION' in env) {
965
+ return /^(9\.(0*[1-9]\d*)\.|\d{2,}\.)/.test(env.TEAMCITY_VERSION) ? 1 : 0;
966
+ }
967
+
968
+ if (env.COLORTERM === 'truecolor') {
969
+ return 3;
970
+ }
971
+
972
+ if ('TERM_PROGRAM' in env) {
973
+ const version = parseInt((env.TERM_PROGRAM_VERSION || '').split('.')[0], 10);
974
+
975
+ switch (env.TERM_PROGRAM) {
976
+ case 'iTerm.app':
977
+ return version >= 3 ? 3 : 2;
978
+ case 'Apple_Terminal':
979
+ return 2;
980
+ // No default
981
+ }
982
+ }
983
+
984
+ if (/-256(color)?$/i.test(env.TERM)) {
985
+ return 2;
986
+ }
987
+
988
+ if (/^screen|^xterm|^vt100|^vt220|^rxvt|color|ansi|cygwin|linux/i.test(env.TERM)) {
989
+ return 1;
990
+ }
991
+
992
+ if ('COLORTERM' in env) {
993
+ return 1;
994
+ }
995
+
996
+ return min;
997
+ }
998
+
999
+ function getSupportLevel(stream) {
1000
+ const level = supportsColor(stream, stream && stream.isTTY);
1001
+ return translateLevel(level);
1002
+ }
1003
+
1004
+ supportsColor_1 = {
1005
+ supportsColor: getSupportLevel,
1006
+ stdout: translateLevel(supportsColor(true, tty.isatty(1))),
1007
+ stderr: translateLevel(supportsColor(true, tty.isatty(2)))
1008
+ };
1009
+ return supportsColor_1;
1010
+ }
1011
+
1012
+ /**
1013
+ * Module dependencies.
1014
+ */
1015
+
1016
+ var hasRequiredNode;
1017
+
1018
+ function requireNode () {
1019
+ if (hasRequiredNode) return node.exports;
1020
+ hasRequiredNode = 1;
1021
+ (function (module, exports$1) {
1022
+ const tty = require$$1;
1023
+ const util = require$$1$1;
1024
+
1025
+ /**
1026
+ * This is the Node.js implementation of `debug()`.
1027
+ */
1028
+
1029
+ exports$1.init = init;
1030
+ exports$1.log = log;
1031
+ exports$1.formatArgs = formatArgs;
1032
+ exports$1.save = save;
1033
+ exports$1.load = load;
1034
+ exports$1.useColors = useColors;
1035
+ exports$1.destroy = util.deprecate(
1036
+ () => {},
1037
+ 'Instance method `debug.destroy()` is deprecated and no longer does anything. It will be removed in the next major version of `debug`.'
1038
+ );
1039
+
1040
+ /**
1041
+ * Colors.
1042
+ */
1043
+
1044
+ exports$1.colors = [6, 2, 3, 4, 5, 1];
1045
+
1046
+ try {
1047
+ // Optional dependency (as in, doesn't need to be installed, NOT like optionalDependencies in package.json)
1048
+ // eslint-disable-next-line import/no-extraneous-dependencies
1049
+ const supportsColor = requireSupportsColor();
1050
+
1051
+ if (supportsColor && (supportsColor.stderr || supportsColor).level >= 2) {
1052
+ exports$1.colors = [
1053
+ 20,
1054
+ 21,
1055
+ 26,
1056
+ 27,
1057
+ 32,
1058
+ 33,
1059
+ 38,
1060
+ 39,
1061
+ 40,
1062
+ 41,
1063
+ 42,
1064
+ 43,
1065
+ 44,
1066
+ 45,
1067
+ 56,
1068
+ 57,
1069
+ 62,
1070
+ 63,
1071
+ 68,
1072
+ 69,
1073
+ 74,
1074
+ 75,
1075
+ 76,
1076
+ 77,
1077
+ 78,
1078
+ 79,
1079
+ 80,
1080
+ 81,
1081
+ 92,
1082
+ 93,
1083
+ 98,
1084
+ 99,
1085
+ 112,
1086
+ 113,
1087
+ 128,
1088
+ 129,
1089
+ 134,
1090
+ 135,
1091
+ 148,
1092
+ 149,
1093
+ 160,
1094
+ 161,
1095
+ 162,
1096
+ 163,
1097
+ 164,
1098
+ 165,
1099
+ 166,
1100
+ 167,
1101
+ 168,
1102
+ 169,
1103
+ 170,
1104
+ 171,
1105
+ 172,
1106
+ 173,
1107
+ 178,
1108
+ 179,
1109
+ 184,
1110
+ 185,
1111
+ 196,
1112
+ 197,
1113
+ 198,
1114
+ 199,
1115
+ 200,
1116
+ 201,
1117
+ 202,
1118
+ 203,
1119
+ 204,
1120
+ 205,
1121
+ 206,
1122
+ 207,
1123
+ 208,
1124
+ 209,
1125
+ 214,
1126
+ 215,
1127
+ 220,
1128
+ 221
1129
+ ];
1130
+ }
1131
+ } catch (error) {
1132
+ // Swallow - we only care if `supports-color` is available; it doesn't have to be.
1133
+ }
1134
+
1135
+ /**
1136
+ * Build up the default `inspectOpts` object from the environment variables.
1137
+ *
1138
+ * $ DEBUG_COLORS=no DEBUG_DEPTH=10 DEBUG_SHOW_HIDDEN=enabled node script.js
1139
+ */
1140
+
1141
+ exports$1.inspectOpts = Object.keys(process.env).filter(key => {
1142
+ return /^debug_/i.test(key);
1143
+ }).reduce((obj, key) => {
1144
+ // Camel-case
1145
+ const prop = key
1146
+ .substring(6)
1147
+ .toLowerCase()
1148
+ .replace(/_([a-z])/g, (_, k) => {
1149
+ return k.toUpperCase();
1150
+ });
1151
+
1152
+ // Coerce string value into JS value
1153
+ let val = process.env[key];
1154
+ if (/^(yes|on|true|enabled)$/i.test(val)) {
1155
+ val = true;
1156
+ } else if (/^(no|off|false|disabled)$/i.test(val)) {
1157
+ val = false;
1158
+ } else if (val === 'null') {
1159
+ val = null;
1160
+ } else {
1161
+ val = Number(val);
1162
+ }
1163
+
1164
+ obj[prop] = val;
1165
+ return obj;
1166
+ }, {});
1167
+
1168
+ /**
1169
+ * Is stdout a TTY? Colored output is enabled when `true`.
1170
+ */
1171
+
1172
+ function useColors() {
1173
+ return 'colors' in exports$1.inspectOpts ?
1174
+ Boolean(exports$1.inspectOpts.colors) :
1175
+ tty.isatty(process.stderr.fd);
1176
+ }
1177
+
1178
+ /**
1179
+ * Adds ANSI color escape codes if enabled.
1180
+ *
1181
+ * @api public
1182
+ */
1183
+
1184
+ function formatArgs(args) {
1185
+ const {namespace: name, useColors} = this;
1186
+
1187
+ if (useColors) {
1188
+ const c = this.color;
1189
+ const colorCode = '\u001B[3' + (c < 8 ? c : '8;5;' + c);
1190
+ const prefix = ` ${colorCode};1m${name} \u001B[0m`;
1191
+
1192
+ args[0] = prefix + args[0].split('\n').join('\n' + prefix);
1193
+ args.push(colorCode + 'm+' + module.exports.humanize(this.diff) + '\u001B[0m');
1194
+ } else {
1195
+ args[0] = getDate() + name + ' ' + args[0];
1196
+ }
1197
+ }
1198
+
1199
+ function getDate() {
1200
+ if (exports$1.inspectOpts.hideDate) {
1201
+ return '';
1202
+ }
1203
+ return new Date().toISOString() + ' ';
1204
+ }
1205
+
1206
+ /**
1207
+ * Invokes `util.formatWithOptions()` with the specified arguments and writes to stderr.
1208
+ */
1209
+
1210
+ function log(...args) {
1211
+ return process.stderr.write(util.formatWithOptions(exports$1.inspectOpts, ...args) + '\n');
1212
+ }
1213
+
1214
+ /**
1215
+ * Save `namespaces`.
1216
+ *
1217
+ * @param {String} namespaces
1218
+ * @api private
1219
+ */
1220
+ function save(namespaces) {
1221
+ if (namespaces) {
1222
+ process.env.DEBUG = namespaces;
1223
+ } else {
1224
+ // If you set a process.env field to null or undefined, it gets cast to the
1225
+ // string 'null' or 'undefined'. Just delete instead.
1226
+ delete process.env.DEBUG;
1227
+ }
1228
+ }
1229
+
1230
+ /**
1231
+ * Load `namespaces`.
1232
+ *
1233
+ * @return {String} returns the previously persisted debug modes
1234
+ * @api private
1235
+ */
1236
+
1237
+ function load() {
1238
+ return process.env.DEBUG;
1239
+ }
1240
+
1241
+ /**
1242
+ * Init logic for `debug` instances.
1243
+ *
1244
+ * Create a new `inspectOpts` object in case `useColors` is set
1245
+ * differently for a particular `debug` instance.
1246
+ */
1247
+
1248
+ function init(debug) {
1249
+ debug.inspectOpts = {};
1250
+
1251
+ const keys = Object.keys(exports$1.inspectOpts);
1252
+ for (let i = 0; i < keys.length; i++) {
1253
+ debug.inspectOpts[keys[i]] = exports$1.inspectOpts[keys[i]];
1254
+ }
1255
+ }
1256
+
1257
+ module.exports = requireCommon()(exports$1);
1258
+
1259
+ const {formatters} = module.exports;
1260
+
1261
+ /**
1262
+ * Map %o to `util.inspect()`, all on a single line.
1263
+ */
1264
+
1265
+ formatters.o = function (v) {
1266
+ this.inspectOpts.colors = this.useColors;
1267
+ return util.inspect(v, this.inspectOpts)
1268
+ .split('\n')
1269
+ .map(str => str.trim())
1270
+ .join(' ');
1271
+ };
1272
+
1273
+ /**
1274
+ * Map %O to `util.inspect()`, allowing multiple lines if needed.
1275
+ */
1276
+
1277
+ formatters.O = function (v) {
1278
+ this.inspectOpts.colors = this.useColors;
1279
+ return util.inspect(v, this.inspectOpts);
1280
+ };
1281
+ } (node, node.exports));
1282
+ return node.exports;
1283
+ }
1284
+
1285
+ /**
1286
+ * Detect Electron renderer / nwjs process, which is node, but we should
1287
+ * treat as a browser.
1288
+ */
1289
+
1290
+ var hasRequiredSrc$1;
1291
+
1292
+ function requireSrc$1 () {
1293
+ if (hasRequiredSrc$1) return src$1.exports;
1294
+ hasRequiredSrc$1 = 1;
1295
+ if (typeof process === 'undefined' || process.type === 'renderer' || process.browser === true || process.__nwjs) {
1296
+ src$1.exports = requireBrowser();
1297
+ } else {
1298
+ src$1.exports = requireNode();
1299
+ }
1300
+ return src$1.exports;
1301
+ }
1302
+
1303
+ var promisify = {};
1304
+
1305
+ var hasRequiredPromisify;
1306
+
1307
+ function requirePromisify () {
1308
+ if (hasRequiredPromisify) return promisify;
1309
+ hasRequiredPromisify = 1;
1310
+ Object.defineProperty(promisify, "__esModule", { value: true });
1311
+ function promisify$1(fn) {
1312
+ return function (req, opts) {
1313
+ return new Promise((resolve, reject) => {
1314
+ fn.call(this, req, opts, (err, rtn) => {
1315
+ if (err) {
1316
+ reject(err);
1317
+ }
1318
+ else {
1319
+ resolve(rtn);
1320
+ }
1321
+ });
1322
+ });
1323
+ };
1324
+ }
1325
+ promisify.default = promisify$1;
1326
+
1327
+ return promisify;
1328
+ }
1329
+
1330
+ var src;
1331
+ var hasRequiredSrc;
1332
+
1333
+ function requireSrc () {
1334
+ if (hasRequiredSrc) return src;
1335
+ hasRequiredSrc = 1;
1336
+ var __importDefault = (src && src.__importDefault) || function (mod) {
1337
+ return (mod && mod.__esModule) ? mod : { "default": mod };
1338
+ };
1339
+ const events_1 = require$$0;
1340
+ const debug_1 = __importDefault(requireSrc$1());
1341
+ const promisify_1 = __importDefault(requirePromisify());
1342
+ const debug = debug_1.default('agent-base');
1343
+ function isAgent(v) {
1344
+ return Boolean(v) && typeof v.addRequest === 'function';
1345
+ }
1346
+ function isSecureEndpoint() {
1347
+ const { stack } = new Error();
1348
+ if (typeof stack !== 'string')
1349
+ return false;
1350
+ return stack.split('\n').some(l => l.indexOf('(https.js:') !== -1 || l.indexOf('node:https:') !== -1);
1351
+ }
1352
+ function createAgent(callback, opts) {
1353
+ return new createAgent.Agent(callback, opts);
1354
+ }
1355
+ (function (createAgent) {
1356
+ /**
1357
+ * Base `http.Agent` implementation.
1358
+ * No pooling/keep-alive is implemented by default.
1359
+ *
1360
+ * @param {Function} callback
1361
+ * @api public
1362
+ */
1363
+ class Agent extends events_1.EventEmitter {
1364
+ constructor(callback, _opts) {
1365
+ super();
1366
+ let opts = _opts;
1367
+ if (typeof callback === 'function') {
1368
+ this.callback = callback;
1369
+ }
1370
+ else if (callback) {
1371
+ opts = callback;
1372
+ }
1373
+ // Timeout for the socket to be returned from the callback
1374
+ this.timeout = null;
1375
+ if (opts && typeof opts.timeout === 'number') {
1376
+ this.timeout = opts.timeout;
1377
+ }
1378
+ // These aren't actually used by `agent-base`, but are required
1379
+ // for the TypeScript definition files in `@types/node` :/
1380
+ this.maxFreeSockets = 1;
1381
+ this.maxSockets = 1;
1382
+ this.maxTotalSockets = Infinity;
1383
+ this.sockets = {};
1384
+ this.freeSockets = {};
1385
+ this.requests = {};
1386
+ this.options = {};
1387
+ }
1388
+ get defaultPort() {
1389
+ if (typeof this.explicitDefaultPort === 'number') {
1390
+ return this.explicitDefaultPort;
1391
+ }
1392
+ return isSecureEndpoint() ? 443 : 80;
1393
+ }
1394
+ set defaultPort(v) {
1395
+ this.explicitDefaultPort = v;
1396
+ }
1397
+ get protocol() {
1398
+ if (typeof this.explicitProtocol === 'string') {
1399
+ return this.explicitProtocol;
1400
+ }
1401
+ return isSecureEndpoint() ? 'https:' : 'http:';
1402
+ }
1403
+ set protocol(v) {
1404
+ this.explicitProtocol = v;
1405
+ }
1406
+ callback(req, opts, fn) {
1407
+ throw new Error('"agent-base" has no default implementation, you must subclass and override `callback()`');
1408
+ }
1409
+ /**
1410
+ * Called by node-core's "_http_client.js" module when creating
1411
+ * a new HTTP request with this Agent instance.
1412
+ *
1413
+ * @api public
1414
+ */
1415
+ addRequest(req, _opts) {
1416
+ const opts = Object.assign({}, _opts);
1417
+ if (typeof opts.secureEndpoint !== 'boolean') {
1418
+ opts.secureEndpoint = isSecureEndpoint();
1419
+ }
1420
+ if (opts.host == null) {
1421
+ opts.host = 'localhost';
1422
+ }
1423
+ if (opts.port == null) {
1424
+ opts.port = opts.secureEndpoint ? 443 : 80;
1425
+ }
1426
+ if (opts.protocol == null) {
1427
+ opts.protocol = opts.secureEndpoint ? 'https:' : 'http:';
1428
+ }
1429
+ if (opts.host && opts.path) {
1430
+ // If both a `host` and `path` are specified then it's most
1431
+ // likely the result of a `url.parse()` call... we need to
1432
+ // remove the `path` portion so that `net.connect()` doesn't
1433
+ // attempt to open that as a unix socket file.
1434
+ delete opts.path;
1435
+ }
1436
+ delete opts.agent;
1437
+ delete opts.hostname;
1438
+ delete opts._defaultAgent;
1439
+ delete opts.defaultPort;
1440
+ delete opts.createConnection;
1441
+ // Hint to use "Connection: close"
1442
+ // XXX: non-documented `http` module API :(
1443
+ req._last = true;
1444
+ req.shouldKeepAlive = false;
1445
+ let timedOut = false;
1446
+ let timeoutId = null;
1447
+ const timeoutMs = opts.timeout || this.timeout;
1448
+ const onerror = (err) => {
1449
+ if (req._hadError)
1450
+ return;
1451
+ req.emit('error', err);
1452
+ // For Safety. Some additional errors might fire later on
1453
+ // and we need to make sure we don't double-fire the error event.
1454
+ req._hadError = true;
1455
+ };
1456
+ const ontimeout = () => {
1457
+ timeoutId = null;
1458
+ timedOut = true;
1459
+ const err = new Error(`A "socket" was not created for HTTP request before ${timeoutMs}ms`);
1460
+ err.code = 'ETIMEOUT';
1461
+ onerror(err);
1462
+ };
1463
+ const callbackError = (err) => {
1464
+ if (timedOut)
1465
+ return;
1466
+ if (timeoutId !== null) {
1467
+ clearTimeout(timeoutId);
1468
+ timeoutId = null;
1469
+ }
1470
+ onerror(err);
1471
+ };
1472
+ const onsocket = (socket) => {
1473
+ if (timedOut)
1474
+ return;
1475
+ if (timeoutId != null) {
1476
+ clearTimeout(timeoutId);
1477
+ timeoutId = null;
1478
+ }
1479
+ if (isAgent(socket)) {
1480
+ // `socket` is actually an `http.Agent` instance, so
1481
+ // relinquish responsibility for this `req` to the Agent
1482
+ // from here on
1483
+ debug('Callback returned another Agent instance %o', socket.constructor.name);
1484
+ socket.addRequest(req, opts);
1485
+ return;
1486
+ }
1487
+ if (socket) {
1488
+ socket.once('free', () => {
1489
+ this.freeSocket(socket, opts);
1490
+ });
1491
+ req.onSocket(socket);
1492
+ return;
1493
+ }
1494
+ const err = new Error(`no Duplex stream was returned to agent-base for \`${req.method} ${req.path}\``);
1495
+ onerror(err);
1496
+ };
1497
+ if (typeof this.callback !== 'function') {
1498
+ onerror(new Error('`callback` is not defined'));
1499
+ return;
1500
+ }
1501
+ if (!this.promisifiedCallback) {
1502
+ if (this.callback.length >= 3) {
1503
+ debug('Converting legacy callback function to promise');
1504
+ this.promisifiedCallback = promisify_1.default(this.callback);
1505
+ }
1506
+ else {
1507
+ this.promisifiedCallback = this.callback;
1508
+ }
1509
+ }
1510
+ if (typeof timeoutMs === 'number' && timeoutMs > 0) {
1511
+ timeoutId = setTimeout(ontimeout, timeoutMs);
1512
+ }
1513
+ if ('port' in opts && typeof opts.port !== 'number') {
1514
+ opts.port = Number(opts.port);
1515
+ }
1516
+ try {
1517
+ debug('Resolving socket for %o request: %o', opts.protocol, `${req.method} ${req.path}`);
1518
+ Promise.resolve(this.promisifiedCallback(req, opts)).then(onsocket, callbackError);
1519
+ }
1520
+ catch (err) {
1521
+ Promise.reject(err).catch(callbackError);
1522
+ }
1523
+ }
1524
+ freeSocket(socket, opts) {
1525
+ debug('Freeing socket %o %o', socket.constructor.name, opts);
1526
+ socket.destroy();
1527
+ }
1528
+ destroy() {
1529
+ debug('Destroying agent %o', this.constructor.name);
1530
+ }
1531
+ }
1532
+ createAgent.Agent = Agent;
1533
+ // So that `instanceof` works correctly
1534
+ createAgent.prototype = createAgent.Agent.prototype;
1535
+ })(createAgent || (createAgent = {}));
1536
+ src = createAgent;
1537
+
1538
+ return src;
1539
+ }
1540
+
1541
+ var parseProxyResponse = {};
1542
+
1543
+ var hasRequiredParseProxyResponse;
1544
+
1545
+ function requireParseProxyResponse () {
1546
+ if (hasRequiredParseProxyResponse) return parseProxyResponse;
1547
+ hasRequiredParseProxyResponse = 1;
1548
+ var __importDefault = (parseProxyResponse && parseProxyResponse.__importDefault) || function (mod) {
1549
+ return (mod && mod.__esModule) ? mod : { "default": mod };
1550
+ };
1551
+ Object.defineProperty(parseProxyResponse, "__esModule", { value: true });
1552
+ const debug_1 = __importDefault(requireSrc$1());
1553
+ const debug = debug_1.default('https-proxy-agent:parse-proxy-response');
1554
+ function parseProxyResponse$1(socket) {
1555
+ return new Promise((resolve, reject) => {
1556
+ // we need to buffer any HTTP traffic that happens with the proxy before we get
1557
+ // the CONNECT response, so that if the response is anything other than an "200"
1558
+ // response code, then we can re-play the "data" events on the socket once the
1559
+ // HTTP parser is hooked up...
1560
+ let buffersLength = 0;
1561
+ const buffers = [];
1562
+ function read() {
1563
+ const b = socket.read();
1564
+ if (b)
1565
+ ondata(b);
1566
+ else
1567
+ socket.once('readable', read);
1568
+ }
1569
+ function cleanup() {
1570
+ socket.removeListener('end', onend);
1571
+ socket.removeListener('error', onerror);
1572
+ socket.removeListener('close', onclose);
1573
+ socket.removeListener('readable', read);
1574
+ }
1575
+ function onclose(err) {
1576
+ debug('onclose had error %o', err);
1577
+ }
1578
+ function onend() {
1579
+ debug('onend');
1580
+ }
1581
+ function onerror(err) {
1582
+ cleanup();
1583
+ debug('onerror %o', err);
1584
+ reject(err);
1585
+ }
1586
+ function ondata(b) {
1587
+ buffers.push(b);
1588
+ buffersLength += b.length;
1589
+ const buffered = Buffer.concat(buffers, buffersLength);
1590
+ const endOfHeaders = buffered.indexOf('\r\n\r\n');
1591
+ if (endOfHeaders === -1) {
1592
+ // keep buffering
1593
+ debug('have not received end of HTTP headers yet...');
1594
+ read();
1595
+ return;
1596
+ }
1597
+ const firstLine = buffered.toString('ascii', 0, buffered.indexOf('\r\n'));
1598
+ const statusCode = +firstLine.split(' ')[1];
1599
+ debug('got proxy server response: %o', firstLine);
1600
+ resolve({
1601
+ statusCode,
1602
+ buffered
1603
+ });
1604
+ }
1605
+ socket.on('error', onerror);
1606
+ socket.on('close', onclose);
1607
+ socket.on('end', onend);
1608
+ read();
1609
+ });
1610
+ }
1611
+ parseProxyResponse.default = parseProxyResponse$1;
1612
+
1613
+ return parseProxyResponse;
1614
+ }
1615
+
1616
+ var hasRequiredAgent;
1617
+
1618
+ function requireAgent () {
1619
+ if (hasRequiredAgent) return agent;
1620
+ hasRequiredAgent = 1;
1621
+ var __awaiter = (agent && agent.__awaiter) || function (thisArg, _arguments, P, generator) {
1622
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
1623
+ return new (P || (P = Promise))(function (resolve, reject) {
1624
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
1625
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
1626
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
1627
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
1628
+ });
1629
+ };
1630
+ var __importDefault = (agent && agent.__importDefault) || function (mod) {
1631
+ return (mod && mod.__esModule) ? mod : { "default": mod };
1632
+ };
1633
+ Object.defineProperty(agent, "__esModule", { value: true });
1634
+ const net_1 = __importDefault(require$$0$1);
1635
+ const tls_1 = __importDefault(require$$1$2);
1636
+ const url_1 = __importDefault(require$$2);
1637
+ const assert_1 = __importDefault(require$$3);
1638
+ const debug_1 = __importDefault(requireSrc$1());
1639
+ const agent_base_1 = requireSrc();
1640
+ const parse_proxy_response_1 = __importDefault(requireParseProxyResponse());
1641
+ const debug = debug_1.default('https-proxy-agent:agent');
1642
+ /**
1643
+ * The `HttpsProxyAgent` implements an HTTP Agent subclass that connects to
1644
+ * the specified "HTTP(s) proxy server" in order to proxy HTTPS requests.
1645
+ *
1646
+ * Outgoing HTTP requests are first tunneled through the proxy server using the
1647
+ * `CONNECT` HTTP request method to establish a connection to the proxy server,
1648
+ * and then the proxy server connects to the destination target and issues the
1649
+ * HTTP request from the proxy server.
1650
+ *
1651
+ * `https:` requests have their socket connection upgraded to TLS once
1652
+ * the connection to the proxy server has been established.
1653
+ *
1654
+ * @api public
1655
+ */
1656
+ class HttpsProxyAgent extends agent_base_1.Agent {
1657
+ constructor(_opts) {
1658
+ let opts;
1659
+ if (typeof _opts === 'string') {
1660
+ opts = url_1.default.parse(_opts);
1661
+ }
1662
+ else {
1663
+ opts = _opts;
1664
+ }
1665
+ if (!opts) {
1666
+ throw new Error('an HTTP(S) proxy server `host` and `port` must be specified!');
1667
+ }
1668
+ debug('creating new HttpsProxyAgent instance: %o', opts);
1669
+ super(opts);
1670
+ const proxy = Object.assign({}, opts);
1671
+ // If `true`, then connect to the proxy server over TLS.
1672
+ // Defaults to `false`.
1673
+ this.secureProxy = opts.secureProxy || isHTTPS(proxy.protocol);
1674
+ // Prefer `hostname` over `host`, and set the `port` if needed.
1675
+ proxy.host = proxy.hostname || proxy.host;
1676
+ if (typeof proxy.port === 'string') {
1677
+ proxy.port = parseInt(proxy.port, 10);
1678
+ }
1679
+ if (!proxy.port && proxy.host) {
1680
+ proxy.port = this.secureProxy ? 443 : 80;
1681
+ }
1682
+ // ALPN is supported by Node.js >= v5.
1683
+ // attempt to negotiate http/1.1 for proxy servers that support http/2
1684
+ if (this.secureProxy && !('ALPNProtocols' in proxy)) {
1685
+ proxy.ALPNProtocols = ['http 1.1'];
1686
+ }
1687
+ if (proxy.host && proxy.path) {
1688
+ // If both a `host` and `path` are specified then it's most likely
1689
+ // the result of a `url.parse()` call... we need to remove the
1690
+ // `path` portion so that `net.connect()` doesn't attempt to open
1691
+ // that as a Unix socket file.
1692
+ delete proxy.path;
1693
+ delete proxy.pathname;
1694
+ }
1695
+ this.proxy = proxy;
1696
+ }
1697
+ /**
1698
+ * Called when the node-core HTTP client library is creating a
1699
+ * new HTTP request.
1700
+ *
1701
+ * @api protected
1702
+ */
1703
+ callback(req, opts) {
1704
+ return __awaiter(this, void 0, void 0, function* () {
1705
+ const { proxy, secureProxy } = this;
1706
+ // Create a socket connection to the proxy server.
1707
+ let socket;
1708
+ if (secureProxy) {
1709
+ debug('Creating `tls.Socket`: %o', proxy);
1710
+ socket = tls_1.default.connect(proxy);
1711
+ }
1712
+ else {
1713
+ debug('Creating `net.Socket`: %o', proxy);
1714
+ socket = net_1.default.connect(proxy);
1715
+ }
1716
+ const headers = Object.assign({}, proxy.headers);
1717
+ const hostname = `${opts.host}:${opts.port}`;
1718
+ let payload = `CONNECT ${hostname} HTTP/1.1\r\n`;
1719
+ // Inject the `Proxy-Authorization` header if necessary.
1720
+ if (proxy.auth) {
1721
+ headers['Proxy-Authorization'] = `Basic ${Buffer.from(proxy.auth).toString('base64')}`;
1722
+ }
1723
+ // The `Host` header should only include the port
1724
+ // number when it is not the default port.
1725
+ let { host, port, secureEndpoint } = opts;
1726
+ if (!isDefaultPort(port, secureEndpoint)) {
1727
+ host += `:${port}`;
1728
+ }
1729
+ headers.Host = host;
1730
+ headers.Connection = 'close';
1731
+ for (const name of Object.keys(headers)) {
1732
+ payload += `${name}: ${headers[name]}\r\n`;
1733
+ }
1734
+ const proxyResponsePromise = parse_proxy_response_1.default(socket);
1735
+ socket.write(`${payload}\r\n`);
1736
+ const { statusCode, buffered } = yield proxyResponsePromise;
1737
+ if (statusCode === 200) {
1738
+ req.once('socket', resume);
1739
+ if (opts.secureEndpoint) {
1740
+ // The proxy is connecting to a TLS server, so upgrade
1741
+ // this socket connection to a TLS connection.
1742
+ debug('Upgrading socket connection to TLS');
1743
+ const servername = opts.servername || opts.host;
1744
+ return tls_1.default.connect(Object.assign(Object.assign({}, omit(opts, 'host', 'hostname', 'path', 'port')), { socket,
1745
+ servername }));
1746
+ }
1747
+ return socket;
1748
+ }
1749
+ // Some other status code that's not 200... need to re-play the HTTP
1750
+ // header "data" events onto the socket once the HTTP machinery is
1751
+ // attached so that the node core `http` can parse and handle the
1752
+ // error status code.
1753
+ // Close the original socket, and a new "fake" socket is returned
1754
+ // instead, so that the proxy doesn't get the HTTP request
1755
+ // written to it (which may contain `Authorization` headers or other
1756
+ // sensitive data).
1757
+ //
1758
+ // See: https://hackerone.com/reports/541502
1759
+ socket.destroy();
1760
+ const fakeSocket = new net_1.default.Socket({ writable: false });
1761
+ fakeSocket.readable = true;
1762
+ // Need to wait for the "socket" event to re-play the "data" events.
1763
+ req.once('socket', (s) => {
1764
+ debug('replaying proxy buffer for failed request');
1765
+ assert_1.default(s.listenerCount('data') > 0);
1766
+ // Replay the "buffered" Buffer onto the fake `socket`, since at
1767
+ // this point the HTTP module machinery has been hooked up for
1768
+ // the user.
1769
+ s.push(buffered);
1770
+ s.push(null);
1771
+ });
1772
+ return fakeSocket;
1773
+ });
1774
+ }
1775
+ }
1776
+ agent.default = HttpsProxyAgent;
1777
+ function resume(socket) {
1778
+ socket.resume();
1779
+ }
1780
+ function isDefaultPort(port, secure) {
1781
+ return Boolean((!secure && port === 80) || (secure && port === 443));
1782
+ }
1783
+ function isHTTPS(protocol) {
1784
+ return typeof protocol === 'string' ? /^https:?$/i.test(protocol) : false;
1785
+ }
1786
+ function omit(obj, ...keys) {
1787
+ const ret = {};
1788
+ let key;
1789
+ for (key in obj) {
1790
+ if (!keys.includes(key)) {
1791
+ ret[key] = obj[key];
1792
+ }
1793
+ }
1794
+ return ret;
1795
+ }
1796
+
1797
+ return agent;
1798
+ }
1799
+
1800
+ var dist;
1801
+ var hasRequiredDist;
1802
+
1803
+ function requireDist () {
1804
+ if (hasRequiredDist) return dist;
1805
+ hasRequiredDist = 1;
1806
+ var __importDefault = (dist && dist.__importDefault) || function (mod) {
1807
+ return (mod && mod.__esModule) ? mod : { "default": mod };
1808
+ };
1809
+ const agent_1 = __importDefault(requireAgent());
1810
+ function createHttpsProxyAgent(opts) {
1811
+ return new agent_1.default(opts);
1812
+ }
1813
+ (function (createHttpsProxyAgent) {
1814
+ createHttpsProxyAgent.HttpsProxyAgent = agent_1.default;
1815
+ createHttpsProxyAgent.prototype = agent_1.default.prototype;
1816
+ })(createHttpsProxyAgent || (createHttpsProxyAgent = {}));
1817
+ dist = createHttpsProxyAgent;
1818
+
1819
+ return dist;
1820
+ }
1821
+
1822
+ var distExports = requireDist();
1823
+
85
1824
  const CONFIG_PATH$1 = process.env.TTMGRC_PATH || path.join(os.homedir(), '.ttmgrc');
86
1825
  const getTTMGRC = () => {
87
1826
  // only check one time
@@ -114,9 +1853,29 @@ const getCurrentUser = () => {
114
1853
  };
115
1854
 
116
1855
  // ppe_dev_tool
1856
+ function getAxiosProxyConfig() {
1857
+ const config = getTTMGRC();
1858
+ const proxyUrl = config?.proxy; // Only use internal config, let axios handle env vars if not set?
1859
+ // User requirement: "内置代理配置".
1860
+ // My logic in previous turn: "Priority: Internal Config > Env Vars".
1861
+ // If I use `https-proxy-agent`, I should probably handle env vars too if I want consistent behavior,
1862
+ // OR just let axios handle env vars if config.proxy is missing.
1863
+ // BUT, if I don't set httpsAgent, axios uses env vars by default.
1864
+ // SO:
1865
+ if (proxyUrl) {
1866
+ // 兼容 http/https 协议
1867
+ return {
1868
+ httpsAgent: new distExports.HttpsProxyAgent(proxyUrl),
1869
+ httpAgent: new distExports.HttpsProxyAgent(proxyUrl),
1870
+ proxy: false,
1871
+ };
1872
+ }
1873
+ return {};
1874
+ }
117
1875
  async function request({ url, method, data, headers, params, }) {
118
1876
  const config = getTTMGRC();
119
1877
  const cookie = config?.cookie;
1878
+ const proxyConfig = getAxiosProxyConfig();
120
1879
  try {
121
1880
  const res = await axios({
122
1881
  url,
@@ -129,6 +1888,7 @@ async function request({ url, method, data, headers, params, }) {
129
1888
  // 'x-tt-env': 'ppe_upgrade_script',
130
1889
  ...(headers || {}),
131
1890
  },
1891
+ ...proxyConfig,
132
1892
  });
133
1893
  // @ts-ignore
134
1894
  return {
@@ -160,11 +1920,13 @@ async function download(url, filePath) {
160
1920
  }
161
1921
  catch { }
162
1922
  }
1923
+ const proxyConfig = getAxiosProxyConfig();
163
1924
  try {
164
1925
  const res = await axios.get(url, {
165
1926
  responseType: 'stream',
166
1927
  // 让非 2xx 进入 catch
167
1928
  validateStatus: s => s >= 200 && s < 300,
1929
+ ...proxyConfig,
168
1930
  });
169
1931
  // 关键:把“流事件”封装为 Promise,并 await 它
170
1932
  await new Promise((resolve, reject) => {
@@ -370,6 +2132,10 @@ const messages = {
370
2132
  'cli.command.init.desc': 'Initialize project',
371
2133
  'cli.command.dev.desc': 'Open browser dev environment',
372
2134
  'cli.command.build.desc': 'Bundle project',
2135
+ 'cli.command.config.desc': 'Manage configuration',
2136
+ 'cli.command.config.set.desc': 'Set a configuration value',
2137
+ 'cli.command.config.get.desc': 'Get a configuration value',
2138
+ 'cli.command.config.delete.desc': 'Delete a configuration value',
373
2139
  'cli.option.h5': 'H5 Mini Game',
374
2140
  'cli.native.init.placeholder': 'Native Mini Game initialize',
375
2141
  'cli.native.build.placeholder': 'Native Mini Game bundle',
@@ -481,6 +2247,10 @@ const messages = {
481
2247
  'cli.command.init.desc': '初始化项目',
482
2248
  'cli.command.dev.desc': '打开浏览器调试环境',
483
2249
  'cli.command.build.desc': '打包项目',
2250
+ 'cli.command.config.desc': '管理配置',
2251
+ 'cli.command.config.set.desc': '设置配置项',
2252
+ 'cli.command.config.get.desc': '获取配置项',
2253
+ 'cli.command.config.delete.desc': '删除配置项',
484
2254
  'cli.option.h5': 'H5 小游戏',
485
2255
  'cli.native.init.placeholder': 'Native 小游戏初始化',
486
2256
  'cli.native.build.placeholder': 'Native 小游戏打包',
@@ -1250,6 +3020,7 @@ const store = Store.getInstance({
1250
3020
  clientKey: '',
1251
3021
  appId: '',
1252
3022
  nodeServerPort: DEV_PORT,
3023
+ nodeHttpPort: DEV_PORT,
1253
3024
  nodeWsPort: DEV_WS_PORT,
1254
3025
  packages: {},
1255
3026
  isUnderCompiling: false,
@@ -2280,6 +4051,7 @@ const gameConfigRoute = {
2280
4051
  data: {
2281
4052
  user,
2282
4053
  code: successCode,
4054
+ nodeServerPort: store.getState().nodeServerPort,
2283
4055
  nodeWsPort: store.getState().nodeWsPort,
2284
4056
  clientKey,
2285
4057
  schema: `https://www.tiktok.com/ttmg/dev/${clientKey}?host=${getLocalIP()}&port=${store.getState().nodeWsPort}&host_list=${encodeURIComponent(JSON.stringify(getLocalIPs()))}`,
@@ -2287,6 +4059,7 @@ const gameConfigRoute = {
2287
4059
  devToolVersion,
2288
4060
  checkResult,
2289
4061
  lang: localLang,
4062
+ nodeStaticBaseUrl: `http://localhost:${store.getState().nodeHttpPort}/game/files`,
2290
4063
  },
2291
4064
  });
2292
4065
  },
@@ -3919,13 +5692,13 @@ async function login(options) {
3919
5692
  }
3920
5693
  }
3921
5694
 
3922
- const supportedLangs = ['en-US', 'zh-CN'];
3923
- function isSupportedLang(lang) {
3924
- return supportedLangs.includes(lang);
5695
+ const supportedLangs$1 = ['en-US', 'zh-CN'];
5696
+ function isSupportedLang$1(lang) {
5697
+ return supportedLangs$1.includes(lang);
3925
5698
  }
3926
5699
  async function setup(options) {
3927
5700
  const inputLang = options?.lang;
3928
- if (inputLang !== undefined && !isSupportedLang(inputLang)) {
5701
+ if (inputLang !== undefined && !isSupportedLang$1(inputLang)) {
3929
5702
  console.error(chalk.red(t('setup.error.unsupportedLang', { lang: inputLang })));
3930
5703
  console.error(chalk.yellow(t('setup.error.availableLangs')));
3931
5704
  console.error(chalk.cyan(t('setup.error.chooseHint')));
@@ -3992,7 +5765,104 @@ async function reset() {
3992
5765
  process.exit(0);
3993
5766
  }
3994
5767
 
3995
- var version = "0.3.2-beta.7";
5768
+ const supportedLangs = ['en-US', 'zh-CN'];
5769
+ function isSupportedLang(lang) {
5770
+ return supportedLangs.includes(lang);
5771
+ }
5772
+ const config = {
5773
+ set: async (key, value) => {
5774
+ if (key === 'lang' && !value) {
5775
+ // 交互式选择语言
5776
+ const { lang } = await inquirer.createPromptModule()([
5777
+ {
5778
+ type: 'list',
5779
+ name: 'lang',
5780
+ message: t('setup.prompt.selectLanguage') || 'Select your preferred language',
5781
+ choices: [
5782
+ { name: t('setup.choice.en') || 'English (en-US)', value: 'en-US' },
5783
+ { name: t('setup.choice.zh') || '简体中文 (zh-CN)', value: 'zh-CN' },
5784
+ ],
5785
+ default: 'en-US',
5786
+ },
5787
+ ]);
5788
+ value = lang;
5789
+ }
5790
+ const oraModule = await import('ora');
5791
+ const ora = (oraModule.default || oraModule);
5792
+ const spinner = ora(`Setting ${key}...`).start();
5793
+ try {
5794
+ if (!value) {
5795
+ spinner.fail(chalk.red(`Value is required for config key: ${key}`));
5796
+ process.exit(1);
5797
+ }
5798
+ if (key === 'proxy') {
5799
+ setTTMGRC({ proxy: value });
5800
+ spinner.succeed(chalk.green(`Set proxy to ${value}`));
5801
+ }
5802
+ else if (key === 'lang') {
5803
+ if (!isSupportedLang(value)) {
5804
+ spinner.fail(chalk.red(`Unsupported language: ${value}. Supported languages: ${supportedLangs.join(', ')}.`));
5805
+ }
5806
+ else {
5807
+ setTTMGRC({ lang: value });
5808
+ spinner.succeed(chalk.green(`Set lang to ${value}`));
5809
+ }
5810
+ }
5811
+ else {
5812
+ spinner.fail(chalk.red(`Unknown config key: ${key}`));
5813
+ }
5814
+ }
5815
+ catch (e) {
5816
+ spinner.fail(chalk.red(`Failed to set config: ${e.message}`));
5817
+ }
5818
+ process.exit(0);
5819
+ },
5820
+ get: async (key) => {
5821
+ const oraModule = await import('ora');
5822
+ const ora = (oraModule.default || oraModule);
5823
+ const spinner = ora(`Getting ${key}...`).start();
5824
+ try {
5825
+ const rc = getTTMGRC();
5826
+ if (key === 'proxy') {
5827
+ spinner.succeed(chalk.green(`proxy=${rc?.proxy || ''}`));
5828
+ }
5829
+ else if (key === 'lang') {
5830
+ spinner.succeed(chalk.green(`lang=${rc?.lang || ''}`));
5831
+ }
5832
+ else {
5833
+ spinner.fail(chalk.red(`Unknown config key: ${key}`));
5834
+ }
5835
+ }
5836
+ catch (e) {
5837
+ spinner.fail(chalk.red(`Failed to get config: ${e.message}`));
5838
+ }
5839
+ process.exit(0);
5840
+ },
5841
+ delete: async (key) => {
5842
+ const oraModule = await import('ora');
5843
+ const ora = (oraModule.default || oraModule);
5844
+ const spinner = ora(`Deleting ${key}...`).start();
5845
+ try {
5846
+ if (key === 'proxy') {
5847
+ setTTMGRC({ proxy: undefined });
5848
+ spinner.succeed(chalk.green(`Deleted proxy config`));
5849
+ }
5850
+ else if (key === 'lang') {
5851
+ setTTMGRC({ lang: undefined });
5852
+ spinner.succeed(chalk.green(`Deleted lang config`));
5853
+ }
5854
+ else {
5855
+ spinner.fail(chalk.red(`Unknown config key: ${key}`));
5856
+ }
5857
+ }
5858
+ catch (e) {
5859
+ spinner.fail(chalk.red(`Failed to delete config: ${e.message}`));
5860
+ }
5861
+ process.exit(0);
5862
+ }
5863
+ };
5864
+
5865
+ var version = "0.3.2-beta.8";
3996
5866
  var pkg = {
3997
5867
  version: version};
3998
5868
 
@@ -4024,6 +5894,27 @@ program
4024
5894
  .action(async () => {
4025
5895
  await reset();
4026
5896
  });
5897
+ const configCmd = program
5898
+ .command('config')
5899
+ .description(t('cli.command.config.desc'));
5900
+ configCmd
5901
+ .command('set <key> [value]')
5902
+ .description(t('cli.command.config.set.desc'))
5903
+ .action(async (key, value) => {
5904
+ await config.set(key, value);
5905
+ });
5906
+ configCmd
5907
+ .command('get <key>')
5908
+ .description(t('cli.command.config.get.desc'))
5909
+ .action(async (key) => {
5910
+ await config.get(key);
5911
+ });
5912
+ configCmd
5913
+ .command('delete <key>')
5914
+ .description(t('cli.command.config.delete.desc'))
5915
+ .action(async (key) => {
5916
+ await config.delete(key);
5917
+ });
4027
5918
  program
4028
5919
  .option('--h5', t('cli.option.h5'))
4029
5920
  .command('init')