2024-07-13 19:33:59 +02:00
|
|
|
import { BUILD_FOR_KEYCLOAK_MAJOR_VERSION_ENV_NAME } from "../shared/constants";
|
2024-05-26 17:58:41 +02:00
|
|
|
import * as child_process from "child_process";
|
|
|
|
import { Deferred } from "evt/tools/Deferred";
|
|
|
|
import { assert } from "tsafe/assert";
|
2024-06-09 09:15:16 +02:00
|
|
|
import type { BuildContext } from "../shared/buildContext";
|
2024-06-24 03:58:42 +02:00
|
|
|
import chalk from "chalk";
|
2024-05-26 17:58:41 +02:00
|
|
|
|
2024-06-09 09:15:16 +02:00
|
|
|
export type BuildContextLike = {
|
2024-06-09 09:03:43 +02:00
|
|
|
projectDirPath: string;
|
2024-05-26 17:58:41 +02:00
|
|
|
keycloakifyBuildDirPath: string;
|
|
|
|
};
|
|
|
|
|
2024-06-09 09:15:16 +02:00
|
|
|
assert<BuildContext extends BuildContextLike ? true : false>();
|
2024-05-26 17:58:41 +02:00
|
|
|
|
|
|
|
export async function keycloakifyBuild(params: {
|
2024-06-16 01:29:15 +02:00
|
|
|
buildForKeycloakMajorVersionNumber: number;
|
2024-06-09 09:15:16 +02:00
|
|
|
buildContext: BuildContextLike;
|
2024-05-26 17:58:41 +02:00
|
|
|
}): Promise<{ isKeycloakifyBuildSuccess: boolean }> {
|
2024-06-16 01:29:15 +02:00
|
|
|
const { buildForKeycloakMajorVersionNumber, buildContext } = params;
|
2024-05-26 17:58:41 +02:00
|
|
|
|
|
|
|
const dResult = new Deferred<{ isSuccess: boolean }>();
|
|
|
|
|
2024-08-17 23:20:52 +02:00
|
|
|
console.log(chalk.blue("$ npx keycloakify build"));
|
2024-06-24 03:58:42 +02:00
|
|
|
|
2024-05-26 17:58:41 +02:00
|
|
|
const child = child_process.spawn("npx", ["keycloakify", "build"], {
|
2024-06-09 09:15:16 +02:00
|
|
|
cwd: buildContext.projectDirPath,
|
2024-05-26 17:58:41 +02:00
|
|
|
env: {
|
|
|
|
...process.env,
|
2024-07-13 19:33:59 +02:00
|
|
|
[BUILD_FOR_KEYCLOAK_MAJOR_VERSION_ENV_NAME]: `${buildForKeycloakMajorVersionNumber}`
|
2024-06-14 23:58:54 +02:00
|
|
|
},
|
|
|
|
shell: true
|
2024-05-26 17:58:41 +02:00
|
|
|
});
|
|
|
|
|
|
|
|
child.stdout.on("data", data => process.stdout.write(data));
|
|
|
|
|
|
|
|
child.stderr.on("data", data => process.stderr.write(data));
|
|
|
|
|
|
|
|
child.on("exit", code => dResult.resolve({ isSuccess: code === 0 }));
|
|
|
|
|
|
|
|
const { isSuccess } = await dResult.pr;
|
|
|
|
|
|
|
|
return { isKeycloakifyBuildSuccess: isSuccess };
|
|
|
|
}
|