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