mirror of
https://github.com/supabase/supabase.git
synced 2026-06-23 23:34:34 +08: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>
51 lines
1.2 KiB
TypeScript
51 lines
1.2 KiB
TypeScript
import * as fs from 'fs'
|
|
import * as ejs from 'ejs'
|
|
import * as yaml from 'js-yaml'
|
|
import { writeToDisk } from './helpers'
|
|
import template from './templates/CliTemplate'
|
|
import type { CliSpec } from './types/CliSpec'
|
|
|
|
export default async function gen(inputFileName: string, outputDir: string) {
|
|
const spec = yaml.load(fs.readFileSync(inputFileName, 'utf8'))
|
|
// console.log('spec', spec)
|
|
|
|
switch (spec.clispec) {
|
|
case '001':
|
|
await gen_v001(spec, outputDir)
|
|
break
|
|
|
|
default:
|
|
console.log('Unrecognized specification version:', spec.clispec)
|
|
break
|
|
}
|
|
}
|
|
|
|
/**
|
|
* Versioned Generator
|
|
*/
|
|
async function gen_v001(spec: CliSpec, dest: string) {
|
|
let commandMap = new Map(spec.commands.map((item) => [item.id, item]))
|
|
|
|
const commands = spec.commands.map((x) => {
|
|
const isChild = x.subcommands.length < 1
|
|
const heading = isChild
|
|
? `### ${x.summary} {#${x.id}}`
|
|
: `## ${x.summary} {#${x.id}}`
|
|
|
|
return {
|
|
...x,
|
|
heading,
|
|
subcommandList: x.subcommands.map((c) => commandMap.get(c)),
|
|
}
|
|
})
|
|
|
|
const content = ejs.render(template, {
|
|
info: spec.info,
|
|
commands,
|
|
})
|
|
// console.log(content)
|
|
// Write to disk
|
|
await writeToDisk(dest, content)
|
|
console.log('Saved: ', dest)
|
|
}
|