keycloakify 10.0.0-rc.15 → 10.0.0-rc.17

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -10,6 +10,7 @@ export declare const vitePluginSubScriptEnvNames: {
10
10
  readonly runPostBuildScript: "KEYCLOAKIFY_RUN_POST_BUILD_SCRIPT";
11
11
  readonly resolveViteConfig: "KEYCLOAKIFY_RESOLVE_VITE_CONFIG";
12
12
  };
13
+ export declare const skipBuildJarsEnvName = "KEYCLOAKIFY_SKIP_BUILD_JAR";
13
14
  export declare const loginThemePageIds: readonly ["login.ftl", "login-username.ftl", "login-password.ftl", "webauthn-authenticate.ftl", "webauthn-register.ftl", "register.ftl", "info.ftl", "error.ftl", "login-reset-password.ftl", "login-verify-email.ftl", "terms.ftl", "login-oauth2-device-verify-user-code.ftl", "login-oauth-grant.ftl", "login-otp.ftl", "login-update-profile.ftl", "login-update-password.ftl", "login-idp-link-confirm.ftl", "login-idp-link-email.ftl", "login-page-expired.ftl", "login-config-totp.ftl", "logout-confirm.ftl", "idp-review-user-profile.ftl", "update-email.ftl", "select-authenticator.ftl", "saml-post-form.ftl", "delete-credential.ftl", "code.ftl", "delete-account-confirm.ftl", "frontchannel-logout.ftl", "login-recovery-authn-code-config.ftl", "login-recovery-authn-code-input.ftl", "login-reset-otp.ftl", "login-x509-info.ftl", "webauthn-error.ftl"];
14
15
  export declare const accountThemePageIds: readonly ["password.ftl", "account.ftl", "sessions.ftl", "totp.ftl", "applications.ftl", "log.ftl", "federatedIdentity.ftl"];
15
16
  export type LoginThemePageId = (typeof loginThemePageIds)[number];
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.accountThemePageIds = exports.loginThemePageIds = exports.vitePluginSubScriptEnvNames = exports.accountV1ThemeName = exports.themeTypes = exports.basenameOfTheKeycloakifyResourcesDir = exports.lastKeycloakVersionWithAccountV1 = exports.resources_common = exports.keycloak_resources = exports.nameOfTheGlobal = void 0;
3
+ exports.accountThemePageIds = exports.loginThemePageIds = exports.skipBuildJarsEnvName = exports.vitePluginSubScriptEnvNames = exports.accountV1ThemeName = exports.themeTypes = exports.basenameOfTheKeycloakifyResourcesDir = exports.lastKeycloakVersionWithAccountV1 = exports.resources_common = exports.keycloak_resources = exports.nameOfTheGlobal = void 0;
4
4
  exports.nameOfTheGlobal = "kcContext";
5
5
  exports.keycloak_resources = "keycloak-resources";
6
6
  exports.resources_common = "resources-common";
@@ -12,6 +12,7 @@ exports.vitePluginSubScriptEnvNames = {
12
12
  "runPostBuildScript": "KEYCLOAKIFY_RUN_POST_BUILD_SCRIPT",
13
13
  "resolveViteConfig": "KEYCLOAKIFY_RESOLVE_VITE_CONFIG"
14
14
  };
15
+ exports.skipBuildJarsEnvName = "KEYCLOAKIFY_SKIP_BUILD_JAR";
15
16
  exports.loginThemePageIds = [
16
17
  "login.ftl",
17
18
  "login-username.ftl",
@@ -1 +1 @@
1
- {"version":3,"file":"constants.js","sourceRoot":"","sources":["../../src/bin/shared/constants.ts"],"names":[],"mappings":";;;AAAa,QAAA,eAAe,GAAG,WAAW,CAAC;AAC9B,QAAA,kBAAkB,GAAG,oBAAoB,CAAC;AAC1C,QAAA,gBAAgB,GAAG,kBAAkB,CAAC;AACtC,QAAA,gCAAgC,GAAG,QAAQ,CAAC;AAC5C,QAAA,oCAAoC,GAAG,OAAO,CAAC;AAE/C,QAAA,UAAU,GAAG,CAAC,OAAO,EAAE,SAAS,CAAU,CAAC;AAC3C,QAAA,kBAAkB,GAAG,YAAY,CAAC;AAIlC,QAAA,2BAA2B,GAAG;IACvC,oBAAoB,EAAE,mCAAmC;IACzD,mBAAmB,EAAE,iCAAiC;CAChD,CAAC;AAEE,QAAA,iBAAiB,GAAG;IAC7B,WAAW;IACX,oBAAoB;IACpB,oBAAoB;IACpB,2BAA2B;IAC3B,uBAAuB;IACvB,cAAc;IACd,UAAU;IACV,WAAW;IACX,0BAA0B;IAC1B,wBAAwB;IACxB,WAAW;IACX,0CAA0C;IAC1C,uBAAuB;IACvB,eAAe;IACf,0BAA0B;IAC1B,2BAA2B;IAC3B,4BAA4B;IAC5B,0BAA0B;IAC1B,wBAAwB;IACxB,uBAAuB;IACvB,oBAAoB;IACpB,6BAA6B;IAC7B,kBAAkB;IAClB,0BAA0B;IAC1B,oBAAoB;IACpB,uBAAuB;IACvB,UAAU;IACV,4BAA4B;IAC5B,yBAAyB;IACzB,sCAAsC;IACtC,qCAAqC;IACrC,qBAAqB;IACrB,qBAAqB;IACrB,oBAAoB;CACd,CAAC;AAEE,QAAA,mBAAmB,GAAG;IAC/B,cAAc;IACd,aAAa;IACb,cAAc;IACd,UAAU;IACV,kBAAkB;IAClB,SAAS;IACT,uBAAuB;CACjB,CAAC"}
1
+ {"version":3,"file":"constants.js","sourceRoot":"","sources":["../../src/bin/shared/constants.ts"],"names":[],"mappings":";;;AAAa,QAAA,eAAe,GAAG,WAAW,CAAC;AAC9B,QAAA,kBAAkB,GAAG,oBAAoB,CAAC;AAC1C,QAAA,gBAAgB,GAAG,kBAAkB,CAAC;AACtC,QAAA,gCAAgC,GAAG,QAAQ,CAAC;AAC5C,QAAA,oCAAoC,GAAG,OAAO,CAAC;AAE/C,QAAA,UAAU,GAAG,CAAC,OAAO,EAAE,SAAS,CAAU,CAAC;AAC3C,QAAA,kBAAkB,GAAG,YAAY,CAAC;AAIlC,QAAA,2BAA2B,GAAG;IACvC,oBAAoB,EAAE,mCAAmC;IACzD,mBAAmB,EAAE,iCAAiC;CAChD,CAAC;AAEE,QAAA,oBAAoB,GAAG,4BAA4B,CAAC;AAEpD,QAAA,iBAAiB,GAAG;IAC7B,WAAW;IACX,oBAAoB;IACpB,oBAAoB;IACpB,2BAA2B;IAC3B,uBAAuB;IACvB,cAAc;IACd,UAAU;IACV,WAAW;IACX,0BAA0B;IAC1B,wBAAwB;IACxB,WAAW;IACX,0CAA0C;IAC1C,uBAAuB;IACvB,eAAe;IACf,0BAA0B;IAC1B,2BAA2B;IAC3B,4BAA4B;IAC5B,0BAA0B;IAC1B,wBAAwB;IACxB,uBAAuB;IACvB,oBAAoB;IACpB,6BAA6B;IAC7B,kBAAkB;IAClB,0BAA0B;IAC1B,oBAAoB;IACpB,uBAAuB;IACvB,UAAU;IACV,4BAA4B;IAC5B,yBAAyB;IACzB,sCAAsC;IACtC,qCAAqC;IACrC,qBAAqB;IACrB,qBAAqB;IACrB,oBAAoB;CACd,CAAC;AAEE,QAAA,mBAAmB,GAAG;IAC/B,cAAc;IACd,aAAa;IACb,cAAc;IACd,UAAU;IACV,kBAAkB;IAClB,SAAS;IACT,uBAAuB;CACjB,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "keycloakify",
3
- "version": "10.0.0-rc.15",
3
+ "version": "10.0.0-rc.17",
4
4
  "description": "Create Keycloak themes using React",
5
5
  "repository": {
6
6
  "type": "git",
@@ -73,8 +73,8 @@
73
73
  "src/account/pages/Sessions.tsx",
74
74
  "src/account/pages/Totp.tsx",
75
75
  "src/bin/copy-keycloak-resources-to-public.ts",
76
- "src/bin/download-builtin-keycloak-theme.ts",
77
- "src/bin/eject-keycloak-page.ts",
76
+ "src/bin/download-keycloak-default-theme.ts",
77
+ "src/bin/eject-page.ts",
78
78
  "src/bin/initialize-email-theme.ts",
79
79
  "src/bin/keycloakify/buildJars/buildJar.ts",
80
80
  "src/bin/keycloakify/buildJars/buildJars.ts",
@@ -108,7 +108,7 @@
108
108
  "src/bin/shared/constants.ts",
109
109
  "src/bin/shared/copyKeycloakResourcesToPublic.ts",
110
110
  "src/bin/shared/downloadAndUnzip.ts",
111
- "src/bin/shared/downloadBuiltinKeycloakTheme.ts",
111
+ "src/bin/shared/downloadKeycloakDefaultTheme.ts",
112
112
  "src/bin/shared/downloadKeycloakStaticResources.ts",
113
113
  "src/bin/shared/getJarFileBasename.ts",
114
114
  "src/bin/shared/getThemeSrcDirPath.ts",
@@ -0,0 +1,41 @@
1
+ import { join as pathJoin, relative as pathRelative, sep as pathSep } from "path";
2
+ import { promptKeycloakVersion } from "./shared/promptKeycloakVersion";
3
+ import { readBuildOptions } from "./shared/buildOptions";
4
+ import { downloadKeycloakDefaultTheme } from "./shared/downloadKeycloakDefaultTheme";
5
+ import type { CliCommandOptions } from "./main";
6
+ import chalk from "chalk";
7
+
8
+ export async function command(params: { cliCommandOptions: CliCommandOptions }) {
9
+ const { cliCommandOptions } = params;
10
+
11
+ const buildOptions = readBuildOptions({
12
+ cliCommandOptions
13
+ });
14
+
15
+ console.log(chalk.cyan("Select the Keycloak version from which you want to download the builtins theme:"));
16
+
17
+ const { keycloakVersion } = await promptKeycloakVersion({
18
+ "startingFromMajor": undefined,
19
+ "cacheDirPath": buildOptions.cacheDirPath
20
+ });
21
+
22
+ console.log(`→ ${keycloakVersion}`);
23
+
24
+ const destDirPath = pathJoin(buildOptions.keycloakifyBuildDirPath, "src", "main", "resources", "theme");
25
+
26
+ console.log(
27
+ [
28
+ `Downloading builtins theme of Keycloak ${keycloakVersion} here:`,
29
+ `- ${chalk.bold(`.${pathSep}${pathJoin(pathRelative(process.cwd(), destDirPath), "base")}`)}`,
30
+ `- ${chalk.bold(`.${pathSep}${pathJoin(pathRelative(process.cwd(), destDirPath), "keycloak")}`)}`
31
+ ].join("\n")
32
+ );
33
+
34
+ await downloadKeycloakDefaultTheme({
35
+ keycloakVersion,
36
+ destDirPath,
37
+ buildOptions
38
+ });
39
+
40
+ console.log(chalk.green(`✓ done`));
41
+ }
@@ -18,6 +18,7 @@ import { assert, Equals } from "tsafe/assert";
18
18
  import { getThemeSrcDirPath } from "./shared/getThemeSrcDirPath";
19
19
  import type { CliCommandOptions } from "./main";
20
20
  import { readBuildOptions } from "./shared/buildOptions";
21
+ import chalk from "chalk";
21
22
 
22
23
  export async function command(params: { cliCommandOptions: CliCommandOptions }) {
23
24
  const { cliCommandOptions } = params;
@@ -26,17 +27,17 @@ export async function command(params: { cliCommandOptions: CliCommandOptions })
26
27
  cliCommandOptions
27
28
  });
28
29
 
29
- console.log("Theme type:");
30
+ console.log(chalk.cyan("Theme type:"));
30
31
 
31
32
  const { value: themeType } = await cliSelect<ThemeType>({
32
33
  "values": [...themeTypes]
33
34
  }).catch(() => {
34
- console.log("Aborting");
35
-
36
35
  process.exit(-1);
37
36
  });
38
37
 
39
- console.log("Select the page you want to customize:");
38
+ console.log(`→ ${themeType}`);
39
+
40
+ console.log(chalk.cyan("Select the page you want to customize:"));
40
41
 
41
42
  const { value: pageId } = await cliSelect<LoginThemePageId | AccountThemePageId>({
42
43
  "values": (() => {
@@ -49,11 +50,11 @@ export async function command(params: { cliCommandOptions: CliCommandOptions })
49
50
  assert<Equals<typeof themeType, never>>(false);
50
51
  })()
51
52
  }).catch(() => {
52
- console.log("Aborting");
53
-
54
53
  process.exit(-1);
55
54
  });
56
55
 
56
+ console.log(`→ ${pageId}`);
57
+
57
58
  const componentPageBasename = capitalize(kebabCaseToCamelCase(pageId)).replace(/ftl$/, "tsx");
58
59
 
59
60
  const { themeSrcDirPath } = getThemeSrcDirPath({ "reactAppRootDirPath": buildOptions.reactAppRootDirPath });
@@ -85,42 +86,54 @@ export async function command(params: { cliCommandOptions: CliCommandOptions })
85
86
  console.log(
86
87
  [
87
88
  ``,
88
- `\`${pathJoin(".", pathRelative(process.cwd(), targetFilePath))}\` copy pasted from the Keycloakify source code into your project.`,
89
+ `${chalk.green("")} ${chalk.bold(
90
+ pathJoin(".", pathRelative(process.cwd(), targetFilePath))
91
+ )} copy pasted from the Keycloakify source code into your project`,
89
92
  ``,
90
93
  `You now need to update your page router:`,
91
94
  ``,
92
- `\`${pathJoin(".", pathRelative(process.cwd(), themeSrcDirPath), themeType, "KcApp.tsx")}\`:`,
93
- "```",
95
+ `${chalk.bold(pathJoin(".", pathRelative(process.cwd(), themeSrcDirPath), themeType, "KcApp.tsx"))}:`,
96
+ chalk.grey("```"),
94
97
  `// ...`,
95
98
  ``,
96
- `+const ${componentPageBasename.replace(/.tsx$/, "")} = lazy(() => import("./pages/${componentPageBasename}"));`,
97
- ``,
98
- ` export default function KcApp(props: { kcContext: KcContext; }) {`,
99
- ``,
100
- ` // ...`,
101
- ``,
102
- ` return (`,
103
- ` <Suspense>`,
104
- ` {(() => {`,
105
- ` switch (kcContext.pageId) {`,
106
- ` // ...`,
107
- ` case "${pageId}": return (`,
108
- `+ <Login`,
109
- `+ {...{ kcContext, i18n, classes }}`,
110
- `+ Template={Template}`,
111
- ...(!componentPageContent.includes(userProfileFormFieldComponentName)
112
- ? []
113
- : [`+ ${userProfileFormFieldComponentName}={${userProfileFormFieldComponentName}}`]),
114
- `+ doUseDefaultCss={true}`,
115
- `+ />`,
116
- `+ );`,
117
- ` default: return <Fallback /* .. */ />;`,
118
- ` }`,
119
- ` })()}`,
120
- ` </Suspense>`,
121
- ` );`,
122
- ` }`,
123
- "```"
99
+ chalk.green(`+const ${componentPageBasename.replace(/.tsx$/, "")} = lazy(() => import("./pages/${componentPageBasename}"));`),
100
+ ...[
101
+ ``,
102
+ ` export default function KcApp(props: { kcContext: KcContext; }) {`,
103
+ ``,
104
+ ` // ...`,
105
+ ``,
106
+ ` return (`,
107
+ ` <Suspense>`,
108
+ ` {(() => {`,
109
+ ` switch (kcContext.pageId) {`,
110
+ ` // ...`,
111
+ `+ case "${pageId}": return (`,
112
+ `+ <Login`,
113
+ `+ {...{ kcContext, i18n, classes }}`,
114
+ `+ Template={Template}`,
115
+ ...(!componentPageContent.includes(userProfileFormFieldComponentName)
116
+ ? []
117
+ : [`+ ${userProfileFormFieldComponentName}={${userProfileFormFieldComponentName}}`]),
118
+ `+ doUseDefaultCss={true}`,
119
+ `+ />`,
120
+ `+ );`,
121
+ ` default: return <Fallback /* .. */ />;`,
122
+ ` }`,
123
+ ` })()}`,
124
+ ` </Suspense>`,
125
+ ` );`,
126
+ ` }`
127
+ ].map(line => {
128
+ if (line.startsWith("+")) {
129
+ return chalk.green(line);
130
+ }
131
+ if (line.startsWith("-")) {
132
+ return chalk.red(line);
133
+ }
134
+ return chalk.grey(line);
135
+ }),
136
+ chalk.grey("```")
124
137
  ].join("\n")
125
138
  );
126
139
  }
@@ -1,4 +1,4 @@
1
- import { downloadBuiltinKeycloakTheme } from "./shared/downloadBuiltinKeycloakTheme";
1
+ import { downloadKeycloakDefaultTheme } from "./shared/downloadKeycloakDefaultTheme";
2
2
  import { join as pathJoin, relative as pathRelative } from "path";
3
3
  import { transformCodebase } from "./tools/transformCodebase";
4
4
  import { promptKeycloakVersion } from "./shared/promptKeycloakVersion";
@@ -37,7 +37,7 @@ export async function command(params: { cliCommandOptions: CliCommandOptions })
37
37
 
38
38
  rmSync(builtinKeycloakThemeTmpDirPath, { "recursive": true, "force": true });
39
39
 
40
- await downloadBuiltinKeycloakTheme({
40
+ await downloadKeycloakDefaultTheme({
41
41
  keycloakVersion,
42
42
  "destDirPath": builtinKeycloakThemeTmpDirPath,
43
43
  buildOptions
@@ -10,7 +10,8 @@ import { readFileSync } from "fs";
10
10
  import { isInside } from "../../tools/isInside";
11
11
  import child_process from "child_process";
12
12
  import { rmSync } from "../../tools/fs.rmSync";
13
- import { getMetaInfKeycloakThemesJsonPath } from "../../shared/metaInfKeycloakThemes";
13
+ import { getMetaInfKeycloakThemesJsonFilePath } from "../../shared/metaInfKeycloakThemes";
14
+ import type { Param0 } from "tsafe";
14
15
 
15
16
  export type BuildOptionsLike = BuildOptionsLike_generatePom & {
16
17
  keycloakifyBuildDirPath: string;
@@ -35,50 +36,98 @@ export async function buildJar(params: {
35
36
  rmSync(keycloakifyBuildTmpDirPath, { "recursive": true, "force": true });
36
37
 
37
38
  {
38
- const keycloakThemesJsonFilePath = getMetaInfKeycloakThemesJsonPath({ "keycloakifyBuildDirPath": "" });
39
+ const metaInfKeycloakThemesJsonRelativePath = getMetaInfKeycloakThemesJsonFilePath({ "keycloakifyBuildDirPath": "" });
39
40
 
40
- const themePropertiesFilePathSet = new Set(
41
- ...buildOptions.themeNames.map(themeName => pathJoin("src", "main", "resources", "theme", themeName, "account", "theme.properties"))
42
- );
41
+ const { transformCodebase_common } = (() => {
42
+ const includingAccountV1ThemeNames = [...buildOptions.themeNames, accountV1ThemeName];
43
+
44
+ const transformCodebase_common: Param0<typeof transformCodebase>["transformSourceCode"] = ({ fileRelativePath, sourceCode }) => {
45
+ if (metaInfKeycloakThemesJsonRelativePath === fileRelativePath) {
46
+ return { "modifiedSourceCode": sourceCode };
47
+ }
48
+
49
+ for (const themeName of includingAccountV1ThemeNames) {
50
+ if (isInside({ "dirPath": pathJoin("src", "main", "resources", "theme", themeName), "filePath": fileRelativePath })) {
51
+ return { "modifiedSourceCode": sourceCode };
52
+ }
53
+ }
54
+
55
+ return undefined;
56
+ };
57
+
58
+ return { transformCodebase_common };
59
+ })();
60
+
61
+ const { transformCodebase_patchForUsingBuiltinAccountV1 } = (() => {
62
+ if (keycloakAccountV1Version !== null) {
63
+ return { "transformCodebase_patchForUsingBuiltinAccountV1": undefined };
64
+ }
65
+
66
+ const themePropertiesFileRelativePathSet = new Set(
67
+ ...buildOptions.themeNames.map(themeName => pathJoin("src", "main", "resources", "theme", themeName, "account", "theme.properties"))
68
+ );
69
+
70
+ const accountV1RelativeDirPath = pathJoin("src", "main", "resources", "theme", accountV1ThemeName);
71
+
72
+ const transformCodebase_patchForUsingBuiltinAccountV1: Param0<typeof transformCodebase>["transformSourceCode"] = ({
73
+ fileRelativePath,
74
+ sourceCode
75
+ }) => {
76
+ if (isInside({ "dirPath": accountV1RelativeDirPath, "filePath": fileRelativePath })) {
77
+ return undefined;
78
+ }
79
+
80
+ if (fileRelativePath === metaInfKeycloakThemesJsonRelativePath) {
81
+ const keycloakThemesJsonParsed = JSON.parse(sourceCode.toString("utf8")) as {
82
+ themes: { name: string; types: string[] }[];
83
+ };
43
84
 
44
- const accountV1RelativeDirPath = pathJoin("src", "main", "resources", "theme", accountV1ThemeName);
85
+ keycloakThemesJsonParsed.themes = keycloakThemesJsonParsed.themes.filter(({ name }) => name !== accountV1ThemeName);
86
+
87
+ return { "modifiedSourceCode": Buffer.from(JSON.stringify(keycloakThemesJsonParsed, null, 2), "utf8") };
88
+ }
89
+
90
+ if (themePropertiesFileRelativePathSet.has(fileRelativePath)) {
91
+ const modifiedSourceCode = Buffer.from(
92
+ sourceCode.toString("utf8").replace(`parent=${accountV1ThemeName}`, "parent=keycloak"),
93
+ "utf8"
94
+ );
95
+
96
+ // assert modifiedSourceCode !== sourceCode
97
+ assert(Buffer.compare(modifiedSourceCode, sourceCode) !== 0);
98
+
99
+ return { modifiedSourceCode };
100
+ }
101
+
102
+ return { "modifiedSourceCode": sourceCode };
103
+ };
104
+
105
+ return { transformCodebase_patchForUsingBuiltinAccountV1 };
106
+ })();
45
107
 
46
108
  transformCodebase({
47
109
  "srcDirPath": buildOptions.keycloakifyBuildDirPath,
48
110
  "destDirPath": keycloakifyBuildTmpDirPath,
49
- "transformSourceCode":
50
- keycloakAccountV1Version !== null
51
- ? undefined
52
- : ({ fileRelativePath, sourceCode }) => {
53
- if (fileRelativePath === keycloakThemesJsonFilePath) {
54
- const keycloakThemesJsonParsed = JSON.parse(sourceCode.toString("utf8")) as {
55
- themes: { name: string; types: string[] }[];
56
- };
57
-
58
- keycloakThemesJsonParsed.themes = keycloakThemesJsonParsed.themes.filter(({ name }) => name !== accountV1ThemeName);
59
-
60
- return { "modifiedSourceCode": Buffer.from(JSON.stringify(keycloakThemesJsonParsed, null, 2), "utf8") };
61
- }
62
-
63
- if (isInside({ "dirPath": "target", "filePath": fileRelativePath })) {
64
- return undefined;
65
- }
66
-
67
- if (isInside({ "dirPath": accountV1RelativeDirPath, "filePath": fileRelativePath })) {
68
- return undefined;
69
- }
70
-
71
- if (themePropertiesFilePathSet.has(fileRelativePath)) {
72
- return {
73
- "modifiedSourceCode": Buffer.from(
74
- sourceCode.toString("utf8").replace(`parent=${accountV1ThemeName}`, "parent=keycloak"),
75
- "utf8"
76
- )
77
- };
78
- }
79
-
80
- return { "modifiedSourceCode": sourceCode };
81
- }
111
+ "transformSourceCode": params => {
112
+ const resultCommon = transformCodebase_common(params);
113
+
114
+ if (resultCommon === undefined) {
115
+ return undefined;
116
+ }
117
+
118
+ if (transformCodebase_patchForUsingBuiltinAccountV1 === undefined) {
119
+ return resultCommon;
120
+ }
121
+
122
+ const { modifiedSourceCode, newFileName } = resultCommon;
123
+
124
+ assert(newFileName === undefined);
125
+
126
+ return transformCodebase_patchForUsingBuiltinAccountV1?.({
127
+ ...params,
128
+ "sourceCode": modifiedSourceCode
129
+ });
130
+ }
82
131
  });
83
132
  }
84
133
 
@@ -3,7 +3,7 @@ import { join as pathJoin } from "path";
3
3
  import { assert } from "tsafe/assert";
4
4
  import type { BuildOptions } from "../../shared/buildOptions";
5
5
  import { resources_common, lastKeycloakVersionWithAccountV1, accountV1ThemeName } from "../../shared/constants";
6
- import { downloadBuiltinKeycloakTheme } from "../../shared/downloadBuiltinKeycloakTheme";
6
+ import { downloadKeycloakDefaultTheme } from "../../shared/downloadKeycloakDefaultTheme";
7
7
  import { transformCodebase } from "../../tools/transformCodebase";
8
8
  import { rmSync } from "../../tools/fs.rmSync";
9
9
 
@@ -20,7 +20,7 @@ export async function bringInAccountV1(params: { buildOptions: BuildOptionsLike
20
20
 
21
21
  const builtinKeycloakThemeTmpDirPath = pathJoin(buildOptions.cacheDirPath, "bringInAccountV1_tmp");
22
22
 
23
- await downloadBuiltinKeycloakTheme({
23
+ await downloadKeycloakDefaultTheme({
24
24
  "destDirPath": builtinKeycloakThemeTmpDirPath,
25
25
  "keycloakVersion": lastKeycloakVersionWithAccountV1,
26
26
  buildOptions
@@ -3,7 +3,7 @@ import { join as pathJoin, relative as pathRelative, sep as pathSep } from "path
3
3
  import * as child_process from "child_process";
4
4
  import * as fs from "fs";
5
5
  import { readBuildOptions } from "../shared/buildOptions";
6
- import { vitePluginSubScriptEnvNames } from "../shared/constants";
6
+ import { vitePluginSubScriptEnvNames, skipBuildJarsEnvName } from "../shared/constants";
7
7
  import { buildJars } from "./buildJars";
8
8
  import type { CliCommandOptions } from "../main";
9
9
  import chalk from "chalk";
@@ -76,7 +76,13 @@ export async function command(params: { cliCommandOptions: CliCommandOptions })
76
76
  });
77
77
  }
78
78
 
79
- await buildJars({ buildOptions });
79
+ build_jars: {
80
+ if (process.env[skipBuildJarsEnvName]) {
81
+ break build_jars;
82
+ }
83
+
84
+ await buildJars({ buildOptions });
85
+ }
80
86
 
81
87
  console.log(chalk.green(`✓ built in ${((Date.now() - startTime) / 1000).toFixed(2)}s`));
82
88
  }
package/src/bin/main.ts CHANGED
@@ -107,13 +107,13 @@ program
107
107
 
108
108
  program
109
109
  .command({
110
- "name": "download-builtin-keycloak-theme",
110
+ "name": "download-keycloak-default-theme",
111
111
  "description": "Download the built-in Keycloak theme."
112
112
  })
113
113
  .task({
114
114
  skip,
115
115
  "handler": async cliCommandOptions => {
116
- const { command } = await import("./download-builtin-keycloak-theme");
116
+ const { command } = await import("./download-keycloak-default-theme");
117
117
 
118
118
  await command({ cliCommandOptions });
119
119
  }
@@ -121,13 +121,13 @@ program
121
121
 
122
122
  program
123
123
  .command({
124
- "name": "eject-keycloak-page",
124
+ "name": "eject-page",
125
125
  "description": "Eject a Keycloak page."
126
126
  })
127
127
  .task({
128
128
  skip,
129
129
  "handler": async cliCommandOptions => {
130
- const { command } = await import("./eject-keycloak-page");
130
+ const { command } = await import("./eject-page");
131
131
 
132
132
  await command({ cliCommandOptions });
133
133
  }
@@ -163,7 +163,10 @@ export function readBuildOptions(params: { cliCommandOptions: CliCommandOptions
163
163
  return pathJoin(reactAppRootDirPath, resolvedViteConfig.buildDir);
164
164
  })();
165
165
 
166
- const { npmWorkspaceRootDirPath } = getNpmWorkspaceRootDirPath({ reactAppRootDirPath });
166
+ const { npmWorkspaceRootDirPath } = getNpmWorkspaceRootDirPath({
167
+ reactAppRootDirPath,
168
+ "dependencyExpected": "keycloakify"
169
+ });
167
170
 
168
171
  return {
169
172
  "bundler": resolvedViteConfig !== undefined ? "vite" : "webpack",
@@ -14,6 +14,8 @@ export const vitePluginSubScriptEnvNames = {
14
14
  "resolveViteConfig": "KEYCLOAKIFY_RESOLVE_VITE_CONFIG"
15
15
  } as const;
16
16
 
17
+ export const skipBuildJarsEnvName = "KEYCLOAKIFY_SKIP_BUILD_JAR";
18
+
17
19
  export const loginThemePageIds = [
18
20
  "login.ftl",
19
21
  "login-username.ftl",
@@ -116,11 +116,11 @@ export async function downloadAndUnzip(params: {
116
116
 
117
117
  await rm(extractDirPath, { "recursive": true });
118
118
 
119
- upload_to_remot_cache_if_admin: {
119
+ upload_to_remote_cache_if_admin: {
120
120
  const githubToken = process.env["KEYCLOAKIFY_ADMIN_GITHUB_PERSONAL_ACCESS_TOKEN"];
121
121
 
122
- if (githubToken === undefined) {
123
- break upload_to_remot_cache_if_admin;
122
+ if (!githubToken) {
123
+ break upload_to_remote_cache_if_admin;
124
124
  }
125
125
 
126
126
  console.log("uploading to remote cache");
@@ -5,7 +5,7 @@ import { assert } from "tsafe/assert";
5
5
  import * as child_process from "child_process";
6
6
  import * as fs from "fs";
7
7
  import { rmSync } from "../tools/fs.rmSync";
8
- import { lastKeycloakVersionWithAccountV1 } from "../shared/constants";
8
+ import { lastKeycloakVersionWithAccountV1 } from "./constants";
9
9
  import { transformCodebase } from "../tools/transformCodebase";
10
10
 
11
11
  export type BuildOptionsLike = {
@@ -15,7 +15,7 @@ export type BuildOptionsLike = {
15
15
 
16
16
  assert<BuildOptions extends BuildOptionsLike ? true : false>();
17
17
 
18
- export async function downloadBuiltinKeycloakTheme(params: { keycloakVersion: string; destDirPath: string; buildOptions: BuildOptionsLike }) {
18
+ export async function downloadKeycloakDefaultTheme(params: { keycloakVersion: string; destDirPath: string; buildOptions: BuildOptionsLike }) {
19
19
  const { keycloakVersion, destDirPath, buildOptions } = params;
20
20
 
21
21
  await downloadAndUnzip({
@@ -1,6 +1,6 @@
1
1
  import { transformCodebase } from "../tools/transformCodebase";
2
2
  import { join as pathJoin } from "path";
3
- import { downloadBuiltinKeycloakTheme } from "./downloadBuiltinKeycloakTheme";
3
+ import { downloadKeycloakDefaultTheme } from "./downloadKeycloakDefaultTheme";
4
4
  import { resources_common, type ThemeType } from "./constants";
5
5
  import type { BuildOptions } from "./buildOptions";
6
6
  import { assert } from "tsafe/assert";
@@ -27,7 +27,7 @@ export async function downloadKeycloakStaticResources(params: {
27
27
  `downloadKeycloakStaticResources_tmp_${crypto.createHash("sha256").update(`${themeType}-${keycloakVersion}`).digest("hex").slice(0, 8)}`
28
28
  );
29
29
 
30
- await downloadBuiltinKeycloakTheme({
30
+ await downloadKeycloakDefaultTheme({
31
31
  keycloakVersion,
32
32
  "destDirPath": tmpDirPath,
33
33
  buildOptions
@@ -6,7 +6,7 @@ export type MetaInfKeycloakTheme = {
6
6
  themes: { name: string; types: (ThemeType | "email")[] }[];
7
7
  };
8
8
 
9
- export function getMetaInfKeycloakThemesJsonPath(params: { keycloakifyBuildDirPath: string }) {
9
+ export function getMetaInfKeycloakThemesJsonFilePath(params: { keycloakifyBuildDirPath: string }) {
10
10
  const { keycloakifyBuildDirPath } = params;
11
11
 
12
12
  return pathJoin(keycloakifyBuildDirPath, "src", "main", "resources", "META-INF", "keycloak-themes.json");
@@ -15,13 +15,13 @@ export function getMetaInfKeycloakThemesJsonPath(params: { keycloakifyBuildDirPa
15
15
  export function readMetaInfKeycloakThemes(params: { keycloakifyBuildDirPath: string }): MetaInfKeycloakTheme {
16
16
  const { keycloakifyBuildDirPath } = params;
17
17
 
18
- return JSON.parse(fs.readFileSync(getMetaInfKeycloakThemesJsonPath({ keycloakifyBuildDirPath })).toString("utf8")) as MetaInfKeycloakTheme;
18
+ return JSON.parse(fs.readFileSync(getMetaInfKeycloakThemesJsonFilePath({ keycloakifyBuildDirPath })).toString("utf8")) as MetaInfKeycloakTheme;
19
19
  }
20
20
 
21
21
  export function writeMetaInfKeycloakThemes(params: { keycloakifyBuildDirPath: string; metaInfKeycloakThemes: MetaInfKeycloakTheme }) {
22
22
  const { keycloakifyBuildDirPath, metaInfKeycloakThemes } = params;
23
23
 
24
- const metaInfKeycloakThemesJsonPath = getMetaInfKeycloakThemesJsonPath({ keycloakifyBuildDirPath });
24
+ const metaInfKeycloakThemesJsonPath = getMetaInfKeycloakThemesJsonFilePath({ keycloakifyBuildDirPath });
25
25
 
26
26
  {
27
27
  const dirPath = pathDirname(metaInfKeycloakThemesJsonPath);