keycloakify 10.0.0-rc.14 → 10.0.0-rc.16

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.
@@ -1,8 +1,9 @@
1
- import { join as pathJoin } from "path";
1
+ import { join as pathJoin, relative as pathRelative, sep as pathSep } from "path";
2
2
  import { promptKeycloakVersion } from "./shared/promptKeycloakVersion";
3
3
  import { readBuildOptions } from "./shared/buildOptions";
4
- import { downloadBuiltinKeycloakTheme } from "./shared/downloadBuiltinKeycloakTheme";
4
+ import { downloadKeycloakDefaultTheme } from "./shared/downloadKeycloakDefaultTheme";
5
5
  import type { CliCommandOptions } from "./main";
6
+ import chalk from "chalk";
6
7
 
7
8
  export async function command(params: { cliCommandOptions: CliCommandOptions }) {
8
9
  const { cliCommandOptions } = params;
@@ -11,20 +12,26 @@ export async function command(params: { cliCommandOptions: CliCommandOptions })
11
12
  cliCommandOptions
12
13
  });
13
14
 
14
- console.log("Select the Keycloak version from which you want to download the builtins theme:");
15
+ console.log(chalk.cyan("Select the Keycloak version from which you want to download the builtins theme:"));
15
16
 
16
17
  const { keycloakVersion } = await promptKeycloakVersion({
17
18
  "startingFromMajor": undefined,
18
19
  "cacheDirPath": buildOptions.cacheDirPath
19
20
  });
20
21
 
22
+ console.log(`→ ${keycloakVersion}`);
23
+
21
24
  const destDirPath = pathJoin(buildOptions.keycloakifyBuildDirPath, "src", "main", "resources", "theme");
22
25
 
23
- console.log(`Downloading builtins theme of Keycloak ${keycloakVersion} here ${destDirPath}`);
26
+ console.log(
27
+ `Downloading builtins theme of Keycloak ${keycloakVersion} here ${chalk.bold(`.${pathSep}${pathRelative(process.cwd(), destDirPath)}`)}`
28
+ );
24
29
 
25
- await downloadBuiltinKeycloakTheme({
30
+ await downloadKeycloakDefaultTheme({
26
31
  keycloakVersion,
27
32
  destDirPath,
28
33
  buildOptions
29
34
  });
35
+
36
+ console.log(chalk.green(`✓ done`));
30
37
  }
@@ -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
@@ -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
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
  }
@@ -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