Skip to content

Commit e88b55e

Browse files
committed
Show deps
1 parent cc3fc6d commit e88b55e

8 files changed

Lines changed: 545 additions & 1 deletion

File tree

.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,3 +39,6 @@ yarn-error.log*
3939
# typescript
4040
*.tsbuildinfo
4141
next-env.d.ts
42+
43+
# github data cache
44+
github_issues_cache.json

fetch_github_issues.py

Lines changed: 99 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,99 @@
1+
#!/usr/bin/env python3
2+
import os
3+
import sys
4+
import json
5+
import urllib.request
6+
import urllib.error
7+
8+
9+
def fetch_github_issues():
10+
"""Fetch GitHub issues from the repository"""
11+
repo = "lemonade-sdk/halo_website"
12+
token = os.environ.get("GITHUB_TOKEN", "")
13+
14+
headers = {
15+
"Accept": "application/vnd.github.v3+json",
16+
"User-Agent": "Halo-Website-Fetch",
17+
}
18+
19+
if token:
20+
headers["Authorization"] = f"Bearer {token}"
21+
22+
issues = []
23+
24+
# Try to fetch by milestone first
25+
try:
26+
milestones_url = f"https://api.github.com/repos/{repo}/milestones"
27+
req = urllib.request.Request(milestones_url, headers=headers)
28+
29+
with urllib.request.urlopen(req) as response:
30+
milestones = json.loads(response.read())
31+
32+
playbooks_milestone = next(
33+
(m for m in milestones if m["title"].lower() == "playbooks"), None
34+
)
35+
36+
if playbooks_milestone:
37+
issues_url = f"https://api.github.com/repos/{repo}/issues?milestone={playbooks_milestone['number']}&state=all&per_page=100"
38+
req = urllib.request.Request(issues_url, headers=headers)
39+
40+
with urllib.request.urlopen(req) as response:
41+
issues = json.loads(response.read())
42+
except Exception as e:
43+
print(f"Milestone fetch failed: {e}", file=sys.stderr)
44+
45+
# Fallback: fetch issues with "playbooks" label
46+
if not issues:
47+
try:
48+
issues_url = f"https://api.github.com/repos/{repo}/issues?labels=playbooks&state=all&per_page=100"
49+
req = urllib.request.Request(issues_url, headers=headers)
50+
51+
with urllib.request.urlopen(req) as response:
52+
issues = json.loads(response.read())
53+
except Exception as e:
54+
print(f"Label fetch failed: {e}", file=sys.stderr)
55+
56+
# If still no issues, try fetching all issues and filter
57+
if not issues:
58+
try:
59+
all_issues_url = (
60+
f"https://api.github.com/repos/{repo}/issues?state=all&per_page=100"
61+
)
62+
req = urllib.request.Request(all_issues_url, headers=headers)
63+
64+
with urllib.request.urlopen(req) as response:
65+
all_issues = json.loads(response.read())
66+
67+
# Filter for issues that have relevant labels
68+
issues = [
69+
issue
70+
for issue in all_issues
71+
if any(
72+
label["name"].startswith(prefix)
73+
for label in issue.get("labels", [])
74+
for prefix in ["track::", "os::", "app::", "framework::", "model::"]
75+
)
76+
]
77+
except Exception as e:
78+
print(f"All issues fetch failed: {e}", file=sys.stderr)
79+
80+
return issues
81+
82+
83+
if __name__ == "__main__":
84+
try:
85+
issues = fetch_github_issues()
86+
result = {"issues": issues}
87+
88+
# Write to file
89+
output_file = "github_issues_cache.json"
90+
with open(output_file, "w", encoding="utf-8") as f:
91+
json.dump(result, f, indent=2)
92+
93+
print(f"Successfully fetched {len(issues)} issues and saved to {output_file}")
94+
except Exception as e:
95+
error_result = {"error": str(e), "issues": []}
96+
with open("github_issues_cache.json", "w", encoding="utf-8") as f:
97+
json.dump(error_result, f, indent=2)
98+
print(f"Error: {e}", file=sys.stderr)
99+
sys.exit(1)

package-lock.json

Lines changed: 53 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,8 @@
99
"lint": "eslint"
1010
},
1111
"dependencies": {
12+
"echarts": "^6.0.0",
13+
"echarts-for-react": "^3.0.5",
1214
"next": "16.0.7",
1315
"react": "19.2.0",
1416
"react-dom": "19.2.0"

src/app/api/github-issues/route.ts

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
import { NextResponse } from "next/server";
2+
import { readFile } from "fs/promises";
3+
import path from "path";
4+
5+
export async function GET() {
6+
try {
7+
// Read the cached data file
8+
const cacheFilePath = path.join(process.cwd(), "github_issues_cache.json");
9+
const fileContent = await readFile(cacheFilePath, "utf-8");
10+
const data = JSON.parse(fileContent);
11+
12+
return NextResponse.json(data);
13+
} catch (error) {
14+
console.error("Error reading GitHub issues cache:", error);
15+
16+
return NextResponse.json(
17+
{
18+
error: "Failed to read GitHub issues cache. Run 'python fetch_github_issues.py' first.",
19+
issues: []
20+
},
21+
{ status: 500 }
22+
);
23+
}
24+
}
Lines changed: 14 additions & 0 deletions
Loading

0 commit comments

Comments
 (0)