keycloak_theme/src/bin/download-builtin-keycloak-theme.ts

35 lines
1.3 KiB
TypeScript
Raw Normal View History

2021-02-21 23:40:10 +01:00
#!/usr/bin/env node
2021-02-21 23:06:42 +01:00
import { keycloakThemeBuildingDirPath } from "./build-keycloak-theme";
2021-03-03 02:31:02 +01:00
import { join as pathJoin } from "path";
import { downloadAndUnzip } from "./tools/downloadAndUnzip";
2022-04-20 00:39:40 +02:00
import { promptKeycloakVersion } from "./promptKeycloakVersion";
2021-02-21 23:06:42 +01:00
2022-04-09 20:17:20 +02:00
export function downloadBuiltinKeycloakTheme(params: { keycloakVersion: string; destDirPath: string }) {
const { keycloakVersion, destDirPath } = params;
for (const ext of ["", "-community"]) {
downloadAndUnzip({
"destDirPath": destDirPath,
"url": `https://github.com/keycloak/keycloak/archive/refs/tags/${keycloakVersion}.zip`,
2022-08-20 14:56:20 +07:00
"pathOfDirToExtractInArchive": `keycloak-${keycloakVersion}/themes/src/main/resources${ext}/theme`,
"cacheDirPath": pathJoin(keycloakThemeBuildingDirPath, ".cache")
});
}
}
2021-02-28 18:40:57 +01:00
if (require.main === module) {
2022-04-20 00:39:40 +02:00
(async () => {
const { keycloakVersion } = await promptKeycloakVersion();
2022-04-20 00:39:40 +02:00
const destDirPath = pathJoin(keycloakThemeBuildingDirPath, "src", "main", "resources", "theme");
2022-04-20 00:39:40 +02:00
console.log(`Downloading builtins theme of Keycloak ${keycloakVersion} here ${destDirPath}`);
2022-04-20 00:39:40 +02:00
downloadBuiltinKeycloakTheme({
keycloakVersion,
destDirPath
2022-04-20 00:39:40 +02:00
});
})();
2021-02-28 18:40:57 +01:00
}