mirror of
https://github.com/google-gemini/gemini-cli.git
synced 2026-04-28 05:55:17 -07:00
Fix rough edges around extension updates (#10926)
This commit is contained in:
@@ -8,12 +8,12 @@ import { describe, it, expect, vi, type MockInstance } from 'vitest';
|
||||
import { handleInstall, installCommand } from './install.js';
|
||||
import yargs from 'yargs';
|
||||
|
||||
const mockInstallExtension = vi.hoisted(() => vi.fn());
|
||||
const mockInstallOrUpdateExtension = vi.hoisted(() => vi.fn());
|
||||
const mockRequestConsentNonInteractive = vi.hoisted(() => vi.fn());
|
||||
const mockStat = vi.hoisted(() => vi.fn());
|
||||
|
||||
vi.mock('../../config/extension.js', () => ({
|
||||
installExtension: mockInstallExtension,
|
||||
installOrUpdateExtension: mockInstallOrUpdateExtension,
|
||||
requestConsentNonInteractive: mockRequestConsentNonInteractive,
|
||||
}));
|
||||
|
||||
@@ -51,14 +51,14 @@ describe('handleInstall', () => {
|
||||
});
|
||||
|
||||
afterEach(() => {
|
||||
mockInstallExtension.mockClear();
|
||||
mockInstallOrUpdateExtension.mockClear();
|
||||
mockRequestConsentNonInteractive.mockClear();
|
||||
mockStat.mockClear();
|
||||
vi.resetAllMocks();
|
||||
});
|
||||
|
||||
it('should install an extension from a http source', async () => {
|
||||
mockInstallExtension.mockResolvedValue('http-extension');
|
||||
mockInstallOrUpdateExtension.mockResolvedValue('http-extension');
|
||||
|
||||
await handleInstall({
|
||||
source: 'http://google.com',
|
||||
@@ -70,7 +70,7 @@ describe('handleInstall', () => {
|
||||
});
|
||||
|
||||
it('should install an extension from a https source', async () => {
|
||||
mockInstallExtension.mockResolvedValue('https-extension');
|
||||
mockInstallOrUpdateExtension.mockResolvedValue('https-extension');
|
||||
|
||||
await handleInstall({
|
||||
source: 'https://google.com',
|
||||
@@ -82,7 +82,7 @@ describe('handleInstall', () => {
|
||||
});
|
||||
|
||||
it('should install an extension from a git source', async () => {
|
||||
mockInstallExtension.mockResolvedValue('git-extension');
|
||||
mockInstallOrUpdateExtension.mockResolvedValue('git-extension');
|
||||
|
||||
await handleInstall({
|
||||
source: 'git@some-url',
|
||||
@@ -104,7 +104,7 @@ describe('handleInstall', () => {
|
||||
});
|
||||
|
||||
it('should install an extension from a sso source', async () => {
|
||||
mockInstallExtension.mockResolvedValue('sso-extension');
|
||||
mockInstallOrUpdateExtension.mockResolvedValue('sso-extension');
|
||||
|
||||
await handleInstall({
|
||||
source: 'sso://google.com',
|
||||
@@ -116,7 +116,7 @@ describe('handleInstall', () => {
|
||||
});
|
||||
|
||||
it('should install an extension from a local path', async () => {
|
||||
mockInstallExtension.mockResolvedValue('local-extension');
|
||||
mockInstallOrUpdateExtension.mockResolvedValue('local-extension');
|
||||
mockStat.mockResolvedValue({});
|
||||
await handleInstall({
|
||||
source: '/some/path',
|
||||
@@ -128,7 +128,7 @@ describe('handleInstall', () => {
|
||||
});
|
||||
|
||||
it('should throw an error if install extension fails', async () => {
|
||||
mockInstallExtension.mockRejectedValue(
|
||||
mockInstallOrUpdateExtension.mockRejectedValue(
|
||||
new Error('Install extension failed'),
|
||||
);
|
||||
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
|
||||
import type { CommandModule } from 'yargs';
|
||||
import {
|
||||
installExtension,
|
||||
installOrUpdateExtension,
|
||||
requestConsentNonInteractive,
|
||||
} from '../../config/extension.js';
|
||||
import type { ExtensionInstallMetadata } from '@google/gemini-cli-core';
|
||||
@@ -54,7 +54,7 @@ export async function handleInstall(args: InstallArgs) {
|
||||
}
|
||||
}
|
||||
|
||||
const name = await installExtension(
|
||||
const name = await installOrUpdateExtension(
|
||||
installMetadata,
|
||||
requestConsentNonInteractive,
|
||||
);
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
|
||||
import type { CommandModule } from 'yargs';
|
||||
import {
|
||||
installExtension,
|
||||
installOrUpdateExtension,
|
||||
requestConsentNonInteractive,
|
||||
} from '../../config/extension.js';
|
||||
import type { ExtensionInstallMetadata } from '@google/gemini-cli-core';
|
||||
@@ -23,7 +23,7 @@ export async function handleLink(args: InstallArgs) {
|
||||
source: args.path,
|
||||
type: 'link',
|
||||
};
|
||||
const extensionName = await installExtension(
|
||||
const extensionName = await installOrUpdateExtension(
|
||||
installMetadata,
|
||||
requestConsentNonInteractive,
|
||||
);
|
||||
|
||||
@@ -14,7 +14,7 @@ interface UninstallArgs {
|
||||
|
||||
export async function handleUninstall(args: UninstallArgs) {
|
||||
try {
|
||||
await uninstallExtension(args.name);
|
||||
await uninstallExtension(args.name, false);
|
||||
console.log(`Extension "${args.name}" successfully uninstalled.`);
|
||||
} catch (error) {
|
||||
console.error(getErrorMessage(error));
|
||||
|
||||
Reference in New Issue
Block a user