node-consul-service 1.0.74 → 1.0.76
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/consul/atlasDiscovery.d.ts +5 -0
- package/dist/consul/client.d.ts +0 -2
- package/dist/consul/registry.d.ts +0 -9
- package/dist/consul/types.d.ts +6 -0
- package/dist/index.cjs.js +29 -1278
- package/dist/index.d.ts +1 -1
- package/dist/index.esm.js +30 -1277
- package/dist/utils/logger.d.ts +2 -2
- package/package.json +1 -1
package/dist/index.esm.js
CHANGED
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import Consul from 'consul';
|
|
2
1
|
import require$$1 from 'util';
|
|
3
2
|
import stream, { Readable } from 'stream';
|
|
4
3
|
import path from 'path';
|
|
@@ -8,8 +7,6 @@ import require$$0$1 from 'url';
|
|
|
8
7
|
import require$$6, { promises } from 'fs';
|
|
9
8
|
import crypto from 'crypto';
|
|
10
9
|
import require$$4$1 from 'assert';
|
|
11
|
-
import require$$1$1 from 'tty';
|
|
12
|
-
import require$$0$2 from 'os';
|
|
13
10
|
import zlib from 'zlib';
|
|
14
11
|
import { EventEmitter } from 'events';
|
|
15
12
|
|
|
@@ -15536,1196 +15533,6 @@ var proxyFromEnv = /*@__PURE__*/getDefaultExportFromCjs(proxyFromEnvExports);
|
|
|
15536
15533
|
|
|
15537
15534
|
var followRedirects$1 = {exports: {}};
|
|
15538
15535
|
|
|
15539
|
-
var src = {exports: {}};
|
|
15540
|
-
|
|
15541
|
-
var browser = {exports: {}};
|
|
15542
|
-
|
|
15543
|
-
/**
|
|
15544
|
-
* Helpers.
|
|
15545
|
-
*/
|
|
15546
|
-
|
|
15547
|
-
var ms;
|
|
15548
|
-
var hasRequiredMs;
|
|
15549
|
-
|
|
15550
|
-
function requireMs () {
|
|
15551
|
-
if (hasRequiredMs) return ms;
|
|
15552
|
-
hasRequiredMs = 1;
|
|
15553
|
-
var s = 1000;
|
|
15554
|
-
var m = s * 60;
|
|
15555
|
-
var h = m * 60;
|
|
15556
|
-
var d = h * 24;
|
|
15557
|
-
var w = d * 7;
|
|
15558
|
-
var y = d * 365.25;
|
|
15559
|
-
|
|
15560
|
-
/**
|
|
15561
|
-
* Parse or format the given `val`.
|
|
15562
|
-
*
|
|
15563
|
-
* Options:
|
|
15564
|
-
*
|
|
15565
|
-
* - `long` verbose formatting [false]
|
|
15566
|
-
*
|
|
15567
|
-
* @param {String|Number} val
|
|
15568
|
-
* @param {Object} [options]
|
|
15569
|
-
* @throws {Error} throw an error if val is not a non-empty string or a number
|
|
15570
|
-
* @return {String|Number}
|
|
15571
|
-
* @api public
|
|
15572
|
-
*/
|
|
15573
|
-
|
|
15574
|
-
ms = function (val, options) {
|
|
15575
|
-
options = options || {};
|
|
15576
|
-
var type = typeof val;
|
|
15577
|
-
if (type === 'string' && val.length > 0) {
|
|
15578
|
-
return parse(val);
|
|
15579
|
-
} else if (type === 'number' && isFinite(val)) {
|
|
15580
|
-
return options.long ? fmtLong(val) : fmtShort(val);
|
|
15581
|
-
}
|
|
15582
|
-
throw new Error(
|
|
15583
|
-
'val is not a non-empty string or a valid number. val=' +
|
|
15584
|
-
JSON.stringify(val)
|
|
15585
|
-
);
|
|
15586
|
-
};
|
|
15587
|
-
|
|
15588
|
-
/**
|
|
15589
|
-
* Parse the given `str` and return milliseconds.
|
|
15590
|
-
*
|
|
15591
|
-
* @param {String} str
|
|
15592
|
-
* @return {Number}
|
|
15593
|
-
* @api private
|
|
15594
|
-
*/
|
|
15595
|
-
|
|
15596
|
-
function parse(str) {
|
|
15597
|
-
str = String(str);
|
|
15598
|
-
if (str.length > 100) {
|
|
15599
|
-
return;
|
|
15600
|
-
}
|
|
15601
|
-
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(
|
|
15602
|
-
str
|
|
15603
|
-
);
|
|
15604
|
-
if (!match) {
|
|
15605
|
-
return;
|
|
15606
|
-
}
|
|
15607
|
-
var n = parseFloat(match[1]);
|
|
15608
|
-
var type = (match[2] || 'ms').toLowerCase();
|
|
15609
|
-
switch (type) {
|
|
15610
|
-
case 'years':
|
|
15611
|
-
case 'year':
|
|
15612
|
-
case 'yrs':
|
|
15613
|
-
case 'yr':
|
|
15614
|
-
case 'y':
|
|
15615
|
-
return n * y;
|
|
15616
|
-
case 'weeks':
|
|
15617
|
-
case 'week':
|
|
15618
|
-
case 'w':
|
|
15619
|
-
return n * w;
|
|
15620
|
-
case 'days':
|
|
15621
|
-
case 'day':
|
|
15622
|
-
case 'd':
|
|
15623
|
-
return n * d;
|
|
15624
|
-
case 'hours':
|
|
15625
|
-
case 'hour':
|
|
15626
|
-
case 'hrs':
|
|
15627
|
-
case 'hr':
|
|
15628
|
-
case 'h':
|
|
15629
|
-
return n * h;
|
|
15630
|
-
case 'minutes':
|
|
15631
|
-
case 'minute':
|
|
15632
|
-
case 'mins':
|
|
15633
|
-
case 'min':
|
|
15634
|
-
case 'm':
|
|
15635
|
-
return n * m;
|
|
15636
|
-
case 'seconds':
|
|
15637
|
-
case 'second':
|
|
15638
|
-
case 'secs':
|
|
15639
|
-
case 'sec':
|
|
15640
|
-
case 's':
|
|
15641
|
-
return n * s;
|
|
15642
|
-
case 'milliseconds':
|
|
15643
|
-
case 'millisecond':
|
|
15644
|
-
case 'msecs':
|
|
15645
|
-
case 'msec':
|
|
15646
|
-
case 'ms':
|
|
15647
|
-
return n;
|
|
15648
|
-
default:
|
|
15649
|
-
return undefined;
|
|
15650
|
-
}
|
|
15651
|
-
}
|
|
15652
|
-
|
|
15653
|
-
/**
|
|
15654
|
-
* Short format for `ms`.
|
|
15655
|
-
*
|
|
15656
|
-
* @param {Number} ms
|
|
15657
|
-
* @return {String}
|
|
15658
|
-
* @api private
|
|
15659
|
-
*/
|
|
15660
|
-
|
|
15661
|
-
function fmtShort(ms) {
|
|
15662
|
-
var msAbs = Math.abs(ms);
|
|
15663
|
-
if (msAbs >= d) {
|
|
15664
|
-
return Math.round(ms / d) + 'd';
|
|
15665
|
-
}
|
|
15666
|
-
if (msAbs >= h) {
|
|
15667
|
-
return Math.round(ms / h) + 'h';
|
|
15668
|
-
}
|
|
15669
|
-
if (msAbs >= m) {
|
|
15670
|
-
return Math.round(ms / m) + 'm';
|
|
15671
|
-
}
|
|
15672
|
-
if (msAbs >= s) {
|
|
15673
|
-
return Math.round(ms / s) + 's';
|
|
15674
|
-
}
|
|
15675
|
-
return ms + 'ms';
|
|
15676
|
-
}
|
|
15677
|
-
|
|
15678
|
-
/**
|
|
15679
|
-
* Long format for `ms`.
|
|
15680
|
-
*
|
|
15681
|
-
* @param {Number} ms
|
|
15682
|
-
* @return {String}
|
|
15683
|
-
* @api private
|
|
15684
|
-
*/
|
|
15685
|
-
|
|
15686
|
-
function fmtLong(ms) {
|
|
15687
|
-
var msAbs = Math.abs(ms);
|
|
15688
|
-
if (msAbs >= d) {
|
|
15689
|
-
return plural(ms, msAbs, d, 'day');
|
|
15690
|
-
}
|
|
15691
|
-
if (msAbs >= h) {
|
|
15692
|
-
return plural(ms, msAbs, h, 'hour');
|
|
15693
|
-
}
|
|
15694
|
-
if (msAbs >= m) {
|
|
15695
|
-
return plural(ms, msAbs, m, 'minute');
|
|
15696
|
-
}
|
|
15697
|
-
if (msAbs >= s) {
|
|
15698
|
-
return plural(ms, msAbs, s, 'second');
|
|
15699
|
-
}
|
|
15700
|
-
return ms + ' ms';
|
|
15701
|
-
}
|
|
15702
|
-
|
|
15703
|
-
/**
|
|
15704
|
-
* Pluralization helper.
|
|
15705
|
-
*/
|
|
15706
|
-
|
|
15707
|
-
function plural(ms, msAbs, n, name) {
|
|
15708
|
-
var isPlural = msAbs >= n * 1.5;
|
|
15709
|
-
return Math.round(ms / n) + ' ' + name + (isPlural ? 's' : '');
|
|
15710
|
-
}
|
|
15711
|
-
return ms;
|
|
15712
|
-
}
|
|
15713
|
-
|
|
15714
|
-
var common;
|
|
15715
|
-
var hasRequiredCommon;
|
|
15716
|
-
|
|
15717
|
-
function requireCommon () {
|
|
15718
|
-
if (hasRequiredCommon) return common;
|
|
15719
|
-
hasRequiredCommon = 1;
|
|
15720
|
-
/**
|
|
15721
|
-
* This is the common logic for both the Node.js and web browser
|
|
15722
|
-
* implementations of `debug()`.
|
|
15723
|
-
*/
|
|
15724
|
-
|
|
15725
|
-
function setup(env) {
|
|
15726
|
-
createDebug.debug = createDebug;
|
|
15727
|
-
createDebug.default = createDebug;
|
|
15728
|
-
createDebug.coerce = coerce;
|
|
15729
|
-
createDebug.disable = disable;
|
|
15730
|
-
createDebug.enable = enable;
|
|
15731
|
-
createDebug.enabled = enabled;
|
|
15732
|
-
createDebug.humanize = requireMs();
|
|
15733
|
-
createDebug.destroy = destroy;
|
|
15734
|
-
|
|
15735
|
-
Object.keys(env).forEach(key => {
|
|
15736
|
-
createDebug[key] = env[key];
|
|
15737
|
-
});
|
|
15738
|
-
|
|
15739
|
-
/**
|
|
15740
|
-
* The currently active debug mode names, and names to skip.
|
|
15741
|
-
*/
|
|
15742
|
-
|
|
15743
|
-
createDebug.names = [];
|
|
15744
|
-
createDebug.skips = [];
|
|
15745
|
-
|
|
15746
|
-
/**
|
|
15747
|
-
* Map of special "%n" handling functions, for the debug "format" argument.
|
|
15748
|
-
*
|
|
15749
|
-
* Valid key names are a single, lower or upper-case letter, i.e. "n" and "N".
|
|
15750
|
-
*/
|
|
15751
|
-
createDebug.formatters = {};
|
|
15752
|
-
|
|
15753
|
-
/**
|
|
15754
|
-
* Selects a color for a debug namespace
|
|
15755
|
-
* @param {String} namespace The namespace string for the debug instance to be colored
|
|
15756
|
-
* @return {Number|String} An ANSI color code for the given namespace
|
|
15757
|
-
* @api private
|
|
15758
|
-
*/
|
|
15759
|
-
function selectColor(namespace) {
|
|
15760
|
-
let hash = 0;
|
|
15761
|
-
|
|
15762
|
-
for (let i = 0; i < namespace.length; i++) {
|
|
15763
|
-
hash = ((hash << 5) - hash) + namespace.charCodeAt(i);
|
|
15764
|
-
hash |= 0; // Convert to 32bit integer
|
|
15765
|
-
}
|
|
15766
|
-
|
|
15767
|
-
return createDebug.colors[Math.abs(hash) % createDebug.colors.length];
|
|
15768
|
-
}
|
|
15769
|
-
createDebug.selectColor = selectColor;
|
|
15770
|
-
|
|
15771
|
-
/**
|
|
15772
|
-
* Create a debugger with the given `namespace`.
|
|
15773
|
-
*
|
|
15774
|
-
* @param {String} namespace
|
|
15775
|
-
* @return {Function}
|
|
15776
|
-
* @api public
|
|
15777
|
-
*/
|
|
15778
|
-
function createDebug(namespace) {
|
|
15779
|
-
let prevTime;
|
|
15780
|
-
let enableOverride = null;
|
|
15781
|
-
let namespacesCache;
|
|
15782
|
-
let enabledCache;
|
|
15783
|
-
|
|
15784
|
-
function debug(...args) {
|
|
15785
|
-
// Disabled?
|
|
15786
|
-
if (!debug.enabled) {
|
|
15787
|
-
return;
|
|
15788
|
-
}
|
|
15789
|
-
|
|
15790
|
-
const self = debug;
|
|
15791
|
-
|
|
15792
|
-
// Set `diff` timestamp
|
|
15793
|
-
const curr = Number(new Date());
|
|
15794
|
-
const ms = curr - (prevTime || curr);
|
|
15795
|
-
self.diff = ms;
|
|
15796
|
-
self.prev = prevTime;
|
|
15797
|
-
self.curr = curr;
|
|
15798
|
-
prevTime = curr;
|
|
15799
|
-
|
|
15800
|
-
args[0] = createDebug.coerce(args[0]);
|
|
15801
|
-
|
|
15802
|
-
if (typeof args[0] !== 'string') {
|
|
15803
|
-
// Anything else let's inspect with %O
|
|
15804
|
-
args.unshift('%O');
|
|
15805
|
-
}
|
|
15806
|
-
|
|
15807
|
-
// Apply any `formatters` transformations
|
|
15808
|
-
let index = 0;
|
|
15809
|
-
args[0] = args[0].replace(/%([a-zA-Z%])/g, (match, format) => {
|
|
15810
|
-
// If we encounter an escaped % then don't increase the array index
|
|
15811
|
-
if (match === '%%') {
|
|
15812
|
-
return '%';
|
|
15813
|
-
}
|
|
15814
|
-
index++;
|
|
15815
|
-
const formatter = createDebug.formatters[format];
|
|
15816
|
-
if (typeof formatter === 'function') {
|
|
15817
|
-
const val = args[index];
|
|
15818
|
-
match = formatter.call(self, val);
|
|
15819
|
-
|
|
15820
|
-
// Now we need to remove `args[index]` since it's inlined in the `format`
|
|
15821
|
-
args.splice(index, 1);
|
|
15822
|
-
index--;
|
|
15823
|
-
}
|
|
15824
|
-
return match;
|
|
15825
|
-
});
|
|
15826
|
-
|
|
15827
|
-
// Apply env-specific formatting (colors, etc.)
|
|
15828
|
-
createDebug.formatArgs.call(self, args);
|
|
15829
|
-
|
|
15830
|
-
const logFn = self.log || createDebug.log;
|
|
15831
|
-
logFn.apply(self, args);
|
|
15832
|
-
}
|
|
15833
|
-
|
|
15834
|
-
debug.namespace = namespace;
|
|
15835
|
-
debug.useColors = createDebug.useColors();
|
|
15836
|
-
debug.color = createDebug.selectColor(namespace);
|
|
15837
|
-
debug.extend = extend;
|
|
15838
|
-
debug.destroy = createDebug.destroy; // XXX Temporary. Will be removed in the next major release.
|
|
15839
|
-
|
|
15840
|
-
Object.defineProperty(debug, 'enabled', {
|
|
15841
|
-
enumerable: true,
|
|
15842
|
-
configurable: false,
|
|
15843
|
-
get: () => {
|
|
15844
|
-
if (enableOverride !== null) {
|
|
15845
|
-
return enableOverride;
|
|
15846
|
-
}
|
|
15847
|
-
if (namespacesCache !== createDebug.namespaces) {
|
|
15848
|
-
namespacesCache = createDebug.namespaces;
|
|
15849
|
-
enabledCache = createDebug.enabled(namespace);
|
|
15850
|
-
}
|
|
15851
|
-
|
|
15852
|
-
return enabledCache;
|
|
15853
|
-
},
|
|
15854
|
-
set: v => {
|
|
15855
|
-
enableOverride = v;
|
|
15856
|
-
}
|
|
15857
|
-
});
|
|
15858
|
-
|
|
15859
|
-
// Env-specific initialization logic for debug instances
|
|
15860
|
-
if (typeof createDebug.init === 'function') {
|
|
15861
|
-
createDebug.init(debug);
|
|
15862
|
-
}
|
|
15863
|
-
|
|
15864
|
-
return debug;
|
|
15865
|
-
}
|
|
15866
|
-
|
|
15867
|
-
function extend(namespace, delimiter) {
|
|
15868
|
-
const newDebug = createDebug(this.namespace + (typeof delimiter === 'undefined' ? ':' : delimiter) + namespace);
|
|
15869
|
-
newDebug.log = this.log;
|
|
15870
|
-
return newDebug;
|
|
15871
|
-
}
|
|
15872
|
-
|
|
15873
|
-
/**
|
|
15874
|
-
* Enables a debug mode by namespaces. This can include modes
|
|
15875
|
-
* separated by a colon and wildcards.
|
|
15876
|
-
*
|
|
15877
|
-
* @param {String} namespaces
|
|
15878
|
-
* @api public
|
|
15879
|
-
*/
|
|
15880
|
-
function enable(namespaces) {
|
|
15881
|
-
createDebug.save(namespaces);
|
|
15882
|
-
createDebug.namespaces = namespaces;
|
|
15883
|
-
|
|
15884
|
-
createDebug.names = [];
|
|
15885
|
-
createDebug.skips = [];
|
|
15886
|
-
|
|
15887
|
-
let i;
|
|
15888
|
-
const split = (typeof namespaces === 'string' ? namespaces : '').split(/[\s,]+/);
|
|
15889
|
-
const len = split.length;
|
|
15890
|
-
|
|
15891
|
-
for (i = 0; i < len; i++) {
|
|
15892
|
-
if (!split[i]) {
|
|
15893
|
-
// ignore empty strings
|
|
15894
|
-
continue;
|
|
15895
|
-
}
|
|
15896
|
-
|
|
15897
|
-
namespaces = split[i].replace(/\*/g, '.*?');
|
|
15898
|
-
|
|
15899
|
-
if (namespaces[0] === '-') {
|
|
15900
|
-
createDebug.skips.push(new RegExp('^' + namespaces.slice(1) + '$'));
|
|
15901
|
-
} else {
|
|
15902
|
-
createDebug.names.push(new RegExp('^' + namespaces + '$'));
|
|
15903
|
-
}
|
|
15904
|
-
}
|
|
15905
|
-
}
|
|
15906
|
-
|
|
15907
|
-
/**
|
|
15908
|
-
* Disable debug output.
|
|
15909
|
-
*
|
|
15910
|
-
* @return {String} namespaces
|
|
15911
|
-
* @api public
|
|
15912
|
-
*/
|
|
15913
|
-
function disable() {
|
|
15914
|
-
const namespaces = [
|
|
15915
|
-
...createDebug.names.map(toNamespace),
|
|
15916
|
-
...createDebug.skips.map(toNamespace).map(namespace => '-' + namespace)
|
|
15917
|
-
].join(',');
|
|
15918
|
-
createDebug.enable('');
|
|
15919
|
-
return namespaces;
|
|
15920
|
-
}
|
|
15921
|
-
|
|
15922
|
-
/**
|
|
15923
|
-
* Returns true if the given mode name is enabled, false otherwise.
|
|
15924
|
-
*
|
|
15925
|
-
* @param {String} name
|
|
15926
|
-
* @return {Boolean}
|
|
15927
|
-
* @api public
|
|
15928
|
-
*/
|
|
15929
|
-
function enabled(name) {
|
|
15930
|
-
if (name[name.length - 1] === '*') {
|
|
15931
|
-
return true;
|
|
15932
|
-
}
|
|
15933
|
-
|
|
15934
|
-
let i;
|
|
15935
|
-
let len;
|
|
15936
|
-
|
|
15937
|
-
for (i = 0, len = createDebug.skips.length; i < len; i++) {
|
|
15938
|
-
if (createDebug.skips[i].test(name)) {
|
|
15939
|
-
return false;
|
|
15940
|
-
}
|
|
15941
|
-
}
|
|
15942
|
-
|
|
15943
|
-
for (i = 0, len = createDebug.names.length; i < len; i++) {
|
|
15944
|
-
if (createDebug.names[i].test(name)) {
|
|
15945
|
-
return true;
|
|
15946
|
-
}
|
|
15947
|
-
}
|
|
15948
|
-
|
|
15949
|
-
return false;
|
|
15950
|
-
}
|
|
15951
|
-
|
|
15952
|
-
/**
|
|
15953
|
-
* Convert regexp to namespace
|
|
15954
|
-
*
|
|
15955
|
-
* @param {RegExp} regxep
|
|
15956
|
-
* @return {String} namespace
|
|
15957
|
-
* @api private
|
|
15958
|
-
*/
|
|
15959
|
-
function toNamespace(regexp) {
|
|
15960
|
-
return regexp.toString()
|
|
15961
|
-
.substring(2, regexp.toString().length - 2)
|
|
15962
|
-
.replace(/\.\*\?$/, '*');
|
|
15963
|
-
}
|
|
15964
|
-
|
|
15965
|
-
/**
|
|
15966
|
-
* Coerce `val`.
|
|
15967
|
-
*
|
|
15968
|
-
* @param {Mixed} val
|
|
15969
|
-
* @return {Mixed}
|
|
15970
|
-
* @api private
|
|
15971
|
-
*/
|
|
15972
|
-
function coerce(val) {
|
|
15973
|
-
if (val instanceof Error) {
|
|
15974
|
-
return val.stack || val.message;
|
|
15975
|
-
}
|
|
15976
|
-
return val;
|
|
15977
|
-
}
|
|
15978
|
-
|
|
15979
|
-
/**
|
|
15980
|
-
* XXX DO NOT USE. This is a temporary stub function.
|
|
15981
|
-
* XXX It WILL be removed in the next major release.
|
|
15982
|
-
*/
|
|
15983
|
-
function destroy() {
|
|
15984
|
-
console.warn('Instance method `debug.destroy()` is deprecated and no longer does anything. It will be removed in the next major version of `debug`.');
|
|
15985
|
-
}
|
|
15986
|
-
|
|
15987
|
-
createDebug.enable(createDebug.load());
|
|
15988
|
-
|
|
15989
|
-
return createDebug;
|
|
15990
|
-
}
|
|
15991
|
-
|
|
15992
|
-
common = setup;
|
|
15993
|
-
return common;
|
|
15994
|
-
}
|
|
15995
|
-
|
|
15996
|
-
/* eslint-env browser */
|
|
15997
|
-
|
|
15998
|
-
var hasRequiredBrowser;
|
|
15999
|
-
|
|
16000
|
-
function requireBrowser () {
|
|
16001
|
-
if (hasRequiredBrowser) return browser.exports;
|
|
16002
|
-
hasRequiredBrowser = 1;
|
|
16003
|
-
(function (module, exports) {
|
|
16004
|
-
/**
|
|
16005
|
-
* This is the web browser implementation of `debug()`.
|
|
16006
|
-
*/
|
|
16007
|
-
|
|
16008
|
-
exports.formatArgs = formatArgs;
|
|
16009
|
-
exports.save = save;
|
|
16010
|
-
exports.load = load;
|
|
16011
|
-
exports.useColors = useColors;
|
|
16012
|
-
exports.storage = localstorage();
|
|
16013
|
-
exports.destroy = (() => {
|
|
16014
|
-
let warned = false;
|
|
16015
|
-
|
|
16016
|
-
return () => {
|
|
16017
|
-
if (!warned) {
|
|
16018
|
-
warned = true;
|
|
16019
|
-
console.warn('Instance method `debug.destroy()` is deprecated and no longer does anything. It will be removed in the next major version of `debug`.');
|
|
16020
|
-
}
|
|
16021
|
-
};
|
|
16022
|
-
})();
|
|
16023
|
-
|
|
16024
|
-
/**
|
|
16025
|
-
* Colors.
|
|
16026
|
-
*/
|
|
16027
|
-
|
|
16028
|
-
exports.colors = [
|
|
16029
|
-
'#0000CC',
|
|
16030
|
-
'#0000FF',
|
|
16031
|
-
'#0033CC',
|
|
16032
|
-
'#0033FF',
|
|
16033
|
-
'#0066CC',
|
|
16034
|
-
'#0066FF',
|
|
16035
|
-
'#0099CC',
|
|
16036
|
-
'#0099FF',
|
|
16037
|
-
'#00CC00',
|
|
16038
|
-
'#00CC33',
|
|
16039
|
-
'#00CC66',
|
|
16040
|
-
'#00CC99',
|
|
16041
|
-
'#00CCCC',
|
|
16042
|
-
'#00CCFF',
|
|
16043
|
-
'#3300CC',
|
|
16044
|
-
'#3300FF',
|
|
16045
|
-
'#3333CC',
|
|
16046
|
-
'#3333FF',
|
|
16047
|
-
'#3366CC',
|
|
16048
|
-
'#3366FF',
|
|
16049
|
-
'#3399CC',
|
|
16050
|
-
'#3399FF',
|
|
16051
|
-
'#33CC00',
|
|
16052
|
-
'#33CC33',
|
|
16053
|
-
'#33CC66',
|
|
16054
|
-
'#33CC99',
|
|
16055
|
-
'#33CCCC',
|
|
16056
|
-
'#33CCFF',
|
|
16057
|
-
'#6600CC',
|
|
16058
|
-
'#6600FF',
|
|
16059
|
-
'#6633CC',
|
|
16060
|
-
'#6633FF',
|
|
16061
|
-
'#66CC00',
|
|
16062
|
-
'#66CC33',
|
|
16063
|
-
'#9900CC',
|
|
16064
|
-
'#9900FF',
|
|
16065
|
-
'#9933CC',
|
|
16066
|
-
'#9933FF',
|
|
16067
|
-
'#99CC00',
|
|
16068
|
-
'#99CC33',
|
|
16069
|
-
'#CC0000',
|
|
16070
|
-
'#CC0033',
|
|
16071
|
-
'#CC0066',
|
|
16072
|
-
'#CC0099',
|
|
16073
|
-
'#CC00CC',
|
|
16074
|
-
'#CC00FF',
|
|
16075
|
-
'#CC3300',
|
|
16076
|
-
'#CC3333',
|
|
16077
|
-
'#CC3366',
|
|
16078
|
-
'#CC3399',
|
|
16079
|
-
'#CC33CC',
|
|
16080
|
-
'#CC33FF',
|
|
16081
|
-
'#CC6600',
|
|
16082
|
-
'#CC6633',
|
|
16083
|
-
'#CC9900',
|
|
16084
|
-
'#CC9933',
|
|
16085
|
-
'#CCCC00',
|
|
16086
|
-
'#CCCC33',
|
|
16087
|
-
'#FF0000',
|
|
16088
|
-
'#FF0033',
|
|
16089
|
-
'#FF0066',
|
|
16090
|
-
'#FF0099',
|
|
16091
|
-
'#FF00CC',
|
|
16092
|
-
'#FF00FF',
|
|
16093
|
-
'#FF3300',
|
|
16094
|
-
'#FF3333',
|
|
16095
|
-
'#FF3366',
|
|
16096
|
-
'#FF3399',
|
|
16097
|
-
'#FF33CC',
|
|
16098
|
-
'#FF33FF',
|
|
16099
|
-
'#FF6600',
|
|
16100
|
-
'#FF6633',
|
|
16101
|
-
'#FF9900',
|
|
16102
|
-
'#FF9933',
|
|
16103
|
-
'#FFCC00',
|
|
16104
|
-
'#FFCC33'
|
|
16105
|
-
];
|
|
16106
|
-
|
|
16107
|
-
/**
|
|
16108
|
-
* Currently only WebKit-based Web Inspectors, Firefox >= v31,
|
|
16109
|
-
* and the Firebug extension (any Firefox version) are known
|
|
16110
|
-
* to support "%c" CSS customizations.
|
|
16111
|
-
*
|
|
16112
|
-
* TODO: add a `localStorage` variable to explicitly enable/disable colors
|
|
16113
|
-
*/
|
|
16114
|
-
|
|
16115
|
-
// eslint-disable-next-line complexity
|
|
16116
|
-
function useColors() {
|
|
16117
|
-
// NB: In an Electron preload script, document will be defined but not fully
|
|
16118
|
-
// initialized. Since we know we're in Chrome, we'll just detect this case
|
|
16119
|
-
// explicitly
|
|
16120
|
-
if (typeof window !== 'undefined' && window.process && (window.process.type === 'renderer' || window.process.__nwjs)) {
|
|
16121
|
-
return true;
|
|
16122
|
-
}
|
|
16123
|
-
|
|
16124
|
-
// Internet Explorer and Edge do not support colors.
|
|
16125
|
-
if (typeof navigator !== 'undefined' && navigator.userAgent && navigator.userAgent.toLowerCase().match(/(edge|trident)\/(\d+)/)) {
|
|
16126
|
-
return false;
|
|
16127
|
-
}
|
|
16128
|
-
|
|
16129
|
-
let m;
|
|
16130
|
-
|
|
16131
|
-
// Is webkit? http://stackoverflow.com/a/16459606/376773
|
|
16132
|
-
// document is undefined in react-native: https://github.com/facebook/react-native/pull/1632
|
|
16133
|
-
return (typeof document !== 'undefined' && document.documentElement && document.documentElement.style && document.documentElement.style.WebkitAppearance) ||
|
|
16134
|
-
// Is firebug? http://stackoverflow.com/a/398120/376773
|
|
16135
|
-
(typeof window !== 'undefined' && window.console && (window.console.firebug || (window.console.exception && window.console.table))) ||
|
|
16136
|
-
// Is firefox >= v31?
|
|
16137
|
-
// https://developer.mozilla.org/en-US/docs/Tools/Web_Console#Styling_messages
|
|
16138
|
-
(typeof navigator !== 'undefined' && navigator.userAgent && (m = navigator.userAgent.toLowerCase().match(/firefox\/(\d+)/)) && parseInt(m[1], 10) >= 31) ||
|
|
16139
|
-
// Double check webkit in userAgent just in case we are in a worker
|
|
16140
|
-
(typeof navigator !== 'undefined' && navigator.userAgent && navigator.userAgent.toLowerCase().match(/applewebkit\/(\d+)/));
|
|
16141
|
-
}
|
|
16142
|
-
|
|
16143
|
-
/**
|
|
16144
|
-
* Colorize log arguments if enabled.
|
|
16145
|
-
*
|
|
16146
|
-
* @api public
|
|
16147
|
-
*/
|
|
16148
|
-
|
|
16149
|
-
function formatArgs(args) {
|
|
16150
|
-
args[0] = (this.useColors ? '%c' : '') +
|
|
16151
|
-
this.namespace +
|
|
16152
|
-
(this.useColors ? ' %c' : ' ') +
|
|
16153
|
-
args[0] +
|
|
16154
|
-
(this.useColors ? '%c ' : ' ') +
|
|
16155
|
-
'+' + module.exports.humanize(this.diff);
|
|
16156
|
-
|
|
16157
|
-
if (!this.useColors) {
|
|
16158
|
-
return;
|
|
16159
|
-
}
|
|
16160
|
-
|
|
16161
|
-
const c = 'color: ' + this.color;
|
|
16162
|
-
args.splice(1, 0, c, 'color: inherit');
|
|
16163
|
-
|
|
16164
|
-
// The final "%c" is somewhat tricky, because there could be other
|
|
16165
|
-
// arguments passed either before or after the %c, so we need to
|
|
16166
|
-
// figure out the correct index to insert the CSS into
|
|
16167
|
-
let index = 0;
|
|
16168
|
-
let lastC = 0;
|
|
16169
|
-
args[0].replace(/%[a-zA-Z%]/g, match => {
|
|
16170
|
-
if (match === '%%') {
|
|
16171
|
-
return;
|
|
16172
|
-
}
|
|
16173
|
-
index++;
|
|
16174
|
-
if (match === '%c') {
|
|
16175
|
-
// We only are interested in the *last* %c
|
|
16176
|
-
// (the user may have provided their own)
|
|
16177
|
-
lastC = index;
|
|
16178
|
-
}
|
|
16179
|
-
});
|
|
16180
|
-
|
|
16181
|
-
args.splice(lastC, 0, c);
|
|
16182
|
-
}
|
|
16183
|
-
|
|
16184
|
-
/**
|
|
16185
|
-
* Invokes `console.debug()` when available.
|
|
16186
|
-
* No-op when `console.debug` is not a "function".
|
|
16187
|
-
* If `console.debug` is not available, falls back
|
|
16188
|
-
* to `console.log`.
|
|
16189
|
-
*
|
|
16190
|
-
* @api public
|
|
16191
|
-
*/
|
|
16192
|
-
exports.log = console.debug || console.log || (() => {});
|
|
16193
|
-
|
|
16194
|
-
/**
|
|
16195
|
-
* Save `namespaces`.
|
|
16196
|
-
*
|
|
16197
|
-
* @param {String} namespaces
|
|
16198
|
-
* @api private
|
|
16199
|
-
*/
|
|
16200
|
-
function save(namespaces) {
|
|
16201
|
-
try {
|
|
16202
|
-
if (namespaces) {
|
|
16203
|
-
exports.storage.setItem('debug', namespaces);
|
|
16204
|
-
} else {
|
|
16205
|
-
exports.storage.removeItem('debug');
|
|
16206
|
-
}
|
|
16207
|
-
} catch (error) {
|
|
16208
|
-
// Swallow
|
|
16209
|
-
// XXX (@Qix-) should we be logging these?
|
|
16210
|
-
}
|
|
16211
|
-
}
|
|
16212
|
-
|
|
16213
|
-
/**
|
|
16214
|
-
* Load `namespaces`.
|
|
16215
|
-
*
|
|
16216
|
-
* @return {String} returns the previously persisted debug modes
|
|
16217
|
-
* @api private
|
|
16218
|
-
*/
|
|
16219
|
-
function load() {
|
|
16220
|
-
let r;
|
|
16221
|
-
try {
|
|
16222
|
-
r = exports.storage.getItem('debug');
|
|
16223
|
-
} catch (error) {
|
|
16224
|
-
// Swallow
|
|
16225
|
-
// XXX (@Qix-) should we be logging these?
|
|
16226
|
-
}
|
|
16227
|
-
|
|
16228
|
-
// If debug isn't set in LS, and we're in Electron, try to load $DEBUG
|
|
16229
|
-
if (!r && typeof process !== 'undefined' && 'env' in process) {
|
|
16230
|
-
r = process.env.DEBUG;
|
|
16231
|
-
}
|
|
16232
|
-
|
|
16233
|
-
return r;
|
|
16234
|
-
}
|
|
16235
|
-
|
|
16236
|
-
/**
|
|
16237
|
-
* Localstorage attempts to return the localstorage.
|
|
16238
|
-
*
|
|
16239
|
-
* This is necessary because safari throws
|
|
16240
|
-
* when a user disables cookies/localstorage
|
|
16241
|
-
* and you attempt to access it.
|
|
16242
|
-
*
|
|
16243
|
-
* @return {LocalStorage}
|
|
16244
|
-
* @api private
|
|
16245
|
-
*/
|
|
16246
|
-
|
|
16247
|
-
function localstorage() {
|
|
16248
|
-
try {
|
|
16249
|
-
// TVMLKit (Apple TV JS Runtime) does not have a window object, just localStorage in the global context
|
|
16250
|
-
// The Browser also has localStorage in the global context.
|
|
16251
|
-
return localStorage;
|
|
16252
|
-
} catch (error) {
|
|
16253
|
-
// Swallow
|
|
16254
|
-
// XXX (@Qix-) should we be logging these?
|
|
16255
|
-
}
|
|
16256
|
-
}
|
|
16257
|
-
|
|
16258
|
-
module.exports = requireCommon()(exports);
|
|
16259
|
-
|
|
16260
|
-
const {formatters} = module.exports;
|
|
16261
|
-
|
|
16262
|
-
/**
|
|
16263
|
-
* Map %j to `JSON.stringify()`, since no Web Inspectors do that by default.
|
|
16264
|
-
*/
|
|
16265
|
-
|
|
16266
|
-
formatters.j = function (v) {
|
|
16267
|
-
try {
|
|
16268
|
-
return JSON.stringify(v);
|
|
16269
|
-
} catch (error) {
|
|
16270
|
-
return '[UnexpectedJSONParseError]: ' + error.message;
|
|
16271
|
-
}
|
|
16272
|
-
};
|
|
16273
|
-
} (browser, browser.exports));
|
|
16274
|
-
return browser.exports;
|
|
16275
|
-
}
|
|
16276
|
-
|
|
16277
|
-
var node = {exports: {}};
|
|
16278
|
-
|
|
16279
|
-
var hasFlag;
|
|
16280
|
-
var hasRequiredHasFlag;
|
|
16281
|
-
|
|
16282
|
-
function requireHasFlag () {
|
|
16283
|
-
if (hasRequiredHasFlag) return hasFlag;
|
|
16284
|
-
hasRequiredHasFlag = 1;
|
|
16285
|
-
|
|
16286
|
-
hasFlag = (flag, argv = process.argv) => {
|
|
16287
|
-
const prefix = flag.startsWith('-') ? '' : (flag.length === 1 ? '-' : '--');
|
|
16288
|
-
const position = argv.indexOf(prefix + flag);
|
|
16289
|
-
const terminatorPosition = argv.indexOf('--');
|
|
16290
|
-
return position !== -1 && (terminatorPosition === -1 || position < terminatorPosition);
|
|
16291
|
-
};
|
|
16292
|
-
return hasFlag;
|
|
16293
|
-
}
|
|
16294
|
-
|
|
16295
|
-
var supportsColor_1;
|
|
16296
|
-
var hasRequiredSupportsColor;
|
|
16297
|
-
|
|
16298
|
-
function requireSupportsColor () {
|
|
16299
|
-
if (hasRequiredSupportsColor) return supportsColor_1;
|
|
16300
|
-
hasRequiredSupportsColor = 1;
|
|
16301
|
-
const os = require$$0$2;
|
|
16302
|
-
const tty = require$$1$1;
|
|
16303
|
-
const hasFlag = requireHasFlag();
|
|
16304
|
-
|
|
16305
|
-
const {env} = process;
|
|
16306
|
-
|
|
16307
|
-
let forceColor;
|
|
16308
|
-
if (hasFlag('no-color') ||
|
|
16309
|
-
hasFlag('no-colors') ||
|
|
16310
|
-
hasFlag('color=false') ||
|
|
16311
|
-
hasFlag('color=never')) {
|
|
16312
|
-
forceColor = 0;
|
|
16313
|
-
} else if (hasFlag('color') ||
|
|
16314
|
-
hasFlag('colors') ||
|
|
16315
|
-
hasFlag('color=true') ||
|
|
16316
|
-
hasFlag('color=always')) {
|
|
16317
|
-
forceColor = 1;
|
|
16318
|
-
}
|
|
16319
|
-
|
|
16320
|
-
if ('FORCE_COLOR' in env) {
|
|
16321
|
-
if (env.FORCE_COLOR === 'true') {
|
|
16322
|
-
forceColor = 1;
|
|
16323
|
-
} else if (env.FORCE_COLOR === 'false') {
|
|
16324
|
-
forceColor = 0;
|
|
16325
|
-
} else {
|
|
16326
|
-
forceColor = env.FORCE_COLOR.length === 0 ? 1 : Math.min(parseInt(env.FORCE_COLOR, 10), 3);
|
|
16327
|
-
}
|
|
16328
|
-
}
|
|
16329
|
-
|
|
16330
|
-
function translateLevel(level) {
|
|
16331
|
-
if (level === 0) {
|
|
16332
|
-
return false;
|
|
16333
|
-
}
|
|
16334
|
-
|
|
16335
|
-
return {
|
|
16336
|
-
level,
|
|
16337
|
-
hasBasic: true,
|
|
16338
|
-
has256: level >= 2,
|
|
16339
|
-
has16m: level >= 3
|
|
16340
|
-
};
|
|
16341
|
-
}
|
|
16342
|
-
|
|
16343
|
-
function supportsColor(haveStream, streamIsTTY) {
|
|
16344
|
-
if (forceColor === 0) {
|
|
16345
|
-
return 0;
|
|
16346
|
-
}
|
|
16347
|
-
|
|
16348
|
-
if (hasFlag('color=16m') ||
|
|
16349
|
-
hasFlag('color=full') ||
|
|
16350
|
-
hasFlag('color=truecolor')) {
|
|
16351
|
-
return 3;
|
|
16352
|
-
}
|
|
16353
|
-
|
|
16354
|
-
if (hasFlag('color=256')) {
|
|
16355
|
-
return 2;
|
|
16356
|
-
}
|
|
16357
|
-
|
|
16358
|
-
if (haveStream && !streamIsTTY && forceColor === undefined) {
|
|
16359
|
-
return 0;
|
|
16360
|
-
}
|
|
16361
|
-
|
|
16362
|
-
const min = forceColor || 0;
|
|
16363
|
-
|
|
16364
|
-
if (env.TERM === 'dumb') {
|
|
16365
|
-
return min;
|
|
16366
|
-
}
|
|
16367
|
-
|
|
16368
|
-
if (process.platform === 'win32') {
|
|
16369
|
-
// Windows 10 build 10586 is the first Windows release that supports 256 colors.
|
|
16370
|
-
// Windows 10 build 14931 is the first release that supports 16m/TrueColor.
|
|
16371
|
-
const osRelease = os.release().split('.');
|
|
16372
|
-
if (
|
|
16373
|
-
Number(osRelease[0]) >= 10 &&
|
|
16374
|
-
Number(osRelease[2]) >= 10586
|
|
16375
|
-
) {
|
|
16376
|
-
return Number(osRelease[2]) >= 14931 ? 3 : 2;
|
|
16377
|
-
}
|
|
16378
|
-
|
|
16379
|
-
return 1;
|
|
16380
|
-
}
|
|
16381
|
-
|
|
16382
|
-
if ('CI' in env) {
|
|
16383
|
-
if (['TRAVIS', 'CIRCLECI', 'APPVEYOR', 'GITLAB_CI', 'GITHUB_ACTIONS', 'BUILDKITE'].some(sign => sign in env) || env.CI_NAME === 'codeship') {
|
|
16384
|
-
return 1;
|
|
16385
|
-
}
|
|
16386
|
-
|
|
16387
|
-
return min;
|
|
16388
|
-
}
|
|
16389
|
-
|
|
16390
|
-
if ('TEAMCITY_VERSION' in env) {
|
|
16391
|
-
return /^(9\.(0*[1-9]\d*)\.|\d{2,}\.)/.test(env.TEAMCITY_VERSION) ? 1 : 0;
|
|
16392
|
-
}
|
|
16393
|
-
|
|
16394
|
-
if (env.COLORTERM === 'truecolor') {
|
|
16395
|
-
return 3;
|
|
16396
|
-
}
|
|
16397
|
-
|
|
16398
|
-
if ('TERM_PROGRAM' in env) {
|
|
16399
|
-
const version = parseInt((env.TERM_PROGRAM_VERSION || '').split('.')[0], 10);
|
|
16400
|
-
|
|
16401
|
-
switch (env.TERM_PROGRAM) {
|
|
16402
|
-
case 'iTerm.app':
|
|
16403
|
-
return version >= 3 ? 3 : 2;
|
|
16404
|
-
case 'Apple_Terminal':
|
|
16405
|
-
return 2;
|
|
16406
|
-
// No default
|
|
16407
|
-
}
|
|
16408
|
-
}
|
|
16409
|
-
|
|
16410
|
-
if (/-256(color)?$/i.test(env.TERM)) {
|
|
16411
|
-
return 2;
|
|
16412
|
-
}
|
|
16413
|
-
|
|
16414
|
-
if (/^screen|^xterm|^vt100|^vt220|^rxvt|color|ansi|cygwin|linux/i.test(env.TERM)) {
|
|
16415
|
-
return 1;
|
|
16416
|
-
}
|
|
16417
|
-
|
|
16418
|
-
if ('COLORTERM' in env) {
|
|
16419
|
-
return 1;
|
|
16420
|
-
}
|
|
16421
|
-
|
|
16422
|
-
return min;
|
|
16423
|
-
}
|
|
16424
|
-
|
|
16425
|
-
function getSupportLevel(stream) {
|
|
16426
|
-
const level = supportsColor(stream, stream && stream.isTTY);
|
|
16427
|
-
return translateLevel(level);
|
|
16428
|
-
}
|
|
16429
|
-
|
|
16430
|
-
supportsColor_1 = {
|
|
16431
|
-
supportsColor: getSupportLevel,
|
|
16432
|
-
stdout: translateLevel(supportsColor(true, tty.isatty(1))),
|
|
16433
|
-
stderr: translateLevel(supportsColor(true, tty.isatty(2)))
|
|
16434
|
-
};
|
|
16435
|
-
return supportsColor_1;
|
|
16436
|
-
}
|
|
16437
|
-
|
|
16438
|
-
/**
|
|
16439
|
-
* Module dependencies.
|
|
16440
|
-
*/
|
|
16441
|
-
|
|
16442
|
-
var hasRequiredNode;
|
|
16443
|
-
|
|
16444
|
-
function requireNode () {
|
|
16445
|
-
if (hasRequiredNode) return node.exports;
|
|
16446
|
-
hasRequiredNode = 1;
|
|
16447
|
-
(function (module, exports) {
|
|
16448
|
-
const tty = require$$1$1;
|
|
16449
|
-
const util = require$$1;
|
|
16450
|
-
|
|
16451
|
-
/**
|
|
16452
|
-
* This is the Node.js implementation of `debug()`.
|
|
16453
|
-
*/
|
|
16454
|
-
|
|
16455
|
-
exports.init = init;
|
|
16456
|
-
exports.log = log;
|
|
16457
|
-
exports.formatArgs = formatArgs;
|
|
16458
|
-
exports.save = save;
|
|
16459
|
-
exports.load = load;
|
|
16460
|
-
exports.useColors = useColors;
|
|
16461
|
-
exports.destroy = util.deprecate(
|
|
16462
|
-
() => {},
|
|
16463
|
-
'Instance method `debug.destroy()` is deprecated and no longer does anything. It will be removed in the next major version of `debug`.'
|
|
16464
|
-
);
|
|
16465
|
-
|
|
16466
|
-
/**
|
|
16467
|
-
* Colors.
|
|
16468
|
-
*/
|
|
16469
|
-
|
|
16470
|
-
exports.colors = [6, 2, 3, 4, 5, 1];
|
|
16471
|
-
|
|
16472
|
-
try {
|
|
16473
|
-
// Optional dependency (as in, doesn't need to be installed, NOT like optionalDependencies in package.json)
|
|
16474
|
-
// eslint-disable-next-line import/no-extraneous-dependencies
|
|
16475
|
-
const supportsColor = requireSupportsColor();
|
|
16476
|
-
|
|
16477
|
-
if (supportsColor && (supportsColor.stderr || supportsColor).level >= 2) {
|
|
16478
|
-
exports.colors = [
|
|
16479
|
-
20,
|
|
16480
|
-
21,
|
|
16481
|
-
26,
|
|
16482
|
-
27,
|
|
16483
|
-
32,
|
|
16484
|
-
33,
|
|
16485
|
-
38,
|
|
16486
|
-
39,
|
|
16487
|
-
40,
|
|
16488
|
-
41,
|
|
16489
|
-
42,
|
|
16490
|
-
43,
|
|
16491
|
-
44,
|
|
16492
|
-
45,
|
|
16493
|
-
56,
|
|
16494
|
-
57,
|
|
16495
|
-
62,
|
|
16496
|
-
63,
|
|
16497
|
-
68,
|
|
16498
|
-
69,
|
|
16499
|
-
74,
|
|
16500
|
-
75,
|
|
16501
|
-
76,
|
|
16502
|
-
77,
|
|
16503
|
-
78,
|
|
16504
|
-
79,
|
|
16505
|
-
80,
|
|
16506
|
-
81,
|
|
16507
|
-
92,
|
|
16508
|
-
93,
|
|
16509
|
-
98,
|
|
16510
|
-
99,
|
|
16511
|
-
112,
|
|
16512
|
-
113,
|
|
16513
|
-
128,
|
|
16514
|
-
129,
|
|
16515
|
-
134,
|
|
16516
|
-
135,
|
|
16517
|
-
148,
|
|
16518
|
-
149,
|
|
16519
|
-
160,
|
|
16520
|
-
161,
|
|
16521
|
-
162,
|
|
16522
|
-
163,
|
|
16523
|
-
164,
|
|
16524
|
-
165,
|
|
16525
|
-
166,
|
|
16526
|
-
167,
|
|
16527
|
-
168,
|
|
16528
|
-
169,
|
|
16529
|
-
170,
|
|
16530
|
-
171,
|
|
16531
|
-
172,
|
|
16532
|
-
173,
|
|
16533
|
-
178,
|
|
16534
|
-
179,
|
|
16535
|
-
184,
|
|
16536
|
-
185,
|
|
16537
|
-
196,
|
|
16538
|
-
197,
|
|
16539
|
-
198,
|
|
16540
|
-
199,
|
|
16541
|
-
200,
|
|
16542
|
-
201,
|
|
16543
|
-
202,
|
|
16544
|
-
203,
|
|
16545
|
-
204,
|
|
16546
|
-
205,
|
|
16547
|
-
206,
|
|
16548
|
-
207,
|
|
16549
|
-
208,
|
|
16550
|
-
209,
|
|
16551
|
-
214,
|
|
16552
|
-
215,
|
|
16553
|
-
220,
|
|
16554
|
-
221
|
|
16555
|
-
];
|
|
16556
|
-
}
|
|
16557
|
-
} catch (error) {
|
|
16558
|
-
// Swallow - we only care if `supports-color` is available; it doesn't have to be.
|
|
16559
|
-
}
|
|
16560
|
-
|
|
16561
|
-
/**
|
|
16562
|
-
* Build up the default `inspectOpts` object from the environment variables.
|
|
16563
|
-
*
|
|
16564
|
-
* $ DEBUG_COLORS=no DEBUG_DEPTH=10 DEBUG_SHOW_HIDDEN=enabled node script.js
|
|
16565
|
-
*/
|
|
16566
|
-
|
|
16567
|
-
exports.inspectOpts = Object.keys(process.env).filter(key => {
|
|
16568
|
-
return /^debug_/i.test(key);
|
|
16569
|
-
}).reduce((obj, key) => {
|
|
16570
|
-
// Camel-case
|
|
16571
|
-
const prop = key
|
|
16572
|
-
.substring(6)
|
|
16573
|
-
.toLowerCase()
|
|
16574
|
-
.replace(/_([a-z])/g, (_, k) => {
|
|
16575
|
-
return k.toUpperCase();
|
|
16576
|
-
});
|
|
16577
|
-
|
|
16578
|
-
// Coerce string value into JS value
|
|
16579
|
-
let val = process.env[key];
|
|
16580
|
-
if (/^(yes|on|true|enabled)$/i.test(val)) {
|
|
16581
|
-
val = true;
|
|
16582
|
-
} else if (/^(no|off|false|disabled)$/i.test(val)) {
|
|
16583
|
-
val = false;
|
|
16584
|
-
} else if (val === 'null') {
|
|
16585
|
-
val = null;
|
|
16586
|
-
} else {
|
|
16587
|
-
val = Number(val);
|
|
16588
|
-
}
|
|
16589
|
-
|
|
16590
|
-
obj[prop] = val;
|
|
16591
|
-
return obj;
|
|
16592
|
-
}, {});
|
|
16593
|
-
|
|
16594
|
-
/**
|
|
16595
|
-
* Is stdout a TTY? Colored output is enabled when `true`.
|
|
16596
|
-
*/
|
|
16597
|
-
|
|
16598
|
-
function useColors() {
|
|
16599
|
-
return 'colors' in exports.inspectOpts ?
|
|
16600
|
-
Boolean(exports.inspectOpts.colors) :
|
|
16601
|
-
tty.isatty(process.stderr.fd);
|
|
16602
|
-
}
|
|
16603
|
-
|
|
16604
|
-
/**
|
|
16605
|
-
* Adds ANSI color escape codes if enabled.
|
|
16606
|
-
*
|
|
16607
|
-
* @api public
|
|
16608
|
-
*/
|
|
16609
|
-
|
|
16610
|
-
function formatArgs(args) {
|
|
16611
|
-
const {namespace: name, useColors} = this;
|
|
16612
|
-
|
|
16613
|
-
if (useColors) {
|
|
16614
|
-
const c = this.color;
|
|
16615
|
-
const colorCode = '\u001B[3' + (c < 8 ? c : '8;5;' + c);
|
|
16616
|
-
const prefix = ` ${colorCode};1m${name} \u001B[0m`;
|
|
16617
|
-
|
|
16618
|
-
args[0] = prefix + args[0].split('\n').join('\n' + prefix);
|
|
16619
|
-
args.push(colorCode + 'm+' + module.exports.humanize(this.diff) + '\u001B[0m');
|
|
16620
|
-
} else {
|
|
16621
|
-
args[0] = getDate() + name + ' ' + args[0];
|
|
16622
|
-
}
|
|
16623
|
-
}
|
|
16624
|
-
|
|
16625
|
-
function getDate() {
|
|
16626
|
-
if (exports.inspectOpts.hideDate) {
|
|
16627
|
-
return '';
|
|
16628
|
-
}
|
|
16629
|
-
return new Date().toISOString() + ' ';
|
|
16630
|
-
}
|
|
16631
|
-
|
|
16632
|
-
/**
|
|
16633
|
-
* Invokes `util.formatWithOptions()` with the specified arguments and writes to stderr.
|
|
16634
|
-
*/
|
|
16635
|
-
|
|
16636
|
-
function log(...args) {
|
|
16637
|
-
return process.stderr.write(util.formatWithOptions(exports.inspectOpts, ...args) + '\n');
|
|
16638
|
-
}
|
|
16639
|
-
|
|
16640
|
-
/**
|
|
16641
|
-
* Save `namespaces`.
|
|
16642
|
-
*
|
|
16643
|
-
* @param {String} namespaces
|
|
16644
|
-
* @api private
|
|
16645
|
-
*/
|
|
16646
|
-
function save(namespaces) {
|
|
16647
|
-
if (namespaces) {
|
|
16648
|
-
process.env.DEBUG = namespaces;
|
|
16649
|
-
} else {
|
|
16650
|
-
// If you set a process.env field to null or undefined, it gets cast to the
|
|
16651
|
-
// string 'null' or 'undefined'. Just delete instead.
|
|
16652
|
-
delete process.env.DEBUG;
|
|
16653
|
-
}
|
|
16654
|
-
}
|
|
16655
|
-
|
|
16656
|
-
/**
|
|
16657
|
-
* Load `namespaces`.
|
|
16658
|
-
*
|
|
16659
|
-
* @return {String} returns the previously persisted debug modes
|
|
16660
|
-
* @api private
|
|
16661
|
-
*/
|
|
16662
|
-
|
|
16663
|
-
function load() {
|
|
16664
|
-
return process.env.DEBUG;
|
|
16665
|
-
}
|
|
16666
|
-
|
|
16667
|
-
/**
|
|
16668
|
-
* Init logic for `debug` instances.
|
|
16669
|
-
*
|
|
16670
|
-
* Create a new `inspectOpts` object in case `useColors` is set
|
|
16671
|
-
* differently for a particular `debug` instance.
|
|
16672
|
-
*/
|
|
16673
|
-
|
|
16674
|
-
function init(debug) {
|
|
16675
|
-
debug.inspectOpts = {};
|
|
16676
|
-
|
|
16677
|
-
const keys = Object.keys(exports.inspectOpts);
|
|
16678
|
-
for (let i = 0; i < keys.length; i++) {
|
|
16679
|
-
debug.inspectOpts[keys[i]] = exports.inspectOpts[keys[i]];
|
|
16680
|
-
}
|
|
16681
|
-
}
|
|
16682
|
-
|
|
16683
|
-
module.exports = requireCommon()(exports);
|
|
16684
|
-
|
|
16685
|
-
const {formatters} = module.exports;
|
|
16686
|
-
|
|
16687
|
-
/**
|
|
16688
|
-
* Map %o to `util.inspect()`, all on a single line.
|
|
16689
|
-
*/
|
|
16690
|
-
|
|
16691
|
-
formatters.o = function (v) {
|
|
16692
|
-
this.inspectOpts.colors = this.useColors;
|
|
16693
|
-
return util.inspect(v, this.inspectOpts)
|
|
16694
|
-
.split('\n')
|
|
16695
|
-
.map(str => str.trim())
|
|
16696
|
-
.join(' ');
|
|
16697
|
-
};
|
|
16698
|
-
|
|
16699
|
-
/**
|
|
16700
|
-
* Map %O to `util.inspect()`, allowing multiple lines if needed.
|
|
16701
|
-
*/
|
|
16702
|
-
|
|
16703
|
-
formatters.O = function (v) {
|
|
16704
|
-
this.inspectOpts.colors = this.useColors;
|
|
16705
|
-
return util.inspect(v, this.inspectOpts);
|
|
16706
|
-
};
|
|
16707
|
-
} (node, node.exports));
|
|
16708
|
-
return node.exports;
|
|
16709
|
-
}
|
|
16710
|
-
|
|
16711
|
-
/**
|
|
16712
|
-
* Detect Electron renderer / nwjs process, which is node, but we should
|
|
16713
|
-
* treat as a browser.
|
|
16714
|
-
*/
|
|
16715
|
-
|
|
16716
|
-
var hasRequiredSrc;
|
|
16717
|
-
|
|
16718
|
-
function requireSrc () {
|
|
16719
|
-
if (hasRequiredSrc) return src.exports;
|
|
16720
|
-
hasRequiredSrc = 1;
|
|
16721
|
-
if (typeof process === 'undefined' || process.type === 'renderer' || process.browser === true || process.__nwjs) {
|
|
16722
|
-
src.exports = requireBrowser();
|
|
16723
|
-
} else {
|
|
16724
|
-
src.exports = requireNode();
|
|
16725
|
-
}
|
|
16726
|
-
return src.exports;
|
|
16727
|
-
}
|
|
16728
|
-
|
|
16729
15536
|
var debug_1;
|
|
16730
15537
|
var hasRequiredDebug;
|
|
16731
15538
|
|
|
@@ -16738,7 +15545,7 @@ function requireDebug () {
|
|
|
16738
15545
|
if (!debug) {
|
|
16739
15546
|
try {
|
|
16740
15547
|
/* eslint global-require: off */
|
|
16741
|
-
debug =
|
|
15548
|
+
debug = require("debug")("follow-redirects");
|
|
16742
15549
|
}
|
|
16743
15550
|
catch (error) { /* */ }
|
|
16744
15551
|
if (typeof debug !== "function") {
|
|
@@ -20162,8 +18969,6 @@ class AtlasClient {
|
|
|
20162
18969
|
}
|
|
20163
18970
|
}
|
|
20164
18971
|
|
|
20165
|
-
// src/lib/client.ts
|
|
20166
|
-
let consulClient = null;
|
|
20167
18972
|
let atlasClient = null;
|
|
20168
18973
|
function toBoolean(value) {
|
|
20169
18974
|
if (typeof value === 'boolean')
|
|
@@ -20172,25 +18977,12 @@ function toBoolean(value) {
|
|
|
20172
18977
|
return value.toLowerCase() === 'true';
|
|
20173
18978
|
return false;
|
|
20174
18979
|
}
|
|
20175
|
-
function initClient({ host = '127.0.0.1', port =
|
|
18980
|
+
function initClient({ host = '127.0.0.1', port = 3371, secure = false }) {
|
|
20176
18981
|
atlasClient = new AtlasClient({
|
|
20177
18982
|
host: host !== null && host !== void 0 ? host : '127.0.0.1',
|
|
20178
|
-
port
|
|
18983
|
+
port,
|
|
20179
18984
|
version: '1',
|
|
20180
18985
|
});
|
|
20181
|
-
consulClient = new Consul({
|
|
20182
|
-
host: host !== null && host !== void 0 ? host : '127.0.0.1',
|
|
20183
|
-
port: port !== null && port !== void 0 ? port : 8500,
|
|
20184
|
-
secure: toBoolean(secure),
|
|
20185
|
-
});
|
|
20186
|
-
consulClient.agent.self(err => {
|
|
20187
|
-
if (err) {
|
|
20188
|
-
console.error('❌ Failed to connect to Consul:', err.message);
|
|
20189
|
-
}
|
|
20190
|
-
else {
|
|
20191
|
-
console.log('✅ Connected to Consul successfully');
|
|
20192
|
-
}
|
|
20193
|
-
});
|
|
20194
18986
|
}
|
|
20195
18987
|
function getAtlasClient() {
|
|
20196
18988
|
if (!atlasClient) {
|
|
@@ -20198,61 +18990,19 @@ function getAtlasClient() {
|
|
|
20198
18990
|
}
|
|
20199
18991
|
return atlasClient;
|
|
20200
18992
|
}
|
|
20201
|
-
function getClient() {
|
|
20202
|
-
if (!consulClient) {
|
|
20203
|
-
throw new Error('Consul client not initialized. Call initClient() first.');
|
|
20204
|
-
}
|
|
20205
|
-
return consulClient;
|
|
20206
|
-
}
|
|
20207
18993
|
|
|
20208
|
-
const registeredServices = new Set();
|
|
20209
18994
|
async function registerService(options) {
|
|
20210
|
-
|
|
20211
|
-
const { name, id, port, address = 'localhost', check, tags, meta } = options;
|
|
18995
|
+
const { name, port, address = 'localhost', tags, meta } = options;
|
|
20212
18996
|
const atlasClient = getAtlasClient();
|
|
20213
|
-
await atlasClient
|
|
18997
|
+
await atlasClient
|
|
18998
|
+
.registerService({
|
|
20214
18999
|
address,
|
|
20215
19000
|
port,
|
|
20216
19001
|
name,
|
|
20217
|
-
})
|
|
20218
|
-
|
|
19002
|
+
})
|
|
19003
|
+
.then(res => {
|
|
19004
|
+
console.log("Service Registered");
|
|
20219
19005
|
});
|
|
20220
|
-
if (registeredServices.has(id)) {
|
|
20221
|
-
console.log(`⚠️ Service "${id}" is already registered.`);
|
|
20222
|
-
return;
|
|
20223
|
-
}
|
|
20224
|
-
const serviceDefinition = {
|
|
20225
|
-
name,
|
|
20226
|
-
id,
|
|
20227
|
-
address,
|
|
20228
|
-
port,
|
|
20229
|
-
tags,
|
|
20230
|
-
meta,
|
|
20231
|
-
};
|
|
20232
|
-
if (check !== false) {
|
|
20233
|
-
const checkDefinition = {
|
|
20234
|
-
name: (_a = check === null || check === void 0 ? void 0 : check.name) !== null && _a !== void 0 ? _a : `${name}-check`,
|
|
20235
|
-
http: (_b = check === null || check === void 0 ? void 0 : check.http) !== null && _b !== void 0 ? _b : `http://${address}:${port}/health`,
|
|
20236
|
-
interval: (_c = check === null || check === void 0 ? void 0 : check.interval) !== null && _c !== void 0 ? _c : '10s',
|
|
20237
|
-
timeout: (_d = check === null || check === void 0 ? void 0 : check.timeout) !== null && _d !== void 0 ? _d : '5s',
|
|
20238
|
-
};
|
|
20239
|
-
if (check === null || check === void 0 ? void 0 : check.deregistercriticalserviceafter) {
|
|
20240
|
-
checkDefinition.deregistercriticalserviceafter = check.deregistercriticalserviceafter;
|
|
20241
|
-
}
|
|
20242
|
-
serviceDefinition.check = checkDefinition;
|
|
20243
|
-
}
|
|
20244
|
-
await getClient().agent.service.register(serviceDefinition);
|
|
20245
|
-
registeredServices.add(id);
|
|
20246
|
-
console.log(`✅ Service "${id}" registered successfully.`);
|
|
20247
|
-
}
|
|
20248
|
-
async function deregisterService(id) {
|
|
20249
|
-
if (!registeredServices.has(id)) {
|
|
20250
|
-
console.log(`⚠️ Service "${id}" is not registered.`);
|
|
20251
|
-
return;
|
|
20252
|
-
}
|
|
20253
|
-
await getClient().agent.service.deregister(id);
|
|
20254
|
-
registeredServices.delete(id);
|
|
20255
|
-
console.log(`🛑 Service "${id}" deregistered successfully.`);
|
|
20256
19006
|
}
|
|
20257
19007
|
|
|
20258
19008
|
const BASE_LOG_DIR$2 = '/home/log';
|
|
@@ -20262,12 +19012,12 @@ async function ensureLogDir$2(dir) {
|
|
|
20262
19012
|
await promises.mkdir(dir, { recursive: true });
|
|
20263
19013
|
}
|
|
20264
19014
|
function formatLogLine(targetService, instance, elapsedMs) {
|
|
20265
|
-
var _a, _b, _c, _d
|
|
19015
|
+
var _a, _b, _c, _d;
|
|
20266
19016
|
const ts = new Date().toISOString();
|
|
20267
|
-
const addr = (
|
|
20268
|
-
const port = (
|
|
20269
|
-
const node = (
|
|
20270
|
-
const id = (
|
|
19017
|
+
const addr = (_a = instance.address) !== null && _a !== void 0 ? _a : 'unknown';
|
|
19018
|
+
const port = (_b = instance.port) !== null && _b !== void 0 ? _b : 'unknown';
|
|
19019
|
+
const node = (_c = instance.Node) !== null && _c !== void 0 ? _c : 'N/A';
|
|
19020
|
+
const id = (_d = instance.ServiceID) !== null && _d !== void 0 ? _d : 'N/A';
|
|
20271
19021
|
const elapsed = elapsedMs !== undefined ? ` | Elapsed=${elapsedMs}ms` : '';
|
|
20272
19022
|
return `${ts} | Target=${targetService} | ${addr}:${port} | Node=${node} | ID=${id}${elapsed}\n`;
|
|
20273
19023
|
}
|
|
@@ -20312,29 +19062,33 @@ function get(key) {
|
|
|
20312
19062
|
return record.value;
|
|
20313
19063
|
}
|
|
20314
19064
|
|
|
20315
|
-
const CACHE_TTL = 60000;
|
|
19065
|
+
const CACHE_TTL = 60000; // 1 دقيقة
|
|
19066
|
+
// جلب كل الخدمات
|
|
20316
19067
|
async function listServices() {
|
|
20317
19068
|
const cacheKey = 'services:list';
|
|
20318
19069
|
const cached = get(cacheKey);
|
|
20319
19070
|
if (cached)
|
|
20320
19071
|
return cached;
|
|
20321
|
-
const services = await
|
|
20322
|
-
|
|
20323
|
-
|
|
20324
|
-
return values;
|
|
19072
|
+
const services = await getAtlasClient().listServices();
|
|
19073
|
+
set(cacheKey, services, CACHE_TTL);
|
|
19074
|
+
return services;
|
|
20325
19075
|
}
|
|
19076
|
+
// جلب كل الـ instances لسيرفس معين
|
|
20326
19077
|
async function getServiceInstances(serviceName) {
|
|
20327
19078
|
const cacheKey = `services:${serviceName}`;
|
|
20328
19079
|
const cached = get(cacheKey);
|
|
20329
19080
|
if (cached)
|
|
20330
19081
|
return cached;
|
|
20331
19082
|
const start = Date.now();
|
|
20332
|
-
const services = await
|
|
19083
|
+
const services = await getAtlasClient().listServices(); // هنجيب كل السيرفسات
|
|
20333
19084
|
const elapsed = Date.now() - start;
|
|
20334
19085
|
console.log(`⏱️ Discovery for ${serviceName} took ${elapsed}ms`);
|
|
20335
|
-
|
|
20336
|
-
|
|
19086
|
+
// فلترة السيرفس المطلوب
|
|
19087
|
+
const instances = services.filter(s => s.name === serviceName);
|
|
19088
|
+
set(cacheKey, instances, CACHE_TTL);
|
|
19089
|
+
return instances;
|
|
20337
19090
|
}
|
|
19091
|
+
// جلب instance عشوائي لسيرفس معين
|
|
20338
19092
|
async function getRandomServiceInstance(serviceName) {
|
|
20339
19093
|
const cacheKey = `random:${serviceName}`;
|
|
20340
19094
|
const cached = get(cacheKey);
|
|
@@ -20348,18 +19102,17 @@ async function getRandomServiceInstance(serviceName) {
|
|
|
20348
19102
|
const instance = instances[randomIndex];
|
|
20349
19103
|
const elapsed = Date.now() - start;
|
|
20350
19104
|
await appendDiscoveryLog(serviceName, instance, elapsed);
|
|
20351
|
-
// cache random instance
|
|
20352
19105
|
set(cacheKey, instance, CACHE_TTL);
|
|
20353
19106
|
return instance;
|
|
20354
19107
|
}
|
|
19108
|
+
// جلب URL جاهز للاتصال
|
|
20355
19109
|
async function getServiceUrl(serviceName) {
|
|
20356
19110
|
const cacheKey = `url:${serviceName}`;
|
|
20357
19111
|
const cached = get(cacheKey);
|
|
20358
19112
|
if (cached)
|
|
20359
19113
|
return cached;
|
|
20360
19114
|
const instance = await getRandomServiceInstance(serviceName);
|
|
20361
|
-
const url = `http://${instance.
|
|
20362
|
-
// cache url
|
|
19115
|
+
const url = `http://${instance.address}:${instance.port}`;
|
|
20363
19116
|
set(cacheKey, url, CACHE_TTL);
|
|
20364
19117
|
return url;
|
|
20365
19118
|
}
|
|
@@ -20433,7 +19186,7 @@ async function callService(serviceName, options = {}) {
|
|
|
20433
19186
|
const start = Date.now();
|
|
20434
19187
|
try {
|
|
20435
19188
|
const instance = await getRandomServiceInstance(serviceName);
|
|
20436
|
-
const url = `http://${instance.
|
|
19189
|
+
const url = `http://${instance.address}:${instance.port}${path}`;
|
|
20437
19190
|
const response = await axios.request({ url, method, data, headers, params });
|
|
20438
19191
|
const elapsed = Date.now() - start;
|
|
20439
19192
|
// 📌 سجل الكول
|
|
@@ -20620,5 +19373,5 @@ async function dataLink(data, schema) {
|
|
|
20620
19373
|
return isArray ? result : result[0];
|
|
20621
19374
|
}
|
|
20622
19375
|
|
|
20623
|
-
export { callService, dataLink,
|
|
19376
|
+
export { callService, dataLink, getAtlasClient, getRandomServiceInstance, getServiceInstances, getServiceUrl, initClient, listServices, registerService, toBoolean };
|
|
20624
19377
|
//# sourceMappingURL=index.esm.js.map
|