mirror of
https://github.com/google-gemini/gemini-cli.git
synced 2026-03-18 18:11:02 -07:00
This commit is contained in:
@@ -310,11 +310,11 @@ describe('git extension helpers', () => {
|
||||
|
||||
describe('findReleaseAsset', () => {
|
||||
const assets = [
|
||||
{ name: 'darwin.arm64.extension.tar.gz', browser_download_url: 'url1' },
|
||||
{ name: 'darwin.x64.extension.tar.gz', browser_download_url: 'url2' },
|
||||
{ name: 'linux.x64.extension.tar.gz', browser_download_url: 'url3' },
|
||||
{ name: 'win32.x64.extension.tar.gz', browser_download_url: 'url4' },
|
||||
{ name: 'extension-generic.tar.gz', browser_download_url: 'url5' },
|
||||
{ name: 'darwin.arm64.extension.tar.gz', url: 'url1' },
|
||||
{ name: 'darwin.x64.extension.tar.gz', url: 'url2' },
|
||||
{ name: 'linux.x64.extension.tar.gz', url: 'url3' },
|
||||
{ name: 'win32.x64.extension.tar.gz', url: 'url4' },
|
||||
{ name: 'extension-generic.tar.gz', url: 'url5' },
|
||||
];
|
||||
|
||||
it.each([
|
||||
@@ -334,9 +334,7 @@ describe('git extension helpers', () => {
|
||||
);
|
||||
|
||||
it('should find generic asset if it is the only one', () => {
|
||||
const singleAsset = [
|
||||
{ name: 'extension.tar.gz', browser_download_url: 'url' },
|
||||
];
|
||||
const singleAsset = [{ name: 'extension.tar.gz', url: 'aurl5' }];
|
||||
|
||||
mockPlatform.mockReturnValue('darwin');
|
||||
mockArch.mockReturnValue('arm64');
|
||||
@@ -346,8 +344,8 @@ describe('git extension helpers', () => {
|
||||
|
||||
it('should return undefined if multiple generic assets exist', () => {
|
||||
const multipleGenericAssets = [
|
||||
{ name: 'extension-1.tar.gz', browser_download_url: 'url1' },
|
||||
{ name: 'extension-2.tar.gz', browser_download_url: 'url2' },
|
||||
{ name: 'extension-1.tar.gz', url: 'aurl1' },
|
||||
{ name: 'extension-2.tar.gz', url: 'aurl2' },
|
||||
];
|
||||
|
||||
mockPlatform.mockReturnValue('darwin');
|
||||
|
||||
@@ -306,8 +306,11 @@ export async function downloadFromGitHubRelease(
|
||||
let archiveUrl: string | undefined;
|
||||
let isTar = false;
|
||||
let isZip = false;
|
||||
let fileName: string | undefined;
|
||||
|
||||
if (asset) {
|
||||
archiveUrl = asset.browser_download_url;
|
||||
archiveUrl = asset.url;
|
||||
fileName = asset.name;
|
||||
} else {
|
||||
if (releaseData.tarball_url) {
|
||||
archiveUrl = releaseData.tarball_url;
|
||||
@@ -326,10 +329,10 @@ export async function downloadFromGitHubRelease(
|
||||
errorMessage: `No assets found for release with tag ${releaseData.tag_name}`,
|
||||
};
|
||||
}
|
||||
let downloadedAssetPath = path.join(
|
||||
destination,
|
||||
path.basename(new URL(archiveUrl).pathname),
|
||||
);
|
||||
if (!fileName) {
|
||||
fileName = path.basename(new URL(archiveUrl).pathname);
|
||||
}
|
||||
let downloadedAssetPath = path.join(destination, fileName);
|
||||
if (isTar && !downloadedAssetPath.endsWith('.tar.gz')) {
|
||||
downloadedAssetPath += '.tar.gz';
|
||||
} else if (isZip && !downloadedAssetPath.endsWith('.zip')) {
|
||||
@@ -414,7 +417,7 @@ interface GithubReleaseData {
|
||||
|
||||
interface Asset {
|
||||
name: string;
|
||||
browser_download_url: string;
|
||||
url: string;
|
||||
}
|
||||
|
||||
export function findReleaseAsset(assets: Asset[]): Asset | undefined {
|
||||
@@ -455,8 +458,13 @@ export function findReleaseAsset(assets: Asset[]): Asset | undefined {
|
||||
}
|
||||
|
||||
async function downloadFile(url: string, dest: string): Promise<void> {
|
||||
const headers: { 'User-agent': string; Authorization?: string } = {
|
||||
const headers: {
|
||||
'User-agent': string;
|
||||
Accept: string;
|
||||
Authorization?: string;
|
||||
} = {
|
||||
'User-agent': 'gemini-cli',
|
||||
Accept: 'application/octet-stream',
|
||||
};
|
||||
const token = getGitHubToken();
|
||||
if (token) {
|
||||
|
||||
Reference in New Issue
Block a user