keycloakify 9.4.0-rc.1 → 9.4.0-rc.11
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/PUBLIC_URL.d.ts +5 -0
- package/PUBLIC_URL.js +15 -0
- package/PUBLIC_URL.js.map +1 -0
- package/account/kcContext/createGetKcContext.js +7 -4
- package/account/kcContext/createGetKcContext.js.map +1 -1
- package/account/kcContext/kcContextMocks.js +3 -5
- package/account/kcContext/kcContextMocks.js.map +1 -1
- package/bin/constants.d.ts +1 -1
- package/bin/constants.js +1 -1
- package/bin/constants.js.map +1 -1
- package/bin/copy-keycloak-resources-to-public.d.ts +12 -1
- package/bin/copy-keycloak-resources-to-public.js +133 -70
- package/bin/copy-keycloak-resources-to-public.js.map +1 -1
- package/bin/download-builtin-keycloak-theme.d.ts +1 -0
- package/bin/download-builtin-keycloak-theme.js +37 -27
- package/bin/download-builtin-keycloak-theme.js.map +1 -1
- package/bin/{tools/downloadAndUnzip.d.ts → downloadAndUnzip.d.ts} +6 -6
- package/bin/downloadAndUnzip.js +255 -0
- package/bin/downloadAndUnzip.js.map +1 -0
- package/bin/eject-keycloak-page.js +6 -3
- package/bin/eject-keycloak-page.js.map +1 -1
- package/bin/initialize-email-theme.js +2 -4
- package/bin/initialize-email-theme.js.map +1 -1
- package/bin/keycloakify/buildOptions/buildOptions.d.ts +1 -1
- package/bin/keycloakify/buildOptions/buildOptions.js +56 -32
- package/bin/keycloakify/buildOptions/buildOptions.js.map +1 -1
- package/bin/keycloakify/buildOptions/getCacheDirPath.d.ts +5 -0
- package/bin/keycloakify/buildOptions/getCacheDirPath.js +22 -0
- package/bin/keycloakify/buildOptions/getCacheDirPath.js.map +1 -0
- package/bin/keycloakify/buildOptions/getNpmWorkspaceRootDirPath.d.ts +5 -0
- package/bin/keycloakify/buildOptions/getNpmWorkspaceRootDirPath.js +86 -0
- package/bin/keycloakify/buildOptions/getNpmWorkspaceRootDirPath.js.map +1 -0
- package/bin/keycloakify/buildOptions/getReactAppRootDirPath.d.ts +5 -0
- package/bin/keycloakify/buildOptions/getReactAppRootDirPath.js +26 -0
- package/bin/keycloakify/buildOptions/getReactAppRootDirPath.js.map +1 -0
- package/bin/keycloakify/buildOptions/resolvedViteConfig.d.ts +3 -4
- package/bin/keycloakify/buildOptions/resolvedViteConfig.js +4 -11
- package/bin/keycloakify/buildOptions/resolvedViteConfig.js.map +1 -1
- package/bin/keycloakify/generateFtl/ftl_object_to_js_code_declaring_an_object.ftl +8 -0
- package/bin/keycloakify/generateFtl/generateFtl.js +2 -1
- package/bin/keycloakify/generateFtl/generateFtl.js.map +1 -1
- package/bin/keycloakify/generateStartKeycloakTestingContainer.js +0 -1
- package/bin/keycloakify/generateStartKeycloakTestingContainer.js.map +1 -1
- package/bin/keycloakify/generateTheme/bringInAccountV1.d.ts +1 -0
- package/bin/keycloakify/generateTheme/bringInAccountV1.js.map +1 -1
- package/bin/keycloakify/generateTheme/downloadKeycloakStaticResources.d.ts +1 -0
- package/bin/keycloakify/generateTheme/downloadKeycloakStaticResources.js.map +1 -1
- package/bin/keycloakify/generateTheme/generateTheme.d.ts +1 -0
- package/bin/keycloakify/generateTheme/generateTheme.js.map +1 -1
- package/bin/keycloakify/keycloakify.js +11 -16
- package/bin/keycloakify/keycloakify.js.map +1 -1
- package/bin/keycloakify/replacers/replaceImportsInJsCode/webpack.js +0 -5
- package/bin/keycloakify/replacers/replaceImportsInJsCode/webpack.js.map +1 -1
- package/bin/tools/fetchProxyOptions.d.ts +5 -0
- package/bin/tools/fetchProxyOptions.js +172 -0
- package/bin/tools/fetchProxyOptions.js.map +1 -0
- package/bin/tools/fs.existsAsync.d.ts +1 -0
- package/bin/tools/fs.existsAsync.js +86 -0
- package/bin/tools/fs.existsAsync.js.map +1 -0
- package/bin/tools/getThisCodebaseRootDirPath.d.ts +1 -0
- package/bin/tools/{getProjectRoot.js → getThisCodebaseRootDirPath.js} +7 -7
- package/bin/tools/getThisCodebaseRootDirPath.js.map +1 -0
- package/bin/tools/grant-exec-perms.js +6 -4
- package/bin/tools/grant-exec-perms.js.map +1 -1
- package/bin/tools/readThisNpmProjectVersion.d.ts +1 -0
- package/bin/tools/readThisNpmProjectVersion.js +37 -0
- package/bin/tools/readThisNpmProjectVersion.js.map +1 -0
- package/bin/tools/transformCodebase.js +5 -5
- package/bin/tools/transformCodebase.js.map +1 -1
- package/lib/BASE_URL.d.ts +10 -0
- package/lib/BASE_URL.js +38 -0
- package/lib/BASE_URL.js.map +1 -0
- package/lib/isStorybook.d.ts +1 -0
- package/lib/isStorybook.js +3 -0
- package/lib/isStorybook.js.map +1 -0
- package/lib/keycloakJsAdapter.d.ts +4 -0
- package/lib/keycloakJsAdapter.js +4 -0
- package/lib/keycloakJsAdapter.js.map +1 -1
- package/login/kcContext/createGetKcContext.js +7 -4
- package/login/kcContext/createGetKcContext.js.map +1 -1
- package/login/kcContext/kcContextMocks.js +3 -5
- package/login/kcContext/kcContextMocks.js.map +1 -1
- package/package.json +56 -23
- package/src/PUBLIC_URL.ts +21 -0
- package/src/account/kcContext/createGetKcContext.ts +8 -5
- package/src/account/kcContext/kcContextMocks.ts +3 -5
- package/src/bin/constants.ts +1 -1
- package/src/bin/copy-keycloak-resources-to-public.ts +73 -12
- package/src/bin/download-builtin-keycloak-theme.ts +40 -27
- package/src/bin/downloadAndUnzip.ts +203 -0
- package/src/bin/eject-keycloak-page.ts +6 -3
- package/src/bin/initialize-email-theme.ts +1 -4
- package/src/bin/keycloakify/buildOptions/buildOptions.ts +35 -35
- package/src/bin/keycloakify/buildOptions/getCacheDirPath.ts +25 -0
- package/src/bin/keycloakify/buildOptions/getNpmWorkspaceRootDirPath.ts +49 -0
- package/src/bin/keycloakify/buildOptions/getReactAppRootDirPath.ts +23 -0
- package/src/bin/keycloakify/buildOptions/resolvedViteConfig.ts +7 -21
- package/src/bin/keycloakify/generateFtl/ftl_object_to_js_code_declaring_an_object.ftl +8 -0
- package/src/bin/keycloakify/generateFtl/generateFtl.ts +3 -2
- package/src/bin/keycloakify/generateStartKeycloakTestingContainer.ts +0 -1
- package/src/bin/keycloakify/generateTheme/bringInAccountV1.ts +1 -0
- package/src/bin/keycloakify/generateTheme/downloadKeycloakStaticResources.ts +1 -0
- package/src/bin/keycloakify/generateTheme/generateTheme.ts +1 -0
- package/src/bin/keycloakify/keycloakify.ts +13 -19
- package/src/bin/keycloakify/replacers/replaceImportsInJsCode/webpack.ts +0 -14
- package/src/bin/tools/fetchProxyOptions.ts +73 -0
- package/src/bin/tools/fs.existsAsync.ts +11 -0
- package/src/bin/tools/{getProjectRoot.ts → getThisCodebaseRootDirPath.ts} +4 -4
- package/src/bin/tools/grant-exec-perms.ts +5 -3
- package/src/bin/tools/readThisNpmProjectVersion.ts +12 -0
- package/src/bin/tools/transformCodebase.ts +6 -5
- package/src/lib/BASE_URL.ts +44 -0
- package/src/lib/isStorybook.ts +3 -0
- package/src/lib/keycloakJsAdapter.ts +4 -0
- package/src/login/kcContext/createGetKcContext.ts +8 -5
- package/src/login/kcContext/kcContextMocks.ts +3 -5
- package/src/vite-plugin/vite-plugin.ts +12 -11
- package/vite-plugin/tsconfig.tsbuildinfo +1 -1
- package/vite-plugin/vite-plugin.js +11 -11
- package/vite-plugin/vite-plugin.js.map +1 -1
- package/bin/keycloakify/buildOptions/getKeycloakifyBuildDirPath.d.ts +0 -7
- package/bin/keycloakify/buildOptions/getKeycloakifyBuildDirPath.js +0 -27
- package/bin/keycloakify/buildOptions/getKeycloakifyBuildDirPath.js.map +0 -1
- package/bin/tools/downloadAndUnzip.js +0 -445
- package/bin/tools/downloadAndUnzip.js.map +0 -1
- package/bin/tools/getProjectRoot.d.ts +0 -1
- package/bin/tools/getProjectRoot.js.map +0 -1
- package/bin/tools/pathJoin.d.ts +0 -1
- package/bin/tools/pathJoin.js +0 -15
- package/bin/tools/pathJoin.js.map +0 -1
- package/src/bin/keycloakify/buildOptions/getKeycloakifyBuildDirPath.ts +0 -33
- package/src/bin/tools/downloadAndUnzip.ts +0 -301
- package/src/bin/tools/pathJoin.ts +0 -6
- package/src/vite-plugin/config.json +0 -232
@@ -29,20 +29,6 @@ export function replaceImportsInJsCode_webpack(params: { jsCode: string; buildOp
|
|
29
29
|
);
|
30
30
|
}
|
31
31
|
|
32
|
-
// d={NODE_ENV:"production",PUBLIC_URL:"/foo-bar",WDS_SOCKET_HOST
|
33
|
-
// d={NODE_ENV:"production",PUBLIC_URL:"",WDS_SOCKET_HOST
|
34
|
-
// ->
|
35
|
-
// ... PUBLIC_URL:window.kcContext.url.resourcesPath+"/build" ...
|
36
|
-
fixedJsCode = fixedJsCode.replace(
|
37
|
-
new RegExp(
|
38
|
-
`NODE_ENV:"production",PUBLIC_URL:"${
|
39
|
-
buildOptions.urlPathname !== undefined ? replaceAll(buildOptions.urlPathname.slice(0, -1), "/", "\\/") : ""
|
40
|
-
}"`,
|
41
|
-
"g"
|
42
|
-
),
|
43
|
-
`NODE_ENV:"production",PUBLIC_URL:window.${nameOfTheGlobal}.url.resourcesPath+"/${basenameOfTheKeycloakifyResourcesDir}"`
|
44
|
-
);
|
45
|
-
|
46
32
|
// Example: "static/ or "foo/bar/"
|
47
33
|
const staticDir = (() => {
|
48
34
|
let out = pathRelative(buildOptions.reactAppBuildDirPath, buildOptions.assetsDirPath);
|
@@ -0,0 +1,73 @@
|
|
1
|
+
import { exec as execCallback } from "child_process";
|
2
|
+
import { readFile } from "fs/promises";
|
3
|
+
import { type FetchOptions } from "make-fetch-happen";
|
4
|
+
import { promisify } from "util";
|
5
|
+
|
6
|
+
function ensureArray<T>(arg0: T | T[]) {
|
7
|
+
return Array.isArray(arg0) ? arg0 : typeof arg0 === "undefined" ? [] : [arg0];
|
8
|
+
}
|
9
|
+
|
10
|
+
function ensureSingleOrNone<T>(arg0: T | T[]) {
|
11
|
+
if (!Array.isArray(arg0)) return arg0;
|
12
|
+
if (arg0.length === 0) return undefined;
|
13
|
+
if (arg0.length === 1) return arg0[0];
|
14
|
+
throw new Error("Illegal configuration, expected a single value but found multiple: " + arg0.map(String).join(", "));
|
15
|
+
}
|
16
|
+
|
17
|
+
type NPMConfig = Record<string, string | string[]>;
|
18
|
+
|
19
|
+
/**
|
20
|
+
* Get npm configuration as map
|
21
|
+
*/
|
22
|
+
async function getNmpConfig(params: { npmWorkspaceRootDirPath: string }) {
|
23
|
+
const { npmWorkspaceRootDirPath } = params;
|
24
|
+
|
25
|
+
const exec = promisify(execCallback);
|
26
|
+
|
27
|
+
const stdout = await exec("npm config get", { "encoding": "utf8", "cwd": npmWorkspaceRootDirPath }).then(({ stdout }) => stdout);
|
28
|
+
|
29
|
+
const npmConfigReducer = (cfg: NPMConfig, [key, value]: [string, string]) =>
|
30
|
+
key in cfg ? { ...cfg, [key]: [...ensureArray(cfg[key]), value] } : { ...cfg, [key]: value };
|
31
|
+
|
32
|
+
return stdout
|
33
|
+
.split("\n")
|
34
|
+
.filter(line => !line.startsWith(";"))
|
35
|
+
.map(line => line.trim())
|
36
|
+
.map(line => line.split("=", 2) as [string, string])
|
37
|
+
.reduce(npmConfigReducer, {} as NPMConfig);
|
38
|
+
}
|
39
|
+
|
40
|
+
export type ProxyFetchOptions = Pick<FetchOptions, "proxy" | "noProxy" | "strictSSL" | "cert" | "ca">;
|
41
|
+
|
42
|
+
export async function getProxyFetchOptions(params: { npmWorkspaceRootDirPath: string }): Promise<ProxyFetchOptions> {
|
43
|
+
const { npmWorkspaceRootDirPath } = params;
|
44
|
+
|
45
|
+
const cfg = await getNmpConfig({ npmWorkspaceRootDirPath });
|
46
|
+
|
47
|
+
const proxy = ensureSingleOrNone(cfg["https-proxy"] ?? cfg["proxy"]);
|
48
|
+
const noProxy = cfg["noproxy"] ?? cfg["no-proxy"];
|
49
|
+
|
50
|
+
function maybeBoolean(arg0: string | undefined) {
|
51
|
+
return typeof arg0 === "undefined" ? undefined : Boolean(arg0);
|
52
|
+
}
|
53
|
+
|
54
|
+
const strictSSL = maybeBoolean(ensureSingleOrNone(cfg["strict-ssl"]));
|
55
|
+
const cert = cfg["cert"];
|
56
|
+
const ca = ensureArray(cfg["ca"] ?? cfg["ca[]"]);
|
57
|
+
const cafile = ensureSingleOrNone(cfg["cafile"]);
|
58
|
+
|
59
|
+
if (typeof cafile !== "undefined" && cafile !== "null") {
|
60
|
+
ca.push(
|
61
|
+
...(await (async () => {
|
62
|
+
function chunks<T>(arr: T[], size: number = 2) {
|
63
|
+
return arr.map((_, i) => i % size == 0 && arr.slice(i, i + size)).filter(Boolean) as T[][];
|
64
|
+
}
|
65
|
+
|
66
|
+
const cafileContent = await readFile(cafile, "utf-8");
|
67
|
+
return chunks(cafileContent.split(/(-----END CERTIFICATE-----)/), 2).map(ca => ca.join("").replace(/^\n/, "").replace(/\n/g, "\\n"));
|
68
|
+
})())
|
69
|
+
);
|
70
|
+
}
|
71
|
+
|
72
|
+
return { proxy, noProxy, strictSSL, cert, "ca": ca.length === 0 ? undefined : ca };
|
73
|
+
}
|
@@ -1,19 +1,19 @@
|
|
1
1
|
import * as fs from "fs";
|
2
2
|
import * as path from "path";
|
3
3
|
|
4
|
-
function
|
4
|
+
function getThisCodebaseRootDirPath_rec(dirPath: string): string {
|
5
5
|
if (fs.existsSync(path.join(dirPath, "package.json"))) {
|
6
6
|
return dirPath;
|
7
7
|
}
|
8
|
-
return
|
8
|
+
return getThisCodebaseRootDirPath_rec(path.join(dirPath, ".."));
|
9
9
|
}
|
10
10
|
|
11
11
|
let result: string | undefined = undefined;
|
12
12
|
|
13
|
-
export function
|
13
|
+
export function getThisCodebaseRootDirPath(): string {
|
14
14
|
if (result !== undefined) {
|
15
15
|
return result;
|
16
16
|
}
|
17
17
|
|
18
|
-
return (result =
|
18
|
+
return (result = getThisCodebaseRootDirPath_rec(__dirname));
|
19
19
|
}
|
@@ -1,13 +1,15 @@
|
|
1
|
-
import {
|
1
|
+
import { getThisCodebaseRootDirPath } from "./getThisCodebaseRootDirPath";
|
2
2
|
import { join as pathJoin } from "path";
|
3
3
|
import { constants } from "fs";
|
4
4
|
import { chmod, stat } from "fs/promises";
|
5
5
|
|
6
6
|
(async () => {
|
7
|
-
const
|
7
|
+
const thisCodebaseRootDirPath = getThisCodebaseRootDirPath();
|
8
|
+
|
9
|
+
const { bin } = await import(pathJoin(thisCodebaseRootDirPath, "package.json"));
|
8
10
|
|
9
11
|
const promises = Object.values<string>(bin).map(async scriptPath => {
|
10
|
-
const fullPath = pathJoin(
|
12
|
+
const fullPath = pathJoin(thisCodebaseRootDirPath, scriptPath);
|
11
13
|
const oldMode = (await stat(fullPath)).mode;
|
12
14
|
const newMode = oldMode | constants.S_IXUSR | constants.S_IXGRP | constants.S_IXOTH;
|
13
15
|
await chmod(fullPath, newMode);
|
@@ -0,0 +1,12 @@
|
|
1
|
+
import { getThisCodebaseRootDirPath } from "./getThisCodebaseRootDirPath";
|
2
|
+
import { assert } from "tsafe/assert";
|
3
|
+
import * as fs from "fs";
|
4
|
+
import { join as pathJoin } from "path";
|
5
|
+
|
6
|
+
export function readThisNpmProjectVersion(): string {
|
7
|
+
const version = JSON.parse(fs.readFileSync(pathJoin(getThisCodebaseRootDirPath(), "package.json")).toString("utf8"))["version"];
|
8
|
+
|
9
|
+
assert(typeof version === "string");
|
10
|
+
|
11
|
+
return version;
|
12
|
+
}
|
@@ -17,13 +17,14 @@ type TransformSourceCode = (params: { sourceCode: Buffer; filePath: string; file
|
|
17
17
|
* */
|
18
18
|
export function transformCodebase(params: { srcDirPath: string; destDirPath: string; transformSourceCode?: TransformSourceCode }) {
|
19
19
|
const { srcDirPath, transformSourceCode } = params;
|
20
|
-
let { destDirPath } = params;
|
21
20
|
|
22
|
-
const isTargetSameAsSource = path.relative(srcDirPath, destDirPath) === "";
|
21
|
+
const isTargetSameAsSource = path.relative(srcDirPath, params.destDirPath) === "";
|
23
22
|
|
24
|
-
|
25
|
-
|
26
|
-
|
23
|
+
const destDirPath = isTargetSameAsSource ? path.join(srcDirPath, "..", "tmp_xOsPdkPsTdzPs34sOkHs") : params.destDirPath;
|
24
|
+
|
25
|
+
fs.mkdirSync(destDirPath, {
|
26
|
+
"recursive": true
|
27
|
+
});
|
27
28
|
|
28
29
|
for (const fileRelativePath of crawl({ "dirPath": srcDirPath, "returnedPathsType": "relative to dirPath" })) {
|
29
30
|
const filePath = path.join(srcDirPath, fileRelativePath);
|
@@ -0,0 +1,44 @@
|
|
1
|
+
import { assert } from "tsafe/assert";
|
2
|
+
|
3
|
+
/**
|
4
|
+
* WARNING: Internal use only!!
|
5
|
+
* THIS DOES NOT WORK IN KEYCLOAK! It's only for resolving mock assets.
|
6
|
+
* This is just a way to know what's the base url that works
|
7
|
+
* both in webpack and vite.
|
8
|
+
* You can see this as a polyfill that return `import.meta.env.BASE_URL` when in Vite
|
9
|
+
* and when in Webpack returns the base url in the same format as vite does meaning
|
10
|
+
* "/" if hosted at root or "/foo/" when hosted under a subpath (always start and ends with a "/").
|
11
|
+
*/
|
12
|
+
export const BASE_URL = (() => {
|
13
|
+
vite: {
|
14
|
+
let BASE_URL: string;
|
15
|
+
|
16
|
+
try {
|
17
|
+
// @ts-expect-error
|
18
|
+
BASE_URL = import.meta.env.BASE_URL;
|
19
|
+
|
20
|
+
assert(typeof BASE_URL === "string");
|
21
|
+
} catch {
|
22
|
+
break vite;
|
23
|
+
}
|
24
|
+
|
25
|
+
return BASE_URL;
|
26
|
+
}
|
27
|
+
|
28
|
+
webpack: {
|
29
|
+
let BASE_URL: string;
|
30
|
+
|
31
|
+
try {
|
32
|
+
// @ts-expect-error
|
33
|
+
BASE_URL = process.env.PUBLIC_URL;
|
34
|
+
|
35
|
+
assert(typeof BASE_URL === "string");
|
36
|
+
} catch {
|
37
|
+
break webpack;
|
38
|
+
}
|
39
|
+
|
40
|
+
return BASE_URL === "" ? "/" : `${BASE_URL}/`;
|
41
|
+
}
|
42
|
+
|
43
|
+
throw new Error("Bundler not supported");
|
44
|
+
})();
|
@@ -36,6 +36,10 @@ export declare namespace keycloak_js {
|
|
36
36
|
}
|
37
37
|
|
38
38
|
/**
|
39
|
+
* @deprecated: This will be removed in the next major version.
|
40
|
+
* If you use this, please copy paste the code into your project.
|
41
|
+
* Better yet migrate away from keycloak-js and use https://docs.oidc-spa.dev instead.
|
42
|
+
*
|
39
43
|
* NOTE: This is just a slightly modified version of the default adapter in keycloak-js
|
40
44
|
* The goal here is just to be able to inject search param in url before keycloak redirect.
|
41
45
|
* Our use case for it is to pass over the login screen the states of useGlobalState
|
@@ -2,14 +2,13 @@ import type { KcContext, Attribute } from "./KcContext";
|
|
2
2
|
import { kcContextMocks, kcContextCommonMock } from "./kcContextMocks";
|
3
3
|
import type { DeepPartial } from "keycloakify/tools/DeepPartial";
|
4
4
|
import { deepAssign } from "keycloakify/tools/deepAssign";
|
5
|
+
import { isStorybook } from "keycloakify/lib/isStorybook";
|
5
6
|
import { id } from "tsafe/id";
|
6
7
|
import { exclude } from "tsafe/exclude";
|
7
8
|
import { assert } from "tsafe/assert";
|
8
9
|
import type { ExtendKcContext } from "./getKcContextFromWindow";
|
9
10
|
import { getKcContextFromWindow } from "./getKcContextFromWindow";
|
10
|
-
import { pathJoin } from "keycloakify/bin/tools/pathJoin";
|
11
11
|
import { symToStr } from "tsafe/symToStr";
|
12
|
-
import { resources_common } from "keycloakify/bin/constants";
|
13
12
|
|
14
13
|
export function createGetKcContext<KcContextExtension extends { pageId: string } = never>(params?: {
|
15
14
|
mockData?: readonly DeepPartial<ExtendKcContext<KcContextExtension>>[];
|
@@ -31,7 +30,13 @@ export function createGetKcContext<KcContextExtension extends { pageId: string }
|
|
31
30
|
if (mockPageId !== undefined && realKcContext === undefined) {
|
32
31
|
//TODO maybe trow if no mock fo custom page
|
33
32
|
|
34
|
-
|
33
|
+
warn_that_mock_is_enbaled: {
|
34
|
+
if (isStorybook) {
|
35
|
+
break warn_that_mock_is_enbaled;
|
36
|
+
}
|
37
|
+
|
38
|
+
console.log(`%cKeycloakify: ${symToStr({ mockPageId })} set to ${mockPageId}.`, "background: red; color: yellow; font-size: medium");
|
39
|
+
}
|
35
40
|
|
36
41
|
const kcContextDefaultMock = kcContextMocks.find(({ pageId }) => pageId === mockPageId);
|
37
42
|
|
@@ -147,8 +152,6 @@ export function createGetKcContext<KcContextExtension extends { pageId: string }
|
|
147
152
|
return { "kcContext": undefined as any };
|
148
153
|
}
|
149
154
|
|
150
|
-
realKcContext.url.resourcesCommonPath = pathJoin(realKcContext.url.resourcesPath, resources_common);
|
151
|
-
|
152
155
|
return { "kcContext": realKcContext as any };
|
153
156
|
}
|
154
157
|
|
@@ -1,10 +1,10 @@
|
|
1
1
|
import "minimal-polyfills/Object.fromEntries";
|
2
2
|
import type { KcContext, Attribute } from "./KcContext";
|
3
3
|
import { resources_common, keycloak_resources } from "keycloakify/bin/constants";
|
4
|
-
import { pathJoin } from "keycloakify/bin/tools/pathJoin";
|
5
4
|
import { id } from "tsafe/id";
|
6
5
|
import { assert, type Equals } from "tsafe/assert";
|
7
6
|
import type { LoginThemePageId } from "keycloakify/bin/keycloakify/generateFtl";
|
7
|
+
import { BASE_URL } from "keycloakify/lib/BASE_URL";
|
8
8
|
|
9
9
|
const attributes: Attribute[] = [
|
10
10
|
{
|
@@ -100,9 +100,7 @@ const attributes: Attribute[] = [
|
|
100
100
|
|
101
101
|
const attributesByName = Object.fromEntries(attributes.map(attribute => [attribute.name, attribute])) as any;
|
102
102
|
|
103
|
-
const
|
104
|
-
|
105
|
-
const resourcesPath = pathJoin(PUBLIC_URL, keycloak_resources, "login", "resources");
|
103
|
+
const resourcesPath = `${BASE_URL}${keycloak_resources}/login/resources`;
|
106
104
|
|
107
105
|
export const kcContextCommonMock: KcContext.Common = {
|
108
106
|
"themeVersion": "0.0.0",
|
@@ -112,7 +110,7 @@ export const kcContextCommonMock: KcContext.Common = {
|
|
112
110
|
"url": {
|
113
111
|
"loginAction": "#",
|
114
112
|
resourcesPath,
|
115
|
-
"resourcesCommonPath":
|
113
|
+
"resourcesCommonPath": `${resourcesPath}/${resources_common}`,
|
116
114
|
"loginRestartFlowUrl": "/auth/realms/myrealm/login-actions/restart?client_id=account&tab_id=HoAx28ja4xg",
|
117
115
|
"loginUrl": "/auth/realms/myrealm/login-actions/authenticate?client_id=account&tab_id=HoAx28ja4xg"
|
118
116
|
},
|
@@ -1,14 +1,14 @@
|
|
1
1
|
import { join as pathJoin, relative as pathRelative, sep as pathSep } from "path";
|
2
|
-
import { readParsedPackageJson } from "../bin/keycloakify/buildOptions/parsedPackageJson";
|
3
2
|
import type { Plugin } from "vite";
|
4
3
|
import { assert } from "tsafe/assert";
|
5
4
|
import * as fs from "fs";
|
6
5
|
import { resolvedViteConfigJsonBasename, nameOfTheGlobal, basenameOfTheKeycloakifyResourcesDir, keycloak_resources } from "../bin/constants";
|
7
6
|
import type { ResolvedViteConfig } from "../bin/keycloakify/buildOptions/resolvedViteConfig";
|
8
|
-
import {
|
7
|
+
import { getCacheDirPath } from "../bin/keycloakify/buildOptions/getCacheDirPath";
|
9
8
|
import { replaceAll } from "../bin/tools/String.prototype.replaceAll";
|
10
9
|
import { id } from "tsafe/id";
|
11
10
|
import { rm } from "../bin/tools/fs.rm";
|
11
|
+
import { copyKeycloakResourcesToPublic } from "../bin/copy-keycloak-resources-to-public";
|
12
12
|
|
13
13
|
export function keycloakify(): Plugin {
|
14
14
|
let reactAppRootDirPath: string | undefined = undefined;
|
@@ -18,7 +18,7 @@ export function keycloakify(): Plugin {
|
|
18
18
|
return {
|
19
19
|
"name": "keycloakify",
|
20
20
|
"apply": "build",
|
21
|
-
"configResolved": resolvedConfig => {
|
21
|
+
"configResolved": async resolvedConfig => {
|
22
22
|
reactAppRootDirPath = resolvedConfig.root;
|
23
23
|
urlPathname = (() => {
|
24
24
|
let out = resolvedConfig.env.BASE_URL;
|
@@ -40,19 +40,16 @@ export function keycloakify(): Plugin {
|
|
40
40
|
|
41
41
|
buildDirPath = pathJoin(reactAppRootDirPath, resolvedConfig.build.outDir);
|
42
42
|
|
43
|
-
const {
|
44
|
-
|
45
|
-
?.keycloakifyBuildDirPath,
|
46
|
-
reactAppRootDirPath,
|
47
|
-
"bundler": "vite"
|
43
|
+
const { cacheDirPath } = getCacheDirPath({
|
44
|
+
reactAppRootDirPath
|
48
45
|
});
|
49
46
|
|
50
|
-
if (!fs.existsSync(
|
51
|
-
fs.mkdirSync(
|
47
|
+
if (!fs.existsSync(cacheDirPath)) {
|
48
|
+
fs.mkdirSync(cacheDirPath);
|
52
49
|
}
|
53
50
|
|
54
51
|
fs.writeFileSync(
|
55
|
-
pathJoin(
|
52
|
+
pathJoin(cacheDirPath, resolvedViteConfigJsonBasename),
|
56
53
|
Buffer.from(
|
57
54
|
JSON.stringify(
|
58
55
|
id<ResolvedViteConfig>({
|
@@ -67,6 +64,10 @@ export function keycloakify(): Plugin {
|
|
67
64
|
"utf8"
|
68
65
|
)
|
69
66
|
);
|
67
|
+
|
68
|
+
await copyKeycloakResourcesToPublic({
|
69
|
+
"processArgv": ["--project", reactAppRootDirPath]
|
70
|
+
});
|
70
71
|
},
|
71
72
|
"transform": (code, id) => {
|
72
73
|
assert(reactAppRootDirPath !== undefined);
|