diff --git a/README.md b/README.md
index 43bce86b..ecc3b323 100644
--- a/README.md
+++ b/README.md
@@ -49,6 +49,12 @@
# Changelog highlights
+## 6.11.0
+
+- You no longer need to have Maven installed to build the theme. Thanks to @lordvlad, [see PR](https://github.com/InseeFrLab/keycloakify/pull/239).
+- Feature new build options: [`bundler`](https://docs.keycloakify.dev/build-options#keycloakify.bundler), [`groupId`](https://docs.keycloakify.dev/build-options#keycloakify.groupid), [`artifactId`](https://docs.keycloakify.dev/build-options#keycloakify.artifactid), [`version`](https://docs.keycloakify.dev/build-options#version).
+ Theses options can be user to customize the output name of the .jar. You can use environnement variables to overrides the values read in the package.json. Thanks to @lordvlad.
+
## 6.10.0
- Widows compat (thanks to @lordvlad, [see PR](https://github.com/InseeFrLab/keycloakify/pull/226)). WSL is no longer required 🎉
diff --git a/package.json b/package.json
index 7f308a92..bcf3d7ab 100644
--- a/package.json
+++ b/package.json
@@ -1,6 +1,6 @@
{
"name": "keycloakify",
- "version": "6.10.1",
+ "version": "6.11.2",
"description": "Keycloak theme generator for Reacts app",
"repository": {
"type": "git",
diff --git a/src/bin/keycloakify/BuildOptions.ts b/src/bin/keycloakify/BuildOptions.ts
index 1351304a..fac35dcf 100644
--- a/src/bin/keycloakify/BuildOptions.ts
+++ b/src/bin/keycloakify/BuildOptions.ts
@@ -3,9 +3,11 @@ import { assert } from "tsafe/assert";
import type { Equals } from "tsafe";
import { id } from "tsafe/id";
import { parse as urlParse } from "url";
+import { typeGuard } from "tsafe/typeGuard";
+import { symToStr } from "tsafe/symToStr";
-const BUNDLERS = ["mvn", "keycloakify", "none"] as const;
-type Bundler = typeof BUNDLERS[number];
+const bundlers = ["mvn", "keycloakify", "none"] as const;
+type Bundler = typeof bundlers[number];
type ParsedPackageJson = {
name: string;
version: string;
@@ -31,7 +33,7 @@ const zParsedPackageJson = z.object({
"areAppAndKeycloakServerSharingSameDomain": z.boolean().optional(),
"artifactId": z.string().optional(),
"groupId": z.string().optional(),
- "bundler": z.enum(BUNDLERS).optional()
+ "bundler": z.enum(bundlers).optional()
})
.optional()
});
@@ -49,8 +51,8 @@ export namespace BuildOptions {
extraPages?: string[];
extraThemeProperties?: string[];
groupId: string;
- artifactId?: string;
- bundler?: Bundler;
+ artifactId: string;
+ bundler: Bundler;
};
export type Standalone = Common & {
@@ -126,8 +128,20 @@ export function readBuildOptions(params: {
return {
themeName,
- "bundler": (process.env.KEYCLOAKIFY_BUNDLER ?? bundler) as Bundler | undefined,
- "artifactId": process.env.KEYCLOAKIFY_ARTIFACT_ID ?? artifactId,
+ "bundler": (() => {
+ const { KEYCLOAKIFY_BUNDLER } = process.env;
+
+ assert(
+ typeGuard(
+ KEYCLOAKIFY_BUNDLER,
+ [undefined, ...id(bundlers)].includes(KEYCLOAKIFY_BUNDLER)
+ ),
+ `${symToStr({ KEYCLOAKIFY_BUNDLER })} should be one of ${bundlers.join(", ")}`
+ );
+
+ return KEYCLOAKIFY_BUNDLER ?? bundler ?? "mvn";
+ })(),
+ "artifactId": process.env.KEYCLOAKIFY_ARTIFACT_ID ?? artifactId ?? `${themeName}-keycloak-theme`,
"groupId": (() => {
const fallbackGroupId = `${themeName}.keycloak`;
@@ -143,7 +157,7 @@ export function readBuildOptions(params: {
.join(".") ?? fallbackGroupId) + ".keycloak"
);
})(),
- "version": process.env.KEYCLOAKFIY_VERSION ?? version,
+ "version": process.env.KEYCLOAKIFY_VERSION ?? version,
extraPages,
extraThemeProperties,
isSilent
diff --git a/src/bin/keycloakify/generateJavaStackFiles.ts b/src/bin/keycloakify/generateJavaStackFiles.ts
index c7f4ccf2..7e20ef45 100644
--- a/src/bin/keycloakify/generateJavaStackFiles.ts
+++ b/src/bin/keycloakify/generateJavaStackFiles.ts
@@ -30,8 +30,6 @@ export function generateJavaStackFiles(params: {
doBundlesEmailTemplate
} = params;
- const finalArtifactId = artifactId ?? `${themeName}-keycloak-theme`;
-
{
const { pomFileCode } = (function generatePomFileCode(): {
pomFileCode: string;
@@ -43,9 +41,9 @@ export function generateJavaStackFiles(params: {
` xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">`,
` 4.0.0`,
` ${groupId}`,
- ` ${finalArtifactId}`,
+ ` ${artifactId}`,
` ${version}`,
- ` ${finalArtifactId}`,
+ ` ${artifactId}`,
` `,
``
].join("\n");
@@ -84,6 +82,6 @@ export function generateJavaStackFiles(params: {
}
return {
- "jarFilePath": pathJoin(keycloakThemeBuildingDirPath, "target", `${finalArtifactId}-${version}.jar`)
+ "jarFilePath": pathJoin(keycloakThemeBuildingDirPath, "target", `${artifactId}-${version}.jar`)
};
}
diff --git a/src/bin/keycloakify/keycloakify.ts b/src/bin/keycloakify/keycloakify.ts
index 2aa36d7d..5bb8f74a 100644
--- a/src/bin/keycloakify/keycloakify.ts
+++ b/src/bin/keycloakify/keycloakify.ts
@@ -8,6 +8,8 @@ import { readBuildOptions } from "./BuildOptions";
import { getLogger } from "../tools/logger";
import { getCliOptions } from "../tools/cliOptions";
import jar from "../tools/jar";
+import { assert } from "tsafe/assert";
+import type { Equals } from "tsafe";
const reactProjectDirPath = process.cwd();
@@ -51,22 +53,26 @@ export async function main() {
buildOptions
});
- if (buildOptions.bundler === "none") {
- logger.log("😱 Skipping bundling step, there will be no jar");
- } else if (buildOptions.bundler === "keycloakify") {
- logger.log("🫶 Let keycloakify do its thang");
- await jar({
- "rootPath": pathJoin(keycloakThemeBuildingDirPath, "src", "main", "resources"),
- "version": buildOptions.version,
- "groupId": buildOptions.groupId,
- "artifactId": buildOptions.artifactId || `${buildOptions.themeName}-keycloak-theme`,
- "targetPath": jarFilePath
- });
- } else {
- logger.log("🫙 Run maven to deliver a jar");
- child_process.execSync("mvn package", {
- "cwd": keycloakThemeBuildingDirPath
- });
+ switch (buildOptions.bundler) {
+ case "none":
+ logger.log("😱 Skipping bundling step, there will be no jar");
+ break;
+ case "keycloakify":
+ logger.log("🫶 Let keycloakify do its thang");
+ await jar({
+ "rootPath": pathJoin(keycloakThemeBuildingDirPath, "src", "main", "resources"),
+ "version": buildOptions.version,
+ "groupId": buildOptions.groupId,
+ "artifactId": buildOptions.artifactId,
+ "targetPath": jarFilePath
+ });
+ break;
+ case "mvn":
+ logger.log("🫙 Run maven to deliver a jar");
+ child_process.execSync("mvn package", { "cwd": keycloakThemeBuildingDirPath });
+ break;
+ default:
+ assert>(false);
}
// We want, however, to test in a container running the latest Keycloak version
diff --git a/src/bin/tools/grant-exec-perms.ts b/src/bin/tools/grant-exec-perms.ts
index dab91c6b..315f39bb 100644
--- a/src/bin/tools/grant-exec-perms.ts
+++ b/src/bin/tools/grant-exec-perms.ts
@@ -3,10 +3,10 @@ import { join as pathJoin } from "path";
import { constants } from "fs";
import { chmod, stat } from "fs/promises";
-async () => {
- var { bin } = await import(pathJoin(getProjectRoot(), "package.json"));
+(async () => {
+ const { bin } = await import(pathJoin(getProjectRoot(), "package.json"));
- var promises = Object.values(bin).map(async scriptPath => {
+ const promises = Object.values(bin).map(async scriptPath => {
const fullPath = pathJoin(getProjectRoot(), scriptPath);
const oldMode = (await stat(fullPath)).mode;
const newMode = oldMode | constants.S_IXUSR | constants.S_IXGRP | constants.S_IXOTH;
@@ -14,4 +14,4 @@ async () => {
});
await Promise.all(promises);
-};
+})();