refactor(core): Move getPackageJson utility to core package (#12224)

This commit is contained in:
Shreya Keshive
2025-10-29 13:23:35 -07:00
committed by GitHub
parent b31b786db7
commit 3e9701861e
9 changed files with 61 additions and 49 deletions

View File

@@ -9,8 +9,12 @@ import { checkForUpdates } from './updateCheck.js';
import type { LoadedSettings } from '../../config/settings.js';
const getPackageJson = vi.hoisted(() => vi.fn());
vi.mock('../../utils/package.js', () => ({
const debugLogger = vi.hoisted(() => ({
warn: vi.fn(),
}));
vi.mock('@google/gemini-cli-core', () => ({
getPackageJson,
debugLogger,
}));
const latestVersion = vi.hoisted(() => vi.fn());

View File

@@ -6,9 +6,13 @@
import latestVersion from 'latest-version';
import semver from 'semver';
import { getPackageJson } from '../../utils/package.js';
import { getPackageJson, debugLogger } from '@google/gemini-cli-core';
import type { LoadedSettings } from '../../config/settings.js';
import { debugLogger } 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 const FETCH_TIMEOUT_MS = 2000;
@@ -54,7 +58,7 @@ export async function checkForUpdates(
if (process.env['DEV'] === 'true') {
return null;
}
const packageJson = await getPackageJson();
const packageJson = await getPackageJson(__dirname);
if (!packageJson || !packageJson.name || !packageJson.version) {
return null;
}