Resolve package.json path relative to the package.json

This commit is contained in:
Joseph Garrone 2024-10-13 00:55:06 +02:00
parent b86039536e
commit f5a9a28124

View File

@ -508,6 +508,15 @@ export function getBuildContext(params: {
return themeNames; return themeNames;
})(); })();
const relativePathsCwd = (() => {
switch (bundler) {
case "vite":
return projectDirPath;
case "webpack":
return pathDirname(packageJsonFilePath);
}
})();
const projectBuildDirPath = (() => { const projectBuildDirPath = (() => {
webpack: { webpack: {
if (bundler !== "webpack") { if (bundler !== "webpack") {
@ -519,7 +528,7 @@ export function getBuildContext(params: {
if (parsedPackageJson.keycloakify.projectBuildDirPath !== undefined) { if (parsedPackageJson.keycloakify.projectBuildDirPath !== undefined) {
return getAbsoluteAndInOsFormatPath({ return getAbsoluteAndInOsFormatPath({
pathIsh: parsedPackageJson.keycloakify.projectBuildDirPath, pathIsh: parsedPackageJson.keycloakify.projectBuildDirPath,
cwd: projectDirPath cwd: relativePathsCwd
}); });
} }
@ -563,7 +572,7 @@ export function getBuildContext(params: {
if (buildOptions.keycloakifyBuildDirPath !== undefined) { if (buildOptions.keycloakifyBuildDirPath !== undefined) {
return getAbsoluteAndInOsFormatPath({ return getAbsoluteAndInOsFormatPath({
pathIsh: buildOptions.keycloakifyBuildDirPath, pathIsh: buildOptions.keycloakifyBuildDirPath,
cwd: projectDirPath cwd: relativePathsCwd
}); });
} }
@ -592,7 +601,7 @@ export function getBuildContext(params: {
if (parsedPackageJson.keycloakify.publicDirPath !== undefined) { if (parsedPackageJson.keycloakify.publicDirPath !== undefined) {
return getAbsoluteAndInOsFormatPath({ return getAbsoluteAndInOsFormatPath({
pathIsh: parsedPackageJson.keycloakify.publicDirPath, pathIsh: parsedPackageJson.keycloakify.publicDirPath,
cwd: projectDirPath cwd: relativePathsCwd
}); });
} }
@ -664,7 +673,7 @@ export function getBuildContext(params: {
pathIsh: pathIsh:
parsedPackageJson.keycloakify parsedPackageJson.keycloakify
.staticDirPathInProjectBuildDirPath, .staticDirPathInProjectBuildDirPath,
cwd: projectBuildDirPath cwd: relativePathsCwd
}); });
} }
@ -992,7 +1001,7 @@ export function getBuildContext(params: {
type: "path", type: "path",
path: getAbsoluteAndInOsFormatPath({ path: getAbsoluteAndInOsFormatPath({
pathIsh: urlOrPath, pathIsh: urlOrPath,
cwd: projectDirPath cwd: relativePathsCwd
}) })
}; };
} }
@ -1002,7 +1011,7 @@ export function getBuildContext(params: {
? undefined ? undefined
: getAbsoluteAndInOsFormatPath({ : getAbsoluteAndInOsFormatPath({
pathIsh: buildOptions.startKeycloakOptions.realmJsonFilePath, pathIsh: buildOptions.startKeycloakOptions.realmJsonFilePath,
cwd: projectDirPath cwd: relativePathsCwd
}), }),
port: buildOptions.startKeycloakOptions?.port port: buildOptions.startKeycloakOptions?.port
} }