Do not trickle down parameters as much

This commit is contained in:
Joseph Garrone 2024-05-16 09:29:26 +02:00
parent 3cd3e08ede
commit b2a00737d3
3 changed files with 7 additions and 24 deletions

View File

@ -11,13 +11,8 @@ export type BuildOptionsLike = BuildOptionsLike_generateSrcMainResources & {
assert<BuildOptions extends BuildOptionsLike ? true : false>(); assert<BuildOptions extends BuildOptionsLike ? true : false>();
export async function generateTheme(params: { export async function generateTheme(params: { buildOptions: BuildOptionsLike }): Promise<void> {
themeSrcDirPath: string; const { buildOptions } = params;
keycloakifySrcDirPath: string;
buildOptions: BuildOptionsLike;
keycloakifyVersion: string;
}): Promise<void> {
const { themeSrcDirPath, keycloakifySrcDirPath, buildOptions, keycloakifyVersion } = params;
const [themeName, ...themeVariantNames] = buildOptions.themeNames; const [themeName, ...themeVariantNames] = buildOptions.themeNames;
@ -26,9 +21,6 @@ export async function generateTheme(params: {
await generateSrcMainResources({ await generateSrcMainResources({
themeName, themeName,
srcMainResourcesDirPath, srcMainResourcesDirPath,
themeSrcDirPath,
keycloakifySrcDirPath,
keycloakifyVersion,
buildOptions buildOptions
}); });

View File

@ -2,14 +2,15 @@ import { crawl } from "../../tools/crawl";
import { join as pathJoin } from "path"; import { join as pathJoin } from "path";
import * as fs from "fs"; import * as fs from "fs";
import type { ThemeType } from "../../shared/constants"; import type { ThemeType } from "../../shared/constants";
import { getThisCodebaseRootDirPath } from "../../tools/getThisCodebaseRootDirPath";
/** Assumes the theme type exists */ /** Assumes the theme type exists */
export function readFieldNameUsage(params: { keycloakifySrcDirPath: string; themeSrcDirPath: string; themeType: ThemeType }): string[] { export function readFieldNameUsage(params: { themeSrcDirPath: string; themeType: ThemeType }): string[] {
const { keycloakifySrcDirPath, themeSrcDirPath, themeType } = params; const { themeSrcDirPath, themeType } = params;
const fieldNames = new Set<string>(); const fieldNames = new Set<string>();
for (const srcDirPath of [pathJoin(keycloakifySrcDirPath, themeType), pathJoin(themeSrcDirPath, themeType)]) { for (const srcDirPath of [pathJoin(getThisCodebaseRootDirPath(), "src", themeType), pathJoin(themeSrcDirPath, themeType)]) {
const filePaths = crawl({ "dirPath": srcDirPath, "returnedPathsType": "absolute" }).filter(filePath => /\.(ts|tsx|js|jsx)$/.test(filePath)); const filePaths = crawl({ "dirPath": srcDirPath, "returnedPathsType": "absolute" }).filter(filePath => /\.(ts|tsx|js|jsx)$/.test(filePath));
for (const filePath of filePaths) { for (const filePath of filePaths) {

View File

@ -4,9 +4,6 @@ import * as child_process from "child_process";
import * as fs from "fs"; import * as fs from "fs";
import { readBuildOptions } from "../shared/buildOptions"; import { readBuildOptions } from "../shared/buildOptions";
import { getLogger } from "../tools/logger"; import { getLogger } from "../tools/logger";
import { getThemeSrcDirPath } from "../shared/getThemeSrcDirPath";
import { getThisCodebaseRootDirPath } from "../tools/getThisCodebaseRootDirPath";
import { readThisNpmProjectVersion } from "../tools/readThisNpmProjectVersion";
import { vitePluginSubScriptEnvNames } from "../shared/constants"; import { vitePluginSubScriptEnvNames } from "../shared/constants";
import { buildJars } from "./buildJars"; import { buildJars } from "./buildJars";
import type { CliCommandOptions } from "../main"; import type { CliCommandOptions } from "../main";
@ -20,8 +17,6 @@ export async function command(params: { cliCommandOptions: CliCommandOptions })
logger.log("🔏 Building the keycloak theme...⌚"); logger.log("🔏 Building the keycloak theme...⌚");
const { themeSrcDirPath } = getThemeSrcDirPath({ "reactAppRootDirPath": buildOptions.reactAppRootDirPath });
{ {
if (!fs.existsSync(buildOptions.keycloakifyBuildDirPath)) { if (!fs.existsSync(buildOptions.keycloakifyBuildDirPath)) {
fs.mkdirSync(buildOptions.keycloakifyBuildDirPath, { "recursive": true }); fs.mkdirSync(buildOptions.keycloakifyBuildDirPath, { "recursive": true });
@ -30,12 +25,7 @@ export async function command(params: { cliCommandOptions: CliCommandOptions })
fs.writeFileSync(pathJoin(buildOptions.keycloakifyBuildDirPath, ".gitignore"), Buffer.from("*", "utf8")); fs.writeFileSync(pathJoin(buildOptions.keycloakifyBuildDirPath, ".gitignore"), Buffer.from("*", "utf8"));
} }
await generateTheme({ await generateTheme({ buildOptions });
themeSrcDirPath,
"keycloakifySrcDirPath": pathJoin(getThisCodebaseRootDirPath(), "src"),
"keycloakifyVersion": readThisNpmProjectVersion(),
buildOptions
});
run_post_build_script: { run_post_build_script: {
if (buildOptions.bundler !== "vite") { if (buildOptions.bundler !== "vite") {