Files
supabase/apps/docs/internals/files/cli.ts
Charis cf3ecc93eb chore(docs): turn on strictNullChecks (#36180)
strictNullChecks was off for docs, which lets errors slip through and
leads to incorrect required/optional typing on Zod-inferred types. This
PR enables strictNullChecks and fixes all the existing violations.
2025-06-04 17:05:37 -04:00

24 lines
747 B
TypeScript

import fs from 'fs'
import yaml from 'js-yaml'
import cliCommonSections from '../../spec/common-cli-sections.json'
import { flattenSections } from '../helpers'
const flatCLISections = flattenSections(cliCommonSections)
const cliSpec = yaml.load(fs.readFileSync(`spec/cli_v1_commands.yaml`, 'utf8')) as any
/**
* Generates the CLI page links for the CLI reference.
* @returns {Array<{link: string}>} - An array of CLI page links.
*/
export function generateCLIPages() {
let cliPages: Array<{ link: string }> = []
cliSpec.commands.map((section: any) => {
const slug = (flatCLISections as any[]).find((item: any) => item.id === section.id)?.slug
if (slug) cliPages.push({ link: `reference/cli/${slug}` })
})
return cliPages
}