Rename BuildOptions -> BuildContext
This commit is contained in:
parent
3453a17c15
commit
25c8599d8f
@ -15,13 +15,13 @@ import { kebabCaseToCamelCase } from "./tools/kebabCaseToSnakeCase";
|
|||||||
import { assert, Equals } from "tsafe/assert";
|
import { assert, Equals } from "tsafe/assert";
|
||||||
import { getThemeSrcDirPath } from "./shared/getThemeSrcDirPath";
|
import { getThemeSrcDirPath } from "./shared/getThemeSrcDirPath";
|
||||||
import type { CliCommandOptions } from "./main";
|
import type { CliCommandOptions } from "./main";
|
||||||
import { readBuildOptions } from "./shared/buildOptions";
|
import { getBuildContext } from "./shared/buildContext";
|
||||||
import chalk from "chalk";
|
import chalk from "chalk";
|
||||||
|
|
||||||
export async function command(params: { cliCommandOptions: CliCommandOptions }) {
|
export async function command(params: { cliCommandOptions: CliCommandOptions }) {
|
||||||
const { cliCommandOptions } = params;
|
const { cliCommandOptions } = params;
|
||||||
|
|
||||||
const buildOptions = readBuildOptions({
|
const buildContext = getBuildContext({
|
||||||
cliCommandOptions
|
cliCommandOptions
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -54,7 +54,7 @@ export async function command(params: { cliCommandOptions: CliCommandOptions })
|
|||||||
console.log(`→ ${pageId}`);
|
console.log(`→ ${pageId}`);
|
||||||
|
|
||||||
const { themeSrcDirPath } = getThemeSrcDirPath({
|
const { themeSrcDirPath } = getThemeSrcDirPath({
|
||||||
projectDirPath: buildOptions.projectDirPath
|
projectDirPath: buildContext.projectDirPath
|
||||||
});
|
});
|
||||||
|
|
||||||
const componentBasename = capitalize(kebabCaseToCamelCase(pageId)).replace(
|
const componentBasename = capitalize(kebabCaseToCamelCase(pageId)).replace(
|
||||||
|
@ -1,13 +1,13 @@
|
|||||||
import { copyKeycloakResourcesToPublic } from "./shared/copyKeycloakResourcesToPublic";
|
import { copyKeycloakResourcesToPublic } from "./shared/copyKeycloakResourcesToPublic";
|
||||||
import { readBuildOptions } from "./shared/buildOptions";
|
import { getBuildContext } from "./shared/buildContext";
|
||||||
import type { CliCommandOptions } from "./main";
|
import type { CliCommandOptions } from "./main";
|
||||||
|
|
||||||
export async function command(params: { cliCommandOptions: CliCommandOptions }) {
|
export async function command(params: { cliCommandOptions: CliCommandOptions }) {
|
||||||
const { cliCommandOptions } = params;
|
const { cliCommandOptions } = params;
|
||||||
|
|
||||||
const buildOptions = readBuildOptions({ cliCommandOptions });
|
const buildContext = getBuildContext({ cliCommandOptions });
|
||||||
|
|
||||||
await copyKeycloakResourcesToPublic({
|
await copyKeycloakResourcesToPublic({
|
||||||
buildOptions
|
buildContext
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
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 { promptKeycloakVersion } from "./shared/promptKeycloakVersion";
|
import { promptKeycloakVersion } from "./shared/promptKeycloakVersion";
|
||||||
import { readBuildOptions } from "./shared/buildOptions";
|
import { getBuildContext } from "./shared/buildContext";
|
||||||
import { downloadKeycloakDefaultTheme } from "./shared/downloadKeycloakDefaultTheme";
|
import { downloadKeycloakDefaultTheme } from "./shared/downloadKeycloakDefaultTheme";
|
||||||
import { transformCodebase } from "./tools/transformCodebase";
|
import { transformCodebase } from "./tools/transformCodebase";
|
||||||
import type { CliCommandOptions } from "./main";
|
import type { CliCommandOptions } from "./main";
|
||||||
@ -9,7 +9,7 @@ import chalk from "chalk";
|
|||||||
export async function command(params: { cliCommandOptions: CliCommandOptions }) {
|
export async function command(params: { cliCommandOptions: CliCommandOptions }) {
|
||||||
const { cliCommandOptions } = params;
|
const { cliCommandOptions } = params;
|
||||||
|
|
||||||
const buildOptions = readBuildOptions({
|
const buildContext = getBuildContext({
|
||||||
cliCommandOptions
|
cliCommandOptions
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -21,13 +21,13 @@ export async function command(params: { cliCommandOptions: CliCommandOptions })
|
|||||||
|
|
||||||
const { keycloakVersion } = await promptKeycloakVersion({
|
const { keycloakVersion } = await promptKeycloakVersion({
|
||||||
startingFromMajor: undefined,
|
startingFromMajor: undefined,
|
||||||
cacheDirPath: buildOptions.cacheDirPath
|
cacheDirPath: buildContext.cacheDirPath
|
||||||
});
|
});
|
||||||
|
|
||||||
console.log(`→ ${keycloakVersion}`);
|
console.log(`→ ${keycloakVersion}`);
|
||||||
|
|
||||||
const destDirPath = pathJoin(
|
const destDirPath = pathJoin(
|
||||||
buildOptions.keycloakifyBuildDirPath,
|
buildContext.keycloakifyBuildDirPath,
|
||||||
"src",
|
"src",
|
||||||
"main",
|
"main",
|
||||||
"resources",
|
"resources",
|
||||||
@ -51,7 +51,7 @@ export async function command(params: { cliCommandOptions: CliCommandOptions })
|
|||||||
|
|
||||||
const { defaultThemeDirPath } = await downloadKeycloakDefaultTheme({
|
const { defaultThemeDirPath } = await downloadKeycloakDefaultTheme({
|
||||||
keycloakVersion,
|
keycloakVersion,
|
||||||
buildOptions
|
buildContext
|
||||||
});
|
});
|
||||||
|
|
||||||
transformCodebase({
|
transformCodebase({
|
||||||
|
@ -17,13 +17,13 @@ import { kebabCaseToCamelCase } from "./tools/kebabCaseToSnakeCase";
|
|||||||
import { assert, Equals } from "tsafe/assert";
|
import { assert, Equals } from "tsafe/assert";
|
||||||
import { getThemeSrcDirPath } from "./shared/getThemeSrcDirPath";
|
import { getThemeSrcDirPath } from "./shared/getThemeSrcDirPath";
|
||||||
import type { CliCommandOptions } from "./main";
|
import type { CliCommandOptions } from "./main";
|
||||||
import { readBuildOptions } from "./shared/buildOptions";
|
import { getBuildContext } from "./shared/buildContext";
|
||||||
import chalk from "chalk";
|
import chalk from "chalk";
|
||||||
|
|
||||||
export async function command(params: { cliCommandOptions: CliCommandOptions }) {
|
export async function command(params: { cliCommandOptions: CliCommandOptions }) {
|
||||||
const { cliCommandOptions } = params;
|
const { cliCommandOptions } = params;
|
||||||
|
|
||||||
const buildOptions = readBuildOptions({
|
const buildContext = getBuildContext({
|
||||||
cliCommandOptions
|
cliCommandOptions
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -69,7 +69,7 @@ export async function command(params: { cliCommandOptions: CliCommandOptions })
|
|||||||
console.log(`→ ${pageIdOrComponent}`);
|
console.log(`→ ${pageIdOrComponent}`);
|
||||||
|
|
||||||
const { themeSrcDirPath } = getThemeSrcDirPath({
|
const { themeSrcDirPath } = getThemeSrcDirPath({
|
||||||
projectDirPath: buildOptions.projectDirPath
|
projectDirPath: buildContext.projectDirPath
|
||||||
});
|
});
|
||||||
|
|
||||||
const componentBasename = (() => {
|
const componentBasename = (() => {
|
||||||
|
@ -2,7 +2,7 @@ import { downloadKeycloakDefaultTheme } from "./shared/downloadKeycloakDefaultTh
|
|||||||
import { join as pathJoin, relative as pathRelative } from "path";
|
import { join as pathJoin, relative as pathRelative } from "path";
|
||||||
import { transformCodebase } from "./tools/transformCodebase";
|
import { transformCodebase } from "./tools/transformCodebase";
|
||||||
import { promptKeycloakVersion } from "./shared/promptKeycloakVersion";
|
import { promptKeycloakVersion } from "./shared/promptKeycloakVersion";
|
||||||
import { readBuildOptions } from "./shared/buildOptions";
|
import { getBuildContext } from "./shared/buildContext";
|
||||||
import * as fs from "fs";
|
import * as fs from "fs";
|
||||||
import { getThemeSrcDirPath } from "./shared/getThemeSrcDirPath";
|
import { getThemeSrcDirPath } from "./shared/getThemeSrcDirPath";
|
||||||
import type { CliCommandOptions } from "./main";
|
import type { CliCommandOptions } from "./main";
|
||||||
@ -10,10 +10,10 @@ import type { CliCommandOptions } from "./main";
|
|||||||
export async function command(params: { cliCommandOptions: CliCommandOptions }) {
|
export async function command(params: { cliCommandOptions: CliCommandOptions }) {
|
||||||
const { cliCommandOptions } = params;
|
const { cliCommandOptions } = params;
|
||||||
|
|
||||||
const buildOptions = readBuildOptions({ cliCommandOptions });
|
const buildContext = getBuildContext({ cliCommandOptions });
|
||||||
|
|
||||||
const { themeSrcDirPath } = getThemeSrcDirPath({
|
const { themeSrcDirPath } = getThemeSrcDirPath({
|
||||||
projectDirPath: buildOptions.projectDirPath
|
projectDirPath: buildContext.projectDirPath
|
||||||
});
|
});
|
||||||
|
|
||||||
const emailThemeSrcDirPath = pathJoin(themeSrcDirPath, "email");
|
const emailThemeSrcDirPath = pathJoin(themeSrcDirPath, "email");
|
||||||
@ -34,12 +34,12 @@ export async function command(params: { cliCommandOptions: CliCommandOptions })
|
|||||||
const { keycloakVersion } = await promptKeycloakVersion({
|
const { keycloakVersion } = await promptKeycloakVersion({
|
||||||
// NOTE: This is arbitrary
|
// NOTE: This is arbitrary
|
||||||
startingFromMajor: 17,
|
startingFromMajor: 17,
|
||||||
cacheDirPath: buildOptions.cacheDirPath
|
cacheDirPath: buildContext.cacheDirPath
|
||||||
});
|
});
|
||||||
|
|
||||||
const { defaultThemeDirPath } = await downloadKeycloakDefaultTheme({
|
const { defaultThemeDirPath } = await downloadKeycloakDefaultTheme({
|
||||||
keycloakVersion,
|
keycloakVersion,
|
||||||
buildOptions
|
buildContext
|
||||||
});
|
});
|
||||||
|
|
||||||
transformCodebase({
|
transformCodebase({
|
||||||
|
@ -5,12 +5,12 @@ import type {
|
|||||||
} from "./extensionVersions";
|
} from "./extensionVersions";
|
||||||
import { join as pathJoin, dirname as pathDirname } from "path";
|
import { join as pathJoin, dirname as pathDirname } from "path";
|
||||||
import { transformCodebase } from "../../tools/transformCodebase";
|
import { transformCodebase } from "../../tools/transformCodebase";
|
||||||
import type { BuildOptions } from "../../shared/buildOptions";
|
import type { BuildContext } from "../../shared/buildContext";
|
||||||
import * as fs from "fs/promises";
|
import * as fs from "fs/promises";
|
||||||
import { accountV1ThemeName } from "../../shared/constants";
|
import { accountV1ThemeName } from "../../shared/constants";
|
||||||
import {
|
import {
|
||||||
generatePom,
|
generatePom,
|
||||||
BuildOptionsLike as BuildOptionsLike_generatePom
|
BuildContextLike as BuildContextLike_generatePom
|
||||||
} from "./generatePom";
|
} from "./generatePom";
|
||||||
import { readFileSync } from "fs";
|
import { readFileSync } from "fs";
|
||||||
import { isInside } from "../../tools/isInside";
|
import { isInside } from "../../tools/isInside";
|
||||||
@ -18,7 +18,7 @@ import child_process from "child_process";
|
|||||||
import { rmSync } from "../../tools/fs.rmSync";
|
import { rmSync } from "../../tools/fs.rmSync";
|
||||||
import { getMetaInfKeycloakThemesJsonFilePath } from "../../shared/metaInfKeycloakThemes";
|
import { getMetaInfKeycloakThemesJsonFilePath } from "../../shared/metaInfKeycloakThemes";
|
||||||
|
|
||||||
export type BuildOptionsLike = BuildOptionsLike_generatePom & {
|
export type BuildContextLike = BuildContextLike_generatePom & {
|
||||||
keycloakifyBuildDirPath: string;
|
keycloakifyBuildDirPath: string;
|
||||||
themeNames: string[];
|
themeNames: string[];
|
||||||
artifactId: string;
|
artifactId: string;
|
||||||
@ -26,23 +26,23 @@ export type BuildOptionsLike = BuildOptionsLike_generatePom & {
|
|||||||
cacheDirPath: string;
|
cacheDirPath: string;
|
||||||
};
|
};
|
||||||
|
|
||||||
assert<BuildOptions extends BuildOptionsLike ? true : false>();
|
assert<BuildContext extends BuildContextLike ? true : false>();
|
||||||
|
|
||||||
export async function buildJar(params: {
|
export async function buildJar(params: {
|
||||||
jarFileBasename: string;
|
jarFileBasename: string;
|
||||||
keycloakAccountV1Version: KeycloakAccountV1Version;
|
keycloakAccountV1Version: KeycloakAccountV1Version;
|
||||||
keycloakThemeAdditionalInfoExtensionVersion: KeycloakThemeAdditionalInfoExtensionVersion;
|
keycloakThemeAdditionalInfoExtensionVersion: KeycloakThemeAdditionalInfoExtensionVersion;
|
||||||
buildOptions: BuildOptionsLike;
|
buildContext: BuildContextLike;
|
||||||
}): Promise<void> {
|
}): Promise<void> {
|
||||||
const {
|
const {
|
||||||
jarFileBasename,
|
jarFileBasename,
|
||||||
keycloakAccountV1Version,
|
keycloakAccountV1Version,
|
||||||
keycloakThemeAdditionalInfoExtensionVersion,
|
keycloakThemeAdditionalInfoExtensionVersion,
|
||||||
buildOptions
|
buildContext
|
||||||
} = params;
|
} = params;
|
||||||
|
|
||||||
const keycloakifyBuildTmpDirPath = pathJoin(
|
const keycloakifyBuildTmpDirPath = pathJoin(
|
||||||
buildOptions.cacheDirPath,
|
buildContext.cacheDirPath,
|
||||||
jarFileBasename.replace(".jar", "")
|
jarFileBasename.replace(".jar", "")
|
||||||
);
|
);
|
||||||
|
|
||||||
@ -62,7 +62,7 @@ export async function buildJar(params: {
|
|||||||
return { modifiedSourceCode: sourceCode };
|
return { modifiedSourceCode: sourceCode };
|
||||||
}
|
}
|
||||||
|
|
||||||
for (const themeName of [...buildOptions.themeNames, accountV1ThemeName]) {
|
for (const themeName of [...buildContext.themeNames, accountV1ThemeName]) {
|
||||||
if (
|
if (
|
||||||
isInside({
|
isInside({
|
||||||
dirPath: pathJoin("src", "main", "resources", "theme", themeName),
|
dirPath: pathJoin("src", "main", "resources", "theme", themeName),
|
||||||
@ -125,7 +125,7 @@ export async function buildJar(params: {
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
for (const themeName of buildOptions.themeNames) {
|
for (const themeName of buildContext.themeNames) {
|
||||||
if (
|
if (
|
||||||
fileRelativePath ===
|
fileRelativePath ===
|
||||||
pathJoin(
|
pathJoin(
|
||||||
@ -160,7 +160,7 @@ export async function buildJar(params: {
|
|||||||
};
|
};
|
||||||
|
|
||||||
transformCodebase({
|
transformCodebase({
|
||||||
srcDirPath: buildOptions.keycloakifyBuildDirPath,
|
srcDirPath: buildContext.keycloakifyBuildDirPath,
|
||||||
destDirPath: keycloakifyBuildTmpDirPath,
|
destDirPath: keycloakifyBuildTmpDirPath,
|
||||||
transformSourceCode: params => {
|
transformSourceCode: params => {
|
||||||
const resultCommon = transformCodebase_common(params);
|
const resultCommon = transformCodebase_common(params);
|
||||||
@ -203,7 +203,7 @@ export async function buildJar(params: {
|
|||||||
}
|
}
|
||||||
|
|
||||||
(["register.ftl", "login-update-profile.ftl"] as const).forEach(pageId =>
|
(["register.ftl", "login-update-profile.ftl"] as const).forEach(pageId =>
|
||||||
buildOptions.themeNames.map(themeName => {
|
buildContext.themeNames.map(themeName => {
|
||||||
const ftlFilePath = pathJoin(
|
const ftlFilePath = pathJoin(
|
||||||
keycloakifyBuildTmpDirPath,
|
keycloakifyBuildTmpDirPath,
|
||||||
"src",
|
"src",
|
||||||
@ -244,7 +244,7 @@ export async function buildJar(params: {
|
|||||||
|
|
||||||
{
|
{
|
||||||
const { pomFileCode } = generatePom({
|
const { pomFileCode } = generatePom({
|
||||||
buildOptions,
|
buildContext,
|
||||||
keycloakAccountV1Version,
|
keycloakAccountV1Version,
|
||||||
keycloakThemeAdditionalInfoExtensionVersion
|
keycloakThemeAdditionalInfoExtensionVersion
|
||||||
});
|
});
|
||||||
@ -285,9 +285,9 @@ export async function buildJar(params: {
|
|||||||
pathJoin(
|
pathJoin(
|
||||||
keycloakifyBuildTmpDirPath,
|
keycloakifyBuildTmpDirPath,
|
||||||
"target",
|
"target",
|
||||||
`${buildOptions.artifactId}-${buildOptions.themeVersion}.jar`
|
`${buildContext.artifactId}-${buildContext.themeVersion}.jar`
|
||||||
),
|
),
|
||||||
pathJoin(buildOptions.keycloakifyBuildDirPath, jarFileBasename)
|
pathJoin(buildContext.keycloakifyBuildDirPath, jarFileBasename)
|
||||||
);
|
);
|
||||||
|
|
||||||
rmSync(keycloakifyBuildTmpDirPath, { recursive: true });
|
rmSync(keycloakifyBuildTmpDirPath, { recursive: true });
|
||||||
|
@ -5,25 +5,25 @@ import {
|
|||||||
keycloakThemeAdditionalInfoExtensionVersions
|
keycloakThemeAdditionalInfoExtensionVersions
|
||||||
} from "./extensionVersions";
|
} from "./extensionVersions";
|
||||||
import { getKeycloakVersionRangeForJar } from "./getKeycloakVersionRangeForJar";
|
import { getKeycloakVersionRangeForJar } from "./getKeycloakVersionRangeForJar";
|
||||||
import { buildJar, BuildOptionsLike as BuildOptionsLike_buildJar } from "./buildJar";
|
import { buildJar, BuildContextLike as BuildContextLike_buildJar } from "./buildJar";
|
||||||
import type { BuildOptions } from "../../shared/buildOptions";
|
import type { BuildContext } from "../../shared/buildContext";
|
||||||
import { getJarFileBasename } from "../../shared/getJarFileBasename";
|
import { getJarFileBasename } from "../../shared/getJarFileBasename";
|
||||||
import { readMetaInfKeycloakThemes } from "../../shared/metaInfKeycloakThemes";
|
import { readMetaInfKeycloakThemes } from "../../shared/metaInfKeycloakThemes";
|
||||||
import { accountV1ThemeName } from "../../shared/constants";
|
import { accountV1ThemeName } from "../../shared/constants";
|
||||||
|
|
||||||
export type BuildOptionsLike = BuildOptionsLike_buildJar & {
|
export type BuildContextLike = BuildContextLike_buildJar & {
|
||||||
keycloakifyBuildDirPath: string;
|
keycloakifyBuildDirPath: string;
|
||||||
};
|
};
|
||||||
|
|
||||||
assert<BuildOptions extends BuildOptionsLike ? true : false>();
|
assert<BuildContext extends BuildContextLike ? true : false>();
|
||||||
|
|
||||||
export async function buildJars(params: {
|
export async function buildJars(params: {
|
||||||
buildOptions: BuildOptionsLike;
|
buildContext: BuildContextLike;
|
||||||
}): Promise<void> {
|
}): Promise<void> {
|
||||||
const { buildOptions } = params;
|
const { buildContext } = params;
|
||||||
|
|
||||||
const doesImplementAccountTheme = readMetaInfKeycloakThemes({
|
const doesImplementAccountTheme = readMetaInfKeycloakThemes({
|
||||||
keycloakifyBuildDirPath: buildOptions.keycloakifyBuildDirPath
|
keycloakifyBuildDirPath: buildContext.keycloakifyBuildDirPath
|
||||||
}).themes.some(({ name }) => name === accountV1ThemeName);
|
}).themes.some(({ name }) => name === accountV1ThemeName);
|
||||||
|
|
||||||
await Promise.all(
|
await Promise.all(
|
||||||
@ -71,7 +71,7 @@ export async function buildJars(params: {
|
|||||||
jarFileBasename,
|
jarFileBasename,
|
||||||
keycloakAccountV1Version,
|
keycloakAccountV1Version,
|
||||||
keycloakThemeAdditionalInfoExtensionVersion,
|
keycloakThemeAdditionalInfoExtensionVersion,
|
||||||
buildOptions
|
buildContext
|
||||||
})
|
})
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
|
@ -1,27 +1,27 @@
|
|||||||
import { assert } from "tsafe/assert";
|
import { assert } from "tsafe/assert";
|
||||||
import type { BuildOptions } from "../../shared/buildOptions";
|
import type { BuildContext } from "../../shared/buildContext";
|
||||||
import type {
|
import type {
|
||||||
KeycloakAccountV1Version,
|
KeycloakAccountV1Version,
|
||||||
KeycloakThemeAdditionalInfoExtensionVersion
|
KeycloakThemeAdditionalInfoExtensionVersion
|
||||||
} from "./extensionVersions";
|
} from "./extensionVersions";
|
||||||
|
|
||||||
export type BuildOptionsLike = {
|
export type BuildContextLike = {
|
||||||
groupId: string;
|
groupId: string;
|
||||||
artifactId: string;
|
artifactId: string;
|
||||||
themeVersion: string;
|
themeVersion: string;
|
||||||
};
|
};
|
||||||
|
|
||||||
assert<BuildOptions extends BuildOptionsLike ? true : false>();
|
assert<BuildContext extends BuildContextLike ? true : false>();
|
||||||
|
|
||||||
export function generatePom(params: {
|
export function generatePom(params: {
|
||||||
keycloakAccountV1Version: KeycloakAccountV1Version;
|
keycloakAccountV1Version: KeycloakAccountV1Version;
|
||||||
keycloakThemeAdditionalInfoExtensionVersion: KeycloakThemeAdditionalInfoExtensionVersion;
|
keycloakThemeAdditionalInfoExtensionVersion: KeycloakThemeAdditionalInfoExtensionVersion;
|
||||||
buildOptions: BuildOptionsLike;
|
buildContext: BuildContextLike;
|
||||||
}) {
|
}) {
|
||||||
const {
|
const {
|
||||||
keycloakAccountV1Version,
|
keycloakAccountV1Version,
|
||||||
keycloakThemeAdditionalInfoExtensionVersion,
|
keycloakThemeAdditionalInfoExtensionVersion,
|
||||||
buildOptions
|
buildContext
|
||||||
} = params;
|
} = params;
|
||||||
|
|
||||||
const { pomFileCode } = (function generatePomFileCode(): {
|
const { pomFileCode } = (function generatePomFileCode(): {
|
||||||
@ -33,10 +33,10 @@ export function generatePom(params: {
|
|||||||
` xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"`,
|
` xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"`,
|
||||||
` xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">`,
|
` xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">`,
|
||||||
` <modelVersion>4.0.0</modelVersion>`,
|
` <modelVersion>4.0.0</modelVersion>`,
|
||||||
` <groupId>${buildOptions.groupId}</groupId>`,
|
` <groupId>${buildContext.groupId}</groupId>`,
|
||||||
` <artifactId>${buildOptions.artifactId}</artifactId>`,
|
` <artifactId>${buildContext.artifactId}</artifactId>`,
|
||||||
` <version>${buildOptions.themeVersion}</version>`,
|
` <version>${buildContext.themeVersion}</version>`,
|
||||||
` <name>${buildOptions.artifactId}</name>`,
|
` <name>${buildContext.artifactId}</name>`,
|
||||||
` <description />`,
|
` <description />`,
|
||||||
` <packaging>jar</packaging>`,
|
` <packaging>jar</packaging>`,
|
||||||
` <properties>`,
|
` <properties>`,
|
||||||
|
@ -4,7 +4,7 @@ import { generateCssCodeToDefineGlobals } from "../replacers/replaceImportsInCss
|
|||||||
import { replaceImportsInInlineCssCode } from "../replacers/replaceImportsInInlineCssCode";
|
import { replaceImportsInInlineCssCode } from "../replacers/replaceImportsInInlineCssCode";
|
||||||
import * as fs from "fs";
|
import * as fs from "fs";
|
||||||
import { join as pathJoin } from "path";
|
import { join as pathJoin } from "path";
|
||||||
import type { BuildOptions } from "../../shared/buildOptions";
|
import type { BuildContext } from "../../shared/buildContext";
|
||||||
import { assert } from "tsafe/assert";
|
import { assert } from "tsafe/assert";
|
||||||
import {
|
import {
|
||||||
type ThemeType,
|
type ThemeType,
|
||||||
@ -15,7 +15,7 @@ import {
|
|||||||
} from "../../shared/constants";
|
} from "../../shared/constants";
|
||||||
import { getThisCodebaseRootDirPath } from "../../tools/getThisCodebaseRootDirPath";
|
import { getThisCodebaseRootDirPath } from "../../tools/getThisCodebaseRootDirPath";
|
||||||
|
|
||||||
export type BuildOptionsLike = {
|
export type BuildContextLike = {
|
||||||
bundler: "vite" | "webpack";
|
bundler: "vite" | "webpack";
|
||||||
themeVersion: string;
|
themeVersion: string;
|
||||||
urlPathname: string | undefined;
|
urlPathname: string | undefined;
|
||||||
@ -24,13 +24,13 @@ export type BuildOptionsLike = {
|
|||||||
kcContextExclusionsFtlCode: string | undefined;
|
kcContextExclusionsFtlCode: string | undefined;
|
||||||
};
|
};
|
||||||
|
|
||||||
assert<BuildOptions extends BuildOptionsLike ? true : false>();
|
assert<BuildContext extends BuildContextLike ? true : false>();
|
||||||
|
|
||||||
export function generateFtlFilesCodeFactory(params: {
|
export function generateFtlFilesCodeFactory(params: {
|
||||||
themeName: string;
|
themeName: string;
|
||||||
indexHtmlCode: string;
|
indexHtmlCode: string;
|
||||||
cssGlobalsToDefine: Record<string, string>;
|
cssGlobalsToDefine: Record<string, string>;
|
||||||
buildOptions: BuildOptionsLike;
|
buildContext: BuildContextLike;
|
||||||
keycloakifyVersion: string;
|
keycloakifyVersion: string;
|
||||||
themeType: ThemeType;
|
themeType: ThemeType;
|
||||||
fieldNames: string[];
|
fieldNames: string[];
|
||||||
@ -39,7 +39,7 @@ export function generateFtlFilesCodeFactory(params: {
|
|||||||
themeName,
|
themeName,
|
||||||
cssGlobalsToDefine,
|
cssGlobalsToDefine,
|
||||||
indexHtmlCode,
|
indexHtmlCode,
|
||||||
buildOptions,
|
buildContext,
|
||||||
keycloakifyVersion,
|
keycloakifyVersion,
|
||||||
themeType,
|
themeType,
|
||||||
fieldNames
|
fieldNames
|
||||||
@ -55,7 +55,7 @@ export function generateFtlFilesCodeFactory(params: {
|
|||||||
|
|
||||||
const { fixedJsCode } = replaceImportsInJsCode({
|
const { fixedJsCode } = replaceImportsInJsCode({
|
||||||
jsCode,
|
jsCode,
|
||||||
buildOptions
|
buildContext
|
||||||
});
|
});
|
||||||
|
|
||||||
$(element).text(fixedJsCode);
|
$(element).text(fixedJsCode);
|
||||||
@ -68,7 +68,7 @@ export function generateFtlFilesCodeFactory(params: {
|
|||||||
|
|
||||||
const { fixedCssCode } = replaceImportsInInlineCssCode({
|
const { fixedCssCode } = replaceImportsInInlineCssCode({
|
||||||
cssCode,
|
cssCode,
|
||||||
buildOptions
|
buildContext
|
||||||
});
|
});
|
||||||
|
|
||||||
$(element).text(fixedCssCode);
|
$(element).text(fixedCssCode);
|
||||||
@ -91,7 +91,7 @@ export function generateFtlFilesCodeFactory(params: {
|
|||||||
attrName,
|
attrName,
|
||||||
href.replace(
|
href.replace(
|
||||||
new RegExp(
|
new RegExp(
|
||||||
`^${(buildOptions.urlPathname ?? "/").replace(/\//g, "\\/")}`
|
`^${(buildContext.urlPathname ?? "/").replace(/\//g, "\\/")}`
|
||||||
),
|
),
|
||||||
`\${url.resourcesPath}/${basenameOfTheKeycloakifyResourcesDir}/`
|
`\${url.resourcesPath}/${basenameOfTheKeycloakifyResourcesDir}/`
|
||||||
)
|
)
|
||||||
@ -106,7 +106,7 @@ export function generateFtlFilesCodeFactory(params: {
|
|||||||
"<style>",
|
"<style>",
|
||||||
generateCssCodeToDefineGlobals({
|
generateCssCodeToDefineGlobals({
|
||||||
cssGlobalsToDefine,
|
cssGlobalsToDefine,
|
||||||
buildOptions
|
buildContext
|
||||||
}).cssCodeToPrependInHead,
|
}).cssCodeToPrependInHead,
|
||||||
"</style>",
|
"</style>",
|
||||||
""
|
""
|
||||||
@ -134,7 +134,7 @@ export function generateFtlFilesCodeFactory(params: {
|
|||||||
fieldNames.map(name => `"${name}"`).join(", ")
|
fieldNames.map(name => `"${name}"`).join(", ")
|
||||||
)
|
)
|
||||||
.replace("KEYCLOAKIFY_VERSION_xEdKd3xEdr", keycloakifyVersion)
|
.replace("KEYCLOAKIFY_VERSION_xEdKd3xEdr", keycloakifyVersion)
|
||||||
.replace("KEYCLOAKIFY_THEME_VERSION_sIgKd3xEdr3dx", buildOptions.themeVersion)
|
.replace("KEYCLOAKIFY_THEME_VERSION_sIgKd3xEdr3dx", buildContext.themeVersion)
|
||||||
.replace("KEYCLOAKIFY_THEME_TYPE_dExKd3xEdr", themeType)
|
.replace("KEYCLOAKIFY_THEME_TYPE_dExKd3xEdr", themeType)
|
||||||
.replace("KEYCLOAKIFY_THEME_NAME_cXxKd3xEer", themeName)
|
.replace("KEYCLOAKIFY_THEME_NAME_cXxKd3xEer", themeName)
|
||||||
.replace("RESOURCES_COMMON_cLsLsMrtDkpVv", resources_common)
|
.replace("RESOURCES_COMMON_cLsLsMrtDkpVv", resources_common)
|
||||||
@ -144,7 +144,7 @@ export function generateFtlFilesCodeFactory(params: {
|
|||||||
)
|
)
|
||||||
.replace(
|
.replace(
|
||||||
"USER_DEFINED_EXCLUSIONS_eKsaY4ZsZ4eMr2",
|
"USER_DEFINED_EXCLUSIONS_eKsaY4ZsZ4eMr2",
|
||||||
buildOptions.kcContextExclusionsFtlCode ?? ""
|
buildContext.kcContextExclusionsFtlCode ?? ""
|
||||||
);
|
);
|
||||||
const ftlObjectToJsCodeDeclaringAnObjectPlaceholder =
|
const ftlObjectToJsCodeDeclaringAnObjectPlaceholder =
|
||||||
'{ "x": "vIdLqMeOed9sdLdIdOxdK0d" }';
|
'{ "x": "vIdLqMeOed9sdLdIdOxdK0d" }';
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
import * as fs from "fs";
|
import * as fs from "fs";
|
||||||
import { join as pathJoin } from "path";
|
import { join as pathJoin } from "path";
|
||||||
import { assert } from "tsafe/assert";
|
import { assert } from "tsafe/assert";
|
||||||
import type { BuildOptions } from "../../shared/buildOptions";
|
import type { BuildContext } from "../../shared/buildContext";
|
||||||
import {
|
import {
|
||||||
resources_common,
|
resources_common,
|
||||||
lastKeycloakVersionWithAccountV1,
|
lastKeycloakVersionWithAccountV1,
|
||||||
@ -10,24 +10,24 @@ import {
|
|||||||
import { downloadKeycloakDefaultTheme } from "../../shared/downloadKeycloakDefaultTheme";
|
import { downloadKeycloakDefaultTheme } from "../../shared/downloadKeycloakDefaultTheme";
|
||||||
import { transformCodebase } from "../../tools/transformCodebase";
|
import { transformCodebase } from "../../tools/transformCodebase";
|
||||||
|
|
||||||
export type BuildOptionsLike = {
|
export type BuildContextLike = {
|
||||||
cacheDirPath: string;
|
cacheDirPath: string;
|
||||||
npmWorkspaceRootDirPath: string;
|
npmWorkspaceRootDirPath: string;
|
||||||
keycloakifyBuildDirPath: string;
|
keycloakifyBuildDirPath: string;
|
||||||
};
|
};
|
||||||
|
|
||||||
assert<BuildOptions extends BuildOptionsLike ? true : false>();
|
assert<BuildContext extends BuildContextLike ? true : false>();
|
||||||
|
|
||||||
export async function bringInAccountV1(params: { buildOptions: BuildOptionsLike }) {
|
export async function bringInAccountV1(params: { buildContext: BuildContextLike }) {
|
||||||
const { buildOptions } = params;
|
const { buildContext } = params;
|
||||||
|
|
||||||
const { defaultThemeDirPath } = await downloadKeycloakDefaultTheme({
|
const { defaultThemeDirPath } = await downloadKeycloakDefaultTheme({
|
||||||
keycloakVersion: lastKeycloakVersionWithAccountV1,
|
keycloakVersion: lastKeycloakVersionWithAccountV1,
|
||||||
buildOptions
|
buildContext
|
||||||
});
|
});
|
||||||
|
|
||||||
const accountV1DirPath = pathJoin(
|
const accountV1DirPath = pathJoin(
|
||||||
buildOptions.keycloakifyBuildDirPath,
|
buildContext.keycloakifyBuildDirPath,
|
||||||
"src",
|
"src",
|
||||||
"main",
|
"main",
|
||||||
"resources",
|
"resources",
|
||||||
|
@ -1,34 +1,34 @@
|
|||||||
import type { BuildOptions } from "../../shared/buildOptions";
|
import type { BuildContext } from "../../shared/buildContext";
|
||||||
import { assert } from "tsafe/assert";
|
import { assert } from "tsafe/assert";
|
||||||
import {
|
import {
|
||||||
generateSrcMainResourcesForMainTheme,
|
generateSrcMainResourcesForMainTheme,
|
||||||
type BuildOptionsLike as BuildOptionsLike_generateSrcMainResourcesForMainTheme
|
type BuildContextLike as BuildContextLike_generateSrcMainResourcesForMainTheme
|
||||||
} from "./generateSrcMainResourcesForMainTheme";
|
} from "./generateSrcMainResourcesForMainTheme";
|
||||||
import { generateSrcMainResourcesForThemeVariant } from "./generateSrcMainResourcesForThemeVariant";
|
import { generateSrcMainResourcesForThemeVariant } from "./generateSrcMainResourcesForThemeVariant";
|
||||||
|
|
||||||
export type BuildOptionsLike = BuildOptionsLike_generateSrcMainResourcesForMainTheme & {
|
export type BuildContextLike = BuildContextLike_generateSrcMainResourcesForMainTheme & {
|
||||||
themeNames: string[];
|
themeNames: string[];
|
||||||
};
|
};
|
||||||
|
|
||||||
assert<BuildOptions extends BuildOptionsLike ? true : false>();
|
assert<BuildContext extends BuildContextLike ? true : false>();
|
||||||
|
|
||||||
export async function generateSrcMainResources(params: {
|
export async function generateSrcMainResources(params: {
|
||||||
buildOptions: BuildOptionsLike;
|
buildContext: BuildContextLike;
|
||||||
}): Promise<void> {
|
}): Promise<void> {
|
||||||
const { buildOptions } = params;
|
const { buildContext } = params;
|
||||||
|
|
||||||
const [themeName, ...themeVariantNames] = buildOptions.themeNames;
|
const [themeName, ...themeVariantNames] = buildContext.themeNames;
|
||||||
|
|
||||||
await generateSrcMainResourcesForMainTheme({
|
await generateSrcMainResourcesForMainTheme({
|
||||||
themeName,
|
themeName,
|
||||||
buildOptions
|
buildContext
|
||||||
});
|
});
|
||||||
|
|
||||||
for (const themeVariantName of themeVariantNames) {
|
for (const themeVariantName of themeVariantNames) {
|
||||||
generateSrcMainResourcesForThemeVariant({
|
generateSrcMainResourcesForThemeVariant({
|
||||||
themeName,
|
themeName,
|
||||||
themeVariantName,
|
themeVariantName,
|
||||||
buildOptions
|
buildContext
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -5,7 +5,7 @@ import { replaceImportsInJsCode } from "../replacers/replaceImportsInJsCode";
|
|||||||
import { replaceImportsInCssCode } from "../replacers/replaceImportsInCssCode";
|
import { replaceImportsInCssCode } from "../replacers/replaceImportsInCssCode";
|
||||||
import {
|
import {
|
||||||
generateFtlFilesCodeFactory,
|
generateFtlFilesCodeFactory,
|
||||||
type BuildOptionsLike as BuildOptionsLike_kcContextExclusionsFtlCode
|
type BuildContextLike as BuildContextLike_kcContextExclusionsFtlCode
|
||||||
} from "../generateFtl";
|
} from "../generateFtl";
|
||||||
import {
|
import {
|
||||||
type ThemeType,
|
type ThemeType,
|
||||||
@ -17,18 +17,18 @@ import {
|
|||||||
accountThemePageIds
|
accountThemePageIds
|
||||||
} from "../../shared/constants";
|
} from "../../shared/constants";
|
||||||
import { isInside } from "../../tools/isInside";
|
import { isInside } from "../../tools/isInside";
|
||||||
import type { BuildOptions } from "../../shared/buildOptions";
|
import type { BuildContext } from "../../shared/buildContext";
|
||||||
import { assert, type Equals } from "tsafe/assert";
|
import { assert, type Equals } from "tsafe/assert";
|
||||||
import {
|
import {
|
||||||
downloadKeycloakStaticResources,
|
downloadKeycloakStaticResources,
|
||||||
type BuildOptionsLike as BuildOptionsLike_downloadKeycloakStaticResources
|
type BuildContextLike as BuildContextLike_downloadKeycloakStaticResources
|
||||||
} from "../../shared/downloadKeycloakStaticResources";
|
} from "../../shared/downloadKeycloakStaticResources";
|
||||||
import { readFieldNameUsage } from "./readFieldNameUsage";
|
import { readFieldNameUsage } from "./readFieldNameUsage";
|
||||||
import { readExtraPagesNames } from "./readExtraPageNames";
|
import { readExtraPagesNames } from "./readExtraPageNames";
|
||||||
import { generateMessageProperties } from "./generateMessageProperties";
|
import { generateMessageProperties } from "./generateMessageProperties";
|
||||||
import {
|
import {
|
||||||
bringInAccountV1,
|
bringInAccountV1,
|
||||||
type BuildOptionsLike as BuildOptionsLike_bringInAccountV1
|
type BuildContextLike as BuildContextLike_bringInAccountV1
|
||||||
} from "./bringInAccountV1";
|
} from "./bringInAccountV1";
|
||||||
import { getThemeSrcDirPath } from "../../shared/getThemeSrcDirPath";
|
import { getThemeSrcDirPath } from "../../shared/getThemeSrcDirPath";
|
||||||
import { rmSync } from "../../tools/fs.rmSync";
|
import { rmSync } from "../../tools/fs.rmSync";
|
||||||
@ -40,9 +40,9 @@ import {
|
|||||||
import { objectEntries } from "tsafe/objectEntries";
|
import { objectEntries } from "tsafe/objectEntries";
|
||||||
import { escapeStringForPropertiesFile } from "../../tools/escapeStringForPropertiesFile";
|
import { escapeStringForPropertiesFile } from "../../tools/escapeStringForPropertiesFile";
|
||||||
|
|
||||||
export type BuildOptionsLike = BuildOptionsLike_kcContextExclusionsFtlCode &
|
export type BuildContextLike = BuildContextLike_kcContextExclusionsFtlCode &
|
||||||
BuildOptionsLike_downloadKeycloakStaticResources &
|
BuildContextLike_downloadKeycloakStaticResources &
|
||||||
BuildOptionsLike_bringInAccountV1 & {
|
BuildContextLike_bringInAccountV1 & {
|
||||||
bundler: "vite" | "webpack";
|
bundler: "vite" | "webpack";
|
||||||
extraThemeProperties: string[] | undefined;
|
extraThemeProperties: string[] | undefined;
|
||||||
loginThemeResourcesFromKeycloakVersion: string;
|
loginThemeResourcesFromKeycloakVersion: string;
|
||||||
@ -54,22 +54,22 @@ export type BuildOptionsLike = BuildOptionsLike_kcContextExclusionsFtlCode &
|
|||||||
environmentVariables: { name: string; default: string }[];
|
environmentVariables: { name: string; default: string }[];
|
||||||
};
|
};
|
||||||
|
|
||||||
assert<BuildOptions extends BuildOptionsLike ? true : false>();
|
assert<BuildContext extends BuildContextLike ? true : false>();
|
||||||
|
|
||||||
export async function generateSrcMainResourcesForMainTheme(params: {
|
export async function generateSrcMainResourcesForMainTheme(params: {
|
||||||
themeName: string;
|
themeName: string;
|
||||||
buildOptions: BuildOptionsLike;
|
buildContext: BuildContextLike;
|
||||||
}): Promise<void> {
|
}): Promise<void> {
|
||||||
const { themeName, buildOptions } = params;
|
const { themeName, buildContext } = params;
|
||||||
|
|
||||||
const { themeSrcDirPath } = getThemeSrcDirPath({
|
const { themeSrcDirPath } = getThemeSrcDirPath({
|
||||||
projectDirPath: buildOptions.projectDirPath
|
projectDirPath: buildContext.projectDirPath
|
||||||
});
|
});
|
||||||
|
|
||||||
const getThemeTypeDirPath = (params: { themeType: ThemeType | "email" }) => {
|
const getThemeTypeDirPath = (params: { themeType: ThemeType | "email" }) => {
|
||||||
const { themeType } = params;
|
const { themeType } = params;
|
||||||
return pathJoin(
|
return pathJoin(
|
||||||
buildOptions.keycloakifyBuildDirPath,
|
buildContext.keycloakifyBuildDirPath,
|
||||||
"src",
|
"src",
|
||||||
"main",
|
"main",
|
||||||
"resources",
|
"resources",
|
||||||
@ -124,7 +124,7 @@ export async function generateSrcMainResourcesForMainTheme(params: {
|
|||||||
}
|
}
|
||||||
|
|
||||||
transformCodebase({
|
transformCodebase({
|
||||||
srcDirPath: buildOptions.projectBuildDirPath,
|
srcDirPath: buildContext.projectBuildDirPath,
|
||||||
destDirPath,
|
destDirPath,
|
||||||
transformSourceCode: ({ filePath, sourceCode }) => {
|
transformSourceCode: ({ filePath, sourceCode }) => {
|
||||||
//NOTE: Prevent cycles, excludes the folder we generated for debug in public/
|
//NOTE: Prevent cycles, excludes the folder we generated for debug in public/
|
||||||
@ -132,7 +132,7 @@ export async function generateSrcMainResourcesForMainTheme(params: {
|
|||||||
if (
|
if (
|
||||||
isInside({
|
isInside({
|
||||||
dirPath: pathJoin(
|
dirPath: pathJoin(
|
||||||
buildOptions.projectBuildDirPath,
|
buildContext.projectBuildDirPath,
|
||||||
keycloak_resources
|
keycloak_resources
|
||||||
),
|
),
|
||||||
filePath
|
filePath
|
||||||
@ -163,7 +163,7 @@ export async function generateSrcMainResourcesForMainTheme(params: {
|
|||||||
if (/\.js?$/i.test(filePath)) {
|
if (/\.js?$/i.test(filePath)) {
|
||||||
const { fixedJsCode } = replaceImportsInJsCode({
|
const { fixedJsCode } = replaceImportsInJsCode({
|
||||||
jsCode: sourceCode.toString("utf8"),
|
jsCode: sourceCode.toString("utf8"),
|
||||||
buildOptions
|
buildContext
|
||||||
});
|
});
|
||||||
|
|
||||||
return {
|
return {
|
||||||
@ -179,10 +179,10 @@ export async function generateSrcMainResourcesForMainTheme(params: {
|
|||||||
const { generateFtlFilesCode } = generateFtlFilesCodeFactory({
|
const { generateFtlFilesCode } = generateFtlFilesCodeFactory({
|
||||||
themeName,
|
themeName,
|
||||||
indexHtmlCode: fs
|
indexHtmlCode: fs
|
||||||
.readFileSync(pathJoin(buildOptions.projectBuildDirPath, "index.html"))
|
.readFileSync(pathJoin(buildContext.projectBuildDirPath, "index.html"))
|
||||||
.toString("utf8"),
|
.toString("utf8"),
|
||||||
cssGlobalsToDefine,
|
cssGlobalsToDefine,
|
||||||
buildOptions,
|
buildContext,
|
||||||
keycloakifyVersion: readThisNpmPackageVersion(),
|
keycloakifyVersion: readThisNpmPackageVersion(),
|
||||||
themeType,
|
themeType,
|
||||||
fieldNames: readFieldNameUsage({
|
fieldNames: readFieldNameUsage({
|
||||||
@ -242,12 +242,12 @@ export async function generateSrcMainResourcesForMainTheme(params: {
|
|||||||
case "account":
|
case "account":
|
||||||
return lastKeycloakVersionWithAccountV1;
|
return lastKeycloakVersionWithAccountV1;
|
||||||
case "login":
|
case "login":
|
||||||
return buildOptions.loginThemeResourcesFromKeycloakVersion;
|
return buildContext.loginThemeResourcesFromKeycloakVersion;
|
||||||
}
|
}
|
||||||
})(),
|
})(),
|
||||||
themeDirPath: pathResolve(pathJoin(themeTypeDirPath, "..")),
|
themeDirPath: pathResolve(pathJoin(themeTypeDirPath, "..")),
|
||||||
themeType,
|
themeType,
|
||||||
buildOptions
|
buildContext
|
||||||
});
|
});
|
||||||
|
|
||||||
fs.writeFileSync(
|
fs.writeFileSync(
|
||||||
@ -263,8 +263,8 @@ export async function generateSrcMainResourcesForMainTheme(params: {
|
|||||||
}
|
}
|
||||||
assert<Equals<typeof themeType, never>>(false);
|
assert<Equals<typeof themeType, never>>(false);
|
||||||
})()}`,
|
})()}`,
|
||||||
...(buildOptions.extraThemeProperties ?? []),
|
...(buildContext.extraThemeProperties ?? []),
|
||||||
buildOptions.environmentVariables.map(
|
buildContext.environmentVariables.map(
|
||||||
({ name, default: defaultValue }) =>
|
({ name, default: defaultValue }) =>
|
||||||
`${name}=\${env.${name}:${escapeStringForPropertiesFile(defaultValue)}}`
|
`${name}=\${env.${name}:${escapeStringForPropertiesFile(defaultValue)}}`
|
||||||
)
|
)
|
||||||
@ -291,7 +291,7 @@ export async function generateSrcMainResourcesForMainTheme(params: {
|
|||||||
|
|
||||||
if (implementedThemeTypes.account) {
|
if (implementedThemeTypes.account) {
|
||||||
await bringInAccountV1({
|
await bringInAccountV1({
|
||||||
buildOptions
|
buildContext
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -313,7 +313,7 @@ export async function generateSrcMainResourcesForMainTheme(params: {
|
|||||||
}
|
}
|
||||||
|
|
||||||
writeMetaInfKeycloakThemes({
|
writeMetaInfKeycloakThemes({
|
||||||
keycloakifyBuildDirPath: buildOptions.keycloakifyBuildDirPath,
|
keycloakifyBuildDirPath: buildContext.keycloakifyBuildDirPath,
|
||||||
metaInfKeycloakThemes
|
metaInfKeycloakThemes
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
@ -1,27 +1,27 @@
|
|||||||
import { join as pathJoin, extname as pathExtname, sep as pathSep } from "path";
|
import { join as pathJoin, extname as pathExtname, sep as pathSep } from "path";
|
||||||
import { transformCodebase } from "../../tools/transformCodebase";
|
import { transformCodebase } from "../../tools/transformCodebase";
|
||||||
import type { BuildOptions } from "../../shared/buildOptions";
|
import type { BuildContext } from "../../shared/buildContext";
|
||||||
import {
|
import {
|
||||||
readMetaInfKeycloakThemes,
|
readMetaInfKeycloakThemes,
|
||||||
writeMetaInfKeycloakThemes
|
writeMetaInfKeycloakThemes
|
||||||
} from "../../shared/metaInfKeycloakThemes";
|
} from "../../shared/metaInfKeycloakThemes";
|
||||||
import { assert } from "tsafe/assert";
|
import { assert } from "tsafe/assert";
|
||||||
|
|
||||||
export type BuildOptionsLike = {
|
export type BuildContextLike = {
|
||||||
keycloakifyBuildDirPath: string;
|
keycloakifyBuildDirPath: string;
|
||||||
};
|
};
|
||||||
|
|
||||||
assert<BuildOptions extends BuildOptionsLike ? true : false>();
|
assert<BuildContext extends BuildContextLike ? true : false>();
|
||||||
|
|
||||||
export function generateSrcMainResourcesForThemeVariant(params: {
|
export function generateSrcMainResourcesForThemeVariant(params: {
|
||||||
themeName: string;
|
themeName: string;
|
||||||
themeVariantName: string;
|
themeVariantName: string;
|
||||||
buildOptions: BuildOptionsLike;
|
buildContext: BuildContextLike;
|
||||||
}) {
|
}) {
|
||||||
const { themeName, themeVariantName, buildOptions } = params;
|
const { themeName, themeVariantName, buildContext } = params;
|
||||||
|
|
||||||
const mainThemeDirPath = pathJoin(
|
const mainThemeDirPath = pathJoin(
|
||||||
buildOptions.keycloakifyBuildDirPath,
|
buildContext.keycloakifyBuildDirPath,
|
||||||
"src",
|
"src",
|
||||||
"main",
|
"main",
|
||||||
"resources",
|
"resources",
|
||||||
@ -58,7 +58,7 @@ export function generateSrcMainResourcesForThemeVariant(params: {
|
|||||||
|
|
||||||
{
|
{
|
||||||
const updatedMetaInfKeycloakThemes = readMetaInfKeycloakThemes({
|
const updatedMetaInfKeycloakThemes = readMetaInfKeycloakThemes({
|
||||||
keycloakifyBuildDirPath: buildOptions.keycloakifyBuildDirPath
|
keycloakifyBuildDirPath: buildContext.keycloakifyBuildDirPath
|
||||||
});
|
});
|
||||||
|
|
||||||
updatedMetaInfKeycloakThemes.themes.push({
|
updatedMetaInfKeycloakThemes.themes.push({
|
||||||
@ -73,7 +73,7 @@ export function generateSrcMainResourcesForThemeVariant(params: {
|
|||||||
});
|
});
|
||||||
|
|
||||||
writeMetaInfKeycloakThemes({
|
writeMetaInfKeycloakThemes({
|
||||||
keycloakifyBuildDirPath: buildOptions.keycloakifyBuildDirPath,
|
keycloakifyBuildDirPath: buildContext.keycloakifyBuildDirPath,
|
||||||
metaInfKeycloakThemes: updatedMetaInfKeycloakThemes
|
metaInfKeycloakThemes: updatedMetaInfKeycloakThemes
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
@ -5,15 +5,15 @@ import {
|
|||||||
basename as pathBasename
|
basename as pathBasename
|
||||||
} from "path";
|
} from "path";
|
||||||
import { assert } from "tsafe/assert";
|
import { assert } from "tsafe/assert";
|
||||||
import type { BuildOptions } from "../shared/buildOptions";
|
import type { BuildContext } from "../shared/buildContext";
|
||||||
import { accountV1ThemeName } from "../shared/constants";
|
import { accountV1ThemeName } from "../shared/constants";
|
||||||
|
|
||||||
export type BuildOptionsLike = {
|
export type BuildContextLike = {
|
||||||
keycloakifyBuildDirPath: string;
|
keycloakifyBuildDirPath: string;
|
||||||
themeNames: string[];
|
themeNames: string[];
|
||||||
};
|
};
|
||||||
|
|
||||||
assert<BuildOptions extends BuildOptionsLike ? true : false>();
|
assert<BuildContext extends BuildContextLike ? true : false>();
|
||||||
|
|
||||||
generateStartKeycloakTestingContainer.basename = "start_keycloak_testing_container.sh";
|
generateStartKeycloakTestingContainer.basename = "start_keycloak_testing_container.sh";
|
||||||
|
|
||||||
@ -24,15 +24,15 @@ const keycloakVersion = "24.0.4";
|
|||||||
export function generateStartKeycloakTestingContainer(params: {
|
export function generateStartKeycloakTestingContainer(params: {
|
||||||
jarFilePath: string;
|
jarFilePath: string;
|
||||||
doesImplementAccountTheme: boolean;
|
doesImplementAccountTheme: boolean;
|
||||||
buildOptions: BuildOptionsLike;
|
buildContext: BuildContextLike;
|
||||||
}) {
|
}) {
|
||||||
const { jarFilePath, doesImplementAccountTheme, buildOptions } = params;
|
const { jarFilePath, doesImplementAccountTheme, buildContext } = params;
|
||||||
|
|
||||||
const themeRelativeDirPath = pathJoin("src", "main", "resources", "theme");
|
const themeRelativeDirPath = pathJoin("src", "main", "resources", "theme");
|
||||||
|
|
||||||
fs.writeFileSync(
|
fs.writeFileSync(
|
||||||
pathJoin(
|
pathJoin(
|
||||||
buildOptions.keycloakifyBuildDirPath,
|
buildContext.keycloakifyBuildDirPath,
|
||||||
generateStartKeycloakTestingContainer.basename
|
generateStartKeycloakTestingContainer.basename
|
||||||
),
|
),
|
||||||
Buffer.from(
|
Buffer.from(
|
||||||
@ -41,7 +41,7 @@ export function generateStartKeycloakTestingContainer(params: {
|
|||||||
"",
|
"",
|
||||||
`docker rm ${containerName} || true`,
|
`docker rm ${containerName} || true`,
|
||||||
"",
|
"",
|
||||||
`cd "${buildOptions.keycloakifyBuildDirPath}"`,
|
`cd "${buildContext.keycloakifyBuildDirPath}"`,
|
||||||
"",
|
"",
|
||||||
"docker run \\",
|
"docker run \\",
|
||||||
" -p 8080:8080 \\",
|
" -p 8080:8080 \\",
|
||||||
@ -50,11 +50,11 @@ export function generateStartKeycloakTestingContainer(params: {
|
|||||||
" -e KEYCLOAK_ADMIN_PASSWORD=admin \\",
|
" -e KEYCLOAK_ADMIN_PASSWORD=admin \\",
|
||||||
` -v "${pathJoin(
|
` -v "${pathJoin(
|
||||||
"$(pwd)",
|
"$(pwd)",
|
||||||
pathRelative(buildOptions.keycloakifyBuildDirPath, jarFilePath)
|
pathRelative(buildContext.keycloakifyBuildDirPath, jarFilePath)
|
||||||
)}":"/opt/keycloak/providers/${pathBasename(jarFilePath)}" \\`,
|
)}":"/opt/keycloak/providers/${pathBasename(jarFilePath)}" \\`,
|
||||||
[
|
[
|
||||||
...(doesImplementAccountTheme ? [accountV1ThemeName] : []),
|
...(doesImplementAccountTheme ? [accountV1ThemeName] : []),
|
||||||
...buildOptions.themeNames
|
...buildContext.themeNames
|
||||||
].map(
|
].map(
|
||||||
themeName =>
|
themeName =>
|
||||||
` -v "${pathJoin(
|
` -v "${pathJoin(
|
||||||
|
@ -2,7 +2,7 @@ import { generateSrcMainResources } from "./generateSrcMainResources";
|
|||||||
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 * as child_process from "child_process";
|
import * as child_process from "child_process";
|
||||||
import * as fs from "fs";
|
import * as fs from "fs";
|
||||||
import { readBuildOptions } from "../shared/buildOptions";
|
import { getBuildContext } from "../shared/buildContext";
|
||||||
import { vitePluginSubScriptEnvNames, skipBuildJarsEnvName } from "../shared/constants";
|
import { vitePluginSubScriptEnvNames, skipBuildJarsEnvName } from "../shared/constants";
|
||||||
import { buildJars } from "./buildJars";
|
import { buildJars } from "./buildJars";
|
||||||
import type { CliCommandOptions } from "../main";
|
import type { CliCommandOptions } from "../main";
|
||||||
@ -47,7 +47,7 @@ export async function command(params: { cliCommandOptions: CliCommandOptions })
|
|||||||
|
|
||||||
const { cliCommandOptions } = params;
|
const { cliCommandOptions } = params;
|
||||||
|
|
||||||
const buildOptions = readBuildOptions({ cliCommandOptions });
|
const buildContext = getBuildContext({ cliCommandOptions });
|
||||||
|
|
||||||
console.log(
|
console.log(
|
||||||
[
|
[
|
||||||
@ -55,7 +55,7 @@ export async function command(params: { cliCommandOptions: CliCommandOptions })
|
|||||||
chalk.green(
|
chalk.green(
|
||||||
`Building the keycloak theme in .${pathSep}${pathRelative(
|
`Building the keycloak theme in .${pathSep}${pathRelative(
|
||||||
process.cwd(),
|
process.cwd(),
|
||||||
buildOptions.keycloakifyBuildDirPath
|
buildContext.keycloakifyBuildDirPath
|
||||||
)} ...`
|
)} ...`
|
||||||
)
|
)
|
||||||
].join(" ")
|
].join(" ")
|
||||||
@ -64,31 +64,31 @@ export async function command(params: { cliCommandOptions: CliCommandOptions })
|
|||||||
const startTime = Date.now();
|
const startTime = Date.now();
|
||||||
|
|
||||||
{
|
{
|
||||||
if (!fs.existsSync(buildOptions.keycloakifyBuildDirPath)) {
|
if (!fs.existsSync(buildContext.keycloakifyBuildDirPath)) {
|
||||||
fs.mkdirSync(buildOptions.keycloakifyBuildDirPath, {
|
fs.mkdirSync(buildContext.keycloakifyBuildDirPath, {
|
||||||
recursive: true
|
recursive: true
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
fs.writeFileSync(
|
fs.writeFileSync(
|
||||||
pathJoin(buildOptions.keycloakifyBuildDirPath, ".gitignore"),
|
pathJoin(buildContext.keycloakifyBuildDirPath, ".gitignore"),
|
||||||
Buffer.from("*", "utf8")
|
Buffer.from("*", "utf8")
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
await generateSrcMainResources({ buildOptions });
|
await generateSrcMainResources({ buildContext });
|
||||||
|
|
||||||
run_post_build_script: {
|
run_post_build_script: {
|
||||||
if (buildOptions.bundler !== "vite") {
|
if (buildContext.bundler !== "vite") {
|
||||||
break run_post_build_script;
|
break run_post_build_script;
|
||||||
}
|
}
|
||||||
|
|
||||||
child_process.execSync("npx vite", {
|
child_process.execSync("npx vite", {
|
||||||
cwd: buildOptions.projectDirPath,
|
cwd: buildContext.projectDirPath,
|
||||||
env: {
|
env: {
|
||||||
...process.env,
|
...process.env,
|
||||||
[vitePluginSubScriptEnvNames.runPostBuildScript]:
|
[vitePluginSubScriptEnvNames.runPostBuildScript]:
|
||||||
JSON.stringify(buildOptions)
|
JSON.stringify(buildContext)
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@ -98,7 +98,7 @@ export async function command(params: { cliCommandOptions: CliCommandOptions })
|
|||||||
break build_jars;
|
break build_jars;
|
||||||
}
|
}
|
||||||
|
|
||||||
await buildJars({ buildOptions });
|
await buildJars({ buildContext });
|
||||||
}
|
}
|
||||||
|
|
||||||
console.log(
|
console.log(
|
||||||
|
@ -1,13 +1,13 @@
|
|||||||
import * as crypto from "crypto";
|
import * as crypto from "crypto";
|
||||||
import type { BuildOptions } from "../../shared/buildOptions";
|
import type { BuildContext } from "../../shared/buildContext";
|
||||||
import { assert } from "tsafe/assert";
|
import { assert } from "tsafe/assert";
|
||||||
import { basenameOfTheKeycloakifyResourcesDir } from "../../shared/constants";
|
import { basenameOfTheKeycloakifyResourcesDir } from "../../shared/constants";
|
||||||
|
|
||||||
export type BuildOptionsLike = {
|
export type BuildContextLike = {
|
||||||
urlPathname: string | undefined;
|
urlPathname: string | undefined;
|
||||||
};
|
};
|
||||||
|
|
||||||
assert<BuildOptions extends BuildOptionsLike ? true : false>();
|
assert<BuildContext extends BuildContextLike ? true : false>();
|
||||||
|
|
||||||
export function replaceImportsInCssCode(params: { cssCode: string }): {
|
export function replaceImportsInCssCode(params: { cssCode: string }): {
|
||||||
fixedCssCode: string;
|
fixedCssCode: string;
|
||||||
@ -44,11 +44,11 @@ export function replaceImportsInCssCode(params: { cssCode: string }): {
|
|||||||
|
|
||||||
export function generateCssCodeToDefineGlobals(params: {
|
export function generateCssCodeToDefineGlobals(params: {
|
||||||
cssGlobalsToDefine: Record<string, string>;
|
cssGlobalsToDefine: Record<string, string>;
|
||||||
buildOptions: BuildOptionsLike;
|
buildContext: BuildContextLike;
|
||||||
}): {
|
}): {
|
||||||
cssCodeToPrependInHead: string;
|
cssCodeToPrependInHead: string;
|
||||||
} {
|
} {
|
||||||
const { cssGlobalsToDefine, buildOptions } = params;
|
const { cssGlobalsToDefine, buildContext } = params;
|
||||||
|
|
||||||
return {
|
return {
|
||||||
cssCodeToPrependInHead: [
|
cssCodeToPrependInHead: [
|
||||||
@ -59,7 +59,7 @@ export function generateCssCodeToDefineGlobals(params: {
|
|||||||
`--${cssVariableName}:`,
|
`--${cssVariableName}:`,
|
||||||
cssGlobalsToDefine[cssVariableName].replace(
|
cssGlobalsToDefine[cssVariableName].replace(
|
||||||
new RegExp(
|
new RegExp(
|
||||||
`url\\(${(buildOptions.urlPathname ?? "/").replace(
|
`url\\(${(buildContext.urlPathname ?? "/").replace(
|
||||||
/\//g,
|
/\//g,
|
||||||
"\\/"
|
"\\/"
|
||||||
)}`,
|
)}`,
|
||||||
|
@ -1,25 +1,25 @@
|
|||||||
import type { BuildOptions } from "../../shared/buildOptions";
|
import type { BuildContext } from "../../shared/buildContext";
|
||||||
import { assert } from "tsafe/assert";
|
import { assert } from "tsafe/assert";
|
||||||
import { basenameOfTheKeycloakifyResourcesDir } from "../../shared/constants";
|
import { basenameOfTheKeycloakifyResourcesDir } from "../../shared/constants";
|
||||||
|
|
||||||
export type BuildOptionsLike = {
|
export type BuildContextLike = {
|
||||||
urlPathname: string | undefined;
|
urlPathname: string | undefined;
|
||||||
};
|
};
|
||||||
|
|
||||||
assert<BuildOptions extends BuildOptionsLike ? true : false>();
|
assert<BuildContext extends BuildContextLike ? true : false>();
|
||||||
|
|
||||||
export function replaceImportsInInlineCssCode(params: {
|
export function replaceImportsInInlineCssCode(params: {
|
||||||
cssCode: string;
|
cssCode: string;
|
||||||
buildOptions: BuildOptionsLike;
|
buildContext: BuildContextLike;
|
||||||
}): {
|
}): {
|
||||||
fixedCssCode: string;
|
fixedCssCode: string;
|
||||||
} {
|
} {
|
||||||
const { cssCode, buildOptions } = params;
|
const { cssCode, buildContext } = params;
|
||||||
|
|
||||||
const fixedCssCode = cssCode.replace(
|
const fixedCssCode = cssCode.replace(
|
||||||
buildOptions.urlPathname === undefined
|
buildContext.urlPathname === undefined
|
||||||
? /url\(["']?\/([^/][^)"']+)["']?\)/g
|
? /url\(["']?\/([^/][^)"']+)["']?\)/g
|
||||||
: new RegExp(`url\\(["']?${buildOptions.urlPathname}([^)"']+)["']?\\)`, "g"),
|
: new RegExp(`url\\(["']?${buildContext.urlPathname}([^)"']+)["']?\\)`, "g"),
|
||||||
(...[, group]) =>
|
(...[, group]) =>
|
||||||
`url(\${url.resourcesPath}/${basenameOfTheKeycloakifyResourcesDir}/${group})`
|
`url(\${url.resourcesPath}/${basenameOfTheKeycloakifyResourcesDir}/${group})`
|
||||||
);
|
);
|
||||||
|
@ -1,38 +1,38 @@
|
|||||||
import { assert } from "tsafe/assert";
|
import { assert } from "tsafe/assert";
|
||||||
import type { BuildOptions } from "../../../shared/buildOptions";
|
import type { BuildContext } from "../../../shared/buildContext";
|
||||||
import { replaceImportsInJsCode_vite } from "./vite";
|
import { replaceImportsInJsCode_vite } from "./vite";
|
||||||
import { replaceImportsInJsCode_webpack } from "./webpack";
|
import { replaceImportsInJsCode_webpack } from "./webpack";
|
||||||
import * as fs from "fs";
|
import * as fs from "fs";
|
||||||
|
|
||||||
export type BuildOptionsLike = {
|
export type BuildContextLike = {
|
||||||
projectBuildDirPath: string;
|
projectBuildDirPath: string;
|
||||||
assetsDirPath: string;
|
assetsDirPath: string;
|
||||||
urlPathname: string | undefined;
|
urlPathname: string | undefined;
|
||||||
bundler: "vite" | "webpack";
|
bundler: "vite" | "webpack";
|
||||||
};
|
};
|
||||||
|
|
||||||
assert<BuildOptions extends BuildOptionsLike ? true : false>();
|
assert<BuildContext extends BuildContextLike ? true : false>();
|
||||||
|
|
||||||
export function replaceImportsInJsCode(params: {
|
export function replaceImportsInJsCode(params: {
|
||||||
jsCode: string;
|
jsCode: string;
|
||||||
buildOptions: BuildOptionsLike;
|
buildContext: BuildContextLike;
|
||||||
}) {
|
}) {
|
||||||
const { jsCode, buildOptions } = params;
|
const { jsCode, buildContext } = params;
|
||||||
|
|
||||||
const { fixedJsCode } = (() => {
|
const { fixedJsCode } = (() => {
|
||||||
switch (buildOptions.bundler) {
|
switch (buildContext.bundler) {
|
||||||
case "vite":
|
case "vite":
|
||||||
return replaceImportsInJsCode_vite({
|
return replaceImportsInJsCode_vite({
|
||||||
jsCode,
|
jsCode,
|
||||||
buildOptions,
|
buildContext,
|
||||||
basenameOfAssetsFiles: readAssetsDirSync({
|
basenameOfAssetsFiles: readAssetsDirSync({
|
||||||
assetsDirPath: params.buildOptions.assetsDirPath
|
assetsDirPath: params.buildContext.assetsDirPath
|
||||||
})
|
})
|
||||||
});
|
});
|
||||||
case "webpack":
|
case "webpack":
|
||||||
return replaceImportsInJsCode_webpack({
|
return replaceImportsInJsCode_webpack({
|
||||||
jsCode,
|
jsCode,
|
||||||
buildOptions
|
buildContext
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
})();
|
})();
|
||||||
|
@ -3,21 +3,21 @@ import {
|
|||||||
basenameOfTheKeycloakifyResourcesDir
|
basenameOfTheKeycloakifyResourcesDir
|
||||||
} from "../../../shared/constants";
|
} from "../../../shared/constants";
|
||||||
import { assert } from "tsafe/assert";
|
import { assert } from "tsafe/assert";
|
||||||
import type { BuildOptions } from "../../../shared/buildOptions";
|
import type { BuildContext } from "../../../shared/buildContext";
|
||||||
import * as nodePath from "path";
|
import * as nodePath from "path";
|
||||||
import { replaceAll } from "../../../tools/String.prototype.replaceAll";
|
import { replaceAll } from "../../../tools/String.prototype.replaceAll";
|
||||||
|
|
||||||
export type BuildOptionsLike = {
|
export type BuildContextLike = {
|
||||||
projectBuildDirPath: string;
|
projectBuildDirPath: string;
|
||||||
assetsDirPath: string;
|
assetsDirPath: string;
|
||||||
urlPathname: string | undefined;
|
urlPathname: string | undefined;
|
||||||
};
|
};
|
||||||
|
|
||||||
assert<BuildOptions extends BuildOptionsLike ? true : false>();
|
assert<BuildContext extends BuildContextLike ? true : false>();
|
||||||
|
|
||||||
export function replaceImportsInJsCode_vite(params: {
|
export function replaceImportsInJsCode_vite(params: {
|
||||||
jsCode: string;
|
jsCode: string;
|
||||||
buildOptions: BuildOptionsLike;
|
buildContext: BuildContextLike;
|
||||||
basenameOfAssetsFiles: string[];
|
basenameOfAssetsFiles: string[];
|
||||||
systemType?: "posix" | "win32";
|
systemType?: "posix" | "win32";
|
||||||
}): {
|
}): {
|
||||||
@ -25,7 +25,7 @@ export function replaceImportsInJsCode_vite(params: {
|
|||||||
} {
|
} {
|
||||||
const {
|
const {
|
||||||
jsCode,
|
jsCode,
|
||||||
buildOptions,
|
buildContext,
|
||||||
basenameOfAssetsFiles,
|
basenameOfAssetsFiles,
|
||||||
systemType = nodePath.sep === "/" ? "posix" : "win32"
|
systemType = nodePath.sep === "/" ? "posix" : "win32"
|
||||||
} = params;
|
} = params;
|
||||||
@ -35,11 +35,11 @@ export function replaceImportsInJsCode_vite(params: {
|
|||||||
let fixedJsCode = jsCode;
|
let fixedJsCode = jsCode;
|
||||||
|
|
||||||
replace_base_javacript_import: {
|
replace_base_javacript_import: {
|
||||||
if (buildOptions.urlPathname === undefined) {
|
if (buildContext.urlPathname === undefined) {
|
||||||
break replace_base_javacript_import;
|
break replace_base_javacript_import;
|
||||||
}
|
}
|
||||||
// Optimization
|
// Optimization
|
||||||
if (!jsCode.includes(buildOptions.urlPathname)) {
|
if (!jsCode.includes(buildContext.urlPathname)) {
|
||||||
break replace_base_javacript_import;
|
break replace_base_javacript_import;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -47,7 +47,7 @@ export function replaceImportsInJsCode_vite(params: {
|
|||||||
fixedJsCode = fixedJsCode.replace(
|
fixedJsCode = fixedJsCode.replace(
|
||||||
new RegExp(
|
new RegExp(
|
||||||
`([\\w\\$][\\w\\d\\$]*)=function\\(([\\w\\$][\\w\\d\\$]*)\\)\\{return"${replaceAll(
|
`([\\w\\$][\\w\\d\\$]*)=function\\(([\\w\\$][\\w\\d\\$]*)\\)\\{return"${replaceAll(
|
||||||
buildOptions.urlPathname,
|
buildContext.urlPathname,
|
||||||
"/",
|
"/",
|
||||||
"\\/"
|
"\\/"
|
||||||
)}"\\+\\2\\}`,
|
)}"\\+\\2\\}`,
|
||||||
@ -62,8 +62,8 @@ export function replaceImportsInJsCode_vite(params: {
|
|||||||
// Example: "assets/ or "foo/bar/"
|
// Example: "assets/ or "foo/bar/"
|
||||||
const staticDir = (() => {
|
const staticDir = (() => {
|
||||||
let out = pathRelative(
|
let out = pathRelative(
|
||||||
buildOptions.projectBuildDirPath,
|
buildContext.projectBuildDirPath,
|
||||||
buildOptions.assetsDirPath
|
buildContext.assetsDirPath
|
||||||
);
|
);
|
||||||
|
|
||||||
out = replaceAll(out, pathSep, "/") + "/";
|
out = replaceAll(out, pathSep, "/") + "/";
|
||||||
@ -93,7 +93,7 @@ export function replaceImportsInJsCode_vite(params: {
|
|||||||
|
|
||||||
fixedJsCode = replaceAll(
|
fixedJsCode = replaceAll(
|
||||||
fixedJsCode,
|
fixedJsCode,
|
||||||
`"${buildOptions.urlPathname ?? "/"}${relativePathOfAssetFile}"`,
|
`"${buildContext.urlPathname ?? "/"}${relativePathOfAssetFile}"`,
|
||||||
`(window.${nameOfTheGlobal}.url.resourcesPath + "/${basenameOfTheKeycloakifyResourcesDir}/${relativePathOfAssetFile}")`
|
`(window.${nameOfTheGlobal}.url.resourcesPath + "/${basenameOfTheKeycloakifyResourcesDir}/${relativePathOfAssetFile}")`
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
|
@ -3,28 +3,28 @@ import {
|
|||||||
basenameOfTheKeycloakifyResourcesDir
|
basenameOfTheKeycloakifyResourcesDir
|
||||||
} from "../../../shared/constants";
|
} from "../../../shared/constants";
|
||||||
import { assert } from "tsafe/assert";
|
import { assert } from "tsafe/assert";
|
||||||
import type { BuildOptions } from "../../../shared/buildOptions";
|
import type { BuildContext } from "../../../shared/buildContext";
|
||||||
import * as nodePath from "path";
|
import * as nodePath from "path";
|
||||||
import { replaceAll } from "../../../tools/String.prototype.replaceAll";
|
import { replaceAll } from "../../../tools/String.prototype.replaceAll";
|
||||||
|
|
||||||
export type BuildOptionsLike = {
|
export type BuildContextLike = {
|
||||||
projectBuildDirPath: string;
|
projectBuildDirPath: string;
|
||||||
assetsDirPath: string;
|
assetsDirPath: string;
|
||||||
urlPathname: string | undefined;
|
urlPathname: string | undefined;
|
||||||
};
|
};
|
||||||
|
|
||||||
assert<BuildOptions extends BuildOptionsLike ? true : false>();
|
assert<BuildContext extends BuildContextLike ? true : false>();
|
||||||
|
|
||||||
export function replaceImportsInJsCode_webpack(params: {
|
export function replaceImportsInJsCode_webpack(params: {
|
||||||
jsCode: string;
|
jsCode: string;
|
||||||
buildOptions: BuildOptionsLike;
|
buildContext: BuildContextLike;
|
||||||
systemType?: "posix" | "win32";
|
systemType?: "posix" | "win32";
|
||||||
}): {
|
}): {
|
||||||
fixedJsCode: string;
|
fixedJsCode: string;
|
||||||
} {
|
} {
|
||||||
const {
|
const {
|
||||||
jsCode,
|
jsCode,
|
||||||
buildOptions,
|
buildContext,
|
||||||
systemType = nodePath.sep === "/" ? "posix" : "win32"
|
systemType = nodePath.sep === "/" ? "posix" : "win32"
|
||||||
} = params;
|
} = params;
|
||||||
|
|
||||||
@ -32,12 +32,12 @@ export function replaceImportsInJsCode_webpack(params: {
|
|||||||
|
|
||||||
let fixedJsCode = jsCode;
|
let fixedJsCode = jsCode;
|
||||||
|
|
||||||
if (buildOptions.urlPathname !== undefined) {
|
if (buildContext.urlPathname !== undefined) {
|
||||||
// "__esModule",{value:!0})},n.p="/foo-bar/",function(){if("undefined" -> ... n.p="/" ...
|
// "__esModule",{value:!0})},n.p="/foo-bar/",function(){if("undefined" -> ... n.p="/" ...
|
||||||
fixedJsCode = fixedJsCode.replace(
|
fixedJsCode = fixedJsCode.replace(
|
||||||
new RegExp(
|
new RegExp(
|
||||||
`,([a-zA-Z]\\.[a-zA-Z])="${replaceAll(
|
`,([a-zA-Z]\\.[a-zA-Z])="${replaceAll(
|
||||||
buildOptions.urlPathname,
|
buildContext.urlPathname,
|
||||||
"/",
|
"/",
|
||||||
"\\/"
|
"\\/"
|
||||||
)}",`,
|
)}",`,
|
||||||
@ -50,8 +50,8 @@ export function replaceImportsInJsCode_webpack(params: {
|
|||||||
// Example: "static/ or "foo/bar/"
|
// Example: "static/ or "foo/bar/"
|
||||||
const staticDir = (() => {
|
const staticDir = (() => {
|
||||||
let out = pathRelative(
|
let out = pathRelative(
|
||||||
buildOptions.projectBuildDirPath,
|
buildContext.projectBuildDirPath,
|
||||||
buildOptions.assetsDirPath
|
buildContext.assetsDirPath
|
||||||
);
|
);
|
||||||
|
|
||||||
out = replaceAll(out, pathSep, "/") + "/";
|
out = replaceAll(out, pathSep, "/") + "/";
|
||||||
|
@ -9,8 +9,7 @@ import { assert } from "tsafe";
|
|||||||
import * as child_process from "child_process";
|
import * as child_process from "child_process";
|
||||||
import { vitePluginSubScriptEnvNames } from "./constants";
|
import { vitePluginSubScriptEnvNames } from "./constants";
|
||||||
|
|
||||||
/** Consolidated build option gathered form CLI arguments and config in package.json */
|
export type BuildContext = {
|
||||||
export type BuildOptions = {
|
|
||||||
bundler: "vite" | "webpack";
|
bundler: "vite" | "webpack";
|
||||||
themeVersion: string;
|
themeVersion: string;
|
||||||
themeNames: string[];
|
themeNames: string[];
|
||||||
@ -33,7 +32,7 @@ export type BuildOptions = {
|
|||||||
environmentVariables: { name: string; default: string }[];
|
environmentVariables: { name: string; default: string }[];
|
||||||
};
|
};
|
||||||
|
|
||||||
export type UserProvidedBuildOptions = {
|
export type BuildOptions = {
|
||||||
themeName?: string | string[];
|
themeName?: string | string[];
|
||||||
environmentVariables?: { name: string; default: string }[];
|
environmentVariables?: { name: string; default: string }[];
|
||||||
extraThemeProperties?: string[];
|
extraThemeProperties?: string[];
|
||||||
@ -49,12 +48,12 @@ export type ResolvedViteConfig = {
|
|||||||
publicDir: string;
|
publicDir: string;
|
||||||
assetsDir: string;
|
assetsDir: string;
|
||||||
urlPathname: string | undefined;
|
urlPathname: string | undefined;
|
||||||
userProvidedBuildOptions: UserProvidedBuildOptions;
|
buildOptions: BuildOptions;
|
||||||
};
|
};
|
||||||
|
|
||||||
export function readBuildOptions(params: {
|
export function getBuildContext(params: {
|
||||||
cliCommandOptions: CliCommandOptions;
|
cliCommandOptions: CliCommandOptions;
|
||||||
}): BuildOptions {
|
}): BuildContext {
|
||||||
const { cliCommandOptions } = params;
|
const { cliCommandOptions } = params;
|
||||||
|
|
||||||
const projectDirPath = (() => {
|
const projectDirPath = (() => {
|
||||||
@ -107,7 +106,7 @@ export function readBuildOptions(params: {
|
|||||||
name: string;
|
name: string;
|
||||||
version?: string;
|
version?: string;
|
||||||
homepage?: string;
|
homepage?: string;
|
||||||
keycloakify?: UserProvidedBuildOptions & {
|
keycloakify?: BuildOptions & {
|
||||||
projectBuildDirPath?: string;
|
projectBuildDirPath?: string;
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
@ -143,13 +142,13 @@ export function readBuildOptions(params: {
|
|||||||
);
|
);
|
||||||
})();
|
})();
|
||||||
|
|
||||||
const userProvidedBuildOptions: UserProvidedBuildOptions = {
|
const buildOptions: BuildOptions = {
|
||||||
...parsedPackageJson.keycloakify,
|
...parsedPackageJson.keycloakify,
|
||||||
...resolvedViteConfig?.userProvidedBuildOptions
|
...resolvedViteConfig?.buildOptions
|
||||||
};
|
};
|
||||||
|
|
||||||
const themeNames = (() => {
|
const themeNames = (() => {
|
||||||
if (userProvidedBuildOptions.themeName === undefined) {
|
if (buildOptions.themeName === undefined) {
|
||||||
return [
|
return [
|
||||||
parsedPackageJson.name
|
parsedPackageJson.name
|
||||||
.replace(/^@(.*)/, "$1")
|
.replace(/^@(.*)/, "$1")
|
||||||
@ -158,11 +157,11 @@ export function readBuildOptions(params: {
|
|||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
if (typeof userProvidedBuildOptions.themeName === "string") {
|
if (typeof buildOptions.themeName === "string") {
|
||||||
return [userProvidedBuildOptions.themeName];
|
return [buildOptions.themeName];
|
||||||
}
|
}
|
||||||
|
|
||||||
return userProvidedBuildOptions.themeName;
|
return buildOptions.themeName;
|
||||||
})();
|
})();
|
||||||
|
|
||||||
const projectBuildDirPath = (() => {
|
const projectBuildDirPath = (() => {
|
||||||
@ -194,13 +193,13 @@ export function readBuildOptions(params: {
|
|||||||
themeVersion:
|
themeVersion:
|
||||||
process.env.KEYCLOAKIFY_THEME_VERSION ?? parsedPackageJson.version ?? "0.0.0",
|
process.env.KEYCLOAKIFY_THEME_VERSION ?? parsedPackageJson.version ?? "0.0.0",
|
||||||
themeNames,
|
themeNames,
|
||||||
extraThemeProperties: userProvidedBuildOptions.extraThemeProperties,
|
extraThemeProperties: buildOptions.extraThemeProperties,
|
||||||
groupId: (() => {
|
groupId: (() => {
|
||||||
const fallbackGroupId = `${themeNames[0]}.keycloak`;
|
const fallbackGroupId = `${themeNames[0]}.keycloak`;
|
||||||
|
|
||||||
return (
|
return (
|
||||||
process.env.KEYCLOAKIFY_GROUP_ID ??
|
process.env.KEYCLOAKIFY_GROUP_ID ??
|
||||||
userProvidedBuildOptions.groupId ??
|
buildOptions.groupId ??
|
||||||
(parsedPackageJson.homepage === undefined
|
(parsedPackageJson.homepage === undefined
|
||||||
? fallbackGroupId
|
? fallbackGroupId
|
||||||
: urlParse(parsedPackageJson.homepage)
|
: urlParse(parsedPackageJson.homepage)
|
||||||
@ -212,16 +211,16 @@ export function readBuildOptions(params: {
|
|||||||
})(),
|
})(),
|
||||||
artifactId:
|
artifactId:
|
||||||
process.env.KEYCLOAKIFY_ARTIFACT_ID ??
|
process.env.KEYCLOAKIFY_ARTIFACT_ID ??
|
||||||
userProvidedBuildOptions.artifactId ??
|
buildOptions.artifactId ??
|
||||||
`${themeNames[0]}-keycloak-theme`,
|
`${themeNames[0]}-keycloak-theme`,
|
||||||
loginThemeResourcesFromKeycloakVersion:
|
loginThemeResourcesFromKeycloakVersion:
|
||||||
userProvidedBuildOptions.loginThemeResourcesFromKeycloakVersion ?? "24.0.4",
|
buildOptions.loginThemeResourcesFromKeycloakVersion ?? "24.0.4",
|
||||||
projectDirPath,
|
projectDirPath,
|
||||||
projectBuildDirPath,
|
projectBuildDirPath,
|
||||||
keycloakifyBuildDirPath: (() => {
|
keycloakifyBuildDirPath: (() => {
|
||||||
if (userProvidedBuildOptions.keycloakifyBuildDirPath !== undefined) {
|
if (buildOptions.keycloakifyBuildDirPath !== undefined) {
|
||||||
return getAbsoluteAndInOsFormatPath({
|
return getAbsoluteAndInOsFormatPath({
|
||||||
pathIsh: userProvidedBuildOptions.keycloakifyBuildDirPath,
|
pathIsh: buildOptions.keycloakifyBuildDirPath,
|
||||||
cwd: projectDirPath
|
cwd: projectDirPath
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@ -304,7 +303,7 @@ export function readBuildOptions(params: {
|
|||||||
return pathJoin(projectBuildDirPath, resolvedViteConfig.assetsDir);
|
return pathJoin(projectBuildDirPath, resolvedViteConfig.assetsDir);
|
||||||
})(),
|
})(),
|
||||||
npmWorkspaceRootDirPath,
|
npmWorkspaceRootDirPath,
|
||||||
kcContextExclusionsFtlCode: userProvidedBuildOptions.kcContextExclusionsFtlCode,
|
kcContextExclusionsFtlCode: buildOptions.kcContextExclusionsFtlCode,
|
||||||
environmentVariables: userProvidedBuildOptions.environmentVariables ?? []
|
environmentVariables: buildOptions.environmentVariables ?? []
|
||||||
};
|
};
|
||||||
}
|
}
|
@ -1,6 +1,6 @@
|
|||||||
import {
|
import {
|
||||||
downloadKeycloakStaticResources,
|
downloadKeycloakStaticResources,
|
||||||
type BuildOptionsLike as BuildOptionsLike_downloadKeycloakStaticResources
|
type BuildContextLike as BuildContextLike_downloadKeycloakStaticResources
|
||||||
} from "./downloadKeycloakStaticResources";
|
} from "./downloadKeycloakStaticResources";
|
||||||
import { join as pathJoin, relative as pathRelative } from "path";
|
import { join as pathJoin, relative as pathRelative } from "path";
|
||||||
import {
|
import {
|
||||||
@ -12,21 +12,21 @@ import { readThisNpmPackageVersion } from "../tools/readThisNpmPackageVersion";
|
|||||||
import { assert } from "tsafe/assert";
|
import { assert } from "tsafe/assert";
|
||||||
import * as fs from "fs";
|
import * as fs from "fs";
|
||||||
import { rmSync } from "../tools/fs.rmSync";
|
import { rmSync } from "../tools/fs.rmSync";
|
||||||
import type { BuildOptions } from "./buildOptions";
|
import type { BuildContext } from "./buildContext";
|
||||||
|
|
||||||
export type BuildOptionsLike = BuildOptionsLike_downloadKeycloakStaticResources & {
|
export type BuildContextLike = BuildContextLike_downloadKeycloakStaticResources & {
|
||||||
loginThemeResourcesFromKeycloakVersion: string;
|
loginThemeResourcesFromKeycloakVersion: string;
|
||||||
publicDirPath: string;
|
publicDirPath: string;
|
||||||
};
|
};
|
||||||
|
|
||||||
assert<BuildOptions extends BuildOptionsLike ? true : false>();
|
assert<BuildContext extends BuildContextLike ? true : false>();
|
||||||
|
|
||||||
export async function copyKeycloakResourcesToPublic(params: {
|
export async function copyKeycloakResourcesToPublic(params: {
|
||||||
buildOptions: BuildOptionsLike;
|
buildContext: BuildContextLike;
|
||||||
}) {
|
}) {
|
||||||
const { buildOptions } = params;
|
const { buildContext } = params;
|
||||||
|
|
||||||
const destDirPath = pathJoin(buildOptions.publicDirPath, keycloak_resources);
|
const destDirPath = pathJoin(buildContext.publicDirPath, keycloak_resources);
|
||||||
|
|
||||||
const keycloakifyBuildinfoFilePath = pathJoin(destDirPath, "keycloakify.buildinfo");
|
const keycloakifyBuildinfoFilePath = pathJoin(destDirPath, "keycloakify.buildinfo");
|
||||||
|
|
||||||
@ -34,12 +34,12 @@ export async function copyKeycloakResourcesToPublic(params: {
|
|||||||
{
|
{
|
||||||
destDirPath,
|
destDirPath,
|
||||||
keycloakifyVersion: readThisNpmPackageVersion(),
|
keycloakifyVersion: readThisNpmPackageVersion(),
|
||||||
buildOptions: {
|
buildContext: {
|
||||||
loginThemeResourcesFromKeycloakVersion: readThisNpmPackageVersion(),
|
loginThemeResourcesFromKeycloakVersion: readThisNpmPackageVersion(),
|
||||||
cacheDirPath: pathRelative(destDirPath, buildOptions.cacheDirPath),
|
cacheDirPath: pathRelative(destDirPath, buildContext.cacheDirPath),
|
||||||
npmWorkspaceRootDirPath: pathRelative(
|
npmWorkspaceRootDirPath: pathRelative(
|
||||||
destDirPath,
|
destDirPath,
|
||||||
buildOptions.npmWorkspaceRootDirPath
|
buildContext.npmWorkspaceRootDirPath
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
@ -74,14 +74,14 @@ export async function copyKeycloakResourcesToPublic(params: {
|
|||||||
keycloakVersion: (() => {
|
keycloakVersion: (() => {
|
||||||
switch (themeType) {
|
switch (themeType) {
|
||||||
case "login":
|
case "login":
|
||||||
return buildOptions.loginThemeResourcesFromKeycloakVersion;
|
return buildContext.loginThemeResourcesFromKeycloakVersion;
|
||||||
case "account":
|
case "account":
|
||||||
return lastKeycloakVersionWithAccountV1;
|
return lastKeycloakVersionWithAccountV1;
|
||||||
}
|
}
|
||||||
})(),
|
})(),
|
||||||
themeType,
|
themeType,
|
||||||
themeDirPath: destDirPath,
|
themeDirPath: destDirPath,
|
||||||
buildOptions
|
buildContext
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,27 +1,27 @@
|
|||||||
import { join as pathJoin, relative as pathRelative } from "path";
|
import { join as pathJoin, relative as pathRelative } from "path";
|
||||||
import { type BuildOptions } from "./buildOptions";
|
import { type BuildContext } from "./buildContext";
|
||||||
import { assert } from "tsafe/assert";
|
import { assert } from "tsafe/assert";
|
||||||
import { lastKeycloakVersionWithAccountV1 } from "./constants";
|
import { lastKeycloakVersionWithAccountV1 } from "./constants";
|
||||||
import { downloadAndExtractArchive } from "../tools/downloadAndExtractArchive";
|
import { downloadAndExtractArchive } from "../tools/downloadAndExtractArchive";
|
||||||
import { isInside } from "../tools/isInside";
|
import { isInside } from "../tools/isInside";
|
||||||
|
|
||||||
export type BuildOptionsLike = {
|
export type BuildContextLike = {
|
||||||
cacheDirPath: string;
|
cacheDirPath: string;
|
||||||
npmWorkspaceRootDirPath: string;
|
npmWorkspaceRootDirPath: string;
|
||||||
};
|
};
|
||||||
|
|
||||||
assert<BuildOptions extends BuildOptionsLike ? true : false>();
|
assert<BuildContext extends BuildContextLike ? true : false>();
|
||||||
|
|
||||||
export async function downloadKeycloakDefaultTheme(params: {
|
export async function downloadKeycloakDefaultTheme(params: {
|
||||||
keycloakVersion: string;
|
keycloakVersion: string;
|
||||||
buildOptions: BuildOptionsLike;
|
buildContext: BuildContextLike;
|
||||||
}): Promise<{ defaultThemeDirPath: string }> {
|
}): Promise<{ defaultThemeDirPath: string }> {
|
||||||
const { keycloakVersion, buildOptions } = params;
|
const { keycloakVersion, buildContext } = params;
|
||||||
|
|
||||||
const { extractedDirPath } = await downloadAndExtractArchive({
|
const { extractedDirPath } = await downloadAndExtractArchive({
|
||||||
url: `https://repo1.maven.org/maven2/org/keycloak/keycloak-themes/${keycloakVersion}/keycloak-themes-${keycloakVersion}.jar`,
|
url: `https://repo1.maven.org/maven2/org/keycloak/keycloak-themes/${keycloakVersion}/keycloak-themes-${keycloakVersion}.jar`,
|
||||||
cacheDirPath: buildOptions.cacheDirPath,
|
cacheDirPath: buildContext.cacheDirPath,
|
||||||
npmWorkspaceRootDirPath: buildOptions.npmWorkspaceRootDirPath,
|
npmWorkspaceRootDirPath: buildContext.npmWorkspaceRootDirPath,
|
||||||
uniqueIdOfOnOnArchiveFile: "downloadKeycloakDefaultTheme",
|
uniqueIdOfOnOnArchiveFile: "downloadKeycloakDefaultTheme",
|
||||||
onArchiveFile: async params => {
|
onArchiveFile: async params => {
|
||||||
if (!isInside({ dirPath: "theme", filePath: params.fileRelativePath })) {
|
if (!isInside({ dirPath: "theme", filePath: params.fileRelativePath })) {
|
||||||
|
@ -2,28 +2,28 @@ import { transformCodebase } from "../tools/transformCodebase";
|
|||||||
import { join as pathJoin } from "path";
|
import { join as pathJoin } from "path";
|
||||||
import {
|
import {
|
||||||
downloadKeycloakDefaultTheme,
|
downloadKeycloakDefaultTheme,
|
||||||
type BuildOptionsLike as BuildOptionsLike_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 { BuildOptions } from "./buildOptions";
|
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";
|
||||||
|
|
||||||
export type BuildOptionsLike = BuildOptionsLike_downloadKeycloakDefaultTheme & {};
|
export type BuildContextLike = BuildContextLike_downloadKeycloakDefaultTheme & {};
|
||||||
|
|
||||||
assert<BuildOptions extends BuildOptionsLike ? true : false>();
|
assert<BuildContext extends BuildContextLike ? true : false>();
|
||||||
|
|
||||||
export async function downloadKeycloakStaticResources(params: {
|
export async function downloadKeycloakStaticResources(params: {
|
||||||
themeType: ThemeType;
|
themeType: ThemeType;
|
||||||
themeDirPath: string;
|
themeDirPath: string;
|
||||||
keycloakVersion: string;
|
keycloakVersion: string;
|
||||||
buildOptions: BuildOptionsLike;
|
buildContext: BuildContextLike;
|
||||||
}) {
|
}) {
|
||||||
const { themeType, themeDirPath, keycloakVersion, buildOptions } = params;
|
const { themeType, themeDirPath, keycloakVersion, buildContext } = params;
|
||||||
|
|
||||||
const { defaultThemeDirPath } = await downloadKeycloakDefaultTheme({
|
const { defaultThemeDirPath } = await downloadKeycloakDefaultTheme({
|
||||||
keycloakVersion,
|
keycloakVersion,
|
||||||
buildOptions
|
buildContext
|
||||||
});
|
});
|
||||||
|
|
||||||
const resourcesDirPath = pathJoin(themeDirPath, themeType, "resources");
|
const resourcesDirPath = pathJoin(themeDirPath, themeType, "resources");
|
||||||
|
@ -1,24 +1,24 @@
|
|||||||
import { assert } from "tsafe/assert";
|
import { assert } from "tsafe/assert";
|
||||||
import type { BuildOptions } from "./buildOptions";
|
import type { BuildContext } from "./buildContext";
|
||||||
import { getThemeSrcDirPath } from "./getThemeSrcDirPath";
|
import { getThemeSrcDirPath } from "./getThemeSrcDirPath";
|
||||||
import * as fs from "fs/promises";
|
import * as fs from "fs/promises";
|
||||||
import { join as pathJoin } from "path";
|
import { join as pathJoin } from "path";
|
||||||
|
|
||||||
export type BuildOptionsLike = {
|
export type BuildContextLike = {
|
||||||
projectDirPath: string;
|
projectDirPath: string;
|
||||||
themeNames: string[];
|
themeNames: string[];
|
||||||
environmentVariables: { name: string; default: string }[];
|
environmentVariables: { name: string; default: string }[];
|
||||||
};
|
};
|
||||||
|
|
||||||
assert<BuildOptions extends BuildOptionsLike ? true : false>();
|
assert<BuildContext extends BuildContextLike ? true : false>();
|
||||||
|
|
||||||
export async function generateKcGenTs(params: {
|
export async function generateKcGenTs(params: {
|
||||||
buildOptions: BuildOptionsLike;
|
buildContext: BuildContextLike;
|
||||||
}): Promise<void> {
|
}): Promise<void> {
|
||||||
const { buildOptions } = params;
|
const { buildContext } = params;
|
||||||
|
|
||||||
const { themeSrcDirPath } = getThemeSrcDirPath({
|
const { themeSrcDirPath } = getThemeSrcDirPath({
|
||||||
projectDirPath: buildOptions.projectDirPath
|
projectDirPath: buildContext.projectDirPath
|
||||||
});
|
});
|
||||||
|
|
||||||
await fs.writeFile(
|
await fs.writeFile(
|
||||||
@ -35,17 +35,17 @@ export async function generateKcGenTs(params: {
|
|||||||
``,
|
``,
|
||||||
`// This file is auto-generated by Keycloakify`,
|
`// This file is auto-generated by Keycloakify`,
|
||||||
``,
|
``,
|
||||||
`export type ThemeName = ${buildOptions.themeNames.map(themeName => `"${themeName}"`).join(" | ")};`,
|
`export type ThemeName = ${buildContext.themeNames.map(themeName => `"${themeName}"`).join(" | ")};`,
|
||||||
``,
|
``,
|
||||||
`export const themeNames: ThemeName[] = [${buildOptions.themeNames.map(themeName => `"${themeName}"`).join(", ")}];`,
|
`export const themeNames: ThemeName[] = [${buildContext.themeNames.map(themeName => `"${themeName}"`).join(", ")}];`,
|
||||||
``,
|
``,
|
||||||
`export type KcEnvName = ${buildOptions.environmentVariables.length === 0 ? "never" : buildOptions.environmentVariables.map(({ name }) => `"${name}"`).join(" | ")};`,
|
`export type KcEnvName = ${buildContext.environmentVariables.length === 0 ? "never" : buildContext.environmentVariables.map(({ name }) => `"${name}"`).join(" | ")};`,
|
||||||
``,
|
``,
|
||||||
`export const KcEnvNames: KcEnvName[] = [${buildOptions.environmentVariables.map(({ name }) => `"${name}"`).join(", ")}];`,
|
`export const KcEnvNames: KcEnvName[] = [${buildContext.environmentVariables.map(({ name }) => `"${name}"`).join(", ")}];`,
|
||||||
``,
|
``,
|
||||||
`export const kcEnvDefaults: Record<KcEnvName, string> = ${JSON.stringify(
|
`export const kcEnvDefaults: Record<KcEnvName, string> = ${JSON.stringify(
|
||||||
Object.fromEntries(
|
Object.fromEntries(
|
||||||
buildOptions.environmentVariables.map(
|
buildContext.environmentVariables.map(
|
||||||
({ name, default: defaultValue }) => [name, defaultValue]
|
({ name, default: defaultValue }) => [name, defaultValue]
|
||||||
)
|
)
|
||||||
),
|
),
|
||||||
|
@ -2,11 +2,11 @@ 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";
|
||||||
import { is } from "tsafe/is";
|
import { is } from "tsafe/is";
|
||||||
import type { BuildOptions } from "../shared/buildOptions";
|
import type { BuildContext } from "../shared/buildContext";
|
||||||
import * as fs from "fs";
|
import * as fs from "fs";
|
||||||
import { join as pathJoin } from "path";
|
import { join as pathJoin } from "path";
|
||||||
|
|
||||||
export type BuildOptionsLike = {
|
export type BuildContextLike = {
|
||||||
projectDirPath: string;
|
projectDirPath: string;
|
||||||
keycloakifyBuildDirPath: string;
|
keycloakifyBuildDirPath: string;
|
||||||
bundler: "vite" | "webpack";
|
bundler: "vite" | "webpack";
|
||||||
@ -14,14 +14,14 @@ export type BuildOptionsLike = {
|
|||||||
projectBuildDirPath: string;
|
projectBuildDirPath: string;
|
||||||
};
|
};
|
||||||
|
|
||||||
assert<BuildOptions extends BuildOptionsLike ? true : false>();
|
assert<BuildContext extends BuildContextLike ? true : false>();
|
||||||
|
|
||||||
export async function appBuild(params: {
|
export async function appBuild(params: {
|
||||||
buildOptions: BuildOptionsLike;
|
buildContext: BuildContextLike;
|
||||||
}): Promise<{ isAppBuildSuccess: boolean }> {
|
}): Promise<{ isAppBuildSuccess: boolean }> {
|
||||||
const { buildOptions } = params;
|
const { buildContext } = params;
|
||||||
|
|
||||||
const { bundler } = buildOptions;
|
const { bundler } = buildContext;
|
||||||
|
|
||||||
const { command, args, cwd } = (() => {
|
const { command, args, cwd } = (() => {
|
||||||
switch (bundler) {
|
switch (bundler) {
|
||||||
@ -29,12 +29,12 @@ export async function appBuild(params: {
|
|||||||
return {
|
return {
|
||||||
command: "npx",
|
command: "npx",
|
||||||
args: ["vite", "build"],
|
args: ["vite", "build"],
|
||||||
cwd: buildOptions.projectDirPath
|
cwd: buildContext.projectDirPath
|
||||||
};
|
};
|
||||||
case "webpack": {
|
case "webpack": {
|
||||||
for (const dirPath of [
|
for (const dirPath of [
|
||||||
buildOptions.projectDirPath,
|
buildContext.projectDirPath,
|
||||||
buildOptions.npmWorkspaceRootDirPath
|
buildContext.npmWorkspaceRootDirPath
|
||||||
]) {
|
]) {
|
||||||
try {
|
try {
|
||||||
const parsedPackageJson = JSON.parse(
|
const parsedPackageJson = JSON.parse(
|
||||||
|
@ -2,27 +2,27 @@ import { skipBuildJarsEnvName } 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";
|
||||||
import type { BuildOptions } from "../shared/buildOptions";
|
import type { BuildContext } from "../shared/buildContext";
|
||||||
|
|
||||||
export type BuildOptionsLike = {
|
export type BuildContextLike = {
|
||||||
projectDirPath: string;
|
projectDirPath: string;
|
||||||
keycloakifyBuildDirPath: string;
|
keycloakifyBuildDirPath: string;
|
||||||
bundler: "vite" | "webpack";
|
bundler: "vite" | "webpack";
|
||||||
npmWorkspaceRootDirPath: string;
|
npmWorkspaceRootDirPath: string;
|
||||||
};
|
};
|
||||||
|
|
||||||
assert<BuildOptions extends BuildOptionsLike ? true : false>();
|
assert<BuildContext extends BuildContextLike ? true : false>();
|
||||||
|
|
||||||
export async function keycloakifyBuild(params: {
|
export async function keycloakifyBuild(params: {
|
||||||
doSkipBuildJars: boolean;
|
doSkipBuildJars: boolean;
|
||||||
buildOptions: BuildOptionsLike;
|
buildContext: BuildContextLike;
|
||||||
}): Promise<{ isKeycloakifyBuildSuccess: boolean }> {
|
}): Promise<{ isKeycloakifyBuildSuccess: boolean }> {
|
||||||
const { buildOptions, doSkipBuildJars } = params;
|
const { buildContext, doSkipBuildJars } = params;
|
||||||
|
|
||||||
const dResult = new Deferred<{ isSuccess: boolean }>();
|
const dResult = new Deferred<{ isSuccess: boolean }>();
|
||||||
|
|
||||||
const child = child_process.spawn("npx", ["keycloakify", "build"], {
|
const child = child_process.spawn("npx", ["keycloakify", "build"], {
|
||||||
cwd: buildOptions.projectDirPath,
|
cwd: buildContext.projectDirPath,
|
||||||
env: {
|
env: {
|
||||||
...process.env,
|
...process.env,
|
||||||
...(doSkipBuildJars ? { [skipBuildJarsEnvName]: "true" } : {})
|
...(doSkipBuildJars ? { [skipBuildJarsEnvName]: "true" } : {})
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
import { readBuildOptions } from "../shared/buildOptions";
|
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";
|
||||||
@ -81,11 +81,11 @@ export async function command(params: { cliCommandOptions: CliCommandOptions })
|
|||||||
|
|
||||||
const { cliCommandOptions } = params;
|
const { cliCommandOptions } = params;
|
||||||
|
|
||||||
const buildOptions = readBuildOptions({ cliCommandOptions });
|
const buildContext = getBuildContext({ cliCommandOptions });
|
||||||
|
|
||||||
{
|
{
|
||||||
const { isAppBuildSuccess } = await appBuild({
|
const { isAppBuildSuccess } = await appBuild({
|
||||||
buildOptions
|
buildContext
|
||||||
});
|
});
|
||||||
|
|
||||||
if (!isAppBuildSuccess) {
|
if (!isAppBuildSuccess) {
|
||||||
@ -99,7 +99,7 @@ export async function command(params: { cliCommandOptions: CliCommandOptions })
|
|||||||
|
|
||||||
const { isKeycloakifyBuildSuccess } = await keycloakifyBuild({
|
const { isKeycloakifyBuildSuccess } = await keycloakifyBuild({
|
||||||
doSkipBuildJars: false,
|
doSkipBuildJars: false,
|
||||||
buildOptions
|
buildContext
|
||||||
});
|
});
|
||||||
|
|
||||||
if (!isKeycloakifyBuildSuccess) {
|
if (!isKeycloakifyBuildSuccess) {
|
||||||
@ -113,7 +113,7 @@ export async function command(params: { cliCommandOptions: CliCommandOptions })
|
|||||||
}
|
}
|
||||||
|
|
||||||
const metaInfKeycloakThemes = readMetaInfKeycloakThemes({
|
const metaInfKeycloakThemes = readMetaInfKeycloakThemes({
|
||||||
keycloakifyBuildDirPath: buildOptions.keycloakifyBuildDirPath
|
keycloakifyBuildDirPath: buildContext.keycloakifyBuildDirPath
|
||||||
});
|
});
|
||||||
|
|
||||||
const doesImplementAccountTheme = metaInfKeycloakThemes.themes.some(
|
const doesImplementAccountTheme = metaInfKeycloakThemes.themes.some(
|
||||||
@ -139,7 +139,7 @@ export async function command(params: { cliCommandOptions: CliCommandOptions })
|
|||||||
|
|
||||||
const { keycloakVersion } = await promptKeycloakVersion({
|
const { keycloakVersion } = await promptKeycloakVersion({
|
||||||
startingFromMajor: 17,
|
startingFromMajor: 17,
|
||||||
cacheDirPath: buildOptions.cacheDirPath
|
cacheDirPath: buildContext.cacheDirPath
|
||||||
});
|
});
|
||||||
|
|
||||||
console.log(`→ ${keycloakVersion}`);
|
console.log(`→ ${keycloakVersion}`);
|
||||||
@ -260,7 +260,7 @@ export async function command(params: { cliCommandOptions: CliCommandOptions })
|
|||||||
return pathJoin(dirPath, value);
|
return pathJoin(dirPath, value);
|
||||||
})();
|
})();
|
||||||
|
|
||||||
const jarFilePath = pathJoin(buildOptions.keycloakifyBuildDirPath, jarFileBasename);
|
const jarFilePath = pathJoin(buildContext.keycloakifyBuildDirPath, jarFileBasename);
|
||||||
|
|
||||||
const { doUseBuiltInAccountV1Theme } = await (async () => {
|
const { doUseBuiltInAccountV1Theme } = await (async () => {
|
||||||
let doUseBuiltInAccountV1Theme = false;
|
let doUseBuiltInAccountV1Theme = false;
|
||||||
@ -268,7 +268,7 @@ export async function command(params: { cliCommandOptions: CliCommandOptions })
|
|||||||
await extractArchive({
|
await extractArchive({
|
||||||
archiveFilePath: jarFilePath,
|
archiveFilePath: jarFilePath,
|
||||||
onArchiveFile: async ({ relativeFilePathInArchive, readFile, earlyExit }) => {
|
onArchiveFile: async ({ relativeFilePathInArchive, readFile, earlyExit }) => {
|
||||||
for (const themeName of buildOptions.themeNames) {
|
for (const themeName of buildContext.themeNames) {
|
||||||
if (
|
if (
|
||||||
relativeFilePathInArchive ===
|
relativeFilePathInArchive ===
|
||||||
pathJoin("theme", themeName, "account", "theme.properties")
|
pathJoin("theme", themeName, "account", "theme.properties")
|
||||||
@ -293,9 +293,9 @@ export async function command(params: { cliCommandOptions: CliCommandOptions })
|
|||||||
const accountThemePropertyPatch = !doUseBuiltInAccountV1Theme
|
const accountThemePropertyPatch = !doUseBuiltInAccountV1Theme
|
||||||
? undefined
|
? undefined
|
||||||
: () => {
|
: () => {
|
||||||
for (const themeName of buildOptions.themeNames) {
|
for (const themeName of buildContext.themeNames) {
|
||||||
const filePath = pathJoin(
|
const filePath = pathJoin(
|
||||||
buildOptions.keycloakifyBuildDirPath,
|
buildContext.keycloakifyBuildDirPath,
|
||||||
"src",
|
"src",
|
||||||
"main",
|
"main",
|
||||||
"resources",
|
"resources",
|
||||||
@ -347,12 +347,12 @@ export async function command(params: { cliCommandOptions: CliCommandOptions })
|
|||||||
? ["-e", "JAVA_OPTS=-Dkeycloak.profile=preview"]
|
? ["-e", "JAVA_OPTS=-Dkeycloak.profile=preview"]
|
||||||
: []),
|
: []),
|
||||||
...[
|
...[
|
||||||
...buildOptions.themeNames,
|
...buildContext.themeNames,
|
||||||
...(doUseBuiltInAccountV1Theme ? [] : [accountV1ThemeName])
|
...(doUseBuiltInAccountV1Theme ? [] : [accountV1ThemeName])
|
||||||
]
|
]
|
||||||
.map(themeName => ({
|
.map(themeName => ({
|
||||||
localDirPath: pathJoin(
|
localDirPath: pathJoin(
|
||||||
buildOptions.keycloakifyBuildDirPath,
|
buildContext.keycloakifyBuildDirPath,
|
||||||
"src",
|
"src",
|
||||||
"main",
|
"main",
|
||||||
"resources",
|
"resources",
|
||||||
@ -366,7 +366,7 @@ export async function command(params: { cliCommandOptions: CliCommandOptions })
|
|||||||
`${localDirPath}:${containerDirPath}:rw`
|
`${localDirPath}:${containerDirPath}:rw`
|
||||||
])
|
])
|
||||||
.flat(),
|
.flat(),
|
||||||
...buildOptions.environmentVariables
|
...buildContext.environmentVariables
|
||||||
.map(({ name }) => ({ name, envValue: process.env[name] }))
|
.map(({ name }) => ({ name, envValue: process.env[name] }))
|
||||||
.map(({ name, envValue }) =>
|
.map(({ name, envValue }) =>
|
||||||
envValue === undefined ? undefined : { name, envValue }
|
envValue === undefined ? undefined : { name, envValue }
|
||||||
@ -385,7 +385,7 @@ export async function command(params: { cliCommandOptions: CliCommandOptions })
|
|||||||
...(realmJsonFilePath === undefined ? [] : ["--import-realm"])
|
...(realmJsonFilePath === undefined ? [] : ["--import-realm"])
|
||||||
],
|
],
|
||||||
{
|
{
|
||||||
cwd: buildOptions.keycloakifyBuildDirPath
|
cwd: buildContext.keycloakifyBuildDirPath
|
||||||
}
|
}
|
||||||
] as const;
|
] as const;
|
||||||
|
|
||||||
@ -397,7 +397,7 @@ export async function command(params: { cliCommandOptions: CliCommandOptions })
|
|||||||
|
|
||||||
child.on("exit", process.exit);
|
child.on("exit", process.exit);
|
||||||
|
|
||||||
const srcDirPath = pathJoin(buildOptions.projectDirPath, "src");
|
const srcDirPath = pathJoin(buildContext.projectDirPath, "src");
|
||||||
|
|
||||||
{
|
{
|
||||||
const handler = async (data: Buffer) => {
|
const handler = async (data: Buffer) => {
|
||||||
@ -429,7 +429,7 @@ export async function command(params: { cliCommandOptions: CliCommandOptions })
|
|||||||
`- password: ${chalk.cyan.bold("password123")}`,
|
`- password: ${chalk.cyan.bold("password123")}`,
|
||||||
"",
|
"",
|
||||||
`Watching for changes in ${chalk.bold(
|
`Watching for changes in ${chalk.bold(
|
||||||
`.${pathSep}${pathRelative(process.cwd(), buildOptions.projectDirPath)}`
|
`.${pathSep}${pathRelative(process.cwd(), buildContext.projectDirPath)}`
|
||||||
)}`
|
)}`
|
||||||
].join("\n")
|
].join("\n")
|
||||||
);
|
);
|
||||||
@ -443,7 +443,7 @@ export async function command(params: { cliCommandOptions: CliCommandOptions })
|
|||||||
console.log(chalk.cyan("Detected changes in the theme. Rebuilding ..."));
|
console.log(chalk.cyan("Detected changes in the theme. Rebuilding ..."));
|
||||||
|
|
||||||
const { isAppBuildSuccess } = await appBuild({
|
const { isAppBuildSuccess } = await appBuild({
|
||||||
buildOptions
|
buildContext
|
||||||
});
|
});
|
||||||
|
|
||||||
if (!isAppBuildSuccess) {
|
if (!isAppBuildSuccess) {
|
||||||
@ -452,7 +452,7 @@ export async function command(params: { cliCommandOptions: CliCommandOptions })
|
|||||||
|
|
||||||
const { isKeycloakifyBuildSuccess } = await keycloakifyBuild({
|
const { isKeycloakifyBuildSuccess } = await keycloakifyBuild({
|
||||||
doSkipBuildJars: true,
|
doSkipBuildJars: true,
|
||||||
buildOptions
|
buildContext
|
||||||
});
|
});
|
||||||
|
|
||||||
if (!isKeycloakifyBuildSuccess) {
|
if (!isKeycloakifyBuildSuccess) {
|
||||||
@ -470,11 +470,11 @@ export async function command(params: { cliCommandOptions: CliCommandOptions })
|
|||||||
.watch(
|
.watch(
|
||||||
[
|
[
|
||||||
srcDirPath,
|
srcDirPath,
|
||||||
buildOptions.publicDirPath,
|
buildContext.publicDirPath,
|
||||||
pathJoin(buildOptions.projectDirPath, "package.json"),
|
pathJoin(buildContext.projectDirPath, "package.json"),
|
||||||
pathJoin(buildOptions.projectDirPath, "vite.config.ts"),
|
pathJoin(buildContext.projectDirPath, "vite.config.ts"),
|
||||||
pathJoin(buildOptions.projectDirPath, "vite.config.js"),
|
pathJoin(buildContext.projectDirPath, "vite.config.js"),
|
||||||
pathJoin(buildOptions.projectDirPath, "index.html"),
|
pathJoin(buildContext.projectDirPath, "index.html"),
|
||||||
pathJoin(getThisCodebaseRootDirPath(), "src")
|
pathJoin(getThisCodebaseRootDirPath(), "src")
|
||||||
],
|
],
|
||||||
{
|
{
|
||||||
|
@ -1,13 +1,13 @@
|
|||||||
import type { CliCommandOptions } from "./main";
|
import type { CliCommandOptions } from "./main";
|
||||||
import { readBuildOptions } from "./shared/buildOptions";
|
import { getBuildContext } from "./shared/buildContext";
|
||||||
import { generateKcGenTs } from "./shared/generateKcGenTs";
|
import { generateKcGenTs } from "./shared/generateKcGenTs";
|
||||||
|
|
||||||
export async function command(params: { cliCommandOptions: CliCommandOptions }) {
|
export async function command(params: { cliCommandOptions: CliCommandOptions }) {
|
||||||
const { cliCommandOptions } = params;
|
const { cliCommandOptions } = params;
|
||||||
|
|
||||||
const buildOptions = readBuildOptions({
|
const buildContext = getBuildContext({
|
||||||
cliCommandOptions
|
cliCommandOptions
|
||||||
});
|
});
|
||||||
|
|
||||||
await generateKcGenTs({ buildOptions });
|
await generateKcGenTs({ buildContext });
|
||||||
}
|
}
|
||||||
|
@ -11,20 +11,20 @@ import { rm } from "../bin/tools/fs.rm";
|
|||||||
import { copyKeycloakResourcesToPublic } from "../bin/shared/copyKeycloakResourcesToPublic";
|
import { copyKeycloakResourcesToPublic } from "../bin/shared/copyKeycloakResourcesToPublic";
|
||||||
import { assert } from "tsafe/assert";
|
import { assert } from "tsafe/assert";
|
||||||
import {
|
import {
|
||||||
readBuildOptions,
|
getBuildContext,
|
||||||
|
type BuildContext,
|
||||||
type BuildOptions,
|
type BuildOptions,
|
||||||
type UserProvidedBuildOptions,
|
|
||||||
type ResolvedViteConfig
|
type ResolvedViteConfig
|
||||||
} from "../bin/shared/buildOptions";
|
} from "../bin/shared/buildContext";
|
||||||
import MagicString from "magic-string";
|
import MagicString from "magic-string";
|
||||||
import { generateKcGenTs } from "../bin/shared/generateKcGenTs";
|
import { generateKcGenTs } from "../bin/shared/generateKcGenTs";
|
||||||
|
|
||||||
export type Params = UserProvidedBuildOptions & {
|
export type Params = BuildOptions & {
|
||||||
postBuild?: (buildOptions: Omit<BuildOptions, "bundler">) => Promise<void>;
|
postBuild?: (buildContext: Omit<BuildContext, "bundler">) => Promise<void>;
|
||||||
};
|
};
|
||||||
|
|
||||||
export function keycloakify(params?: Params) {
|
export function keycloakify(params?: Params) {
|
||||||
const { postBuild, ...userProvidedBuildOptions } = params ?? {};
|
const { postBuild, ...buildOptions } = params ?? {};
|
||||||
|
|
||||||
let projectDirPath: string | undefined = undefined;
|
let projectDirPath: string | undefined = undefined;
|
||||||
let urlPathname: string | undefined = undefined;
|
let urlPathname: string | undefined = undefined;
|
||||||
@ -45,9 +45,9 @@ export function keycloakify(params?: Params) {
|
|||||||
break run_post_build_script_case;
|
break run_post_build_script_case;
|
||||||
}
|
}
|
||||||
|
|
||||||
const buildOptions = JSON.parse(envValue) as BuildOptions;
|
const buildContext = JSON.parse(envValue) as BuildContext;
|
||||||
|
|
||||||
await postBuild?.(buildOptions);
|
await postBuild?.(buildContext);
|
||||||
|
|
||||||
process.exit(0);
|
process.exit(0);
|
||||||
}
|
}
|
||||||
@ -108,7 +108,7 @@ export function keycloakify(params?: Params) {
|
|||||||
assetsDir: resolvedConfig.build.assetsDir,
|
assetsDir: resolvedConfig.build.assetsDir,
|
||||||
buildDir: resolvedConfig.build.outDir,
|
buildDir: resolvedConfig.build.outDir,
|
||||||
urlPathname,
|
urlPathname,
|
||||||
userProvidedBuildOptions
|
buildOptions
|
||||||
})
|
})
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
@ -116,7 +116,7 @@ export function keycloakify(params?: Params) {
|
|||||||
process.exit(0);
|
process.exit(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
const buildOptions = readBuildOptions({
|
const buildContext = getBuildContext({
|
||||||
cliCommandOptions: {
|
cliCommandOptions: {
|
||||||
projectDirPath
|
projectDirPath
|
||||||
}
|
}
|
||||||
@ -124,10 +124,10 @@ export function keycloakify(params?: Params) {
|
|||||||
|
|
||||||
await Promise.all([
|
await Promise.all([
|
||||||
copyKeycloakResourcesToPublic({
|
copyKeycloakResourcesToPublic({
|
||||||
buildOptions
|
buildContext
|
||||||
}),
|
}),
|
||||||
generateKcGenTs({
|
generateKcGenTs({
|
||||||
buildOptions
|
buildContext
|
||||||
})
|
})
|
||||||
]);
|
]);
|
||||||
},
|
},
|
||||||
|
Loading…
x
Reference in New Issue
Block a user