Files
BrowserOS/apps/agent/codegen.ts
Dani Akash 5d082deca3 fix: typescript checks in ci (#364)
* feat: setup schema file as fallback for codegen

* ci: included codegen build script

* fix: biome lint issues

* ci: fix heap memory
2026-02-27 00:22:59 +05:30

48 lines
1.2 KiB
TypeScript

import { existsSync } from 'node:fs'
import path from 'node:path'
import { includeIgnoreFile } from '@eslint/compat'
import type { CodegenConfig } from '@graphql-codegen/cli'
// biome-ignore lint/style/noProcessEnv: env needed for codegen config
const env = process.env
const schemaPath =
env.GRAPHQL_SCHEMA_PATH ?? path.resolve(__dirname, 'schema/schema.graphql')
if (!existsSync(schemaPath)) {
throw new Error(
'No schema found. Either set GRAPHQL_SCHEMA_PATH in .env.development ' +
'or ensure schema/schema.graphql exists',
)
}
const gitignorePath = path.resolve(__dirname, '.gitignore')
const ignorePatterns = includeIgnoreFile(
gitignorePath,
'Imported .gitignore patterns',
)
const ignoresList = ignorePatterns.ignores?.map((each) => `!${each}`) ?? []
const config: CodegenConfig = {
schema: schemaPath,
documents: ['./**/*.tsx', './**/*.ts', ...ignoresList],
ignoreNoDocuments: true,
generates: {
'./generated/graphql/': {
preset: 'client',
config: {
documentMode: 'string',
},
},
'./generated/graphql/schema.graphql': {
plugins: ['schema-ast'],
config: {
includeDirectives: true,
},
},
},
}
export default config