mirror of
https://github.com/google-gemini/gemini-cli.git
synced 2026-04-28 05:55:17 -07:00
Remove org/repo install support (#7815)
This commit is contained in:
@@ -5,9 +5,8 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
import { describe, it, expect } from 'vitest';
|
import { describe, it, expect } from 'vitest';
|
||||||
import { installCommand, handleInstall } from './install.js';
|
import { installCommand } from './install.js';
|
||||||
import yargs from 'yargs';
|
import yargs from 'yargs';
|
||||||
import * as extension from '../../config/extension.js';
|
|
||||||
|
|
||||||
vi.mock('../../config/extension.js', () => ({
|
vi.mock('../../config/extension.js', () => ({
|
||||||
installExtension: vi.fn(),
|
installExtension: vi.fn(),
|
||||||
@@ -28,22 +27,3 @@ describe('extensions install command', () => {
|
|||||||
).toThrow('Arguments source and path are mutually exclusive');
|
).toThrow('Arguments source and path are mutually exclusive');
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
describe('extensions install with org/repo', () => {
|
|
||||||
it('should call installExtension with the correct git URL', async () => {
|
|
||||||
const consoleLogSpy = vi.spyOn(console, 'log').mockImplementation(() => {});
|
|
||||||
const installExtensionSpy = vi
|
|
||||||
.spyOn(extension, 'installExtension')
|
|
||||||
.mockResolvedValue('test-extension');
|
|
||||||
|
|
||||||
await handleInstall({ source: 'test-org/test-repo' });
|
|
||||||
|
|
||||||
expect(installExtensionSpy).toHaveBeenCalledWith({
|
|
||||||
source: 'https://github.com/test-org/test-repo.git',
|
|
||||||
type: 'git',
|
|
||||||
});
|
|
||||||
expect(consoleLogSpy).toHaveBeenCalledWith(
|
|
||||||
'Extension "test-extension" installed successfully and enabled.',
|
|
||||||
);
|
|
||||||
});
|
|
||||||
});
|
|
||||||
|
|||||||
@@ -17,8 +17,6 @@ interface InstallArgs {
|
|||||||
path?: string;
|
path?: string;
|
||||||
}
|
}
|
||||||
|
|
||||||
const ORG_REPO_REGEX = /^[a-zA-Z0-9-]+\/[\w.-]+$/;
|
|
||||||
|
|
||||||
export async function handleInstall(args: InstallArgs) {
|
export async function handleInstall(args: InstallArgs) {
|
||||||
try {
|
try {
|
||||||
let installMetadata: ExtensionInstallMetadata;
|
let installMetadata: ExtensionInstallMetadata;
|
||||||
@@ -34,15 +32,8 @@ export async function handleInstall(args: InstallArgs) {
|
|||||||
source,
|
source,
|
||||||
type: 'git',
|
type: 'git',
|
||||||
};
|
};
|
||||||
} else if (ORG_REPO_REGEX.test(source)) {
|
|
||||||
installMetadata = {
|
|
||||||
source: `https://github.com/${source}.git`,
|
|
||||||
type: 'git',
|
|
||||||
};
|
|
||||||
} else {
|
} else {
|
||||||
throw new Error(
|
throw new Error(`The source "${source}" is not a valid URL format.`);
|
||||||
`The source "${source}" is not a valid URL or "org/repo" format.`,
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
} else if (args.path) {
|
} else if (args.path) {
|
||||||
installMetadata = {
|
installMetadata = {
|
||||||
@@ -66,12 +57,11 @@ export async function handleInstall(args: InstallArgs) {
|
|||||||
|
|
||||||
export const installCommand: CommandModule = {
|
export const installCommand: CommandModule = {
|
||||||
command: 'install [source]',
|
command: 'install [source]',
|
||||||
describe:
|
describe: 'Installs an extension from a git repository URL or a local path.',
|
||||||
'Installs an extension from a git repository (URL or "org/repo") or a local path.',
|
|
||||||
builder: (yargs) =>
|
builder: (yargs) =>
|
||||||
yargs
|
yargs
|
||||||
.positional('source', {
|
.positional('source', {
|
||||||
describe: 'The git URL or "org/repo" of the extension to install.',
|
describe: 'The github URL of the extension to install.',
|
||||||
type: 'string',
|
type: 'string',
|
||||||
})
|
})
|
||||||
.option('path', {
|
.option('path', {
|
||||||
|
|||||||
Reference in New Issue
Block a user