mirror of
https://github.com/google-gemini/gemini-cli.git
synced 2026-03-14 16:10:59 -07:00
feat(core): centralize compatibility checks and add TrueColor detection (#19478)
This commit is contained in:
@@ -13,6 +13,7 @@ import {
|
||||
isFolderTrustEnabled,
|
||||
isWorkspaceTrusted,
|
||||
} from '../config/trustedFolders.js';
|
||||
import { getCompatibilityWarnings } from '@google/gemini-cli-core';
|
||||
|
||||
// Mock os.homedir to control the home directory in tests
|
||||
vi.mock('os', async (importOriginal) => {
|
||||
@@ -29,6 +30,7 @@ vi.mock('@google/gemini-cli-core', async (importOriginal) => {
|
||||
return {
|
||||
...actual,
|
||||
homedir: () => os.homedir(),
|
||||
getCompatibilityWarnings: vi.fn().mockReturnValue([]),
|
||||
};
|
||||
});
|
||||
|
||||
@@ -51,11 +53,12 @@ describe('getUserStartupWarnings', () => {
|
||||
isTrusted: false,
|
||||
source: undefined,
|
||||
});
|
||||
vi.mocked(getCompatibilityWarnings).mockReturnValue([]);
|
||||
});
|
||||
|
||||
afterEach(async () => {
|
||||
await fs.rm(testRootDir, { recursive: true, force: true });
|
||||
vi.clearAllMocks();
|
||||
vi.restoreAllMocks();
|
||||
});
|
||||
|
||||
describe('home directory check', () => {
|
||||
@@ -135,4 +138,27 @@ describe('getUserStartupWarnings', () => {
|
||||
expect(warnings).toEqual([expectedWarning, expectedWarning]);
|
||||
});
|
||||
});
|
||||
|
||||
describe('compatibility warnings', () => {
|
||||
it('should include compatibility warnings by default', async () => {
|
||||
vi.mocked(getCompatibilityWarnings).mockReturnValue(['Comp warning 1']);
|
||||
const projectDir = path.join(testRootDir, 'project');
|
||||
await fs.mkdir(projectDir);
|
||||
|
||||
const warnings = await getUserStartupWarnings({}, projectDir);
|
||||
expect(warnings).toContain('Comp warning 1');
|
||||
});
|
||||
|
||||
it('should not include compatibility warnings when showCompatibilityWarnings is false', async () => {
|
||||
vi.mocked(getCompatibilityWarnings).mockReturnValue(['Comp warning 1']);
|
||||
const projectDir = path.join(testRootDir, 'project');
|
||||
await fs.mkdir(projectDir);
|
||||
|
||||
const warnings = await getUserStartupWarnings(
|
||||
{ ui: { showCompatibilityWarnings: false } },
|
||||
projectDir,
|
||||
);
|
||||
expect(warnings).not.toContain('Comp warning 1');
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
@@ -7,7 +7,7 @@
|
||||
import fs from 'node:fs/promises';
|
||||
import path from 'node:path';
|
||||
import process from 'node:process';
|
||||
import { homedir } from '@google/gemini-cli-core';
|
||||
import { homedir, getCompatibilityWarnings } from '@google/gemini-cli-core';
|
||||
import type { Settings } from '../config/settingsSchema.js';
|
||||
import {
|
||||
isFolderTrustEnabled,
|
||||
@@ -84,5 +84,11 @@ export async function getUserStartupWarnings(
|
||||
const results = await Promise.all(
|
||||
WARNING_CHECKS.map((check) => check.check(workspaceRoot, settings)),
|
||||
);
|
||||
return results.filter((msg) => msg !== null);
|
||||
const warnings = results.filter((msg) => msg !== null);
|
||||
|
||||
if (settings.ui?.showCompatibilityWarnings !== false) {
|
||||
warnings.push(...getCompatibilityWarnings());
|
||||
}
|
||||
|
||||
return warnings;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user