-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.html
73 lines (65 loc) · 3.19 KB
/
index.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>GitHub Project Dependencies</title>
<script type="module">
import mermaid from 'https://cdn.jsdelivr.net/npm/mermaid@10/dist/mermaid.esm.min.mjs';
document.addEventListener('DOMContentLoaded', async () => {
const chartContainer = document.getElementById('mermaid-chart');
mermaid.initialize({ startOnLoad: false });
const projects = [
{ name: 'tt-metal', dependencies: [], color: 'gray' },
{ name: 'tt-mlir', dependencies: ['tt-metal'], color: 'gray' },
{ name: 'tt-forge-fe', dependencies: ['tt-mlir'], color: 'gray' },
{ name: 'tt-torch', dependencies: ['tt-mlir'], color: 'gray' },
{ name: 'tt-xla', dependencies: ['tt-mlir'], color: 'gray' }
];
// Helper function to fetch GitHub data
async function fetchUpliftBranch(project) {
const url = `https://api.github.com/repos/tenstorrent/${project.name}/branches/uplift`;
try {
const response = await fetch(url);
if (response.ok) {
const prResponse = await fetch(`https://api.github.com/repos/tenstorrent/${project.name}/pulls?head=tenstorrent:uplift`);
const prs = await prResponse.json();
project.color = 'red';
project.link = prs.length > 0 ? prs[0].html_url : null;
} else {
project.color = 'green';
}
} catch (error) {
console.error(`Failed to fetch branch data for ${project.name}:`, error);
}
}
// Fetch uplift branch info for each project
await Promise.all(projects.map(fetchUpliftBranch));
// Construct the Mermaid chart definition
let chartDefinition = 'graph TD;\n';
projects.forEach(project => {
// Define project node with color and link if available
const nodeDef = project.link
? `${project.name}["${project.name}"]:::${project.color} -->|click|${project.link};\n`
: `${project.name}["${project.name}"]:::${project.color};\n`;
chartDefinition += nodeDef;
// Define dependency edges
project.dependencies.forEach(dep => {
chartDefinition += `${dep} --> ${project.name};\n`;
});
});
// Add styling classes
chartDefinition += 'classDef red fill:#ffaaaa,stroke:#ff0000;\n';
chartDefinition += 'classDef green fill:#aaffaa,stroke:#00ff00;\n';
chartDefinition += 'classDef gray fill:#e0e0e0,stroke:#888888;\n';
// Render the Mermaid chart
chartContainer.innerHTML = chartDefinition;
mermaid.contentLoaded();
});
</script>
</head>
<body>
<h1>Dynamic GitHub Project Dependency Chart</h1>
<div id="mermaid-chart" class="mermaid"></div>
</body>
</html>