Use uppercase for constants
This commit is contained in:
parent
ca549fe8d8
commit
f172b94467
@ -1,4 +1,4 @@
|
|||||||
import { containerName } from "../src/bin/shared/constants";
|
import { CONTAINER_NAME } from "../src/bin/shared/constants";
|
||||||
import child_process from "child_process";
|
import child_process from "child_process";
|
||||||
import { SemVer } from "../src/bin/tools/SemVer";
|
import { SemVer } from "../src/bin/tools/SemVer";
|
||||||
import { join as pathJoin, relative as pathRelative } from "path";
|
import { join as pathJoin, relative as pathRelative } from "path";
|
||||||
@ -14,7 +14,7 @@ import { is } from "tsafe/is";
|
|||||||
const child = child_process.spawn(
|
const child = child_process.spawn(
|
||||||
"docker",
|
"docker",
|
||||||
[
|
[
|
||||||
...["exec", containerName],
|
...["exec", CONTAINER_NAME],
|
||||||
...["/opt/keycloak/bin/kc.sh", "export"],
|
...["/opt/keycloak/bin/kc.sh", "export"],
|
||||||
...["--dir", "/tmp"],
|
...["--dir", "/tmp"],
|
||||||
...["--realm", "myrealm"],
|
...["--realm", "myrealm"],
|
||||||
@ -62,7 +62,7 @@ import { is } from "tsafe/is";
|
|||||||
|
|
||||||
const keycloakMajorVersionNumber = SemVer.parse(
|
const keycloakMajorVersionNumber = SemVer.parse(
|
||||||
child_process
|
child_process
|
||||||
.execSync(`docker inspect --format '{{.Config.Image}}' ${containerName}`)
|
.execSync(`docker inspect --format '{{.Config.Image}}' ${CONTAINER_NAME}`)
|
||||||
.toString("utf8")
|
.toString("utf8")
|
||||||
.trim()
|
.trim()
|
||||||
.split(":")[1]
|
.split(":")[1]
|
||||||
@ -80,7 +80,7 @@ import { is } from "tsafe/is";
|
|||||||
)
|
)
|
||||||
);
|
);
|
||||||
|
|
||||||
run(`docker cp ${containerName}:/tmp/myrealm-realm.json ${targetFilePath}`);
|
run(`docker cp ${CONTAINER_NAME}:/tmp/myrealm-realm.json ${targetFilePath}`);
|
||||||
|
|
||||||
console.log(`${chalk.green(`✓ Exported realm to`)} ${chalk.bold(targetFilePath)}`);
|
console.log(`${chalk.green(`✓ Exported realm to`)} ${chalk.bold(targetFilePath)}`);
|
||||||
})();
|
})();
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
import { basenameOfTheKeycloakifyResourcesDir } from "keycloakify/bin/shared/constants";
|
import { BASENAME_OF_KEYCLOAKIFY_RESOURCES_DIR } from "keycloakify/bin/shared/constants";
|
||||||
import { assert } from "tsafe/assert";
|
import { assert } from "tsafe/assert";
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -17,5 +17,5 @@ export const PUBLIC_URL = (() => {
|
|||||||
return process.env.PUBLIC_URL;
|
return process.env.PUBLIC_URL;
|
||||||
}
|
}
|
||||||
|
|
||||||
return `${kcContext.url.resourcesPath}/${basenameOfTheKeycloakifyResourcesDir}`;
|
return `${kcContext.url.resourcesPath}/${BASENAME_OF_KEYCLOAKIFY_RESOURCES_DIR}`;
|
||||||
})();
|
})();
|
||||||
|
@ -1,10 +1,10 @@
|
|||||||
import "keycloakify/tools/Object.fromEntries";
|
import "keycloakify/tools/Object.fromEntries";
|
||||||
import { resources_common, keycloak_resources } from "keycloakify/bin/shared/constants";
|
import { RESOURCES_COMMON, KEYCLOAK_RESOURCES } from "keycloakify/bin/shared/constants";
|
||||||
import { id } from "tsafe/id";
|
import { id } from "tsafe/id";
|
||||||
import type { KcContext } from "./KcContext";
|
import type { KcContext } from "./KcContext";
|
||||||
import { BASE_URL } from "keycloakify/lib/BASE_URL";
|
import { BASE_URL } from "keycloakify/lib/BASE_URL";
|
||||||
|
|
||||||
const resourcesPath = `${BASE_URL}${keycloak_resources}/account/resources`;
|
const resourcesPath = `${BASE_URL}${KEYCLOAK_RESOURCES}/account/resources`;
|
||||||
|
|
||||||
export const kcContextCommonMock: KcContext.Common = {
|
export const kcContextCommonMock: KcContext.Common = {
|
||||||
themeVersion: "0.0.0",
|
themeVersion: "0.0.0",
|
||||||
@ -13,7 +13,7 @@ export const kcContextCommonMock: KcContext.Common = {
|
|||||||
themeName: "my-theme-name",
|
themeName: "my-theme-name",
|
||||||
url: {
|
url: {
|
||||||
resourcesPath,
|
resourcesPath,
|
||||||
resourcesCommonPath: `${resourcesPath}/${resources_common}`,
|
resourcesCommonPath: `${resourcesPath}/${RESOURCES_COMMON}`,
|
||||||
resourceUrl: "#",
|
resourceUrl: "#",
|
||||||
accountUrl: "#",
|
accountUrl: "#",
|
||||||
applicationsUrl: "#",
|
applicationsUrl: "#",
|
||||||
|
@ -3,7 +3,7 @@ import { assert } from "tsafe/assert";
|
|||||||
import messages_defaultSet_fallbackLanguage from "./messages_defaultSet/en";
|
import messages_defaultSet_fallbackLanguage from "./messages_defaultSet/en";
|
||||||
import { fetchMessages_defaultSet } from "./messages_defaultSet";
|
import { fetchMessages_defaultSet } from "./messages_defaultSet";
|
||||||
import type { KcContext } from "../KcContext";
|
import type { KcContext } from "../KcContext";
|
||||||
import { fallbackLanguageTag } from "keycloakify/bin/shared/constants";
|
import { FALLBACK_LANGUAGE_TAG } from "keycloakify/bin/shared/constants";
|
||||||
import { id } from "tsafe/id";
|
import { id } from "tsafe/id";
|
||||||
|
|
||||||
export type KcContextLike = {
|
export type KcContextLike = {
|
||||||
@ -104,7 +104,7 @@ export function createGetI18n<MessageKey_themeDefined extends string = never>(me
|
|||||||
}
|
}
|
||||||
|
|
||||||
const partialI18n: Pick<I18n, "currentLanguageTag" | "getChangeLocaleUrl" | "labelBySupportedLanguageTag"> = {
|
const partialI18n: Pick<I18n, "currentLanguageTag" | "getChangeLocaleUrl" | "labelBySupportedLanguageTag"> = {
|
||||||
currentLanguageTag: kcContext.locale?.currentLanguageTag ?? fallbackLanguageTag,
|
currentLanguageTag: kcContext.locale?.currentLanguageTag ?? FALLBACK_LANGUAGE_TAG,
|
||||||
getChangeLocaleUrl: newLanguageTag => {
|
getChangeLocaleUrl: newLanguageTag => {
|
||||||
const { locale } = kcContext;
|
const { locale } = kcContext;
|
||||||
|
|
||||||
@ -122,7 +122,7 @@ export function createGetI18n<MessageKey_themeDefined extends string = never>(me
|
|||||||
const { createI18nTranslationFunctions } = createI18nTranslationFunctionsFactory<MessageKey_themeDefined>({
|
const { createI18nTranslationFunctions } = createI18nTranslationFunctionsFactory<MessageKey_themeDefined>({
|
||||||
messages_themeDefined:
|
messages_themeDefined:
|
||||||
messagesByLanguageTag_themeDefined[partialI18n.currentLanguageTag] ??
|
messagesByLanguageTag_themeDefined[partialI18n.currentLanguageTag] ??
|
||||||
messagesByLanguageTag_themeDefined[fallbackLanguageTag] ??
|
messagesByLanguageTag_themeDefined[FALLBACK_LANGUAGE_TAG] ??
|
||||||
(() => {
|
(() => {
|
||||||
const firstLanguageTag = Object.keys(messagesByLanguageTag_themeDefined)[0];
|
const firstLanguageTag = Object.keys(messagesByLanguageTag_themeDefined)[0];
|
||||||
if (firstLanguageTag === undefined) {
|
if (firstLanguageTag === undefined) {
|
||||||
@ -133,7 +133,7 @@ export function createGetI18n<MessageKey_themeDefined extends string = never>(me
|
|||||||
messages_fromKcServer: kcContext["x-keycloakify"].messages
|
messages_fromKcServer: kcContext["x-keycloakify"].messages
|
||||||
});
|
});
|
||||||
|
|
||||||
const isCurrentLanguageFallbackLanguage = partialI18n.currentLanguageTag === fallbackLanguageTag;
|
const isCurrentLanguageFallbackLanguage = partialI18n.currentLanguageTag === FALLBACK_LANGUAGE_TAG;
|
||||||
|
|
||||||
const result: Result = {
|
const result: Result = {
|
||||||
i18n: {
|
i18n: {
|
||||||
|
@ -1,11 +1,11 @@
|
|||||||
import { getThisCodebaseRootDirPath } from "./tools/getThisCodebaseRootDirPath";
|
import { getThisCodebaseRootDirPath } from "./tools/getThisCodebaseRootDirPath";
|
||||||
import cliSelect from "cli-select";
|
import cliSelect from "cli-select";
|
||||||
import {
|
import {
|
||||||
loginThemePageIds,
|
LOGIN_THEME_PAGE_IDS,
|
||||||
accountThemePageIds,
|
ACCOUNT_THEME_PAGE_IDS,
|
||||||
type LoginThemePageId,
|
type LoginThemePageId,
|
||||||
type AccountThemePageId,
|
type AccountThemePageId,
|
||||||
themeTypes,
|
THEME_TYPES,
|
||||||
type ThemeType
|
type ThemeType
|
||||||
} from "./shared/constants";
|
} from "./shared/constants";
|
||||||
import { capitalize } from "tsafe/capitalize";
|
import { capitalize } from "tsafe/capitalize";
|
||||||
@ -27,7 +27,7 @@ export async function command(params: { cliCommandOptions: CliCommandOptions })
|
|||||||
console.log(chalk.cyan("Theme type:"));
|
console.log(chalk.cyan("Theme type:"));
|
||||||
|
|
||||||
const { value: themeType } = await cliSelect<ThemeType>({
|
const { value: themeType } = await cliSelect<ThemeType>({
|
||||||
values: [...themeTypes]
|
values: [...THEME_TYPES]
|
||||||
}).catch(() => {
|
}).catch(() => {
|
||||||
process.exit(-1);
|
process.exit(-1);
|
||||||
});
|
});
|
||||||
@ -40,9 +40,9 @@ export async function command(params: { cliCommandOptions: CliCommandOptions })
|
|||||||
values: (() => {
|
values: (() => {
|
||||||
switch (themeType) {
|
switch (themeType) {
|
||||||
case "login":
|
case "login":
|
||||||
return [...loginThemePageIds];
|
return [...LOGIN_THEME_PAGE_IDS];
|
||||||
case "account":
|
case "account":
|
||||||
return [...accountThemePageIds];
|
return [...ACCOUNT_THEME_PAGE_IDS];
|
||||||
}
|
}
|
||||||
assert<Equals<typeof themeType, never>>(false);
|
assert<Equals<typeof themeType, never>>(false);
|
||||||
})()
|
})()
|
||||||
|
@ -3,11 +3,11 @@
|
|||||||
import { getThisCodebaseRootDirPath } from "./tools/getThisCodebaseRootDirPath";
|
import { getThisCodebaseRootDirPath } from "./tools/getThisCodebaseRootDirPath";
|
||||||
import cliSelect from "cli-select";
|
import cliSelect from "cli-select";
|
||||||
import {
|
import {
|
||||||
loginThemePageIds,
|
LOGIN_THEME_PAGE_IDS,
|
||||||
accountThemePageIds,
|
ACCOUNT_THEME_PAGE_IDS,
|
||||||
type LoginThemePageId,
|
type LoginThemePageId,
|
||||||
type AccountThemePageId,
|
type AccountThemePageId,
|
||||||
themeTypes,
|
THEME_TYPES,
|
||||||
type ThemeType
|
type ThemeType
|
||||||
} from "./shared/constants";
|
} from "./shared/constants";
|
||||||
import { capitalize } from "tsafe/capitalize";
|
import { capitalize } from "tsafe/capitalize";
|
||||||
@ -29,7 +29,7 @@ export async function command(params: { cliCommandOptions: CliCommandOptions })
|
|||||||
console.log(chalk.cyan("Theme type:"));
|
console.log(chalk.cyan("Theme type:"));
|
||||||
|
|
||||||
const { value: themeType } = await cliSelect<ThemeType>({
|
const { value: themeType } = await cliSelect<ThemeType>({
|
||||||
values: [...themeTypes]
|
values: [...THEME_TYPES]
|
||||||
}).catch(() => {
|
}).catch(() => {
|
||||||
process.exit(-1);
|
process.exit(-1);
|
||||||
});
|
});
|
||||||
@ -54,10 +54,10 @@ export async function command(params: { cliCommandOptions: CliCommandOptions })
|
|||||||
return [
|
return [
|
||||||
templateValue,
|
templateValue,
|
||||||
userProfileFormFieldsValue,
|
userProfileFormFieldsValue,
|
||||||
...loginThemePageIds
|
...LOGIN_THEME_PAGE_IDS
|
||||||
];
|
];
|
||||||
case "account":
|
case "account":
|
||||||
return [templateValue, ...accountThemePageIds];
|
return [templateValue, ...ACCOUNT_THEME_PAGE_IDS];
|
||||||
}
|
}
|
||||||
assert<Equals<typeof themeType, never>>(false);
|
assert<Equals<typeof themeType, never>>(false);
|
||||||
})()
|
})()
|
||||||
|
@ -7,7 +7,7 @@ import { join as pathJoin, dirname as pathDirname } from "path";
|
|||||||
import { transformCodebase } from "../../tools/transformCodebase";
|
import { transformCodebase } from "../../tools/transformCodebase";
|
||||||
import type { BuildContext } from "../../shared/buildContext";
|
import type { BuildContext } from "../../shared/buildContext";
|
||||||
import * as fs from "fs/promises";
|
import * as fs from "fs/promises";
|
||||||
import { accountV1ThemeName } from "../../shared/constants";
|
import { ACCOUNT_V1_THEME_NAME } from "../../shared/constants";
|
||||||
import {
|
import {
|
||||||
generatePom,
|
generatePom,
|
||||||
BuildContextLike as BuildContextLike_generatePom
|
BuildContextLike as BuildContextLike_generatePom
|
||||||
@ -75,7 +75,7 @@ export async function buildJar(params: {
|
|||||||
|
|
||||||
if (
|
if (
|
||||||
isInside({
|
isInside({
|
||||||
dirPath: pathJoin("theme", accountV1ThemeName),
|
dirPath: pathJoin("theme", ACCOUNT_V1_THEME_NAME),
|
||||||
filePath: fileRelativePath
|
filePath: fileRelativePath
|
||||||
})
|
})
|
||||||
) {
|
) {
|
||||||
@ -91,7 +91,7 @@ export async function buildJar(params: {
|
|||||||
sourceCode
|
sourceCode
|
||||||
.toString("utf8")
|
.toString("utf8")
|
||||||
.replace(
|
.replace(
|
||||||
`parent=${accountV1ThemeName}`,
|
`parent=${ACCOUNT_V1_THEME_NAME}`,
|
||||||
"parent=keycloak"
|
"parent=keycloak"
|
||||||
),
|
),
|
||||||
"utf8"
|
"utf8"
|
||||||
@ -126,7 +126,7 @@ export async function buildJar(params: {
|
|||||||
assert(metaInfKeycloakTheme !== undefined);
|
assert(metaInfKeycloakTheme !== undefined);
|
||||||
|
|
||||||
metaInfKeycloakTheme.themes = metaInfKeycloakTheme.themes.filter(
|
metaInfKeycloakTheme.themes = metaInfKeycloakTheme.themes.filter(
|
||||||
({ name }) => name !== accountV1ThemeName
|
({ name }) => name !== ACCOUNT_V1_THEME_NAME
|
||||||
);
|
);
|
||||||
|
|
||||||
return metaInfKeycloakTheme;
|
return metaInfKeycloakTheme;
|
||||||
|
@ -13,8 +13,8 @@ import type { BuildContext } from "../../shared/buildContext";
|
|||||||
import { assert } from "tsafe/assert";
|
import { assert } from "tsafe/assert";
|
||||||
import {
|
import {
|
||||||
type ThemeType,
|
type ThemeType,
|
||||||
basenameOfTheKeycloakifyResourcesDir,
|
BASENAME_OF_KEYCLOAKIFY_RESOURCES_DIR,
|
||||||
resources_common
|
RESOURCES_COMMON
|
||||||
} from "../../shared/constants";
|
} from "../../shared/constants";
|
||||||
import { getThisCodebaseRootDirPath } from "../../tools/getThisCodebaseRootDirPath";
|
import { getThisCodebaseRootDirPath } from "../../tools/getThisCodebaseRootDirPath";
|
||||||
|
|
||||||
@ -93,7 +93,7 @@ export function generateFtlFilesCodeFactory(params: {
|
|||||||
new RegExp(
|
new RegExp(
|
||||||
`^${(buildContext.urlPathname ?? "/").replace(/\//g, "\\/")}`
|
`^${(buildContext.urlPathname ?? "/").replace(/\//g, "\\/")}`
|
||||||
),
|
),
|
||||||
`\${xKeycloakify.resourcesPath}/${basenameOfTheKeycloakifyResourcesDir}/`
|
`\${xKeycloakify.resourcesPath}/${BASENAME_OF_KEYCLOAKIFY_RESOURCES_DIR}/`
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
})
|
})
|
||||||
@ -118,7 +118,7 @@ export function generateFtlFilesCodeFactory(params: {
|
|||||||
.replace("{{keycloakifyVersion}}", keycloakifyVersion)
|
.replace("{{keycloakifyVersion}}", keycloakifyVersion)
|
||||||
.replace("{{themeVersion}}", buildContext.themeVersion)
|
.replace("{{themeVersion}}", buildContext.themeVersion)
|
||||||
.replace("{{fieldNames}}", fieldNames.map(name => `"${name}"`).join(", "))
|
.replace("{{fieldNames}}", fieldNames.map(name => `"${name}"`).join(", "))
|
||||||
.replace("{{RESOURCES_COMMON}}", resources_common)
|
.replace("{{RESOURCES_COMMON}}", RESOURCES_COMMON)
|
||||||
.replace(
|
.replace(
|
||||||
"{{userDefinedExclusions}}",
|
"{{userDefinedExclusions}}",
|
||||||
buildContext.kcContextExclusionsFtlCode ?? ""
|
buildContext.kcContextExclusionsFtlCode ?? ""
|
||||||
|
@ -3,9 +3,9 @@ import { join as pathJoin } from "path";
|
|||||||
import { assert } from "tsafe/assert";
|
import { assert } from "tsafe/assert";
|
||||||
import type { BuildContext } from "../../shared/buildContext";
|
import type { BuildContext } from "../../shared/buildContext";
|
||||||
import {
|
import {
|
||||||
resources_common,
|
RESOURCES_COMMON,
|
||||||
lastKeycloakVersionWithAccountV1,
|
LAST_KEYCLOAK_VERSION_WITH_ACCOUNT_V1,
|
||||||
accountV1ThemeName
|
ACCOUNT_V1_THEME_NAME
|
||||||
} from "../../shared/constants";
|
} from "../../shared/constants";
|
||||||
import {
|
import {
|
||||||
downloadKeycloakDefaultTheme,
|
downloadKeycloakDefaultTheme,
|
||||||
@ -24,14 +24,14 @@ export async function bringInAccountV1(params: {
|
|||||||
const { resourcesDirPath, buildContext } = params;
|
const { resourcesDirPath, buildContext } = params;
|
||||||
|
|
||||||
const { defaultThemeDirPath } = await downloadKeycloakDefaultTheme({
|
const { defaultThemeDirPath } = await downloadKeycloakDefaultTheme({
|
||||||
keycloakVersion: lastKeycloakVersionWithAccountV1,
|
keycloakVersion: LAST_KEYCLOAK_VERSION_WITH_ACCOUNT_V1,
|
||||||
buildContext
|
buildContext
|
||||||
});
|
});
|
||||||
|
|
||||||
const accountV1DirPath = pathJoin(
|
const accountV1DirPath = pathJoin(
|
||||||
resourcesDirPath,
|
resourcesDirPath,
|
||||||
"theme",
|
"theme",
|
||||||
accountV1ThemeName,
|
ACCOUNT_V1_THEME_NAME,
|
||||||
"account"
|
"account"
|
||||||
);
|
);
|
||||||
|
|
||||||
@ -47,7 +47,7 @@ export async function bringInAccountV1(params: {
|
|||||||
|
|
||||||
transformCodebase({
|
transformCodebase({
|
||||||
srcDirPath: pathJoin(defaultThemeDirPath, "keycloak", "common", "resources"),
|
srcDirPath: pathJoin(defaultThemeDirPath, "keycloak", "common", "resources"),
|
||||||
destDirPath: pathJoin(accountV1DirPath, "resources", resources_common)
|
destDirPath: pathJoin(accountV1DirPath, "resources", RESOURCES_COMMON)
|
||||||
});
|
});
|
||||||
|
|
||||||
fs.writeFileSync(
|
fs.writeFileSync(
|
||||||
@ -69,7 +69,7 @@ export async function bringInAccountV1(params: {
|
|||||||
"patternfly-additions.min.css"
|
"patternfly-additions.min.css"
|
||||||
].map(
|
].map(
|
||||||
fileBasename =>
|
fileBasename =>
|
||||||
`${resources_common}/node_modules/patternfly/dist/css/${fileBasename}`
|
`${RESOURCES_COMMON}/node_modules/patternfly/dist/css/${fileBasename}`
|
||||||
)
|
)
|
||||||
].join(" "),
|
].join(" "),
|
||||||
"",
|
"",
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
import { type ThemeType, fallbackLanguageTag } from "../../shared/constants";
|
import { type ThemeType, FALLBACK_LANGUAGE_TAG } from "../../shared/constants";
|
||||||
import { crawl } from "../../tools/crawl";
|
import { crawl } from "../../tools/crawl";
|
||||||
import { join as pathJoin } from "path";
|
import { join as pathJoin } from "path";
|
||||||
import { symToStr } from "tsafe/symToStr";
|
import { symToStr } from "tsafe/symToStr";
|
||||||
@ -168,7 +168,7 @@ export function generateMessageProperties(params: {
|
|||||||
...(messageBundle === undefined
|
...(messageBundle === undefined
|
||||||
? {}
|
? {}
|
||||||
: messageBundle[languageTag] ??
|
: messageBundle[languageTag] ??
|
||||||
messageBundle[fallbackLanguageTag] ??
|
messageBundle[FALLBACK_LANGUAGE_TAG] ??
|
||||||
messageBundle[Object.keys(messageBundle)[0]] ??
|
messageBundle[Object.keys(messageBundle)[0]] ??
|
||||||
{})
|
{})
|
||||||
}
|
}
|
||||||
|
@ -15,12 +15,12 @@ import {
|
|||||||
} from "../generateFtl";
|
} from "../generateFtl";
|
||||||
import {
|
import {
|
||||||
type ThemeType,
|
type ThemeType,
|
||||||
lastKeycloakVersionWithAccountV1,
|
LAST_KEYCLOAK_VERSION_WITH_ACCOUNT_V1,
|
||||||
keycloak_resources,
|
KEYCLOAK_RESOURCES,
|
||||||
accountV1ThemeName,
|
ACCOUNT_V1_THEME_NAME,
|
||||||
basenameOfTheKeycloakifyResourcesDir,
|
BASENAME_OF_KEYCLOAKIFY_RESOURCES_DIR,
|
||||||
loginThemePageIds,
|
LOGIN_THEME_PAGE_IDS,
|
||||||
accountThemePageIds
|
ACCOUNT_THEME_PAGE_IDS
|
||||||
} from "../../shared/constants";
|
} from "../../shared/constants";
|
||||||
import type { BuildContext } from "../../shared/buildContext";
|
import type { BuildContext } from "../../shared/buildContext";
|
||||||
import { assert, type Equals } from "tsafe/assert";
|
import { assert, type Equals } from "tsafe/assert";
|
||||||
@ -85,7 +85,7 @@ export async function generateResourcesForMainTheme(params: {
|
|||||||
const destDirPath = pathJoin(
|
const destDirPath = pathJoin(
|
||||||
themeTypeDirPath,
|
themeTypeDirPath,
|
||||||
"resources",
|
"resources",
|
||||||
basenameOfTheKeycloakifyResourcesDir
|
BASENAME_OF_KEYCLOAKIFY_RESOURCES_DIR
|
||||||
);
|
);
|
||||||
|
|
||||||
// NOTE: Prevent accumulation of files in the assets dir, as names are hashed they pile up.
|
// NOTE: Prevent accumulation of files in the assets dir, as names are hashed they pile up.
|
||||||
@ -103,7 +103,7 @@ export async function generateResourcesForMainTheme(params: {
|
|||||||
themeType: "login"
|
themeType: "login"
|
||||||
}),
|
}),
|
||||||
"resources",
|
"resources",
|
||||||
basenameOfTheKeycloakifyResourcesDir
|
BASENAME_OF_KEYCLOAKIFY_RESOURCES_DIR
|
||||||
),
|
),
|
||||||
destDirPath
|
destDirPath
|
||||||
});
|
});
|
||||||
@ -114,7 +114,7 @@ export async function generateResourcesForMainTheme(params: {
|
|||||||
{
|
{
|
||||||
const dirPath = pathJoin(
|
const dirPath = pathJoin(
|
||||||
buildContext.projectBuildDirPath,
|
buildContext.projectBuildDirPath,
|
||||||
keycloak_resources
|
KEYCLOAK_RESOURCES
|
||||||
);
|
);
|
||||||
|
|
||||||
if (fs.existsSync(dirPath)) {
|
if (fs.existsSync(dirPath)) {
|
||||||
@ -122,7 +122,7 @@ export async function generateResourcesForMainTheme(params: {
|
|||||||
|
|
||||||
throw new Error(
|
throw new Error(
|
||||||
[
|
[
|
||||||
`Keycloakify build error: The ${keycloak_resources} directory shouldn't exist in your build directory.`,
|
`Keycloakify build error: The ${KEYCLOAK_RESOURCES} directory shouldn't exist in your build directory.`,
|
||||||
`(${pathRelative(process.cwd(), dirPath)}).\n`,
|
`(${pathRelative(process.cwd(), dirPath)}).\n`,
|
||||||
`Theses assets are only required for local development with Storybook.",
|
`Theses assets are only required for local development with Storybook.",
|
||||||
"Please remove this directory as an additional step of your command.\n`,
|
"Please remove this directory as an additional step of your command.\n`,
|
||||||
@ -182,9 +182,9 @@ export async function generateResourcesForMainTheme(params: {
|
|||||||
...(() => {
|
...(() => {
|
||||||
switch (themeType) {
|
switch (themeType) {
|
||||||
case "login":
|
case "login":
|
||||||
return loginThemePageIds;
|
return LOGIN_THEME_PAGE_IDS;
|
||||||
case "account":
|
case "account":
|
||||||
return isAccountV3 ? ["index.ftl"] : accountThemePageIds;
|
return isAccountV3 ? ["index.ftl"] : ACCOUNT_THEME_PAGE_IDS;
|
||||||
}
|
}
|
||||||
})(),
|
})(),
|
||||||
...(isAccountV3
|
...(isAccountV3
|
||||||
@ -238,7 +238,7 @@ export async function generateResourcesForMainTheme(params: {
|
|||||||
keycloakVersion: (() => {
|
keycloakVersion: (() => {
|
||||||
switch (themeType) {
|
switch (themeType) {
|
||||||
case "account":
|
case "account":
|
||||||
return lastKeycloakVersionWithAccountV1;
|
return LAST_KEYCLOAK_VERSION_WITH_ACCOUNT_V1;
|
||||||
case "login":
|
case "login":
|
||||||
return buildContext.loginThemeResourcesFromKeycloakVersion;
|
return buildContext.loginThemeResourcesFromKeycloakVersion;
|
||||||
}
|
}
|
||||||
@ -256,7 +256,7 @@ export async function generateResourcesForMainTheme(params: {
|
|||||||
`parent=${(() => {
|
`parent=${(() => {
|
||||||
switch (themeType) {
|
switch (themeType) {
|
||||||
case "account":
|
case "account":
|
||||||
return isAccountV3 ? "base" : accountV1ThemeName;
|
return isAccountV3 ? "base" : ACCOUNT_V1_THEME_NAME;
|
||||||
case "login":
|
case "login":
|
||||||
return "keycloak";
|
return "keycloak";
|
||||||
}
|
}
|
||||||
@ -347,7 +347,7 @@ export async function generateResourcesForMainTheme(params: {
|
|||||||
|
|
||||||
if (buildContext.recordIsImplementedByThemeType.account) {
|
if (buildContext.recordIsImplementedByThemeType.account) {
|
||||||
metaInfKeycloakThemes.themes.push({
|
metaInfKeycloakThemes.themes.push({
|
||||||
name: accountV1ThemeName,
|
name: ACCOUNT_V1_THEME_NAME,
|
||||||
types: ["account"]
|
types: ["account"]
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
@ -5,8 +5,8 @@ import * as fs from "fs";
|
|||||||
import { join as pathJoin } from "path";
|
import { join as pathJoin } from "path";
|
||||||
import {
|
import {
|
||||||
type ThemeType,
|
type ThemeType,
|
||||||
accountThemePageIds,
|
ACCOUNT_THEME_PAGE_IDS,
|
||||||
loginThemePageIds
|
LOGIN_THEME_PAGE_IDS
|
||||||
} from "../../shared/constants";
|
} from "../../shared/constants";
|
||||||
|
|
||||||
export function readExtraPagesNames(params: {
|
export function readExtraPagesNames(params: {
|
||||||
@ -41,9 +41,9 @@ export function readExtraPagesNames(params: {
|
|||||||
return extraPages.reduce(...removeDuplicates<string>()).filter(pageId => {
|
return extraPages.reduce(...removeDuplicates<string>()).filter(pageId => {
|
||||||
switch (themeType) {
|
switch (themeType) {
|
||||||
case "account":
|
case "account":
|
||||||
return !id<readonly string[]>(accountThemePageIds).includes(pageId);
|
return !id<readonly string[]>(ACCOUNT_THEME_PAGE_IDS).includes(pageId);
|
||||||
case "login":
|
case "login":
|
||||||
return !id<readonly string[]>(loginThemePageIds).includes(pageId);
|
return !id<readonly string[]>(LOGIN_THEME_PAGE_IDS).includes(pageId);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
@ -3,7 +3,7 @@ import { join as pathJoin, relative as pathRelative, sep as pathSep } from "path
|
|||||||
import * as child_process from "child_process";
|
import * as child_process from "child_process";
|
||||||
import * as fs from "fs";
|
import * as fs from "fs";
|
||||||
import { getBuildContext } from "../shared/buildContext";
|
import { getBuildContext } from "../shared/buildContext";
|
||||||
import { vitePluginSubScriptEnvNames } from "../shared/constants";
|
import { VITE_PLUGIN_SUB_SCRIPTS_ENV_NAMES } from "../shared/constants";
|
||||||
import { buildJars } from "./buildJars";
|
import { buildJars } from "./buildJars";
|
||||||
import type { CliCommandOptions } from "../main";
|
import type { CliCommandOptions } from "../main";
|
||||||
import chalk from "chalk";
|
import chalk from "chalk";
|
||||||
@ -93,10 +93,12 @@ export async function command(params: { cliCommandOptions: CliCommandOptions })
|
|||||||
cwd: buildContext.projectDirPath,
|
cwd: buildContext.projectDirPath,
|
||||||
env: {
|
env: {
|
||||||
...process.env,
|
...process.env,
|
||||||
[vitePluginSubScriptEnvNames.runPostBuildScript]: JSON.stringify({
|
[VITE_PLUGIN_SUB_SCRIPTS_ENV_NAMES.RUN_POST_BUILD_SCRIPT]: JSON.stringify(
|
||||||
resourcesDirPath,
|
{
|
||||||
buildContext
|
resourcesDirPath,
|
||||||
})
|
buildContext
|
||||||
|
}
|
||||||
|
)
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
import type { BuildContext } from "../../shared/buildContext";
|
import type { BuildContext } from "../../shared/buildContext";
|
||||||
import { basenameOfTheKeycloakifyResourcesDir } from "../../shared/constants";
|
import { BASENAME_OF_KEYCLOAKIFY_RESOURCES_DIR } from "../../shared/constants";
|
||||||
import { assert } from "tsafe/assert";
|
import { assert } from "tsafe/assert";
|
||||||
import { posix } from "path";
|
import { posix } from "path";
|
||||||
|
|
||||||
@ -37,7 +37,7 @@ export function replaceImportsInCssCode(params: {
|
|||||||
break inline_style_in_html;
|
break inline_style_in_html;
|
||||||
}
|
}
|
||||||
|
|
||||||
return `url(\${xKeycloakify.resourcesPath}/${basenameOfTheKeycloakifyResourcesDir}${assetFileAbsoluteUrlPathname})`;
|
return `url(\${xKeycloakify.resourcesPath}/${BASENAME_OF_KEYCLOAKIFY_RESOURCES_DIR}${assetFileAbsoluteUrlPathname})`;
|
||||||
}
|
}
|
||||||
|
|
||||||
const assetFileRelativeUrlPathname = posix.relative(
|
const assetFileRelativeUrlPathname = posix.relative(
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
import { basenameOfTheKeycloakifyResourcesDir } from "../../../shared/constants";
|
import { BASENAME_OF_KEYCLOAKIFY_RESOURCES_DIR } from "../../../shared/constants";
|
||||||
import { assert } from "tsafe/assert";
|
import { assert } from "tsafe/assert";
|
||||||
import type { BuildContext } from "../../../shared/buildContext";
|
import type { BuildContext } from "../../../shared/buildContext";
|
||||||
import * as nodePath from "path";
|
import * as nodePath from "path";
|
||||||
@ -85,13 +85,13 @@ export function replaceImportsInJsCode_vite(params: {
|
|||||||
fixedJsCode = replaceAll(
|
fixedJsCode = replaceAll(
|
||||||
fixedJsCode,
|
fixedJsCode,
|
||||||
`"${relativePathOfAssetFile}"`,
|
`"${relativePathOfAssetFile}"`,
|
||||||
`(window.kcContext["x-keycloakify"].resourcesPath.substring(1) + "/${basenameOfTheKeycloakifyResourcesDir}/${relativePathOfAssetFile}")`
|
`(window.kcContext["x-keycloakify"].resourcesPath.substring(1) + "/${BASENAME_OF_KEYCLOAKIFY_RESOURCES_DIR}/${relativePathOfAssetFile}")`
|
||||||
);
|
);
|
||||||
|
|
||||||
fixedJsCode = replaceAll(
|
fixedJsCode = replaceAll(
|
||||||
fixedJsCode,
|
fixedJsCode,
|
||||||
`"${buildContext.urlPathname ?? "/"}${relativePathOfAssetFile}"`,
|
`"${buildContext.urlPathname ?? "/"}${relativePathOfAssetFile}"`,
|
||||||
`(window.kcContext["x-keycloakify"].resourcesPath + "/${basenameOfTheKeycloakifyResourcesDir}/${relativePathOfAssetFile}")`
|
`(window.kcContext["x-keycloakify"].resourcesPath + "/${BASENAME_OF_KEYCLOAKIFY_RESOURCES_DIR}/${relativePathOfAssetFile}")`
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
import { basenameOfTheKeycloakifyResourcesDir } from "../../../shared/constants";
|
import { BASENAME_OF_KEYCLOAKIFY_RESOURCES_DIR } from "../../../shared/constants";
|
||||||
import { assert } from "tsafe/assert";
|
import { assert } from "tsafe/assert";
|
||||||
import type { BuildContext } from "../../../shared/buildContext";
|
import type { BuildContext } from "../../../shared/buildContext";
|
||||||
import * as nodePath from "path";
|
import * as nodePath from "path";
|
||||||
@ -90,7 +90,7 @@ export function replaceImportsInJsCode_webpack(params: {
|
|||||||
return "${u}";
|
return "${u}";
|
||||||
})()] = ${
|
})()] = ${
|
||||||
isArrowFunction ? `${e} =>` : `function(${e}) { return `
|
isArrowFunction ? `${e} =>` : `function(${e}) { return `
|
||||||
} "/${basenameOfTheKeycloakifyResourcesDir}/${staticDir}${language}/"`
|
} "/${BASENAME_OF_KEYCLOAKIFY_RESOURCES_DIR}/${staticDir}${language}/"`
|
||||||
.replace(/\s+/g, " ")
|
.replace(/\s+/g, " ")
|
||||||
.trim();
|
.trim();
|
||||||
}
|
}
|
||||||
@ -104,7 +104,7 @@ export function replaceImportsInJsCode_webpack(params: {
|
|||||||
`[a-zA-Z]+\\.[a-zA-Z]+\\+"${staticDir.replace(/\//g, "\\/")}`,
|
`[a-zA-Z]+\\.[a-zA-Z]+\\+"${staticDir.replace(/\//g, "\\/")}`,
|
||||||
"g"
|
"g"
|
||||||
),
|
),
|
||||||
`window.kcContext["x-keycloakify"].resourcesPath + "/${basenameOfTheKeycloakifyResourcesDir}/${staticDir}`
|
`window.kcContext["x-keycloakify"].resourcesPath + "/${BASENAME_OF_KEYCLOAKIFY_RESOURCES_DIR}/${staticDir}`
|
||||||
);
|
);
|
||||||
|
|
||||||
return { fixedJsCode };
|
return { fixedJsCode };
|
||||||
|
@ -13,13 +13,13 @@ import * as fs from "fs";
|
|||||||
import { assert, type Equals } from "tsafe/assert";
|
import { assert, type Equals } from "tsafe/assert";
|
||||||
import * as child_process from "child_process";
|
import * as child_process from "child_process";
|
||||||
import {
|
import {
|
||||||
vitePluginSubScriptEnvNames,
|
VITE_PLUGIN_SUB_SCRIPTS_ENV_NAMES,
|
||||||
buildForKeycloakMajorVersionEnvName
|
BUILD_FOR_KEYCLOAK_MAJOR_VERSION_ENV_NAME
|
||||||
} from "./constants";
|
} from "./constants";
|
||||||
import type { KeycloakVersionRange } from "./KeycloakVersionRange";
|
import type { KeycloakVersionRange } from "./KeycloakVersionRange";
|
||||||
import { exclude } from "tsafe";
|
import { exclude } from "tsafe";
|
||||||
import { crawl } from "../tools/crawl";
|
import { crawl } from "../tools/crawl";
|
||||||
import { themeTypes } from "./constants";
|
import { THEME_TYPES } from "./constants";
|
||||||
import { objectFromEntries } from "tsafe/objectFromEntries";
|
import { objectFromEntries } from "tsafe/objectFromEntries";
|
||||||
import { objectEntries } from "tsafe/objectEntries";
|
import { objectEntries } from "tsafe/objectEntries";
|
||||||
import { type ThemeType } from "./constants";
|
import { type ThemeType } from "./constants";
|
||||||
@ -136,7 +136,7 @@ export function getBuildContext(params: {
|
|||||||
return { themeSrcDirPath };
|
return { themeSrcDirPath };
|
||||||
}
|
}
|
||||||
|
|
||||||
for (const themeType of [...themeTypes, "email"]) {
|
for (const themeType of [...THEME_TYPES, "email"]) {
|
||||||
if (!fs.existsSync(pathJoin(srcDirPath, themeType))) {
|
if (!fs.existsSync(pathJoin(srcDirPath, themeType))) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
@ -171,18 +171,18 @@ export function getBuildContext(params: {
|
|||||||
cwd: projectDirPath,
|
cwd: projectDirPath,
|
||||||
env: {
|
env: {
|
||||||
...process.env,
|
...process.env,
|
||||||
[vitePluginSubScriptEnvNames.resolveViteConfig]: "true"
|
[VITE_PLUGIN_SUB_SCRIPTS_ENV_NAMES.RESOLVE_VITE_CONFIG]: "true"
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
.toString("utf8");
|
.toString("utf8");
|
||||||
|
|
||||||
assert(
|
assert(
|
||||||
output.includes(vitePluginSubScriptEnvNames.resolveViteConfig),
|
output.includes(VITE_PLUGIN_SUB_SCRIPTS_ENV_NAMES.RESOLVE_VITE_CONFIG),
|
||||||
"Seems like the Keycloakify's Vite plugin is not installed."
|
"Seems like the Keycloakify's Vite plugin is not installed."
|
||||||
);
|
);
|
||||||
|
|
||||||
const resolvedViteConfigStr = output
|
const resolvedViteConfigStr = output
|
||||||
.split(vitePluginSubScriptEnvNames.resolveViteConfig)
|
.split(VITE_PLUGIN_SUB_SCRIPTS_ENV_NAMES.RESOLVE_VITE_CONFIG)
|
||||||
.reverse()[0];
|
.reverse()[0];
|
||||||
|
|
||||||
const resolvedViteConfig: ResolvedViteConfig = JSON.parse(resolvedViteConfigStr);
|
const resolvedViteConfig: ResolvedViteConfig = JSON.parse(resolvedViteConfigStr);
|
||||||
@ -594,7 +594,8 @@ export function getBuildContext(params: {
|
|||||||
|
|
||||||
build_for_specific_keycloak_major_version: {
|
build_for_specific_keycloak_major_version: {
|
||||||
const buildForKeycloakMajorVersionNumber = (() => {
|
const buildForKeycloakMajorVersionNumber = (() => {
|
||||||
const envValue = process.env[buildForKeycloakMajorVersionEnvName];
|
const envValue =
|
||||||
|
process.env[BUILD_FOR_KEYCLOAK_MAJOR_VERSION_ENV_NAME];
|
||||||
|
|
||||||
if (envValue === undefined) {
|
if (envValue === undefined) {
|
||||||
return undefined;
|
return undefined;
|
||||||
|
@ -1,22 +1,22 @@
|
|||||||
export const keycloak_resources = "keycloak-resources";
|
export const KEYCLOAK_RESOURCES = "keycloak-resources";
|
||||||
export const resources_common = "resources-common";
|
export const RESOURCES_COMMON = "resources-common";
|
||||||
export const lastKeycloakVersionWithAccountV1 = "21.1.2";
|
export const LAST_KEYCLOAK_VERSION_WITH_ACCOUNT_V1 = "21.1.2";
|
||||||
export const basenameOfTheKeycloakifyResourcesDir = "dist";
|
export const BASENAME_OF_KEYCLOAKIFY_RESOURCES_DIR = "dist";
|
||||||
|
|
||||||
export const themeTypes = ["login", "account"] as const;
|
export const THEME_TYPES = ["login", "account"] as const;
|
||||||
export const accountV1ThemeName = "account-v1";
|
export const ACCOUNT_V1_THEME_NAME = "account-v1";
|
||||||
|
|
||||||
export type ThemeType = (typeof themeTypes)[number];
|
export type ThemeType = (typeof THEME_TYPES)[number];
|
||||||
|
|
||||||
export const vitePluginSubScriptEnvNames = {
|
export const VITE_PLUGIN_SUB_SCRIPTS_ENV_NAMES = {
|
||||||
runPostBuildScript: "KEYCLOAKIFY_RUN_POST_BUILD_SCRIPT",
|
RUN_POST_BUILD_SCRIPT: "KEYCLOAKIFY_RUN_POST_BUILD_SCRIPT",
|
||||||
resolveViteConfig: "KEYCLOAKIFY_RESOLVE_VITE_CONFIG"
|
RESOLVE_VITE_CONFIG: "KEYCLOAKIFY_RESOLVE_VITE_CONFIG"
|
||||||
} as const;
|
} as const;
|
||||||
|
|
||||||
export const buildForKeycloakMajorVersionEnvName =
|
export const BUILD_FOR_KEYCLOAK_MAJOR_VERSION_ENV_NAME =
|
||||||
"KEYCLOAKIFY_BUILD_FOR_KEYCLOAK_MAJOR_VERSION";
|
"KEYCLOAKIFY_BUILD_FOR_KEYCLOAK_MAJOR_VERSION";
|
||||||
|
|
||||||
export const loginThemePageIds = [
|
export const LOGIN_THEME_PAGE_IDS = [
|
||||||
"login.ftl",
|
"login.ftl",
|
||||||
"login-username.ftl",
|
"login-username.ftl",
|
||||||
"login-password.ftl",
|
"login-password.ftl",
|
||||||
@ -53,7 +53,7 @@ export const loginThemePageIds = [
|
|||||||
"webauthn-error.ftl"
|
"webauthn-error.ftl"
|
||||||
] as const;
|
] as const;
|
||||||
|
|
||||||
export const accountThemePageIds = [
|
export const ACCOUNT_THEME_PAGE_IDS = [
|
||||||
"password.ftl",
|
"password.ftl",
|
||||||
"account.ftl",
|
"account.ftl",
|
||||||
"sessions.ftl",
|
"sessions.ftl",
|
||||||
@ -63,9 +63,9 @@ export const accountThemePageIds = [
|
|||||||
"federatedIdentity.ftl"
|
"federatedIdentity.ftl"
|
||||||
] as const;
|
] as const;
|
||||||
|
|
||||||
export type LoginThemePageId = (typeof loginThemePageIds)[number];
|
export type LoginThemePageId = (typeof LOGIN_THEME_PAGE_IDS)[number];
|
||||||
export type AccountThemePageId = (typeof accountThemePageIds)[number];
|
export type AccountThemePageId = (typeof ACCOUNT_THEME_PAGE_IDS)[number];
|
||||||
|
|
||||||
export const containerName = "keycloak-keycloakify";
|
export const CONTAINER_NAME = "keycloak-keycloakify";
|
||||||
|
|
||||||
export const fallbackLanguageTag = "en";
|
export const FALLBACK_LANGUAGE_TAG = "en";
|
||||||
|
@ -4,9 +4,9 @@ import {
|
|||||||
} from "./downloadKeycloakStaticResources";
|
} from "./downloadKeycloakStaticResources";
|
||||||
import { join as pathJoin, relative as pathRelative } from "path";
|
import { join as pathJoin, relative as pathRelative } from "path";
|
||||||
import {
|
import {
|
||||||
themeTypes,
|
THEME_TYPES,
|
||||||
keycloak_resources,
|
KEYCLOAK_RESOURCES,
|
||||||
lastKeycloakVersionWithAccountV1
|
LAST_KEYCLOAK_VERSION_WITH_ACCOUNT_V1
|
||||||
} from "../shared/constants";
|
} from "../shared/constants";
|
||||||
import { readThisNpmPackageVersion } from "../tools/readThisNpmPackageVersion";
|
import { readThisNpmPackageVersion } from "../tools/readThisNpmPackageVersion";
|
||||||
import { assert } from "tsafe/assert";
|
import { assert } from "tsafe/assert";
|
||||||
@ -26,7 +26,7 @@ export async function copyKeycloakResourcesToPublic(params: {
|
|||||||
}) {
|
}) {
|
||||||
const { buildContext } = params;
|
const { buildContext } = params;
|
||||||
|
|
||||||
const destDirPath = pathJoin(buildContext.publicDirPath, keycloak_resources);
|
const destDirPath = pathJoin(buildContext.publicDirPath, KEYCLOAK_RESOURCES);
|
||||||
|
|
||||||
const keycloakifyBuildinfoFilePath = pathJoin(destDirPath, "keycloakify.buildinfo");
|
const keycloakifyBuildinfoFilePath = pathJoin(destDirPath, "keycloakify.buildinfo");
|
||||||
|
|
||||||
@ -66,14 +66,14 @@ export async function copyKeycloakResourcesToPublic(params: {
|
|||||||
|
|
||||||
fs.writeFileSync(pathJoin(destDirPath, ".gitignore"), Buffer.from("*", "utf8"));
|
fs.writeFileSync(pathJoin(destDirPath, ".gitignore"), Buffer.from("*", "utf8"));
|
||||||
|
|
||||||
for (const themeType of themeTypes) {
|
for (const themeType of THEME_TYPES) {
|
||||||
await downloadKeycloakStaticResources({
|
await downloadKeycloakStaticResources({
|
||||||
keycloakVersion: (() => {
|
keycloakVersion: (() => {
|
||||||
switch (themeType) {
|
switch (themeType) {
|
||||||
case "login":
|
case "login":
|
||||||
return buildContext.loginThemeResourcesFromKeycloakVersion;
|
return buildContext.loginThemeResourcesFromKeycloakVersion;
|
||||||
case "account":
|
case "account":
|
||||||
return lastKeycloakVersionWithAccountV1;
|
return LAST_KEYCLOAK_VERSION_WITH_ACCOUNT_V1;
|
||||||
}
|
}
|
||||||
})(),
|
})(),
|
||||||
themeType,
|
themeType,
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
import { join as pathJoin, relative as pathRelative } from "path";
|
import { join as pathJoin, relative as pathRelative } from "path";
|
||||||
import { type BuildContext } from "./buildContext";
|
import { type BuildContext } from "./buildContext";
|
||||||
import { assert } from "tsafe/assert";
|
import { assert } from "tsafe/assert";
|
||||||
import { lastKeycloakVersionWithAccountV1 } from "./constants";
|
import { LAST_KEYCLOAK_VERSION_WITH_ACCOUNT_V1 } from "./constants";
|
||||||
import { downloadAndExtractArchive } from "../tools/downloadAndExtractArchive";
|
import { downloadAndExtractArchive } from "../tools/downloadAndExtractArchive";
|
||||||
|
|
||||||
export type BuildContextLike = {
|
export type BuildContextLike = {
|
||||||
@ -43,7 +43,7 @@ export async function downloadKeycloakDefaultTheme(params: {
|
|||||||
}
|
}
|
||||||
|
|
||||||
last_account_v1_transformations: {
|
last_account_v1_transformations: {
|
||||||
if (lastKeycloakVersionWithAccountV1 !== keycloakVersion) {
|
if (LAST_KEYCLOAK_VERSION_WITH_ACCOUNT_V1 !== keycloakVersion) {
|
||||||
break last_account_v1_transformations;
|
break last_account_v1_transformations;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -4,7 +4,7 @@ import {
|
|||||||
downloadKeycloakDefaultTheme,
|
downloadKeycloakDefaultTheme,
|
||||||
type BuildContextLike as BuildContextLike_downloadKeycloakDefaultTheme
|
type BuildContextLike as BuildContextLike_downloadKeycloakDefaultTheme
|
||||||
} from "./downloadKeycloakDefaultTheme";
|
} from "./downloadKeycloakDefaultTheme";
|
||||||
import { resources_common, type ThemeType } from "./constants";
|
import { RESOURCES_COMMON, type ThemeType } from "./constants";
|
||||||
import type { BuildContext } from "./buildContext";
|
import type { BuildContext } from "./buildContext";
|
||||||
import { assert } from "tsafe/assert";
|
import { assert } from "tsafe/assert";
|
||||||
import { existsAsync } from "../tools/fs.existsAsync";
|
import { existsAsync } from "../tools/fs.existsAsync";
|
||||||
@ -48,6 +48,6 @@ export async function downloadKeycloakStaticResources(params: {
|
|||||||
|
|
||||||
transformCodebase({
|
transformCodebase({
|
||||||
srcDirPath: pathJoin(defaultThemeDirPath, "keycloak", "common", "resources"),
|
srcDirPath: pathJoin(defaultThemeDirPath, "keycloak", "common", "resources"),
|
||||||
destDirPath: pathJoin(resourcesDirPath, resources_common)
|
destDirPath: pathJoin(resourcesDirPath, RESOURCES_COMMON)
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
import { buildForKeycloakMajorVersionEnvName } from "../shared/constants";
|
import { BUILD_FOR_KEYCLOAK_MAJOR_VERSION_ENV_NAME } from "../shared/constants";
|
||||||
import * as child_process from "child_process";
|
import * as child_process from "child_process";
|
||||||
import { Deferred } from "evt/tools/Deferred";
|
import { Deferred } from "evt/tools/Deferred";
|
||||||
import { assert } from "tsafe/assert";
|
import { assert } from "tsafe/assert";
|
||||||
@ -26,7 +26,7 @@ export async function keycloakifyBuild(params: {
|
|||||||
cwd: buildContext.projectDirPath,
|
cwd: buildContext.projectDirPath,
|
||||||
env: {
|
env: {
|
||||||
...process.env,
|
...process.env,
|
||||||
[buildForKeycloakMajorVersionEnvName]: `${buildForKeycloakMajorVersionNumber}`
|
[BUILD_FOR_KEYCLOAK_MAJOR_VERSION_ENV_NAME]: `${buildForKeycloakMajorVersionNumber}`
|
||||||
},
|
},
|
||||||
shell: true
|
shell: true
|
||||||
});
|
});
|
||||||
|
@ -2,7 +2,7 @@ import { getBuildContext } from "../shared/buildContext";
|
|||||||
import { exclude } from "tsafe/exclude";
|
import { exclude } from "tsafe/exclude";
|
||||||
import type { CliCommandOptions as CliCommandOptions_common } from "../main";
|
import type { CliCommandOptions as CliCommandOptions_common } from "../main";
|
||||||
import { promptKeycloakVersion } from "../shared/promptKeycloakVersion";
|
import { promptKeycloakVersion } from "../shared/promptKeycloakVersion";
|
||||||
import { accountV1ThemeName, containerName } from "../shared/constants";
|
import { ACCOUNT_V1_THEME_NAME, CONTAINER_NAME } from "../shared/constants";
|
||||||
import { SemVer } from "../tools/SemVer";
|
import { SemVer } from "../tools/SemVer";
|
||||||
import { assert } from "tsafe/assert";
|
import { assert } from "tsafe/assert";
|
||||||
import * as fs from "fs";
|
import * as fs from "fs";
|
||||||
@ -269,7 +269,7 @@ export async function command(params: { cliCommandOptions: CliCommandOptions })
|
|||||||
fs.copyFileSync(jarFilePath, jarFilePath_cacheDir);
|
fs.copyFileSync(jarFilePath, jarFilePath_cacheDir);
|
||||||
|
|
||||||
try {
|
try {
|
||||||
child_process.execSync(`docker rm --force ${containerName}`, {
|
child_process.execSync(`docker rm --force ${CONTAINER_NAME}`, {
|
||||||
stdio: "ignore"
|
stdio: "ignore"
|
||||||
});
|
});
|
||||||
} catch {}
|
} catch {}
|
||||||
@ -279,7 +279,7 @@ export async function command(params: { cliCommandOptions: CliCommandOptions })
|
|||||||
[
|
[
|
||||||
"run",
|
"run",
|
||||||
...["-p", `${cliCommandOptions.port}:8080`],
|
...["-p", `${cliCommandOptions.port}:8080`],
|
||||||
...["--name", containerName],
|
...["--name", CONTAINER_NAME],
|
||||||
...["-e", "KEYCLOAK_ADMIN=admin"],
|
...["-e", "KEYCLOAK_ADMIN=admin"],
|
||||||
...["-e", "KEYCLOAK_ADMIN_PASSWORD=admin"],
|
...["-e", "KEYCLOAK_ADMIN_PASSWORD=admin"],
|
||||||
...(realmJsonFilePath === undefined
|
...(realmJsonFilePath === undefined
|
||||||
@ -301,10 +301,10 @@ export async function command(params: { cliCommandOptions: CliCommandOptions })
|
|||||||
pathJoin(
|
pathJoin(
|
||||||
buildContext.keycloakifyBuildDirPath,
|
buildContext.keycloakifyBuildDirPath,
|
||||||
"theme",
|
"theme",
|
||||||
accountV1ThemeName
|
ACCOUNT_V1_THEME_NAME
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
? [accountV1ThemeName]
|
? [ACCOUNT_V1_THEME_NAME]
|
||||||
: [])
|
: [])
|
||||||
]
|
]
|
||||||
.map(themeName => ({
|
.map(themeName => ({
|
||||||
|
@ -1,8 +1,8 @@
|
|||||||
import "keycloakify/tools/Object.fromEntries";
|
import "keycloakify/tools/Object.fromEntries";
|
||||||
import type { KcContext, Attribute } from "./KcContext";
|
import type { KcContext, Attribute } from "./KcContext";
|
||||||
import {
|
import {
|
||||||
resources_common,
|
RESOURCES_COMMON,
|
||||||
keycloak_resources,
|
KEYCLOAK_RESOURCES,
|
||||||
type LoginThemePageId
|
type LoginThemePageId
|
||||||
} from "keycloakify/bin/shared/constants";
|
} from "keycloakify/bin/shared/constants";
|
||||||
import { id } from "tsafe/id";
|
import { id } from "tsafe/id";
|
||||||
@ -76,7 +76,7 @@ const attributesByName = Object.fromEntries(
|
|||||||
]).map(attribute => [attribute.name, attribute])
|
]).map(attribute => [attribute.name, attribute])
|
||||||
);
|
);
|
||||||
|
|
||||||
const resourcesPath = `${BASE_URL}${keycloak_resources}/login/resources`;
|
const resourcesPath = `${BASE_URL}${KEYCLOAK_RESOURCES}/login/resources`;
|
||||||
|
|
||||||
export const kcContextCommonMock: KcContext.Common = {
|
export const kcContextCommonMock: KcContext.Common = {
|
||||||
themeVersion: "0.0.0",
|
themeVersion: "0.0.0",
|
||||||
@ -86,7 +86,7 @@ export const kcContextCommonMock: KcContext.Common = {
|
|||||||
url: {
|
url: {
|
||||||
loginAction: "#",
|
loginAction: "#",
|
||||||
resourcesPath,
|
resourcesPath,
|
||||||
resourcesCommonPath: `${resourcesPath}/${resources_common}`,
|
resourcesCommonPath: `${resourcesPath}/${RESOURCES_COMMON}`,
|
||||||
loginRestartFlowUrl: "#",
|
loginRestartFlowUrl: "#",
|
||||||
loginUrl: "#",
|
loginUrl: "#",
|
||||||
ssoLoginInOtherTabsUrl: "#"
|
ssoLoginInOtherTabsUrl: "#"
|
||||||
|
@ -3,7 +3,7 @@ import { assert } from "tsafe/assert";
|
|||||||
import messages_defaultSet_fallbackLanguage from "./messages_defaultSet/en";
|
import messages_defaultSet_fallbackLanguage from "./messages_defaultSet/en";
|
||||||
import { fetchMessages_defaultSet } from "./messages_defaultSet";
|
import { fetchMessages_defaultSet } from "./messages_defaultSet";
|
||||||
import type { KcContext } from "../KcContext";
|
import type { KcContext } from "../KcContext";
|
||||||
import { fallbackLanguageTag } from "keycloakify/bin/shared/constants";
|
import { FALLBACK_LANGUAGE_TAG } from "keycloakify/bin/shared/constants";
|
||||||
import { id } from "tsafe/id";
|
import { id } from "tsafe/id";
|
||||||
|
|
||||||
export type KcContextLike = {
|
export type KcContextLike = {
|
||||||
@ -104,7 +104,7 @@ export function createGetI18n<MessageKey_themeDefined extends string = never>(me
|
|||||||
}
|
}
|
||||||
|
|
||||||
const partialI18n: Pick<I18n, "currentLanguageTag" | "getChangeLocaleUrl" | "labelBySupportedLanguageTag"> = {
|
const partialI18n: Pick<I18n, "currentLanguageTag" | "getChangeLocaleUrl" | "labelBySupportedLanguageTag"> = {
|
||||||
currentLanguageTag: kcContext.locale?.currentLanguageTag ?? fallbackLanguageTag,
|
currentLanguageTag: kcContext.locale?.currentLanguageTag ?? FALLBACK_LANGUAGE_TAG,
|
||||||
getChangeLocaleUrl: newLanguageTag => {
|
getChangeLocaleUrl: newLanguageTag => {
|
||||||
const { locale } = kcContext;
|
const { locale } = kcContext;
|
||||||
|
|
||||||
@ -122,7 +122,7 @@ export function createGetI18n<MessageKey_themeDefined extends string = never>(me
|
|||||||
const { createI18nTranslationFunctions } = createI18nTranslationFunctionsFactory<MessageKey_themeDefined>({
|
const { createI18nTranslationFunctions } = createI18nTranslationFunctionsFactory<MessageKey_themeDefined>({
|
||||||
messages_themeDefined:
|
messages_themeDefined:
|
||||||
messagesByLanguageTag_themeDefined[partialI18n.currentLanguageTag] ??
|
messagesByLanguageTag_themeDefined[partialI18n.currentLanguageTag] ??
|
||||||
messagesByLanguageTag_themeDefined[fallbackLanguageTag] ??
|
messagesByLanguageTag_themeDefined[FALLBACK_LANGUAGE_TAG] ??
|
||||||
(() => {
|
(() => {
|
||||||
const firstLanguageTag = Object.keys(messagesByLanguageTag_themeDefined)[0];
|
const firstLanguageTag = Object.keys(messagesByLanguageTag_themeDefined)[0];
|
||||||
if (firstLanguageTag === undefined) {
|
if (firstLanguageTag === undefined) {
|
||||||
@ -133,7 +133,7 @@ export function createGetI18n<MessageKey_themeDefined extends string = never>(me
|
|||||||
messages_fromKcServer: kcContext["x-keycloakify"].messages
|
messages_fromKcServer: kcContext["x-keycloakify"].messages
|
||||||
});
|
});
|
||||||
|
|
||||||
const isCurrentLanguageFallbackLanguage = partialI18n.currentLanguageTag === fallbackLanguageTag;
|
const isCurrentLanguageFallbackLanguage = partialI18n.currentLanguageTag === FALLBACK_LANGUAGE_TAG;
|
||||||
|
|
||||||
const result: Result = {
|
const result: Result = {
|
||||||
i18n: {
|
i18n: {
|
||||||
|
@ -1,9 +1,9 @@
|
|||||||
import { join as pathJoin, relative as pathRelative, sep as pathSep } from "path";
|
import { join as pathJoin, relative as pathRelative, sep as pathSep } from "path";
|
||||||
import type { Plugin } from "vite";
|
import type { Plugin } from "vite";
|
||||||
import {
|
import {
|
||||||
basenameOfTheKeycloakifyResourcesDir,
|
BASENAME_OF_KEYCLOAKIFY_RESOURCES_DIR,
|
||||||
keycloak_resources,
|
KEYCLOAK_RESOURCES,
|
||||||
vitePluginSubScriptEnvNames
|
VITE_PLUGIN_SUB_SCRIPTS_ENV_NAMES
|
||||||
} from "../bin/shared/constants";
|
} from "../bin/shared/constants";
|
||||||
import { id } from "tsafe/id";
|
import { id } from "tsafe/id";
|
||||||
import { rm } from "../bin/tools/fs.rm";
|
import { rm } from "../bin/tools/fs.rm";
|
||||||
@ -38,7 +38,7 @@ export function keycloakify(params?: Params) {
|
|||||||
|
|
||||||
run_post_build_script_case: {
|
run_post_build_script_case: {
|
||||||
const envValue =
|
const envValue =
|
||||||
process.env[vitePluginSubScriptEnvNames.runPostBuildScript];
|
process.env[VITE_PLUGIN_SUB_SCRIPTS_ENV_NAMES.RUN_POST_BUILD_SCRIPT];
|
||||||
|
|
||||||
if (envValue === undefined) {
|
if (envValue === undefined) {
|
||||||
break run_post_build_script_case;
|
break run_post_build_script_case;
|
||||||
@ -94,13 +94,13 @@ export function keycloakify(params?: Params) {
|
|||||||
|
|
||||||
resolve_vite_config_case: {
|
resolve_vite_config_case: {
|
||||||
const envValue =
|
const envValue =
|
||||||
process.env[vitePluginSubScriptEnvNames.resolveViteConfig];
|
process.env[VITE_PLUGIN_SUB_SCRIPTS_ENV_NAMES.RESOLVE_VITE_CONFIG];
|
||||||
|
|
||||||
if (envValue === undefined) {
|
if (envValue === undefined) {
|
||||||
break resolve_vite_config_case;
|
break resolve_vite_config_case;
|
||||||
}
|
}
|
||||||
|
|
||||||
console.log(vitePluginSubScriptEnvNames.resolveViteConfig);
|
console.log(VITE_PLUGIN_SUB_SCRIPTS_ENV_NAMES.RESOLVE_VITE_CONFIG);
|
||||||
|
|
||||||
console.log(
|
console.log(
|
||||||
JSON.stringify(
|
JSON.stringify(
|
||||||
@ -172,7 +172,7 @@ export function keycloakify(params?: Params) {
|
|||||||
`(`,
|
`(`,
|
||||||
`(window.kcContext === undefined || import.meta.env.MODE === "development")?`,
|
`(window.kcContext === undefined || import.meta.env.MODE === "development")?`,
|
||||||
`"${urlPathname ?? "/"}":`,
|
`"${urlPathname ?? "/"}":`,
|
||||||
`(window.kcContext["x-keycloakify"].resourcesPath + "/${basenameOfTheKeycloakifyResourcesDir}/")`,
|
`(window.kcContext["x-keycloakify"].resourcesPath + "/${BASENAME_OF_KEYCLOAKIFY_RESOURCES_DIR}/")`,
|
||||||
`)`
|
`)`
|
||||||
].join("")
|
].join("")
|
||||||
);
|
);
|
||||||
@ -205,7 +205,7 @@ export function keycloakify(params?: Params) {
|
|||||||
|
|
||||||
assert(buildDirPath !== undefined);
|
assert(buildDirPath !== undefined);
|
||||||
|
|
||||||
await rm(pathJoin(buildDirPath, keycloak_resources), {
|
await rm(pathJoin(buildDirPath, KEYCLOAK_RESOURCES), {
|
||||||
recursive: true,
|
recursive: true,
|
||||||
force: true
|
force: true
|
||||||
});
|
});
|
||||||
|
@ -2,7 +2,7 @@ import { replaceImportsInJsCode_vite } from "keycloakify/bin/keycloakify/replace
|
|||||||
import { replaceImportsInJsCode_webpack } from "keycloakify/bin/keycloakify/replacers/replaceImportsInJsCode/webpack";
|
import { replaceImportsInJsCode_webpack } from "keycloakify/bin/keycloakify/replacers/replaceImportsInJsCode/webpack";
|
||||||
import { replaceImportsInCssCode } from "keycloakify/bin/keycloakify/replacers/replaceImportsInCssCode";
|
import { replaceImportsInCssCode } from "keycloakify/bin/keycloakify/replacers/replaceImportsInCssCode";
|
||||||
import { expect, it, describe } from "vitest";
|
import { expect, it, describe } from "vitest";
|
||||||
import { basenameOfTheKeycloakifyResourcesDir } from "keycloakify/bin/shared/constants";
|
import { BASENAME_OF_KEYCLOAKIFY_RESOURCES_DIR } from "keycloakify/bin/shared/constants";
|
||||||
|
|
||||||
describe("js replacer - vite", () => {
|
describe("js replacer - vite", () => {
|
||||||
it("replaceImportsInJsCode_vite - 1", () => {
|
it("replaceImportsInJsCode_vite - 1", () => {
|
||||||
@ -87,13 +87,13 @@ describe("js replacer - vite", () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
const fixedJsCodeExpected = `
|
const fixedJsCodeExpected = `
|
||||||
S=(window.kcContext["x-keycloakify"].resourcesPath + "/${basenameOfTheKeycloakifyResourcesDir}/assets/keycloakify-logo-mqjydaoZ.png"),H=(()=>{
|
S=(window.kcContext["x-keycloakify"].resourcesPath + "/${BASENAME_OF_KEYCLOAKIFY_RESOURCES_DIR}/assets/keycloakify-logo-mqjydaoZ.png"),H=(()=>{
|
||||||
|
|
||||||
function __vite__mapDeps(indexes) {
|
function __vite__mapDeps(indexes) {
|
||||||
if (!__vite__mapDeps.viteFileDeps) {
|
if (!__vite__mapDeps.viteFileDeps) {
|
||||||
__vite__mapDeps.viteFileDeps = [
|
__vite__mapDeps.viteFileDeps = [
|
||||||
(window.kcContext["x-keycloakify"].resourcesPath.substring(1) + "/${basenameOfTheKeycloakifyResourcesDir}/assets/Login-dJpPRzM4.js"),
|
(window.kcContext["x-keycloakify"].resourcesPath.substring(1) + "/${BASENAME_OF_KEYCLOAKIFY_RESOURCES_DIR}/assets/Login-dJpPRzM4.js"),
|
||||||
(window.kcContext["x-keycloakify"].resourcesPath.substring(1) + "/${basenameOfTheKeycloakifyResourcesDir}/assets/index-XwzrZ5Gu.js")
|
(window.kcContext["x-keycloakify"].resourcesPath.substring(1) + "/${BASENAME_OF_KEYCLOAKIFY_RESOURCES_DIR}/assets/index-XwzrZ5Gu.js")
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
return indexes.map((i) => __vite__mapDeps.viteFileDeps[i])
|
return indexes.map((i) => __vite__mapDeps.viteFileDeps[i])
|
||||||
@ -146,13 +146,13 @@ describe("js replacer - vite", () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
const fixedJsCodeExpected = `
|
const fixedJsCodeExpected = `
|
||||||
S=(window.kcContext["x-keycloakify"].resourcesPath + "/${basenameOfTheKeycloakifyResourcesDir}/foo/bar/keycloakify-logo-mqjydaoZ.png"),H=(()=>{
|
S=(window.kcContext["x-keycloakify"].resourcesPath + "/${BASENAME_OF_KEYCLOAKIFY_RESOURCES_DIR}/foo/bar/keycloakify-logo-mqjydaoZ.png"),H=(()=>{
|
||||||
|
|
||||||
function __vite__mapDeps(indexes) {
|
function __vite__mapDeps(indexes) {
|
||||||
if (!__vite__mapDeps.viteFileDeps) {
|
if (!__vite__mapDeps.viteFileDeps) {
|
||||||
__vite__mapDeps.viteFileDeps = [
|
__vite__mapDeps.viteFileDeps = [
|
||||||
(window.kcContext["x-keycloakify"].resourcesPath.substring(1) + "/${basenameOfTheKeycloakifyResourcesDir}/foo/bar/Login-dJpPRzM4.js"),
|
(window.kcContext["x-keycloakify"].resourcesPath.substring(1) + "/${BASENAME_OF_KEYCLOAKIFY_RESOURCES_DIR}/foo/bar/Login-dJpPRzM4.js"),
|
||||||
(window.kcContext["x-keycloakify"].resourcesPath.substring(1) + "/${basenameOfTheKeycloakifyResourcesDir}/foo/bar/index-XwzrZ5Gu.js")
|
(window.kcContext["x-keycloakify"].resourcesPath.substring(1) + "/${BASENAME_OF_KEYCLOAKIFY_RESOURCES_DIR}/foo/bar/index-XwzrZ5Gu.js")
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
return indexes.map((i) => __vite__mapDeps.viteFileDeps[i])
|
return indexes.map((i) => __vite__mapDeps.viteFileDeps[i])
|
||||||
@ -205,13 +205,13 @@ describe("js replacer - vite", () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
const fixedJsCodeExpected = `
|
const fixedJsCodeExpected = `
|
||||||
S=(window.kcContext["x-keycloakify"].resourcesPath + "/${basenameOfTheKeycloakifyResourcesDir}/assets/keycloakify-logo-mqjydaoZ.png"),H=(()=>{
|
S=(window.kcContext["x-keycloakify"].resourcesPath + "/${BASENAME_OF_KEYCLOAKIFY_RESOURCES_DIR}/assets/keycloakify-logo-mqjydaoZ.png"),H=(()=>{
|
||||||
|
|
||||||
function __vite__mapDeps(indexes) {
|
function __vite__mapDeps(indexes) {
|
||||||
if (!__vite__mapDeps.viteFileDeps) {
|
if (!__vite__mapDeps.viteFileDeps) {
|
||||||
__vite__mapDeps.viteFileDeps = [
|
__vite__mapDeps.viteFileDeps = [
|
||||||
(window.kcContext["x-keycloakify"].resourcesPath.substring(1) + "/${basenameOfTheKeycloakifyResourcesDir}/assets/Login-dJpPRzM4.js"),
|
(window.kcContext["x-keycloakify"].resourcesPath.substring(1) + "/${BASENAME_OF_KEYCLOAKIFY_RESOURCES_DIR}/assets/Login-dJpPRzM4.js"),
|
||||||
(window.kcContext["x-keycloakify"].resourcesPath.substring(1) + "/${basenameOfTheKeycloakifyResourcesDir}/assets/index-XwzrZ5Gu.js")
|
(window.kcContext["x-keycloakify"].resourcesPath.substring(1) + "/${BASENAME_OF_KEYCLOAKIFY_RESOURCES_DIR}/assets/index-XwzrZ5Gu.js")
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
return indexes.map((i) => __vite__mapDeps.viteFileDeps[i])
|
return indexes.map((i) => __vite__mapDeps.viteFileDeps[i])
|
||||||
@ -267,13 +267,13 @@ describe("js replacer - webpack", () => {
|
|||||||
|
|
||||||
const fixedJsCodeExpected = `
|
const fixedJsCodeExpected = `
|
||||||
function f() {
|
function f() {
|
||||||
return window.kcContext["x-keycloakify"].resourcesPath + "/${basenameOfTheKeycloakifyResourcesDir}/static/js/" + ({}[e] || e) + "." + {
|
return window.kcContext["x-keycloakify"].resourcesPath + "/${BASENAME_OF_KEYCLOAKIFY_RESOURCES_DIR}/static/js/" + ({}[e] || e) + "." + {
|
||||||
3: "0664cdc0"
|
3: "0664cdc0"
|
||||||
}[e] + ".chunk.js"
|
}[e] + ".chunk.js"
|
||||||
}
|
}
|
||||||
|
|
||||||
function sameAsF() {
|
function sameAsF() {
|
||||||
return window.kcContext["x-keycloakify"].resourcesPath + "/${basenameOfTheKeycloakifyResourcesDir}/static/js/" + ({}[e] || e) + "." + {
|
return window.kcContext["x-keycloakify"].resourcesPath + "/${BASENAME_OF_KEYCLOAKIFY_RESOURCES_DIR}/static/js/" + ({}[e] || e) + "." + {
|
||||||
3: "0664cdc0"
|
3: "0664cdc0"
|
||||||
}[e] + ".chunk.js"
|
}[e] + ".chunk.js"
|
||||||
}
|
}
|
||||||
@ -288,7 +288,7 @@ describe("js replacer - webpack", () => {
|
|||||||
}
|
}
|
||||||
return "u";
|
return "u";
|
||||||
})()] = function(e) {
|
})()] = function(e) {
|
||||||
return "/${basenameOfTheKeycloakifyResourcesDir}/static/js/" + e + "." + {
|
return "/${BASENAME_OF_KEYCLOAKIFY_RESOURCES_DIR}/static/js/" + e + "." + {
|
||||||
147: "6c5cee76",
|
147: "6c5cee76",
|
||||||
787: "8da10fcf",
|
787: "8da10fcf",
|
||||||
922: "be170a73"
|
922: "be170a73"
|
||||||
@ -305,7 +305,7 @@ describe("js replacer - webpack", () => {
|
|||||||
}
|
}
|
||||||
return "miniCssF";
|
return "miniCssF";
|
||||||
})()] = function(e) {
|
})()] = function(e) {
|
||||||
return "/${basenameOfTheKeycloakifyResourcesDir}/static/css/" + e + "." + {
|
return "/${BASENAME_OF_KEYCLOAKIFY_RESOURCES_DIR}/static/css/" + e + "." + {
|
||||||
164:"dcfd7749",
|
164:"dcfd7749",
|
||||||
908:"67c9ed2c"
|
908:"67c9ed2c"
|
||||||
} [e] + ".chunk.css"
|
} [e] + ".chunk.css"
|
||||||
@ -320,7 +320,7 @@ describe("js replacer - webpack", () => {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
return "u";
|
return "u";
|
||||||
})()] = e => "/${basenameOfTheKeycloakifyResourcesDir}/static/js/"+e+"."+{69:"4f205f87",128:"49264537",453:"b2fed72e",482:"f0106901"}[e]+".chunk.js"
|
})()] = e => "/${BASENAME_OF_KEYCLOAKIFY_RESOURCES_DIR}/static/js/"+e+"."+{69:"4f205f87",128:"49264537",453:"b2fed72e",482:"f0106901"}[e]+".chunk.js"
|
||||||
|
|
||||||
t[(function(){
|
t[(function(){
|
||||||
var pd = Object.getOwnPropertyDescriptor(t, "p");
|
var pd = Object.getOwnPropertyDescriptor(t, "p");
|
||||||
@ -331,7 +331,7 @@ describe("js replacer - webpack", () => {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
return "miniCssF";
|
return "miniCssF";
|
||||||
})()] = e => "/${basenameOfTheKeycloakifyResourcesDir}/static/css/"+e+"."+{164:"dcfd7749",908:"67c9ed2c"}[e]+".chunk.css"
|
})()] = e => "/${BASENAME_OF_KEYCLOAKIFY_RESOURCES_DIR}/static/css/"+e+"."+{164:"dcfd7749",908:"67c9ed2c"}[e]+".chunk.css"
|
||||||
`;
|
`;
|
||||||
|
|
||||||
expect(isSameCode(fixedJsCode, fixedJsCodeExpected)).toBe(true);
|
expect(isSameCode(fixedJsCode, fixedJsCodeExpected)).toBe(true);
|
||||||
@ -479,15 +479,15 @@ describe("css replacer", () => {
|
|||||||
|
|
||||||
const fixedCssCodeExpected = `
|
const fixedCssCodeExpected = `
|
||||||
.my-div {
|
.my-div {
|
||||||
background: url(\${xKeycloakify.resourcesPath}/${basenameOfTheKeycloakifyResourcesDir}/background.png) no-repeat center center;
|
background: url(\${xKeycloakify.resourcesPath}/${BASENAME_OF_KEYCLOAKIFY_RESOURCES_DIR}/background.png) no-repeat center center;
|
||||||
}
|
}
|
||||||
|
|
||||||
.my-div2 {
|
.my-div2 {
|
||||||
background: url(\${xKeycloakify.resourcesPath}/${basenameOfTheKeycloakifyResourcesDir}/assets/background.png) repeat center center;
|
background: url(\${xKeycloakify.resourcesPath}/${BASENAME_OF_KEYCLOAKIFY_RESOURCES_DIR}/assets/background.png) repeat center center;
|
||||||
}
|
}
|
||||||
|
|
||||||
.my-div3 {
|
.my-div3 {
|
||||||
background-image: url(\${xKeycloakify.resourcesPath}/${basenameOfTheKeycloakifyResourcesDir}/assets/media/something.svg);
|
background-image: url(\${xKeycloakify.resourcesPath}/${BASENAME_OF_KEYCLOAKIFY_RESOURCES_DIR}/assets/media/something.svg);
|
||||||
}
|
}
|
||||||
`;
|
`;
|
||||||
|
|
||||||
@ -517,15 +517,15 @@ describe("css replacer", () => {
|
|||||||
|
|
||||||
const fixedCssCodeExpected = `
|
const fixedCssCodeExpected = `
|
||||||
.my-div {
|
.my-div {
|
||||||
background: url(\${xKeycloakify.resourcesPath}/${basenameOfTheKeycloakifyResourcesDir}/background.png) no-repeat center center;
|
background: url(\${xKeycloakify.resourcesPath}/${BASENAME_OF_KEYCLOAKIFY_RESOURCES_DIR}/background.png) no-repeat center center;
|
||||||
}
|
}
|
||||||
|
|
||||||
.my-div2 {
|
.my-div2 {
|
||||||
background: url(\${xKeycloakify.resourcesPath}/${basenameOfTheKeycloakifyResourcesDir}/assets/background.png) repeat center center;
|
background: url(\${xKeycloakify.resourcesPath}/${BASENAME_OF_KEYCLOAKIFY_RESOURCES_DIR}/assets/background.png) repeat center center;
|
||||||
}
|
}
|
||||||
|
|
||||||
.my-div3 {
|
.my-div3 {
|
||||||
background-image: url(\${xKeycloakify.resourcesPath}/${basenameOfTheKeycloakifyResourcesDir}/assets/media/something.svg);
|
background-image: url(\${xKeycloakify.resourcesPath}/${BASENAME_OF_KEYCLOAKIFY_RESOURCES_DIR}/assets/media/something.svg);
|
||||||
}
|
}
|
||||||
`;
|
`;
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user