Feature custom themes logic (#2639)

Co-authored-by: Jacob Richman <jacob314@gmail.com>
This commit is contained in:
Ali Al Jufairi
2025-07-20 16:51:18 +09:00
committed by GitHub
parent c0bfa388c5
commit 76b935d598
19 changed files with 1313 additions and 341 deletions

View File

@@ -8,7 +8,6 @@
import { describe, it, expect, vi, beforeEach, afterEach, Mock } from 'vitest';
import fsPromises from 'fs/promises';
import * as fs from 'fs';
import { Dirent as FSDirent } from 'fs';
import * as nodePath from 'path';
import { getFolderStructure } from './getFolderStructure.js';
import * as gitUtils from './gitUtils.js';
@@ -30,8 +29,21 @@ vi.mock('./gitUtils.js');
// Import 'path' again here, it will be the mocked version
import * as path from 'path';
interface TestDirent {
name: string;
isFile: () => boolean;
isDirectory: () => boolean;
isBlockDevice: () => boolean;
isCharacterDevice: () => boolean;
isSymbolicLink: () => boolean;
isFIFO: () => boolean;
isSocket: () => boolean;
path: string;
parentPath: string;
}
// Helper to create Dirent-like objects for mocking fs.readdir
const createDirent = (name: string, type: 'file' | 'dir'): FSDirent => ({
const createDirent = (name: string, type: 'file' | 'dir'): TestDirent => ({
name,
isFile: () => type === 'file',
isDirectory: () => type === 'dir',
@@ -77,7 +89,7 @@ describe('getFolderStructure', () => {
vi.restoreAllMocks(); // Restores spies (like fsPromises.readdir) and resets vi.fn mocks (like path.resolve)
});
const mockFsStructure: Record<string, FSDirent[]> = {
const mockFsStructure: Record<string, TestDirent[]> = {
'/testroot': [
createDirent('file1.txt', 'file'),
createDirent('subfolderA', 'dir'),

View File

@@ -5,9 +5,11 @@
*/
import { Schema } from '@google/genai';
import * as ajv from 'ajv';
const ajValidator = new ajv.Ajv();
import AjvPkg from 'ajv';
// Ajv's ESM/CJS interop: use 'any' for compatibility as recommended by Ajv docs
// eslint-disable-next-line @typescript-eslint/no-explicit-any
const AjvClass = (AjvPkg as any).default || AjvPkg;
const ajValidator = new AjvClass();
/**
* Simple utility to validate objects against JSON Schemas