use cacheDirPath for temporary directories
This commit is contained in:
parent
f935922241
commit
7d61be231e
@ -5,6 +5,7 @@ import { crawl } from "../src/bin/tools/crawl";
|
||||
import { downloadBuiltinKeycloakTheme } from "../src/bin/shared/downloadBuiltinKeycloakTheme";
|
||||
import { getThisCodebaseRootDirPath } from "../src/bin/tools/getThisCodebaseRootDirPath";
|
||||
import { getLogger } from "../src/bin/tools/logger";
|
||||
import { rmSync } from "../src/bin/tools/fs.rmSync";
|
||||
|
||||
// NOTE: To run without argument when we want to generate src/i18n/generated_kcMessages files,
|
||||
// update the version array for generating for newer version.
|
||||
@ -23,7 +24,7 @@ async function main() {
|
||||
|
||||
const tmpDirPath = pathJoin(thisCodebaseRootDirPath, "tmp_xImOef9dOd44");
|
||||
|
||||
fs.rmSync(tmpDirPath, { "recursive": true, "force": true });
|
||||
rmSync(tmpDirPath, { "recursive": true, "force": true });
|
||||
|
||||
fs.mkdirSync(tmpDirPath);
|
||||
|
||||
@ -66,7 +67,7 @@ async function main() {
|
||||
});
|
||||
}
|
||||
|
||||
fs.rmSync(tmpDirPath, { recursive: true, force: true });
|
||||
rmSync(tmpDirPath, { "recursive": true });
|
||||
|
||||
Object.keys(record).forEach(themeType => {
|
||||
const recordForPageType = record[themeType];
|
||||
|
@ -30,7 +30,9 @@ export async function command(params: { cliCommandOptions: CliCommandOptions })
|
||||
|
||||
const { keycloakVersion } = await promptKeycloakVersion();
|
||||
|
||||
const builtinKeycloakThemeTmpDirPath = pathJoin(emailThemeSrcDirPath, "..", "tmp_xIdP3_builtin_keycloak_theme");
|
||||
const builtinKeycloakThemeTmpDirPath = pathJoin(buildOptions.cacheDirPath, "initialize-email-theme_tmp");
|
||||
|
||||
rmSync(builtinKeycloakThemeTmpDirPath, { "recursive": true, "force": true });
|
||||
|
||||
await downloadBuiltinKeycloakTheme({
|
||||
keycloakVersion,
|
||||
@ -51,5 +53,5 @@ export async function command(params: { cliCommandOptions: CliCommandOptions })
|
||||
|
||||
logger.log(`${pathRelative(process.cwd(), emailThemeSrcDirPath)} ready to be customized, feel free to remove every file you do not customize`);
|
||||
|
||||
rmSync(builtinKeycloakThemeTmpDirPath, { "recursive": true, "force": true });
|
||||
rmSync(builtinKeycloakThemeTmpDirPath, { "recursive": true });
|
||||
}
|
||||
|
@ -6,15 +6,17 @@ import type { BuildOptions } from "../../shared/buildOptions";
|
||||
import * as fs from "fs/promises";
|
||||
import { accountV1ThemeName } from "../../shared/constants";
|
||||
import { generatePom, BuildOptionsLike as BuildOptionsLike_generatePom } from "./generatePom";
|
||||
import { existsSync, readFileSync } from "fs";
|
||||
import { readFileSync } from "fs";
|
||||
import { isInside } from "../../tools/isInside";
|
||||
import child_process from "child_process";
|
||||
import { rmSync } from "../../tools/fs.rmSync";
|
||||
|
||||
export type BuildOptionsLike = BuildOptionsLike_generatePom & {
|
||||
keycloakifyBuildDirPath: string;
|
||||
themeNames: string[];
|
||||
artifactId: string;
|
||||
themeVersion: string;
|
||||
cacheDirPath: string;
|
||||
};
|
||||
|
||||
assert<BuildOptions extends BuildOptionsLike ? true : false>();
|
||||
@ -27,14 +29,9 @@ export async function buildJar(params: {
|
||||
}): Promise<void> {
|
||||
const { jarFileBasename, keycloakAccountV1Version, keycloakThemeAdditionalInfoExtensionVersion, buildOptions } = params;
|
||||
|
||||
const keycloakifyBuildTmpDirPath = pathJoin(buildOptions.keycloakifyBuildDirPath, "..", jarFileBasename.replace(".jar", ""));
|
||||
const keycloakifyBuildTmpDirPath = pathJoin(buildOptions.cacheDirPath, jarFileBasename.replace(".jar", ""));
|
||||
|
||||
if (existsSync(keycloakifyBuildTmpDirPath)) {
|
||||
await fs.rm(keycloakifyBuildTmpDirPath, { "recursive": true });
|
||||
}
|
||||
|
||||
await fs.mkdir(keycloakifyBuildTmpDirPath, { "recursive": true });
|
||||
await fs.writeFile(pathJoin(keycloakifyBuildTmpDirPath, ".gitignore"), Buffer.from("*", "utf8"));
|
||||
rmSync(keycloakifyBuildTmpDirPath, { "recursive": true, "force": true });
|
||||
|
||||
const srcMainResourcesRelativeDirPath = pathJoin("src", "main", "resources");
|
||||
|
||||
@ -170,5 +167,5 @@ export async function buildJar(params: {
|
||||
pathJoin(buildOptions.keycloakifyBuildDirPath, jarFileBasename)
|
||||
);
|
||||
|
||||
await fs.rm(keycloakifyBuildTmpDirPath, { "recursive": true });
|
||||
rmSync(keycloakifyBuildTmpDirPath, { "recursive": true });
|
||||
}
|
||||
|
@ -18,7 +18,7 @@ assert<BuildOptions extends BuildOptionsLike ? true : false>();
|
||||
export async function bringInAccountV1(params: { buildOptions: BuildOptionsLike }) {
|
||||
const { buildOptions } = params;
|
||||
|
||||
const builtinKeycloakThemeTmpDirPath = pathJoin(buildOptions.cacheDirPath, "tmp_yxdE2_builtin_keycloak_theme");
|
||||
const builtinKeycloakThemeTmpDirPath = pathJoin(buildOptions.cacheDirPath, "bringInAccountV1_tmp");
|
||||
|
||||
await downloadBuiltinKeycloakTheme({
|
||||
"destDirPath": builtinKeycloakThemeTmpDirPath,
|
||||
|
@ -23,8 +23,8 @@ export async function downloadKeycloakStaticResources(params: {
|
||||
const { themeType, themeDirPath, keycloakVersion, buildOptions } = params;
|
||||
|
||||
const tmpDirPath = pathJoin(
|
||||
themeDirPath,
|
||||
`tmp_suLeKsxId_${crypto.createHash("sha256").update(`${themeType}-${keycloakVersion}`).digest("hex").slice(0, 8)}`
|
||||
buildOptions.cacheDirPath,
|
||||
`downloadKeycloakStaticResources_tmp_${crypto.createHash("sha256").update(`${themeType}-${keycloakVersion}`).digest("hex").slice(0, 8)}`
|
||||
);
|
||||
|
||||
await downloadBuiltinKeycloakTheme({
|
||||
@ -45,5 +45,5 @@ export async function downloadKeycloakStaticResources(params: {
|
||||
"destDirPath": pathJoin(resourcesPath, resources_common)
|
||||
});
|
||||
|
||||
rmSync(tmpDirPath, { "recursive": true, "force": true });
|
||||
rmSync(tmpDirPath, { "recursive": true });
|
||||
}
|
||||
|
@ -20,13 +20,13 @@ export function rmSync(dirPath: string, options: { recursive: true; force?: true
|
||||
|
||||
const removeDir_rec = (dirPath: string) =>
|
||||
fs.readdirSync(dirPath).forEach(basename => {
|
||||
const fileOrDirpath = pathJoin(dirPath, basename);
|
||||
const fileOrDirPath = pathJoin(dirPath, basename);
|
||||
|
||||
if (fs.lstatSync(fileOrDirpath).isDirectory()) {
|
||||
removeDir_rec(fileOrDirpath);
|
||||
if (fs.lstatSync(fileOrDirPath).isDirectory()) {
|
||||
removeDir_rec(fileOrDirPath);
|
||||
return;
|
||||
} else {
|
||||
fs.unlinkSync(fileOrDirpath);
|
||||
fs.unlinkSync(fileOrDirPath);
|
||||
}
|
||||
});
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user