mirror of
https://github.com/QwenLM/qwen-code.git
synced 2026-04-29 20:20:57 +00:00
[extensions] Add an initial set of extension variables (#7035)
Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com>
This commit is contained in:
parent
75b1e01bb0
commit
b6cca01161
6 changed files with 166 additions and 5 deletions
|
|
@ -17,6 +17,7 @@ import {
|
|||
uninstallExtension,
|
||||
updateExtension,
|
||||
} from './extension.js';
|
||||
import { type MCPServerConfig } from '@google/gemini-cli-core';
|
||||
import { execSync } from 'node:child_process';
|
||||
import { type SimpleGit, simpleGit } from 'simple-git';
|
||||
|
||||
|
|
@ -58,6 +59,7 @@ describe('loadExtensions', () => {
|
|||
afterEach(() => {
|
||||
fs.rmSync(tempWorkspaceDir, { recursive: true, force: true });
|
||||
fs.rmSync(tempHomeDir, { recursive: true, force: true });
|
||||
vi.restoreAllMocks();
|
||||
});
|
||||
|
||||
it('should include extension path in loaded extension', () => {
|
||||
|
|
@ -127,6 +129,37 @@ describe('loadExtensions', () => {
|
|||
path.join(workspaceExtensionsDir, 'ext1', 'my-context-file.md'),
|
||||
]);
|
||||
});
|
||||
|
||||
it('should hydrate variables', () => {
|
||||
const workspaceExtensionsDir = path.join(
|
||||
tempWorkspaceDir,
|
||||
EXTENSIONS_DIRECTORY_NAME,
|
||||
);
|
||||
fs.mkdirSync(workspaceExtensionsDir, { recursive: true });
|
||||
|
||||
createExtension(
|
||||
workspaceExtensionsDir,
|
||||
'test-extension',
|
||||
'1.0.0',
|
||||
false,
|
||||
undefined,
|
||||
{
|
||||
'test-server': {
|
||||
cwd: '${extensionPath}${/}server',
|
||||
},
|
||||
},
|
||||
);
|
||||
|
||||
const extensions = loadExtensions(tempWorkspaceDir);
|
||||
expect(extensions).toHaveLength(1);
|
||||
const loadedConfig = extensions[0].config;
|
||||
const expectedCwd = path.join(
|
||||
workspaceExtensionsDir,
|
||||
'test-extension',
|
||||
'server',
|
||||
);
|
||||
expect(loadedConfig.mcpServers?.['test-server'].cwd).toBe(expectedCwd);
|
||||
});
|
||||
});
|
||||
|
||||
describe('annotateActiveExtensions', () => {
|
||||
|
|
@ -265,9 +298,7 @@ describe('installExtension', () => {
|
|||
});
|
||||
|
||||
const mockedSimpleGit = simpleGit as vi.MockedFunction<typeof simpleGit>;
|
||||
mockedSimpleGit.mockReturnValue({
|
||||
clone,
|
||||
} as unknown as SimpleGit);
|
||||
mockedSimpleGit.mockReturnValue({ clone } as unknown as SimpleGit);
|
||||
|
||||
await installExtension({ source: gitUrl, type: 'git' });
|
||||
|
||||
|
|
@ -347,12 +378,13 @@ function createExtension(
|
|||
version: string,
|
||||
addContextFile = false,
|
||||
contextFileName?: string,
|
||||
mcpServers?: Record<string, MCPServerConfig>,
|
||||
): string {
|
||||
const extDir = path.join(extensionsDir, name);
|
||||
fs.mkdirSync(extDir, { recursive: true });
|
||||
fs.writeFileSync(
|
||||
path.join(extDir, EXTENSIONS_CONFIG_FILENAME),
|
||||
JSON.stringify({ name, version, contextFileName }),
|
||||
JSON.stringify({ name, version, contextFileName, mcpServers }),
|
||||
);
|
||||
|
||||
if (addContextFile) {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue