mirror of
https://github.com/supabase/supabase.git
synced 2026-10-06 01:45:10 +03:00
* removes all generated files * ignore all generated files * moves the docs generator into docusaurus * clean up old files from the generator * generator -> parser * Adds the latest spec * fixing generated path * updates specs * delete generated files * keep the generated folder * keep generated folder * Adds a dart generator * Addds new auth doc for Dart v1 * Adds postgrest method in Dart doc * Adds realtime docs to Dart v1 * Adds storage docs to Dart doc * Adds filters and modifiers to Dart docs spec file * fix: label used in dart sidebar to match spec file for Dart docs * final items for generator * Adds a build command * Adds typescript * fix broken links * fix build * fix import error * lowercase helpers * clean missing file Co-authored-by: dshukertjr <18113850+dshukertjr@users.noreply.github.com>
47 lines
1.1 KiB
TypeScript
47 lines
1.1 KiB
TypeScript
import template from './templates/ConfigTemplate'
|
|
import type { ConfigSpec } from './types/ConfigSpec'
|
|
|
|
import * as fs from 'fs'
|
|
import * as ejs from 'ejs'
|
|
import * as yaml from 'js-yaml'
|
|
import { writeToDisk } from './helpers'
|
|
|
|
type Section = {
|
|
id: string
|
|
title: string
|
|
}
|
|
|
|
export default async function gen(inputFileName: string, outputDir: string) {
|
|
const spec = yaml.load(fs.readFileSync(inputFileName, 'utf8'))
|
|
// console.log('spec', spec)
|
|
|
|
switch (spec.configspec) {
|
|
case '001':
|
|
await gen_v001(spec, outputDir)
|
|
break
|
|
|
|
default:
|
|
console.log('Unrecognized specification version:', spec.configspec)
|
|
break
|
|
}
|
|
}
|
|
|
|
/**
|
|
* Versioned Generator
|
|
*/
|
|
async function gen_v001(spec: ConfigSpec, dest: string) {
|
|
const specLayout = spec.info.tags
|
|
const sections = specLayout.map((section: Section) => {
|
|
const parameters = spec.parameters.filter(
|
|
(parameter) => parameter.tags[0] === section.id
|
|
)
|
|
return { ...section, parameters }
|
|
})
|
|
|
|
const content = ejs.render(template, { info: spec.info, sections })
|
|
// console.log(content)
|
|
// Write to disk
|
|
await writeToDisk(dest, content)
|
|
console.log('Saved: ', dest)
|
|
}
|