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