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";
|
|
|
|
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";
|
2024-05-18 10:24:55 +02:00
|
|
|
import chalk from "chalk";
|
|
|
|
import { readThisNpmPackageVersion } from "../tools/readThisNpmPackageVersion";
|
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
|
|
|
|
2024-05-18 10:24:55 +02:00
|
|
|
console.log(
|
|
|
|
[
|
|
|
|
chalk.cyan(`keycloakify v${readThisNpmPackageVersion()}`),
|
|
|
|
chalk.green(`Building the keycloak theme in .${pathSep}${pathRelative(process.cwd(), buildOptions.keycloakifyBuildDirPath)} ...`)
|
|
|
|
].join(" ")
|
|
|
|
);
|
2024-05-16 09:20:37 +02:00
|
|
|
|
2024-05-18 10:24:55 +02:00
|
|
|
const startTime = Date.now();
|
2023-04-19 05:04:11 +02:00
|
|
|
|
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
|
|
|
|
2024-05-18 10:24:55 +02:00
|
|
|
console.log(chalk.green(`✓ built in ${((Date.now() - startTime) / 1000).toFixed(2)}s`));
|
2021-06-14 21:21:36 +02:00
|
|
|
}
|