mirror of
https://github.com/google-gemini/gemini-cli.git
synced 2026-03-10 22:21:22 -07:00
Store installed release version as a part of install metadata (#9122)
This commit is contained in:
@@ -406,8 +406,8 @@ export async function installExtension(
|
||||
installMetadata,
|
||||
tempDir,
|
||||
);
|
||||
updateExtensionVersion(tempDir, tagName);
|
||||
installMetadata.type = 'github-release';
|
||||
installMetadata.releaseTag = tagName;
|
||||
} catch (_error) {
|
||||
await cloneFromGit(installMetadata, tempDir);
|
||||
installMetadata.type = 'git';
|
||||
@@ -503,21 +503,6 @@ export async function installExtension(
|
||||
}
|
||||
}
|
||||
|
||||
async function updateExtensionVersion(
|
||||
extensionDir: string,
|
||||
extensionVersion: string,
|
||||
) {
|
||||
const configFilePath = path.join(extensionDir, EXTENSIONS_CONFIG_FILENAME);
|
||||
if (fs.existsSync(configFilePath)) {
|
||||
const configContent = await fs.promises.readFile(configFilePath, 'utf-8');
|
||||
const config = JSON.parse(configContent);
|
||||
config.version = extensionVersion;
|
||||
await fs.promises.writeFile(
|
||||
configFilePath,
|
||||
JSON.stringify(config, null, 2),
|
||||
);
|
||||
}
|
||||
}
|
||||
async function requestConsent(extensionConfig: ExtensionConfig) {
|
||||
const mcpServerEntries = Object.entries(extensionConfig.mcpServers || {});
|
||||
if (mcpServerEntries.length) {
|
||||
@@ -609,6 +594,9 @@ export function toOutputString(extension: Extension): string {
|
||||
if (extension.installMetadata.ref) {
|
||||
output += `\n Ref: ${extension.installMetadata.ref}`;
|
||||
}
|
||||
if (extension.installMetadata.releaseTag) {
|
||||
output += `\n Release tag: ${extension.installMetadata.releaseTag}`;
|
||||
}
|
||||
}
|
||||
if (extension.contextFiles.length > 0) {
|
||||
output += `\n Context files:`;
|
||||
|
||||
@@ -191,7 +191,7 @@ export async function checkForExtensionUpdate(
|
||||
setExtensionUpdateState(ExtensionUpdateState.UPDATE_AVAILABLE);
|
||||
return;
|
||||
} else {
|
||||
const { source, ref } = installMetadata;
|
||||
const { source, releaseTag } = installMetadata;
|
||||
if (!source) {
|
||||
console.error(`No "source" provided for extension.`);
|
||||
setExtensionUpdateState(ExtensionUpdateState.ERROR);
|
||||
@@ -204,7 +204,7 @@ export async function checkForExtensionUpdate(
|
||||
repo,
|
||||
installMetadata.ref,
|
||||
);
|
||||
if (releaseData.tag_name !== ref) {
|
||||
if (releaseData.tag_name !== releaseTag) {
|
||||
setExtensionUpdateState(ExtensionUpdateState.UPDATE_AVAILABLE);
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -124,6 +124,7 @@ export interface GeminiCLIExtension {
|
||||
export interface ExtensionInstallMetadata {
|
||||
source: string;
|
||||
type: 'git' | 'local' | 'link' | 'github-release';
|
||||
releaseTag?: string; // Only present for github-release installs.
|
||||
ref?: string;
|
||||
autoUpdate?: boolean;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user