node-consul-service 1.0.67 → 1.0.69
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/index.cjs.js +1269 -13
- package/dist/index.esm.js +1269 -13
- package/dist/utils/callLogger.d.ts +1 -0
- package/dist/utils/logger.d.ts +2 -0
- package/package.json +1 -1
package/dist/index.cjs.js
CHANGED
|
@@ -1,15 +1,17 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
3
|
var Consul = require('consul');
|
|
4
|
+
var require$$6 = require('fs');
|
|
5
|
+
var path = require('path');
|
|
4
6
|
var require$$1 = require('util');
|
|
5
7
|
var stream = require('stream');
|
|
6
|
-
var require$$1$1 = require('path');
|
|
7
8
|
var require$$3 = require('http');
|
|
8
9
|
var require$$4 = require('https');
|
|
9
10
|
var require$$0$1 = require('url');
|
|
10
|
-
var require$$6 = require('fs');
|
|
11
11
|
var crypto = require('crypto');
|
|
12
12
|
var require$$4$1 = require('assert');
|
|
13
|
+
var require$$1$1 = require('tty');
|
|
14
|
+
var require$$0$2 = require('os');
|
|
13
15
|
var zlib = require('zlib');
|
|
14
16
|
var events = require('events');
|
|
15
17
|
|
|
@@ -86,20 +88,56 @@ async function deregisterService(id) {
|
|
|
86
88
|
console.log(`🛑 Service "${id}" deregistered successfully.`);
|
|
87
89
|
}
|
|
88
90
|
|
|
91
|
+
const LOG_DIR$1 = '/home/log';
|
|
92
|
+
const LOG_FILE$1 = path.join(LOG_DIR$1, 'detect.log');
|
|
93
|
+
// تأكد من وجود المجلد
|
|
94
|
+
async function ensureLogDir$1() {
|
|
95
|
+
await require$$6.promises.mkdir(LOG_DIR$1, { recursive: true });
|
|
96
|
+
}
|
|
97
|
+
// صيغة السطر
|
|
98
|
+
function formatLogLine(serviceName, instance, elapsedMs) {
|
|
99
|
+
var _a, _b, _c, _d, _e;
|
|
100
|
+
const ts = new Date().toISOString();
|
|
101
|
+
const addr = (_b = (_a = instance.ServiceAddress) !== null && _a !== void 0 ? _a : instance.ServiceAddress) !== null && _b !== void 0 ? _b : 'unknown';
|
|
102
|
+
const port = (_c = instance.ServicePort) !== null && _c !== void 0 ? _c : 'unknown';
|
|
103
|
+
const node = (_d = instance.Node) !== null && _d !== void 0 ? _d : 'N/A';
|
|
104
|
+
const id = (_e = instance.ServiceID) !== null && _e !== void 0 ? _e : 'N/A';
|
|
105
|
+
const elapsed = elapsedMs !== undefined ? ` | Elapsed=${elapsedMs}ms` : '';
|
|
106
|
+
return `${ts} | ${serviceName} | ${addr}:${port} | Node=${node} | ID=${id}${elapsed}\n`;
|
|
107
|
+
}
|
|
108
|
+
// دالة تسجيل
|
|
109
|
+
async function appendDiscoveryLog(serviceName, instance, elapsedMs) {
|
|
110
|
+
try {
|
|
111
|
+
await ensureLogDir$1();
|
|
112
|
+
const line = formatLogLine(serviceName, instance, elapsedMs);
|
|
113
|
+
await require$$6.promises.appendFile(LOG_FILE$1, line, { encoding: 'utf8' });
|
|
114
|
+
}
|
|
115
|
+
catch (err) {
|
|
116
|
+
console.error('❌ Failed to write discovery log:', err);
|
|
117
|
+
}
|
|
118
|
+
}
|
|
119
|
+
|
|
89
120
|
async function listServices() {
|
|
90
121
|
const services = await getClient().agent.service.list();
|
|
91
122
|
return Object.values(services);
|
|
92
123
|
}
|
|
93
124
|
async function getServiceInstances(serviceName) {
|
|
125
|
+
const start = Date.now();
|
|
94
126
|
const services = await getClient().catalog.service.nodes(serviceName);
|
|
127
|
+
const elapsed = Date.now() - start;
|
|
128
|
+
console.log(`⏱️ Discovery for ${serviceName} took ${elapsed}ms`);
|
|
95
129
|
return services;
|
|
96
130
|
}
|
|
97
131
|
async function getRandomServiceInstance(serviceName) {
|
|
132
|
+
const start = Date.now();
|
|
98
133
|
const instances = await getServiceInstances(serviceName);
|
|
99
134
|
if (!instances.length)
|
|
100
135
|
throw new Error(`Service "${serviceName}" not found`);
|
|
101
136
|
const randomIndex = Math.floor(Math.random() * instances.length);
|
|
102
|
-
|
|
137
|
+
const instance = instances[randomIndex];
|
|
138
|
+
const elapsed = Date.now() - start;
|
|
139
|
+
await appendDiscoveryLog(serviceName, instance, elapsed);
|
|
140
|
+
return instance;
|
|
103
141
|
}
|
|
104
142
|
async function getServiceUrl(serviceName) {
|
|
105
143
|
const instance = await getRandomServiceInstance(serviceName);
|
|
@@ -12034,7 +12072,7 @@ function requireMimeTypes () {
|
|
|
12034
12072
|
*/
|
|
12035
12073
|
|
|
12036
12074
|
var db = requireMimeDb();
|
|
12037
|
-
var extname =
|
|
12075
|
+
var extname = path.extname;
|
|
12038
12076
|
|
|
12039
12077
|
/**
|
|
12040
12078
|
* Module variables.
|
|
@@ -13775,7 +13813,7 @@ function requireForm_data () {
|
|
|
13775
13813
|
hasRequiredForm_data = 1;
|
|
13776
13814
|
var CombinedStream = requireCombined_stream();
|
|
13777
13815
|
var util = require$$1;
|
|
13778
|
-
var path =
|
|
13816
|
+
var path$1 = path;
|
|
13779
13817
|
var http = require$$3;
|
|
13780
13818
|
var https = require$$4;
|
|
13781
13819
|
var parseUrl = require$$0$1.parse;
|
|
@@ -13999,15 +14037,15 @@ function requireForm_data () {
|
|
|
13999
14037
|
|
|
14000
14038
|
if (typeof options.filepath === 'string') {
|
|
14001
14039
|
// custom filepath for relative paths
|
|
14002
|
-
filename = path.normalize(options.filepath).replace(/\\/g, '/');
|
|
14040
|
+
filename = path$1.normalize(options.filepath).replace(/\\/g, '/');
|
|
14003
14041
|
} else if (options.filename || value.name || value.path) {
|
|
14004
14042
|
// custom filename take precedence
|
|
14005
14043
|
// formidable and the browser add a name property
|
|
14006
14044
|
// fs- and request- streams have path property
|
|
14007
|
-
filename = path.basename(options.filename || value.name || value.path);
|
|
14045
|
+
filename = path$1.basename(options.filename || value.name || value.path);
|
|
14008
14046
|
} else if (value.readable && Object.prototype.hasOwnProperty.call(value, 'httpVersion')) {
|
|
14009
14047
|
// or try http response
|
|
14010
|
-
filename = path.basename(value.client._httpMessage.path || '');
|
|
14048
|
+
filename = path$1.basename(value.client._httpMessage.path || '');
|
|
14011
14049
|
}
|
|
14012
14050
|
|
|
14013
14051
|
if (filename) {
|
|
@@ -15629,6 +15667,1196 @@ var proxyFromEnv = /*@__PURE__*/getDefaultExportFromCjs(proxyFromEnvExports);
|
|
|
15629
15667
|
|
|
15630
15668
|
var followRedirects$1 = {exports: {}};
|
|
15631
15669
|
|
|
15670
|
+
var src = {exports: {}};
|
|
15671
|
+
|
|
15672
|
+
var browser = {exports: {}};
|
|
15673
|
+
|
|
15674
|
+
/**
|
|
15675
|
+
* Helpers.
|
|
15676
|
+
*/
|
|
15677
|
+
|
|
15678
|
+
var ms;
|
|
15679
|
+
var hasRequiredMs;
|
|
15680
|
+
|
|
15681
|
+
function requireMs () {
|
|
15682
|
+
if (hasRequiredMs) return ms;
|
|
15683
|
+
hasRequiredMs = 1;
|
|
15684
|
+
var s = 1000;
|
|
15685
|
+
var m = s * 60;
|
|
15686
|
+
var h = m * 60;
|
|
15687
|
+
var d = h * 24;
|
|
15688
|
+
var w = d * 7;
|
|
15689
|
+
var y = d * 365.25;
|
|
15690
|
+
|
|
15691
|
+
/**
|
|
15692
|
+
* Parse or format the given `val`.
|
|
15693
|
+
*
|
|
15694
|
+
* Options:
|
|
15695
|
+
*
|
|
15696
|
+
* - `long` verbose formatting [false]
|
|
15697
|
+
*
|
|
15698
|
+
* @param {String|Number} val
|
|
15699
|
+
* @param {Object} [options]
|
|
15700
|
+
* @throws {Error} throw an error if val is not a non-empty string or a number
|
|
15701
|
+
* @return {String|Number}
|
|
15702
|
+
* @api public
|
|
15703
|
+
*/
|
|
15704
|
+
|
|
15705
|
+
ms = function (val, options) {
|
|
15706
|
+
options = options || {};
|
|
15707
|
+
var type = typeof val;
|
|
15708
|
+
if (type === 'string' && val.length > 0) {
|
|
15709
|
+
return parse(val);
|
|
15710
|
+
} else if (type === 'number' && isFinite(val)) {
|
|
15711
|
+
return options.long ? fmtLong(val) : fmtShort(val);
|
|
15712
|
+
}
|
|
15713
|
+
throw new Error(
|
|
15714
|
+
'val is not a non-empty string or a valid number. val=' +
|
|
15715
|
+
JSON.stringify(val)
|
|
15716
|
+
);
|
|
15717
|
+
};
|
|
15718
|
+
|
|
15719
|
+
/**
|
|
15720
|
+
* Parse the given `str` and return milliseconds.
|
|
15721
|
+
*
|
|
15722
|
+
* @param {String} str
|
|
15723
|
+
* @return {Number}
|
|
15724
|
+
* @api private
|
|
15725
|
+
*/
|
|
15726
|
+
|
|
15727
|
+
function parse(str) {
|
|
15728
|
+
str = String(str);
|
|
15729
|
+
if (str.length > 100) {
|
|
15730
|
+
return;
|
|
15731
|
+
}
|
|
15732
|
+
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(
|
|
15733
|
+
str
|
|
15734
|
+
);
|
|
15735
|
+
if (!match) {
|
|
15736
|
+
return;
|
|
15737
|
+
}
|
|
15738
|
+
var n = parseFloat(match[1]);
|
|
15739
|
+
var type = (match[2] || 'ms').toLowerCase();
|
|
15740
|
+
switch (type) {
|
|
15741
|
+
case 'years':
|
|
15742
|
+
case 'year':
|
|
15743
|
+
case 'yrs':
|
|
15744
|
+
case 'yr':
|
|
15745
|
+
case 'y':
|
|
15746
|
+
return n * y;
|
|
15747
|
+
case 'weeks':
|
|
15748
|
+
case 'week':
|
|
15749
|
+
case 'w':
|
|
15750
|
+
return n * w;
|
|
15751
|
+
case 'days':
|
|
15752
|
+
case 'day':
|
|
15753
|
+
case 'd':
|
|
15754
|
+
return n * d;
|
|
15755
|
+
case 'hours':
|
|
15756
|
+
case 'hour':
|
|
15757
|
+
case 'hrs':
|
|
15758
|
+
case 'hr':
|
|
15759
|
+
case 'h':
|
|
15760
|
+
return n * h;
|
|
15761
|
+
case 'minutes':
|
|
15762
|
+
case 'minute':
|
|
15763
|
+
case 'mins':
|
|
15764
|
+
case 'min':
|
|
15765
|
+
case 'm':
|
|
15766
|
+
return n * m;
|
|
15767
|
+
case 'seconds':
|
|
15768
|
+
case 'second':
|
|
15769
|
+
case 'secs':
|
|
15770
|
+
case 'sec':
|
|
15771
|
+
case 's':
|
|
15772
|
+
return n * s;
|
|
15773
|
+
case 'milliseconds':
|
|
15774
|
+
case 'millisecond':
|
|
15775
|
+
case 'msecs':
|
|
15776
|
+
case 'msec':
|
|
15777
|
+
case 'ms':
|
|
15778
|
+
return n;
|
|
15779
|
+
default:
|
|
15780
|
+
return undefined;
|
|
15781
|
+
}
|
|
15782
|
+
}
|
|
15783
|
+
|
|
15784
|
+
/**
|
|
15785
|
+
* Short format for `ms`.
|
|
15786
|
+
*
|
|
15787
|
+
* @param {Number} ms
|
|
15788
|
+
* @return {String}
|
|
15789
|
+
* @api private
|
|
15790
|
+
*/
|
|
15791
|
+
|
|
15792
|
+
function fmtShort(ms) {
|
|
15793
|
+
var msAbs = Math.abs(ms);
|
|
15794
|
+
if (msAbs >= d) {
|
|
15795
|
+
return Math.round(ms / d) + 'd';
|
|
15796
|
+
}
|
|
15797
|
+
if (msAbs >= h) {
|
|
15798
|
+
return Math.round(ms / h) + 'h';
|
|
15799
|
+
}
|
|
15800
|
+
if (msAbs >= m) {
|
|
15801
|
+
return Math.round(ms / m) + 'm';
|
|
15802
|
+
}
|
|
15803
|
+
if (msAbs >= s) {
|
|
15804
|
+
return Math.round(ms / s) + 's';
|
|
15805
|
+
}
|
|
15806
|
+
return ms + 'ms';
|
|
15807
|
+
}
|
|
15808
|
+
|
|
15809
|
+
/**
|
|
15810
|
+
* Long format for `ms`.
|
|
15811
|
+
*
|
|
15812
|
+
* @param {Number} ms
|
|
15813
|
+
* @return {String}
|
|
15814
|
+
* @api private
|
|
15815
|
+
*/
|
|
15816
|
+
|
|
15817
|
+
function fmtLong(ms) {
|
|
15818
|
+
var msAbs = Math.abs(ms);
|
|
15819
|
+
if (msAbs >= d) {
|
|
15820
|
+
return plural(ms, msAbs, d, 'day');
|
|
15821
|
+
}
|
|
15822
|
+
if (msAbs >= h) {
|
|
15823
|
+
return plural(ms, msAbs, h, 'hour');
|
|
15824
|
+
}
|
|
15825
|
+
if (msAbs >= m) {
|
|
15826
|
+
return plural(ms, msAbs, m, 'minute');
|
|
15827
|
+
}
|
|
15828
|
+
if (msAbs >= s) {
|
|
15829
|
+
return plural(ms, msAbs, s, 'second');
|
|
15830
|
+
}
|
|
15831
|
+
return ms + ' ms';
|
|
15832
|
+
}
|
|
15833
|
+
|
|
15834
|
+
/**
|
|
15835
|
+
* Pluralization helper.
|
|
15836
|
+
*/
|
|
15837
|
+
|
|
15838
|
+
function plural(ms, msAbs, n, name) {
|
|
15839
|
+
var isPlural = msAbs >= n * 1.5;
|
|
15840
|
+
return Math.round(ms / n) + ' ' + name + (isPlural ? 's' : '');
|
|
15841
|
+
}
|
|
15842
|
+
return ms;
|
|
15843
|
+
}
|
|
15844
|
+
|
|
15845
|
+
var common;
|
|
15846
|
+
var hasRequiredCommon;
|
|
15847
|
+
|
|
15848
|
+
function requireCommon () {
|
|
15849
|
+
if (hasRequiredCommon) return common;
|
|
15850
|
+
hasRequiredCommon = 1;
|
|
15851
|
+
/**
|
|
15852
|
+
* This is the common logic for both the Node.js and web browser
|
|
15853
|
+
* implementations of `debug()`.
|
|
15854
|
+
*/
|
|
15855
|
+
|
|
15856
|
+
function setup(env) {
|
|
15857
|
+
createDebug.debug = createDebug;
|
|
15858
|
+
createDebug.default = createDebug;
|
|
15859
|
+
createDebug.coerce = coerce;
|
|
15860
|
+
createDebug.disable = disable;
|
|
15861
|
+
createDebug.enable = enable;
|
|
15862
|
+
createDebug.enabled = enabled;
|
|
15863
|
+
createDebug.humanize = requireMs();
|
|
15864
|
+
createDebug.destroy = destroy;
|
|
15865
|
+
|
|
15866
|
+
Object.keys(env).forEach(key => {
|
|
15867
|
+
createDebug[key] = env[key];
|
|
15868
|
+
});
|
|
15869
|
+
|
|
15870
|
+
/**
|
|
15871
|
+
* The currently active debug mode names, and names to skip.
|
|
15872
|
+
*/
|
|
15873
|
+
|
|
15874
|
+
createDebug.names = [];
|
|
15875
|
+
createDebug.skips = [];
|
|
15876
|
+
|
|
15877
|
+
/**
|
|
15878
|
+
* Map of special "%n" handling functions, for the debug "format" argument.
|
|
15879
|
+
*
|
|
15880
|
+
* Valid key names are a single, lower or upper-case letter, i.e. "n" and "N".
|
|
15881
|
+
*/
|
|
15882
|
+
createDebug.formatters = {};
|
|
15883
|
+
|
|
15884
|
+
/**
|
|
15885
|
+
* Selects a color for a debug namespace
|
|
15886
|
+
* @param {String} namespace The namespace string for the debug instance to be colored
|
|
15887
|
+
* @return {Number|String} An ANSI color code for the given namespace
|
|
15888
|
+
* @api private
|
|
15889
|
+
*/
|
|
15890
|
+
function selectColor(namespace) {
|
|
15891
|
+
let hash = 0;
|
|
15892
|
+
|
|
15893
|
+
for (let i = 0; i < namespace.length; i++) {
|
|
15894
|
+
hash = ((hash << 5) - hash) + namespace.charCodeAt(i);
|
|
15895
|
+
hash |= 0; // Convert to 32bit integer
|
|
15896
|
+
}
|
|
15897
|
+
|
|
15898
|
+
return createDebug.colors[Math.abs(hash) % createDebug.colors.length];
|
|
15899
|
+
}
|
|
15900
|
+
createDebug.selectColor = selectColor;
|
|
15901
|
+
|
|
15902
|
+
/**
|
|
15903
|
+
* Create a debugger with the given `namespace`.
|
|
15904
|
+
*
|
|
15905
|
+
* @param {String} namespace
|
|
15906
|
+
* @return {Function}
|
|
15907
|
+
* @api public
|
|
15908
|
+
*/
|
|
15909
|
+
function createDebug(namespace) {
|
|
15910
|
+
let prevTime;
|
|
15911
|
+
let enableOverride = null;
|
|
15912
|
+
let namespacesCache;
|
|
15913
|
+
let enabledCache;
|
|
15914
|
+
|
|
15915
|
+
function debug(...args) {
|
|
15916
|
+
// Disabled?
|
|
15917
|
+
if (!debug.enabled) {
|
|
15918
|
+
return;
|
|
15919
|
+
}
|
|
15920
|
+
|
|
15921
|
+
const self = debug;
|
|
15922
|
+
|
|
15923
|
+
// Set `diff` timestamp
|
|
15924
|
+
const curr = Number(new Date());
|
|
15925
|
+
const ms = curr - (prevTime || curr);
|
|
15926
|
+
self.diff = ms;
|
|
15927
|
+
self.prev = prevTime;
|
|
15928
|
+
self.curr = curr;
|
|
15929
|
+
prevTime = curr;
|
|
15930
|
+
|
|
15931
|
+
args[0] = createDebug.coerce(args[0]);
|
|
15932
|
+
|
|
15933
|
+
if (typeof args[0] !== 'string') {
|
|
15934
|
+
// Anything else let's inspect with %O
|
|
15935
|
+
args.unshift('%O');
|
|
15936
|
+
}
|
|
15937
|
+
|
|
15938
|
+
// Apply any `formatters` transformations
|
|
15939
|
+
let index = 0;
|
|
15940
|
+
args[0] = args[0].replace(/%([a-zA-Z%])/g, (match, format) => {
|
|
15941
|
+
// If we encounter an escaped % then don't increase the array index
|
|
15942
|
+
if (match === '%%') {
|
|
15943
|
+
return '%';
|
|
15944
|
+
}
|
|
15945
|
+
index++;
|
|
15946
|
+
const formatter = createDebug.formatters[format];
|
|
15947
|
+
if (typeof formatter === 'function') {
|
|
15948
|
+
const val = args[index];
|
|
15949
|
+
match = formatter.call(self, val);
|
|
15950
|
+
|
|
15951
|
+
// Now we need to remove `args[index]` since it's inlined in the `format`
|
|
15952
|
+
args.splice(index, 1);
|
|
15953
|
+
index--;
|
|
15954
|
+
}
|
|
15955
|
+
return match;
|
|
15956
|
+
});
|
|
15957
|
+
|
|
15958
|
+
// Apply env-specific formatting (colors, etc.)
|
|
15959
|
+
createDebug.formatArgs.call(self, args);
|
|
15960
|
+
|
|
15961
|
+
const logFn = self.log || createDebug.log;
|
|
15962
|
+
logFn.apply(self, args);
|
|
15963
|
+
}
|
|
15964
|
+
|
|
15965
|
+
debug.namespace = namespace;
|
|
15966
|
+
debug.useColors = createDebug.useColors();
|
|
15967
|
+
debug.color = createDebug.selectColor(namespace);
|
|
15968
|
+
debug.extend = extend;
|
|
15969
|
+
debug.destroy = createDebug.destroy; // XXX Temporary. Will be removed in the next major release.
|
|
15970
|
+
|
|
15971
|
+
Object.defineProperty(debug, 'enabled', {
|
|
15972
|
+
enumerable: true,
|
|
15973
|
+
configurable: false,
|
|
15974
|
+
get: () => {
|
|
15975
|
+
if (enableOverride !== null) {
|
|
15976
|
+
return enableOverride;
|
|
15977
|
+
}
|
|
15978
|
+
if (namespacesCache !== createDebug.namespaces) {
|
|
15979
|
+
namespacesCache = createDebug.namespaces;
|
|
15980
|
+
enabledCache = createDebug.enabled(namespace);
|
|
15981
|
+
}
|
|
15982
|
+
|
|
15983
|
+
return enabledCache;
|
|
15984
|
+
},
|
|
15985
|
+
set: v => {
|
|
15986
|
+
enableOverride = v;
|
|
15987
|
+
}
|
|
15988
|
+
});
|
|
15989
|
+
|
|
15990
|
+
// Env-specific initialization logic for debug instances
|
|
15991
|
+
if (typeof createDebug.init === 'function') {
|
|
15992
|
+
createDebug.init(debug);
|
|
15993
|
+
}
|
|
15994
|
+
|
|
15995
|
+
return debug;
|
|
15996
|
+
}
|
|
15997
|
+
|
|
15998
|
+
function extend(namespace, delimiter) {
|
|
15999
|
+
const newDebug = createDebug(this.namespace + (typeof delimiter === 'undefined' ? ':' : delimiter) + namespace);
|
|
16000
|
+
newDebug.log = this.log;
|
|
16001
|
+
return newDebug;
|
|
16002
|
+
}
|
|
16003
|
+
|
|
16004
|
+
/**
|
|
16005
|
+
* Enables a debug mode by namespaces. This can include modes
|
|
16006
|
+
* separated by a colon and wildcards.
|
|
16007
|
+
*
|
|
16008
|
+
* @param {String} namespaces
|
|
16009
|
+
* @api public
|
|
16010
|
+
*/
|
|
16011
|
+
function enable(namespaces) {
|
|
16012
|
+
createDebug.save(namespaces);
|
|
16013
|
+
createDebug.namespaces = namespaces;
|
|
16014
|
+
|
|
16015
|
+
createDebug.names = [];
|
|
16016
|
+
createDebug.skips = [];
|
|
16017
|
+
|
|
16018
|
+
let i;
|
|
16019
|
+
const split = (typeof namespaces === 'string' ? namespaces : '').split(/[\s,]+/);
|
|
16020
|
+
const len = split.length;
|
|
16021
|
+
|
|
16022
|
+
for (i = 0; i < len; i++) {
|
|
16023
|
+
if (!split[i]) {
|
|
16024
|
+
// ignore empty strings
|
|
16025
|
+
continue;
|
|
16026
|
+
}
|
|
16027
|
+
|
|
16028
|
+
namespaces = split[i].replace(/\*/g, '.*?');
|
|
16029
|
+
|
|
16030
|
+
if (namespaces[0] === '-') {
|
|
16031
|
+
createDebug.skips.push(new RegExp('^' + namespaces.slice(1) + '$'));
|
|
16032
|
+
} else {
|
|
16033
|
+
createDebug.names.push(new RegExp('^' + namespaces + '$'));
|
|
16034
|
+
}
|
|
16035
|
+
}
|
|
16036
|
+
}
|
|
16037
|
+
|
|
16038
|
+
/**
|
|
16039
|
+
* Disable debug output.
|
|
16040
|
+
*
|
|
16041
|
+
* @return {String} namespaces
|
|
16042
|
+
* @api public
|
|
16043
|
+
*/
|
|
16044
|
+
function disable() {
|
|
16045
|
+
const namespaces = [
|
|
16046
|
+
...createDebug.names.map(toNamespace),
|
|
16047
|
+
...createDebug.skips.map(toNamespace).map(namespace => '-' + namespace)
|
|
16048
|
+
].join(',');
|
|
16049
|
+
createDebug.enable('');
|
|
16050
|
+
return namespaces;
|
|
16051
|
+
}
|
|
16052
|
+
|
|
16053
|
+
/**
|
|
16054
|
+
* Returns true if the given mode name is enabled, false otherwise.
|
|
16055
|
+
*
|
|
16056
|
+
* @param {String} name
|
|
16057
|
+
* @return {Boolean}
|
|
16058
|
+
* @api public
|
|
16059
|
+
*/
|
|
16060
|
+
function enabled(name) {
|
|
16061
|
+
if (name[name.length - 1] === '*') {
|
|
16062
|
+
return true;
|
|
16063
|
+
}
|
|
16064
|
+
|
|
16065
|
+
let i;
|
|
16066
|
+
let len;
|
|
16067
|
+
|
|
16068
|
+
for (i = 0, len = createDebug.skips.length; i < len; i++) {
|
|
16069
|
+
if (createDebug.skips[i].test(name)) {
|
|
16070
|
+
return false;
|
|
16071
|
+
}
|
|
16072
|
+
}
|
|
16073
|
+
|
|
16074
|
+
for (i = 0, len = createDebug.names.length; i < len; i++) {
|
|
16075
|
+
if (createDebug.names[i].test(name)) {
|
|
16076
|
+
return true;
|
|
16077
|
+
}
|
|
16078
|
+
}
|
|
16079
|
+
|
|
16080
|
+
return false;
|
|
16081
|
+
}
|
|
16082
|
+
|
|
16083
|
+
/**
|
|
16084
|
+
* Convert regexp to namespace
|
|
16085
|
+
*
|
|
16086
|
+
* @param {RegExp} regxep
|
|
16087
|
+
* @return {String} namespace
|
|
16088
|
+
* @api private
|
|
16089
|
+
*/
|
|
16090
|
+
function toNamespace(regexp) {
|
|
16091
|
+
return regexp.toString()
|
|
16092
|
+
.substring(2, regexp.toString().length - 2)
|
|
16093
|
+
.replace(/\.\*\?$/, '*');
|
|
16094
|
+
}
|
|
16095
|
+
|
|
16096
|
+
/**
|
|
16097
|
+
* Coerce `val`.
|
|
16098
|
+
*
|
|
16099
|
+
* @param {Mixed} val
|
|
16100
|
+
* @return {Mixed}
|
|
16101
|
+
* @api private
|
|
16102
|
+
*/
|
|
16103
|
+
function coerce(val) {
|
|
16104
|
+
if (val instanceof Error) {
|
|
16105
|
+
return val.stack || val.message;
|
|
16106
|
+
}
|
|
16107
|
+
return val;
|
|
16108
|
+
}
|
|
16109
|
+
|
|
16110
|
+
/**
|
|
16111
|
+
* XXX DO NOT USE. This is a temporary stub function.
|
|
16112
|
+
* XXX It WILL be removed in the next major release.
|
|
16113
|
+
*/
|
|
16114
|
+
function destroy() {
|
|
16115
|
+
console.warn('Instance method `debug.destroy()` is deprecated and no longer does anything. It will be removed in the next major version of `debug`.');
|
|
16116
|
+
}
|
|
16117
|
+
|
|
16118
|
+
createDebug.enable(createDebug.load());
|
|
16119
|
+
|
|
16120
|
+
return createDebug;
|
|
16121
|
+
}
|
|
16122
|
+
|
|
16123
|
+
common = setup;
|
|
16124
|
+
return common;
|
|
16125
|
+
}
|
|
16126
|
+
|
|
16127
|
+
/* eslint-env browser */
|
|
16128
|
+
|
|
16129
|
+
var hasRequiredBrowser;
|
|
16130
|
+
|
|
16131
|
+
function requireBrowser () {
|
|
16132
|
+
if (hasRequiredBrowser) return browser.exports;
|
|
16133
|
+
hasRequiredBrowser = 1;
|
|
16134
|
+
(function (module, exports) {
|
|
16135
|
+
/**
|
|
16136
|
+
* This is the web browser implementation of `debug()`.
|
|
16137
|
+
*/
|
|
16138
|
+
|
|
16139
|
+
exports.formatArgs = formatArgs;
|
|
16140
|
+
exports.save = save;
|
|
16141
|
+
exports.load = load;
|
|
16142
|
+
exports.useColors = useColors;
|
|
16143
|
+
exports.storage = localstorage();
|
|
16144
|
+
exports.destroy = (() => {
|
|
16145
|
+
let warned = false;
|
|
16146
|
+
|
|
16147
|
+
return () => {
|
|
16148
|
+
if (!warned) {
|
|
16149
|
+
warned = true;
|
|
16150
|
+
console.warn('Instance method `debug.destroy()` is deprecated and no longer does anything. It will be removed in the next major version of `debug`.');
|
|
16151
|
+
}
|
|
16152
|
+
};
|
|
16153
|
+
})();
|
|
16154
|
+
|
|
16155
|
+
/**
|
|
16156
|
+
* Colors.
|
|
16157
|
+
*/
|
|
16158
|
+
|
|
16159
|
+
exports.colors = [
|
|
16160
|
+
'#0000CC',
|
|
16161
|
+
'#0000FF',
|
|
16162
|
+
'#0033CC',
|
|
16163
|
+
'#0033FF',
|
|
16164
|
+
'#0066CC',
|
|
16165
|
+
'#0066FF',
|
|
16166
|
+
'#0099CC',
|
|
16167
|
+
'#0099FF',
|
|
16168
|
+
'#00CC00',
|
|
16169
|
+
'#00CC33',
|
|
16170
|
+
'#00CC66',
|
|
16171
|
+
'#00CC99',
|
|
16172
|
+
'#00CCCC',
|
|
16173
|
+
'#00CCFF',
|
|
16174
|
+
'#3300CC',
|
|
16175
|
+
'#3300FF',
|
|
16176
|
+
'#3333CC',
|
|
16177
|
+
'#3333FF',
|
|
16178
|
+
'#3366CC',
|
|
16179
|
+
'#3366FF',
|
|
16180
|
+
'#3399CC',
|
|
16181
|
+
'#3399FF',
|
|
16182
|
+
'#33CC00',
|
|
16183
|
+
'#33CC33',
|
|
16184
|
+
'#33CC66',
|
|
16185
|
+
'#33CC99',
|
|
16186
|
+
'#33CCCC',
|
|
16187
|
+
'#33CCFF',
|
|
16188
|
+
'#6600CC',
|
|
16189
|
+
'#6600FF',
|
|
16190
|
+
'#6633CC',
|
|
16191
|
+
'#6633FF',
|
|
16192
|
+
'#66CC00',
|
|
16193
|
+
'#66CC33',
|
|
16194
|
+
'#9900CC',
|
|
16195
|
+
'#9900FF',
|
|
16196
|
+
'#9933CC',
|
|
16197
|
+
'#9933FF',
|
|
16198
|
+
'#99CC00',
|
|
16199
|
+
'#99CC33',
|
|
16200
|
+
'#CC0000',
|
|
16201
|
+
'#CC0033',
|
|
16202
|
+
'#CC0066',
|
|
16203
|
+
'#CC0099',
|
|
16204
|
+
'#CC00CC',
|
|
16205
|
+
'#CC00FF',
|
|
16206
|
+
'#CC3300',
|
|
16207
|
+
'#CC3333',
|
|
16208
|
+
'#CC3366',
|
|
16209
|
+
'#CC3399',
|
|
16210
|
+
'#CC33CC',
|
|
16211
|
+
'#CC33FF',
|
|
16212
|
+
'#CC6600',
|
|
16213
|
+
'#CC6633',
|
|
16214
|
+
'#CC9900',
|
|
16215
|
+
'#CC9933',
|
|
16216
|
+
'#CCCC00',
|
|
16217
|
+
'#CCCC33',
|
|
16218
|
+
'#FF0000',
|
|
16219
|
+
'#FF0033',
|
|
16220
|
+
'#FF0066',
|
|
16221
|
+
'#FF0099',
|
|
16222
|
+
'#FF00CC',
|
|
16223
|
+
'#FF00FF',
|
|
16224
|
+
'#FF3300',
|
|
16225
|
+
'#FF3333',
|
|
16226
|
+
'#FF3366',
|
|
16227
|
+
'#FF3399',
|
|
16228
|
+
'#FF33CC',
|
|
16229
|
+
'#FF33FF',
|
|
16230
|
+
'#FF6600',
|
|
16231
|
+
'#FF6633',
|
|
16232
|
+
'#FF9900',
|
|
16233
|
+
'#FF9933',
|
|
16234
|
+
'#FFCC00',
|
|
16235
|
+
'#FFCC33'
|
|
16236
|
+
];
|
|
16237
|
+
|
|
16238
|
+
/**
|
|
16239
|
+
* Currently only WebKit-based Web Inspectors, Firefox >= v31,
|
|
16240
|
+
* and the Firebug extension (any Firefox version) are known
|
|
16241
|
+
* to support "%c" CSS customizations.
|
|
16242
|
+
*
|
|
16243
|
+
* TODO: add a `localStorage` variable to explicitly enable/disable colors
|
|
16244
|
+
*/
|
|
16245
|
+
|
|
16246
|
+
// eslint-disable-next-line complexity
|
|
16247
|
+
function useColors() {
|
|
16248
|
+
// NB: In an Electron preload script, document will be defined but not fully
|
|
16249
|
+
// initialized. Since we know we're in Chrome, we'll just detect this case
|
|
16250
|
+
// explicitly
|
|
16251
|
+
if (typeof window !== 'undefined' && window.process && (window.process.type === 'renderer' || window.process.__nwjs)) {
|
|
16252
|
+
return true;
|
|
16253
|
+
}
|
|
16254
|
+
|
|
16255
|
+
// Internet Explorer and Edge do not support colors.
|
|
16256
|
+
if (typeof navigator !== 'undefined' && navigator.userAgent && navigator.userAgent.toLowerCase().match(/(edge|trident)\/(\d+)/)) {
|
|
16257
|
+
return false;
|
|
16258
|
+
}
|
|
16259
|
+
|
|
16260
|
+
let m;
|
|
16261
|
+
|
|
16262
|
+
// Is webkit? http://stackoverflow.com/a/16459606/376773
|
|
16263
|
+
// document is undefined in react-native: https://github.com/facebook/react-native/pull/1632
|
|
16264
|
+
return (typeof document !== 'undefined' && document.documentElement && document.documentElement.style && document.documentElement.style.WebkitAppearance) ||
|
|
16265
|
+
// Is firebug? http://stackoverflow.com/a/398120/376773
|
|
16266
|
+
(typeof window !== 'undefined' && window.console && (window.console.firebug || (window.console.exception && window.console.table))) ||
|
|
16267
|
+
// Is firefox >= v31?
|
|
16268
|
+
// https://developer.mozilla.org/en-US/docs/Tools/Web_Console#Styling_messages
|
|
16269
|
+
(typeof navigator !== 'undefined' && navigator.userAgent && (m = navigator.userAgent.toLowerCase().match(/firefox\/(\d+)/)) && parseInt(m[1], 10) >= 31) ||
|
|
16270
|
+
// Double check webkit in userAgent just in case we are in a worker
|
|
16271
|
+
(typeof navigator !== 'undefined' && navigator.userAgent && navigator.userAgent.toLowerCase().match(/applewebkit\/(\d+)/));
|
|
16272
|
+
}
|
|
16273
|
+
|
|
16274
|
+
/**
|
|
16275
|
+
* Colorize log arguments if enabled.
|
|
16276
|
+
*
|
|
16277
|
+
* @api public
|
|
16278
|
+
*/
|
|
16279
|
+
|
|
16280
|
+
function formatArgs(args) {
|
|
16281
|
+
args[0] = (this.useColors ? '%c' : '') +
|
|
16282
|
+
this.namespace +
|
|
16283
|
+
(this.useColors ? ' %c' : ' ') +
|
|
16284
|
+
args[0] +
|
|
16285
|
+
(this.useColors ? '%c ' : ' ') +
|
|
16286
|
+
'+' + module.exports.humanize(this.diff);
|
|
16287
|
+
|
|
16288
|
+
if (!this.useColors) {
|
|
16289
|
+
return;
|
|
16290
|
+
}
|
|
16291
|
+
|
|
16292
|
+
const c = 'color: ' + this.color;
|
|
16293
|
+
args.splice(1, 0, c, 'color: inherit');
|
|
16294
|
+
|
|
16295
|
+
// The final "%c" is somewhat tricky, because there could be other
|
|
16296
|
+
// arguments passed either before or after the %c, so we need to
|
|
16297
|
+
// figure out the correct index to insert the CSS into
|
|
16298
|
+
let index = 0;
|
|
16299
|
+
let lastC = 0;
|
|
16300
|
+
args[0].replace(/%[a-zA-Z%]/g, match => {
|
|
16301
|
+
if (match === '%%') {
|
|
16302
|
+
return;
|
|
16303
|
+
}
|
|
16304
|
+
index++;
|
|
16305
|
+
if (match === '%c') {
|
|
16306
|
+
// We only are interested in the *last* %c
|
|
16307
|
+
// (the user may have provided their own)
|
|
16308
|
+
lastC = index;
|
|
16309
|
+
}
|
|
16310
|
+
});
|
|
16311
|
+
|
|
16312
|
+
args.splice(lastC, 0, c);
|
|
16313
|
+
}
|
|
16314
|
+
|
|
16315
|
+
/**
|
|
16316
|
+
* Invokes `console.debug()` when available.
|
|
16317
|
+
* No-op when `console.debug` is not a "function".
|
|
16318
|
+
* If `console.debug` is not available, falls back
|
|
16319
|
+
* to `console.log`.
|
|
16320
|
+
*
|
|
16321
|
+
* @api public
|
|
16322
|
+
*/
|
|
16323
|
+
exports.log = console.debug || console.log || (() => {});
|
|
16324
|
+
|
|
16325
|
+
/**
|
|
16326
|
+
* Save `namespaces`.
|
|
16327
|
+
*
|
|
16328
|
+
* @param {String} namespaces
|
|
16329
|
+
* @api private
|
|
16330
|
+
*/
|
|
16331
|
+
function save(namespaces) {
|
|
16332
|
+
try {
|
|
16333
|
+
if (namespaces) {
|
|
16334
|
+
exports.storage.setItem('debug', namespaces);
|
|
16335
|
+
} else {
|
|
16336
|
+
exports.storage.removeItem('debug');
|
|
16337
|
+
}
|
|
16338
|
+
} catch (error) {
|
|
16339
|
+
// Swallow
|
|
16340
|
+
// XXX (@Qix-) should we be logging these?
|
|
16341
|
+
}
|
|
16342
|
+
}
|
|
16343
|
+
|
|
16344
|
+
/**
|
|
16345
|
+
* Load `namespaces`.
|
|
16346
|
+
*
|
|
16347
|
+
* @return {String} returns the previously persisted debug modes
|
|
16348
|
+
* @api private
|
|
16349
|
+
*/
|
|
16350
|
+
function load() {
|
|
16351
|
+
let r;
|
|
16352
|
+
try {
|
|
16353
|
+
r = exports.storage.getItem('debug');
|
|
16354
|
+
} catch (error) {
|
|
16355
|
+
// Swallow
|
|
16356
|
+
// XXX (@Qix-) should we be logging these?
|
|
16357
|
+
}
|
|
16358
|
+
|
|
16359
|
+
// If debug isn't set in LS, and we're in Electron, try to load $DEBUG
|
|
16360
|
+
if (!r && typeof process !== 'undefined' && 'env' in process) {
|
|
16361
|
+
r = process.env.DEBUG;
|
|
16362
|
+
}
|
|
16363
|
+
|
|
16364
|
+
return r;
|
|
16365
|
+
}
|
|
16366
|
+
|
|
16367
|
+
/**
|
|
16368
|
+
* Localstorage attempts to return the localstorage.
|
|
16369
|
+
*
|
|
16370
|
+
* This is necessary because safari throws
|
|
16371
|
+
* when a user disables cookies/localstorage
|
|
16372
|
+
* and you attempt to access it.
|
|
16373
|
+
*
|
|
16374
|
+
* @return {LocalStorage}
|
|
16375
|
+
* @api private
|
|
16376
|
+
*/
|
|
16377
|
+
|
|
16378
|
+
function localstorage() {
|
|
16379
|
+
try {
|
|
16380
|
+
// TVMLKit (Apple TV JS Runtime) does not have a window object, just localStorage in the global context
|
|
16381
|
+
// The Browser also has localStorage in the global context.
|
|
16382
|
+
return localStorage;
|
|
16383
|
+
} catch (error) {
|
|
16384
|
+
// Swallow
|
|
16385
|
+
// XXX (@Qix-) should we be logging these?
|
|
16386
|
+
}
|
|
16387
|
+
}
|
|
16388
|
+
|
|
16389
|
+
module.exports = requireCommon()(exports);
|
|
16390
|
+
|
|
16391
|
+
const {formatters} = module.exports;
|
|
16392
|
+
|
|
16393
|
+
/**
|
|
16394
|
+
* Map %j to `JSON.stringify()`, since no Web Inspectors do that by default.
|
|
16395
|
+
*/
|
|
16396
|
+
|
|
16397
|
+
formatters.j = function (v) {
|
|
16398
|
+
try {
|
|
16399
|
+
return JSON.stringify(v);
|
|
16400
|
+
} catch (error) {
|
|
16401
|
+
return '[UnexpectedJSONParseError]: ' + error.message;
|
|
16402
|
+
}
|
|
16403
|
+
};
|
|
16404
|
+
} (browser, browser.exports));
|
|
16405
|
+
return browser.exports;
|
|
16406
|
+
}
|
|
16407
|
+
|
|
16408
|
+
var node = {exports: {}};
|
|
16409
|
+
|
|
16410
|
+
var hasFlag;
|
|
16411
|
+
var hasRequiredHasFlag;
|
|
16412
|
+
|
|
16413
|
+
function requireHasFlag () {
|
|
16414
|
+
if (hasRequiredHasFlag) return hasFlag;
|
|
16415
|
+
hasRequiredHasFlag = 1;
|
|
16416
|
+
|
|
16417
|
+
hasFlag = (flag, argv = process.argv) => {
|
|
16418
|
+
const prefix = flag.startsWith('-') ? '' : (flag.length === 1 ? '-' : '--');
|
|
16419
|
+
const position = argv.indexOf(prefix + flag);
|
|
16420
|
+
const terminatorPosition = argv.indexOf('--');
|
|
16421
|
+
return position !== -1 && (terminatorPosition === -1 || position < terminatorPosition);
|
|
16422
|
+
};
|
|
16423
|
+
return hasFlag;
|
|
16424
|
+
}
|
|
16425
|
+
|
|
16426
|
+
var supportsColor_1;
|
|
16427
|
+
var hasRequiredSupportsColor;
|
|
16428
|
+
|
|
16429
|
+
function requireSupportsColor () {
|
|
16430
|
+
if (hasRequiredSupportsColor) return supportsColor_1;
|
|
16431
|
+
hasRequiredSupportsColor = 1;
|
|
16432
|
+
const os = require$$0$2;
|
|
16433
|
+
const tty = require$$1$1;
|
|
16434
|
+
const hasFlag = requireHasFlag();
|
|
16435
|
+
|
|
16436
|
+
const {env} = process;
|
|
16437
|
+
|
|
16438
|
+
let forceColor;
|
|
16439
|
+
if (hasFlag('no-color') ||
|
|
16440
|
+
hasFlag('no-colors') ||
|
|
16441
|
+
hasFlag('color=false') ||
|
|
16442
|
+
hasFlag('color=never')) {
|
|
16443
|
+
forceColor = 0;
|
|
16444
|
+
} else if (hasFlag('color') ||
|
|
16445
|
+
hasFlag('colors') ||
|
|
16446
|
+
hasFlag('color=true') ||
|
|
16447
|
+
hasFlag('color=always')) {
|
|
16448
|
+
forceColor = 1;
|
|
16449
|
+
}
|
|
16450
|
+
|
|
16451
|
+
if ('FORCE_COLOR' in env) {
|
|
16452
|
+
if (env.FORCE_COLOR === 'true') {
|
|
16453
|
+
forceColor = 1;
|
|
16454
|
+
} else if (env.FORCE_COLOR === 'false') {
|
|
16455
|
+
forceColor = 0;
|
|
16456
|
+
} else {
|
|
16457
|
+
forceColor = env.FORCE_COLOR.length === 0 ? 1 : Math.min(parseInt(env.FORCE_COLOR, 10), 3);
|
|
16458
|
+
}
|
|
16459
|
+
}
|
|
16460
|
+
|
|
16461
|
+
function translateLevel(level) {
|
|
16462
|
+
if (level === 0) {
|
|
16463
|
+
return false;
|
|
16464
|
+
}
|
|
16465
|
+
|
|
16466
|
+
return {
|
|
16467
|
+
level,
|
|
16468
|
+
hasBasic: true,
|
|
16469
|
+
has256: level >= 2,
|
|
16470
|
+
has16m: level >= 3
|
|
16471
|
+
};
|
|
16472
|
+
}
|
|
16473
|
+
|
|
16474
|
+
function supportsColor(haveStream, streamIsTTY) {
|
|
16475
|
+
if (forceColor === 0) {
|
|
16476
|
+
return 0;
|
|
16477
|
+
}
|
|
16478
|
+
|
|
16479
|
+
if (hasFlag('color=16m') ||
|
|
16480
|
+
hasFlag('color=full') ||
|
|
16481
|
+
hasFlag('color=truecolor')) {
|
|
16482
|
+
return 3;
|
|
16483
|
+
}
|
|
16484
|
+
|
|
16485
|
+
if (hasFlag('color=256')) {
|
|
16486
|
+
return 2;
|
|
16487
|
+
}
|
|
16488
|
+
|
|
16489
|
+
if (haveStream && !streamIsTTY && forceColor === undefined) {
|
|
16490
|
+
return 0;
|
|
16491
|
+
}
|
|
16492
|
+
|
|
16493
|
+
const min = forceColor || 0;
|
|
16494
|
+
|
|
16495
|
+
if (env.TERM === 'dumb') {
|
|
16496
|
+
return min;
|
|
16497
|
+
}
|
|
16498
|
+
|
|
16499
|
+
if (process.platform === 'win32') {
|
|
16500
|
+
// Windows 10 build 10586 is the first Windows release that supports 256 colors.
|
|
16501
|
+
// Windows 10 build 14931 is the first release that supports 16m/TrueColor.
|
|
16502
|
+
const osRelease = os.release().split('.');
|
|
16503
|
+
if (
|
|
16504
|
+
Number(osRelease[0]) >= 10 &&
|
|
16505
|
+
Number(osRelease[2]) >= 10586
|
|
16506
|
+
) {
|
|
16507
|
+
return Number(osRelease[2]) >= 14931 ? 3 : 2;
|
|
16508
|
+
}
|
|
16509
|
+
|
|
16510
|
+
return 1;
|
|
16511
|
+
}
|
|
16512
|
+
|
|
16513
|
+
if ('CI' in env) {
|
|
16514
|
+
if (['TRAVIS', 'CIRCLECI', 'APPVEYOR', 'GITLAB_CI', 'GITHUB_ACTIONS', 'BUILDKITE'].some(sign => sign in env) || env.CI_NAME === 'codeship') {
|
|
16515
|
+
return 1;
|
|
16516
|
+
}
|
|
16517
|
+
|
|
16518
|
+
return min;
|
|
16519
|
+
}
|
|
16520
|
+
|
|
16521
|
+
if ('TEAMCITY_VERSION' in env) {
|
|
16522
|
+
return /^(9\.(0*[1-9]\d*)\.|\d{2,}\.)/.test(env.TEAMCITY_VERSION) ? 1 : 0;
|
|
16523
|
+
}
|
|
16524
|
+
|
|
16525
|
+
if (env.COLORTERM === 'truecolor') {
|
|
16526
|
+
return 3;
|
|
16527
|
+
}
|
|
16528
|
+
|
|
16529
|
+
if ('TERM_PROGRAM' in env) {
|
|
16530
|
+
const version = parseInt((env.TERM_PROGRAM_VERSION || '').split('.')[0], 10);
|
|
16531
|
+
|
|
16532
|
+
switch (env.TERM_PROGRAM) {
|
|
16533
|
+
case 'iTerm.app':
|
|
16534
|
+
return version >= 3 ? 3 : 2;
|
|
16535
|
+
case 'Apple_Terminal':
|
|
16536
|
+
return 2;
|
|
16537
|
+
// No default
|
|
16538
|
+
}
|
|
16539
|
+
}
|
|
16540
|
+
|
|
16541
|
+
if (/-256(color)?$/i.test(env.TERM)) {
|
|
16542
|
+
return 2;
|
|
16543
|
+
}
|
|
16544
|
+
|
|
16545
|
+
if (/^screen|^xterm|^vt100|^vt220|^rxvt|color|ansi|cygwin|linux/i.test(env.TERM)) {
|
|
16546
|
+
return 1;
|
|
16547
|
+
}
|
|
16548
|
+
|
|
16549
|
+
if ('COLORTERM' in env) {
|
|
16550
|
+
return 1;
|
|
16551
|
+
}
|
|
16552
|
+
|
|
16553
|
+
return min;
|
|
16554
|
+
}
|
|
16555
|
+
|
|
16556
|
+
function getSupportLevel(stream) {
|
|
16557
|
+
const level = supportsColor(stream, stream && stream.isTTY);
|
|
16558
|
+
return translateLevel(level);
|
|
16559
|
+
}
|
|
16560
|
+
|
|
16561
|
+
supportsColor_1 = {
|
|
16562
|
+
supportsColor: getSupportLevel,
|
|
16563
|
+
stdout: translateLevel(supportsColor(true, tty.isatty(1))),
|
|
16564
|
+
stderr: translateLevel(supportsColor(true, tty.isatty(2)))
|
|
16565
|
+
};
|
|
16566
|
+
return supportsColor_1;
|
|
16567
|
+
}
|
|
16568
|
+
|
|
16569
|
+
/**
|
|
16570
|
+
* Module dependencies.
|
|
16571
|
+
*/
|
|
16572
|
+
|
|
16573
|
+
var hasRequiredNode;
|
|
16574
|
+
|
|
16575
|
+
function requireNode () {
|
|
16576
|
+
if (hasRequiredNode) return node.exports;
|
|
16577
|
+
hasRequiredNode = 1;
|
|
16578
|
+
(function (module, exports) {
|
|
16579
|
+
const tty = require$$1$1;
|
|
16580
|
+
const util = require$$1;
|
|
16581
|
+
|
|
16582
|
+
/**
|
|
16583
|
+
* This is the Node.js implementation of `debug()`.
|
|
16584
|
+
*/
|
|
16585
|
+
|
|
16586
|
+
exports.init = init;
|
|
16587
|
+
exports.log = log;
|
|
16588
|
+
exports.formatArgs = formatArgs;
|
|
16589
|
+
exports.save = save;
|
|
16590
|
+
exports.load = load;
|
|
16591
|
+
exports.useColors = useColors;
|
|
16592
|
+
exports.destroy = util.deprecate(
|
|
16593
|
+
() => {},
|
|
16594
|
+
'Instance method `debug.destroy()` is deprecated and no longer does anything. It will be removed in the next major version of `debug`.'
|
|
16595
|
+
);
|
|
16596
|
+
|
|
16597
|
+
/**
|
|
16598
|
+
* Colors.
|
|
16599
|
+
*/
|
|
16600
|
+
|
|
16601
|
+
exports.colors = [6, 2, 3, 4, 5, 1];
|
|
16602
|
+
|
|
16603
|
+
try {
|
|
16604
|
+
// Optional dependency (as in, doesn't need to be installed, NOT like optionalDependencies in package.json)
|
|
16605
|
+
// eslint-disable-next-line import/no-extraneous-dependencies
|
|
16606
|
+
const supportsColor = requireSupportsColor();
|
|
16607
|
+
|
|
16608
|
+
if (supportsColor && (supportsColor.stderr || supportsColor).level >= 2) {
|
|
16609
|
+
exports.colors = [
|
|
16610
|
+
20,
|
|
16611
|
+
21,
|
|
16612
|
+
26,
|
|
16613
|
+
27,
|
|
16614
|
+
32,
|
|
16615
|
+
33,
|
|
16616
|
+
38,
|
|
16617
|
+
39,
|
|
16618
|
+
40,
|
|
16619
|
+
41,
|
|
16620
|
+
42,
|
|
16621
|
+
43,
|
|
16622
|
+
44,
|
|
16623
|
+
45,
|
|
16624
|
+
56,
|
|
16625
|
+
57,
|
|
16626
|
+
62,
|
|
16627
|
+
63,
|
|
16628
|
+
68,
|
|
16629
|
+
69,
|
|
16630
|
+
74,
|
|
16631
|
+
75,
|
|
16632
|
+
76,
|
|
16633
|
+
77,
|
|
16634
|
+
78,
|
|
16635
|
+
79,
|
|
16636
|
+
80,
|
|
16637
|
+
81,
|
|
16638
|
+
92,
|
|
16639
|
+
93,
|
|
16640
|
+
98,
|
|
16641
|
+
99,
|
|
16642
|
+
112,
|
|
16643
|
+
113,
|
|
16644
|
+
128,
|
|
16645
|
+
129,
|
|
16646
|
+
134,
|
|
16647
|
+
135,
|
|
16648
|
+
148,
|
|
16649
|
+
149,
|
|
16650
|
+
160,
|
|
16651
|
+
161,
|
|
16652
|
+
162,
|
|
16653
|
+
163,
|
|
16654
|
+
164,
|
|
16655
|
+
165,
|
|
16656
|
+
166,
|
|
16657
|
+
167,
|
|
16658
|
+
168,
|
|
16659
|
+
169,
|
|
16660
|
+
170,
|
|
16661
|
+
171,
|
|
16662
|
+
172,
|
|
16663
|
+
173,
|
|
16664
|
+
178,
|
|
16665
|
+
179,
|
|
16666
|
+
184,
|
|
16667
|
+
185,
|
|
16668
|
+
196,
|
|
16669
|
+
197,
|
|
16670
|
+
198,
|
|
16671
|
+
199,
|
|
16672
|
+
200,
|
|
16673
|
+
201,
|
|
16674
|
+
202,
|
|
16675
|
+
203,
|
|
16676
|
+
204,
|
|
16677
|
+
205,
|
|
16678
|
+
206,
|
|
16679
|
+
207,
|
|
16680
|
+
208,
|
|
16681
|
+
209,
|
|
16682
|
+
214,
|
|
16683
|
+
215,
|
|
16684
|
+
220,
|
|
16685
|
+
221
|
|
16686
|
+
];
|
|
16687
|
+
}
|
|
16688
|
+
} catch (error) {
|
|
16689
|
+
// Swallow - we only care if `supports-color` is available; it doesn't have to be.
|
|
16690
|
+
}
|
|
16691
|
+
|
|
16692
|
+
/**
|
|
16693
|
+
* Build up the default `inspectOpts` object from the environment variables.
|
|
16694
|
+
*
|
|
16695
|
+
* $ DEBUG_COLORS=no DEBUG_DEPTH=10 DEBUG_SHOW_HIDDEN=enabled node script.js
|
|
16696
|
+
*/
|
|
16697
|
+
|
|
16698
|
+
exports.inspectOpts = Object.keys(process.env).filter(key => {
|
|
16699
|
+
return /^debug_/i.test(key);
|
|
16700
|
+
}).reduce((obj, key) => {
|
|
16701
|
+
// Camel-case
|
|
16702
|
+
const prop = key
|
|
16703
|
+
.substring(6)
|
|
16704
|
+
.toLowerCase()
|
|
16705
|
+
.replace(/_([a-z])/g, (_, k) => {
|
|
16706
|
+
return k.toUpperCase();
|
|
16707
|
+
});
|
|
16708
|
+
|
|
16709
|
+
// Coerce string value into JS value
|
|
16710
|
+
let val = process.env[key];
|
|
16711
|
+
if (/^(yes|on|true|enabled)$/i.test(val)) {
|
|
16712
|
+
val = true;
|
|
16713
|
+
} else if (/^(no|off|false|disabled)$/i.test(val)) {
|
|
16714
|
+
val = false;
|
|
16715
|
+
} else if (val === 'null') {
|
|
16716
|
+
val = null;
|
|
16717
|
+
} else {
|
|
16718
|
+
val = Number(val);
|
|
16719
|
+
}
|
|
16720
|
+
|
|
16721
|
+
obj[prop] = val;
|
|
16722
|
+
return obj;
|
|
16723
|
+
}, {});
|
|
16724
|
+
|
|
16725
|
+
/**
|
|
16726
|
+
* Is stdout a TTY? Colored output is enabled when `true`.
|
|
16727
|
+
*/
|
|
16728
|
+
|
|
16729
|
+
function useColors() {
|
|
16730
|
+
return 'colors' in exports.inspectOpts ?
|
|
16731
|
+
Boolean(exports.inspectOpts.colors) :
|
|
16732
|
+
tty.isatty(process.stderr.fd);
|
|
16733
|
+
}
|
|
16734
|
+
|
|
16735
|
+
/**
|
|
16736
|
+
* Adds ANSI color escape codes if enabled.
|
|
16737
|
+
*
|
|
16738
|
+
* @api public
|
|
16739
|
+
*/
|
|
16740
|
+
|
|
16741
|
+
function formatArgs(args) {
|
|
16742
|
+
const {namespace: name, useColors} = this;
|
|
16743
|
+
|
|
16744
|
+
if (useColors) {
|
|
16745
|
+
const c = this.color;
|
|
16746
|
+
const colorCode = '\u001B[3' + (c < 8 ? c : '8;5;' + c);
|
|
16747
|
+
const prefix = ` ${colorCode};1m${name} \u001B[0m`;
|
|
16748
|
+
|
|
16749
|
+
args[0] = prefix + args[0].split('\n').join('\n' + prefix);
|
|
16750
|
+
args.push(colorCode + 'm+' + module.exports.humanize(this.diff) + '\u001B[0m');
|
|
16751
|
+
} else {
|
|
16752
|
+
args[0] = getDate() + name + ' ' + args[0];
|
|
16753
|
+
}
|
|
16754
|
+
}
|
|
16755
|
+
|
|
16756
|
+
function getDate() {
|
|
16757
|
+
if (exports.inspectOpts.hideDate) {
|
|
16758
|
+
return '';
|
|
16759
|
+
}
|
|
16760
|
+
return new Date().toISOString() + ' ';
|
|
16761
|
+
}
|
|
16762
|
+
|
|
16763
|
+
/**
|
|
16764
|
+
* Invokes `util.formatWithOptions()` with the specified arguments and writes to stderr.
|
|
16765
|
+
*/
|
|
16766
|
+
|
|
16767
|
+
function log(...args) {
|
|
16768
|
+
return process.stderr.write(util.formatWithOptions(exports.inspectOpts, ...args) + '\n');
|
|
16769
|
+
}
|
|
16770
|
+
|
|
16771
|
+
/**
|
|
16772
|
+
* Save `namespaces`.
|
|
16773
|
+
*
|
|
16774
|
+
* @param {String} namespaces
|
|
16775
|
+
* @api private
|
|
16776
|
+
*/
|
|
16777
|
+
function save(namespaces) {
|
|
16778
|
+
if (namespaces) {
|
|
16779
|
+
process.env.DEBUG = namespaces;
|
|
16780
|
+
} else {
|
|
16781
|
+
// If you set a process.env field to null or undefined, it gets cast to the
|
|
16782
|
+
// string 'null' or 'undefined'. Just delete instead.
|
|
16783
|
+
delete process.env.DEBUG;
|
|
16784
|
+
}
|
|
16785
|
+
}
|
|
16786
|
+
|
|
16787
|
+
/**
|
|
16788
|
+
* Load `namespaces`.
|
|
16789
|
+
*
|
|
16790
|
+
* @return {String} returns the previously persisted debug modes
|
|
16791
|
+
* @api private
|
|
16792
|
+
*/
|
|
16793
|
+
|
|
16794
|
+
function load() {
|
|
16795
|
+
return process.env.DEBUG;
|
|
16796
|
+
}
|
|
16797
|
+
|
|
16798
|
+
/**
|
|
16799
|
+
* Init logic for `debug` instances.
|
|
16800
|
+
*
|
|
16801
|
+
* Create a new `inspectOpts` object in case `useColors` is set
|
|
16802
|
+
* differently for a particular `debug` instance.
|
|
16803
|
+
*/
|
|
16804
|
+
|
|
16805
|
+
function init(debug) {
|
|
16806
|
+
debug.inspectOpts = {};
|
|
16807
|
+
|
|
16808
|
+
const keys = Object.keys(exports.inspectOpts);
|
|
16809
|
+
for (let i = 0; i < keys.length; i++) {
|
|
16810
|
+
debug.inspectOpts[keys[i]] = exports.inspectOpts[keys[i]];
|
|
16811
|
+
}
|
|
16812
|
+
}
|
|
16813
|
+
|
|
16814
|
+
module.exports = requireCommon()(exports);
|
|
16815
|
+
|
|
16816
|
+
const {formatters} = module.exports;
|
|
16817
|
+
|
|
16818
|
+
/**
|
|
16819
|
+
* Map %o to `util.inspect()`, all on a single line.
|
|
16820
|
+
*/
|
|
16821
|
+
|
|
16822
|
+
formatters.o = function (v) {
|
|
16823
|
+
this.inspectOpts.colors = this.useColors;
|
|
16824
|
+
return util.inspect(v, this.inspectOpts)
|
|
16825
|
+
.split('\n')
|
|
16826
|
+
.map(str => str.trim())
|
|
16827
|
+
.join(' ');
|
|
16828
|
+
};
|
|
16829
|
+
|
|
16830
|
+
/**
|
|
16831
|
+
* Map %O to `util.inspect()`, allowing multiple lines if needed.
|
|
16832
|
+
*/
|
|
16833
|
+
|
|
16834
|
+
formatters.O = function (v) {
|
|
16835
|
+
this.inspectOpts.colors = this.useColors;
|
|
16836
|
+
return util.inspect(v, this.inspectOpts);
|
|
16837
|
+
};
|
|
16838
|
+
} (node, node.exports));
|
|
16839
|
+
return node.exports;
|
|
16840
|
+
}
|
|
16841
|
+
|
|
16842
|
+
/**
|
|
16843
|
+
* Detect Electron renderer / nwjs process, which is node, but we should
|
|
16844
|
+
* treat as a browser.
|
|
16845
|
+
*/
|
|
16846
|
+
|
|
16847
|
+
var hasRequiredSrc;
|
|
16848
|
+
|
|
16849
|
+
function requireSrc () {
|
|
16850
|
+
if (hasRequiredSrc) return src.exports;
|
|
16851
|
+
hasRequiredSrc = 1;
|
|
16852
|
+
if (typeof process === 'undefined' || process.type === 'renderer' || process.browser === true || process.__nwjs) {
|
|
16853
|
+
src.exports = requireBrowser();
|
|
16854
|
+
} else {
|
|
16855
|
+
src.exports = requireNode();
|
|
16856
|
+
}
|
|
16857
|
+
return src.exports;
|
|
16858
|
+
}
|
|
16859
|
+
|
|
15632
16860
|
var debug_1;
|
|
15633
16861
|
var hasRequiredDebug;
|
|
15634
16862
|
|
|
@@ -15641,7 +16869,7 @@ function requireDebug () {
|
|
|
15641
16869
|
if (!debug) {
|
|
15642
16870
|
try {
|
|
15643
16871
|
/* eslint global-require: off */
|
|
15644
|
-
debug =
|
|
16872
|
+
debug = requireSrc()("follow-redirects");
|
|
15645
16873
|
}
|
|
15646
16874
|
catch (error) { /* */ }
|
|
15647
16875
|
if (typeof debug !== "function") {
|
|
@@ -19031,9 +20259,30 @@ const {
|
|
|
19031
20259
|
mergeConfig
|
|
19032
20260
|
} = axios;
|
|
19033
20261
|
|
|
20262
|
+
const LOG_DIR = '/home/log';
|
|
20263
|
+
const LOG_FILE = path.join(LOG_DIR, 'calls.log');
|
|
20264
|
+
async function ensureLogDir() {
|
|
20265
|
+
await require$$6.promises.mkdir(LOG_DIR, { recursive: true });
|
|
20266
|
+
}
|
|
20267
|
+
function formatCallLogLine(serviceName, url, method, status, elapsedMs) {
|
|
20268
|
+
const ts = new Date().toISOString();
|
|
20269
|
+
return `${ts} | ${serviceName} | ${method.toUpperCase()} ${url} | Status=${status} | Elapsed=${elapsedMs}ms\n`;
|
|
20270
|
+
}
|
|
20271
|
+
async function appendCallLog(serviceName, url, method, status, elapsedMs) {
|
|
20272
|
+
try {
|
|
20273
|
+
await ensureLogDir();
|
|
20274
|
+
const line = formatCallLogLine(serviceName, url, method, status, elapsedMs);
|
|
20275
|
+
await require$$6.promises.appendFile(LOG_FILE, line, { encoding: 'utf8' });
|
|
20276
|
+
}
|
|
20277
|
+
catch (err) {
|
|
20278
|
+
console.error('❌ Failed to write call log:', err);
|
|
20279
|
+
}
|
|
20280
|
+
}
|
|
20281
|
+
|
|
19034
20282
|
async function callService(serviceName, options = {}) {
|
|
19035
|
-
var _a, _b, _c, _d;
|
|
20283
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k;
|
|
19036
20284
|
const { method = 'GET', path = '/', data, headers, params, } = options;
|
|
20285
|
+
const start = Date.now();
|
|
19037
20286
|
try {
|
|
19038
20287
|
const instance = await getRandomServiceInstance(serviceName);
|
|
19039
20288
|
const url = `http://${instance.ServiceAddress}:${instance.ServicePort}${path}`;
|
|
@@ -19044,15 +20293,22 @@ async function callService(serviceName, options = {}) {
|
|
|
19044
20293
|
headers,
|
|
19045
20294
|
params,
|
|
19046
20295
|
});
|
|
20296
|
+
const elapsed = Date.now() - start;
|
|
20297
|
+
// 📌 سجل نجاح الكول
|
|
20298
|
+
await appendCallLog(serviceName, url, method, response.status, elapsed);
|
|
19047
20299
|
return response.data;
|
|
19048
20300
|
}
|
|
19049
20301
|
catch (error) {
|
|
20302
|
+
const elapsed = Date.now() - start;
|
|
20303
|
+
// 📌 سجل الفشل كمان
|
|
20304
|
+
const status = (_b = (_a = error.response) === null || _a === void 0 ? void 0 : _a.status) !== null && _b !== void 0 ? _b : 0;
|
|
20305
|
+
await appendCallLog(serviceName, (_d = (_c = error.config) === null || _c === void 0 ? void 0 : _c.url) !== null && _d !== void 0 ? _d : '', (_f = (_e = error.config) === null || _e === void 0 ? void 0 : _e.method) !== null && _f !== void 0 ? _f : method, status, elapsed);
|
|
19050
20306
|
return {
|
|
19051
20307
|
success: false,
|
|
19052
20308
|
message: error.message,
|
|
19053
|
-
status
|
|
19054
|
-
code: (
|
|
19055
|
-
data: (
|
|
20309
|
+
status,
|
|
20310
|
+
code: (_j = (_h = (_g = error.response) === null || _g === void 0 ? void 0 : _g.data) === null || _h === void 0 ? void 0 : _h.code) !== null && _j !== void 0 ? _j : "",
|
|
20311
|
+
data: (_k = error.response) === null || _k === void 0 ? void 0 : _k.data,
|
|
19056
20312
|
};
|
|
19057
20313
|
}
|
|
19058
20314
|
}
|