mirror of
https://github.com/google-gemini/gemini-cli.git
synced 2026-03-15 00:21:09 -07:00
Send the model and CLI version with the user agent (#14865)
This commit is contained in:
committed by
GitHub
parent
d90356e8a3
commit
d2a6b30398
@@ -1,46 +0,0 @@
|
||||
/**
|
||||
* @license
|
||||
* Copyright 2025 Google LLC
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
|
||||
import { describe, it, expect, vi, beforeEach, afterEach } from 'vitest';
|
||||
import { getCliVersion } from './version.js';
|
||||
import { getPackageJson } from '@google/gemini-cli-core';
|
||||
|
||||
vi.mock('@google/gemini-cli-core', () => ({
|
||||
getPackageJson: vi.fn(),
|
||||
}));
|
||||
|
||||
describe('version', () => {
|
||||
const originalEnv = process.env;
|
||||
|
||||
beforeEach(() => {
|
||||
vi.resetModules();
|
||||
process.env = { ...originalEnv };
|
||||
vi.mocked(getPackageJson).mockResolvedValue({ version: '1.0.0' });
|
||||
});
|
||||
|
||||
afterEach(() => {
|
||||
process.env = originalEnv;
|
||||
});
|
||||
|
||||
it('should return CLI_VERSION from env if set', async () => {
|
||||
process.env['CLI_VERSION'] = '2.0.0';
|
||||
const version = await getCliVersion();
|
||||
expect(version).toBe('2.0.0');
|
||||
});
|
||||
|
||||
it('should return version from package.json if CLI_VERSION is not set', async () => {
|
||||
delete process.env['CLI_VERSION'];
|
||||
const version = await getCliVersion();
|
||||
expect(version).toBe('1.0.0');
|
||||
});
|
||||
|
||||
it('should return "unknown" if package.json is not found and CLI_VERSION is not set', async () => {
|
||||
delete process.env['CLI_VERSION'];
|
||||
vi.mocked(getPackageJson).mockResolvedValue(undefined);
|
||||
const version = await getCliVersion();
|
||||
expect(version).toBe('unknown');
|
||||
});
|
||||
});
|
||||
@@ -1,17 +0,0 @@
|
||||
/**
|
||||
* @license
|
||||
* Copyright 2025 Google LLC
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
|
||||
import { getPackageJson } from '@google/gemini-cli-core';
|
||||
import { fileURLToPath } from 'node:url';
|
||||
import path from 'node:path';
|
||||
|
||||
const __filename = fileURLToPath(import.meta.url);
|
||||
const __dirname = path.dirname(__filename);
|
||||
|
||||
export async function getCliVersion(): Promise<string> {
|
||||
const pkgJson = await getPackageJson(__dirname);
|
||||
return process.env['CLI_VERSION'] || pkgJson?.version || 'unknown';
|
||||
}
|
||||
Reference in New Issue
Block a user