@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.
Files changed (211) hide show
  1. package/compiled/connect/index.d.ts +90 -0
  2. package/compiled/connect/index.js +2427 -0
  3. package/compiled/connect/license +25 -0
  4. package/compiled/connect/package.json +1 -0
  5. package/compiled/filesize/index.d.ts +58 -0
  6. package/compiled/filesize/index.js +255 -0
  7. package/compiled/filesize/license +28 -0
  8. package/compiled/filesize/package.json +1 -0
  9. package/dist/{type/build → build}/envinfo.d.ts +0 -1
  10. package/dist/{type/build → build}/file/cache.d.ts +0 -1
  11. package/dist/build/file/index.d.ts +3 -0
  12. package/dist/{type/build → build}/file/sharding.d.ts +0 -1
  13. package/dist/{type/build → build}/index.d.ts +0 -1
  14. package/dist/{type/build → build}/json.d.ts +0 -1
  15. package/dist/{type/build → build}/process.d.ts +0 -1
  16. package/dist/{type/build → build}/server.d.ts +0 -1
  17. package/dist/build.cjs +1310 -0
  18. package/dist/build.js +343 -0
  19. package/dist/{type/common → common}/alerts.d.ts +0 -1
  20. package/dist/{type/common → common}/algorithm.d.ts +0 -1
  21. package/dist/{type/common → common}/bundle.d.ts +0 -1
  22. package/dist/{type/common → common}/crypto.d.ts +0 -1
  23. package/dist/{type/common → common}/data/index.d.ts +0 -1
  24. package/dist/{type/common → common}/file.d.ts +0 -1
  25. package/dist/{type/common → common}/global-config.d.ts +0 -1
  26. package/dist/{type/common → common}/graph/assets.d.ts +0 -1
  27. package/dist/{type/common → common}/graph/chunk.d.ts +0 -1
  28. package/dist/{type/common → common}/graph/dependency.d.ts +0 -1
  29. package/dist/{type/common → common}/graph/entrypoints.d.ts +0 -1
  30. package/dist/{type/common → common}/graph/index.d.ts +0 -1
  31. package/dist/{type/common → common}/graph/modules.d.ts +0 -1
  32. package/dist/{type/common → common}/index.d.ts +0 -1
  33. package/dist/{type/common → common}/loader.d.ts +0 -1
  34. package/dist/{type/common → common}/lodash.d.ts +0 -1
  35. package/dist/{type/common → common}/manifest.d.ts +0 -1
  36. package/dist/{type/common → common}/package.d.ts +0 -1
  37. package/dist/{type/common → common}/plugin.d.ts +0 -1
  38. package/dist/{type/common → common}/resolver.d.ts +0 -1
  39. package/dist/{type/common → common}/rspack.d.ts +0 -1
  40. package/dist/{type/common → common}/summary.d.ts +0 -1
  41. package/dist/{type/common → common}/time.d.ts +0 -1
  42. package/dist/{type/common → common}/url.d.ts +0 -1
  43. package/dist/common.cjs +1328 -0
  44. package/dist/common.js +1255 -0
  45. package/dist/{type/error → error}/error.d.ts +0 -1
  46. package/dist/{type/error → error}/index.d.ts +0 -1
  47. package/dist/{type/error → error}/transform.d.ts +0 -1
  48. package/dist/{type/error → error}/utils.d.ts +0 -1
  49. package/dist/error.cjs +310 -0
  50. package/dist/error.js +232 -0
  51. package/dist/logger.cjs +82 -0
  52. package/dist/{type/logger.d.ts → logger.d.ts} +0 -1
  53. package/dist/{esm/logger.mjs → logger.js} +8 -13
  54. package/dist/{type/rule-utils → rule-utils}/document/document.d.ts +0 -1
  55. package/dist/{type/rule-utils → rule-utils}/document/index.d.ts +0 -1
  56. package/dist/{type/rule-utils → rule-utils}/document/server.d.ts +0 -1
  57. package/dist/{type/rule-utils → rule-utils}/document/types.d.ts +0 -1
  58. package/dist/{type/rule-utils → rule-utils}/index.d.ts +0 -1
  59. package/dist/{type/rule-utils → rule-utils}/parser/asserts.d.ts +0 -1
  60. package/dist/{type/rule-utils → rule-utils}/parser/index.d.ts +0 -1
  61. package/dist/{type/rule-utils → rule-utils}/parser/parser.d.ts +0 -1
  62. package/dist/{type/rule-utils → rule-utils}/parser/types.d.ts +0 -1
  63. package/dist/{type/rule-utils → rule-utils}/parser/utils.d.ts +0 -1
  64. package/dist/ruleUtils.cjs +320 -0
  65. package/dist/ruleUtils.js +256 -0
  66. package/package.json +35 -39
  67. package/dist/cjs/build/envinfo.js +0 -121
  68. package/dist/cjs/build/file/cache.js +0 -76
  69. package/dist/cjs/build/file/index.js +0 -81
  70. package/dist/cjs/build/file/sharding.js +0 -96
  71. package/dist/cjs/build/index.js +0 -52
  72. package/dist/cjs/build/json.js +0 -103
  73. package/dist/cjs/build/process.js +0 -54
  74. package/dist/cjs/build/server.js +0 -158
  75. package/dist/cjs/common/alerts.js +0 -51
  76. package/dist/cjs/common/algorithm.js +0 -75
  77. package/dist/cjs/common/bundle.js +0 -62
  78. package/dist/cjs/common/crypto.js +0 -54
  79. package/dist/cjs/common/data/index.js +0 -396
  80. package/dist/cjs/common/file.js +0 -44
  81. package/dist/cjs/common/global-config.js +0 -81
  82. package/dist/cjs/common/graph/assets.js +0 -314
  83. package/dist/cjs/common/graph/chunk.js +0 -81
  84. package/dist/cjs/common/graph/dependency.js +0 -50
  85. package/dist/cjs/common/graph/entrypoints.js +0 -38
  86. package/dist/cjs/common/graph/index.js +0 -96
  87. package/dist/cjs/common/graph/modules.js +0 -133
  88. package/dist/cjs/common/index.js +0 -104
  89. package/dist/cjs/common/loader.js +0 -320
  90. package/dist/cjs/common/lodash.js +0 -93
  91. package/dist/cjs/common/manifest.js +0 -70
  92. package/dist/cjs/common/package.js +0 -96
  93. package/dist/cjs/common/plugin.js +0 -91
  94. package/dist/cjs/common/resolver.js +0 -92
  95. package/dist/cjs/common/rspack.js +0 -65
  96. package/dist/cjs/common/summary.js +0 -42
  97. package/dist/cjs/common/time.js +0 -86
  98. package/dist/cjs/common/url.js +0 -54
  99. package/dist/cjs/error/error.js +0 -199
  100. package/dist/cjs/error/index.js +0 -73
  101. package/dist/cjs/error/transform.js +0 -182
  102. package/dist/cjs/error/utils.js +0 -62
  103. package/dist/cjs/index.js +0 -40
  104. package/dist/cjs/logger.js +0 -106
  105. package/dist/cjs/rule-utils/document/document.js +0 -92
  106. package/dist/cjs/rule-utils/document/index.js +0 -78
  107. package/dist/cjs/rule-utils/document/server.js +0 -49
  108. package/dist/cjs/rule-utils/document/types.js +0 -18
  109. package/dist/cjs/rule-utils/index.js +0 -69
  110. package/dist/cjs/rule-utils/parser/asserts.js +0 -138
  111. package/dist/cjs/rule-utils/parser/index.js +0 -87
  112. package/dist/cjs/rule-utils/parser/parser.js +0 -57
  113. package/dist/cjs/rule-utils/parser/types.js +0 -41
  114. package/dist/cjs/rule-utils/parser/utils.js +0 -170
  115. package/dist/esm/build/envinfo.mjs +0 -57
  116. package/dist/esm/build/file/cache.mjs +0 -23
  117. package/dist/esm/build/file/index.mjs +0 -4
  118. package/dist/esm/build/file/sharding.mjs +0 -50
  119. package/dist/esm/build/index.mjs +0 -6
  120. package/dist/esm/build/json.mjs +0 -66
  121. package/dist/esm/build/process.mjs +0 -17
  122. package/dist/esm/build/server.mjs +0 -96
  123. package/dist/esm/common/alerts.mjs +0 -17
  124. package/dist/esm/common/algorithm.mjs +0 -32
  125. package/dist/esm/common/bundle.mjs +0 -22
  126. package/dist/esm/common/crypto.mjs +0 -17
  127. package/dist/esm/common/data/index.mjs +0 -362
  128. package/dist/esm/common/file.mjs +0 -7
  129. package/dist/esm/common/global-config.mjs +0 -32
  130. package/dist/esm/common/graph/assets.mjs +0 -238
  131. package/dist/esm/common/graph/chunk.mjs +0 -32
  132. package/dist/esm/common/graph/dependency.mjs +0 -10
  133. package/dist/esm/common/graph/entrypoints.mjs +0 -4
  134. package/dist/esm/common/graph/index.mjs +0 -5
  135. package/dist/esm/common/graph/modules.mjs +0 -78
  136. package/dist/esm/common/index.mjs +0 -19
  137. package/dist/esm/common/loader.mjs +0 -247
  138. package/dist/esm/common/lodash.mjs +0 -32
  139. package/dist/esm/common/manifest.mjs +0 -30
  140. package/dist/esm/common/package.mjs +0 -56
  141. package/dist/esm/common/plugin.mjs +0 -48
  142. package/dist/esm/common/resolver.mjs +0 -46
  143. package/dist/esm/common/rspack.mjs +0 -25
  144. package/dist/esm/common/summary.mjs +0 -8
  145. package/dist/esm/common/time.mjs +0 -43
  146. package/dist/esm/common/url.mjs +0 -14
  147. package/dist/esm/error/error.mjs +0 -154
  148. package/dist/esm/error/index.mjs +0 -3
  149. package/dist/esm/error/transform.mjs +0 -138
  150. package/dist/esm/error/utils.mjs +0 -22
  151. package/dist/esm/index.mjs +0 -3
  152. package/dist/esm/rule-utils/document/document.mjs +0 -58
  153. package/dist/esm/rule-utils/document/index.mjs +0 -3
  154. package/dist/esm/rule-utils/document/server.mjs +0 -12
  155. package/dist/esm/rule-utils/document/types.mjs +0 -0
  156. package/dist/esm/rule-utils/index.mjs +0 -2
  157. package/dist/esm/rule-utils/parser/asserts.mjs +0 -104
  158. package/dist/esm/rule-utils/parser/index.mjs +0 -4
  159. package/dist/esm/rule-utils/parser/parser.mjs +0 -23
  160. package/dist/esm/rule-utils/parser/types.mjs +0 -7
  161. package/dist/esm/rule-utils/parser/utils.mjs +0 -109
  162. package/dist/type/build/envinfo.d.ts.map +0 -1
  163. package/dist/type/build/file/cache.d.ts.map +0 -1
  164. package/dist/type/build/file/index.d.ts +0 -4
  165. package/dist/type/build/file/index.d.ts.map +0 -1
  166. package/dist/type/build/file/sharding.d.ts.map +0 -1
  167. package/dist/type/build/index.d.ts.map +0 -1
  168. package/dist/type/build/json.d.ts.map +0 -1
  169. package/dist/type/build/process.d.ts.map +0 -1
  170. package/dist/type/build/server.d.ts.map +0 -1
  171. package/dist/type/common/alerts.d.ts.map +0 -1
  172. package/dist/type/common/algorithm.d.ts.map +0 -1
  173. package/dist/type/common/bundle.d.ts.map +0 -1
  174. package/dist/type/common/crypto.d.ts.map +0 -1
  175. package/dist/type/common/data/index.d.ts.map +0 -1
  176. package/dist/type/common/file.d.ts.map +0 -1
  177. package/dist/type/common/global-config.d.ts.map +0 -1
  178. package/dist/type/common/graph/assets.d.ts.map +0 -1
  179. package/dist/type/common/graph/chunk.d.ts.map +0 -1
  180. package/dist/type/common/graph/dependency.d.ts.map +0 -1
  181. package/dist/type/common/graph/entrypoints.d.ts.map +0 -1
  182. package/dist/type/common/graph/index.d.ts.map +0 -1
  183. package/dist/type/common/graph/modules.d.ts.map +0 -1
  184. package/dist/type/common/index.d.ts.map +0 -1
  185. package/dist/type/common/loader.d.ts.map +0 -1
  186. package/dist/type/common/lodash.d.ts.map +0 -1
  187. package/dist/type/common/manifest.d.ts.map +0 -1
  188. package/dist/type/common/package.d.ts.map +0 -1
  189. package/dist/type/common/plugin.d.ts.map +0 -1
  190. package/dist/type/common/resolver.d.ts.map +0 -1
  191. package/dist/type/common/rspack.d.ts.map +0 -1
  192. package/dist/type/common/summary.d.ts.map +0 -1
  193. package/dist/type/common/time.d.ts.map +0 -1
  194. package/dist/type/common/url.d.ts.map +0 -1
  195. package/dist/type/error/error.d.ts.map +0 -1
  196. package/dist/type/error/index.d.ts.map +0 -1
  197. package/dist/type/error/transform.d.ts.map +0 -1
  198. package/dist/type/error/utils.d.ts.map +0 -1
  199. package/dist/type/index.d.ts +0 -3
  200. package/dist/type/index.d.ts.map +0 -1
  201. package/dist/type/logger.d.ts.map +0 -1
  202. package/dist/type/rule-utils/document/document.d.ts.map +0 -1
  203. package/dist/type/rule-utils/document/index.d.ts.map +0 -1
  204. package/dist/type/rule-utils/document/server.d.ts.map +0 -1
  205. package/dist/type/rule-utils/document/types.d.ts.map +0 -1
  206. package/dist/type/rule-utils/index.d.ts.map +0 -1
  207. package/dist/type/rule-utils/parser/asserts.d.ts.map +0 -1
  208. package/dist/type/rule-utils/parser/index.d.ts.map +0 -1
  209. package/dist/type/rule-utils/parser/parser.d.ts.map +0 -1
  210. package/dist/type/rule-utils/parser/types.d.ts.map +0 -1
  211. package/dist/type/rule-utils/parser/utils.d.ts.map +0 -1
@@ -1,170 +0,0 @@
1
- "use strict";
2
- var __webpack_require__ = {};
3
- (()=>{
4
- __webpack_require__.d = (exports1, definition)=>{
5
- for(var key in definition)if (__webpack_require__.o(definition, key) && !__webpack_require__.o(exports1, key)) Object.defineProperty(exports1, key, {
6
- enumerable: true,
7
- get: definition[key]
8
- });
9
- };
10
- })();
11
- (()=>{
12
- __webpack_require__.o = (obj, prop)=>Object.prototype.hasOwnProperty.call(obj, prop);
13
- })();
14
- (()=>{
15
- __webpack_require__.r = (exports1)=>{
16
- if ('undefined' != typeof Symbol && Symbol.toStringTag) Object.defineProperty(exports1, Symbol.toStringTag, {
17
- value: 'Module'
18
- });
19
- Object.defineProperty(exports1, '__esModule', {
20
- value: true
21
- });
22
- };
23
- })();
24
- var __webpack_exports__ = {};
25
- __webpack_require__.r(__webpack_exports__);
26
- __webpack_require__.d(__webpack_exports__, {
27
- isES6: ()=>isES6,
28
- getIdentifierInDeclaration: ()=>getIdentifierInDeclaration,
29
- getIdentifierInExport: ()=>getIdentifierInExport,
30
- isSameSemantics: ()=>isSameSemantics,
31
- getIdentifierInImport: ()=>getIdentifierInImport,
32
- canParse: ()=>canParse,
33
- getIdentifierInPattern: ()=>getIdentifierInPattern,
34
- getDefaultImports: ()=>getDefaultImports,
35
- isES5: ()=>isES5,
36
- detectECMAVersion: ()=>detectECMAVersion
37
- });
38
- const external_acorn_namespaceObject = require("acorn");
39
- const external_types_js_namespaceObject = require("./types.js");
40
- const external_asserts_js_namespaceObject = require("./asserts.js");
41
- function isSameSemantics(node1, node2) {
42
- if (node1.type !== node2.type) return false;
43
- switch(node1.type){
44
- case 'CallExpression':
45
- {
46
- const next = node2;
47
- return node1.arguments.length === next.arguments.length && Boolean(node1.optional) === Boolean(next.optional) && isSameSemantics(node1.callee, next.callee) && node1.arguments.every((node, i)=>isSameSemantics(node, next.arguments[i]));
48
- }
49
- case 'MemberExpression':
50
- {
51
- const next = node2;
52
- return node1.computed === next.computed && Boolean(node1.optional) === Boolean(next.optional) && isSameSemantics(node1.object, next.object) && isSameSemantics(node1.property, next.property);
53
- }
54
- case 'Identifier':
55
- return node1.name === node2.name;
56
- case 'Literal':
57
- if (external_asserts_js_namespaceObject.asserts.isSimpleLiteral(node1) && external_asserts_js_namespaceObject.asserts.isSimpleLiteral(node2)) return node1.value === node2.value;
58
- return node1.raw === node2.raw;
59
- case 'ObjectExpression':
60
- {
61
- const next = node2;
62
- return node1.properties.length === next.properties.length && node1.properties.every((prop, i)=>isSameSemantics(prop, next.properties[i]));
63
- }
64
- case 'Property':
65
- {
66
- const next = node2;
67
- return node1.computed === next.computed && node1.kind === next.kind && node1.method === next.method && isSameSemantics(node1.key, next.key) && isSameSemantics(node1.value, next.value);
68
- }
69
- default:
70
- throw new Error(`Unknown node type: ${node1.type}`);
71
- }
72
- }
73
- function getDefaultImports(node) {
74
- return node.body.filter((statement)=>{
75
- var _statement_specifiers;
76
- if ('ImportDeclaration' !== statement.type) return false;
77
- const specifier = null == statement ? void 0 : null == (_statement_specifiers = statement.specifiers) ? void 0 : _statement_specifiers[0];
78
- if ((null == specifier ? void 0 : specifier.type) === 'ImportDefaultSpecifier') return true;
79
- return false;
80
- });
81
- }
82
- function getIdentifierInPattern(name, node) {
83
- if (external_asserts_js_namespaceObject.asserts.isIdentifier(node) && node.name === name) return node;
84
- if (external_asserts_js_namespaceObject.asserts.isObjectPattern(node)) for (const prop of node.properties){
85
- if (external_asserts_js_namespaceObject.asserts.isAssignmentProperty(prop)) return getIdentifierInPattern(name, prop.value);
86
- if (external_asserts_js_namespaceObject.asserts.isRestElement(prop)) return getIdentifierInPattern(name, prop);
87
- }
88
- if (external_asserts_js_namespaceObject.asserts.isArrayPattern(node)) {
89
- for (const el of node.elements)if (el) {
90
- const result = getIdentifierInPattern(name, el);
91
- if (result) return result;
92
- }
93
- }
94
- if (external_asserts_js_namespaceObject.asserts.isRestElement(node)) return getIdentifierInPattern(name, node.argument);
95
- if (external_asserts_js_namespaceObject.asserts.isAssignmentPattern(node)) return getIdentifierInPattern(name, node.left);
96
- }
97
- function getIdentifierInDeclaration(name, node) {
98
- function getId(node) {
99
- return external_asserts_js_namespaceObject.asserts.isIdentifier(node.id) && node.id.name === name ? node.id : void 0;
100
- }
101
- if (external_asserts_js_namespaceObject.asserts.isFunctionDeclaration(node)) return getId(node);
102
- if (external_asserts_js_namespaceObject.asserts.isClassDeclaration(node)) return getId(node);
103
- if (external_asserts_js_namespaceObject.asserts.isVariableDeclaration(node)) {
104
- var _node_declarations_find;
105
- return null == (_node_declarations_find = node.declarations.find((item)=>getIdentifierInPattern(name, item.id))) ? void 0 : _node_declarations_find.id;
106
- }
107
- }
108
- function getIdentifierInImport(name, node) {
109
- if (external_asserts_js_namespaceObject.asserts.isImportDeclaration(node)) {
110
- for (const specifier of node.specifiers ?? [])if (specifier.local.name === name) return specifier.local;
111
- }
112
- }
113
- function getIdentifierInExport(name, node) {
114
- if (external_asserts_js_namespaceObject.asserts.isExportNamedDeclaration(node)) {
115
- if (node.declaration) return getIdentifierInDeclaration(name, node.declaration);
116
- for (const specifier of node.specifiers ?? [])if (specifier.exported.name === name) return specifier.exported;
117
- }
118
- if (external_asserts_js_namespaceObject.asserts.isExportAllDeclaration(node) && node.exported) {
119
- if (node.exported.name === name) return node.exported;
120
- }
121
- }
122
- function canParse(code, ecmaVersion) {
123
- try {
124
- (0, external_acorn_namespaceObject.parse)(code, {
125
- ecmaVersion,
126
- sourceType: 'number' == typeof ecmaVersion && ecmaVersion <= 5 ? "script" : 'module'
127
- });
128
- return true;
129
- } catch (err) {
130
- return false;
131
- }
132
- }
133
- function isES5(code) {
134
- return canParse(code, 5);
135
- }
136
- function isES6(code) {
137
- return canParse(code, 6);
138
- }
139
- function detectECMAVersion(code) {
140
- if (isES6(code)) {
141
- if (isES5(code)) return external_types_js_namespaceObject.ECMAVersion.ES5;
142
- return external_types_js_namespaceObject.ECMAVersion.ES6;
143
- }
144
- return external_types_js_namespaceObject.ECMAVersion.ES7P;
145
- }
146
- exports.canParse = __webpack_exports__.canParse;
147
- exports.detectECMAVersion = __webpack_exports__.detectECMAVersion;
148
- exports.getDefaultImports = __webpack_exports__.getDefaultImports;
149
- exports.getIdentifierInDeclaration = __webpack_exports__.getIdentifierInDeclaration;
150
- exports.getIdentifierInExport = __webpack_exports__.getIdentifierInExport;
151
- exports.getIdentifierInImport = __webpack_exports__.getIdentifierInImport;
152
- exports.getIdentifierInPattern = __webpack_exports__.getIdentifierInPattern;
153
- exports.isES5 = __webpack_exports__.isES5;
154
- exports.isES6 = __webpack_exports__.isES6;
155
- exports.isSameSemantics = __webpack_exports__.isSameSemantics;
156
- for(var __webpack_i__ in __webpack_exports__)if (-1 === [
157
- "canParse",
158
- "detectECMAVersion",
159
- "getDefaultImports",
160
- "getIdentifierInDeclaration",
161
- "getIdentifierInExport",
162
- "getIdentifierInImport",
163
- "getIdentifierInPattern",
164
- "isES5",
165
- "isES6",
166
- "isSameSemantics"
167
- ].indexOf(__webpack_i__)) exports[__webpack_i__] = __webpack_exports__[__webpack_i__];
168
- Object.defineProperty(exports, '__esModule', {
169
- value: true
170
- });
@@ -1,57 +0,0 @@
1
- import { helpers, run } from "envinfo";
2
- import { exec } from "child_process";
3
- const getCPUInfo = ()=>helpers.getCPUInfo().then((res)=>res[1]);
4
- const getOSInfo = ()=>helpers.getOSInfo().then((res)=>res[1]);
5
- const getMemoryInfo = ()=>helpers.getMemoryInfo().then((res)=>res[1]);
6
- const getNodeVersion = ()=>helpers.getNodeInfo().then((res)=>res[1]);
7
- const getYarnVersion = ()=>helpers.getYarnInfo().then((res)=>res[1]);
8
- const getNpmVersion = ()=>helpers.getnpmInfo().then((res)=>res[1]);
9
- const getPnpmVersion = ()=>helpers.getpnpmInfo().then((res)=>res[1]);
10
- function getNpmPackageVersion(pkg) {
11
- const isArray = Array.isArray(pkg);
12
- return run({
13
- npmPackages: isArray ? pkg : [
14
- pkg
15
- ]
16
- }, {
17
- json: true,
18
- showNotFound: true
19
- }).then((res)=>{
20
- const { npmPackages = {} } = JSON.parse(res) || {};
21
- return isArray ? pkg.map((e)=>npmPackages[e] || 'Not Found') : npmPackages[pkg];
22
- });
23
- }
24
- function getGlobalNpmPackageVersion(pkg) {
25
- const isArray = Array.isArray(pkg);
26
- return run({
27
- npmGlobalPackages: isArray ? pkg : [
28
- pkg
29
- ]
30
- }, {
31
- json: true,
32
- showNotFound: true
33
- }).then((res)=>{
34
- const { npmGlobalPackages = {} } = JSON.parse(res) || {};
35
- return isArray ? pkg.map((e)=>npmGlobalPackages[e] || 'Not Found') : npmGlobalPackages[pkg];
36
- });
37
- }
38
- function getGitBranch() {
39
- return new Promise((resolve, reject)=>{
40
- exec('git branch --show-current', (err, stdout)=>{
41
- if (err) exec('git branch', (err, stdout)=>{
42
- if (err) reject(err);
43
- else resolve(stdout.split('\n').map((e)=>e.replace('* ', '')).join('').trim());
44
- });
45
- else resolve(stdout.trim());
46
- });
47
- });
48
- }
49
- function getGitRepo() {
50
- return new Promise((resolve, reject)=>{
51
- exec('git config --get remote.origin.url', (err, stdout)=>{
52
- if (err) reject(err);
53
- else resolve(stdout.trim());
54
- });
55
- });
56
- }
57
- export { getCPUInfo, getGitBranch, getGitRepo, getGlobalNpmPackageVersion, getMemoryInfo, getNodeVersion, getNpmPackageVersion, getNpmVersion, getOSInfo, getPnpmVersion, getYarnVersion };
@@ -1,23 +0,0 @@
1
- import fs_extra from "fs-extra";
2
- const cache = new Map();
3
- async function readFile(path) {
4
- if (cache.has(path)) return cache.get(path);
5
- const res = await fs_extra.readFile(path, 'utf-8');
6
- cache.set(path, res);
7
- return res;
8
- }
9
- function readFileSync(path) {
10
- if (cache.has(path)) return cache.get(path);
11
- const res = fs_extra.readFileSync(path, 'utf-8');
12
- cache.set(path, res);
13
- return res;
14
- }
15
- async function readJSON(path) {
16
- const str = await readFile(path);
17
- return JSON.parse(str);
18
- }
19
- function readJSONSync(path) {
20
- const str = readFileSync(path);
21
- return JSON.parse(str);
22
- }
23
- export { readFile, readFileSync, readJSON, readJSONSync };
@@ -1,4 +0,0 @@
1
- export * from "./sharding.mjs";
2
- import * as __WEBPACK_EXTERNAL_MODULE_fs_extra_ce68a66b__ from "fs-extra";
3
- import * as __WEBPACK_EXTERNAL_MODULE__cache_mjs_b6df9da1__ from "./cache.mjs";
4
- export { __WEBPACK_EXTERNAL_MODULE__cache_mjs_b6df9da1__ as cache, __WEBPACK_EXTERNAL_MODULE_fs_extra_ce68a66b__ as fse };
@@ -1,50 +0,0 @@
1
- import fs_extra from "fs-extra";
2
- import fs from "fs";
3
- import path from "path";
4
- function _define_property(obj, key, value) {
5
- if (key in obj) Object.defineProperty(obj, key, {
6
- value: value,
7
- enumerable: true,
8
- configurable: true,
9
- writable: true
10
- });
11
- else obj[key] = value;
12
- return obj;
13
- }
14
- class FileSharding {
15
- createVirtualShardingFiles(ext = '', index = 0) {
16
- const bf = Buffer.from(this.content, this.encoding);
17
- const res = [];
18
- const threshold = this.limitBytes;
19
- let tmpBytes = 0;
20
- while(bf.byteLength > tmpBytes){
21
- res.push(bf.subarray(tmpBytes, tmpBytes + threshold));
22
- tmpBytes += threshold;
23
- }
24
- return res.map((e, i)=>({
25
- filename: `${i + index}${ext}`,
26
- content: e
27
- }));
28
- }
29
- async writeStringToFolder(folder, ext = '', index) {
30
- const dist = path.resolve(folder);
31
- await fs_extra.ensureDir(dist);
32
- const res = this.createVirtualShardingFiles(ext, index);
33
- await Promise.all(res.map((e)=>new Promise((resolve, reject)=>{
34
- const stream = fs.createWriteStream(path.join(dist, e.filename), this.encoding);
35
- stream.end(e.content);
36
- stream.once('close', ()=>resolve(void 0));
37
- stream.once('error', (err)=>reject(err));
38
- })));
39
- return res;
40
- }
41
- constructor(content, limitBytes = 10485760, encoding = 'utf-8'){
42
- _define_property(this, "content", void 0);
43
- _define_property(this, "limitBytes", void 0);
44
- _define_property(this, "encoding", void 0);
45
- this.content = content;
46
- this.limitBytes = limitBytes;
47
- this.encoding = encoding;
48
- }
49
- }
50
- export { FileSharding };
@@ -1,6 +0,0 @@
1
- import * as __WEBPACK_EXTERNAL_MODULE__file_index_mjs_bb48710d__ from "./file/index.mjs";
2
- import * as __WEBPACK_EXTERNAL_MODULE__json_mjs_4d5c7582__ from "./json.mjs";
3
- import * as __WEBPACK_EXTERNAL_MODULE__server_mjs_d774bffd__ from "./server.mjs";
4
- import * as __WEBPACK_EXTERNAL_MODULE__envinfo_mjs_e2a5d4a8__ from "./envinfo.mjs";
5
- import * as __WEBPACK_EXTERNAL_MODULE__process_mjs_2ae7d58e__ from "./process.mjs";
6
- export { __WEBPACK_EXTERNAL_MODULE__envinfo_mjs_e2a5d4a8__ as EnvInfo, __WEBPACK_EXTERNAL_MODULE__file_index_mjs_bb48710d__ as File, __WEBPACK_EXTERNAL_MODULE__json_mjs_4d5c7582__ as Json, __WEBPACK_EXTERNAL_MODULE__process_mjs_2ae7d58e__ as Process, __WEBPACK_EXTERNAL_MODULE__server_mjs_d774bffd__ as Server };
@@ -1,66 +0,0 @@
1
- import { JsonStreamStringify } from "json-stream-stringify";
2
- import { dirname, join } from "path";
3
- import { Package } from "../common/index.mjs";
4
- import { Transform } from "stream";
5
- const maxFileSize = 419430400;
6
- function stringify(json, replacer, space, cycle) {
7
- const jsonList = [];
8
- if (json && 'object' == typeof json) return new Promise((resolve, reject)=>{
9
- const stream = new JsonStreamStringify(json, replacer, space, cycle);
10
- let currentLength = 0;
11
- let currentContent = '';
12
- const batchProcessor = new Transform({
13
- readableObjectMode: true,
14
- transform (chunk, _encoding, callback) {
15
- const lines = chunk.toString().split('\\n');
16
- lines.forEach((line)=>{
17
- if (currentLength + line.length > maxFileSize) {
18
- jsonList.push(currentContent);
19
- currentContent = '';
20
- currentLength = 0;
21
- }
22
- if (line.length) {
23
- currentContent += line;
24
- currentLength += line.length;
25
- }
26
- });
27
- callback();
28
- }
29
- });
30
- stream.pipe(batchProcessor).on('data', (line)=>{
31
- if (currentLength + line.length > maxFileSize) {
32
- jsonList.push(currentContent);
33
- currentContent = '';
34
- currentLength = 0;
35
- }
36
- if (line.length) {
37
- currentContent += line;
38
- currentLength += line.length;
39
- }
40
- }).on('end', ()=>{
41
- if (jsonList.length < 1) jsonList.push(currentContent);
42
- resolve(jsonList);
43
- }).on('error', (err)=>reject(err));
44
- });
45
- return Promise.resolve(JSON.stringify(json, replacer, space));
46
- }
47
- const readPackageJson = (file, readFile)=>{
48
- let result;
49
- let current = file;
50
- while('/' !== current && !result){
51
- const parent = dirname(current);
52
- if (parent === current) break;
53
- current = parent;
54
- if (readFile) result = readFile(join(current, 'package.json'));
55
- if (readFile) {
56
- if (!(null == result ? void 0 : result.name)) result = void 0;
57
- } else result = Package.getPackageMetaFromModulePath(file);
58
- }
59
- if (!result) return;
60
- if (readFile && (!result.name || !result.version)) return readPackageJson(dirname(current), readFile);
61
- return {
62
- ...result,
63
- root: current
64
- };
65
- };
66
- export { readPackageJson, stringify };
@@ -1,17 +0,0 @@
1
- import { filesize } from "filesize";
2
- import { memoryUsage, pid } from "process";
3
- function getMemoryUsage() {
4
- return memoryUsage();
5
- }
6
- function getMemoryUsageMessage() {
7
- const usage = getMemoryUsage();
8
- const msgs = [
9
- `RSS: ${filesize(usage.rss)}`,
10
- `Heap Total: ${filesize(usage.heapTotal)}`,
11
- `Heap Used: ${filesize(usage.heapUsed)}`
12
- ];
13
- if (usage.arrayBuffers) msgs.push(`ArrayBuffers: ${filesize(usage.arrayBuffers)}`);
14
- if (usage.external) msgs.push(`External: ${filesize(usage.external)}`);
15
- return `["${pid}" Memory Usage] ${msgs.join(', ')}`;
16
- }
17
- export { getMemoryUsage, getMemoryUsageMessage };
@@ -1,96 +0,0 @@
1
- import connect from "connect";
2
- import http from "http";
3
- import os from "os";
4
- import get_port from "get-port";
5
- import { execSync } from "child_process";
6
- import { random } from "../common/algorithm.mjs";
7
- const RESTRICTED_PORTS = [
8
- 3659,
9
- 4045,
10
- 6000,
11
- 6665,
12
- 6666,
13
- 6667,
14
- 6668,
15
- 6669
16
- ];
17
- function getRandomPort(min, max) {
18
- let port;
19
- do port = random(min, max);
20
- while (RESTRICTED_PORTS.includes(port));
21
- return port;
22
- }
23
- const defaultPort = getRandomPort(3000, 8999);
24
- async function getPort(expectPort) {
25
- return get_port({
26
- port: expectPort
27
- });
28
- }
29
- const createGetPortSyncFunctionString = (expectPort)=>`
30
- (() => {
31
- const net = require('net');
32
-
33
- function getPort(expectPort) {
34
- return new Promise((resolve, reject) => {
35
- const server = net.createServer();
36
- server.unref();
37
- server.on('error', reject);
38
- server.listen(expectPort, () => {
39
- const { port } = server.address();
40
- server.close(() => {
41
- resolve(port);
42
- });
43
- });
44
- });
45
- }
46
-
47
- async function getAvailablePort(expectPort) {
48
- let port = expectPort;
49
- while (true) {
50
- try {
51
- const res = await getPort(port);
52
- return res;
53
- } catch (error) {
54
- port += Math.floor(Math.random() * 100 + 1);
55
- }
56
- }
57
- }
58
-
59
- getAvailablePort(${expectPort}).then(port => process.stdout.write(port.toString()));
60
- })();
61
- `.trim();
62
- function getPortSync(expectPort) {
63
- const statement = '\n' === os.EOL ? createGetPortSyncFunctionString(expectPort) : createGetPortSyncFunctionString(expectPort).replace(/\n/g, '');
64
- const port = execSync(`node -e "${statement}"`, {
65
- encoding: 'utf-8'
66
- });
67
- return Number(port);
68
- }
69
- function createApp() {
70
- return connect();
71
- }
72
- async function createServer(port) {
73
- const app = createApp();
74
- const server = http.createServer(app);
75
- const res = {
76
- app,
77
- server,
78
- port,
79
- close () {
80
- return new Promise((resolve, reject)=>{
81
- if ('closeAllConnections' in server) server.closeAllConnections();
82
- if ('closeIdleConnections' in server) server.closeIdleConnections();
83
- server.close((err)=>{
84
- if (err) reject(err);
85
- resolve();
86
- });
87
- });
88
- }
89
- };
90
- return new Promise((resolve)=>{
91
- server.listen(port, ()=>{
92
- resolve(res);
93
- });
94
- });
95
- }
96
- export { createApp, createGetPortSyncFunctionString, createServer, defaultPort, getPort, getPortSync };
@@ -1,17 +0,0 @@
1
- import { relative } from "path";
2
- function getPackageRelationAlertDetails(modules, dependencies, root, packageDependencies, moduleCodeMap) {
3
- return packageDependencies.slice().reverse().map((dep)=>{
4
- const dependency = dependencies.find((item)=>item.id === dep.dependencyId);
5
- if (!dependency) return null;
6
- const module = modules.find((item)=>item.id === dependency.module);
7
- if (!module) return null;
8
- return {
9
- group: dep.group,
10
- module,
11
- dependency,
12
- relativePath: relative(root, module.path),
13
- moduleCode: null == moduleCodeMap ? void 0 : moduleCodeMap[module.id]
14
- };
15
- }).filter(Boolean);
16
- }
17
- export { getPackageRelationAlertDetails };
@@ -1,32 +0,0 @@
1
- import { deflateSync, inflateSync } from "zlib";
2
- import { Buffer } from "buffer";
3
- import { logger } from "../logger.mjs";
4
- function mergeIntervals(intervals) {
5
- intervals.sort((a, b)=>a[0] - b[0]);
6
- let previous;
7
- let current;
8
- const result = [];
9
- for(let i = 0; i < intervals.length; i++){
10
- current = intervals[i];
11
- if (!previous || current[0] > previous[1]) {
12
- previous = current;
13
- result.push(current);
14
- } else previous[1] = Math.max(previous[1], current[1]);
15
- }
16
- return result;
17
- }
18
- function compressText(input) {
19
- try {
20
- return deflateSync(input).toString('base64');
21
- } catch (e) {
22
- logger.debug(`compressText error: ${e}`);
23
- return '';
24
- }
25
- }
26
- function decompressText(input) {
27
- return inflateSync(Buffer.from(input, 'base64')).toString();
28
- }
29
- function random(min, max) {
30
- return Math.floor(Math.random() * (max - min + 1) + min);
31
- }
32
- export { compressText, decompressText, mergeIntervals, random };
@@ -1,22 +0,0 @@
1
- import { Client } from "@rsdoctor/types";
2
- const sep = ',';
3
- function getBundleDiffPageQueryString(files) {
4
- let qs = encodeURIComponent(files.join(sep));
5
- if (qs) qs = `?${Client.RsdoctorClientUrlQuery.BundleDiffFiles}=${qs}`;
6
- return qs;
7
- }
8
- function getBundleDiffPageUrl(files) {
9
- let qs = getBundleDiffPageQueryString(files);
10
- if ('development' === process.env.NODE_ENV) {
11
- if ('undefined' != typeof location) {
12
- const { search = '', origin } = location;
13
- if (search) qs += `&${search.slice(1)}`;
14
- return `${origin}${qs}#${Client.RsdoctorClientRoutes.BundleDiff}`;
15
- }
16
- }
17
- return `${qs}#${Client.RsdoctorClientRoutes.BundleDiff}`;
18
- }
19
- function parseFilesFromBundlePageUrlQuery(queryValue) {
20
- return decodeURIComponent(queryValue).split(sep);
21
- }
22
- export { getBundleDiffPageQueryString, getBundleDiffPageUrl, parseFilesFromBundlePageUrlQuery };
@@ -1,17 +0,0 @@
1
- const sep = '!';
2
- function encode(str) {
3
- let res = `${str.charCodeAt(0)}`;
4
- for(let i = 1; i < str.length; i++)res += `${sep}${str.charCodeAt(i)}`;
5
- return res;
6
- }
7
- function decode(str) {
8
- let res = '';
9
- let tmp = '';
10
- for(let i = 0; i < str.length; i++)if (str[i] === sep) {
11
- res += String.fromCharCode(+tmp);
12
- tmp = '';
13
- } else tmp += str[i];
14
- if (tmp) res += String.fromCharCode(+tmp);
15
- return res;
16
- }
17
- export { decode, encode };