Make it clearer what's going on when calling post build script

This commit is contained in:
Joseph Garrone 2024-05-16 09:35:31 +02:00
parent b2a00737d3
commit d5bb7679ca
2 changed files with 12 additions and 9 deletions

View File

@ -20,7 +20,9 @@ import { readFieldNameUsage } from "./readFieldNameUsage";
import { readExtraPagesNames } from "./readExtraPageNames";
import { generateMessageProperties } from "./generateMessageProperties";
import { bringInAccountV1 } from "./bringInAccountV1";
import { getThemeSrcDirPath } from "../../shared/getThemeSrcDirPath";
import { rmSync } from "../../tools/fs.rmSync";
import { readThisNpmProjectVersion } from "../../tools/readThisNpmProjectVersion";
export type BuildOptionsLike = {
bundler: "vite" | "webpack";
@ -32,19 +34,19 @@ export type BuildOptionsLike = {
assetsDirPath: string;
urlPathname: string | undefined;
npmWorkspaceRootDirPath: string;
reactAppRootDirPath: string;
};
assert<BuildOptions extends BuildOptionsLike ? true : false>();
export async function generateSrcMainResources(params: {
themeName: string;
themeSrcDirPath: string;
keycloakifySrcDirPath: string;
buildOptions: BuildOptionsLike;
keycloakifyVersion: string;
srcMainResourcesDirPath: string;
}): Promise<void> {
const { themeName, themeSrcDirPath, keycloakifySrcDirPath, buildOptions, keycloakifyVersion, srcMainResourcesDirPath } = params;
const { themeName, buildOptions, srcMainResourcesDirPath } = params;
const { themeSrcDirPath } = getThemeSrcDirPath({ "reactAppRootDirPath": buildOptions.reactAppRootDirPath });
const getThemeTypeDirPath = (params: { themeType: ThemeType | "email" }) => {
const { themeType } = params;
@ -137,10 +139,9 @@ export async function generateSrcMainResources(params: {
"indexHtmlCode": fs.readFileSync(pathJoin(buildOptions.reactAppBuildDirPath, "index.html")).toString("utf8"),
cssGlobalsToDefine,
buildOptions,
keycloakifyVersion,
"keycloakifyVersion": readThisNpmProjectVersion(),
themeType,
"fieldNames": readFieldNameUsage({
keycloakifySrcDirPath,
themeSrcDirPath,
themeType
})

View File

@ -27,13 +27,15 @@ export function keycloakify(params?: Params) {
shouldGenerateSourcemap = resolvedConfig.build.sourcemap !== false;
run_post_build_script_case: {
const postBuildArgJson = process.env[vitePluginSubScriptEnvNames.runPostBuildScript];
const envValue = process.env[vitePluginSubScriptEnvNames.runPostBuildScript];
if (postBuildArgJson === undefined) {
if (envValue === undefined) {
break run_post_build_script_case;
}
await postBuild?.(JSON.parse(postBuildArgJson));
const buildOptions = JSON.parse(envValue) as BuildOptions;
await postBuild?.(buildOptions);
process.exit(0);
}