import type { CompilerOptionDeclaration } from '../src/types/options'
import fs from 'node:fs/promises'
import ts from 'typescript'
import { defaultHandbookOptions } from '../src/defaults'

async function generateFlagKeys() {
  const tsOptionDeclarations = (ts as any).optionDeclarations as CompilerOptionDeclaration[]

  const keys = [
    ...tsOptionDeclarations.map(i => i.name),
    ...Object.keys(defaultHandbookOptions),
  ].sort()

  await fs.writeFile('src/flag-keys.ts', `// Generated by scripts/flag-keys.ts\nexport const flagKeys = ${JSON.stringify(keys, null, 2)}`, 'utf-8')
}

generateFlagKeys()
