Rename BuildOptions -> BuildContext
This commit is contained in:
@ -1,24 +1,24 @@
|
||||
import { assert } from "tsafe/assert";
|
||||
import type { BuildOptions } from "./buildOptions";
|
||||
import type { BuildContext } from "./buildContext";
|
||||
import { getThemeSrcDirPath } from "./getThemeSrcDirPath";
|
||||
import * as fs from "fs/promises";
|
||||
import { join as pathJoin } from "path";
|
||||
|
||||
export type BuildOptionsLike = {
|
||||
export type BuildContextLike = {
|
||||
projectDirPath: string;
|
||||
themeNames: string[];
|
||||
environmentVariables: { name: string; default: string }[];
|
||||
};
|
||||
|
||||
assert<BuildOptions extends BuildOptionsLike ? true : false>();
|
||||
assert<BuildContext extends BuildContextLike ? true : false>();
|
||||
|
||||
export async function generateKcGenTs(params: {
|
||||
buildOptions: BuildOptionsLike;
|
||||
buildContext: BuildContextLike;
|
||||
}): Promise<void> {
|
||||
const { buildOptions } = params;
|
||||
const { buildContext } = params;
|
||||
|
||||
const { themeSrcDirPath } = getThemeSrcDirPath({
|
||||
projectDirPath: buildOptions.projectDirPath
|
||||
projectDirPath: buildContext.projectDirPath
|
||||
});
|
||||
|
||||
await fs.writeFile(
|
||||
@ -35,17 +35,17 @@ export async function generateKcGenTs(params: {
|
||||
``,
|
||||
`// This file is auto-generated by Keycloakify`,
|
||||
``,
|
||||
`export type ThemeName = ${buildOptions.themeNames.map(themeName => `"${themeName}"`).join(" | ")};`,
|
||||
`export type ThemeName = ${buildContext.themeNames.map(themeName => `"${themeName}"`).join(" | ")};`,
|
||||
``,
|
||||
`export const themeNames: ThemeName[] = [${buildOptions.themeNames.map(themeName => `"${themeName}"`).join(", ")}];`,
|
||||
`export const themeNames: ThemeName[] = [${buildContext.themeNames.map(themeName => `"${themeName}"`).join(", ")}];`,
|
||||
``,
|
||||
`export type KcEnvName = ${buildOptions.environmentVariables.length === 0 ? "never" : buildOptions.environmentVariables.map(({ name }) => `"${name}"`).join(" | ")};`,
|
||||
`export type KcEnvName = ${buildContext.environmentVariables.length === 0 ? "never" : buildContext.environmentVariables.map(({ name }) => `"${name}"`).join(" | ")};`,
|
||||
``,
|
||||
`export const KcEnvNames: KcEnvName[] = [${buildOptions.environmentVariables.map(({ name }) => `"${name}"`).join(", ")}];`,
|
||||
`export const KcEnvNames: KcEnvName[] = [${buildContext.environmentVariables.map(({ name }) => `"${name}"`).join(", ")}];`,
|
||||
``,
|
||||
`export const kcEnvDefaults: Record<KcEnvName, string> = ${JSON.stringify(
|
||||
Object.fromEntries(
|
||||
buildOptions.environmentVariables.map(
|
||||
buildContext.environmentVariables.map(
|
||||
({ name, default: defaultValue }) => [name, defaultValue]
|
||||
)
|
||||
),
|
||||
|
Reference in New Issue
Block a user