Merge pull request #78 from InseeFrLab/Ann2827/pull

Ann2827/pull
This commit is contained in:
Joseph Garrone 2022-01-20 01:50:37 +01:00 committed by GitHub
commit a12bde4656
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
7 changed files with 36 additions and 12 deletions

View File

@ -32,7 +32,7 @@ jobs:
steps: steps:
- name: Tell if project is using npm or yarn - name: Tell if project is using npm or yarn
id: step1 id: step1
uses: garronej/ts-ci@v1.1.3 uses: garronej/ts-ci@v1.1.6
with: with:
action_name: tell_if_project_uses_npm_or_yarn action_name: tell_if_project_uses_npm_or_yarn
- uses: actions/checkout@v2.3.4 - uses: actions/checkout@v2.3.4
@ -64,7 +64,7 @@ jobs:
is_upgraded_version: ${{ steps.step1.outputs.is_upgraded_version }} is_upgraded_version: ${{ steps.step1.outputs.is_upgraded_version }}
is_release_beta: ${{steps.step1.outputs.is_release_beta }} is_release_beta: ${{steps.step1.outputs.is_release_beta }}
steps: steps:
- uses: garronej/ts-ci@v1.1.3 - uses: garronej/ts-ci@v1.1.6
id: step1 id: step1
with: with:
action_name: is_package_json_version_upgraded action_name: is_package_json_version_upgraded
@ -75,7 +75,7 @@ jobs:
needs: check_if_version_upgraded needs: check_if_version_upgraded
if: needs.check_if_version_upgraded.outputs.is_upgraded_version == 'true' if: needs.check_if_version_upgraded.outputs.is_upgraded_version == 'true'
steps: steps:
- uses: garronej/ts-ci@v1.1.3 - uses: garronej/ts-ci@v1.1.6
with: with:
action_name: update_changelog action_name: update_changelog
branch: ${{ github.head_ref || github.ref }} branch: ${{ github.head_ref || github.ref }}

View File

@ -1,6 +1,6 @@
{ {
"name": "keycloakify", "name": "keycloakify",
"version": "4.5.1", "version": "4.5.2-beta.0",
"description": "Keycloak theme generator for Reacts app", "description": "Keycloak theme generator for Reacts app",
"repository": { "repository": {
"type": "git", "type": "git",

View File

@ -126,6 +126,14 @@ ${ftl_object_to_js_code_declaring_an_object(.data_model, [])?no_esc};
key == "loginAction" && key == "loginAction" &&
are_same_path(path, ["url"]) && are_same_path(path, ["url"]) &&
pageId == "saml-post-form.ftl" pageId == "saml-post-form.ftl"
) || (
["contextData", "idpConfig", "idp", "authenticationSession"]?seq_contains(key) &&
are_same_path(path, ["brokerContext"]) &&
["login-idp-link-confirm.ftl", "login-idp-link-email.ftl" ]?seq_contains(pageId)
) || (
key == "identityProviderBrokerCtx" &&
are_same_path(path, []) &&
["login-idp-link-confirm.ftl", "login-idp-link-email.ftl" ]?seq_contains(pageId)
) )
> >
<#local out_seq += ["/*If you need '" + key + "' on " + pageId + ", please submit an issue to the Keycloakify repo*/"]> <#local out_seq += ["/*If you need '" + key + "' on " + pageId + ", please submit an issue to the Keycloakify repo*/"]>

View File

@ -1,6 +1,6 @@
import { transformCodebase } from "../tools/transformCodebase"; import { transformCodebase } from "../tools/transformCodebase";
import * as fs from "fs"; import * as fs from "fs";
import { join as pathJoin } from "path"; import { join as pathJoin, basename as pathBasename } from "path";
import { replaceImportsInCssCode, replaceImportsFromStaticInJsCode } from "./replaceImportFromStatic"; import { replaceImportsInCssCode, replaceImportsFromStaticInJsCode } from "./replaceImportFromStatic";
import { generateFtlFilesCodeFactory, pageIds } from "./generateFtl"; import { generateFtlFilesCodeFactory, pageIds } from "./generateFtl";
import { downloadBuiltinKeycloakTheme } from "../download-builtin-keycloak-theme"; import { downloadBuiltinKeycloakTheme } from "../download-builtin-keycloak-theme";
@ -112,20 +112,22 @@ export function generateKeycloakThemeResources(params: {
const reactAppPublicDirPath = pathJoin(reactAppBuildDirPath, "..", "public"); const reactAppPublicDirPath = pathJoin(reactAppBuildDirPath, "..", "public");
transformCodebase({ transformCodebase({
"srcDirPath": themeResourcesDirPath, "srcDirPath": pathJoin(tmpDirPath, "keycloak", "common", "resources"),
"destDirPath": pathJoin(reactAppPublicDirPath, resourcesPath), "destDirPath": pathJoin(themeResourcesDirPath, pathBasename(resourcesCommonPath)),
}); });
transformCodebase({ transformCodebase({
"srcDirPath": pathJoin(tmpDirPath, "keycloak", "common", "resources"), "srcDirPath": themeResourcesDirPath,
"destDirPath": pathJoin(reactAppPublicDirPath, resourcesCommonPath), "destDirPath": pathJoin(reactAppPublicDirPath, resourcesPath),
}); });
const keycloakResourcesWithinPublicDirPath = pathJoin(reactAppPublicDirPath, subDirOfPublicDirBasename); const keycloakResourcesWithinPublicDirPath = pathJoin(reactAppPublicDirPath, subDirOfPublicDirBasename);
fs.writeFileSync( fs.writeFileSync(
pathJoin(keycloakResourcesWithinPublicDirPath, "README.txt"), pathJoin(keycloakResourcesWithinPublicDirPath, "README.txt"),
Buffer.from(["This is just a test folder that helps develop", "the login and register page without having to yarn build"].join(" ")), Buffer.from(
["This is just a test folder that helps develop", "the login and register page without having to run a Keycloak container"].join(" "),
),
); );
fs.writeFileSync(pathJoin(keycloakResourcesWithinPublicDirPath, ".gitignore"), Buffer.from("*", "utf8")); fs.writeFileSync(pathJoin(keycloakResourcesWithinPublicDirPath, ".gitignore"), Buffer.from("*", "utf8"));

View File

@ -7,6 +7,9 @@ import { exclude } from "tsafe/exclude";
import { assert } from "tsafe/assert"; import { assert } from "tsafe/assert";
import type { ExtendsKcContextBase } from "./getKcContextFromWindow"; import type { ExtendsKcContextBase } from "./getKcContextFromWindow";
import { getKcContextFromWindow } from "./getKcContextFromWindow"; import { getKcContextFromWindow } from "./getKcContextFromWindow";
import { pathJoin } from "../tools/pathJoin";
import { pathBasename } from "../tools/pathBasename";
import { resourcesCommonPath } from "./kcContextMocks/urlResourcesPath";
export function getKcContext<KcContextExtended extends { pageId: string } = never>(params?: { export function getKcContext<KcContextExtended extends { pageId: string } = never>(params?: {
mockPageId?: ExtendsKcContextBase<KcContextExtended>["pageId"]; mockPageId?: ExtendsKcContextBase<KcContextExtended>["pageId"];
@ -93,5 +96,13 @@ export function getKcContext<KcContextExtended extends { pageId: string } = neve
return { kcContext }; return { kcContext };
} }
return { "kcContext": getKcContextFromWindow<KcContextExtended>() }; const kcContext = getKcContextFromWindow<KcContextExtended>();
if (kcContext !== undefined) {
const { url } = kcContext;
url.resourcesCommonPath = pathJoin(url.resourcesPath, pathBasename(resourcesCommonPath));
}
return { kcContext };
} }

View File

@ -2,4 +2,4 @@ import { pathJoin } from "../../tools/pathJoin";
export const subDirOfPublicDirBasename = "keycloak_static"; export const subDirOfPublicDirBasename = "keycloak_static";
export const resourcesPath = pathJoin(subDirOfPublicDirBasename, "resources"); export const resourcesPath = pathJoin(subDirOfPublicDirBasename, "resources");
export const resourcesCommonPath = pathJoin(subDirOfPublicDirBasename, "resources_common"); export const resourcesCommonPath = pathJoin(resourcesPath, "resources_common");

View File

@ -0,0 +1,3 @@
export function pathBasename(path: string) {
return path.split("/").reverse()[0];
}