Skip to content
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions cli/src/utils/github.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,13 +31,19 @@ function checkRateLimit(response: Response): void {
}
}

function getAuthHeaders(): Record<string, string> {
const token = process.env['GITHUB_TOKEN'];
return token ? { 'Authorization': `Bearer ${token}` } : {};
}

export async function fetchReleases(): Promise<Release[]> {
const url = `${API_BASE}/repos/${REPO_OWNER}/${REPO_NAME}/releases`;

const response = await fetch(url, {
headers: {
'Accept': 'application/vnd.github.v3+json',
'User-Agent': 'uipro-cli',
...getAuthHeaders(),
},
});

Expand All @@ -57,6 +63,7 @@ export async function getLatestRelease(): Promise<Release> {
headers: {
'Accept': 'application/vnd.github.v3+json',
'User-Agent': 'uipro-cli',
...getAuthHeaders(),
},
});

Expand All @@ -74,6 +81,7 @@ export async function downloadRelease(url: string, dest: string): Promise<void>
headers: {
'User-Agent': 'uipro-cli',
'Accept': 'application/octet-stream',
...getAuthHeaders(),
},
});

Expand Down