From ac05d529cae1b87fad2f20b82f66d85e9460e440 Mon Sep 17 00:00:00 2001 From: garronej Date: Sat, 4 Feb 2023 17:44:02 +0100 Subject: [PATCH 1/8] Minor fixes --- src/bin/keycloakify/BuildOptions.ts | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/src/bin/keycloakify/BuildOptions.ts b/src/bin/keycloakify/BuildOptions.ts index 1351304a..52ddc14c 100644 --- a/src/bin/keycloakify/BuildOptions.ts +++ b/src/bin/keycloakify/BuildOptions.ts @@ -3,6 +3,7 @@ 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"; const BUNDLERS = ["mvn", "keycloakify", "none"] as const; type Bundler = typeof BUNDLERS[number]; @@ -126,7 +127,18 @@ export function readBuildOptions(params: { return { themeName, - "bundler": (process.env.KEYCLOAKIFY_BUNDLER ?? bundler) as Bundler | undefined, + "bundler": (() => { + const { KEYCLOAKIFY_BUNDLER } = process.env; + + assert( + typeGuard( + KEYCLOAKIFY_BUNDLER, + KEYCLOAKIFY_BUNDLER === undefined || id(BUNDLERS).includes(KEYCLOAKIFY_BUNDLER) + ) + ); + + return KEYCLOAKIFY_BUNDLER ?? bundler; + })(), "artifactId": process.env.KEYCLOAKIFY_ARTIFACT_ID ?? artifactId, "groupId": (() => { const fallbackGroupId = `${themeName}.keycloak`; @@ -143,7 +155,7 @@ export function readBuildOptions(params: { .join(".") ?? fallbackGroupId) + ".keycloak" ); })(), - "version": process.env.KEYCLOAKFIY_VERSION ?? version, + "version": process.env.KEYCLOAKIFY_VERSION ?? version, extraPages, extraThemeProperties, isSilent From 4e6a29069364ab7a182eeb6b2eed58f424e032f8 Mon Sep 17 00:00:00 2001 From: garronej Date: Sat, 4 Feb 2023 18:02:39 +0100 Subject: [PATCH 2/8] Make new node based bundler the default --- src/bin/keycloakify/BuildOptions.ts | 16 ++++++------ src/bin/keycloakify/keycloakify.ts | 38 +++++++++++++++++------------ 2 files changed, 31 insertions(+), 23 deletions(-) diff --git a/src/bin/keycloakify/BuildOptions.ts b/src/bin/keycloakify/BuildOptions.ts index 52ddc14c..9c1a72f5 100644 --- a/src/bin/keycloakify/BuildOptions.ts +++ b/src/bin/keycloakify/BuildOptions.ts @@ -4,9 +4,10 @@ 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; @@ -32,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() }); @@ -51,7 +52,7 @@ export namespace BuildOptions { extraThemeProperties?: string[]; groupId: string; artifactId?: string; - bundler?: Bundler; + bundler: Bundler; }; export type Standalone = Common & { @@ -133,11 +134,12 @@ export function readBuildOptions(params: { assert( typeGuard( KEYCLOAKIFY_BUNDLER, - KEYCLOAKIFY_BUNDLER === undefined || id(BUNDLERS).includes(KEYCLOAKIFY_BUNDLER) - ) + [undefined, ...id(bundlers)].includes(KEYCLOAKIFY_BUNDLER) + ), + `${symToStr({ KEYCLOAKIFY_BUNDLER })} should be one of ${bundlers.join(", ")}` ); - return KEYCLOAKIFY_BUNDLER ?? bundler; + return KEYCLOAKIFY_BUNDLER ?? bundler ?? "keycloakify"; })(), "artifactId": process.env.KEYCLOAKIFY_ARTIFACT_ID ?? artifactId, "groupId": (() => { diff --git a/src/bin/keycloakify/keycloakify.ts b/src/bin/keycloakify/keycloakify.ts index 2f3f1d77..119e9c2d 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": keycloakThemeBuildingDirPath, - "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": keycloakThemeBuildingDirPath, + "version": buildOptions.version, + "groupId": buildOptions.groupId, + "artifactId": buildOptions.artifactId || `${buildOptions.themeName}-keycloak-theme`, + "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 From 243fbd4dc997664c50a380a6d84fe3a90d91bb21 Mon Sep 17 00:00:00 2001 From: garronej Date: Sat, 4 Feb 2023 19:36:42 +0100 Subject: [PATCH 3/8] Set the artifactId name in the build option --- src/bin/keycloakify/BuildOptions.ts | 4 ++-- src/bin/keycloakify/generateJavaStackFiles.ts | 8 +++----- 2 files changed, 5 insertions(+), 7 deletions(-) diff --git a/src/bin/keycloakify/BuildOptions.ts b/src/bin/keycloakify/BuildOptions.ts index 9c1a72f5..91eafec6 100644 --- a/src/bin/keycloakify/BuildOptions.ts +++ b/src/bin/keycloakify/BuildOptions.ts @@ -51,7 +51,7 @@ export namespace BuildOptions { extraPages?: string[]; extraThemeProperties?: string[]; groupId: string; - artifactId?: string; + artifactId: string; bundler: Bundler; }; @@ -141,7 +141,7 @@ export function readBuildOptions(params: { return KEYCLOAKIFY_BUNDLER ?? bundler ?? "keycloakify"; })(), - "artifactId": process.env.KEYCLOAKIFY_ARTIFACT_ID ?? artifactId, + "artifactId": process.env.KEYCLOAKIFY_ARTIFACT_ID ?? artifactId ?? `${themeName}-keycloak-theme`, "groupId": (() => { const fallbackGroupId = `${themeName}.keycloak`; 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`) }; } From a463878bf26b96869a6a760191bfb3a825a0bfd7 Mon Sep 17 00:00:00 2001 From: garronej Date: Sat, 4 Feb 2023 20:22:45 +0100 Subject: [PATCH 4/8] Bump version --- README.md | 6 ++++++ package.json | 2 +- 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 43bce86b..788672a9 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..a86a40a4 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "keycloakify", - "version": "6.10.1", + "version": "6.11.0", "description": "Keycloak theme generator for Reacts app", "repository": { "type": "git", From 64ab400af53aee4e594913a632a40b52ad481fd4 Mon Sep 17 00:00:00 2001 From: garronej Date: Sat, 4 Feb 2023 20:38:50 +0100 Subject: [PATCH 5/8] Temporarly restore mvn as default bundler --- src/bin/keycloakify/BuildOptions.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/bin/keycloakify/BuildOptions.ts b/src/bin/keycloakify/BuildOptions.ts index 91eafec6..fac35dcf 100644 --- a/src/bin/keycloakify/BuildOptions.ts +++ b/src/bin/keycloakify/BuildOptions.ts @@ -139,7 +139,7 @@ export function readBuildOptions(params: { `${symToStr({ KEYCLOAKIFY_BUNDLER })} should be one of ${bundlers.join(", ")}` ); - return KEYCLOAKIFY_BUNDLER ?? bundler ?? "keycloakify"; + return KEYCLOAKIFY_BUNDLER ?? bundler ?? "mvn"; })(), "artifactId": process.env.KEYCLOAKIFY_ARTIFACT_ID ?? artifactId ?? `${themeName}-keycloak-theme`, "groupId": (() => { From a787215c95070e7c1479920488060318dca79493 Mon Sep 17 00:00:00 2001 From: garronej Date: Sat, 4 Feb 2023 20:39:38 +0100 Subject: [PATCH 6/8] Bump version --- README.md | 2 +- package.json | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 788672a9..ecc3b323 100644 --- a/README.md +++ b/README.md @@ -51,7 +51,7 @@ ## 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). +- 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. diff --git a/package.json b/package.json index a86a40a4..30c45b34 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "keycloakify", - "version": "6.11.0", + "version": "6.11.1", "description": "Keycloak theme generator for Reacts app", "repository": { "type": "git", From 1a9f6d10d47ba04b0661e87a163ad6db8a063434 Mon Sep 17 00:00:00 2001 From: garronej Date: Sat, 4 Feb 2023 20:50:53 +0100 Subject: [PATCH 7/8] Actually run the top level await --- src/bin/tools/grant-exec-perms.ts | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) 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); -}; +})(); From 0df661819f93e5da094c1dfcb51f70a3504ba75d Mon Sep 17 00:00:00 2001 From: garronej Date: Sat, 4 Feb 2023 20:51:06 +0100 Subject: [PATCH 8/8] Bump version --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 30c45b34..bcf3d7ab 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "keycloakify", - "version": "6.11.1", + "version": "6.11.2", "description": "Keycloak theme generator for Reacts app", "repository": { "type": "git",