Files
archived-next-auth/docs/scripts/generate-providers.js
Nico Domino 846a0a0f9d docs: move database model to mermaid (#3839)
* chore: move database model to mermaid

* chore: update model details

* chore: update docusaurus dependencies

* chore: add model notes

* chore(docs): fix broken links

* Apply suggestions from code review

Co-authored-by: Balázs Orbán <info@balazsorban.com>
2022-02-16 00:12:27 +01:00

22 lines
566 B
JavaScript

const path = require("path")
const fs = require("fs")
const providersPath = path.join(process.cwd(), "/docs/providers")
const files = fs.readdirSync(providersPath, "utf8")
const result = files.reduce((acc, file) => {
if (file === "index.md") return acc
const provider = fs.readFileSync(path.join(providersPath, file), "utf8")
const { id, title } = provider.match(
/id: (?<id>.+)\ntitle: (?<title>.+)\n/
).groups
acc[id] = title
return acc
}, {})
fs.writeFileSync(
path.join(process.cwd(), "providers.json"),
JSON.stringify(result, null, 2)
)