import { mkdir, writeFile } from 'node:fs/promises';
import { dirname, resolve } from 'node:path';

import { typeDefs } from '../src/graphql/type-defs.js';

const schemaPath = resolve('graphql-contracts/schema.graphql');
const schema = typeDefs.trim().replace(/^  /gm, '');

await mkdir(dirname(schemaPath), { recursive: true });
await writeFile(schemaPath, `${schema}\n`, 'utf8');
