mirror of
https://github.com/google-gemini/gemini-cli.git
synced 2026-05-13 05:12:55 -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,
|
installMetadata,
|
||||||
tempDir,
|
tempDir,
|
||||||
);
|
);
|
||||||
updateExtensionVersion(tempDir, tagName);
|
|
||||||
installMetadata.type = 'github-release';
|
installMetadata.type = 'github-release';
|
||||||
|
installMetadata.releaseTag = tagName;
|
||||||
} catch (_error) {
|
} catch (_error) {
|
||||||
await cloneFromGit(installMetadata, tempDir);
|
await cloneFromGit(installMetadata, tempDir);
|
||||||
installMetadata.type = 'git';
|
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) {
|
async function requestConsent(extensionConfig: ExtensionConfig) {
|
||||||
const mcpServerEntries = Object.entries(extensionConfig.mcpServers || {});
|
const mcpServerEntries = Object.entries(extensionConfig.mcpServers || {});
|
||||||
if (mcpServerEntries.length) {
|
if (mcpServerEntries.length) {
|
||||||
@@ -609,6 +594,9 @@ export function toOutputString(extension: Extension): string {
|
|||||||
if (extension.installMetadata.ref) {
|
if (extension.installMetadata.ref) {
|
||||||
output += `\n Ref: ${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) {
|
if (extension.contextFiles.length > 0) {
|
||||||
output += `\n Context files:`;
|
output += `\n Context files:`;
|
||||||
|
|||||||
@@ -191,7 +191,7 @@ export async function checkForExtensionUpdate(
|
|||||||
setExtensionUpdateState(ExtensionUpdateState.UPDATE_AVAILABLE);
|
setExtensionUpdateState(ExtensionUpdateState.UPDATE_AVAILABLE);
|
||||||
return;
|
return;
|
||||||
} else {
|
} else {
|
||||||
const { source, ref } = installMetadata;
|
const { source, releaseTag } = installMetadata;
|
||||||
if (!source) {
|
if (!source) {
|
||||||
console.error(`No "source" provided for extension.`);
|
console.error(`No "source" provided for extension.`);
|
||||||
setExtensionUpdateState(ExtensionUpdateState.ERROR);
|
setExtensionUpdateState(ExtensionUpdateState.ERROR);
|
||||||
@@ -204,7 +204,7 @@ export async function checkForExtensionUpdate(
|
|||||||
repo,
|
repo,
|
||||||
installMetadata.ref,
|
installMetadata.ref,
|
||||||
);
|
);
|
||||||
if (releaseData.tag_name !== ref) {
|
if (releaseData.tag_name !== releaseTag) {
|
||||||
setExtensionUpdateState(ExtensionUpdateState.UPDATE_AVAILABLE);
|
setExtensionUpdateState(ExtensionUpdateState.UPDATE_AVAILABLE);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -124,6 +124,7 @@ export interface GeminiCLIExtension {
|
|||||||
export interface ExtensionInstallMetadata {
|
export interface ExtensionInstallMetadata {
|
||||||
source: string;
|
source: string;
|
||||||
type: 'git' | 'local' | 'link' | 'github-release';
|
type: 'git' | 'local' | 'link' | 'github-release';
|
||||||
|
releaseTag?: string; // Only present for github-release installs.
|
||||||
ref?: string;
|
ref?: string;
|
||||||
autoUpdate?: boolean;
|
autoUpdate?: boolean;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user