2024-05-17 01:21:26 +02:00
|
|
|
import { generateSrcMainResources } from "./generateSrcMainResources";
|
2024-05-11 23:20:15 +02:00
|
|
|
import { join as pathJoin, relative as pathRelative, sep as pathSep } from "path";
|
2021-06-14 21:21:36 +02:00
|
|
|
import * as child_process from "child_process";
|
2022-01-18 18:52:52 +01:00
|
|
|
import * as fs from "fs";
|
2024-05-15 05:14:01 +02:00
|
|
|
import { readBuildOptions } from "../shared/buildOptions";
|
2022-09-08 12:06:26 +03:00
|
|
|
import { getLogger } from "../tools/logger";
|
2024-05-15 05:14:01 +02:00
|
|
|
import { vitePluginSubScriptEnvNames } from "../shared/constants";
|
2024-05-12 19:16:59 +02:00
|
|
|
import { buildJars } from "./buildJars";
|
2024-05-15 05:14:01 +02:00
|
|
|
import type { CliCommandOptions } from "../main";
|
2021-06-14 21:21:36 +02:00
|
|
|
|
2024-05-15 05:14:01 +02:00
|
|
|
export async function command(params: { cliCommandOptions: CliCommandOptions }) {
|
|
|
|
const { cliCommandOptions } = params;
|
|
|
|
|
|
|
|
const buildOptions = readBuildOptions({ cliCommandOptions });
|
2021-06-23 18:03:49 +02:00
|
|
|
|
2023-04-19 05:04:11 +02:00
|
|
|
const logger = getLogger({ "isSilent": buildOptions.isSilent });
|
2024-05-16 09:20:37 +02:00
|
|
|
|
2023-04-19 05:04:11 +02:00
|
|
|
logger.log("🔏 Building the keycloak theme...⌚");
|
|
|
|
|
2024-05-12 19:37:16 +02:00
|
|
|
{
|
2024-05-12 19:38:48 +02:00
|
|
|
if (!fs.existsSync(buildOptions.keycloakifyBuildDirPath)) {
|
|
|
|
fs.mkdirSync(buildOptions.keycloakifyBuildDirPath, { "recursive": true });
|
|
|
|
}
|
|
|
|
|
|
|
|
fs.writeFileSync(pathJoin(buildOptions.keycloakifyBuildDirPath, ".gitignore"), Buffer.from("*", "utf8"));
|
|
|
|
}
|
|
|
|
|
2024-05-17 01:21:26 +02:00
|
|
|
await generateSrcMainResources({ buildOptions });
|
2024-05-12 19:38:48 +02:00
|
|
|
|
2024-03-05 19:42:49 +01:00
|
|
|
run_post_build_script: {
|
|
|
|
if (buildOptions.bundler !== "vite") {
|
|
|
|
break run_post_build_script;
|
2024-02-23 19:15:59 +01:00
|
|
|
}
|
2024-03-05 19:42:49 +01:00
|
|
|
|
|
|
|
child_process.execSync("npx vite", {
|
|
|
|
"cwd": buildOptions.reactAppRootDirPath,
|
|
|
|
"env": {
|
|
|
|
...process.env,
|
2024-05-15 05:14:01 +02:00
|
|
|
[vitePluginSubScriptEnvNames.runPostBuildScript]: JSON.stringify(buildOptions)
|
2024-03-05 19:42:49 +01:00
|
|
|
}
|
|
|
|
});
|
|
|
|
}
|
2024-02-23 19:15:59 +01:00
|
|
|
|
2024-05-17 01:21:26 +02:00
|
|
|
await buildJars({ buildOptions });
|
2021-06-14 21:21:36 +02:00
|
|
|
|
2022-09-08 12:06:26 +03:00
|
|
|
logger.log(
|
2024-05-16 09:20:37 +02:00
|
|
|
`✅ Your keycloak theme has been generated and bundled into .${pathSep}${pathJoin(
|
|
|
|
pathRelative(process.cwd(), buildOptions.keycloakifyBuildDirPath),
|
|
|
|
"keycloak-theme-for-kc-*.jar"
|
|
|
|
)}`
|
2021-10-11 21:35:40 +02:00
|
|
|
);
|
2021-06-14 21:21:36 +02:00
|
|
|
}
|