Merge branch 'main' of github.com:InseeFrLab/keycloakify
* 'main' of github.com:InseeFrLab/keycloakify: Update CI Bump version #297 Fix type error in useDownloadTerms Refactor Terms.tsx
This commit is contained in:
commit
f58a5ad524
54
.github/workflows/ci.yaml
vendored
54
.github/workflows/ci.yaml
vendored
@ -17,44 +17,32 @@ jobs:
|
|||||||
- uses: actions/setup-node@v3
|
- uses: actions/setup-node@v3
|
||||||
- uses: bahmutov/npm-install@v1
|
- uses: bahmutov/npm-install@v1
|
||||||
- name: If this step fails run 'yarn format' then commit again.
|
- name: If this step fails run 'yarn format' then commit again.
|
||||||
run: |
|
run: yarn format:check
|
||||||
PACKAGE_MANAGER=npm
|
|
||||||
if [ -f "./yarn.lock" ]; then
|
|
||||||
PACKAGE_MANAGER=yarn
|
|
||||||
fi
|
|
||||||
$PACKAGE_MANAGER run format:check
|
|
||||||
test:
|
test:
|
||||||
runs-on: ${{ matrix.os }}
|
runs-on: ${{ matrix.os }}
|
||||||
needs: test_lint
|
needs: test_lint
|
||||||
strategy:
|
strategy:
|
||||||
matrix:
|
matrix:
|
||||||
node: [ '16' ]
|
node: [ '17' ]
|
||||||
os: [ ubuntu-latest ]
|
os: [ ubuntu-latest ]
|
||||||
name: Test with Node v${{ matrix.node }} on ${{ matrix.os }}
|
name: Test with Node v${{ matrix.node }} on ${{ matrix.os }}
|
||||||
steps:
|
steps:
|
||||||
- name: Tell if project is using npm or yarn
|
|
||||||
id: step1
|
|
||||||
uses: garronej/ts-ci@v2.0.2
|
|
||||||
with:
|
|
||||||
action_name: tell_if_project_uses_npm_or_yarn
|
|
||||||
- uses: actions/checkout@v3
|
- uses: actions/checkout@v3
|
||||||
- uses: actions/setup-node@v3
|
- uses: actions/setup-node@v3
|
||||||
with:
|
with:
|
||||||
node-version: ${{ matrix.node }}
|
node-version: ${{ matrix.node }}
|
||||||
- uses: bahmutov/npm-install@v1
|
- uses: bahmutov/npm-install@v1
|
||||||
- if: steps.step1.outputs.npm_or_yarn == 'yarn'
|
- run: yarn build
|
||||||
run: |
|
- run: yarn test
|
||||||
yarn build
|
- run: yarn test:keycloakify-starter
|
||||||
yarn test
|
|
||||||
- if: steps.step1.outputs.npm_or_yarn == 'npm'
|
|
||||||
run: |
|
|
||||||
npm run build
|
|
||||||
npm test
|
|
||||||
check_if_version_upgraded:
|
check_if_version_upgraded:
|
||||||
name: Check if version upgrade
|
name: Check if version upgrade
|
||||||
# We run this only if it's a push on the default branch or if it's a PR from a
|
# When someone forks the repo and opens a PR we want to enables the tests to be run (the previous jobs)
|
||||||
# branch (meaning not a PR from a fork). It would be more straightforward to test if secrets.NPM_TOKEN is
|
# but obviously only us should be allowed to release.
|
||||||
# defined but GitHub Action don't allow it yet.
|
# In the following check we make sure that we own the branch this CI workflow is running on before continuing.
|
||||||
|
# Without this check, trying to release would fail anyway because only us have the correct secret.NPM_TOKEN but
|
||||||
|
# it's cleaner to stop the execution instead of letting the CI crash.
|
||||||
if: |
|
if: |
|
||||||
github.event_name == 'push' ||
|
github.event_name == 'push' ||
|
||||||
github.event.pull_request.head.repo.owner.login == github.event.pull_request.base.repo.owner.login
|
github.event.pull_request.head.repo.owner.login == github.event.pull_request.base.repo.owner.login
|
||||||
@ -66,7 +54,7 @@ jobs:
|
|||||||
is_upgraded_version: ${{ steps.step1.outputs.is_upgraded_version }}
|
is_upgraded_version: ${{ steps.step1.outputs.is_upgraded_version }}
|
||||||
is_pre_release: ${{steps.step1.outputs.is_pre_release }}
|
is_pre_release: ${{steps.step1.outputs.is_pre_release }}
|
||||||
steps:
|
steps:
|
||||||
- uses: garronej/ts-ci@v2.0.2
|
- uses: garronej/ts-ci@v2.1.0
|
||||||
id: step1
|
id: step1
|
||||||
with:
|
with:
|
||||||
action_name: is_package_json_version_upgraded
|
action_name: is_package_json_version_upgraded
|
||||||
@ -74,8 +62,8 @@ jobs:
|
|||||||
|
|
||||||
create_github_release:
|
create_github_release:
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
# We create a release only if the version have been upgraded and we are on the main branch
|
# We create release only if the version in the package.json have been upgraded and this CI is running against the main branch.
|
||||||
# or if we are on a branch of the repo that has an PR open on main.
|
# We allow branches with a PR open on main to publish pre-release (x.y.z-rc.u) but not actual releases.
|
||||||
if: |
|
if: |
|
||||||
needs.check_if_version_upgraded.outputs.is_upgraded_version == 'true' &&
|
needs.check_if_version_upgraded.outputs.is_upgraded_version == 'true' &&
|
||||||
(
|
(
|
||||||
@ -109,15 +97,13 @@ jobs:
|
|||||||
with:
|
with:
|
||||||
registry-url: https://registry.npmjs.org/
|
registry-url: https://registry.npmjs.org/
|
||||||
- uses: bahmutov/npm-install@v1
|
- uses: bahmutov/npm-install@v1
|
||||||
- run: |
|
- run: yarn build
|
||||||
PACKAGE_MANAGER=npm
|
- run: npx -y -p denoify@1.3.0 enable_short_npm_import_path
|
||||||
if [ -f "./yarn.lock" ]; then
|
|
||||||
PACKAGE_MANAGER=yarn
|
|
||||||
fi
|
|
||||||
$PACKAGE_MANAGER run build
|
|
||||||
- run: npx -y -p denoify@1.2.2 enable_short_npm_import_path
|
|
||||||
env:
|
env:
|
||||||
DRY_RUN: "0"
|
DRY_RUN: "0"
|
||||||
|
- uses: garronej/ts-ci@v2.1.0
|
||||||
|
with:
|
||||||
|
action_name: remove_dark_mode_specific_images_from_readme
|
||||||
- name: Publishing on NPM
|
- name: Publishing on NPM
|
||||||
run: |
|
run: |
|
||||||
if [ "$(npm show . version)" = "$VERSION" ]; then
|
if [ "$(npm show . version)" = "$VERSION" ]; then
|
||||||
@ -136,4 +122,4 @@ jobs:
|
|||||||
env:
|
env:
|
||||||
NODE_AUTH_TOKEN: ${{secrets.NPM_TOKEN}}
|
NODE_AUTH_TOKEN: ${{secrets.NPM_TOKEN}}
|
||||||
VERSION: ${{ needs.check_if_version_upgraded.outputs.to_version }}
|
VERSION: ${{ needs.check_if_version_upgraded.outputs.to_version }}
|
||||||
IS_PRE_RELEASE: ${{ needs.check_if_version_upgraded.outputs.is_pre_release }}
|
IS_PRE_RELEASE: ${{ needs.check_if_version_upgraded.outputs.is_pre_release }}
|
@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "keycloakify",
|
"name": "keycloakify",
|
||||||
"version": "7.6.2",
|
"version": "7.6.3",
|
||||||
"description": "Create Keycloak themes using React",
|
"description": "Create Keycloak themes using React",
|
||||||
"repository": {
|
"repository": {
|
||||||
"type": "git",
|
"type": "git",
|
||||||
|
@ -7,6 +7,8 @@ import { pathBasename } from "keycloakify/tools/pathBasename";
|
|||||||
import { mockTestingResourcesCommonPath } from "keycloakify/bin/mockTestingResourcesPath";
|
import { mockTestingResourcesCommonPath } from "keycloakify/bin/mockTestingResourcesPath";
|
||||||
import { symToStr } from "tsafe/symToStr";
|
import { symToStr } from "tsafe/symToStr";
|
||||||
import { kcContextMocks, kcContextCommonMock } from "keycloakify/account/kcContext/kcContextMocks";
|
import { kcContextMocks, kcContextCommonMock } from "keycloakify/account/kcContext/kcContextMocks";
|
||||||
|
import { id } from "tsafe/id";
|
||||||
|
import { accountThemePageIds } from "keycloakify/bin/keycloakify/generateFtl/pageId";
|
||||||
|
|
||||||
export function getKcContext<KcContextExtension extends { pageId: string } = never>(params?: {
|
export function getKcContext<KcContextExtension extends { pageId: string } = never>(params?: {
|
||||||
mockPageId?: ExtendKcContext<KcContextExtension>["pageId"];
|
mockPageId?: ExtendKcContext<KcContextExtension>["pageId"];
|
||||||
@ -62,7 +64,7 @@ export function getKcContext<KcContextExtension extends { pageId: string } = nev
|
|||||||
return { "kcContext": undefined };
|
return { "kcContext": undefined };
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!("account" in realKcContext)) {
|
if (id<readonly string[]>(accountThemePageIds).indexOf(realKcContext.pageId) < 0 && !("account" in realKcContext)) {
|
||||||
return { "kcContext": undefined };
|
return { "kcContext": undefined };
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -9,7 +9,7 @@ import {
|
|||||||
type AccountThemePageId,
|
type AccountThemePageId,
|
||||||
themeTypes,
|
themeTypes,
|
||||||
type ThemeType
|
type ThemeType
|
||||||
} from "./keycloakify/generateFtl/generateFtl";
|
} from "./keycloakify/generateFtl";
|
||||||
import { capitalize } from "tsafe/capitalize";
|
import { capitalize } from "tsafe/capitalize";
|
||||||
import { readFile, writeFile } from "fs/promises";
|
import { readFile, writeFile } from "fs/promises";
|
||||||
import { existsSync } from "fs";
|
import { existsSync } from "fs";
|
||||||
|
@ -13,37 +13,6 @@ export const themeTypes = ["login", "account"] as const;
|
|||||||
|
|
||||||
export type ThemeType = (typeof themeTypes)[number];
|
export type ThemeType = (typeof themeTypes)[number];
|
||||||
|
|
||||||
export const loginThemePageIds = [
|
|
||||||
"login.ftl",
|
|
||||||
"login-username.ftl",
|
|
||||||
"login-password.ftl",
|
|
||||||
"webauthn-authenticate.ftl",
|
|
||||||
"register.ftl",
|
|
||||||
"register-user-profile.ftl",
|
|
||||||
"info.ftl",
|
|
||||||
"error.ftl",
|
|
||||||
"login-reset-password.ftl",
|
|
||||||
"login-verify-email.ftl",
|
|
||||||
"terms.ftl",
|
|
||||||
"login-otp.ftl",
|
|
||||||
"login-update-profile.ftl",
|
|
||||||
"login-update-password.ftl",
|
|
||||||
"login-idp-link-confirm.ftl",
|
|
||||||
"login-idp-link-email.ftl",
|
|
||||||
"login-page-expired.ftl",
|
|
||||||
"login-config-totp.ftl",
|
|
||||||
"logout-confirm.ftl",
|
|
||||||
"update-user-profile.ftl",
|
|
||||||
"idp-review-user-profile.ftl",
|
|
||||||
"update-email.ftl",
|
|
||||||
"select-authenticator.ftl"
|
|
||||||
] as const;
|
|
||||||
|
|
||||||
export const accountThemePageIds = ["password.ftl", "account.ftl"] as const;
|
|
||||||
|
|
||||||
export type LoginThemePageId = (typeof loginThemePageIds)[number];
|
|
||||||
export type AccountThemePageId = (typeof accountThemePageIds)[number];
|
|
||||||
|
|
||||||
export type BuildOptionsLike = BuildOptionsLike.Standalone | BuildOptionsLike.ExternalAssets;
|
export type BuildOptionsLike = BuildOptionsLike.Standalone | BuildOptionsLike.ExternalAssets;
|
||||||
|
|
||||||
export namespace BuildOptionsLike {
|
export namespace BuildOptionsLike {
|
||||||
|
@ -1 +1,2 @@
|
|||||||
export * from "./generateFtl";
|
export * from "./generateFtl";
|
||||||
|
export * from "./pageId";
|
||||||
|
30
src/bin/keycloakify/generateFtl/pageId.ts
Normal file
30
src/bin/keycloakify/generateFtl/pageId.ts
Normal file
@ -0,0 +1,30 @@
|
|||||||
|
export const loginThemePageIds = [
|
||||||
|
"login.ftl",
|
||||||
|
"login-username.ftl",
|
||||||
|
"login-password.ftl",
|
||||||
|
"webauthn-authenticate.ftl",
|
||||||
|
"register.ftl",
|
||||||
|
"register-user-profile.ftl",
|
||||||
|
"info.ftl",
|
||||||
|
"error.ftl",
|
||||||
|
"login-reset-password.ftl",
|
||||||
|
"login-verify-email.ftl",
|
||||||
|
"terms.ftl",
|
||||||
|
"login-otp.ftl",
|
||||||
|
"login-update-profile.ftl",
|
||||||
|
"login-update-password.ftl",
|
||||||
|
"login-idp-link-confirm.ftl",
|
||||||
|
"login-idp-link-email.ftl",
|
||||||
|
"login-page-expired.ftl",
|
||||||
|
"login-config-totp.ftl",
|
||||||
|
"logout-confirm.ftl",
|
||||||
|
"update-user-profile.ftl",
|
||||||
|
"idp-review-user-profile.ftl",
|
||||||
|
"update-email.ftl",
|
||||||
|
"select-authenticator.ftl"
|
||||||
|
] as const;
|
||||||
|
|
||||||
|
export const accountThemePageIds = ["password.ftl", "account.ftl"] as const;
|
||||||
|
|
||||||
|
export type LoginThemePageId = (typeof loginThemePageIds)[number];
|
||||||
|
export type AccountThemePageId = (typeof accountThemePageIds)[number];
|
@ -11,6 +11,7 @@ import { pathJoin } from "keycloakify/bin/tools/pathJoin";
|
|||||||
import { pathBasename } from "keycloakify/tools/pathBasename";
|
import { pathBasename } from "keycloakify/tools/pathBasename";
|
||||||
import { mockTestingResourcesCommonPath } from "keycloakify/bin/mockTestingResourcesPath";
|
import { mockTestingResourcesCommonPath } from "keycloakify/bin/mockTestingResourcesPath";
|
||||||
import { symToStr } from "tsafe/symToStr";
|
import { symToStr } from "tsafe/symToStr";
|
||||||
|
import { loginThemePageIds } from "keycloakify/bin/keycloakify/generateFtl/pageId";
|
||||||
|
|
||||||
export function getKcContext<KcContextExtension extends { pageId: string } = never>(params?: {
|
export function getKcContext<KcContextExtension extends { pageId: string } = never>(params?: {
|
||||||
mockPageId?: ExtendKcContext<KcContextExtension>["pageId"];
|
mockPageId?: ExtendKcContext<KcContextExtension>["pageId"];
|
||||||
@ -121,7 +122,7 @@ export function getKcContext<KcContextExtension extends { pageId: string } = nev
|
|||||||
return { "kcContext": undefined };
|
return { "kcContext": undefined };
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!("login" in realKcContext)) {
|
if (id<readonly string[]>(loginThemePageIds).indexOf(realKcContext.pageId) < 0 && !("login" in realKcContext)) {
|
||||||
return { "kcContext": undefined };
|
return { "kcContext": undefined };
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -10,7 +10,7 @@ import { KcContext } from "../kcContext";
|
|||||||
export const evtTermMarkdown = Evt.create<string | undefined>(undefined);
|
export const evtTermMarkdown = Evt.create<string | undefined>(undefined);
|
||||||
|
|
||||||
export type KcContextLike = {
|
export type KcContextLike = {
|
||||||
pageId: KcContext["pageId"];
|
pageId: string;
|
||||||
locale?: {
|
locale?: {
|
||||||
currentLanguageTag: string;
|
currentLanguageTag: string;
|
||||||
};
|
};
|
||||||
|
@ -21,13 +21,17 @@ export default function Terms(props: PageProps<Extract<KcContext, { pageId: "ter
|
|||||||
|
|
||||||
const { url } = kcContext;
|
const { url } = kcContext;
|
||||||
|
|
||||||
if (evtTermMarkdown.state === undefined) {
|
const termMarkdown = evtTermMarkdown.state;
|
||||||
|
|
||||||
|
if (termMarkdown === undefined) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Template {...{ kcContext, i18n, doUseDefaultCss, classes }} displayMessage={false} headerNode={msg("termsTitle")}>
|
<Template {...{ kcContext, i18n, doUseDefaultCss, classes }} displayMessage={false} headerNode={msg("termsTitle")}>
|
||||||
<div id="kc-terms-text">{evtTermMarkdown.state && <Markdown>{evtTermMarkdown.state}</Markdown>}</div>
|
<div id="kc-terms-text">
|
||||||
|
<Markdown>{termMarkdown}</Markdown>
|
||||||
|
</div>
|
||||||
<form className="form-actions" action={url.loginAction} method="POST">
|
<form className="form-actions" action={url.loginAction} method="POST">
|
||||||
<input
|
<input
|
||||||
className={clsx(
|
className={clsx(
|
||||||
|
Loading…
x
Reference in New Issue
Block a user