mirror of
https://github.com/SrIzan10/next-auth.git
synced 2026-05-01 10:55:20 +00:00
* tweak types, fix typos * filter non-oauth files when generating provider types * allow implicit config invoke * remove workaround for multiple cookie settings in Next.js * feat: return `null` when session does not exist * error on missing checks when configured
20 lines
677 B
JavaScript
20 lines
677 B
JavaScript
import { join } from "path"
|
|
import { readdirSync, writeFileSync } from "fs"
|
|
|
|
const providersPath = join(process.cwd(), "src/providers")
|
|
|
|
const files = readdirSync(providersPath, "utf8")
|
|
|
|
const nonOAuthFile = ["oauth-types", "oauth", "index", "email", "credentials"]
|
|
const providers = files.map((file) => {
|
|
const strippedProviderName = file.substring(0, file.indexOf("."))
|
|
return `"${strippedProviderName}"`
|
|
}).filter((provider) => !nonOAuthFile.includes(provider.replace(/"/g, '')))
|
|
|
|
const result = `
|
|
// THIS FILE IS AUTOGENERATED. DO NOT EDIT.
|
|
export type OAuthProviderType =
|
|
| ${providers.join("\n | ")}`
|
|
|
|
writeFileSync(join(providersPath, "oauth-types.ts"), result)
|