2023-04-19 05:04:11 +02:00
|
|
|
#!/usr/bin/env node
|
|
|
|
|
|
|
|
import { downloadKeycloakStaticResources } from "./keycloakify/generateTheme/downloadKeycloakStaticResources";
|
2023-09-03 23:26:34 +02:00
|
|
|
import { join as pathJoin, relative as pathRelative } from "path";
|
2024-01-30 06:38:26 +01:00
|
|
|
import { readBuildOptions } from "./keycloakify/buildOptions";
|
2023-09-03 07:14:57 +02:00
|
|
|
import { themeTypes, keycloak_resources, lastKeycloakVersionWithAccountV1 } from "./constants";
|
2023-04-19 05:04:11 +02:00
|
|
|
import * as fs from "fs";
|
|
|
|
|
|
|
|
(async () => {
|
|
|
|
const buildOptions = readBuildOptions({
|
2023-09-03 23:26:34 +02:00
|
|
|
"processArgv": process.argv.slice(2)
|
2023-04-19 05:04:11 +02:00
|
|
|
});
|
|
|
|
|
2023-09-03 23:26:34 +02:00
|
|
|
const reservedDirPath = pathJoin(buildOptions.publicDirPath, keycloak_resources);
|
2023-04-19 05:04:11 +02:00
|
|
|
|
|
|
|
for (const themeType of themeTypes) {
|
|
|
|
await downloadKeycloakStaticResources({
|
2023-09-03 07:14:57 +02:00
|
|
|
"keycloakVersion": (() => {
|
|
|
|
switch (themeType) {
|
|
|
|
case "login":
|
2023-09-03 21:02:51 +02:00
|
|
|
return buildOptions.loginThemeResourcesFromKeycloakVersion;
|
2023-09-03 07:14:57 +02:00
|
|
|
case "account":
|
|
|
|
return lastKeycloakVersionWithAccountV1;
|
|
|
|
}
|
|
|
|
})(),
|
|
|
|
themeType,
|
|
|
|
"themeDirPath": reservedDirPath,
|
2023-09-03 23:26:34 +02:00
|
|
|
buildOptions
|
2023-04-19 05:04:11 +02:00
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
fs.writeFileSync(
|
2023-09-03 07:14:57 +02:00
|
|
|
pathJoin(reservedDirPath, "README.txt"),
|
2023-04-19 05:04:11 +02:00
|
|
|
Buffer.from(
|
|
|
|
// prettier-ignore
|
|
|
|
[
|
|
|
|
"This is just a test folder that helps develop",
|
|
|
|
"the login and register page without having to run a Keycloak container"
|
|
|
|
].join(" ")
|
|
|
|
)
|
|
|
|
);
|
|
|
|
|
2024-02-05 08:52:58 +01:00
|
|
|
fs.writeFileSync(pathJoin(buildOptions.publicDirPath, keycloak_resources, ".gitignore"), Buffer.from("*", "utf8"));
|
2023-04-19 05:32:19 +02:00
|
|
|
|
2024-02-08 00:56:33 +01:00
|
|
|
console.log(`${pathRelative(buildOptions.reactAppRootDirPath, reservedDirPath)} directory created.`);
|
2023-04-19 05:04:11 +02:00
|
|
|
})();
|