impact-analysis 1.0.2 → 1.0.4
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/index.mjs +148 -138
- package/index.zip +0 -0
- package/package.json +1 -1
package/index.mjs
CHANGED
|
@@ -149,7 +149,7 @@ function generateGraphData(dependencyData) {
|
|
|
149
149
|
if (!nodes.has(impactedFile)) {
|
|
150
150
|
nodes.set(impactedFile, { id: impactedFileName, path: impactedFile, isChangedFile: false });
|
|
151
151
|
}
|
|
152
|
-
links.push({ source: changedFile, target: impactedFileName });
|
|
152
|
+
links.push({ id: changedFile, source: changedFile, target: impactedFileName });
|
|
153
153
|
});
|
|
154
154
|
});
|
|
155
155
|
|
|
@@ -160,7 +160,6 @@ function generateGraphData(dependencyData) {
|
|
|
160
160
|
}
|
|
161
161
|
|
|
162
162
|
const graphData = generateGraphData(results);
|
|
163
|
-
|
|
164
163
|
const htmlContent = `
|
|
165
164
|
<!DOCTYPE html>
|
|
166
165
|
<html lang="en">
|
|
@@ -249,6 +248,7 @@ const htmlContent = `
|
|
|
249
248
|
th {
|
|
250
249
|
background: #1f4afe;
|
|
251
250
|
background: linear-gradient(90deg,#1f4afe 35%,#167cfc);
|
|
251
|
+
width: 50%;
|
|
252
252
|
}
|
|
253
253
|
|
|
254
254
|
th:last-child {
|
|
@@ -295,151 +295,161 @@ const htmlContent = `
|
|
|
295
295
|
|
|
296
296
|
|
|
297
297
|
<script>
|
|
298
|
-
const
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
const svg = d3.select("#svgGraph")
|
|
304
|
-
.attr("width", width)
|
|
305
|
-
.attr("height", height);
|
|
306
|
-
|
|
307
|
-
const simulation = d3.forceSimulation(graph.nodes)
|
|
308
|
-
.force("link", d3.forceLink(graph.links).id(d => d.id).distance(150)) // Increased distance for better spacing
|
|
309
|
-
.force("charge", d3.forceManyBody().strength(-200)) // Stronger repulsion to avoid overlap
|
|
310
|
-
.force("center", d3.forceCenter(width / 2, height / 2)) // Centering the graph
|
|
311
|
-
.force("collision", d3.forceCollide().radius(20)) // Prevents overlap
|
|
312
|
-
.on("tick", ticked);
|
|
313
|
-
|
|
314
|
-
const link = svg.selectAll("line")
|
|
315
|
-
.data(graph.links)
|
|
316
|
-
.enter().append("line");
|
|
317
|
-
|
|
318
|
-
const node = svg.selectAll("circle")
|
|
319
|
-
.data(graph.nodes)
|
|
320
|
-
.enter().append("circle")
|
|
321
|
-
.attr("r", d => d.isChangedFile ? 18 : 12) // Slightly larger nodes
|
|
322
|
-
.attr("fill", d => d.isChangedFile ? "#ff4500" : "#007bff") // Bright orange for changedFile, blue for others
|
|
323
|
-
.style("stroke", "#fff") // White border for clarity
|
|
324
|
-
.style("stroke-width", 2)
|
|
325
|
-
.call(drag(simulation));
|
|
326
|
-
|
|
327
|
-
const tooltip = d3.select("#tooltip");
|
|
328
|
-
|
|
329
|
-
node.on("mouseover", (event, d) => {
|
|
330
|
-
tooltip.style("display", "block")
|
|
331
|
-
.html(\`<strong>\${d.isChangedFile ? d.id : d.path}</strong>\`)
|
|
332
|
-
.style("left", (event.pageX + 10) + "px")
|
|
333
|
-
.style("top", (event.pageY - 10) + "px");
|
|
334
|
-
}).on("mouseout", () => tooltip.style("display", "none"));
|
|
335
|
-
|
|
336
|
-
svg.selectAll("text")
|
|
337
|
-
.data(graph.nodes)
|
|
338
|
-
.enter().append("text")
|
|
339
|
-
.attr("dy", 4)
|
|
340
|
-
.attr("x", 12)
|
|
341
|
-
.text(d => d.isChangedFile ? d.name : d.id);
|
|
342
|
-
|
|
343
|
-
simulation.on("tick", () => {
|
|
344
|
-
link.attr("x1", d => clamp(d.source.x, 0, width))
|
|
345
|
-
.attr("y1", d => clamp(d.source.y, 0, height))
|
|
346
|
-
.attr("x2", d => clamp(d.target.x, 0, width))
|
|
347
|
-
.attr("y2", d => clamp(d.target.y, 0, height));
|
|
348
|
-
|
|
349
|
-
node.attr("cx", d => clamp(d.x, 10, width - 10))
|
|
350
|
-
.attr("cy", d => clamp(d.y, 10, height - 10));
|
|
351
|
-
|
|
352
|
-
svg.selectAll("text")
|
|
353
|
-
.attr("x", d => clamp(d.x + 20, 10, width - 10))
|
|
354
|
-
.attr("y", d => clamp(d.y + 6, 10, height - 10));
|
|
355
|
-
});
|
|
356
|
-
function clamp(value, min, max) {
|
|
357
|
-
return Math.max(min, Math.min(max, value));
|
|
358
|
-
}
|
|
298
|
+
const impactData = ${JSON.stringify(dependencyJson)};
|
|
299
|
+
function getFileName(path) {
|
|
300
|
+
return path.split(/[/\\\\\\\\]/).pop();
|
|
301
|
+
}
|
|
359
302
|
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
303
|
+
const nodesMap = new Map();
|
|
304
|
+
impactData.forEach(d => {
|
|
305
|
+
nodesMap.set(d.changedFile, { id: d.changedFile, name: getFileName(d.changedFile), isChangedFile: true });
|
|
306
|
+
d.impactsTo.forEach(target => {
|
|
307
|
+
nodesMap.set(target, { id: target, name: getFileName(target), isChangedFile: false });
|
|
308
|
+
});
|
|
309
|
+
});
|
|
310
|
+
const nodes = Array.from(nodesMap.values());
|
|
311
|
+
const links = [];
|
|
312
|
+
const impactMap = new Map();
|
|
313
|
+
|
|
314
|
+
impactData.forEach(d => {
|
|
315
|
+
d.impactsTo.forEach(target => {
|
|
316
|
+
links.push({ source: d.changedFile, target });
|
|
317
|
+
if (!impactMap.has(target)) impactMap.set(target, new Set());
|
|
318
|
+
impactMap.get(target).add(d.changedFile);
|
|
319
|
+
});
|
|
320
|
+
});
|
|
366
321
|
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
322
|
+
impactMap.forEach((sources, target) => {
|
|
323
|
+
sources.forEach(source1 => {
|
|
324
|
+
sources.forEach(source2 => {
|
|
325
|
+
if (source1 !== source2) {
|
|
326
|
+
links.push({ source: source1, target: source2 });
|
|
327
|
+
}
|
|
328
|
+
});
|
|
329
|
+
});
|
|
330
|
+
});
|
|
371
331
|
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
332
|
+
const graph = { nodes, links };
|
|
333
|
+
|
|
334
|
+
const width = window.innerWidth;
|
|
335
|
+
const height = window.innerHeight - 100;
|
|
336
|
+
|
|
337
|
+
const svg = d3.select("#svgGraph")
|
|
338
|
+
.attr("width", width)
|
|
339
|
+
.attr("height", height);
|
|
340
|
+
|
|
341
|
+
const simulation = d3.forceSimulation(graph.nodes)
|
|
342
|
+
.force("link", d3.forceLink(graph.links)
|
|
343
|
+
.id(d => d.id)
|
|
344
|
+
.distance(80)
|
|
345
|
+
)
|
|
346
|
+
.force("charge", d3.forceManyBody()
|
|
347
|
+
.strength(-50)
|
|
348
|
+
)
|
|
349
|
+
.force("center", d3.forceCenter(width / 2, height / 2))
|
|
350
|
+
.force("collision", d3.forceCollide()
|
|
351
|
+
.radius(35)
|
|
352
|
+
)
|
|
353
|
+
.on("tick", ticked);
|
|
354
|
+
|
|
355
|
+
const link = svg.append("g")
|
|
356
|
+
.selectAll("line")
|
|
357
|
+
.data(graph.links)
|
|
358
|
+
.enter().append("line")
|
|
359
|
+
.attr("stroke", "#aaa");
|
|
360
|
+
|
|
361
|
+
const nodeGroup = svg.append("g")
|
|
362
|
+
.selectAll("g")
|
|
363
|
+
.data(graph.nodes)
|
|
364
|
+
.enter().append("g")
|
|
365
|
+
.call(d3.drag()
|
|
366
|
+
.on("start", dragStarted)
|
|
367
|
+
.on("drag", dragged)
|
|
368
|
+
.on("end", dragEnded));
|
|
369
|
+
|
|
370
|
+
const node = nodeGroup.append("circle")
|
|
371
|
+
.attr("r", 10)
|
|
372
|
+
.attr("fill", d => d.isChangedFile ? "red" : "steelblue");
|
|
373
|
+
|
|
374
|
+
const labels = nodeGroup.append("text")
|
|
375
|
+
.attr("x", 12)
|
|
376
|
+
.attr("y", 5)
|
|
377
|
+
.text(d => d.name);
|
|
378
|
+
|
|
379
|
+
simulation.on("tick", () => {
|
|
380
|
+
link.attr("x1", d => d.source.x)
|
|
381
|
+
.attr("y1", d => d.source.y)
|
|
382
|
+
.attr("x2", d => d.target.x)
|
|
383
|
+
.attr("y2", d => d.target.y);
|
|
384
|
+
|
|
385
|
+
nodeGroup.attr("transform", function(d) { return "translate(" + d.x + "," + d.y + ")"; });
|
|
386
|
+
});
|
|
387
|
+
|
|
388
|
+
function dragStarted(event, d) {
|
|
389
|
+
if (!event.active) simulation.alphaTarget(0.3).restart();
|
|
390
|
+
d.fx = d.x;
|
|
391
|
+
d.fy = d.y;
|
|
392
|
+
}
|
|
377
393
|
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
}
|
|
383
|
-
function ticked() {
|
|
384
|
-
link
|
|
385
|
-
.attr("x1", d => d.source.x)
|
|
386
|
-
.attr("y1", d => d.source.y)
|
|
387
|
-
.attr("x2", d => d.target.x)
|
|
388
|
-
.attr("y2", d => d.target.y);
|
|
389
|
-
|
|
390
|
-
node
|
|
391
|
-
.attr("cx", d => d.x)
|
|
392
|
-
.attr("cy", d => d.y);
|
|
393
|
-
|
|
394
|
-
label
|
|
395
|
-
.attr("x", d => d.x + 10)
|
|
396
|
-
.attr("y", d => d.y + 5);
|
|
397
|
-
}
|
|
394
|
+
function dragged(event, d) {
|
|
395
|
+
d.fx = event.x;
|
|
396
|
+
d.fy = event.y;
|
|
397
|
+
}
|
|
398
398
|
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
}
|
|
404
|
-
|
|
405
|
-
document.getElementById("tableViewBtn").addEventListener("click", function () {
|
|
406
|
-
document.getElementById("graphView").style.display = "none";
|
|
407
|
-
document.getElementById("tableView").style.display = "block";
|
|
408
|
-
setActiveButton(this);
|
|
409
|
-
generateTableView(${JSON.stringify(dependencyJson)});
|
|
410
|
-
});
|
|
411
|
-
|
|
412
|
-
function setActiveButton(activeBtn) {
|
|
413
|
-
document.querySelectorAll(".btn-theme").forEach(button => {
|
|
414
|
-
button.classList.remove("btn-active");
|
|
415
|
-
});
|
|
416
|
-
activeBtn.classList.add("btn-active");
|
|
417
|
-
}
|
|
399
|
+
function dragEnded(event, d) {
|
|
400
|
+
if (!event.active) simulation.alphaTarget(0);
|
|
401
|
+
d.fx = null;
|
|
402
|
+
d.fy = null;
|
|
403
|
+
}
|
|
418
404
|
|
|
419
|
-
function
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
tableBody.innerHTML = '<tr><td colspan="2">No data available</td></tr>';
|
|
425
|
-
return;
|
|
426
|
-
}
|
|
427
|
-
tableData.forEach(function (result) {
|
|
428
|
-
var row = document.createElement("tr");
|
|
405
|
+
document.getElementById("graphViewBtn").addEventListener("click", function () {
|
|
406
|
+
document.getElementById("graphView").style.display = "block";
|
|
407
|
+
document.getElementById("tableView").style.display = "none";
|
|
408
|
+
setActiveButton(this);
|
|
409
|
+
});
|
|
429
410
|
|
|
430
|
-
|
|
431
|
-
|
|
411
|
+
document.getElementById("tableViewBtn").addEventListener("click", function () {
|
|
412
|
+
document.getElementById("graphView").style.display = "none";
|
|
413
|
+
document.getElementById("tableView").style.display = "block";
|
|
414
|
+
setActiveButton(this);
|
|
415
|
+
generateTableView(impactData);
|
|
416
|
+
});
|
|
432
417
|
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
|
|
418
|
+
function setActiveButton(activeBtn) {
|
|
419
|
+
document.querySelectorAll(".btn-theme").forEach(button => {
|
|
420
|
+
button.classList.remove("btn-active");
|
|
421
|
+
});
|
|
422
|
+
activeBtn.classList.add("btn-active");
|
|
423
|
+
}
|
|
424
|
+
|
|
425
|
+
function generateTableView(data) {
|
|
426
|
+
const tableBody = document.getElementById("tableBody");
|
|
427
|
+
tableBody.innerHTML = "";
|
|
428
|
+
|
|
429
|
+
data.forEach(row => {
|
|
430
|
+
const tr = document.createElement("tr");
|
|
431
|
+
|
|
432
|
+
const tdFile = document.createElement("td");
|
|
433
|
+
tdFile.textContent = row.changedFile;
|
|
434
|
+
tr.appendChild(tdFile);
|
|
435
|
+
|
|
436
|
+
const tdImpact = document.createElement("td");
|
|
437
|
+
tdImpact.textContent = row.impactsTo.length ? row.impactsTo.join(", ") : "No Impact";
|
|
438
|
+
tr.appendChild(tdImpact);
|
|
439
|
+
|
|
440
|
+
tableBody.appendChild(tr);
|
|
441
|
+
});
|
|
442
|
+
}
|
|
443
|
+
function ticked() {
|
|
444
|
+
node.attr("cx", d => d.x = Math.max(20, Math.min(width - 20, d.x)))
|
|
445
|
+
.attr("cy", d => d.y = Math.max(20, Math.min(height - 20, d.y)));
|
|
446
|
+
|
|
447
|
+
link.attr("x1", d => d.source.x)
|
|
448
|
+
.attr("y1", d => d.source.y)
|
|
449
|
+
.attr("x2", d => d.target.x)
|
|
450
|
+
.attr("y2", d => d.target.y);
|
|
451
|
+
}
|
|
437
452
|
|
|
438
|
-
row.appendChild(changedFileCell);
|
|
439
|
-
row.appendChild(impactsToCell);
|
|
440
|
-
tableBody.appendChild(row);
|
|
441
|
-
});
|
|
442
|
-
}
|
|
443
453
|
|
|
444
454
|
|
|
445
455
|
</script>
|
package/index.zip
ADDED
|
Binary file
|