Revert Node <20 warning (#4244)

This commit is contained in:
Pascal Birchler 2025-07-15 20:42:27 +02:00 committed by GitHub
parent 7b49560265
commit af551f4a41
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 1 additions and 63 deletions

View File

@ -8,7 +8,6 @@ import { describe, it, expect, vi, beforeEach, afterEach } from 'vitest';
import { getUserStartupWarnings } from './userStartupWarnings.js';
import * as os from 'os';
import fs from 'fs/promises';
import semver from 'semver';
vi.mock('os', () => ({
default: { homedir: vi.fn() },
@ -19,13 +18,6 @@ vi.mock('fs/promises', () => ({
default: { realpath: vi.fn() },
}));
vi.mock('semver', () => ({
default: {
major: vi.fn(),
},
major: vi.fn(),
}));
describe('getUserStartupWarnings', () => {
const homeDir = '/home/user';
@ -74,44 +66,6 @@ describe('getUserStartupWarnings', () => {
});
});
function setNodeVersionMajor(majorVersion: number) {
vi.mocked(semver.major).mockReturnValue(majorVersion);
}
describe('node version check', () => {
afterEach(() => {
setNodeVersionMajor(20);
});
it('should return a warning if Node.js version is less than minMajor', async () => {
setNodeVersionMajor(18);
const warnings = await getUserStartupWarnings('');
expect(warnings).toHaveLength(1);
expect(warnings[0]).toContain('Node.js');
expect(warnings[0]).toContain('requires Node.js 20 or higher');
});
it('should not return a warning if Node.js version is equal to minMajor', async () => {
setNodeVersionMajor(20);
const warnings = await getUserStartupWarnings('');
expect(warnings).toEqual([]);
});
it('should not return a warning if Node.js version is greater than minMajor', async () => {
setNodeVersionMajor(22);
const warnings = await getUserStartupWarnings('');
expect(warnings).toEqual([]);
});
it('should use default minMajor=20 if not provided', async () => {
setNodeVersionMajor(18);
const warnings = await getUserStartupWarnings('');
expect(warnings).toHaveLength(1);
expect(warnings[0]).toContain('Node.js');
expect(warnings[0]).toContain('requires Node.js 20 or higher');
});
});
// // Example of how to add a new check:
// describe('node version check', () => {
// // Tests for node version check would go here

View File

@ -6,7 +6,6 @@
import fs from 'fs/promises';
import * as os from 'os';
import semver from 'semver';
type WarningCheck = {
id: string;
@ -33,23 +32,8 @@ const homeDirectoryCheck: WarningCheck = {
},
};
const nodeVersionCheck: WarningCheck = {
id: 'node-version',
check: async (_workspaceRoot: string) => {
const minMajor = 20;
const major = semver.major(process.versions.node);
if (major < minMajor) {
return `You are using Node.js v${process.versions.node}. Gemini CLI requires Node.js ${minMajor} or higher for best results.`;
}
return null;
},
};
// All warning checks
const WARNING_CHECKS: readonly WarningCheck[] = [
homeDirectoryCheck,
nodeVersionCheck,
];
const WARNING_CHECKS: readonly WarningCheck[] = [homeDirectoryCheck];
export async function getUserStartupWarnings(
workspaceRoot: string,