keycloak_theme/src/bin/copy-keycloak-resources-to-public.ts

45 lines
1.5 KiB
TypeScript
Raw Normal View History

#!/usr/bin/env node
import { downloadKeycloakStaticResources } from "./keycloakify/generateTheme/downloadKeycloakStaticResources";
2024-02-11 12:04:50 +01:00
import { join as pathJoin } from "path";
2024-01-30 06:38:26 +01:00
import { readBuildOptions } from "./keycloakify/buildOptions";
import { themeTypes, keycloak_resources, lastKeycloakVersionWithAccountV1 } from "./constants";
import * as fs from "fs";
(async () => {
const buildOptions = readBuildOptions({
2023-09-03 23:26:34 +02:00
"processArgv": process.argv.slice(2)
});
2023-09-03 23:26:34 +02:00
const reservedDirPath = pathJoin(buildOptions.publicDirPath, keycloak_resources);
for (const themeType of themeTypes) {
await downloadKeycloakStaticResources({
"keycloakVersion": (() => {
switch (themeType) {
case "login":
2023-09-03 21:02:51 +02:00
return buildOptions.loginThemeResourcesFromKeycloakVersion;
case "account":
return lastKeycloakVersionWithAccountV1;
}
})(),
themeType,
"themeDirPath": reservedDirPath,
2023-09-03 23:26:34 +02:00
buildOptions
});
}
fs.writeFileSync(
pathJoin(reservedDirPath, "README.txt"),
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"));
})();