keycloakify 10.0.0-rc.38 → 10.0.0-rc.39
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/bin/193.index.js +13 -13
- package/bin/3.index.js +86 -86
- package/bin/322.index.js +595 -0
- package/bin/453.index.js +3 -3
- package/bin/526.index.js +42 -633
- package/bin/538.index.js +68 -57
- package/bin/932.index.js +7 -7
- package/bin/944.index.js +621 -0
- package/bin/961.index.js +5 -5
- package/bin/97.index.js +3 -3
- package/bin/{21.index.js → 98.index.js} +59 -48
- package/bin/main.js +8 -8
- package/lib/getKcClsx.js +12 -1
- package/lib/getKcClsx.js.map +1 -1
- package/login/Fallback.d.ts +1 -0
- package/login/Fallback.js.map +1 -1
- package/login/UserProfileFormFields.d.ts +1 -0
- package/login/UserProfileFormFields.js +1 -3
- package/login/UserProfileFormFields.js.map +1 -1
- package/login/i18n/i18n.js +1 -1
- package/login/pages/IdpReviewUserProfile.d.ts +1 -0
- package/login/pages/IdpReviewUserProfile.js +2 -2
- package/login/pages/IdpReviewUserProfile.js.map +1 -1
- package/login/pages/LoginUpdateProfile.d.ts +1 -0
- package/login/pages/LoginUpdateProfile.js +2 -2
- package/login/pages/LoginUpdateProfile.js.map +1 -1
- package/login/pages/Register.d.ts +1 -0
- package/login/pages/Register.js +2 -2
- package/login/pages/Register.js.map +1 -1
- package/login/pages/UpdateEmail.d.ts +1 -0
- package/login/pages/UpdateEmail.js +2 -2
- package/login/pages/UpdateEmail.js.map +1 -1
- package/package.json +5 -8
- package/src/bin/add-story.ts +3 -3
- package/src/bin/copy-keycloak-resources-to-public.ts +3 -3
- package/src/bin/download-keycloak-default-theme.ts +5 -5
- package/src/bin/eject-page.ts +3 -3
- package/src/bin/initialize-email-theme.ts +5 -5
- package/src/bin/keycloakify/buildJars/buildJar.ts +14 -14
- package/src/bin/keycloakify/buildJars/buildJars.ts +8 -8
- package/src/bin/keycloakify/buildJars/generatePom.ts +9 -9
- package/src/bin/keycloakify/generateFtl/generateFtl.ts +12 -12
- package/src/bin/keycloakify/generateSrcMainResources/bringInAccountV1.ts +7 -7
- package/src/bin/keycloakify/generateSrcMainResources/generateSrcMainResources.ts +9 -9
- package/src/bin/keycloakify/generateSrcMainResources/generateSrcMainResourcesForMainTheme.ts +25 -25
- package/src/bin/keycloakify/generateSrcMainResources/generateSrcMainResourcesForThemeVariant.ts +8 -8
- package/src/bin/keycloakify/generateStartKeycloakTestingContainer.ts +9 -9
- package/src/bin/keycloakify/keycloakify.ts +11 -11
- package/src/bin/keycloakify/replacers/replaceImportsInCssCode.ts +6 -6
- package/src/bin/keycloakify/replacers/replaceImportsInInlineCssCode.ts +7 -7
- package/src/bin/keycloakify/replacers/replaceImportsInJsCode/replaceImportsInJsCode.ts +10 -10
- package/src/bin/keycloakify/replacers/replaceImportsInJsCode/vite.ts +13 -13
- package/src/bin/keycloakify/replacers/replaceImportsInJsCode/webpack.ts +11 -11
- package/src/bin/main.ts +2 -2
- package/src/bin/shared/{buildOptions.ts → buildContext.ts} +62 -51
- package/src/bin/shared/copyKeycloakResourcesToPublic.ts +12 -12
- package/src/bin/shared/downloadKeycloakDefaultTheme.ts +7 -7
- package/src/bin/shared/downloadKeycloakStaticResources.ts +7 -7
- package/src/bin/shared/generateKcGenTs.ts +12 -12
- package/src/bin/shared/getThemeSrcDirPath.ts +3 -3
- package/src/bin/start-keycloak/appBuild.ts +11 -11
- package/src/bin/start-keycloak/keycloakifyBuild.ts +7 -7
- package/src/bin/start-keycloak/start-keycloak.ts +34 -22
- package/src/bin/tools/getNpmWorkspaceRootDirPath.ts +3 -3
- package/src/bin/update-kc-gen.ts +3 -3
- package/src/lib/getKcClsx.ts +15 -1
- package/src/login/Fallback.tsx +1 -0
- package/src/login/UserProfileFormFields.tsx +2 -4
- package/src/login/i18n/i18n.tsx +1 -1
- package/src/login/pages/IdpReviewUserProfile.tsx +8 -2
- package/src/login/pages/LoginUpdateProfile.tsx +8 -2
- package/src/login/pages/Register.tsx +8 -2
- package/src/login/pages/UpdateEmail.tsx +8 -2
- package/src/vite-plugin/vite-plugin.ts +19 -19
- package/vite-plugin/index.js +91 -80
- package/vite-plugin/vite-plugin.d.ts +3 -3
- package/bin/795.index.js +0 -1198
- package/lib/isStorybook.d.ts +0 -1
- package/lib/isStorybook.js +0 -3
- package/lib/isStorybook.js.map +0 -1
- package/src/lib/isStorybook.ts +0 -3
@@ -3,28 +3,28 @@ import {
|
|
3
3
|
basenameOfTheKeycloakifyResourcesDir
|
4
4
|
} from "../../../shared/constants";
|
5
5
|
import { assert } from "tsafe/assert";
|
6
|
-
import type {
|
6
|
+
import type { BuildContext } from "../../../shared/buildContext";
|
7
7
|
import * as nodePath from "path";
|
8
8
|
import { replaceAll } from "../../../tools/String.prototype.replaceAll";
|
9
9
|
|
10
|
-
export type
|
11
|
-
|
10
|
+
export type BuildContextLike = {
|
11
|
+
projectBuildDirPath: string;
|
12
12
|
assetsDirPath: string;
|
13
13
|
urlPathname: string | undefined;
|
14
14
|
};
|
15
15
|
|
16
|
-
assert<
|
16
|
+
assert<BuildContext extends BuildContextLike ? true : false>();
|
17
17
|
|
18
18
|
export function replaceImportsInJsCode_webpack(params: {
|
19
19
|
jsCode: string;
|
20
|
-
|
20
|
+
buildContext: BuildContextLike;
|
21
21
|
systemType?: "posix" | "win32";
|
22
22
|
}): {
|
23
23
|
fixedJsCode: string;
|
24
24
|
} {
|
25
25
|
const {
|
26
26
|
jsCode,
|
27
|
-
|
27
|
+
buildContext,
|
28
28
|
systemType = nodePath.sep === "/" ? "posix" : "win32"
|
29
29
|
} = params;
|
30
30
|
|
@@ -32,12 +32,12 @@ export function replaceImportsInJsCode_webpack(params: {
|
|
32
32
|
|
33
33
|
let fixedJsCode = jsCode;
|
34
34
|
|
35
|
-
if (
|
35
|
+
if (buildContext.urlPathname !== undefined) {
|
36
36
|
// "__esModule",{value:!0})},n.p="/foo-bar/",function(){if("undefined" -> ... n.p="/" ...
|
37
37
|
fixedJsCode = fixedJsCode.replace(
|
38
38
|
new RegExp(
|
39
39
|
`,([a-zA-Z]\\.[a-zA-Z])="${replaceAll(
|
40
|
-
|
40
|
+
buildContext.urlPathname,
|
41
41
|
"/",
|
42
42
|
"\\/"
|
43
43
|
)}",`,
|
@@ -50,15 +50,15 @@ export function replaceImportsInJsCode_webpack(params: {
|
|
50
50
|
// Example: "static/ or "foo/bar/"
|
51
51
|
const staticDir = (() => {
|
52
52
|
let out = pathRelative(
|
53
|
-
|
54
|
-
|
53
|
+
buildContext.projectBuildDirPath,
|
54
|
+
buildContext.assetsDirPath
|
55
55
|
);
|
56
56
|
|
57
57
|
out = replaceAll(out, pathSep, "/") + "/";
|
58
58
|
|
59
59
|
if (out === "/") {
|
60
60
|
throw new Error(
|
61
|
-
`The assetsDirPath must be a subdirectory of
|
61
|
+
`The assetsDirPath must be a subdirectory of projectBuildDirPath`
|
62
62
|
);
|
63
63
|
}
|
64
64
|
|
package/src/bin/main.ts
CHANGED
@@ -5,7 +5,7 @@ import { readThisNpmPackageVersion } from "./tools/readThisNpmPackageVersion";
|
|
5
5
|
import * as child_process from "child_process";
|
6
6
|
|
7
7
|
export type CliCommandOptions = {
|
8
|
-
|
8
|
+
projectDirPath: string | undefined;
|
9
9
|
};
|
10
10
|
|
11
11
|
const program = termost<CliCommandOptions>(
|
@@ -25,7 +25,7 @@ const program = termost<CliCommandOptions>(
|
|
25
25
|
const optionsKeys: string[] = [];
|
26
26
|
|
27
27
|
program.option({
|
28
|
-
key: "
|
28
|
+
key: "projectDirPath",
|
29
29
|
name: (() => {
|
30
30
|
const long = "project";
|
31
31
|
const short = "p";
|
@@ -9,8 +9,7 @@ import { assert } from "tsafe";
|
|
9
9
|
import * as child_process from "child_process";
|
10
10
|
import { vitePluginSubScriptEnvNames } from "./constants";
|
11
11
|
|
12
|
-
|
13
|
-
export type BuildOptions = {
|
12
|
+
export type BuildContext = {
|
14
13
|
bundler: "vite" | "webpack";
|
15
14
|
themeVersion: string;
|
16
15
|
themeNames: string[];
|
@@ -18,9 +17,8 @@ export type BuildOptions = {
|
|
18
17
|
groupId: string;
|
19
18
|
artifactId: string;
|
20
19
|
loginThemeResourcesFromKeycloakVersion: string;
|
21
|
-
|
22
|
-
|
23
|
-
reactAppBuildDirPath: string;
|
20
|
+
projectDirPath: string;
|
21
|
+
projectBuildDirPath: string;
|
24
22
|
/** Directory that keycloakify outputs to. Defaults to {cwd}/build_keycloak */
|
25
23
|
keycloakifyBuildDirPath: string;
|
26
24
|
publicDirPath: string;
|
@@ -34,7 +32,7 @@ export type BuildOptions = {
|
|
34
32
|
environmentVariables: { name: string; default: string }[];
|
35
33
|
};
|
36
34
|
|
37
|
-
export type
|
35
|
+
export type BuildOptions = {
|
38
36
|
themeName?: string | string[];
|
39
37
|
environmentVariables?: { name: string; default: string }[];
|
40
38
|
extraThemeProperties?: string[];
|
@@ -42,7 +40,7 @@ export type UserProvidedBuildOptions = {
|
|
42
40
|
groupId?: string;
|
43
41
|
loginThemeResourcesFromKeycloakVersion?: string;
|
44
42
|
keycloakifyBuildDirPath?: string;
|
45
|
-
|
43
|
+
kcContextExclusionsFtl?: string;
|
46
44
|
};
|
47
45
|
|
48
46
|
export type ResolvedViteConfig = {
|
@@ -50,21 +48,21 @@ export type ResolvedViteConfig = {
|
|
50
48
|
publicDir: string;
|
51
49
|
assetsDir: string;
|
52
50
|
urlPathname: string | undefined;
|
53
|
-
|
51
|
+
buildOptions: BuildOptions;
|
54
52
|
};
|
55
53
|
|
56
|
-
export function
|
54
|
+
export function getBuildContext(params: {
|
57
55
|
cliCommandOptions: CliCommandOptions;
|
58
|
-
}):
|
56
|
+
}): BuildContext {
|
59
57
|
const { cliCommandOptions } = params;
|
60
58
|
|
61
|
-
const
|
62
|
-
if (cliCommandOptions.
|
59
|
+
const projectDirPath = (() => {
|
60
|
+
if (cliCommandOptions.projectDirPath === undefined) {
|
63
61
|
return process.cwd();
|
64
62
|
}
|
65
63
|
|
66
64
|
return getAbsoluteAndInOsFormatPath({
|
67
|
-
pathIsh: cliCommandOptions.
|
65
|
+
pathIsh: cliCommandOptions.projectDirPath,
|
68
66
|
cwd: process.cwd()
|
69
67
|
});
|
70
68
|
})();
|
@@ -72,7 +70,7 @@ export function readBuildOptions(params: {
|
|
72
70
|
const { resolvedViteConfig } = (() => {
|
73
71
|
if (
|
74
72
|
fs
|
75
|
-
.readdirSync(
|
73
|
+
.readdirSync(projectDirPath)
|
76
74
|
.find(fileBasename => fileBasename.startsWith("vite.config")) ===
|
77
75
|
undefined
|
78
76
|
) {
|
@@ -81,7 +79,7 @@ export function readBuildOptions(params: {
|
|
81
79
|
|
82
80
|
const output = child_process
|
83
81
|
.execSync("npx vite", {
|
84
|
-
cwd:
|
82
|
+
cwd: projectDirPath,
|
85
83
|
env: {
|
86
84
|
...process.env,
|
87
85
|
[vitePluginSubScriptEnvNames.resolveViteConfig]: "true"
|
@@ -108,8 +106,8 @@ export function readBuildOptions(params: {
|
|
108
106
|
name: string;
|
109
107
|
version?: string;
|
110
108
|
homepage?: string;
|
111
|
-
keycloakify?:
|
112
|
-
|
109
|
+
keycloakify?: BuildOptions & {
|
110
|
+
projectBuildDirPath?: string;
|
113
111
|
};
|
114
112
|
};
|
115
113
|
|
@@ -123,7 +121,7 @@ export function readBuildOptions(params: {
|
|
123
121
|
artifactId: z.string().optional(),
|
124
122
|
groupId: z.string().optional(),
|
125
123
|
loginThemeResourcesFromKeycloakVersion: z.string().optional(),
|
126
|
-
|
124
|
+
projectBuildDirPath: z.string().optional(),
|
127
125
|
keycloakifyBuildDirPath: z.string().optional(),
|
128
126
|
themeName: z.union([z.string(), z.array(z.string())]).optional()
|
129
127
|
})
|
@@ -139,20 +137,18 @@ export function readBuildOptions(params: {
|
|
139
137
|
|
140
138
|
return zParsedPackageJson.parse(
|
141
139
|
JSON.parse(
|
142
|
-
fs
|
143
|
-
.readFileSync(pathJoin(reactAppRootDirPath, "package.json"))
|
144
|
-
.toString("utf8")
|
140
|
+
fs.readFileSync(pathJoin(projectDirPath, "package.json")).toString("utf8")
|
145
141
|
)
|
146
142
|
);
|
147
143
|
})();
|
148
144
|
|
149
|
-
const
|
145
|
+
const buildOptions: BuildOptions = {
|
150
146
|
...parsedPackageJson.keycloakify,
|
151
|
-
...resolvedViteConfig?.
|
147
|
+
...resolvedViteConfig?.buildOptions
|
152
148
|
};
|
153
149
|
|
154
150
|
const themeNames = (() => {
|
155
|
-
if (
|
151
|
+
if (buildOptions.themeName === undefined) {
|
156
152
|
return [
|
157
153
|
parsedPackageJson.name
|
158
154
|
.replace(/^@(.*)/, "$1")
|
@@ -161,34 +157,34 @@ export function readBuildOptions(params: {
|
|
161
157
|
];
|
162
158
|
}
|
163
159
|
|
164
|
-
if (typeof
|
165
|
-
return [
|
160
|
+
if (typeof buildOptions.themeName === "string") {
|
161
|
+
return [buildOptions.themeName];
|
166
162
|
}
|
167
163
|
|
168
|
-
return
|
164
|
+
return buildOptions.themeName;
|
169
165
|
})();
|
170
166
|
|
171
|
-
const
|
167
|
+
const projectBuildDirPath = (() => {
|
172
168
|
webpack: {
|
173
169
|
if (resolvedViteConfig !== undefined) {
|
174
170
|
break webpack;
|
175
171
|
}
|
176
172
|
|
177
|
-
if (parsedPackageJson.keycloakify?.
|
173
|
+
if (parsedPackageJson.keycloakify?.projectBuildDirPath !== undefined) {
|
178
174
|
return getAbsoluteAndInOsFormatPath({
|
179
|
-
pathIsh: parsedPackageJson.keycloakify.
|
180
|
-
cwd:
|
175
|
+
pathIsh: parsedPackageJson.keycloakify.projectBuildDirPath,
|
176
|
+
cwd: projectDirPath
|
181
177
|
});
|
182
178
|
}
|
183
179
|
|
184
|
-
return pathJoin(
|
180
|
+
return pathJoin(projectDirPath, "build");
|
185
181
|
}
|
186
182
|
|
187
|
-
return pathJoin(
|
183
|
+
return pathJoin(projectDirPath, resolvedViteConfig.buildDir);
|
188
184
|
})();
|
189
185
|
|
190
186
|
const { npmWorkspaceRootDirPath } = getNpmWorkspaceRootDirPath({
|
191
|
-
|
187
|
+
projectDirPath,
|
192
188
|
dependencyExpected: "keycloakify"
|
193
189
|
});
|
194
190
|
|
@@ -197,13 +193,13 @@ export function readBuildOptions(params: {
|
|
197
193
|
themeVersion:
|
198
194
|
process.env.KEYCLOAKIFY_THEME_VERSION ?? parsedPackageJson.version ?? "0.0.0",
|
199
195
|
themeNames,
|
200
|
-
extraThemeProperties:
|
196
|
+
extraThemeProperties: buildOptions.extraThemeProperties,
|
201
197
|
groupId: (() => {
|
202
198
|
const fallbackGroupId = `${themeNames[0]}.keycloak`;
|
203
199
|
|
204
200
|
return (
|
205
201
|
process.env.KEYCLOAKIFY_GROUP_ID ??
|
206
|
-
|
202
|
+
buildOptions.groupId ??
|
207
203
|
(parsedPackageJson.homepage === undefined
|
208
204
|
? fallbackGroupId
|
209
205
|
: urlParse(parsedPackageJson.homepage)
|
@@ -215,22 +211,22 @@ export function readBuildOptions(params: {
|
|
215
211
|
})(),
|
216
212
|
artifactId:
|
217
213
|
process.env.KEYCLOAKIFY_ARTIFACT_ID ??
|
218
|
-
|
214
|
+
buildOptions.artifactId ??
|
219
215
|
`${themeNames[0]}-keycloak-theme`,
|
220
216
|
loginThemeResourcesFromKeycloakVersion:
|
221
|
-
|
222
|
-
|
223
|
-
|
217
|
+
buildOptions.loginThemeResourcesFromKeycloakVersion ?? "24.0.4",
|
218
|
+
projectDirPath,
|
219
|
+
projectBuildDirPath,
|
224
220
|
keycloakifyBuildDirPath: (() => {
|
225
|
-
if (
|
221
|
+
if (buildOptions.keycloakifyBuildDirPath !== undefined) {
|
226
222
|
return getAbsoluteAndInOsFormatPath({
|
227
|
-
pathIsh:
|
228
|
-
cwd:
|
223
|
+
pathIsh: buildOptions.keycloakifyBuildDirPath,
|
224
|
+
cwd: projectDirPath
|
229
225
|
});
|
230
226
|
}
|
231
227
|
|
232
228
|
return pathJoin(
|
233
|
-
|
229
|
+
projectDirPath,
|
234
230
|
resolvedViteConfig?.buildDir === undefined
|
235
231
|
? "build_keycloak"
|
236
232
|
: `${resolvedViteConfig.buildDir}_keycloak`
|
@@ -245,14 +241,14 @@ export function readBuildOptions(params: {
|
|
245
241
|
if (process.env.PUBLIC_DIR_PATH !== undefined) {
|
246
242
|
return getAbsoluteAndInOsFormatPath({
|
247
243
|
pathIsh: process.env.PUBLIC_DIR_PATH,
|
248
|
-
cwd:
|
244
|
+
cwd: projectDirPath
|
249
245
|
});
|
250
246
|
}
|
251
247
|
|
252
|
-
return pathJoin(
|
248
|
+
return pathJoin(projectDirPath, "public");
|
253
249
|
}
|
254
250
|
|
255
|
-
return pathJoin(
|
251
|
+
return pathJoin(projectDirPath, resolvedViteConfig.publicDir);
|
256
252
|
})(),
|
257
253
|
cacheDirPath: (() => {
|
258
254
|
const cacheDirPath = pathJoin(
|
@@ -301,13 +297,28 @@ export function readBuildOptions(params: {
|
|
301
297
|
break webpack;
|
302
298
|
}
|
303
299
|
|
304
|
-
return pathJoin(
|
300
|
+
return pathJoin(projectBuildDirPath, "static");
|
305
301
|
}
|
306
302
|
|
307
|
-
return pathJoin(
|
303
|
+
return pathJoin(projectBuildDirPath, resolvedViteConfig.assetsDir);
|
308
304
|
})(),
|
309
305
|
npmWorkspaceRootDirPath,
|
310
|
-
kcContextExclusionsFtlCode:
|
311
|
-
|
306
|
+
kcContextExclusionsFtlCode: (() => {
|
307
|
+
if (buildOptions.kcContextExclusionsFtl === undefined) {
|
308
|
+
return undefined;
|
309
|
+
}
|
310
|
+
|
311
|
+
if (buildOptions.kcContextExclusionsFtl.endsWith(".ftl")) {
|
312
|
+
const kcContextExclusionsFtlPath = getAbsoluteAndInOsFormatPath({
|
313
|
+
pathIsh: buildOptions.kcContextExclusionsFtl,
|
314
|
+
cwd: projectDirPath
|
315
|
+
});
|
316
|
+
|
317
|
+
return fs.readFileSync(kcContextExclusionsFtlPath).toString("utf8");
|
318
|
+
}
|
319
|
+
|
320
|
+
return buildOptions.kcContextExclusionsFtl;
|
321
|
+
})(),
|
322
|
+
environmentVariables: buildOptions.environmentVariables ?? []
|
312
323
|
};
|
313
324
|
}
|
@@ -1,6 +1,6 @@
|
|
1
1
|
import {
|
2
2
|
downloadKeycloakStaticResources,
|
3
|
-
type
|
3
|
+
type BuildContextLike as BuildContextLike_downloadKeycloakStaticResources
|
4
4
|
} from "./downloadKeycloakStaticResources";
|
5
5
|
import { join as pathJoin, relative as pathRelative } from "path";
|
6
6
|
import {
|
@@ -12,21 +12,21 @@ import { readThisNpmPackageVersion } from "../tools/readThisNpmPackageVersion";
|
|
12
12
|
import { assert } from "tsafe/assert";
|
13
13
|
import * as fs from "fs";
|
14
14
|
import { rmSync } from "../tools/fs.rmSync";
|
15
|
-
import type {
|
15
|
+
import type { BuildContext } from "./buildContext";
|
16
16
|
|
17
|
-
export type
|
17
|
+
export type BuildContextLike = BuildContextLike_downloadKeycloakStaticResources & {
|
18
18
|
loginThemeResourcesFromKeycloakVersion: string;
|
19
19
|
publicDirPath: string;
|
20
20
|
};
|
21
21
|
|
22
|
-
assert<
|
22
|
+
assert<BuildContext extends BuildContextLike ? true : false>();
|
23
23
|
|
24
24
|
export async function copyKeycloakResourcesToPublic(params: {
|
25
|
-
|
25
|
+
buildContext: BuildContextLike;
|
26
26
|
}) {
|
27
|
-
const {
|
27
|
+
const { buildContext } = params;
|
28
28
|
|
29
|
-
const destDirPath = pathJoin(
|
29
|
+
const destDirPath = pathJoin(buildContext.publicDirPath, keycloak_resources);
|
30
30
|
|
31
31
|
const keycloakifyBuildinfoFilePath = pathJoin(destDirPath, "keycloakify.buildinfo");
|
32
32
|
|
@@ -34,12 +34,12 @@ export async function copyKeycloakResourcesToPublic(params: {
|
|
34
34
|
{
|
35
35
|
destDirPath,
|
36
36
|
keycloakifyVersion: readThisNpmPackageVersion(),
|
37
|
-
|
37
|
+
buildContext: {
|
38
38
|
loginThemeResourcesFromKeycloakVersion: readThisNpmPackageVersion(),
|
39
|
-
cacheDirPath: pathRelative(destDirPath,
|
39
|
+
cacheDirPath: pathRelative(destDirPath, buildContext.cacheDirPath),
|
40
40
|
npmWorkspaceRootDirPath: pathRelative(
|
41
41
|
destDirPath,
|
42
|
-
|
42
|
+
buildContext.npmWorkspaceRootDirPath
|
43
43
|
)
|
44
44
|
}
|
45
45
|
},
|
@@ -74,14 +74,14 @@ export async function copyKeycloakResourcesToPublic(params: {
|
|
74
74
|
keycloakVersion: (() => {
|
75
75
|
switch (themeType) {
|
76
76
|
case "login":
|
77
|
-
return
|
77
|
+
return buildContext.loginThemeResourcesFromKeycloakVersion;
|
78
78
|
case "account":
|
79
79
|
return lastKeycloakVersionWithAccountV1;
|
80
80
|
}
|
81
81
|
})(),
|
82
82
|
themeType,
|
83
83
|
themeDirPath: destDirPath,
|
84
|
-
|
84
|
+
buildContext
|
85
85
|
});
|
86
86
|
}
|
87
87
|
|
@@ -1,27 +1,27 @@
|
|
1
1
|
import { join as pathJoin, relative as pathRelative } from "path";
|
2
|
-
import { type
|
2
|
+
import { type BuildContext } from "./buildContext";
|
3
3
|
import { assert } from "tsafe/assert";
|
4
4
|
import { lastKeycloakVersionWithAccountV1 } from "./constants";
|
5
5
|
import { downloadAndExtractArchive } from "../tools/downloadAndExtractArchive";
|
6
6
|
import { isInside } from "../tools/isInside";
|
7
7
|
|
8
|
-
export type
|
8
|
+
export type BuildContextLike = {
|
9
9
|
cacheDirPath: string;
|
10
10
|
npmWorkspaceRootDirPath: string;
|
11
11
|
};
|
12
12
|
|
13
|
-
assert<
|
13
|
+
assert<BuildContext extends BuildContextLike ? true : false>();
|
14
14
|
|
15
15
|
export async function downloadKeycloakDefaultTheme(params: {
|
16
16
|
keycloakVersion: string;
|
17
|
-
|
17
|
+
buildContext: BuildContextLike;
|
18
18
|
}): Promise<{ defaultThemeDirPath: string }> {
|
19
|
-
const { keycloakVersion,
|
19
|
+
const { keycloakVersion, buildContext } = params;
|
20
20
|
|
21
21
|
const { extractedDirPath } = await downloadAndExtractArchive({
|
22
22
|
url: `https://repo1.maven.org/maven2/org/keycloak/keycloak-themes/${keycloakVersion}/keycloak-themes-${keycloakVersion}.jar`,
|
23
|
-
cacheDirPath:
|
24
|
-
npmWorkspaceRootDirPath:
|
23
|
+
cacheDirPath: buildContext.cacheDirPath,
|
24
|
+
npmWorkspaceRootDirPath: buildContext.npmWorkspaceRootDirPath,
|
25
25
|
uniqueIdOfOnOnArchiveFile: "downloadKeycloakDefaultTheme",
|
26
26
|
onArchiveFile: async params => {
|
27
27
|
if (!isInside({ dirPath: "theme", filePath: params.fileRelativePath })) {
|
@@ -2,28 +2,28 @@ import { transformCodebase } from "../tools/transformCodebase";
|
|
2
2
|
import { join as pathJoin } from "path";
|
3
3
|
import {
|
4
4
|
downloadKeycloakDefaultTheme,
|
5
|
-
type
|
5
|
+
type BuildContextLike as BuildContextLike_downloadKeycloakDefaultTheme
|
6
6
|
} from "./downloadKeycloakDefaultTheme";
|
7
7
|
import { resources_common, type ThemeType } from "./constants";
|
8
|
-
import type {
|
8
|
+
import type { BuildContext } from "./buildContext";
|
9
9
|
import { assert } from "tsafe/assert";
|
10
10
|
import { existsAsync } from "../tools/fs.existsAsync";
|
11
11
|
|
12
|
-
export type
|
12
|
+
export type BuildContextLike = BuildContextLike_downloadKeycloakDefaultTheme & {};
|
13
13
|
|
14
|
-
assert<
|
14
|
+
assert<BuildContext extends BuildContextLike ? true : false>();
|
15
15
|
|
16
16
|
export async function downloadKeycloakStaticResources(params: {
|
17
17
|
themeType: ThemeType;
|
18
18
|
themeDirPath: string;
|
19
19
|
keycloakVersion: string;
|
20
|
-
|
20
|
+
buildContext: BuildContextLike;
|
21
21
|
}) {
|
22
|
-
const { themeType, themeDirPath, keycloakVersion,
|
22
|
+
const { themeType, themeDirPath, keycloakVersion, buildContext } = params;
|
23
23
|
|
24
24
|
const { defaultThemeDirPath } = await downloadKeycloakDefaultTheme({
|
25
25
|
keycloakVersion,
|
26
|
-
|
26
|
+
buildContext
|
27
27
|
});
|
28
28
|
|
29
29
|
const resourcesDirPath = pathJoin(themeDirPath, themeType, "resources");
|
@@ -1,24 +1,24 @@
|
|
1
1
|
import { assert } from "tsafe/assert";
|
2
|
-
import type {
|
2
|
+
import type { BuildContext } from "./buildContext";
|
3
3
|
import { getThemeSrcDirPath } from "./getThemeSrcDirPath";
|
4
4
|
import * as fs from "fs/promises";
|
5
5
|
import { join as pathJoin } from "path";
|
6
6
|
|
7
|
-
export type
|
8
|
-
|
7
|
+
export type BuildContextLike = {
|
8
|
+
projectDirPath: string;
|
9
9
|
themeNames: string[];
|
10
10
|
environmentVariables: { name: string; default: string }[];
|
11
11
|
};
|
12
12
|
|
13
|
-
assert<
|
13
|
+
assert<BuildContext extends BuildContextLike ? true : false>();
|
14
14
|
|
15
15
|
export async function generateKcGenTs(params: {
|
16
|
-
|
16
|
+
buildContext: BuildContextLike;
|
17
17
|
}): Promise<void> {
|
18
|
-
const {
|
18
|
+
const { buildContext } = params;
|
19
19
|
|
20
20
|
const { themeSrcDirPath } = getThemeSrcDirPath({
|
21
|
-
|
21
|
+
projectDirPath: buildContext.projectDirPath
|
22
22
|
});
|
23
23
|
|
24
24
|
await fs.writeFile(
|
@@ -35,17 +35,17 @@ export async function generateKcGenTs(params: {
|
|
35
35
|
``,
|
36
36
|
`// This file is auto-generated by Keycloakify`,
|
37
37
|
``,
|
38
|
-
`export type ThemeName = ${
|
38
|
+
`export type ThemeName = ${buildContext.themeNames.map(themeName => `"${themeName}"`).join(" | ")};`,
|
39
39
|
``,
|
40
|
-
`export const themeNames: ThemeName[] = [${
|
40
|
+
`export const themeNames: ThemeName[] = [${buildContext.themeNames.map(themeName => `"${themeName}"`).join(", ")}];`,
|
41
41
|
``,
|
42
|
-
`export type KcEnvName = ${
|
42
|
+
`export type KcEnvName = ${buildContext.environmentVariables.length === 0 ? "never" : buildContext.environmentVariables.map(({ name }) => `"${name}"`).join(" | ")};`,
|
43
43
|
``,
|
44
|
-
`export const KcEnvNames: KcEnvName[] = [${
|
44
|
+
`export const KcEnvNames: KcEnvName[] = [${buildContext.environmentVariables.map(({ name }) => `"${name}"`).join(", ")}];`,
|
45
45
|
``,
|
46
46
|
`export const kcEnvDefaults: Record<KcEnvName, string> = ${JSON.stringify(
|
47
47
|
Object.fromEntries(
|
48
|
-
|
48
|
+
buildContext.environmentVariables.map(
|
49
49
|
({ name, default: defaultValue }) => [name, defaultValue]
|
50
50
|
)
|
51
51
|
),
|
@@ -7,10 +7,10 @@ import { themeTypes } from "./constants";
|
|
7
7
|
const themeSrcDirBasenames = ["keycloak-theme", "keycloak_theme"];
|
8
8
|
|
9
9
|
/** Can't catch error, if the directory isn't found, this function will just exit the process with an error message. */
|
10
|
-
export function getThemeSrcDirPath(params: {
|
11
|
-
const {
|
10
|
+
export function getThemeSrcDirPath(params: { projectDirPath: string }) {
|
11
|
+
const { projectDirPath } = params;
|
12
12
|
|
13
|
-
const srcDirPath = pathJoin(
|
13
|
+
const srcDirPath = pathJoin(projectDirPath, "src");
|
14
14
|
|
15
15
|
const themeSrcDirPath: string | undefined = crawl({
|
16
16
|
dirPath: srcDirPath,
|
@@ -2,26 +2,26 @@ import * as child_process from "child_process";
|
|
2
2
|
import { Deferred } from "evt/tools/Deferred";
|
3
3
|
import { assert } from "tsafe/assert";
|
4
4
|
import { is } from "tsafe/is";
|
5
|
-
import type {
|
5
|
+
import type { BuildContext } from "../shared/buildContext";
|
6
6
|
import * as fs from "fs";
|
7
7
|
import { join as pathJoin } from "path";
|
8
8
|
|
9
|
-
export type
|
10
|
-
|
9
|
+
export type BuildContextLike = {
|
10
|
+
projectDirPath: string;
|
11
11
|
keycloakifyBuildDirPath: string;
|
12
12
|
bundler: "vite" | "webpack";
|
13
13
|
npmWorkspaceRootDirPath: string;
|
14
|
-
|
14
|
+
projectBuildDirPath: string;
|
15
15
|
};
|
16
16
|
|
17
|
-
assert<
|
17
|
+
assert<BuildContext extends BuildContextLike ? true : false>();
|
18
18
|
|
19
19
|
export async function appBuild(params: {
|
20
|
-
|
20
|
+
buildContext: BuildContextLike;
|
21
21
|
}): Promise<{ isAppBuildSuccess: boolean }> {
|
22
|
-
const {
|
22
|
+
const { buildContext } = params;
|
23
23
|
|
24
|
-
const { bundler } =
|
24
|
+
const { bundler } = buildContext;
|
25
25
|
|
26
26
|
const { command, args, cwd } = (() => {
|
27
27
|
switch (bundler) {
|
@@ -29,12 +29,12 @@ export async function appBuild(params: {
|
|
29
29
|
return {
|
30
30
|
command: "npx",
|
31
31
|
args: ["vite", "build"],
|
32
|
-
cwd:
|
32
|
+
cwd: buildContext.projectDirPath
|
33
33
|
};
|
34
34
|
case "webpack": {
|
35
35
|
for (const dirPath of [
|
36
|
-
|
37
|
-
|
36
|
+
buildContext.projectDirPath,
|
37
|
+
buildContext.npmWorkspaceRootDirPath
|
38
38
|
]) {
|
39
39
|
try {
|
40
40
|
const parsedPackageJson = JSON.parse(
|
@@ -2,27 +2,27 @@ import { skipBuildJarsEnvName } from "../shared/constants";
|
|
2
2
|
import * as child_process from "child_process";
|
3
3
|
import { Deferred } from "evt/tools/Deferred";
|
4
4
|
import { assert } from "tsafe/assert";
|
5
|
-
import type {
|
5
|
+
import type { BuildContext } from "../shared/buildContext";
|
6
6
|
|
7
|
-
export type
|
8
|
-
|
7
|
+
export type BuildContextLike = {
|
8
|
+
projectDirPath: string;
|
9
9
|
keycloakifyBuildDirPath: string;
|
10
10
|
bundler: "vite" | "webpack";
|
11
11
|
npmWorkspaceRootDirPath: string;
|
12
12
|
};
|
13
13
|
|
14
|
-
assert<
|
14
|
+
assert<BuildContext extends BuildContextLike ? true : false>();
|
15
15
|
|
16
16
|
export async function keycloakifyBuild(params: {
|
17
17
|
doSkipBuildJars: boolean;
|
18
|
-
|
18
|
+
buildContext: BuildContextLike;
|
19
19
|
}): Promise<{ isKeycloakifyBuildSuccess: boolean }> {
|
20
|
-
const {
|
20
|
+
const { buildContext, doSkipBuildJars } = params;
|
21
21
|
|
22
22
|
const dResult = new Deferred<{ isSuccess: boolean }>();
|
23
23
|
|
24
24
|
const child = child_process.spawn("npx", ["keycloakify", "build"], {
|
25
|
-
cwd:
|
25
|
+
cwd: buildContext.projectDirPath,
|
26
26
|
env: {
|
27
27
|
...process.env,
|
28
28
|
...(doSkipBuildJars ? { [skipBuildJarsEnvName]: "true" } : {})
|