2024-05-19 10:32:38 +02:00
|
|
|
import { join as pathJoin, relative as pathRelative, sep as pathSep } from "path";
|
2024-05-15 05:14:01 +02:00
|
|
|
import { promptKeycloakVersion } from "./shared/promptKeycloakVersion";
|
|
|
|
import { readBuildOptions } from "./shared/buildOptions";
|
2024-05-19 10:46:26 +02:00
|
|
|
import { downloadKeycloakDefaultTheme } from "./shared/downloadKeycloakDefaultTheme";
|
2024-05-15 05:14:01 +02:00
|
|
|
import type { CliCommandOptions } from "./main";
|
2024-05-19 10:32:38 +02:00
|
|
|
import chalk from "chalk";
|
2021-02-21 23:06:42 +01:00
|
|
|
|
2024-05-15 05:14:01 +02:00
|
|
|
export async function command(params: { cliCommandOptions: CliCommandOptions }) {
|
|
|
|
const { cliCommandOptions } = params;
|
2023-09-03 23:26:34 +02:00
|
|
|
|
2023-04-19 05:04:11 +02:00
|
|
|
const buildOptions = readBuildOptions({
|
2024-05-15 05:14:01 +02:00
|
|
|
cliCommandOptions
|
2023-04-19 05:04:11 +02:00
|
|
|
});
|
|
|
|
|
2024-05-19 10:32:38 +02:00
|
|
|
console.log(chalk.cyan("Select the Keycloak version from which you want to download the builtins theme:"));
|
2024-05-18 04:33:31 +02:00
|
|
|
|
2024-05-17 05:13:41 +02:00
|
|
|
const { keycloakVersion } = await promptKeycloakVersion({
|
2024-05-18 08:11:20 +02:00
|
|
|
"startingFromMajor": undefined,
|
|
|
|
"cacheDirPath": buildOptions.cacheDirPath
|
2024-05-17 05:13:41 +02:00
|
|
|
});
|
2023-03-29 09:54:29 +02:00
|
|
|
|
2024-05-19 10:32:38 +02:00
|
|
|
console.log(`→ ${keycloakVersion}`);
|
|
|
|
|
2023-04-19 05:04:11 +02:00
|
|
|
const destDirPath = pathJoin(buildOptions.keycloakifyBuildDirPath, "src", "main", "resources", "theme");
|
2021-10-07 21:00:53 +02:00
|
|
|
|
2024-05-19 10:32:38 +02:00
|
|
|
console.log(
|
2024-05-20 02:26:14 +02:00
|
|
|
[
|
|
|
|
`Downloading builtins theme of Keycloak ${keycloakVersion} here:`,
|
|
|
|
`- ${chalk.bold(`.${pathSep}${pathJoin(pathRelative(process.cwd(), destDirPath), "base")}`)}`,
|
|
|
|
`- ${chalk.bold(`.${pathSep}${pathJoin(pathRelative(process.cwd(), destDirPath), "keycloak")}`)}`
|
|
|
|
].join("\n")
|
2024-05-19 10:32:38 +02:00
|
|
|
);
|
2021-10-07 17:32:38 +02:00
|
|
|
|
2024-05-19 10:46:26 +02:00
|
|
|
await downloadKeycloakDefaultTheme({
|
2023-03-29 09:54:29 +02:00
|
|
|
keycloakVersion,
|
2023-09-03 23:26:34 +02:00
|
|
|
destDirPath,
|
|
|
|
buildOptions
|
2023-03-29 09:54:29 +02:00
|
|
|
});
|
2024-05-19 10:32:38 +02:00
|
|
|
|
|
|
|
console.log(chalk.green(`✓ done`));
|
2023-03-29 09:54:29 +02:00
|
|
|
}
|