diff --git a/src/bin/keycloakify/keycloakify.ts b/src/bin/keycloakify/keycloakify.ts index 5de98472..a2cdc2a8 100644 --- a/src/bin/keycloakify/keycloakify.ts +++ b/src/bin/keycloakify/keycloakify.ts @@ -12,6 +12,12 @@ import * as os from "os"; import { rmSync } from "../tools/fs.rmSync"; export async function command(params: { cliCommandOptions: CliCommandOptions }) { + console.log("DEBUG:", { + __filename, + __dirname, + "process.cwd()": process.cwd() + }); + exit_if_maven_not_installed: { let commandOutput: Buffer | undefined = undefined; diff --git a/src/bin/shared/buildContext.ts b/src/bin/shared/buildContext.ts index ea8f0557..2d0b92b6 100644 --- a/src/bin/shared/buildContext.ts +++ b/src/bin/shared/buildContext.ts @@ -90,6 +90,8 @@ export function getBuildContext(params: { }): BuildContext { const { cliCommandOptions } = params; + console.log("DEBUG:", { cliCommandOptions }); + const projectDirPath = (() => { if (cliCommandOptions.projectDirPath === undefined) { return process.cwd(); @@ -101,6 +103,8 @@ export function getBuildContext(params: { }); })(); + console.log("DEBUG:", { projectDirPath }); + const { resolvedViteConfig } = (() => { if ( fs @@ -135,6 +139,8 @@ export function getBuildContext(params: { return { resolvedViteConfig }; })(); + console.log("DEBUG:", { resolvedViteConfig }); + const parsedPackageJson = (() => { type BuildOptions_packageJson = BuildOptions & { projectBuildDirPath?: string; @@ -235,11 +241,15 @@ export function getBuildContext(params: { ); })(); + console.log("DEBUG:", { parsedPackageJson }); + const buildOptions = { ...parsedPackageJson.keycloakify, ...resolvedViteConfig?.buildOptions }; + console.log("DEBUG:", { buildOptions }); + const { themeSrcDirPath } = (() => { const srcDirPath = pathJoin(projectDirPath, "src"); @@ -288,6 +298,8 @@ export function getBuildContext(params: { ]) ); + console.log("DEBUG:", { themeSrcDirPath }); + const themeNames = ((): [string, ...string[]] => { if (buildOptions.themeName === undefined) { return [ @@ -309,6 +321,8 @@ export function getBuildContext(params: { return [mainThemeName, ...themeVariantNames]; })(); + console.log("DEBUG:", { themeNames }); + const projectBuildDirPath = (() => { webpack: { if (resolvedViteConfig !== undefined) { @@ -328,14 +342,18 @@ export function getBuildContext(params: { return pathJoin(projectDirPath, resolvedViteConfig.buildDir); })(); + console.log("DEBUG:", { projectBuildDirPath }); + const { npmWorkspaceRootDirPath } = getNpmWorkspaceRootDirPath({ projectDirPath, dependencyExpected: "keycloakify" }); + console.log("DEBUG:", { npmWorkspaceRootDirPath }); + const bundler = resolvedViteConfig !== undefined ? "vite" : "webpack"; - return { + const buildContext: BuildContext = { bundler, themeVersion: buildOptions.themeVersion ?? parsedPackageJson.version ?? "0.0.0", themeNames, @@ -765,4 +783,8 @@ export function getBuildContext(params: { return jarTargets; })() }; + + console.log("DEBUG:", JSON.stringify({ buildContext }, null, 2)); + + return buildContext; } diff --git a/src/bin/tools/getNpmWorkspaceRootDirPath.ts b/src/bin/tools/getNpmWorkspaceRootDirPath.ts index 87a610c7..1d1ed2c2 100644 --- a/src/bin/tools/getNpmWorkspaceRootDirPath.ts +++ b/src/bin/tools/getNpmWorkspaceRootDirPath.ts @@ -9,11 +9,18 @@ export function getNpmWorkspaceRootDirPath(params: { }) { const { projectDirPath, dependencyExpected } = params; + console.log("DEBUG getNpmWorkspaceRootDirPath:", { + projectDirPath, + dependencyExpected + }); + const npmWorkspaceRootDirPath = (function callee(depth: number): string { const cwd = pathResolve( pathJoin(...[projectDirPath, ...Array(depth).fill("..")]) ); + console.log("DEBUG getNpmWorkspaceRootDirPath:", { cwd }); + assert(cwd !== pathSep, "NPM workspace not found"); try { @@ -22,6 +29,8 @@ export function getNpmWorkspaceRootDirPath(params: { stdio: "ignore" }); } catch (error) { + console.log("DEBUG getNpmWorkspaceRootDirPath: got error npm config get"); + if (String(error).includes("ENOWORKSPACES")) { return callee(depth + 1); } @@ -29,6 +38,8 @@ export function getNpmWorkspaceRootDirPath(params: { throw error; } + console.log("DEBUG getNpmWorkspaceRootDirPath: npm workspace found"); + const packageJsonFilePath = pathJoin(cwd, "package.json"); if (!fs.existsSync(packageJsonFilePath)) {