@rsdoctor/utils 1.2.2 → 1.2.4-beta.0
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/compiled/connect/index.d.ts +90 -0
- package/compiled/connect/index.js +2427 -0
- package/compiled/connect/license +25 -0
- package/compiled/connect/package.json +1 -0
- package/compiled/filesize/index.d.ts +58 -0
- package/compiled/filesize/index.js +255 -0
- package/compiled/filesize/license +28 -0
- package/compiled/filesize/package.json +1 -0
- package/dist/{type/build → build}/envinfo.d.ts +0 -1
- package/dist/{type/build → build}/file/cache.d.ts +0 -1
- package/dist/build/file/index.d.ts +3 -0
- package/dist/{type/build → build}/file/sharding.d.ts +0 -1
- package/dist/{type/build → build}/index.d.ts +0 -1
- package/dist/{type/build → build}/json.d.ts +0 -1
- package/dist/{type/build → build}/process.d.ts +0 -1
- package/dist/{type/build → build}/server.d.ts +0 -1
- package/dist/build.cjs +1310 -0
- package/dist/build.js +343 -0
- package/dist/{type/common → common}/alerts.d.ts +0 -1
- package/dist/{type/common → common}/algorithm.d.ts +0 -1
- package/dist/{type/common → common}/bundle.d.ts +0 -1
- package/dist/{type/common → common}/crypto.d.ts +0 -1
- package/dist/{type/common → common}/data/index.d.ts +0 -1
- package/dist/{type/common → common}/file.d.ts +0 -1
- package/dist/{type/common → common}/global-config.d.ts +0 -1
- package/dist/{type/common → common}/graph/assets.d.ts +0 -1
- package/dist/{type/common → common}/graph/chunk.d.ts +0 -1
- package/dist/{type/common → common}/graph/dependency.d.ts +0 -1
- package/dist/{type/common → common}/graph/entrypoints.d.ts +0 -1
- package/dist/{type/common → common}/graph/index.d.ts +0 -1
- package/dist/{type/common → common}/graph/modules.d.ts +0 -1
- package/dist/{type/common → common}/index.d.ts +0 -1
- package/dist/{type/common → common}/loader.d.ts +0 -1
- package/dist/{type/common → common}/lodash.d.ts +0 -1
- package/dist/{type/common → common}/manifest.d.ts +0 -1
- package/dist/{type/common → common}/package.d.ts +0 -1
- package/dist/{type/common → common}/plugin.d.ts +0 -1
- package/dist/{type/common → common}/resolver.d.ts +0 -1
- package/dist/{type/common → common}/rspack.d.ts +0 -1
- package/dist/{type/common → common}/summary.d.ts +0 -1
- package/dist/{type/common → common}/time.d.ts +0 -1
- package/dist/{type/common → common}/url.d.ts +0 -1
- package/dist/common.cjs +1328 -0
- package/dist/common.js +1255 -0
- package/dist/{type/error → error}/error.d.ts +0 -1
- package/dist/{type/error → error}/index.d.ts +0 -1
- package/dist/{type/error → error}/transform.d.ts +0 -1
- package/dist/{type/error → error}/utils.d.ts +0 -1
- package/dist/error.cjs +310 -0
- package/dist/error.js +232 -0
- package/dist/logger.cjs +82 -0
- package/dist/{type/logger.d.ts → logger.d.ts} +0 -1
- package/dist/{esm/logger.mjs → logger.js} +8 -13
- package/dist/{type/rule-utils → rule-utils}/document/document.d.ts +0 -1
- package/dist/{type/rule-utils → rule-utils}/document/index.d.ts +0 -1
- package/dist/{type/rule-utils → rule-utils}/document/server.d.ts +0 -1
- package/dist/{type/rule-utils → rule-utils}/document/types.d.ts +0 -1
- package/dist/{type/rule-utils → rule-utils}/index.d.ts +0 -1
- package/dist/{type/rule-utils → rule-utils}/parser/asserts.d.ts +0 -1
- package/dist/{type/rule-utils → rule-utils}/parser/index.d.ts +0 -1
- package/dist/{type/rule-utils → rule-utils}/parser/parser.d.ts +0 -1
- package/dist/{type/rule-utils → rule-utils}/parser/types.d.ts +0 -1
- package/dist/{type/rule-utils → rule-utils}/parser/utils.d.ts +0 -1
- package/dist/ruleUtils.cjs +320 -0
- package/dist/ruleUtils.js +256 -0
- package/package.json +35 -39
- package/dist/cjs/build/envinfo.js +0 -121
- package/dist/cjs/build/file/cache.js +0 -76
- package/dist/cjs/build/file/index.js +0 -81
- package/dist/cjs/build/file/sharding.js +0 -96
- package/dist/cjs/build/index.js +0 -52
- package/dist/cjs/build/json.js +0 -103
- package/dist/cjs/build/process.js +0 -54
- package/dist/cjs/build/server.js +0 -158
- package/dist/cjs/common/alerts.js +0 -51
- package/dist/cjs/common/algorithm.js +0 -75
- package/dist/cjs/common/bundle.js +0 -62
- package/dist/cjs/common/crypto.js +0 -54
- package/dist/cjs/common/data/index.js +0 -396
- package/dist/cjs/common/file.js +0 -44
- package/dist/cjs/common/global-config.js +0 -81
- package/dist/cjs/common/graph/assets.js +0 -314
- package/dist/cjs/common/graph/chunk.js +0 -81
- package/dist/cjs/common/graph/dependency.js +0 -50
- package/dist/cjs/common/graph/entrypoints.js +0 -38
- package/dist/cjs/common/graph/index.js +0 -96
- package/dist/cjs/common/graph/modules.js +0 -133
- package/dist/cjs/common/index.js +0 -104
- package/dist/cjs/common/loader.js +0 -320
- package/dist/cjs/common/lodash.js +0 -93
- package/dist/cjs/common/manifest.js +0 -70
- package/dist/cjs/common/package.js +0 -96
- package/dist/cjs/common/plugin.js +0 -91
- package/dist/cjs/common/resolver.js +0 -92
- package/dist/cjs/common/rspack.js +0 -65
- package/dist/cjs/common/summary.js +0 -42
- package/dist/cjs/common/time.js +0 -86
- package/dist/cjs/common/url.js +0 -54
- package/dist/cjs/error/error.js +0 -199
- package/dist/cjs/error/index.js +0 -73
- package/dist/cjs/error/transform.js +0 -182
- package/dist/cjs/error/utils.js +0 -62
- package/dist/cjs/index.js +0 -40
- package/dist/cjs/logger.js +0 -106
- package/dist/cjs/rule-utils/document/document.js +0 -92
- package/dist/cjs/rule-utils/document/index.js +0 -78
- package/dist/cjs/rule-utils/document/server.js +0 -49
- package/dist/cjs/rule-utils/document/types.js +0 -18
- package/dist/cjs/rule-utils/index.js +0 -69
- package/dist/cjs/rule-utils/parser/asserts.js +0 -138
- package/dist/cjs/rule-utils/parser/index.js +0 -87
- package/dist/cjs/rule-utils/parser/parser.js +0 -57
- package/dist/cjs/rule-utils/parser/types.js +0 -41
- package/dist/cjs/rule-utils/parser/utils.js +0 -170
- package/dist/esm/build/envinfo.mjs +0 -57
- package/dist/esm/build/file/cache.mjs +0 -23
- package/dist/esm/build/file/index.mjs +0 -4
- package/dist/esm/build/file/sharding.mjs +0 -50
- package/dist/esm/build/index.mjs +0 -6
- package/dist/esm/build/json.mjs +0 -66
- package/dist/esm/build/process.mjs +0 -17
- package/dist/esm/build/server.mjs +0 -96
- package/dist/esm/common/alerts.mjs +0 -17
- package/dist/esm/common/algorithm.mjs +0 -32
- package/dist/esm/common/bundle.mjs +0 -22
- package/dist/esm/common/crypto.mjs +0 -17
- package/dist/esm/common/data/index.mjs +0 -362
- package/dist/esm/common/file.mjs +0 -7
- package/dist/esm/common/global-config.mjs +0 -32
- package/dist/esm/common/graph/assets.mjs +0 -238
- package/dist/esm/common/graph/chunk.mjs +0 -32
- package/dist/esm/common/graph/dependency.mjs +0 -10
- package/dist/esm/common/graph/entrypoints.mjs +0 -4
- package/dist/esm/common/graph/index.mjs +0 -5
- package/dist/esm/common/graph/modules.mjs +0 -78
- package/dist/esm/common/index.mjs +0 -19
- package/dist/esm/common/loader.mjs +0 -247
- package/dist/esm/common/lodash.mjs +0 -32
- package/dist/esm/common/manifest.mjs +0 -30
- package/dist/esm/common/package.mjs +0 -56
- package/dist/esm/common/plugin.mjs +0 -48
- package/dist/esm/common/resolver.mjs +0 -46
- package/dist/esm/common/rspack.mjs +0 -25
- package/dist/esm/common/summary.mjs +0 -8
- package/dist/esm/common/time.mjs +0 -43
- package/dist/esm/common/url.mjs +0 -14
- package/dist/esm/error/error.mjs +0 -154
- package/dist/esm/error/index.mjs +0 -3
- package/dist/esm/error/transform.mjs +0 -138
- package/dist/esm/error/utils.mjs +0 -22
- package/dist/esm/index.mjs +0 -3
- package/dist/esm/rule-utils/document/document.mjs +0 -58
- package/dist/esm/rule-utils/document/index.mjs +0 -3
- package/dist/esm/rule-utils/document/server.mjs +0 -12
- package/dist/esm/rule-utils/document/types.mjs +0 -0
- package/dist/esm/rule-utils/index.mjs +0 -2
- package/dist/esm/rule-utils/parser/asserts.mjs +0 -104
- package/dist/esm/rule-utils/parser/index.mjs +0 -4
- package/dist/esm/rule-utils/parser/parser.mjs +0 -23
- package/dist/esm/rule-utils/parser/types.mjs +0 -7
- package/dist/esm/rule-utils/parser/utils.mjs +0 -109
- package/dist/type/build/envinfo.d.ts.map +0 -1
- package/dist/type/build/file/cache.d.ts.map +0 -1
- package/dist/type/build/file/index.d.ts +0 -4
- package/dist/type/build/file/index.d.ts.map +0 -1
- package/dist/type/build/file/sharding.d.ts.map +0 -1
- package/dist/type/build/index.d.ts.map +0 -1
- package/dist/type/build/json.d.ts.map +0 -1
- package/dist/type/build/process.d.ts.map +0 -1
- package/dist/type/build/server.d.ts.map +0 -1
- package/dist/type/common/alerts.d.ts.map +0 -1
- package/dist/type/common/algorithm.d.ts.map +0 -1
- package/dist/type/common/bundle.d.ts.map +0 -1
- package/dist/type/common/crypto.d.ts.map +0 -1
- package/dist/type/common/data/index.d.ts.map +0 -1
- package/dist/type/common/file.d.ts.map +0 -1
- package/dist/type/common/global-config.d.ts.map +0 -1
- package/dist/type/common/graph/assets.d.ts.map +0 -1
- package/dist/type/common/graph/chunk.d.ts.map +0 -1
- package/dist/type/common/graph/dependency.d.ts.map +0 -1
- package/dist/type/common/graph/entrypoints.d.ts.map +0 -1
- package/dist/type/common/graph/index.d.ts.map +0 -1
- package/dist/type/common/graph/modules.d.ts.map +0 -1
- package/dist/type/common/index.d.ts.map +0 -1
- package/dist/type/common/loader.d.ts.map +0 -1
- package/dist/type/common/lodash.d.ts.map +0 -1
- package/dist/type/common/manifest.d.ts.map +0 -1
- package/dist/type/common/package.d.ts.map +0 -1
- package/dist/type/common/plugin.d.ts.map +0 -1
- package/dist/type/common/resolver.d.ts.map +0 -1
- package/dist/type/common/rspack.d.ts.map +0 -1
- package/dist/type/common/summary.d.ts.map +0 -1
- package/dist/type/common/time.d.ts.map +0 -1
- package/dist/type/common/url.d.ts.map +0 -1
- package/dist/type/error/error.d.ts.map +0 -1
- package/dist/type/error/index.d.ts.map +0 -1
- package/dist/type/error/transform.d.ts.map +0 -1
- package/dist/type/error/utils.d.ts.map +0 -1
- package/dist/type/index.d.ts +0 -3
- package/dist/type/index.d.ts.map +0 -1
- package/dist/type/logger.d.ts.map +0 -1
- package/dist/type/rule-utils/document/document.d.ts.map +0 -1
- package/dist/type/rule-utils/document/index.d.ts.map +0 -1
- package/dist/type/rule-utils/document/server.d.ts.map +0 -1
- package/dist/type/rule-utils/document/types.d.ts.map +0 -1
- package/dist/type/rule-utils/index.d.ts.map +0 -1
- package/dist/type/rule-utils/parser/asserts.d.ts.map +0 -1
- package/dist/type/rule-utils/parser/index.d.ts.map +0 -1
- package/dist/type/rule-utils/parser/parser.d.ts.map +0 -1
- package/dist/type/rule-utils/parser/types.d.ts.map +0 -1
- package/dist/type/rule-utils/parser/utils.d.ts.map +0 -1
package/dist/build.cjs
ADDED
|
@@ -0,0 +1,1310 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
let __rslib_import_meta_url__ = 'undefined' == typeof document ? new (require('url'.replace('', ''))).URL('file:' + __filename).href : document.currentScript && document.currentScript.src || new URL('main.js', document.baseURI).href;
|
|
3
|
+
var __webpack_require__ = {};
|
|
4
|
+
__webpack_require__.n = (module)=>{
|
|
5
|
+
var getter = module && module.__esModule ? ()=>module.default : ()=>module;
|
|
6
|
+
return __webpack_require__.d(getter, {
|
|
7
|
+
a: getter
|
|
8
|
+
}), getter;
|
|
9
|
+
}, __webpack_require__.d = (exports1, definition)=>{
|
|
10
|
+
for(var key in definition)__webpack_require__.o(definition, key) && !__webpack_require__.o(exports1, key) && Object.defineProperty(exports1, key, {
|
|
11
|
+
enumerable: !0,
|
|
12
|
+
get: definition[key]
|
|
13
|
+
});
|
|
14
|
+
}, __webpack_require__.o = (obj, prop)=>Object.prototype.hasOwnProperty.call(obj, prop), __webpack_require__.r = (exports1)=>{
|
|
15
|
+
'undefined' != typeof Symbol && Symbol.toStringTag && Object.defineProperty(exports1, Symbol.toStringTag, {
|
|
16
|
+
value: 'Module'
|
|
17
|
+
}), Object.defineProperty(exports1, '__esModule', {
|
|
18
|
+
value: !0
|
|
19
|
+
});
|
|
20
|
+
};
|
|
21
|
+
var __webpack_exports__ = {};
|
|
22
|
+
__webpack_require__.r(__webpack_exports__), __webpack_require__.d(__webpack_exports__, {
|
|
23
|
+
Server: ()=>server_namespaceObject,
|
|
24
|
+
File: ()=>file_namespaceObject,
|
|
25
|
+
Json: ()=>json_namespaceObject,
|
|
26
|
+
EnvInfo: ()=>envinfo_namespaceObject,
|
|
27
|
+
Process: ()=>process_namespaceObject
|
|
28
|
+
});
|
|
29
|
+
var cache_namespaceObject = {};
|
|
30
|
+
__webpack_require__.r(cache_namespaceObject), __webpack_require__.d(cache_namespaceObject, {
|
|
31
|
+
readFile: ()=>cache_readFile,
|
|
32
|
+
readFileSync: ()=>readFileSync,
|
|
33
|
+
readJSON: ()=>readJSON,
|
|
34
|
+
readJSONSync: ()=>readJSONSync
|
|
35
|
+
});
|
|
36
|
+
var file_namespaceObject = {};
|
|
37
|
+
__webpack_require__.r(file_namespaceObject), __webpack_require__.d(file_namespaceObject, {
|
|
38
|
+
FileSharding: ()=>FileSharding,
|
|
39
|
+
cache: ()=>cache_namespaceObject,
|
|
40
|
+
fse: ()=>esm_namespaceObject
|
|
41
|
+
});
|
|
42
|
+
var json_namespaceObject = {};
|
|
43
|
+
__webpack_require__.r(json_namespaceObject), __webpack_require__.d(json_namespaceObject, {
|
|
44
|
+
readPackageJson: ()=>readPackageJson,
|
|
45
|
+
stringify: ()=>stringify
|
|
46
|
+
});
|
|
47
|
+
var server_namespaceObject = {};
|
|
48
|
+
__webpack_require__.r(server_namespaceObject), __webpack_require__.d(server_namespaceObject, {
|
|
49
|
+
createApp: ()=>createApp,
|
|
50
|
+
createGetPortSyncFunctionString: ()=>createGetPortSyncFunctionString,
|
|
51
|
+
createServer: ()=>createServer,
|
|
52
|
+
defaultPort: ()=>defaultPort,
|
|
53
|
+
getPort: ()=>getPort,
|
|
54
|
+
getPortSync: ()=>getPortSync
|
|
55
|
+
});
|
|
56
|
+
var envinfo_namespaceObject = {};
|
|
57
|
+
__webpack_require__.r(envinfo_namespaceObject), __webpack_require__.d(envinfo_namespaceObject, {
|
|
58
|
+
getCPUInfo: ()=>getCPUInfo,
|
|
59
|
+
getGitBranch: ()=>getGitBranch,
|
|
60
|
+
getGitRepo: ()=>getGitRepo,
|
|
61
|
+
getGlobalNpmPackageVersion: ()=>getGlobalNpmPackageVersion,
|
|
62
|
+
getMemoryInfo: ()=>getMemoryInfo,
|
|
63
|
+
getNodeVersion: ()=>getNodeVersion,
|
|
64
|
+
getNpmPackageVersion: ()=>getNpmPackageVersion,
|
|
65
|
+
getNpmVersion: ()=>getNpmVersion,
|
|
66
|
+
getOSInfo: ()=>getOSInfo,
|
|
67
|
+
getPnpmVersion: ()=>getPnpmVersion,
|
|
68
|
+
getYarnVersion: ()=>getYarnVersion
|
|
69
|
+
});
|
|
70
|
+
var process_namespaceObject = {};
|
|
71
|
+
__webpack_require__.r(process_namespaceObject), __webpack_require__.d(process_namespaceObject, {
|
|
72
|
+
getMemoryUsage: ()=>getMemoryUsage,
|
|
73
|
+
getMemoryUsageMessage: ()=>getMemoryUsageMessage
|
|
74
|
+
});
|
|
75
|
+
let external_fs_extra_namespaceObject = require("fs-extra");
|
|
76
|
+
var external_fs_extra_default = __webpack_require__.n(external_fs_extra_namespaceObject);
|
|
77
|
+
let external_fs_namespaceObject = require("fs");
|
|
78
|
+
var external_fs_default = __webpack_require__.n(external_fs_namespaceObject);
|
|
79
|
+
let external_path_namespaceObject = require("path");
|
|
80
|
+
var external_path_default = __webpack_require__.n(external_path_namespaceObject);
|
|
81
|
+
class FileSharding {
|
|
82
|
+
content;
|
|
83
|
+
limitBytes;
|
|
84
|
+
encoding;
|
|
85
|
+
constructor(content, limitBytes = 10485760, encoding = 'utf-8'){
|
|
86
|
+
this.content = content, this.limitBytes = limitBytes, this.encoding = encoding;
|
|
87
|
+
}
|
|
88
|
+
createVirtualShardingFiles(ext = '', index = 0) {
|
|
89
|
+
let bf = Buffer.from(this.content, this.encoding), res = [], threshold = this.limitBytes, tmpBytes = 0;
|
|
90
|
+
for(; bf.byteLength > tmpBytes;)res.push(bf.subarray(tmpBytes, tmpBytes + threshold)), tmpBytes += threshold;
|
|
91
|
+
return res.map((e, i)=>({
|
|
92
|
+
filename: `${i + index}${ext}`,
|
|
93
|
+
content: e
|
|
94
|
+
}));
|
|
95
|
+
}
|
|
96
|
+
async writeStringToFolder(folder, ext = '', index) {
|
|
97
|
+
let dist = external_path_default().resolve(folder);
|
|
98
|
+
await external_fs_extra_default().ensureDir(dist);
|
|
99
|
+
let res = this.createVirtualShardingFiles(ext, index);
|
|
100
|
+
return await Promise.all(res.map((e)=>new Promise((resolve, reject)=>{
|
|
101
|
+
let stream = external_fs_default().createWriteStream(external_path_default().join(dist, e.filename), this.encoding);
|
|
102
|
+
stream.end(e.content), stream.once('close', ()=>resolve(void 0)), stream.once('error', (err)=>reject(err));
|
|
103
|
+
}))), res;
|
|
104
|
+
}
|
|
105
|
+
}
|
|
106
|
+
let esm_namespaceObject = require("fs-extra/esm"), external_node_fs_namespaceObject = require("node:fs");
|
|
107
|
+
var external_node_fs_default = __webpack_require__.n(external_node_fs_namespaceObject);
|
|
108
|
+
let cache = new Map();
|
|
109
|
+
async function cache_readFile(path1) {
|
|
110
|
+
if (cache.has(path1)) return cache.get(path1);
|
|
111
|
+
let res = await external_node_fs_default().promises.readFile(path1, 'utf-8');
|
|
112
|
+
return cache.set(path1, res), res;
|
|
113
|
+
}
|
|
114
|
+
function readFileSync(path1) {
|
|
115
|
+
if (cache.has(path1)) return cache.get(path1);
|
|
116
|
+
let res = external_node_fs_default().readFileSync(path1, 'utf-8');
|
|
117
|
+
return cache.set(path1, res), res;
|
|
118
|
+
}
|
|
119
|
+
async function readJSON(path1) {
|
|
120
|
+
return JSON.parse(await cache_readFile(path1));
|
|
121
|
+
}
|
|
122
|
+
function readJSONSync(path1) {
|
|
123
|
+
return JSON.parse(readFileSync(path1));
|
|
124
|
+
}
|
|
125
|
+
let external_json_stream_stringify_namespaceObject = require("json-stream-stringify"), external_zlib_namespaceObject = require("zlib"), external_buffer_namespaceObject = require("buffer"), external_picocolors_namespaceObject = require("picocolors");
|
|
126
|
+
var external_picocolors_default = __webpack_require__.n(external_picocolors_namespaceObject);
|
|
127
|
+
let external_rslog_namespaceObject = require("rslog"), types_namespaceObject = require("@rsdoctor/types");
|
|
128
|
+
function debug(getMsg, prefix = '') {
|
|
129
|
+
process.env.DEBUG && (logger.level = 'verbose', logger.debug(`${prefix} ${getMsg()}`));
|
|
130
|
+
}
|
|
131
|
+
let rsdoctorLogger = (0, external_rslog_namespaceObject.createLogger)();
|
|
132
|
+
rsdoctorLogger.override({
|
|
133
|
+
log: (message)=>{
|
|
134
|
+
console.log(`${external_picocolors_default().green('[RSDOCTOR LOG]')} ${message}`);
|
|
135
|
+
},
|
|
136
|
+
info: (message)=>{
|
|
137
|
+
console.log(`${external_picocolors_default().yellow('[RSDOCTOR INFO]')} ${message}`);
|
|
138
|
+
},
|
|
139
|
+
warn: (message)=>{
|
|
140
|
+
console.warn(`${external_picocolors_default().yellow('[RSDOCTOR WARN]')} ${message}`);
|
|
141
|
+
},
|
|
142
|
+
start: (message)=>{
|
|
143
|
+
console.log(`${external_picocolors_default().green('[RSDOCTOR START]')} ${message}`);
|
|
144
|
+
},
|
|
145
|
+
ready: (message)=>{
|
|
146
|
+
console.log(`${external_picocolors_default().green('[RSDOCTOR READY]')} ${message}`);
|
|
147
|
+
},
|
|
148
|
+
error: (message)=>{
|
|
149
|
+
console.error(`${external_picocolors_default().red('[RSDOCTOR ERROR]')} ${message}`);
|
|
150
|
+
},
|
|
151
|
+
success: (message)=>{
|
|
152
|
+
console.error(`${external_picocolors_default().green('[RSDOCTOR SUCCESS]')} ${message}`);
|
|
153
|
+
},
|
|
154
|
+
debug: (message)=>{
|
|
155
|
+
process.env.DEBUG && console.log(`${external_picocolors_default().blue('[RSDOCTOR DEBUG]')} ${message}`);
|
|
156
|
+
}
|
|
157
|
+
});
|
|
158
|
+
let _timers = new Map();
|
|
159
|
+
function time(label) {
|
|
160
|
+
process.env.DEBUG === Constants.RsdoctorProcessEnvDebugKey && (_timers.has(label) || _timers.set(label, Date.now()));
|
|
161
|
+
}
|
|
162
|
+
function timeEnd(label) {
|
|
163
|
+
if (process.env.DEBUG !== Constants.RsdoctorProcessEnvDebugKey) return;
|
|
164
|
+
let start = _timers.get(label);
|
|
165
|
+
if (null == start) return void logger.debug(`Timer '${label}' does not exist.`);
|
|
166
|
+
let duration = Date.now() - start;
|
|
167
|
+
logger.debug(`Timer '${label}' ended: ${duration}ms`), _timers.delete(label);
|
|
168
|
+
}
|
|
169
|
+
function algorithm_mergeIntervals(intervals) {
|
|
170
|
+
let previous, current;
|
|
171
|
+
intervals.sort((a, b)=>a[0] - b[0]);
|
|
172
|
+
let result = [];
|
|
173
|
+
for(let i = 0; i < intervals.length; i++)current = intervals[i], !previous || current[0] > previous[1] ? (previous = current, result.push(current)) : previous[1] = Math.max(previous[1], current[1]);
|
|
174
|
+
return result;
|
|
175
|
+
}
|
|
176
|
+
function compressText(input) {
|
|
177
|
+
try {
|
|
178
|
+
return deflateSync(input).toString('base64');
|
|
179
|
+
} catch (e) {
|
|
180
|
+
return logger.debug(`compressText error: ${e}`), '';
|
|
181
|
+
}
|
|
182
|
+
}
|
|
183
|
+
function algorithm_decompressText(input) {
|
|
184
|
+
return inflateSync(Buffer.from(input, 'base64')).toString();
|
|
185
|
+
}
|
|
186
|
+
function random(min, max) {
|
|
187
|
+
return Math.floor(Math.random() * (max - min + 1) + min);
|
|
188
|
+
}
|
|
189
|
+
function isUrl(uri) {
|
|
190
|
+
return /^https?:\/\//.test(uri);
|
|
191
|
+
}
|
|
192
|
+
function isFilePath(uri) {
|
|
193
|
+
return isAbsolute(uri);
|
|
194
|
+
}
|
|
195
|
+
function url_isRemoteUrl(uri) {
|
|
196
|
+
return !!('string' == typeof uri && (isUrl(uri) || isFilePath(uri)));
|
|
197
|
+
}
|
|
198
|
+
function isShardingData(data) {
|
|
199
|
+
return !!(Array.isArray(data) && data.length > 0 && data.every((e)=>isRemoteUrl(e)));
|
|
200
|
+
}
|
|
201
|
+
async function fetchShardingData(shardingFiles, fetchImplement) {
|
|
202
|
+
let res = await Promise.all(shardingFiles.map((url)=>fetchImplement(url))), strings = 0 === res.length ? [] : res.reduce((t, e)=>t + e);
|
|
203
|
+
return 'object' == typeof strings ? strings : JSON.parse(decompressText(strings));
|
|
204
|
+
}
|
|
205
|
+
async function fetchShardingFiles(data, fetchImplement, filterKeys) {
|
|
206
|
+
return (await Promise.all(Object.keys(data).map(async (_key)=>{
|
|
207
|
+
let val = data[_key];
|
|
208
|
+
return filterKeys?.length && 0 > filterKeys.indexOf(_key) ? {
|
|
209
|
+
[_key]: []
|
|
210
|
+
} : isShardingData(val) ? {
|
|
211
|
+
[_key]: await fetchShardingData(val, fetchImplement)
|
|
212
|
+
} : {
|
|
213
|
+
[_key]: val
|
|
214
|
+
};
|
|
215
|
+
}))).reduce((t, c)=>Object.assign(t, c));
|
|
216
|
+
}
|
|
217
|
+
function findLoaderTotalTiming(loaders) {
|
|
218
|
+
let start = 1 / 0, end = -1 / 0;
|
|
219
|
+
for(let i = 0; i < loaders.length; i++){
|
|
220
|
+
let loader = loaders[i];
|
|
221
|
+
loader.startAt <= start && (start = loader.startAt), loader.endAt >= end && (end = loader.endAt);
|
|
222
|
+
}
|
|
223
|
+
return {
|
|
224
|
+
start,
|
|
225
|
+
end
|
|
226
|
+
};
|
|
227
|
+
}
|
|
228
|
+
function getLoadersCosts(filter, loaders) {
|
|
229
|
+
let match = {}, others = {};
|
|
230
|
+
loaders.forEach((e)=>{
|
|
231
|
+
filter(e) ? (match[e.pid] || (match[e.pid] = []), match[e.pid].push([
|
|
232
|
+
e.startAt,
|
|
233
|
+
e.endAt
|
|
234
|
+
])) : (others[e.pid] || (others[e.pid] = []), others[e.pid].push([
|
|
235
|
+
e.startAt,
|
|
236
|
+
e.endAt
|
|
237
|
+
]));
|
|
238
|
+
});
|
|
239
|
+
let costs = 0, pids = Object.keys(match);
|
|
240
|
+
for(let i = 0; i < pids.length; i++){
|
|
241
|
+
let pid = pids[i], _match = mergeIntervals(match[pid]), _others = mergeIntervals(others[pid] || []).filter(([s, e])=>_match.some((el)=>s >= el[0] && e <= el[1]));
|
|
242
|
+
costs += (_match.length ? _match.reduce((t, c)=>t += c[1] - c[0], 0) : 0) - (_others.length ? _others.reduce((t, c)=>t += c[1] - c[0], 0) : 0);
|
|
243
|
+
}
|
|
244
|
+
return costs;
|
|
245
|
+
}
|
|
246
|
+
function getLoaderCosts(loader, loaders) {
|
|
247
|
+
let blocked = loaders.filter((e)=>!e.loader.includes('builtin') && e !== loader && e.pid === loader.pid && !!(e.startAt >= loader.startAt) && !!(e.endAt <= loader.endAt)), costs = loader.endAt - loader.startAt;
|
|
248
|
+
return blocked.length && mergeIntervals(blocked.map((e)=>[
|
|
249
|
+
Math.max(e.startAt, loader.startAt),
|
|
250
|
+
Math.min(e.endAt, loader.endAt)
|
|
251
|
+
])).forEach((e)=>{
|
|
252
|
+
let sub = e[1] - e[0];
|
|
253
|
+
costs -= sub;
|
|
254
|
+
}), costs;
|
|
255
|
+
}
|
|
256
|
+
function getLoaderNames(loaders) {
|
|
257
|
+
let names = new Set();
|
|
258
|
+
return loaders.forEach((e)=>e.loaders.forEach((l)=>names.add(getLoadrName(l.loader)))), [
|
|
259
|
+
...names
|
|
260
|
+
];
|
|
261
|
+
}
|
|
262
|
+
function getLoadersTransformData(loaders) {
|
|
263
|
+
let res = [];
|
|
264
|
+
for(let i = 0; i < loaders.length; i++){
|
|
265
|
+
let item = loaders[i];
|
|
266
|
+
for(let j = 0; j < item.loaders.length; j++){
|
|
267
|
+
let loader = item.loaders[j];
|
|
268
|
+
res.push(loader);
|
|
269
|
+
}
|
|
270
|
+
}
|
|
271
|
+
return res;
|
|
272
|
+
}
|
|
273
|
+
function getLoaderChartData(loaders) {
|
|
274
|
+
let res = [], list = getLoadersTransformData(loaders);
|
|
275
|
+
return loaders.forEach((item)=>{
|
|
276
|
+
item.loaders.forEach((el)=>{
|
|
277
|
+
res.push({
|
|
278
|
+
layer: item.resource.layer,
|
|
279
|
+
loader: getLoadrName(el.loader),
|
|
280
|
+
isPitch: el.isPitch,
|
|
281
|
+
startAt: el.startAt,
|
|
282
|
+
endAt: el.endAt,
|
|
283
|
+
pid: el.pid,
|
|
284
|
+
sync: el.sync,
|
|
285
|
+
resource: item.resource.path,
|
|
286
|
+
costs: getLoaderCosts(el, list)
|
|
287
|
+
});
|
|
288
|
+
});
|
|
289
|
+
}), res;
|
|
290
|
+
}
|
|
291
|
+
function getLoaderFileTree(loaders) {
|
|
292
|
+
let list = getLoadersTransformData(loaders);
|
|
293
|
+
return loaders.map((data)=>{
|
|
294
|
+
let { loaders: arr, resource } = data;
|
|
295
|
+
return {
|
|
296
|
+
path: resource.path,
|
|
297
|
+
layer: resource.layer,
|
|
298
|
+
loaders: arr.map((l)=>({
|
|
299
|
+
key: l.path,
|
|
300
|
+
loader: getLoadrName(l.loader),
|
|
301
|
+
path: l.path,
|
|
302
|
+
errors: l.errors,
|
|
303
|
+
costs: getLoaderCosts(l, list)
|
|
304
|
+
}))
|
|
305
|
+
};
|
|
306
|
+
});
|
|
307
|
+
}
|
|
308
|
+
function getLoaderFileDetails(path1, loaders) {
|
|
309
|
+
let data = loaders.find((e)=>e.resource.path === path1);
|
|
310
|
+
if (!data) throw Error(`"${path1}" not match any loader data`);
|
|
311
|
+
let list = getLoadersTransformData(loaders);
|
|
312
|
+
return {
|
|
313
|
+
...data,
|
|
314
|
+
loaders: data.loaders.map((el)=>({
|
|
315
|
+
...el,
|
|
316
|
+
loader: getLoadrName(el.loader),
|
|
317
|
+
costs: getLoaderCosts(el, list)
|
|
318
|
+
}))
|
|
319
|
+
};
|
|
320
|
+
}
|
|
321
|
+
function getLoaderFolderStatistics(folder, loaders) {
|
|
322
|
+
let datas = loaders.filter((data)=>{
|
|
323
|
+
let { path: path1 } = data.resource;
|
|
324
|
+
return path1.startsWith(folder);
|
|
325
|
+
}), filteredLoaders = [], uniqueLoaders = new Map();
|
|
326
|
+
return datas.forEach((data)=>{
|
|
327
|
+
data.loaders.forEach((fl)=>{
|
|
328
|
+
let uniqueLoader = uniqueLoaders.get(fl.loader);
|
|
329
|
+
return uniqueLoader ? uniqueLoaders.set(fl.loader, {
|
|
330
|
+
files: uniqueLoader.files + 1,
|
|
331
|
+
path: fl.path
|
|
332
|
+
}) : uniqueLoaders.set(fl.loader, {
|
|
333
|
+
files: 1,
|
|
334
|
+
path: fl.path
|
|
335
|
+
}), filteredLoaders.push({
|
|
336
|
+
loader: fl.loader,
|
|
337
|
+
startAt: fl.startAt,
|
|
338
|
+
endAt: fl.endAt,
|
|
339
|
+
pid: fl.pid
|
|
340
|
+
});
|
|
341
|
+
});
|
|
342
|
+
}), Array.from(uniqueLoaders).map((uniqueLoader)=>{
|
|
343
|
+
let costs = getLoadersCosts((l)=>l.loader === uniqueLoader[0], filteredLoaders);
|
|
344
|
+
return {
|
|
345
|
+
loader: uniqueLoader[0],
|
|
346
|
+
files: uniqueLoader[1].files,
|
|
347
|
+
path: uniqueLoader[1].path,
|
|
348
|
+
costs
|
|
349
|
+
};
|
|
350
|
+
});
|
|
351
|
+
}
|
|
352
|
+
function collectResourceDirectories(loaders, root) {
|
|
353
|
+
let directories = new Set();
|
|
354
|
+
return loaders.forEach((item)=>{
|
|
355
|
+
if (item.resource.path.startsWith(root)) {
|
|
356
|
+
let pathParts = item.resource.path.split(root).slice(1).join('/').split('/');
|
|
357
|
+
if (pathParts.length >= 2) {
|
|
358
|
+
let twoLevelDir = pathParts.slice(0, 2).join('/');
|
|
359
|
+
directories.add(`${root}/${twoLevelDir}`);
|
|
360
|
+
}
|
|
361
|
+
} else {
|
|
362
|
+
let pathParts = item.resource.path.split('/'), twoLevelDir = pathParts.slice(0, pathParts.length - 1).join('/');
|
|
363
|
+
directories.add(twoLevelDir);
|
|
364
|
+
}
|
|
365
|
+
}), Array.from(directories);
|
|
366
|
+
}
|
|
367
|
+
function getDirectoriesLoaders(loaders, root) {
|
|
368
|
+
return collectResourceDirectories(loaders, root || process.cwd()).map((directory)=>{
|
|
369
|
+
let stats = getLoaderFolderStatistics(directory, loaders);
|
|
370
|
+
return {
|
|
371
|
+
directory,
|
|
372
|
+
stats
|
|
373
|
+
};
|
|
374
|
+
});
|
|
375
|
+
}
|
|
376
|
+
function getLoaderFileFirstInput(file, loaders) {
|
|
377
|
+
for(let i = 0; i < loaders.length; i++){
|
|
378
|
+
let item = loaders[i];
|
|
379
|
+
if (item.resource.path === file) {
|
|
380
|
+
let nonPitchLoaders = item.loaders.filter((e)=>!e.isPitch);
|
|
381
|
+
if (!nonPitchLoaders.length) return '';
|
|
382
|
+
return nonPitchLoaders[0].input || '';
|
|
383
|
+
}
|
|
384
|
+
}
|
|
385
|
+
return '';
|
|
386
|
+
}
|
|
387
|
+
function getLoaderFileInputAndOutput(file, loader, loaderIndex, loaders) {
|
|
388
|
+
for(let i = 0; i < loaders.length; i++){
|
|
389
|
+
let item = loaders[i];
|
|
390
|
+
if (item.resource.path === file) for(let j = 0; j < item.loaders.length; j++){
|
|
391
|
+
let l = item.loaders[j];
|
|
392
|
+
if (l.loader === loader && l.loaderIndex === loaderIndex) return {
|
|
393
|
+
input: l.input || '',
|
|
394
|
+
output: l.result || ''
|
|
395
|
+
};
|
|
396
|
+
return {
|
|
397
|
+
input: '',
|
|
398
|
+
output: ''
|
|
399
|
+
};
|
|
400
|
+
}
|
|
401
|
+
}
|
|
402
|
+
return {
|
|
403
|
+
input: '',
|
|
404
|
+
output: ''
|
|
405
|
+
};
|
|
406
|
+
}
|
|
407
|
+
let LoaderInternalPropertyName = '__l__', isVue = (compiler)=>('module' in compiler.options && compiler.options.module.rules || []).some((rule)=>!!(rule && 'object' == typeof rule && rule.test instanceof RegExp && rule.test?.test('.vue'))), getLoadrName = (loader)=>{
|
|
408
|
+
let regResults = loader.includes('node_modules') ? loader.split('node_modules') : null;
|
|
409
|
+
return regResults ? regResults[regResults.length - 1] : loader;
|
|
410
|
+
}, external_process_namespaceObject = require("process");
|
|
411
|
+
function toFixedDigits(num, digits = 2) {
|
|
412
|
+
return 0 === digits ? Math.floor(num) : +num.toFixed(digits);
|
|
413
|
+
}
|
|
414
|
+
function getUnit(num, type) {
|
|
415
|
+
return 'm' === type ? num > 1 ? 'mins' : 'min' : num > 1 ? 'hours' : 'hour';
|
|
416
|
+
}
|
|
417
|
+
function formatCosts(costs) {
|
|
418
|
+
if ((costs = Number(costs)) >= 1000) {
|
|
419
|
+
let sec = costs / 1000;
|
|
420
|
+
if (sec >= 60) {
|
|
421
|
+
let mins = sec / 60;
|
|
422
|
+
if (mins >= 60) {
|
|
423
|
+
let hours = toFixedDigits(mins / 60, 0), restMins = toFixedDigits(mins % 60, 1), hUnit = getUnit(hours, 'h');
|
|
424
|
+
return restMins > 0 ? `${hours}${hUnit} ${restMins}${getUnit(restMins, 'm')}` : `${hours}${hUnit}`;
|
|
425
|
+
}
|
|
426
|
+
let mUnit = getUnit(mins = toFixedDigits(mins, 0), 'm'), restSec = toFixedDigits(sec % 60, 0);
|
|
427
|
+
return restSec > 0 ? `${mins}${mUnit} ${restSec}s` : `${mins}${mUnit}`;
|
|
428
|
+
}
|
|
429
|
+
return `${toFixedDigits(sec, 1)}s`;
|
|
430
|
+
}
|
|
431
|
+
if (costs >= 10) return `${+toFixedDigits(costs, 0)}ms`;
|
|
432
|
+
if (costs >= 1) return `${+toFixedDigits(costs, 1)}ms`;
|
|
433
|
+
let r = +toFixedDigits(costs, 2);
|
|
434
|
+
return 0 === r && (r = +toFixedDigits(costs, 3)), `${r}ms`;
|
|
435
|
+
}
|
|
436
|
+
function getCurrentTimestamp(start, startHRTime) {
|
|
437
|
+
let endHRTime = hrtime(startHRTime);
|
|
438
|
+
return start + 1000 * endHRTime[0] + (process.env.RSTEST ? Math.round(endHRTime[1] / 1000000) : endHRTime[1] / 1000000);
|
|
439
|
+
}
|
|
440
|
+
function isResolveSuccessData(data) {
|
|
441
|
+
return !!data.result;
|
|
442
|
+
}
|
|
443
|
+
function isResolveFailData(data) {
|
|
444
|
+
return !!data.error;
|
|
445
|
+
}
|
|
446
|
+
function getResolverCosts(resolver, resolvers) {
|
|
447
|
+
let blocked = resolvers.filter((e)=>e !== resolver && e.pid === resolver.pid && e.startAt >= resolver.startAt && e.endAt <= resolver.endAt), costs = resolver.endAt - resolver.startAt;
|
|
448
|
+
return blocked.length && mergeIntervals(blocked.map((e)=>[
|
|
449
|
+
Math.max(e.startAt, resolver.startAt),
|
|
450
|
+
Math.min(e.endAt, resolver.endAt)
|
|
451
|
+
])).forEach((e)=>{
|
|
452
|
+
let sub = e[1] - e[0];
|
|
453
|
+
costs -= sub;
|
|
454
|
+
}), costs;
|
|
455
|
+
}
|
|
456
|
+
function getResolverFileTree(resolver) {
|
|
457
|
+
return resolver.map((e)=>({
|
|
458
|
+
issuerPath: e.issuerPath
|
|
459
|
+
}));
|
|
460
|
+
}
|
|
461
|
+
function getResolverFileDetails(filepath, resolvers, modules, moduleCodeMap) {
|
|
462
|
+
let module = modules.find((item)=>item.path === filepath), matchResolvers = resolvers.filter((e)=>e.issuerPath === filepath), before = module && moduleCodeMap && moduleCodeMap[module.id] ? moduleCodeMap[module.id].source : '', after = matchResolvers.reduce((t, c)=>c.request && isResolveSuccessData(c) ? t.replace(RegExp(`["']${c.request}["']`), `"${c.result}"`) : t, before);
|
|
463
|
+
return {
|
|
464
|
+
filepath,
|
|
465
|
+
before,
|
|
466
|
+
after,
|
|
467
|
+
resolvers: matchResolvers.map((e)=>({
|
|
468
|
+
...e,
|
|
469
|
+
costs: getResolverCosts(e, resolvers)
|
|
470
|
+
}))
|
|
471
|
+
};
|
|
472
|
+
}
|
|
473
|
+
function modules_getModulesByAsset(asset, chunks, modules, filterModules, checkModules) {
|
|
474
|
+
let cks = getChunksByChunkIds(getChunkIdsByAsset(asset), chunks);
|
|
475
|
+
return getModulesByChunks(asset.path, cks, modules, filterModules, checkModules);
|
|
476
|
+
}
|
|
477
|
+
function getModuleIdsByChunk(chunk) {
|
|
478
|
+
let { modules = [] } = chunk;
|
|
479
|
+
return modules;
|
|
480
|
+
}
|
|
481
|
+
function getModuleIdsByModulesIds(moduleIds, modules) {
|
|
482
|
+
return moduleIds.map((id)=>modules.find((m)=>m.id === id)).filter(Boolean);
|
|
483
|
+
}
|
|
484
|
+
function getModulesByChunk(chunk, modules, filterModules) {
|
|
485
|
+
return getModuleIdsByChunk(chunk).map((id)=>{
|
|
486
|
+
let module = modules.find((e)=>e.id === id);
|
|
487
|
+
if (filterModules && filterModules.length > 0) {
|
|
488
|
+
if (!module) return null;
|
|
489
|
+
let filtered = {};
|
|
490
|
+
for (let key of filterModules)void 0 !== module[key] && (filtered[key] = module[key]);
|
|
491
|
+
return filtered;
|
|
492
|
+
}
|
|
493
|
+
return module;
|
|
494
|
+
}).filter(Boolean);
|
|
495
|
+
}
|
|
496
|
+
function getTypeChecker(assetPath) {
|
|
497
|
+
return isStyleExt(assetPath) ? isStyleExt : isJsExt(assetPath) ? isJsExt : ()=>!0;
|
|
498
|
+
}
|
|
499
|
+
function getModulesByChunks(assetPath, chunks, modules, filterModules, checkModules) {
|
|
500
|
+
let res = [], typeChecker = getTypeChecker(assetPath);
|
|
501
|
+
try {
|
|
502
|
+
chunks.forEach((chunk)=>{
|
|
503
|
+
getModulesByChunk(chunk, modules, filterModules).forEach((md)=>{
|
|
504
|
+
let name = md.path || '';
|
|
505
|
+
typeChecker(name) && (!checkModules || checkModules(md)) && !res.filter((_m)=>_m.id === md.id).length && res.push(md);
|
|
506
|
+
});
|
|
507
|
+
});
|
|
508
|
+
} catch (error) {
|
|
509
|
+
logger.debug(error);
|
|
510
|
+
}
|
|
511
|
+
return res;
|
|
512
|
+
}
|
|
513
|
+
function getModuleByDependency(dep, modules) {
|
|
514
|
+
return modules.find((item)=>item.id === dep.module);
|
|
515
|
+
}
|
|
516
|
+
function filterModulesAndDependenciesByPackageDeps(deps, dependencies, modules) {
|
|
517
|
+
let _dependencies = [], _modules = [];
|
|
518
|
+
for(let i = 0; i < deps.length; i++){
|
|
519
|
+
let dep = getDependencyByPackageData(deps[i], dependencies);
|
|
520
|
+
if (dep) {
|
|
521
|
+
_dependencies.push(dep);
|
|
522
|
+
let module = getModuleByDependency(dep, modules);
|
|
523
|
+
module && _modules.push(module);
|
|
524
|
+
}
|
|
525
|
+
}
|
|
526
|
+
return {
|
|
527
|
+
dependencies: _dependencies,
|
|
528
|
+
modules: _modules
|
|
529
|
+
};
|
|
530
|
+
}
|
|
531
|
+
function getModuleDetails(moduleId, modules, dependencies) {
|
|
532
|
+
let module = modules.find((e)=>e.id === moduleId);
|
|
533
|
+
return {
|
|
534
|
+
module,
|
|
535
|
+
dependencies: getDependenciesByModule(module, dependencies)
|
|
536
|
+
};
|
|
537
|
+
}
|
|
538
|
+
let EXT = 'js|css|html', hashPattern = /[a-z|A-Z|0-9]{4,32}/, hashSeparatorPattern = /[-|.]/, fileExtensionPattern = /(?:\.[a-z|A-Z|0-9]{2,}){1,}/, filenamePattern = RegExp(`(.*)${hashSeparatorPattern.source}${hashPattern.source}(${fileExtensionPattern.source})$`);
|
|
539
|
+
function formatAssetName(assetName, fileConfig) {
|
|
540
|
+
let splitFilesList = fileConfig?.split('.'), outputFileTailName = '', unHashedFileName = assetName;
|
|
541
|
+
return splitFilesList?.length && splitFilesList.length >= 3 && splitFilesList[splitFilesList.length - 2]?.indexOf('[') < 0 && 'js|css|html'.indexOf(splitFilesList[splitFilesList.length - 1]) > -1 ? (outputFileTailName = splitFilesList[splitFilesList.length - 2], unHashedFileName = assetName.replace(/(.*)(\.[a-f0-9]{4,32})([^.]*.[^.]+){2,}/g, '$1'), `${unHashedFileName}.${outputFileTailName}.${assetName.substring(assetName.lastIndexOf('.') + 1)}`) : assetName.replace(filenamePattern, '$1$2');
|
|
542
|
+
}
|
|
543
|
+
function isAssetMatchExtension(asset, ext) {
|
|
544
|
+
return asset.path.slice(-ext.length) === ext || extname(asset.path) === ext;
|
|
545
|
+
}
|
|
546
|
+
function isAssetMatchExtensions(asset, exts) {
|
|
547
|
+
return !!exts.length && exts.some((ext)=>isAssetMatchExtension(asset, ext));
|
|
548
|
+
}
|
|
549
|
+
function filterAssetsByExtensions(assets, exts) {
|
|
550
|
+
return 'string' == typeof exts ? assets.filter((e)=>isAssetMatchExtension(e, exts)) : Array.isArray(exts) ? assets.filter((e)=>isAssetMatchExtensions(e, exts)) : [];
|
|
551
|
+
}
|
|
552
|
+
function filterAssets(assets, filterOrExtensions) {
|
|
553
|
+
return filterOrExtensions && (assets = 'function' == typeof filterOrExtensions ? assets.filter(filterOrExtensions) : filterAssetsByExtensions(assets, filterOrExtensions)), assets;
|
|
554
|
+
}
|
|
555
|
+
function getAssetsSizeInfo(assets, chunks, options = {}) {
|
|
556
|
+
let { withFileContent = !0, filterOrExtensions } = options;
|
|
557
|
+
return (assets = assets.filter((e)=>!isAssetMatchExtensions(e, Constants.MapExtensions)), filterOrExtensions && (assets = filterAssets(assets, filterOrExtensions)), assets.length) ? {
|
|
558
|
+
count: assets.length,
|
|
559
|
+
size: assets.reduce((t, c)=>t + c.size, 0),
|
|
560
|
+
files: assets.map((e)=>({
|
|
561
|
+
path: e.path,
|
|
562
|
+
size: e.size,
|
|
563
|
+
gzipSize: e.gzipSize,
|
|
564
|
+
initial: isInitialAsset(e, chunks),
|
|
565
|
+
content: withFileContent ? e.content : void 0
|
|
566
|
+
}))
|
|
567
|
+
} : {
|
|
568
|
+
count: 0,
|
|
569
|
+
size: 0,
|
|
570
|
+
files: []
|
|
571
|
+
};
|
|
572
|
+
}
|
|
573
|
+
function isInitialAsset(asset, chunks) {
|
|
574
|
+
return getChunksByAsset(asset, chunks).some((e)=>!!e.initial);
|
|
575
|
+
}
|
|
576
|
+
function getInitialAssetsSizeInfo(assets, chunks, options = {}) {
|
|
577
|
+
return options.filterOrExtensions && (assets = filterAssets(assets, options.filterOrExtensions)), getAssetsSizeInfo(assets, chunks, {
|
|
578
|
+
...options,
|
|
579
|
+
filterOrExtensions: (asset)=>isInitialAsset(asset, chunks)
|
|
580
|
+
});
|
|
581
|
+
}
|
|
582
|
+
function getAssetsDiffResult(baseline, current) {
|
|
583
|
+
return {
|
|
584
|
+
all: {
|
|
585
|
+
total: diffAssetsByExtensions(baseline, current)
|
|
586
|
+
},
|
|
587
|
+
js: {
|
|
588
|
+
total: diffAssetsByExtensions(baseline, current, Constants.JSExtension),
|
|
589
|
+
initial: diffAssetsByExtensions(baseline, current, Constants.JSExtension, !0)
|
|
590
|
+
},
|
|
591
|
+
css: {
|
|
592
|
+
total: diffAssetsByExtensions(baseline, current, Constants.CSSExtension),
|
|
593
|
+
initial: diffAssetsByExtensions(baseline, current, Constants.CSSExtension, !0)
|
|
594
|
+
},
|
|
595
|
+
imgs: {
|
|
596
|
+
total: diffAssetsByExtensions(baseline, current, Constants.ImgExtensions)
|
|
597
|
+
},
|
|
598
|
+
html: {
|
|
599
|
+
total: diffAssetsByExtensions(baseline, current, Constants.HtmlExtension)
|
|
600
|
+
},
|
|
601
|
+
media: {
|
|
602
|
+
total: diffAssetsByExtensions(baseline, current, Constants.MediaExtensions)
|
|
603
|
+
},
|
|
604
|
+
fonts: {
|
|
605
|
+
total: diffAssetsByExtensions(baseline, current, Constants.FontExtensions)
|
|
606
|
+
},
|
|
607
|
+
others: {
|
|
608
|
+
total: diffAssetsByExtensions(baseline, current, (asset)=>!isAssetMatchExtensions(asset, [
|
|
609
|
+
Constants.JSExtension,
|
|
610
|
+
Constants.CSSExtension,
|
|
611
|
+
Constants.HtmlExtension
|
|
612
|
+
].concat(Constants.ImgExtensions, Constants.MediaExtensions, Constants.FontExtensions, Constants.MapExtensions)))
|
|
613
|
+
}
|
|
614
|
+
};
|
|
615
|
+
}
|
|
616
|
+
function diffSize(bSize, cSize) {
|
|
617
|
+
let isEqual = bSize === cSize;
|
|
618
|
+
return {
|
|
619
|
+
percent: isEqual ? 0 : 0 === bSize ? 100 : Math.abs(cSize - bSize) / bSize * 100,
|
|
620
|
+
state: isEqual ? Client.RsdoctorClientDiffState.Equal : bSize > cSize ? Client.RsdoctorClientDiffState.Down : Client.RsdoctorClientDiffState.Up
|
|
621
|
+
};
|
|
622
|
+
}
|
|
623
|
+
function diffAssetsByExtensions(baseline, current, filterOrExtensions, isInitial = !1) {
|
|
624
|
+
let cSize, cCount, { size: bSize, count: bCount } = isInitial ? getInitialAssetsSizeInfo(baseline.assets, baseline.chunks, {
|
|
625
|
+
filterOrExtensions
|
|
626
|
+
}) : getAssetsSizeInfo(baseline.assets, baseline.chunks, {
|
|
627
|
+
filterOrExtensions
|
|
628
|
+
});
|
|
629
|
+
if (baseline === current) cSize = bSize, cCount = bCount;
|
|
630
|
+
else {
|
|
631
|
+
let { size, count } = isInitial ? getInitialAssetsSizeInfo(current.assets, current.chunks, {
|
|
632
|
+
filterOrExtensions
|
|
633
|
+
}) : getAssetsSizeInfo(current.assets, current.chunks, {
|
|
634
|
+
filterOrExtensions
|
|
635
|
+
});
|
|
636
|
+
cSize = size, cCount = count;
|
|
637
|
+
}
|
|
638
|
+
let { percent, state } = diffSize(bSize, cSize);
|
|
639
|
+
return {
|
|
640
|
+
size: {
|
|
641
|
+
baseline: bSize,
|
|
642
|
+
current: cSize
|
|
643
|
+
},
|
|
644
|
+
count: {
|
|
645
|
+
baseline: bCount,
|
|
646
|
+
current: cCount
|
|
647
|
+
},
|
|
648
|
+
percent,
|
|
649
|
+
state
|
|
650
|
+
};
|
|
651
|
+
}
|
|
652
|
+
function getAssetsSummary(assets, chunks, options = {}) {
|
|
653
|
+
let jsOpt = {
|
|
654
|
+
...options,
|
|
655
|
+
filterOrExtensions: Constants.JSExtension
|
|
656
|
+
}, cssOpt = {
|
|
657
|
+
...options,
|
|
658
|
+
filterOrExtensions: Constants.CSSExtension
|
|
659
|
+
}, imgOpt = {
|
|
660
|
+
...options,
|
|
661
|
+
filterOrExtensions: Constants.ImgExtensions
|
|
662
|
+
}, htmlOpt = {
|
|
663
|
+
...options,
|
|
664
|
+
filterOrExtensions: Constants.HtmlExtension
|
|
665
|
+
}, mediaOpt = {
|
|
666
|
+
...options,
|
|
667
|
+
filterOrExtensions: Constants.MediaExtensions
|
|
668
|
+
}, fontOpt = {
|
|
669
|
+
...options,
|
|
670
|
+
filterOrExtensions: Constants.FontExtensions
|
|
671
|
+
}, otherOpt = {
|
|
672
|
+
...options,
|
|
673
|
+
filterOrExtensions: (asset)=>!isAssetMatchExtensions(asset, [
|
|
674
|
+
Constants.JSExtension,
|
|
675
|
+
Constants.CSSExtension,
|
|
676
|
+
Constants.HtmlExtension
|
|
677
|
+
].concat(Constants.ImgExtensions, Constants.MediaExtensions, Constants.FontExtensions, Constants.MapExtensions))
|
|
678
|
+
};
|
|
679
|
+
return {
|
|
680
|
+
all: {
|
|
681
|
+
total: getAssetsSizeInfo(assets, chunks, options)
|
|
682
|
+
},
|
|
683
|
+
js: {
|
|
684
|
+
total: getAssetsSizeInfo(assets, chunks, jsOpt),
|
|
685
|
+
initial: getInitialAssetsSizeInfo(assets, chunks, jsOpt)
|
|
686
|
+
},
|
|
687
|
+
css: {
|
|
688
|
+
total: getAssetsSizeInfo(assets, chunks, cssOpt),
|
|
689
|
+
initial: getInitialAssetsSizeInfo(assets, chunks, cssOpt)
|
|
690
|
+
},
|
|
691
|
+
imgs: {
|
|
692
|
+
total: getAssetsSizeInfo(assets, chunks, imgOpt)
|
|
693
|
+
},
|
|
694
|
+
html: {
|
|
695
|
+
total: getAssetsSizeInfo(assets, chunks, htmlOpt)
|
|
696
|
+
},
|
|
697
|
+
media: {
|
|
698
|
+
total: getAssetsSizeInfo(assets, chunks, mediaOpt)
|
|
699
|
+
},
|
|
700
|
+
fonts: {
|
|
701
|
+
total: getAssetsSizeInfo(assets, chunks, fontOpt)
|
|
702
|
+
},
|
|
703
|
+
others: {
|
|
704
|
+
total: getAssetsSizeInfo(assets, chunks, otherOpt)
|
|
705
|
+
}
|
|
706
|
+
};
|
|
707
|
+
}
|
|
708
|
+
function getAssetDetails(assetPath, assets, chunks, modules, checkModules) {
|
|
709
|
+
let asset = assets.find((e)=>e.path === assetPath);
|
|
710
|
+
return {
|
|
711
|
+
asset,
|
|
712
|
+
chunks: getChunksByAsset(asset, chunks),
|
|
713
|
+
modules: getModulesByAsset(asset, chunks, modules, void 0, checkModules)
|
|
714
|
+
};
|
|
715
|
+
}
|
|
716
|
+
function getAllBundleData(assets, chunks, modules, filtersModules) {
|
|
717
|
+
let result = [];
|
|
718
|
+
try {
|
|
719
|
+
for(let i = 0; i < assets.length; i++){
|
|
720
|
+
let asset = assets[i];
|
|
721
|
+
result.push({
|
|
722
|
+
asset,
|
|
723
|
+
modules: getModulesByAsset(asset, chunks, modules, filtersModules)
|
|
724
|
+
});
|
|
725
|
+
}
|
|
726
|
+
return result;
|
|
727
|
+
} catch (error) {
|
|
728
|
+
return console.error(error), [];
|
|
729
|
+
}
|
|
730
|
+
}
|
|
731
|
+
function extname(filename) {
|
|
732
|
+
let matches = filename.split('?')[0].match(/\.([0-9a-z]+)(?:[\?#]|$)/i);
|
|
733
|
+
return matches ? `.${matches[1]}` : '';
|
|
734
|
+
}
|
|
735
|
+
let sep = ',';
|
|
736
|
+
function getBundleDiffPageQueryString(files) {
|
|
737
|
+
let qs = encodeURIComponent(files.join(','));
|
|
738
|
+
return qs && (qs = `?${Client.RsdoctorClientUrlQuery.BundleDiffFiles}=${qs}`), qs;
|
|
739
|
+
}
|
|
740
|
+
function getBundleDiffPageUrl(files) {
|
|
741
|
+
let qs = getBundleDiffPageQueryString(files);
|
|
742
|
+
if ('development' === process.env.NODE_ENV && 'undefined' != typeof location) {
|
|
743
|
+
let { search = '', origin } = location;
|
|
744
|
+
return search && (qs += `&${search.slice(1)}`), `${origin}${qs}#${Client.RsdoctorClientRoutes.BundleDiff}`;
|
|
745
|
+
}
|
|
746
|
+
return `${qs}#${Client.RsdoctorClientRoutes.BundleDiff}`;
|
|
747
|
+
}
|
|
748
|
+
function parseFilesFromBundlePageUrlQuery(queryValue) {
|
|
749
|
+
return decodeURIComponent(queryValue).split(',');
|
|
750
|
+
}
|
|
751
|
+
function getPackageRelationAlertDetails(modules, dependencies, root, packageDependencies, moduleCodeMap) {
|
|
752
|
+
return packageDependencies.slice().reverse().map((dep)=>{
|
|
753
|
+
let dependency = dependencies.find((item)=>item.id === dep.dependencyId);
|
|
754
|
+
if (!dependency) return null;
|
|
755
|
+
let module = modules.find((item)=>item.id === dependency.module);
|
|
756
|
+
return module ? {
|
|
757
|
+
group: dep.group,
|
|
758
|
+
module,
|
|
759
|
+
dependency,
|
|
760
|
+
relativePath: relative(root, module.path),
|
|
761
|
+
moduleCode: moduleCodeMap?.[module.id]
|
|
762
|
+
} : null;
|
|
763
|
+
}).filter(Boolean);
|
|
764
|
+
}
|
|
765
|
+
class APIDataLoader {
|
|
766
|
+
loader;
|
|
767
|
+
constructor(loader){
|
|
768
|
+
this.loader = loader, this.loadAPI = this.loadAPI.bind(this);
|
|
769
|
+
}
|
|
770
|
+
log(...args) {
|
|
771
|
+
console.log(`[${this.constructor.name}]`, ...args);
|
|
772
|
+
}
|
|
773
|
+
loadAPI(...args) {
|
|
774
|
+
let [api, body] = args;
|
|
775
|
+
switch(api){
|
|
776
|
+
case SDK.ServerAPI.API.LoadDataByKey:
|
|
777
|
+
return this.loader.loadData(body.key);
|
|
778
|
+
case SDK.ServerAPI.API.GetProjectInfo:
|
|
779
|
+
return Promise.all([
|
|
780
|
+
this.loader.loadData('root'),
|
|
781
|
+
this.loader.loadData('pid'),
|
|
782
|
+
this.loader.loadData('hash'),
|
|
783
|
+
this.loader.loadData('summary'),
|
|
784
|
+
this.loader.loadData('configs'),
|
|
785
|
+
this.loader.loadData('envinfo'),
|
|
786
|
+
this.loader.loadData('errors')
|
|
787
|
+
]).then(([root, pid, hash, summary, configs, envinfo, errors])=>({
|
|
788
|
+
root,
|
|
789
|
+
pid,
|
|
790
|
+
hash,
|
|
791
|
+
summary,
|
|
792
|
+
configs,
|
|
793
|
+
envinfo,
|
|
794
|
+
errors
|
|
795
|
+
}));
|
|
796
|
+
case SDK.ServerAPI.API.GetClientRoutes:
|
|
797
|
+
if ('undefined' != typeof window && window?.[Constants.WINDOW_RSDOCTOR_TAG]) return window[Constants.WINDOW_RSDOCTOR_TAG].enableRoutes;
|
|
798
|
+
return this.loader.loadManifest().then((res)=>{
|
|
799
|
+
let { enableRoutes = [] } = res.client || {};
|
|
800
|
+
return enableRoutes;
|
|
801
|
+
});
|
|
802
|
+
case SDK.ServerAPI.API.GetLoaderNames:
|
|
803
|
+
return this.loader.loadData('loader').then((res)=>Loader.getLoaderNames(res || []));
|
|
804
|
+
case SDK.ServerAPI.API.GetLayers:
|
|
805
|
+
return this.loader.loadData('moduleGraph').then((res)=>{
|
|
806
|
+
let { layers } = res || {};
|
|
807
|
+
return layers;
|
|
808
|
+
});
|
|
809
|
+
case SDK.ServerAPI.API.GetLoaderChartData:
|
|
810
|
+
return this.loader.loadData('loader').then((res)=>Loader.getLoaderChartData(res || []));
|
|
811
|
+
case SDK.ServerAPI.API.GetLoaderFileTree:
|
|
812
|
+
return this.loader.loadData('loader').then((res)=>Loader.getLoaderFileTree(res || []));
|
|
813
|
+
case SDK.ServerAPI.API.GetLoaderFileDetails:
|
|
814
|
+
return this.loader.loadData('loader').then((res)=>Loader.getLoaderFileDetails(body.path, res || []));
|
|
815
|
+
case SDK.ServerAPI.API.GetLoaderFolderStatistics:
|
|
816
|
+
return this.loader.loadData('loader').then((res)=>Loader.getLoaderFolderStatistics(body.folder, res || []));
|
|
817
|
+
case SDK.ServerAPI.API.GetLoaderFileFirstInput:
|
|
818
|
+
return this.loader.loadData('loader').then((res)=>Loader.getLoaderFileFirstInput(body.file, res || []));
|
|
819
|
+
case SDK.ServerAPI.API.GetLoaderFileInputAndOutput:
|
|
820
|
+
return this.loader.loadData('loader').then((res)=>Loader.getLoaderFileFirstInput(body.file, res || []));
|
|
821
|
+
case SDK.ServerAPI.API.GetResolverFileTree:
|
|
822
|
+
return this.loader.loadData('resolver').then((res)=>Resolver.getResolverFileTree(res || []));
|
|
823
|
+
case SDK.ServerAPI.API.GetResolverFileDetails:
|
|
824
|
+
return Promise.all([
|
|
825
|
+
this.loader.loadData('resolver'),
|
|
826
|
+
this.loader.loadData('moduleGraph.modules'),
|
|
827
|
+
this.loader.loadData('moduleCodeMap')
|
|
828
|
+
]).then((res)=>{
|
|
829
|
+
let resolverData = res[0], modules = res[1], moduleCodeMap = res[2];
|
|
830
|
+
return Resolver.getResolverFileDetails(body.filepath, resolverData || [], modules || [], moduleCodeMap || {});
|
|
831
|
+
});
|
|
832
|
+
case SDK.ServerAPI.API.GetPluginSummary:
|
|
833
|
+
return this.loader.loadData('plugin').then((res)=>Plugin.getPluginSummary(res || {}));
|
|
834
|
+
case SDK.ServerAPI.API.GetPluginData:
|
|
835
|
+
return this.loader.loadData('plugin').then((res)=>{
|
|
836
|
+
let { hooks, tapNames } = body;
|
|
837
|
+
return Plugin.getPluginData(res || {}, hooks, tapNames);
|
|
838
|
+
});
|
|
839
|
+
case SDK.ServerAPI.API.GetAssetsSummary:
|
|
840
|
+
return this.loader.loadData('chunkGraph').then((res)=>{
|
|
841
|
+
let { withFileContent = !0 } = body, { assets = [], chunks = [] } = res || {};
|
|
842
|
+
return Graph.getAssetsSummary(assets, chunks, {
|
|
843
|
+
withFileContent
|
|
844
|
+
});
|
|
845
|
+
});
|
|
846
|
+
case SDK.ServerAPI.API.GetAssetDetails:
|
|
847
|
+
return Promise.all([
|
|
848
|
+
this.loader.loadData('chunkGraph'),
|
|
849
|
+
this.loader.loadData('moduleGraph'),
|
|
850
|
+
this.loader.loadData('configs')
|
|
851
|
+
]).then((res)=>{
|
|
852
|
+
let { assetPath } = body, { isRspack, hasSourceMap } = checkSourceMapSupport(res[2] || []), { assets = [], chunks = [] } = res[0] || {}, { modules = [] } = res[1] || {};
|
|
853
|
+
return Graph.getAssetDetails(assetPath, assets, chunks, modules, isRspack || hasSourceMap ? (_module)=>!0 : ()=>!0);
|
|
854
|
+
});
|
|
855
|
+
case SDK.ServerAPI.API.GetSummaryBundles:
|
|
856
|
+
return Promise.all([
|
|
857
|
+
this.loader.loadData('chunkGraph'),
|
|
858
|
+
this.loader.loadData('moduleGraph')
|
|
859
|
+
]).then((res)=>{
|
|
860
|
+
let { assets = [], chunks = [] } = res[0] || {}, { modules = [] } = res[1] || {};
|
|
861
|
+
return Graph.getAllBundleData(assets, chunks, modules, [
|
|
862
|
+
'id',
|
|
863
|
+
'path',
|
|
864
|
+
'size',
|
|
865
|
+
'kind'
|
|
866
|
+
]);
|
|
867
|
+
});
|
|
868
|
+
case SDK.ServerAPI.API.GetChunksByModuleId:
|
|
869
|
+
return Promise.all([
|
|
870
|
+
this.loader.loadData('chunkGraph'),
|
|
871
|
+
this.loader.loadData('moduleGraph')
|
|
872
|
+
]).then((res)=>{
|
|
873
|
+
let { moduleId } = body, { chunks = [] } = res[0] || {}, { modules = [] } = res[1] || {};
|
|
874
|
+
return Graph.getChunksByModuleId(moduleId, modules, chunks);
|
|
875
|
+
});
|
|
876
|
+
case SDK.ServerAPI.API.GetModuleDetails:
|
|
877
|
+
return Promise.all([
|
|
878
|
+
this.loader.loadData('chunkGraph'),
|
|
879
|
+
this.loader.loadData('moduleGraph')
|
|
880
|
+
]).then((res)=>{
|
|
881
|
+
let { moduleId } = body, { modules = [], dependencies = [] } = res[1] || {};
|
|
882
|
+
return Graph.getModuleDetails(moduleId, modules, dependencies);
|
|
883
|
+
});
|
|
884
|
+
case SDK.ServerAPI.API.GetModulesByModuleIds:
|
|
885
|
+
return this.loader.loadData('moduleGraph').then((res)=>{
|
|
886
|
+
let { moduleIds } = body, { modules = [] } = res || {};
|
|
887
|
+
return Graph.getModuleIdsByModulesIds(moduleIds, modules);
|
|
888
|
+
});
|
|
889
|
+
case SDK.ServerAPI.API.GetEntryPoints:
|
|
890
|
+
return Promise.all([
|
|
891
|
+
this.loader.loadData('chunkGraph')
|
|
892
|
+
]).then((res)=>{
|
|
893
|
+
let [chunkGraph] = res, { entrypoints = [] } = chunkGraph || {};
|
|
894
|
+
return Graph.getEntryPoints(entrypoints);
|
|
895
|
+
});
|
|
896
|
+
case SDK.ServerAPI.API.GetModuleCodeByModuleId:
|
|
897
|
+
return this.loader.loadData('moduleCodeMap').then((moduleCodeMap)=>{
|
|
898
|
+
let { moduleId } = body;
|
|
899
|
+
return moduleCodeMap ? moduleCodeMap[moduleId] : {
|
|
900
|
+
source: '',
|
|
901
|
+
transformed: '',
|
|
902
|
+
parsedSource: ''
|
|
903
|
+
};
|
|
904
|
+
});
|
|
905
|
+
case SDK.ServerAPI.API.GetModuleCodeByModuleIds:
|
|
906
|
+
return this.loader.loadData('moduleCodeMap').then((moduleCodeMap)=>{
|
|
907
|
+
let { moduleIds } = body, _moduleCodeData = {};
|
|
908
|
+
return moduleCodeMap ? (moduleIds.forEach((id)=>{
|
|
909
|
+
_moduleCodeData[id] = moduleCodeMap[id];
|
|
910
|
+
}), _moduleCodeData) : [];
|
|
911
|
+
});
|
|
912
|
+
case SDK.ServerAPI.API.GetAllModuleGraph:
|
|
913
|
+
return this.loader.loadData('moduleGraph').then((moduleGraph)=>moduleGraph?.modules);
|
|
914
|
+
case SDK.ServerAPI.API.GetSearchModules:
|
|
915
|
+
return Promise.all([
|
|
916
|
+
this.loader.loadData('moduleGraph'),
|
|
917
|
+
this.loader.loadData('chunkGraph')
|
|
918
|
+
]).then((res)=>{
|
|
919
|
+
let [moduleGraph, chunkGraph] = res, { moduleName } = body;
|
|
920
|
+
if (!moduleName) return [];
|
|
921
|
+
let assetMap = chunkGraph.chunks.reduce((acc, chunk)=>(chunk.assets.forEach((asset)=>{
|
|
922
|
+
acc[chunk.id] || (acc[chunk.id] = []), acc[chunk.id].push(asset);
|
|
923
|
+
}), acc), {}), searchedChunksMap = new Map();
|
|
924
|
+
return moduleGraph?.modules.filter((module)=>{
|
|
925
|
+
module.webpackId.includes(moduleName) && module.chunks.forEach((chunk)=>{
|
|
926
|
+
searchedChunksMap.has(chunk) || (assetMap[chunk] || []).forEach((asset)=>{
|
|
927
|
+
asset.endsWith('.js') && searchedChunksMap.set(chunk, asset);
|
|
928
|
+
});
|
|
929
|
+
});
|
|
930
|
+
}), Object.fromEntries(searchedChunksMap);
|
|
931
|
+
});
|
|
932
|
+
case SDK.ServerAPI.API.GetSearchModuleInChunk:
|
|
933
|
+
return Promise.all([
|
|
934
|
+
this.loader.loadData('moduleGraph'),
|
|
935
|
+
this.loader.loadData('root')
|
|
936
|
+
]).then((res)=>{
|
|
937
|
+
let [moduleGraph, root] = res, { moduleName, chunk } = body;
|
|
938
|
+
return moduleName ? moduleGraph?.modules.filter((module)=>module.webpackId.includes(moduleName) && module.chunks.includes(chunk)).map((filteredModule)=>({
|
|
939
|
+
id: filteredModule.id,
|
|
940
|
+
path: filteredModule.path,
|
|
941
|
+
relativePath: relative(root, filteredModule.path)
|
|
942
|
+
})) : [];
|
|
943
|
+
});
|
|
944
|
+
case SDK.ServerAPI.API.GetAllChunkGraph:
|
|
945
|
+
return this.loader.loadData('chunkGraph').then((chunkGraph)=>chunkGraph?.chunks);
|
|
946
|
+
case SDK.ServerAPI.API.GetPackageRelationAlertDetails:
|
|
947
|
+
return Promise.all([
|
|
948
|
+
this.loader.loadData('moduleGraph'),
|
|
949
|
+
this.loader.loadData('errors'),
|
|
950
|
+
this.loader.loadData('root'),
|
|
951
|
+
this.loader.loadData('moduleCodeMap')
|
|
952
|
+
]).then((res)=>{
|
|
953
|
+
let { id, target } = body, [moduleGraph, errors = [], root = '', moduleCodeMap] = res, { modules = [], dependencies = [] } = moduleGraph || {}, { packages = [] } = errors.find((e)=>e.id === id) || {}, { dependencies: pkgDependencies = [] } = packages.find((e)=>e.target.name === target.name && e.target.root === target.root && e.target.version === target.version) || {};
|
|
954
|
+
return Alerts.getPackageRelationAlertDetails(modules, dependencies, root, pkgDependencies, moduleCodeMap || {});
|
|
955
|
+
});
|
|
956
|
+
case SDK.ServerAPI.API.GetOverlayAlerts:
|
|
957
|
+
return this.loader.loadData('errors').then((res)=>(res || []).filter((e)=>e.code === Rule.RuleMessageCodeEnumerated.Overlay));
|
|
958
|
+
case SDK.ServerAPI.API.BundleDiffManifest:
|
|
959
|
+
return this.loader.loadManifest();
|
|
960
|
+
case SDK.ServerAPI.API.GetBundleDiffSummary:
|
|
961
|
+
return Promise.all([
|
|
962
|
+
this.loader.loadManifest(),
|
|
963
|
+
this.loader.loadData('root'),
|
|
964
|
+
this.loader.loadData('hash'),
|
|
965
|
+
this.loader.loadData('errors'),
|
|
966
|
+
this.loader.loadData('chunkGraph'),
|
|
967
|
+
this.loader.loadData('moduleGraph'),
|
|
968
|
+
this.loader.loadData('moduleCodeMap'),
|
|
969
|
+
this.loader.loadData('packageGraph'),
|
|
970
|
+
this.loader.loadData('configs')
|
|
971
|
+
]).then(([_manifest, root = '', hash = '', errors = {}, chunkGraph = {}, moduleGraph = {}, moduleCodeMap = {}, packageGraph = {}, configs = []])=>{
|
|
972
|
+
let outputFilename = '';
|
|
973
|
+
return 'string' == typeof configs[0]?.config?.output?.chunkFilename && (outputFilename = configs[0]?.config.output.chunkFilename), {
|
|
974
|
+
root,
|
|
975
|
+
hash,
|
|
976
|
+
errors,
|
|
977
|
+
chunkGraph,
|
|
978
|
+
moduleGraph,
|
|
979
|
+
packageGraph,
|
|
980
|
+
outputFilename,
|
|
981
|
+
moduleCodeMap
|
|
982
|
+
};
|
|
983
|
+
});
|
|
984
|
+
case SDK.ServerAPI.API.GetChunkGraph:
|
|
985
|
+
return this.loader.loadData('chunkGraph').then((res)=>{
|
|
986
|
+
let { chunks = [] } = res || {};
|
|
987
|
+
return chunks;
|
|
988
|
+
});
|
|
989
|
+
case SDK.ServerAPI.API.GetAllModuleGraphFilter:
|
|
990
|
+
return this.loader.loadData('moduleGraph').then((moduleGraph)=>moduleGraph?.modules.map((m)=>({
|
|
991
|
+
id: m.id,
|
|
992
|
+
webpackId: m.webpackId,
|
|
993
|
+
path: m.path,
|
|
994
|
+
size: m.size,
|
|
995
|
+
chunks: m.chunks,
|
|
996
|
+
kind: m.kind
|
|
997
|
+
})));
|
|
998
|
+
case SDK.ServerAPI.API.GetModuleByName:
|
|
999
|
+
return this.loader.loadData('moduleGraph').then((moduleGraph)=>{
|
|
1000
|
+
let { moduleName } = body, { modules = [] } = moduleGraph || {};
|
|
1001
|
+
return modules.filter((m)=>m.path.includes(moduleName)).map((m)=>({
|
|
1002
|
+
id: m.id,
|
|
1003
|
+
path: m.path
|
|
1004
|
+
})) || [];
|
|
1005
|
+
});
|
|
1006
|
+
case SDK.ServerAPI.API.GetModuleIssuerPath:
|
|
1007
|
+
return this.loader.loadData('moduleGraph').then((moduleGraph)=>{
|
|
1008
|
+
let { moduleId } = body, modules = moduleGraph?.modules || [], issuerPath = modules.find((m)=>String(m.id) === moduleId)?.issuerPath || [];
|
|
1009
|
+
return Array.isArray(issuerPath) && issuerPath.length > 0 && 'number' == typeof issuerPath[0] ? issuerPath.map((id)=>modules.find((m)=>m.id === id)?.path).filter(Boolean) : issuerPath;
|
|
1010
|
+
});
|
|
1011
|
+
case SDK.ServerAPI.API.GetPackageInfo:
|
|
1012
|
+
return this.loader.loadData('packageGraph').then((packageGraph)=>packageGraph?.packages);
|
|
1013
|
+
case SDK.ServerAPI.API.GetPackageDependency:
|
|
1014
|
+
return this.loader.loadData('packageGraph').then((packageGraph)=>packageGraph?.dependencies || []);
|
|
1015
|
+
case SDK.ServerAPI.API.GetChunkGraphAI:
|
|
1016
|
+
return this.loader.loadData('chunkGraph').then((res)=>{
|
|
1017
|
+
let { chunks = [] } = res || {};
|
|
1018
|
+
return chunks.map(({ modules, ...rest })=>rest);
|
|
1019
|
+
});
|
|
1020
|
+
case SDK.ServerAPI.API.GetChunkByIdAI:
|
|
1021
|
+
return Promise.all([
|
|
1022
|
+
this.loader.loadData('chunkGraph'),
|
|
1023
|
+
this.loader.loadData('moduleGraph')
|
|
1024
|
+
]).then(([chunkGraph, moduleGraph])=>{
|
|
1025
|
+
let { chunks = [] } = chunkGraph || {}, { modules = [] } = moduleGraph || {}, { chunkId } = body, chunkInfo = chunks.find((c)=>c.id === chunkId);
|
|
1026
|
+
if (!chunkInfo) return null;
|
|
1027
|
+
let chunkModules = modules.filter((m)=>chunkInfo.modules.includes(m.id)).map((module)=>({
|
|
1028
|
+
id: module.id,
|
|
1029
|
+
path: module.path,
|
|
1030
|
+
size: module.size,
|
|
1031
|
+
chunks: module.chunks,
|
|
1032
|
+
kind: module.kind,
|
|
1033
|
+
issuerPath: module.issuerPath
|
|
1034
|
+
}));
|
|
1035
|
+
return chunkInfo.modulesInfo = chunkModules, chunkInfo;
|
|
1036
|
+
});
|
|
1037
|
+
case SDK.ServerAPI.API.GetDirectoriesLoaders:
|
|
1038
|
+
return Promise.all([
|
|
1039
|
+
this.loader.loadData('root'),
|
|
1040
|
+
this.loader.loadData('loader')
|
|
1041
|
+
]).then(([root, loaders])=>Loader.getDirectoriesLoaders(loaders || [], root || ''));
|
|
1042
|
+
default:
|
|
1043
|
+
throw Error(`API not implement: "${api}"`);
|
|
1044
|
+
}
|
|
1045
|
+
}
|
|
1046
|
+
}
|
|
1047
|
+
function isUndefined(value) {
|
|
1048
|
+
return void 0 === value;
|
|
1049
|
+
}
|
|
1050
|
+
function isNumber(value) {
|
|
1051
|
+
return 'number' == typeof value && !Number.isNaN(value);
|
|
1052
|
+
}
|
|
1053
|
+
function isObject(value) {
|
|
1054
|
+
return 'object' == typeof value && null !== value;
|
|
1055
|
+
}
|
|
1056
|
+
function isEmpty(value) {
|
|
1057
|
+
return null == value || Array.isArray(value) && 0 === value.length || 'object' == typeof value && 0 === Object.keys(value).length;
|
|
1058
|
+
}
|
|
1059
|
+
function last(array) {
|
|
1060
|
+
return array[array.length - 1];
|
|
1061
|
+
}
|
|
1062
|
+
function compact(array) {
|
|
1063
|
+
return array.filter((item)=>null != item || !item);
|
|
1064
|
+
}
|
|
1065
|
+
function isNil(value) {
|
|
1066
|
+
return null == value;
|
|
1067
|
+
}
|
|
1068
|
+
let isPlainObject = (obj)=>null !== obj && 'object' == typeof obj && Object.getPrototypeOf(obj) === Object.prototype, isString = (v)=>'string' == typeof v || !!v && 'object' == typeof v && !Array.isArray(v) && '[object String]' === ({}).toString.call(v);
|
|
1069
|
+
function pick(obj, keys) {
|
|
1070
|
+
let result = {};
|
|
1071
|
+
for(let i = 0; i < keys.length; i++){
|
|
1072
|
+
let key = keys[i];
|
|
1073
|
+
Object.hasOwn(obj, key) && (result[key] = obj[key]);
|
|
1074
|
+
}
|
|
1075
|
+
return result;
|
|
1076
|
+
}
|
|
1077
|
+
let PACKAGE_PREFIX = /(?:node_modules|~)(?:\/\.pnpm)?/, PACKAGE_SLUG = /[a-zA-Z0-9]+(?:[-|_|.]+[a-zA-Z0-9]+)*/, VERSION = /@[\w|\-|_|.]+/, VERSION_NUMBER = '@([\\d.]+)', MODULE_PATH_PACKAGES = RegExp(`(?:${PACKAGE_PREFIX.source}/)(?:(?:@${PACKAGE_SLUG.source}[/|+])?(?:${PACKAGE_SLUG.source}\\+)*(?:${PACKAGE_SLUG.source})(?:${VERSION.source})?)(?:_(?:@${PACKAGE_SLUG.source}[/|+])?(?:${PACKAGE_SLUG.source})(?:@${PACKAGE_SLUG.source})?)*/`, 'g'), PACKAGE_PATH_NAME = /(?:(?:node_modules|~)(?:\/\.pnpm)?\/)(?:((?:@[a-zA-Z0-9]+(?:[-|_|.]+[a-zA-Z0-9]+)*[/|+])?(?:(?:[a-zA-Z0-9]+(?:[-|_|.]+[a-zA-Z0-9]+)*\+)*)(?:[a-zA-Z0-9]+(?:[-|_|.]+[a-zA-Z0-9]+)*))(?:@[\w|\-|_|.]+)?)(?:_((?:@[a-zA-Z0-9]+(?:[-|_|.]+[a-zA-Z0-9]+)*[/|+])?(?:[a-zA-Z0-9]+(?:[-|_|.]+[a-zA-Z0-9]+)*))(?:@[a-zA-Z0-9]+(?:[-|_|.]+[a-zA-Z0-9]+)*))*\//gm, uniqLast = (data)=>{
|
|
1078
|
+
let res = [];
|
|
1079
|
+
return data.forEach((item, index)=>{
|
|
1080
|
+
data.slice(index + 1).includes(item) || res.push(item);
|
|
1081
|
+
}), res;
|
|
1082
|
+
}, getPackageMetaFromModulePath = (modulePath)=>{
|
|
1083
|
+
let paths = modulePath.match(MODULE_PATH_PACKAGES);
|
|
1084
|
+
if (!paths) return {
|
|
1085
|
+
name: '',
|
|
1086
|
+
version: ''
|
|
1087
|
+
};
|
|
1088
|
+
let names = uniqLast(paths.flatMap((packagePath)=>{
|
|
1089
|
+
let found = packagePath.matchAll(PACKAGE_PATH_NAME);
|
|
1090
|
+
return found ? compact([
|
|
1091
|
+
...found
|
|
1092
|
+
].flat()).slice(1).filter(Boolean).map((name)=>name.replace(/\+/g, '/')) : [];
|
|
1093
|
+
}));
|
|
1094
|
+
if (isEmpty(names)) return {
|
|
1095
|
+
name: '',
|
|
1096
|
+
version: ''
|
|
1097
|
+
};
|
|
1098
|
+
let name = last(names), pattern = RegExp(`(.*)(${last(paths)}).*`), path1 = modulePath.replace(pattern, '$1$2').replace(/\/$/, '');
|
|
1099
|
+
return {
|
|
1100
|
+
name,
|
|
1101
|
+
version: path1 && name && path1.match(RegExp(`${name}@([\\d.]+)`))?.flat().slice(1)?.[0] || ''
|
|
1102
|
+
};
|
|
1103
|
+
}, external_os_namespaceObject = require("os");
|
|
1104
|
+
var external_os_default = __webpack_require__.n(external_os_namespaceObject);
|
|
1105
|
+
function writeMcpPort(port, builderName) {
|
|
1106
|
+
let homeDir = os.homedir(), rsdoctorDir = path.join(homeDir, '.cache/rsdoctor'), mcpPortFilePath = path.join(rsdoctorDir, 'mcp.json');
|
|
1107
|
+
fs.existsSync(rsdoctorDir) || fs.mkdirSync(rsdoctorDir, {
|
|
1108
|
+
recursive: !0
|
|
1109
|
+
});
|
|
1110
|
+
let mcpJson = {
|
|
1111
|
+
portList: {},
|
|
1112
|
+
port: 0
|
|
1113
|
+
};
|
|
1114
|
+
if (fs.existsSync(mcpPortFilePath)) try {
|
|
1115
|
+
mcpJson = JSON.parse(fs.readFileSync(mcpPortFilePath, 'utf8'));
|
|
1116
|
+
} catch (error) {
|
|
1117
|
+
logger.debug('Failed to parse mcp.json', error);
|
|
1118
|
+
}
|
|
1119
|
+
mcpJson.portList || (mcpJson.portList = {}), mcpJson.portList[builderName || 'builder'] = port, mcpJson.port = port, fs.writeFileSync(mcpPortFilePath, JSON.stringify(mcpJson, null, 2), 'utf8');
|
|
1120
|
+
}
|
|
1121
|
+
function getMcpConfigPath() {
|
|
1122
|
+
let homeDir = os.homedir(), rsdoctorDir = path.join(homeDir, '.cache/rsdoctor');
|
|
1123
|
+
return path.join(rsdoctorDir, 'mcp.json');
|
|
1124
|
+
}
|
|
1125
|
+
let external_stream_namespaceObject = require("stream"), maxFileSize = 419430400;
|
|
1126
|
+
function stringify(json, replacer, space, cycle) {
|
|
1127
|
+
let jsonList = [];
|
|
1128
|
+
return json && 'object' == typeof json ? new Promise((resolve, reject)=>{
|
|
1129
|
+
let stream = new external_json_stream_stringify_namespaceObject.JsonStreamStringify(json, replacer, space, cycle), currentLength = 0, currentContent = '', batchProcessor = new external_stream_namespaceObject.Transform({
|
|
1130
|
+
readableObjectMode: !0,
|
|
1131
|
+
transform (chunk, _encoding, callback) {
|
|
1132
|
+
chunk.toString().split('\\n').forEach((line)=>{
|
|
1133
|
+
currentLength + line.length > 419430400 && (jsonList.push(currentContent), currentContent = '', currentLength = 0), line.length && (currentContent += line, currentLength += line.length);
|
|
1134
|
+
}), callback();
|
|
1135
|
+
}
|
|
1136
|
+
});
|
|
1137
|
+
stream.pipe(batchProcessor).on('data', (line)=>{
|
|
1138
|
+
currentLength + line.length > 419430400 && (jsonList.push(currentContent), currentContent = '', currentLength = 0), line.length && (currentContent += line, currentLength += line.length);
|
|
1139
|
+
}).on('end', ()=>{
|
|
1140
|
+
jsonList.length < 1 && jsonList.push(currentContent), resolve(jsonList);
|
|
1141
|
+
}).on('error', (err)=>reject(err));
|
|
1142
|
+
}) : Promise.resolve(JSON.stringify(json, replacer, space));
|
|
1143
|
+
}
|
|
1144
|
+
let readPackageJson = (file, readFile)=>{
|
|
1145
|
+
let result, current = file;
|
|
1146
|
+
for(; '/' !== current && !result;){
|
|
1147
|
+
let parent = (0, external_path_namespaceObject.dirname)(current);
|
|
1148
|
+
if (parent === current) break;
|
|
1149
|
+
current = parent, readFile && (result = readFile((0, external_path_namespaceObject.join)(current, 'package.json'))), readFile ? result?.name || (result = void 0) : result = getPackageMetaFromModulePath(file);
|
|
1150
|
+
}
|
|
1151
|
+
if (result) return !readFile || result.name && result.version ? {
|
|
1152
|
+
...result,
|
|
1153
|
+
root: current
|
|
1154
|
+
} : readPackageJson((0, external_path_namespaceObject.dirname)(current), readFile);
|
|
1155
|
+
}, index_js_namespaceObject = require("../compiled/connect/index.js");
|
|
1156
|
+
var index_js_default = __webpack_require__.n(index_js_namespaceObject);
|
|
1157
|
+
let external_http_namespaceObject = require("http");
|
|
1158
|
+
var external_http_default = __webpack_require__.n(external_http_namespaceObject);
|
|
1159
|
+
let external_get_port_namespaceObject = require("get-port");
|
|
1160
|
+
var external_get_port_default = __webpack_require__.n(external_get_port_namespaceObject);
|
|
1161
|
+
let external_child_process_namespaceObject = require("child_process"), RESTRICTED_PORTS = [
|
|
1162
|
+
3659,
|
|
1163
|
+
4045,
|
|
1164
|
+
6000,
|
|
1165
|
+
6665,
|
|
1166
|
+
6666,
|
|
1167
|
+
6667,
|
|
1168
|
+
6668,
|
|
1169
|
+
6669
|
|
1170
|
+
];
|
|
1171
|
+
function getRandomPort(min, max) {
|
|
1172
|
+
let port;
|
|
1173
|
+
do port = random(min, max);
|
|
1174
|
+
while (RESTRICTED_PORTS.includes(port));
|
|
1175
|
+
return port;
|
|
1176
|
+
}
|
|
1177
|
+
let defaultPort = getRandomPort(3000, 8999);
|
|
1178
|
+
async function getPort(expectPort) {
|
|
1179
|
+
return external_get_port_default()({
|
|
1180
|
+
port: expectPort
|
|
1181
|
+
});
|
|
1182
|
+
}
|
|
1183
|
+
let createGetPortSyncFunctionString = (expectPort)=>`
|
|
1184
|
+
(() => {
|
|
1185
|
+
const net = require('net');
|
|
1186
|
+
|
|
1187
|
+
function getPort(expectPort) {
|
|
1188
|
+
return new Promise((resolve, reject) => {
|
|
1189
|
+
const server = net.createServer();
|
|
1190
|
+
server.unref();
|
|
1191
|
+
server.on('error', reject);
|
|
1192
|
+
server.listen(expectPort, () => {
|
|
1193
|
+
const { port } = server.address();
|
|
1194
|
+
server.close(() => {
|
|
1195
|
+
resolve(port);
|
|
1196
|
+
});
|
|
1197
|
+
});
|
|
1198
|
+
});
|
|
1199
|
+
}
|
|
1200
|
+
|
|
1201
|
+
async function getAvailablePort(expectPort) {
|
|
1202
|
+
let port = expectPort;
|
|
1203
|
+
while (true) {
|
|
1204
|
+
try {
|
|
1205
|
+
const res = await getPort(port);
|
|
1206
|
+
return res;
|
|
1207
|
+
} catch (error) {
|
|
1208
|
+
port += Math.floor(Math.random() * 100 + 1);
|
|
1209
|
+
}
|
|
1210
|
+
}
|
|
1211
|
+
}
|
|
1212
|
+
|
|
1213
|
+
getAvailablePort(${expectPort}).then(port => process.stdout.write(port.toString()));
|
|
1214
|
+
})();
|
|
1215
|
+
`.trim();
|
|
1216
|
+
function getPortSync(expectPort) {
|
|
1217
|
+
let statement = '\n' === external_os_default().EOL ? createGetPortSyncFunctionString(expectPort) : createGetPortSyncFunctionString(expectPort).replace(/\n/g, '');
|
|
1218
|
+
return Number((0, external_child_process_namespaceObject.execSync)(`node -e "${statement}"`, {
|
|
1219
|
+
encoding: 'utf-8'
|
|
1220
|
+
}));
|
|
1221
|
+
}
|
|
1222
|
+
function createApp() {
|
|
1223
|
+
return index_js_default()();
|
|
1224
|
+
}
|
|
1225
|
+
async function createServer(port) {
|
|
1226
|
+
let app = createApp(), server = external_http_default().createServer(app), res = {
|
|
1227
|
+
app,
|
|
1228
|
+
server,
|
|
1229
|
+
port,
|
|
1230
|
+
close: ()=>new Promise((resolve, reject)=>{
|
|
1231
|
+
'closeAllConnections' in server && server.closeAllConnections(), 'closeIdleConnections' in server && server.closeIdleConnections(), server.close((err)=>{
|
|
1232
|
+
err && reject(err), resolve();
|
|
1233
|
+
});
|
|
1234
|
+
})
|
|
1235
|
+
};
|
|
1236
|
+
return new Promise((resolve)=>{
|
|
1237
|
+
server.listen(port, ()=>{
|
|
1238
|
+
resolve(res);
|
|
1239
|
+
});
|
|
1240
|
+
});
|
|
1241
|
+
}
|
|
1242
|
+
let external_envinfo_namespaceObject = require("envinfo");
|
|
1243
|
+
var external_envinfo_default = __webpack_require__.n(external_envinfo_namespaceObject);
|
|
1244
|
+
let helpers = external_envinfo_default().helpers, run = external_envinfo_default().run, getCPUInfo = ()=>helpers.getCPUInfo().then((res)=>res[1]), getOSInfo = ()=>helpers.getOSInfo().then((res)=>res[1]), getMemoryInfo = ()=>helpers.getMemoryInfo().then((res)=>res[1]), getNodeVersion = ()=>helpers.getNodeInfo().then((res)=>res[1]), getYarnVersion = ()=>helpers.getYarnInfo().then((res)=>res[1]), getNpmVersion = ()=>helpers.getnpmInfo().then((res)=>res[1]), getPnpmVersion = ()=>helpers.getpnpmInfo().then((res)=>res[1]);
|
|
1245
|
+
function getNpmPackageVersion(pkg) {
|
|
1246
|
+
let isArray = Array.isArray(pkg);
|
|
1247
|
+
return run({
|
|
1248
|
+
npmPackages: isArray ? pkg : [
|
|
1249
|
+
pkg
|
|
1250
|
+
]
|
|
1251
|
+
}, {
|
|
1252
|
+
json: !0,
|
|
1253
|
+
showNotFound: !0
|
|
1254
|
+
}).then((res)=>{
|
|
1255
|
+
let { npmPackages = {} } = JSON.parse(res) || {};
|
|
1256
|
+
return isArray ? pkg.map((e)=>npmPackages[e] || 'Not Found') : npmPackages[pkg];
|
|
1257
|
+
});
|
|
1258
|
+
}
|
|
1259
|
+
function getGlobalNpmPackageVersion(pkg) {
|
|
1260
|
+
let isArray = Array.isArray(pkg);
|
|
1261
|
+
return run({
|
|
1262
|
+
npmGlobalPackages: isArray ? pkg : [
|
|
1263
|
+
pkg
|
|
1264
|
+
]
|
|
1265
|
+
}, {
|
|
1266
|
+
json: !0,
|
|
1267
|
+
showNotFound: !0
|
|
1268
|
+
}).then((res)=>{
|
|
1269
|
+
let { npmGlobalPackages = {} } = JSON.parse(res) || {};
|
|
1270
|
+
return isArray ? pkg.map((e)=>npmGlobalPackages[e] || 'Not Found') : npmGlobalPackages[pkg];
|
|
1271
|
+
});
|
|
1272
|
+
}
|
|
1273
|
+
function getGitBranch() {
|
|
1274
|
+
return new Promise((resolve, reject)=>{
|
|
1275
|
+
(0, external_child_process_namespaceObject.exec)('git branch --show-current', (err, stdout)=>{
|
|
1276
|
+
err ? (0, external_child_process_namespaceObject.exec)('git branch', (err, stdout)=>{
|
|
1277
|
+
err ? reject(err) : resolve(stdout.split('\n').map((e)=>e.replace('* ', '')).join('').trim());
|
|
1278
|
+
}) : resolve(stdout.trim());
|
|
1279
|
+
});
|
|
1280
|
+
});
|
|
1281
|
+
}
|
|
1282
|
+
function getGitRepo() {
|
|
1283
|
+
return new Promise((resolve, reject)=>{
|
|
1284
|
+
(0, external_child_process_namespaceObject.exec)('git config --get remote.origin.url', (err, stdout)=>{
|
|
1285
|
+
err ? reject(err) : resolve(stdout.trim());
|
|
1286
|
+
});
|
|
1287
|
+
});
|
|
1288
|
+
}
|
|
1289
|
+
let filesize_index_js_namespaceObject = require("../compiled/filesize/index.js");
|
|
1290
|
+
function getMemoryUsage() {
|
|
1291
|
+
return (0, external_process_namespaceObject.memoryUsage)();
|
|
1292
|
+
}
|
|
1293
|
+
function getMemoryUsageMessage() {
|
|
1294
|
+
let usage = getMemoryUsage(), msgs = [
|
|
1295
|
+
`RSS: ${(0, filesize_index_js_namespaceObject.filesize)(usage.rss)}`,
|
|
1296
|
+
`Heap Total: ${(0, filesize_index_js_namespaceObject.filesize)(usage.heapTotal)}`,
|
|
1297
|
+
`Heap Used: ${(0, filesize_index_js_namespaceObject.filesize)(usage.heapUsed)}`
|
|
1298
|
+
];
|
|
1299
|
+
return usage.arrayBuffers && msgs.push(`ArrayBuffers: ${(0, filesize_index_js_namespaceObject.filesize)(usage.arrayBuffers)}`), usage.external && msgs.push(`External: ${(0, filesize_index_js_namespaceObject.filesize)(usage.external)}`), `["${external_process_namespaceObject.pid}" Memory Usage] ${msgs.join(', ')}`;
|
|
1300
|
+
}
|
|
1301
|
+
for(var __webpack_i__ in exports.EnvInfo = __webpack_exports__.EnvInfo, exports.File = __webpack_exports__.File, exports.Json = __webpack_exports__.Json, exports.Process = __webpack_exports__.Process, exports.Server = __webpack_exports__.Server, __webpack_exports__)-1 === [
|
|
1302
|
+
"EnvInfo",
|
|
1303
|
+
"File",
|
|
1304
|
+
"Json",
|
|
1305
|
+
"Process",
|
|
1306
|
+
"Server"
|
|
1307
|
+
].indexOf(__webpack_i__) && (exports[__webpack_i__] = __webpack_exports__[__webpack_i__]);
|
|
1308
|
+
Object.defineProperty(exports, '__esModule', {
|
|
1309
|
+
value: !0
|
|
1310
|
+
});
|