@speedy-js/code-helper-diagnostic
Advanced tools
Comparing version 1.2.3 to 1.2.4
@@ -18,4 +18,7 @@ "use strict"; | ||
const path_1 = __importDefault(require("path")); | ||
const fs_1 = __importDefault(require("fs")); | ||
const speedy_logger_1 = require("@speedy-js/speedy-logger"); | ||
const rule_1 = require("../../rule"); | ||
const map_1 = require("./map"); | ||
const logger = (0, speedy_logger_1.createLogger)({ level: 'info' }); | ||
function getErrorMsg(packages, chalk, root) { | ||
@@ -29,2 +32,18 @@ const pkgName = packages[0].name; | ||
} | ||
function _getGraphData(_package, graphData) { | ||
var _a; | ||
if (!(_package === null || _package === void 0 ? void 0 : _package.imported)) { | ||
return; | ||
} | ||
graphData.nodes.push({ | ||
id: `${_package.name}@${_package.version}`, | ||
label: `${_package.name}@${_package.version}`, | ||
}); | ||
if ((_a = _package === null || _package === void 0 ? void 0 : _package.imported) === null || _a === void 0 ? void 0 : _a.length) { | ||
_package.imported.map((pkg) => { | ||
graphData.edges.push({ source: `${_package.name}@${_package.version}`, target: `${pkg.name}@${pkg.version}` }); | ||
_getGraphData(pkg, graphData); | ||
}); | ||
} | ||
} | ||
exports.rule = new rule_1.Rule({ | ||
@@ -44,4 +63,18 @@ meta: { | ||
})))).reduce((ans, item) => ans.concat(item), []); | ||
// TODO: 保存数据到 json 文件,供后续读取 | ||
const graphData = []; | ||
for (const pkg of dupPackages) { | ||
const _dupPackageData = []; | ||
pkg.forEach((_package) => { | ||
const data = { name: `${_package.name}@${_package.version}`, graph: { nodes: [], edges: [] } }; | ||
_getGraphData(_package, data.graph); | ||
data.graph.nodes.length && (data.graph.nodes[0].fill = '#7BC0FC'); | ||
_dupPackageData.push(data); | ||
}); | ||
graphData.push(_dupPackageData); | ||
} | ||
if (graphData === null || graphData === void 0 ? void 0 : graphData.length) { | ||
fs_1.default.writeFileSync(path_1.default.join(process.cwd(), '.graph-data.log'), JSON.stringify(graphData)); | ||
logger.info('🟠🟠🟠 Duplicate packages graph data [.graph-data.log] in current command line root directory, please check this in https://diagnostic.web.bytedance.net/web.'); | ||
} | ||
for (const pkg of dupPackages) { | ||
report({ | ||
@@ -48,0 +81,0 @@ message: getErrorMsg(pkg, chalk, root), |
{ | ||
"name": "@speedy-js/code-helper-diagnostic", | ||
"version": "1.2.3", | ||
"version": "1.2.4", | ||
"description": "", | ||
@@ -17,3 +17,3 @@ "keywords": [], | ||
"dependencies": { | ||
"@speedy-js/speedy-utils": "0.13.2-alpha.13", | ||
"@speedy-js/speedy-utils": "0.13.2-webpack.1", | ||
"lines-and-columns": "2.0.3", | ||
@@ -26,6 +26,6 @@ "look-it-up": "2.1.0" | ||
"@speedy-js/eslint-config": "0.0.1", | ||
"@speedy-js/speedy-config-loader": "0.13.2-alpha.13", | ||
"@speedy-js/speedy-error": "0.13.2-alpha.13", | ||
"@speedy-js/speedy-logger": "0.13.2-alpha.13", | ||
"@speedy-js/speedy-types": "0.13.2-alpha.13", | ||
"@speedy-js/speedy-config-loader": "0.13.2-webpack.1", | ||
"@speedy-js/speedy-error": "0.13.2-webpack.1", | ||
"@speedy-js/speedy-logger": "0.13.2-webpack.1", | ||
"@speedy-js/speedy-types": "0.13.2-webpack.1", | ||
"@speedy-js/test-toolkit": "0.9.2-alpha.2", | ||
@@ -32,0 +32,0 @@ "@types/node": "12.20.42", |
Sorry, the diff of this file is not supported yet
92725
1428
6
+ Added@speedy-js/speedy-utils@0.13.2-webpack.1(transitive)
- Removed@speedy-js/speedy-utils@0.13.2-alpha.13(transitive)