fix(mvn): scoped packages compatibility
This commit is contained in:
parent
f4a6fd5c5e
commit
34263661d7
@ -1,11 +1,16 @@
|
|||||||
import { generateKeycloakThemeResources } from "./generateKeycloakThemeResources";
|
import { generateKeycloakThemeResources } from "./generateKeycloakThemeResources";
|
||||||
import { generateJavaStackFiles } from "./generateJavaStackFiles";
|
import { generateJavaStackFiles } from "./generateJavaStackFiles";
|
||||||
import type { ParsedPackageJson } from "./generateJavaStackFiles";
|
|
||||||
import { join as pathJoin, relative as pathRelative, basename as pathBasename } from "path";
|
import { join as pathJoin, relative as pathRelative, basename as pathBasename } from "path";
|
||||||
import * as child_process from "child_process";
|
import * as child_process from "child_process";
|
||||||
import { generateDebugFiles, containerLaunchScriptBasename } from "./generateDebugFiles";
|
import { generateDebugFiles, containerLaunchScriptBasename } from "./generateDebugFiles";
|
||||||
import { URL } from "url";
|
import { URL } from "url";
|
||||||
|
|
||||||
|
type ParsedPackageJson = {
|
||||||
|
name: string;
|
||||||
|
version: string;
|
||||||
|
homepage?: string;
|
||||||
|
};
|
||||||
|
|
||||||
const reactProjectDirPath = process.cwd();
|
const reactProjectDirPath = process.cwd();
|
||||||
|
|
||||||
const doUseExternalAssets = process.argv[2]?.toLowerCase() === "--external-assets";
|
const doUseExternalAssets = process.argv[2]?.toLowerCase() === "--external-assets";
|
||||||
@ -14,17 +19,21 @@ const parsedPackageJson: ParsedPackageJson = require(pathJoin(reactProjectDirPat
|
|||||||
|
|
||||||
export const keycloakThemeBuildingDirPath = pathJoin(reactProjectDirPath, "build_keycloak");
|
export const keycloakThemeBuildingDirPath = pathJoin(reactProjectDirPath, "build_keycloak");
|
||||||
|
|
||||||
export function main() {
|
function sanitizeThemeName(name: string) {
|
||||||
|
return name.replace(/^@(.*)/, '$1').split('/').join('-');
|
||||||
|
}
|
||||||
|
|
||||||
|
export function main() {
|
||||||
console.log("🔏 Building the keycloak theme...⌚");
|
console.log("🔏 Building the keycloak theme...⌚");
|
||||||
|
|
||||||
const extraPagesId: string[] = (parsedPackageJson as any)["keycloakify"]?.["extraPages"] ?? [];
|
const extraPagesId: string[] = (parsedPackageJson as any)["keycloakify"]?.["extraPages"] ?? [];
|
||||||
const extraThemeProperties: string[] = (parsedPackageJson as any)["keycloakify"]?.["extraThemeProperties"] ?? [];
|
const extraThemeProperties: string[] = (parsedPackageJson as any)["keycloakify"]?.["extraThemeProperties"] ?? [];
|
||||||
|
const themeName = sanitizeThemeName(parsedPackageJson.name);
|
||||||
|
|
||||||
generateKeycloakThemeResources({
|
generateKeycloakThemeResources({
|
||||||
keycloakThemeBuildingDirPath,
|
keycloakThemeBuildingDirPath,
|
||||||
"reactAppBuildDirPath": pathJoin(reactProjectDirPath, "build"),
|
"reactAppBuildDirPath": pathJoin(reactProjectDirPath, "build"),
|
||||||
"themeName": parsedPackageJson.name,
|
themeName,
|
||||||
...(() => {
|
...(() => {
|
||||||
|
|
||||||
const url = (() => {
|
const url = (() => {
|
||||||
@ -61,7 +70,9 @@ export function main() {
|
|||||||
});
|
});
|
||||||
|
|
||||||
const { jarFilePath } = generateJavaStackFiles({
|
const { jarFilePath } = generateJavaStackFiles({
|
||||||
parsedPackageJson,
|
version: parsedPackageJson.version,
|
||||||
|
themeName,
|
||||||
|
homepage: parsedPackageJson.homepage,
|
||||||
keycloakThemeBuildingDirPath
|
keycloakThemeBuildingDirPath
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -72,7 +83,7 @@ export function main() {
|
|||||||
|
|
||||||
generateDebugFiles({
|
generateDebugFiles({
|
||||||
keycloakThemeBuildingDirPath,
|
keycloakThemeBuildingDirPath,
|
||||||
"packageJsonName": parsedPackageJson.name
|
themeName
|
||||||
});
|
});
|
||||||
|
|
||||||
console.log([
|
console.log([
|
||||||
@ -106,7 +117,7 @@ export function main() {
|
|||||||
`👉 $ ./${pathRelative(reactProjectDirPath, pathJoin(keycloakThemeBuildingDirPath, containerLaunchScriptBasename))} 👈`,
|
`👉 $ ./${pathRelative(reactProjectDirPath, pathJoin(keycloakThemeBuildingDirPath, containerLaunchScriptBasename))} 👈`,
|
||||||
'',
|
'',
|
||||||
'To enable the theme within keycloak log into the admin console ( 👉 http://localhost:8080 username: admin, password: admin 👈), create a realm (called "myrealm" for example),',
|
'To enable the theme within keycloak log into the admin console ( 👉 http://localhost:8080 username: admin, password: admin 👈), create a realm (called "myrealm" for example),',
|
||||||
`go to your realm settings, click on the theme tab then select ${parsedPackageJson.name}.`,
|
`go to your realm settings, click on the theme tab then select ${themeName}.`,
|
||||||
`More details: https://www.keycloak.org/getting-started/getting-started-docker`,
|
`More details: https://www.keycloak.org/getting-started/getting-started-docker`,
|
||||||
'',
|
'',
|
||||||
'Once your container is up and configured 👉 http://localhost:8080/auth/realms/myrealm/account 👈',
|
'Once your container is up and configured 👉 http://localhost:8080/auth/realms/myrealm/account 👈',
|
||||||
|
@ -7,12 +7,12 @@ export const containerLaunchScriptBasename = "start_keycloak_testing_container.s
|
|||||||
/** Files for being able to run a hot reload keycloak container */
|
/** Files for being able to run a hot reload keycloak container */
|
||||||
export function generateDebugFiles(
|
export function generateDebugFiles(
|
||||||
params: {
|
params: {
|
||||||
packageJsonName: string;
|
themeName: string;
|
||||||
keycloakThemeBuildingDirPath: string;
|
keycloakThemeBuildingDirPath: string;
|
||||||
}
|
}
|
||||||
) {
|
) {
|
||||||
|
|
||||||
const { packageJsonName, keycloakThemeBuildingDirPath } = params;
|
const { themeName, keycloakThemeBuildingDirPath } = params;
|
||||||
|
|
||||||
fs.writeFileSync(
|
fs.writeFileSync(
|
||||||
pathJoin(keycloakThemeBuildingDirPath, "Dockerfile"),
|
pathJoin(keycloakThemeBuildingDirPath, "Dockerfile"),
|
||||||
@ -32,7 +32,7 @@ export function generateDebugFiles(
|
|||||||
)
|
)
|
||||||
);
|
);
|
||||||
|
|
||||||
const dockerImage = `${packageJsonName}/keycloak-hot-reload`;
|
const dockerImage = `${themeName}/keycloak-hot-reload`;
|
||||||
const containerName = "keycloak-testing-container";
|
const containerName = "keycloak-testing-container";
|
||||||
|
|
||||||
fs.writeFileSync(
|
fs.writeFileSync(
|
||||||
@ -52,8 +52,8 @@ export function generateDebugFiles(
|
|||||||
` --name ${containerName} \\`,
|
` --name ${containerName} \\`,
|
||||||
" -e KEYCLOAK_USER=admin \\",
|
" -e KEYCLOAK_USER=admin \\",
|
||||||
" -e KEYCLOAK_PASSWORD=admin \\",
|
" -e KEYCLOAK_PASSWORD=admin \\",
|
||||||
` -v ${pathJoin(keycloakThemeBuildingDirPath, "src", "main", "resources", "theme", packageJsonName)
|
` -v ${pathJoin(keycloakThemeBuildingDirPath, "src", "main", "resources", "theme", themeName)
|
||||||
}:/opt/jboss/keycloak/themes/${packageJsonName}:rw \\`,
|
}:/opt/jboss/keycloak/themes/${themeName}:rw \\`,
|
||||||
` -it ${dockerImage}:latest`,
|
` -it ${dockerImage}:latest`,
|
||||||
""
|
""
|
||||||
].join("\n"),
|
].join("\n"),
|
||||||
|
@ -3,21 +3,20 @@ import * as url from "url";
|
|||||||
import * as fs from "fs";
|
import * as fs from "fs";
|
||||||
import { join as pathJoin, dirname as pathDirname } from "path";
|
import { join as pathJoin, dirname as pathDirname } from "path";
|
||||||
|
|
||||||
export type ParsedPackageJson = {
|
|
||||||
name: string;
|
|
||||||
version: string;
|
|
||||||
homepage?: string;
|
|
||||||
};
|
|
||||||
|
|
||||||
export function generateJavaStackFiles(
|
export function generateJavaStackFiles(
|
||||||
params: {
|
params: {
|
||||||
parsedPackageJson: ParsedPackageJson;
|
version: string;
|
||||||
|
themeName: string;
|
||||||
|
homepage?: string;
|
||||||
keycloakThemeBuildingDirPath: string;
|
keycloakThemeBuildingDirPath: string;
|
||||||
}
|
}
|
||||||
): { jarFilePath: string; } {
|
): { jarFilePath: string; } {
|
||||||
|
|
||||||
const {
|
const {
|
||||||
parsedPackageJson: { name, version, homepage },
|
themeName,
|
||||||
|
version,
|
||||||
|
homepage,
|
||||||
keycloakThemeBuildingDirPath
|
keycloakThemeBuildingDirPath
|
||||||
} = params;
|
} = params;
|
||||||
|
|
||||||
@ -28,7 +27,7 @@ export function generateJavaStackFiles(
|
|||||||
|
|
||||||
const groupId = (() => {
|
const groupId = (() => {
|
||||||
|
|
||||||
const fallbackGroupId = `there.was.no.homepage.field.in.the.package.json.${name}`;
|
const fallbackGroupId = `there.was.no.homepage.field.in.the.package.json.${themeName}`;
|
||||||
|
|
||||||
return (!homepage ?
|
return (!homepage ?
|
||||||
fallbackGroupId :
|
fallbackGroupId :
|
||||||
@ -37,7 +36,7 @@ export function generateJavaStackFiles(
|
|||||||
|
|
||||||
})();
|
})();
|
||||||
|
|
||||||
const artefactId = `${name}-keycloak-theme`;
|
const artefactId = `${themeName}-keycloak-theme`;
|
||||||
|
|
||||||
const pomFileCode = [
|
const pomFileCode = [
|
||||||
`<?xml version="1.0"?>`,
|
`<?xml version="1.0"?>`,
|
||||||
@ -83,7 +82,7 @@ export function generateJavaStackFiles(
|
|||||||
JSON.stringify({
|
JSON.stringify({
|
||||||
"themes": [
|
"themes": [
|
||||||
{
|
{
|
||||||
"name": name,
|
"name": themeName,
|
||||||
"types": ["login"]
|
"types": ["login"]
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
@ -94,7 +93,7 @@ export function generateJavaStackFiles(
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return { "jarFilePath": pathJoin(keycloakThemeBuildingDirPath, "target", `${name}-${version}.jar`) };
|
return { "jarFilePath": pathJoin(keycloakThemeBuildingDirPath, "target", `${themeName}-${version}.jar`) };
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user