chore: Extract '.gemini' to GEMINI_DIR constant (#10540)

Co-authored-by: Richie Foreman <richie.foreman@gmail.com>
This commit is contained in:
Dongin Kim(Terry)
2025-10-14 02:31:39 +09:00
committed by GitHub
parent 7beaa368a9
commit 518caae62e
36 changed files with 181 additions and 157 deletions

View File

@@ -1171,7 +1171,10 @@ describe('Hierarchical Memory Loading (config.ts) - Placeholder Suite', () => {
// 3. Spies on console functions (for logger output) are correctly set up if needed.
// Example of a previously failing test structure:
it.skip('should correctly use mocked homedir for global path', async () => {
const MOCK_GEMINI_DIR_LOCAL = path.join('/mock/home/user', '.gemini');
const MOCK_GEMINI_DIR_LOCAL = path.join(
'/mock/home/user',
ServerConfig.GEMINI_DIR,
);
const MOCK_GLOBAL_PATH_LOCAL = path.join(
MOCK_GEMINI_DIR_LOCAL,
'GEMINI.md',

View File

@@ -9,7 +9,8 @@ import fs from 'node:fs';
import os from 'node:os';
import { afterEach, beforeEach, describe, expect, it } from 'vitest';
import { ExtensionEnablementManager, Override } from './extensionEnablement.js';
import type { GeminiCLIExtension } from '@google/gemini-cli-core';
import { GEMINI_DIR, type GeminiCLIExtension } from '@google/gemini-cli-core';
// Helper to create a temporary directory for testing
function createTestDir() {
@@ -27,7 +28,7 @@ let manager: ExtensionEnablementManager;
describe('ExtensionEnablementManager', () => {
beforeEach(() => {
testDir = createTestDir();
configDir = path.join(testDir.path, '.gemini');
configDir = path.join(testDir.path, GEMINI_DIR);
manager = new ExtensionEnablementManager(configDir);
});

View File

@@ -59,7 +59,6 @@ import {
USER_SETTINGS_PATH, // This IS the mocked path.
getSystemSettingsPath,
getSystemDefaultsPath,
SETTINGS_DIRECTORY_NAME, // This is from the original module, but used by the mock.
migrateSettingsToV1,
needsMigration,
type Settings,
@@ -70,10 +69,10 @@ import {
import { FatalConfigError, GEMINI_DIR } from '@google/gemini-cli-core';
const MOCK_WORKSPACE_DIR = '/mock/workspace';
// Use the (mocked) SETTINGS_DIRECTORY_NAME for consistency
// Use the (mocked) GEMINI_DIR for consistency
const MOCK_WORKSPACE_SETTINGS_PATH = pathActual.join(
MOCK_WORKSPACE_DIR,
SETTINGS_DIRECTORY_NAME,
GEMINI_DIR,
'settings.json',
);

View File

@@ -11,7 +11,7 @@ import * as dotenv from 'dotenv';
import process from 'node:process';
import {
FatalConfigError,
GEMINI_CONFIG_DIR as GEMINI_DIR,
GEMINI_DIR,
getErrorMessage,
Storage,
} from '@google/gemini-cli-core';
@@ -49,8 +49,6 @@ function getMergeStrategyForPath(path: string[]): MergeStrategy | undefined {
export type { Settings, MemoryImportFormat };
export const SETTINGS_DIRECTORY_NAME = '.gemini';
export const USER_SETTINGS_PATH = Storage.getGlobalSettingsPath();
export const USER_SETTINGS_DIR = path.dirname(USER_SETTINGS_PATH);
export const DEFAULT_EXCLUDED_ENV_VARS = ['DEBUG', 'DEBUG_MODE'];

View File

@@ -12,13 +12,13 @@ import {
getErrorMessage,
isWithinRoot,
ideContextStore,
GEMINI_DIR,
} from '@google/gemini-cli-core';
import type { Settings } from './settings.js';
import stripJsonComments from 'strip-json-comments';
export const TRUSTED_FOLDERS_FILENAME = 'trustedFolders.json';
export const SETTINGS_DIRECTORY_NAME = '.gemini';
export const USER_SETTINGS_DIR = path.join(homedir(), SETTINGS_DIRECTORY_NAME);
export const USER_SETTINGS_DIR = path.join(homedir(), GEMINI_DIR);
export function getTrustedFoldersPath(): string {
if (process.env['GEMINI_CLI_TRUSTED_FOLDERS_PATH']) {