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

51 lines
1.7 KiB
TypeScript
Raw Normal View History

#!/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";
import { readBuildOptions } from "./keycloakify/BuildOptions";
import { themeTypes, keycloak_resources, lastKeycloakVersionWithAccountV1 } from "./constants";
import * as fs from "fs";
(async () => {
2023-09-03 23:26:34 +02:00
const reactAppRootDirPath = process.cwd();
const buildOptions = readBuildOptions({
2023-09-03 23:26:34 +02:00
reactAppRootDirPath,
"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
"usedResources": undefined,
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(" ")
)
);
2023-09-03 23:26:34 +02:00
fs.writeFileSync(pathJoin(buildOptions.publicDirPath, "keycloak-resources", ".gitignore"), Buffer.from("*", "utf8"));
2023-04-19 05:32:19 +02:00
2023-09-03 23:26:34 +02:00
console.log(`${pathRelative(reactAppRootDirPath, reservedDirPath)} directory created.`);
})();