mirror of
https://github.com/supabase/supabase.git
synced 2026-09-06 09:59:03 +08:00
Reverts supabase/supabase#48144 <!-- This is an auto-generated comment: release notes by coderabbit.ai --> ## Summary by CodeRabbit * **Bug Fixes** * Documentation generation now surfaces missing or unreadable AI skills and Terraform schema data instead of silently producing empty sections. * This improves visibility into incomplete documentation builds and helps ensure generated reference content is available and accurate. <!-- end of auto-generated comment: release notes by coderabbit.ai --> Co-authored-by: Ali Waseem <waseema393@gmail.com>
41 lines
1.6 KiB
TypeScript
41 lines
1.6 KiB
TypeScript
import { readFileSync } from 'node:fs'
|
|
import path from 'node:path'
|
|
|
|
const SCHEMA_PATH = path.join(process.cwd(), 'features/docs/generated/terraform.schema.json')
|
|
|
|
function attributesTable(attributes: Record<string, any>, extraColumns: string[]): string {
|
|
const columns = ['Description', ...extraColumns]
|
|
const header = `| Attribute | ${columns.join(' | ')} |`
|
|
const divider = `| --- | ${columns.map(() => '---').join(' | ')} |`
|
|
const rows = Object.entries(attributes).map(
|
|
([name, attribute]) =>
|
|
`| \`${name}\` | ${columns.map((column) => String(attribute[column.toLowerCase()] ?? '')).join(' | ')} |`
|
|
)
|
|
return [header, divider, ...rows].join('\n')
|
|
}
|
|
|
|
export const TerraformProviderSchema = (): string => {
|
|
const schema = JSON.parse(readFileSync(SCHEMA_PATH, 'utf-8'))
|
|
const provider = schema.provider_schemas['registry.terraform.io/supabase/supabase']
|
|
|
|
const resources = Object.entries(provider.resource_schemas)
|
|
.map(
|
|
([name, resource]: [string, any]) =>
|
|
`### ${name}\n\n${attributesTable(resource.block.attributes, ['Type', 'Required', 'Optional'])}`
|
|
)
|
|
.join('\n\n')
|
|
|
|
const dataSources = Object.entries(provider.data_source_schemas)
|
|
.map(
|
|
([name, dataSource]: [string, any]) =>
|
|
`### ${name}\n\n${attributesTable(dataSource.block.attributes, ['Type', 'Required', 'Optional'])}`
|
|
)
|
|
.join('\n\n')
|
|
|
|
return [
|
|
`## Provider settings\n\n${attributesTable(provider.provider.block.attributes, ['Type', 'Optional', 'Sensitive'])}`,
|
|
`## Resources\n\n${resources}`,
|
|
`## Data sources\n\n${dataSources}`,
|
|
].join('\n\n')
|
|
}
|