From e6661cb89899fce15f07ca7f95d9b3813fd1df04 Mon Sep 17 00:00:00 2001 From: Joseph Garrone Date: Sun, 11 Feb 2024 23:17:39 +0100 Subject: [PATCH] Fix build --- scripts/generate-i18n-messages.ts | 13 ++++++++----- scripts/link-in-app.ts | 4 ++-- test/bin/setupSampleReactProject.ts | 11 +++++++++-- 3 files changed, 19 insertions(+), 9 deletions(-) diff --git a/scripts/generate-i18n-messages.ts b/scripts/generate-i18n-messages.ts index 823fb1e8..6da685ae 100644 --- a/scripts/generate-i18n-messages.ts +++ b/scripts/generate-i18n-messages.ts @@ -3,7 +3,7 @@ import * as fs from "fs"; import { join as pathJoin, relative as pathRelative, dirname as pathDirname, sep as pathSep } from "path"; import { crawl } from "../src/bin/tools/crawl"; import { downloadBuiltinKeycloakTheme } from "../src/bin/download-builtin-keycloak-theme"; -import { getProjectRoot } from "../src/bin/tools/getProjectRoot"; +import { getThisCodebaseRootDirPath } from "../src/bin/tools/getThisCodebaseRootDirPath"; import { getLogger } from "../src/bin/tools/logger"; // NOTE: To run without argument when we want to generate src/i18n/generated_kcMessages files, @@ -19,7 +19,9 @@ const logger = getLogger({ isSilent }); async function main() { const keycloakVersion = "23.0.4"; - const tmpDirPath = pathJoin(getProjectRoot(), "tmp_xImOef9dOd44"); + const thisCodebaseRootDirPath = getThisCodebaseRootDirPath(); + + const tmpDirPath = pathJoin(thisCodebaseRootDirPath, "tmp_xImOef9dOd44"); fs.rmSync(tmpDirPath, { "recursive": true, "force": true }); @@ -31,7 +33,8 @@ async function main() { keycloakVersion, "destDirPath": tmpDirPath, "buildOptions": { - "cacheDirPath": pathJoin(getProjectRoot(), "node_modules", ".cache", "keycloakify") + "cacheDirPath": pathJoin(thisCodebaseRootDirPath, "node_modules", ".cache", "keycloakify"), + "npmWorkspaceRootDirPath": thisCodebaseRootDirPath } }); @@ -72,12 +75,12 @@ async function main() { return; } - const baseMessagesDirPath = pathJoin(getProjectRoot(), "src", themeType, "i18n", "baseMessages"); + const baseMessagesDirPath = pathJoin(thisCodebaseRootDirPath, "src", themeType, "i18n", "baseMessages"); const languages = Object.keys(recordForPageType); const generatedFileHeader = [ - `//This code was automatically generated by running ${pathRelative(getProjectRoot(), __filename)}`, + `//This code was automatically generated by running ${pathRelative(thisCodebaseRootDirPath, __filename)}`, "//PLEASE DO NOT EDIT MANUALLY", "" ].join("\n"); diff --git a/scripts/link-in-app.ts b/scripts/link-in-app.ts index 76b14650..eacb3214 100644 --- a/scripts/link-in-app.ts +++ b/scripts/link-in-app.ts @@ -1,11 +1,11 @@ import { execSync } from "child_process"; import { join as pathJoin, relative as pathRelative } from "path"; -import { getProjectRoot } from "../src/bin/tools/getProjectRoot"; +import { getThisCodebaseRootDirPath } from "../src/bin/tools/getThisCodebaseRootDirPath"; import * as fs from "fs"; const singletonDependencies: string[] = ["react", "@types/react"]; -const rootDirPath = getProjectRoot(); +const rootDirPath = getThisCodebaseRootDirPath(); //NOTE: This is only required because of: https://github.com/garronej/ts-ci/blob/c0e207b9677523d4ec97fe672ddd72ccbb3c1cc4/README.md?plain=1#L54-L58 fs.writeFileSync( diff --git a/test/bin/setupSampleReactProject.ts b/test/bin/setupSampleReactProject.ts index 5ea6daf1..79e7516a 100644 --- a/test/bin/setupSampleReactProject.ts +++ b/test/bin/setupSampleReactProject.ts @@ -1,9 +1,16 @@ -import { downloadAndUnzip } from "keycloakify/bin/tools/downloadAndUnzip"; +import { downloadAndUnzip } from "keycloakify/bin/downloadAndUnzip"; +import { join as pathJoin } from "path"; +import { getThisCodebaseRootDirPath } from "keycloakify/bin/tools/getThisCodebaseRootDirPath"; export async function setupSampleReactProject(destDirPath: string) { + const thisCodebaseRootDirPath = getThisCodebaseRootDirPath(); + await downloadAndUnzip({ "url": "https://github.com/keycloakify/keycloakify/releases/download/v0.0.1/sample_build_dir_and_package_json.zip", "destDirPath": destDirPath, - "doUseCache": false + "buildOptions": { + "cacheDirPath": pathJoin(thisCodebaseRootDirPath, "node_modules", ".cache", "keycloakify"), + "npmWorkspaceRootDirPath": thisCodebaseRootDirPath + } }); }