keycloakify 7.6.0 → 7.6.2
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/download-builtin-keycloak-theme.js +6 -2
- package/bin/download-builtin-keycloak-theme.js.map +1 -1
- package/bin/eject-keycloak-page.js +5 -5
- package/bin/eject-keycloak-page.js.map +1 -1
- package/bin/getSrcDirPath.d.ts +12 -0
- package/bin/getSrcDirPath.js +60 -0
- package/bin/getSrcDirPath.js.map +1 -0
- package/bin/initialize-email-theme.js +4 -2
- package/bin/initialize-email-theme.js.map +1 -1
- package/bin/keycloakify/BuildOptions.d.ts +5 -3
- package/bin/keycloakify/BuildOptions.js +62 -5
- package/bin/keycloakify/BuildOptions.js.map +1 -1
- package/bin/keycloakify/keycloakify.js +13 -19
- package/bin/keycloakify/keycloakify.js.map +1 -1
- package/bin/keycloakify/parsedPackageJson.d.ts +26 -3
- package/bin/keycloakify/parsedPackageJson.js +8 -7
- package/bin/keycloakify/parsedPackageJson.js.map +1 -1
- package/bin/tools/trimIndent.d.ts +1 -5
- package/bin/tools/trimIndent.js +16 -32
- package/bin/tools/trimIndent.js.map +1 -1
- package/package.json +5 -5
- package/src/bin/download-builtin-keycloak-theme.ts +12 -2
- package/src/bin/eject-keycloak-page.ts +4 -4
- package/src/bin/getSrcDirPath.ts +43 -0
- package/src/bin/initialize-email-theme.ts +4 -2
- package/src/bin/keycloakify/BuildOptions.ts +53 -10
- package/src/bin/keycloakify/keycloakify.ts +14 -21
- package/src/bin/keycloakify/parsedPackageJson.ts +12 -10
- package/src/bin/tools/trimIndent.ts +19 -24
- package/bin/keycloakify/build-paths.d.ts +0 -12
- package/bin/keycloakify/build-paths.js +0 -93
- package/bin/keycloakify/build-paths.js.map +0 -1
- package/src/bin/keycloakify/build-paths.ts +0 -72
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"trimIndent.js","sourceRoot":"","sources":["../../src/bin/tools/trimIndent.ts"],"names":[],"mappings":";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c;QAAd,6BAAc;;IAC5E,oCAAoC;IACpC,IAAI,MAAM,GAAG,gBAAgB,8BAAC,OAAO,UAAK,IAAI,WACzC,OAAO,CAAC,SAAS,EAAE,EAAE,CAAC;SACtB,OAAO,CAAC,UAAU,EAAE,EAAE,CAAC,CAAC;IAC7B,IAAM,KAAK,GACP,MAAA,MAAA,MAAA,MAAM;SACD,KAAK,CAAC,aAAa,CAAC,0CACnB,MAAM,CAAC,UAAA,CAAC,IAAI,OAAA,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,EAAf,CAAe,CAAC,0CAC5B,GAAG,CAAC,UAAA,CAAC,IAAI,OAAA,CAAC,CAAC,MAAM,EAAR,CAAQ,CAAC,mCAAI,EAAE,CAAC;IACnC,+BAA+B;IAC/B,IAAI,CAAC,KAAK,IAAI,KAAK,CAAC,MAAM,IAAI,CAAC;QAAE,OAAO,MAAM,CAAC;IAC/C,IAAM,OAAO,GAAG,IAAI,CAAC,GAAG,OAAR,IAAI,2BAAQ,KAAK,UAAC,CAAC;IACnC,6CAA6C;IAC7C,IAAI,CAAC,OAAO;QAAE,OAAO,MAAM,CAAC;IAC5B,IAAM,EAAE,GAAG,IAAI,MAAM,CAAC,WAAI,GAAG,CAAC,MAAM,CAAC,OAAO,CAAC,CAAE,EAAE,IAAI,CAAC,CAAC;IACvD,IAAM,QAAQ,GAAG,MAAM,CAAC,OAAO,CAAC,EAAE,EAAE,EAAE,CAAC,CAAC;IACxC,OAAO,QAAQ,CAAC;AACpB,CAAC;AAlBD,6BAkBC"}
|
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "keycloakify",
|
3
|
-
"version": "7.6.
|
3
|
+
"version": "7.6.2",
|
4
4
|
"description": "Create Keycloak themes using React",
|
5
5
|
"repository": {
|
6
6
|
"type": "git",
|
@@ -68,9 +68,9 @@
|
|
68
68
|
"src/account/pages/Password.tsx",
|
69
69
|
"src/bin/download-builtin-keycloak-theme.ts",
|
70
70
|
"src/bin/eject-keycloak-page.ts",
|
71
|
+
"src/bin/getSrcDirPath.ts",
|
71
72
|
"src/bin/initialize-email-theme.ts",
|
72
73
|
"src/bin/keycloakify/BuildOptions.ts",
|
73
|
-
"src/bin/keycloakify/build-paths.ts",
|
74
74
|
"src/bin/keycloakify/ftlValuesGlobalName.ts",
|
75
75
|
"src/bin/keycloakify/generateFtl/ftl_object_to_js_code_declaring_an_object.ftl",
|
76
76
|
"src/bin/keycloakify/generateFtl/generateFtl.ts",
|
@@ -315,15 +315,15 @@
|
|
315
315
|
"bin/eject-keycloak-page.d.ts",
|
316
316
|
"bin/eject-keycloak-page.js",
|
317
317
|
"bin/eject-keycloak-page.js.map",
|
318
|
+
"bin/getSrcDirPath.d.ts",
|
319
|
+
"bin/getSrcDirPath.js",
|
320
|
+
"bin/getSrcDirPath.js.map",
|
318
321
|
"bin/initialize-email-theme.d.ts",
|
319
322
|
"bin/initialize-email-theme.js",
|
320
323
|
"bin/initialize-email-theme.js.map",
|
321
324
|
"bin/keycloakify/BuildOptions.d.ts",
|
322
325
|
"bin/keycloakify/BuildOptions.js",
|
323
326
|
"bin/keycloakify/BuildOptions.js.map",
|
324
|
-
"bin/keycloakify/build-paths.d.ts",
|
325
|
-
"bin/keycloakify/build-paths.js",
|
326
|
-
"bin/keycloakify/build-paths.js.map",
|
327
327
|
"bin/keycloakify/ftlValuesGlobalName.d.ts",
|
328
328
|
"bin/keycloakify/ftlValuesGlobalName.js",
|
329
329
|
"bin/keycloakify/ftlValuesGlobalName.js.map",
|
@@ -4,7 +4,7 @@ import { downloadAndUnzip } from "./tools/downloadAndUnzip";
|
|
4
4
|
import { promptKeycloakVersion } from "./promptKeycloakVersion";
|
5
5
|
import { getCliOptions } from "./tools/cliOptions";
|
6
6
|
import { getLogger } from "./tools/logger";
|
7
|
-
import {
|
7
|
+
import { readBuildOptions } from "./keycloakify/BuildOptions";
|
8
8
|
|
9
9
|
export async function downloadBuiltinKeycloakTheme(params: { keycloakVersion: string; destDirPath: string; isSilent: boolean }) {
|
10
10
|
const { keycloakVersion, destDirPath } = params;
|
@@ -25,7 +25,17 @@ async function main() {
|
|
25
25
|
const logger = getLogger({ isSilent });
|
26
26
|
const { keycloakVersion } = await promptKeycloakVersion();
|
27
27
|
|
28
|
-
const destDirPath = pathJoin(
|
28
|
+
const destDirPath = pathJoin(
|
29
|
+
readBuildOptions({
|
30
|
+
"isSilent": true,
|
31
|
+
"isExternalAssetsCliParamProvided": false,
|
32
|
+
"projectDirPath": process.cwd()
|
33
|
+
}).keycloakifyBuildDirPath,
|
34
|
+
"src",
|
35
|
+
"main",
|
36
|
+
"resources",
|
37
|
+
"theme"
|
38
|
+
);
|
29
39
|
|
30
40
|
logger.log(`Downloading builtins theme of Keycloak ${keycloakVersion} here ${destDirPath}`);
|
31
41
|
|
@@ -16,10 +16,10 @@ import { existsSync } from "fs";
|
|
16
16
|
import { join as pathJoin, relative as pathRelative } from "path";
|
17
17
|
import { kebabCaseToCamelCase } from "./tools/kebabCaseToSnakeCase";
|
18
18
|
import { assert, Equals } from "tsafe/assert";
|
19
|
-
import { getThemeSrcDirPath } from "./
|
19
|
+
import { getThemeSrcDirPath } from "./getSrcDirPath";
|
20
20
|
|
21
21
|
(async () => {
|
22
|
-
const
|
22
|
+
const projectDirPath = getProjectRoot();
|
23
23
|
|
24
24
|
console.log("Select a theme type");
|
25
25
|
|
@@ -51,7 +51,7 @@ import { getThemeSrcDirPath } from "./keycloakify/build-paths";
|
|
51
51
|
|
52
52
|
const pageBasename = capitalize(kebabCaseToCamelCase(pageId)).replace(/ftl$/, "tsx");
|
53
53
|
|
54
|
-
const { themeSrcDirPath } = getThemeSrcDirPath();
|
54
|
+
const { themeSrcDirPath } = getThemeSrcDirPath({ "projectDirPath": projectDirPath });
|
55
55
|
|
56
56
|
if (themeSrcDirPath === undefined) {
|
57
57
|
throw new Error("Couldn't locate your theme sources");
|
@@ -65,7 +65,7 @@ import { getThemeSrcDirPath } from "./keycloakify/build-paths";
|
|
65
65
|
process.exit(-1);
|
66
66
|
}
|
67
67
|
|
68
|
-
writeFile(targetFilePath, await readFile(pathJoin(
|
68
|
+
writeFile(targetFilePath, await readFile(pathJoin(projectDirPath, "src", themeType, "pages", pageBasename)));
|
69
69
|
|
70
70
|
console.log(`${pathRelative(process.cwd(), targetFilePath)} created`);
|
71
71
|
})();
|
@@ -0,0 +1,43 @@
|
|
1
|
+
import * as fs from "fs";
|
2
|
+
import { exclude } from "tsafe";
|
3
|
+
import { crawl } from "./tools/crawl";
|
4
|
+
import { join as pathJoin } from "path";
|
5
|
+
|
6
|
+
const themeSrcDirBasename = "keycloak-theme";
|
7
|
+
|
8
|
+
export function getThemeSrcDirPath(params: { projectDirPath: string }) {
|
9
|
+
const { projectDirPath } = params;
|
10
|
+
|
11
|
+
const srcDirPath = pathJoin(projectDirPath, "src");
|
12
|
+
|
13
|
+
const themeSrcDirPath: string | undefined = crawl(srcDirPath)
|
14
|
+
.map(fileRelativePath => {
|
15
|
+
const split = fileRelativePath.split(themeSrcDirBasename);
|
16
|
+
|
17
|
+
if (split.length !== 2) {
|
18
|
+
return undefined;
|
19
|
+
}
|
20
|
+
|
21
|
+
return pathJoin(srcDirPath, split[0] + themeSrcDirBasename);
|
22
|
+
})
|
23
|
+
.filter(exclude(undefined))[0];
|
24
|
+
|
25
|
+
if (themeSrcDirPath === undefined) {
|
26
|
+
if (fs.existsSync(pathJoin(srcDirPath, "login")) || fs.existsSync(pathJoin(srcDirPath, "account"))) {
|
27
|
+
return { "themeSrcDirPath": srcDirPath };
|
28
|
+
}
|
29
|
+
return { "themeSrcDirPath": undefined };
|
30
|
+
}
|
31
|
+
|
32
|
+
return { themeSrcDirPath };
|
33
|
+
}
|
34
|
+
|
35
|
+
export function getEmailThemeSrcDirPath(params: { projectDirPath: string }) {
|
36
|
+
const { projectDirPath } = params;
|
37
|
+
|
38
|
+
const { themeSrcDirPath } = getThemeSrcDirPath({ projectDirPath });
|
39
|
+
|
40
|
+
const emailThemeSrcDirPath = themeSrcDirPath === undefined ? undefined : pathJoin(themeSrcDirPath, "email");
|
41
|
+
|
42
|
+
return { emailThemeSrcDirPath };
|
43
|
+
}
|
@@ -7,13 +7,15 @@ import { promptKeycloakVersion } from "./promptKeycloakVersion";
|
|
7
7
|
import * as fs from "fs";
|
8
8
|
import { getCliOptions } from "./tools/cliOptions";
|
9
9
|
import { getLogger } from "./tools/logger";
|
10
|
-
import { getEmailThemeSrcDirPath } from "./
|
10
|
+
import { getEmailThemeSrcDirPath } from "./getSrcDirPath";
|
11
11
|
|
12
12
|
export async function main() {
|
13
13
|
const { isSilent } = getCliOptions(process.argv.slice(2));
|
14
14
|
const logger = getLogger({ isSilent });
|
15
15
|
|
16
|
-
const { emailThemeSrcDirPath } = getEmailThemeSrcDirPath(
|
16
|
+
const { emailThemeSrcDirPath } = getEmailThemeSrcDirPath({
|
17
|
+
"projectDirPath": process.cwd()
|
18
|
+
});
|
17
19
|
|
18
20
|
if (emailThemeSrcDirPath === undefined) {
|
19
21
|
logger.warn("Couldn't locate your theme source directory");
|
@@ -4,7 +4,8 @@ import { parse as urlParse } from "url";
|
|
4
4
|
import { typeGuard } from "tsafe/typeGuard";
|
5
5
|
import { symToStr } from "tsafe/symToStr";
|
6
6
|
import { bundlers, getParsedPackageJson, type Bundler } from "./parsedPackageJson";
|
7
|
-
import
|
7
|
+
import * as fs from "fs";
|
8
|
+
import { join as pathJoin, sep as pathSep } from "path";
|
8
9
|
|
9
10
|
/** Consolidated build option gathered form CLI arguments and config in package.json */
|
10
11
|
export type BuildOptions = BuildOptions.Standalone | BuildOptions.ExternalAssets;
|
@@ -21,10 +22,10 @@ export namespace BuildOptions {
|
|
21
22
|
artifactId: string;
|
22
23
|
bundler: Bundler;
|
23
24
|
keycloakVersionDefaultAssets: string;
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
25
|
+
/** Directory of your built react project. Defaults to {cwd}/build */
|
26
|
+
reactAppBuildDirPath: string;
|
27
|
+
/** Directory that keycloakify outputs to. Defaults to {cwd}/build_keycloak */
|
28
|
+
keycloakifyBuildDirPath: string;
|
28
29
|
customUserAttributes: string[];
|
29
30
|
};
|
30
31
|
|
@@ -52,10 +53,10 @@ export namespace BuildOptions {
|
|
52
53
|
}
|
53
54
|
}
|
54
55
|
|
55
|
-
export function readBuildOptions(params: {
|
56
|
-
const {
|
56
|
+
export function readBuildOptions(params: { projectDirPath: string; isExternalAssetsCliParamProvided: boolean; isSilent: boolean }): BuildOptions {
|
57
|
+
const { projectDirPath, isExternalAssetsCliParamProvided, isSilent } = params;
|
57
58
|
|
58
|
-
const parsedPackageJson = getParsedPackageJson();
|
59
|
+
const parsedPackageJson = getParsedPackageJson({ projectDirPath });
|
59
60
|
|
60
61
|
const url = (() => {
|
61
62
|
const { homepage } = parsedPackageJson;
|
@@ -66,6 +67,16 @@ export function readBuildOptions(params: { CNAME: string | undefined; isExternal
|
|
66
67
|
url = new URL(homepage);
|
67
68
|
}
|
68
69
|
|
70
|
+
const CNAME = (() => {
|
71
|
+
const cnameFilePath = pathJoin(projectDirPath, "public", "CNAME");
|
72
|
+
|
73
|
+
if (!fs.existsSync(cnameFilePath)) {
|
74
|
+
return undefined;
|
75
|
+
}
|
76
|
+
|
77
|
+
return fs.readFileSync(cnameFilePath).toString("utf8");
|
78
|
+
})();
|
79
|
+
|
69
80
|
if (CNAME !== undefined) {
|
70
81
|
url = new URL(`https://${CNAME.replace(/\s+$/, "")}`);
|
71
82
|
}
|
@@ -134,8 +145,40 @@ export function readBuildOptions(params: { CNAME: string | undefined; isExternal
|
|
134
145
|
extraThemeProperties,
|
135
146
|
isSilent,
|
136
147
|
"keycloakVersionDefaultAssets": keycloakVersionDefaultAssets ?? "11.0.3",
|
137
|
-
|
138
|
-
|
148
|
+
"reactAppBuildDirPath": (() => {
|
149
|
+
let { reactAppBuildDirPath = undefined } = parsedPackageJson.keycloakify ?? {};
|
150
|
+
|
151
|
+
if (reactAppBuildDirPath === undefined) {
|
152
|
+
return pathJoin(projectDirPath, "build");
|
153
|
+
}
|
154
|
+
|
155
|
+
if (pathSep === "\\") {
|
156
|
+
reactAppBuildDirPath = reactAppBuildDirPath.replace(/\//g, pathSep);
|
157
|
+
}
|
158
|
+
|
159
|
+
if (reactAppBuildDirPath.startsWith(`.${pathSep}`)) {
|
160
|
+
return pathJoin(projectDirPath, reactAppBuildDirPath);
|
161
|
+
}
|
162
|
+
|
163
|
+
return reactAppBuildDirPath;
|
164
|
+
})(),
|
165
|
+
"keycloakifyBuildDirPath": (() => {
|
166
|
+
let { keycloakifyBuildDirPath = undefined } = parsedPackageJson.keycloakify ?? {};
|
167
|
+
|
168
|
+
if (keycloakifyBuildDirPath === undefined) {
|
169
|
+
return pathJoin(projectDirPath, "build_keycloak");
|
170
|
+
}
|
171
|
+
|
172
|
+
if (pathSep === "\\") {
|
173
|
+
keycloakifyBuildDirPath = keycloakifyBuildDirPath.replace(/\//g, pathSep);
|
174
|
+
}
|
175
|
+
|
176
|
+
if (keycloakifyBuildDirPath.startsWith(`.${pathSep}`)) {
|
177
|
+
return pathJoin(projectDirPath, keycloakifyBuildDirPath);
|
178
|
+
}
|
179
|
+
|
180
|
+
return keycloakifyBuildDirPath;
|
181
|
+
})(),
|
139
182
|
"customUserAttributes": keycloakify.customUserAttributes ?? []
|
140
183
|
};
|
141
184
|
})();
|
@@ -10,32 +10,25 @@ import { getCliOptions } from "../tools/cliOptions";
|
|
10
10
|
import jar from "../tools/jar";
|
11
11
|
import { assert } from "tsafe/assert";
|
12
12
|
import { Equals } from "tsafe";
|
13
|
-
import { getEmailThemeSrcDirPath } from "
|
14
|
-
import { getCnamePath, getAppInputPath, getKeycloakBuildPath, getReactProjectDirPath } from "./build-paths";
|
13
|
+
import { getEmailThemeSrcDirPath } from "../getSrcDirPath";
|
15
14
|
|
16
15
|
export async function main() {
|
17
16
|
const { isSilent, hasExternalAssets } = getCliOptions(process.argv.slice(2));
|
18
17
|
const logger = getLogger({ isSilent });
|
19
18
|
logger.log("🔏 Building the keycloak theme...⌚");
|
20
19
|
|
21
|
-
const
|
22
|
-
"CNAME": (() => {
|
23
|
-
const cnameFilePath = getCnamePath();
|
24
|
-
|
25
|
-
if (!fs.existsSync(cnameFilePath)) {
|
26
|
-
return undefined;
|
27
|
-
}
|
20
|
+
const projectDirPath = process.cwd();
|
28
21
|
|
29
|
-
|
30
|
-
|
22
|
+
const buildOptions = readBuildOptions({
|
23
|
+
projectDirPath,
|
31
24
|
"isExternalAssetsCliParamProvided": hasExternalAssets,
|
32
25
|
"isSilent": isSilent
|
33
26
|
});
|
34
27
|
|
35
28
|
const { doBundlesEmailTemplate } = await generateKeycloakThemeResources({
|
36
|
-
keycloakThemeBuildingDirPath: buildOptions.
|
29
|
+
keycloakThemeBuildingDirPath: buildOptions.keycloakifyBuildDirPath,
|
37
30
|
"emailThemeSrcDirPath": (() => {
|
38
|
-
const { emailThemeSrcDirPath } = getEmailThemeSrcDirPath();
|
31
|
+
const { emailThemeSrcDirPath } = getEmailThemeSrcDirPath({ projectDirPath });
|
39
32
|
|
40
33
|
if (emailThemeSrcDirPath === undefined || !fs.existsSync(emailThemeSrcDirPath)) {
|
41
34
|
return;
|
@@ -43,13 +36,13 @@ export async function main() {
|
|
43
36
|
|
44
37
|
return emailThemeSrcDirPath;
|
45
38
|
})(),
|
46
|
-
"reactAppBuildDirPath":
|
39
|
+
"reactAppBuildDirPath": buildOptions.reactAppBuildDirPath,
|
47
40
|
buildOptions,
|
48
41
|
"keycloakVersion": buildOptions.keycloakVersionDefaultAssets
|
49
42
|
});
|
50
43
|
|
51
44
|
const { jarFilePath } = generateJavaStackFiles({
|
52
|
-
keycloakThemeBuildingDirPath: buildOptions.
|
45
|
+
keycloakThemeBuildingDirPath: buildOptions.keycloakifyBuildDirPath,
|
53
46
|
doBundlesEmailTemplate,
|
54
47
|
buildOptions
|
55
48
|
});
|
@@ -61,7 +54,7 @@ export async function main() {
|
|
61
54
|
case "keycloakify":
|
62
55
|
logger.log("🫶 Let keycloakify do its thang");
|
63
56
|
await jar({
|
64
|
-
"rootPath": pathJoin(buildOptions.
|
57
|
+
"rootPath": pathJoin(buildOptions.keycloakifyBuildDirPath, "src", "main", "resources"),
|
65
58
|
"version": buildOptions.version,
|
66
59
|
"groupId": buildOptions.groupId,
|
67
60
|
"artifactId": buildOptions.artifactId,
|
@@ -70,7 +63,7 @@ export async function main() {
|
|
70
63
|
break;
|
71
64
|
case "mvn":
|
72
65
|
logger.log("🫙 Run maven to deliver a jar");
|
73
|
-
child_process.execSync("mvn package", { "cwd": buildOptions.
|
66
|
+
child_process.execSync("mvn package", { "cwd": buildOptions.keycloakifyBuildDirPath });
|
74
67
|
break;
|
75
68
|
default:
|
76
69
|
assert<Equals<typeof buildOptions.bundler, never>>(false);
|
@@ -80,7 +73,7 @@ export async function main() {
|
|
80
73
|
const containerKeycloakVersion = "20.0.1";
|
81
74
|
|
82
75
|
generateStartKeycloakTestingContainer({
|
83
|
-
keycloakThemeBuildingDirPath: buildOptions.
|
76
|
+
keycloakThemeBuildingDirPath: buildOptions.keycloakifyBuildDirPath,
|
84
77
|
"keycloakVersion": containerKeycloakVersion,
|
85
78
|
buildOptions
|
86
79
|
});
|
@@ -88,7 +81,7 @@ export async function main() {
|
|
88
81
|
logger.log(
|
89
82
|
[
|
90
83
|
"",
|
91
|
-
`✅ Your keycloak theme has been generated and bundled into
|
84
|
+
`✅ Your keycloak theme has been generated and bundled into .${pathSep}${pathRelative(projectDirPath, jarFilePath)} 🚀`,
|
92
85
|
`It is to be placed in "/opt/keycloak/providers" in the container running a quay.io/keycloak/keycloak Docker image.`,
|
93
86
|
"",
|
94
87
|
//TODO: Restore when we find a good Helm chart for Keycloak.
|
@@ -123,8 +116,8 @@ export async function main() {
|
|
123
116
|
`To test your theme locally you can spin up a Keycloak ${containerKeycloakVersion} container image with the theme pre loaded by running:`,
|
124
117
|
"",
|
125
118
|
`👉 $ .${pathSep}${pathRelative(
|
126
|
-
|
127
|
-
pathJoin(
|
119
|
+
projectDirPath,
|
120
|
+
pathJoin(buildOptions.keycloakifyBuildDirPath, generateStartKeycloakTestingContainer.basename)
|
128
121
|
)} 👈`,
|
129
122
|
"",
|
130
123
|
`Test with different Keycloak versions by editing the .sh file. see available versions here: https://quay.io/repository/keycloak/keycloak?tab=tags`,
|
@@ -4,10 +4,9 @@ import type { Equals } from "tsafe";
|
|
4
4
|
import { z } from "zod";
|
5
5
|
import { pathJoin } from "../tools/pathJoin";
|
6
6
|
|
7
|
-
const reactProjectDirPath = process.cwd();
|
8
7
|
export const bundlers = ["mvn", "keycloakify", "none"] as const;
|
9
8
|
export type Bundler = (typeof bundlers)[number];
|
10
|
-
type ParsedPackageJson = {
|
9
|
+
export type ParsedPackageJson = {
|
11
10
|
name: string;
|
12
11
|
version: string;
|
13
12
|
homepage?: string;
|
@@ -22,8 +21,8 @@ type ParsedPackageJson = {
|
|
22
21
|
groupId?: string;
|
23
22
|
bundler?: Bundler;
|
24
23
|
keycloakVersionDefaultAssets?: string;
|
25
|
-
|
26
|
-
|
24
|
+
reactAppBuildDirPath?: string;
|
25
|
+
keycloakifyBuildDirPath?: string;
|
27
26
|
customUserAttributes?: string[];
|
28
27
|
themeName?: string;
|
29
28
|
};
|
@@ -44,8 +43,8 @@ const zParsedPackageJson = z.object({
|
|
44
43
|
"groupId": z.string().optional(),
|
45
44
|
"bundler": z.enum(bundlers).optional(),
|
46
45
|
"keycloakVersionDefaultAssets": z.string().optional(),
|
47
|
-
"
|
48
|
-
"
|
46
|
+
"reactAppBuildDirPath": z.string().optional(),
|
47
|
+
"keycloakifyBuildDirPath": z.string().optional(),
|
49
48
|
"customUserAttributes": z.array(z.string()).optional(),
|
50
49
|
"themeName": z.string().optional()
|
51
50
|
})
|
@@ -55,8 +54,11 @@ const zParsedPackageJson = z.object({
|
|
55
54
|
assert<Equals<ReturnType<(typeof zParsedPackageJson)["parse"]>, ParsedPackageJson>>();
|
56
55
|
|
57
56
|
let parsedPackageJson: undefined | ReturnType<(typeof zParsedPackageJson)["parse"]>;
|
58
|
-
export
|
59
|
-
|
60
|
-
|
57
|
+
export function getParsedPackageJson(params: { projectDirPath: string }) {
|
58
|
+
const { projectDirPath } = params;
|
59
|
+
if (parsedPackageJson) {
|
60
|
+
return parsedPackageJson;
|
61
|
+
}
|
62
|
+
parsedPackageJson = zParsedPackageJson.parse(JSON.parse(fs.readFileSync(pathJoin(projectDirPath, "package.json")).toString("utf8")));
|
61
63
|
return parsedPackageJson;
|
62
|
-
}
|
64
|
+
}
|
@@ -2,8 +2,8 @@
|
|
2
2
|
* Concatenate the string fragments and interpolated values
|
3
3
|
* to get a single string.
|
4
4
|
*/
|
5
|
-
function populateTemplate(strings: TemplateStringsArray, ...args:
|
6
|
-
const chunks = [];
|
5
|
+
function populateTemplate(strings: TemplateStringsArray, ...args: unknown[]) {
|
6
|
+
const chunks: string[] = [];
|
7
7
|
for (let i = 0; i < strings.length; i++) {
|
8
8
|
let lastStringLineLength = 0;
|
9
9
|
if (strings[i]) {
|
@@ -14,38 +14,33 @@ function populateTemplate(strings: TemplateStringsArray, ...args: any[]) {
|
|
14
14
|
if (args[i]) {
|
15
15
|
// if the interpolation value has newlines, indent the interpolation values
|
16
16
|
// using the last known string indent
|
17
|
-
|
17
|
+
const chunk = String(args[i]).replace(/([\r?\n])/g, "$1" + " ".repeat(lastStringLineLength));
|
18
|
+
chunks.push(chunk);
|
18
19
|
}
|
19
20
|
}
|
20
21
|
return chunks.join("");
|
21
22
|
}
|
22
23
|
|
23
|
-
|
24
|
+
/**
|
25
|
+
* Shift all lines left by the *smallest* indentation level,
|
26
|
+
* and remove initial newline and all trailing spaces.
|
27
|
+
*/
|
28
|
+
export default function trimIndent(strings: TemplateStringsArray, ...args: any[]) {
|
24
29
|
// Remove initial and final newlines
|
25
|
-
let string = populateTemplate(strings, ...args)
|
26
|
-
|
27
|
-
|
30
|
+
let string = populateTemplate(strings, ...args)
|
31
|
+
.replace(/^[\r\n]/, "")
|
32
|
+
.replace(/\r?\n *$/, "");
|
33
|
+
const dents =
|
34
|
+
string
|
35
|
+
.match(/^([ \t])+/gm)
|
36
|
+
?.filter(s => /^\s+$/.test(s))
|
37
|
+
?.map(s => s.length) ?? [];
|
28
38
|
// No dents? no change required
|
29
39
|
if (!dents || dents.length == 0) return string;
|
30
40
|
const minDent = Math.min(...dents);
|
31
41
|
// The min indentation is 0, no change needed
|
32
42
|
if (!minDent) return string;
|
33
|
-
const
|
43
|
+
const re = new RegExp(`^${" ".repeat(minDent)}`, "gm");
|
44
|
+
const dedented = string.replace(re, "");
|
34
45
|
return dedented;
|
35
46
|
}
|
36
|
-
|
37
|
-
/**
|
38
|
-
* Shift all lines left by the *smallest* indentation level,
|
39
|
-
* and remove initial newline and all trailing spaces.
|
40
|
-
*/
|
41
|
-
export default function trimIndent(strings: TemplateStringsArray, ...args: any[]) {
|
42
|
-
return trimIndentPrivate(true, strings, ...args);
|
43
|
-
}
|
44
|
-
|
45
|
-
/**
|
46
|
-
* Shift all lines left by the *smallest* indentation level,
|
47
|
-
* and _keep_ initial newline and all trailing spaces.
|
48
|
-
*/
|
49
|
-
trimIndent.keepLeadingAndTrailingNewlines = function (strings: TemplateStringsArray, ...args: any[]) {
|
50
|
-
return trimIndentPrivate(false, strings, ...args);
|
51
|
-
};
|
@@ -1,12 +0,0 @@
|
|
1
|
-
export declare const getReactProjectDirPath: () => string;
|
2
|
-
export declare const getCnamePath: () => string;
|
3
|
-
export declare const getAppInputPath: () => string;
|
4
|
-
export declare const getKeycloakBuildPath: () => string;
|
5
|
-
export declare const getThemeSrcDirPath: () => {
|
6
|
-
themeSrcDirPath: string;
|
7
|
-
} | {
|
8
|
-
themeSrcDirPath: undefined;
|
9
|
-
};
|
10
|
-
export declare const getEmailThemeSrcDirPath: () => {
|
11
|
-
emailThemeSrcDirPath: string | undefined;
|
12
|
-
};
|
@@ -1,93 +0,0 @@
|
|
1
|
-
"use strict";
|
2
|
-
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
3
|
-
if (k2 === undefined) k2 = k;
|
4
|
-
var desc = Object.getOwnPropertyDescriptor(m, k);
|
5
|
-
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
6
|
-
desc = { enumerable: true, get: function() { return m[k]; } };
|
7
|
-
}
|
8
|
-
Object.defineProperty(o, k2, desc);
|
9
|
-
}) : (function(o, m, k, k2) {
|
10
|
-
if (k2 === undefined) k2 = k;
|
11
|
-
o[k2] = m[k];
|
12
|
-
}));
|
13
|
-
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
14
|
-
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
15
|
-
}) : function(o, v) {
|
16
|
-
o["default"] = v;
|
17
|
-
});
|
18
|
-
var __importStar = (this && this.__importStar) || function (mod) {
|
19
|
-
if (mod && mod.__esModule) return mod;
|
20
|
-
var result = {};
|
21
|
-
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
22
|
-
__setModuleDefault(result, mod);
|
23
|
-
return result;
|
24
|
-
};
|
25
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
26
|
-
exports.getEmailThemeSrcDirPath = exports.getThemeSrcDirPath = exports.getKeycloakBuildPath = exports.getAppInputPath = exports.getCnamePath = exports.getReactProjectDirPath = void 0;
|
27
|
-
var fs = __importStar(require("fs"));
|
28
|
-
var tsafe_1 = require("tsafe");
|
29
|
-
var crawl_1 = require("../tools/crawl");
|
30
|
-
var pathJoin_1 = require("../tools/pathJoin");
|
31
|
-
var parsedPackageJson_1 = require("./parsedPackageJson");
|
32
|
-
var DEFAULT_APP_INPUT_PATH = "build";
|
33
|
-
var DEFAULT_KEYCLOAK_BUILD_PATH = "build_keycloak";
|
34
|
-
var THEME_SRC_DIR_BASENAME = "keycloak-theme";
|
35
|
-
var getReactProjectDirPath = function () { return process.cwd(); };
|
36
|
-
exports.getReactProjectDirPath = getReactProjectDirPath;
|
37
|
-
var getCnamePath = function () { return (0, pathJoin_1.pathJoin)((0, exports.getReactProjectDirPath)(), "public", "CNAME"); };
|
38
|
-
exports.getCnamePath = getCnamePath;
|
39
|
-
var parseAppInputPath = function (path) {
|
40
|
-
if (!path) {
|
41
|
-
return (0, pathJoin_1.pathJoin)(process.cwd(), DEFAULT_APP_INPUT_PATH);
|
42
|
-
}
|
43
|
-
else if (path.startsWith("./")) {
|
44
|
-
return (0, pathJoin_1.pathJoin)(process.cwd(), path.replace("./", ""));
|
45
|
-
}
|
46
|
-
return path;
|
47
|
-
};
|
48
|
-
var parseKeycloakBuildPath = function (path) {
|
49
|
-
if (!path) {
|
50
|
-
return (0, pathJoin_1.pathJoin)(process.cwd(), DEFAULT_KEYCLOAK_BUILD_PATH);
|
51
|
-
}
|
52
|
-
else if (path.startsWith("./")) {
|
53
|
-
return (0, pathJoin_1.pathJoin)(process.cwd(), path.replace("./", ""));
|
54
|
-
}
|
55
|
-
return path;
|
56
|
-
};
|
57
|
-
var getAppInputPath = function () {
|
58
|
-
var _a;
|
59
|
-
return parseAppInputPath((_a = (0, parsedPackageJson_1.getParsedPackageJson)().keycloakify) === null || _a === void 0 ? void 0 : _a.appInputPath);
|
60
|
-
};
|
61
|
-
exports.getAppInputPath = getAppInputPath;
|
62
|
-
var getKeycloakBuildPath = function () {
|
63
|
-
var _a;
|
64
|
-
return parseKeycloakBuildPath((_a = (0, parsedPackageJson_1.getParsedPackageJson)().keycloakify) === null || _a === void 0 ? void 0 : _a.keycloakBuildPath);
|
65
|
-
};
|
66
|
-
exports.getKeycloakBuildPath = getKeycloakBuildPath;
|
67
|
-
var getThemeSrcDirPath = function () {
|
68
|
-
var srcDirPath = (0, pathJoin_1.pathJoin)((0, exports.getReactProjectDirPath)(), "src");
|
69
|
-
var themeSrcDirPath = (0, crawl_1.crawl)(srcDirPath)
|
70
|
-
.map(function (fileRelativePath) {
|
71
|
-
var split = fileRelativePath.split(THEME_SRC_DIR_BASENAME);
|
72
|
-
if (split.length !== 2) {
|
73
|
-
return undefined;
|
74
|
-
}
|
75
|
-
return (0, pathJoin_1.pathJoin)(srcDirPath, split[0] + THEME_SRC_DIR_BASENAME);
|
76
|
-
})
|
77
|
-
.filter((0, tsafe_1.exclude)(undefined))[0];
|
78
|
-
if (themeSrcDirPath === undefined) {
|
79
|
-
if (fs.existsSync((0, pathJoin_1.pathJoin)(srcDirPath, "login")) || fs.existsSync((0, pathJoin_1.pathJoin)(srcDirPath, "account"))) {
|
80
|
-
return { "themeSrcDirPath": srcDirPath };
|
81
|
-
}
|
82
|
-
return { "themeSrcDirPath": undefined };
|
83
|
-
}
|
84
|
-
return { themeSrcDirPath: themeSrcDirPath };
|
85
|
-
};
|
86
|
-
exports.getThemeSrcDirPath = getThemeSrcDirPath;
|
87
|
-
var getEmailThemeSrcDirPath = function () {
|
88
|
-
var themeSrcDirPath = (0, exports.getThemeSrcDirPath)().themeSrcDirPath;
|
89
|
-
var emailThemeSrcDirPath = themeSrcDirPath === undefined ? undefined : (0, pathJoin_1.pathJoin)(themeSrcDirPath, "email");
|
90
|
-
return { emailThemeSrcDirPath: emailThemeSrcDirPath };
|
91
|
-
};
|
92
|
-
exports.getEmailThemeSrcDirPath = getEmailThemeSrcDirPath;
|
93
|
-
//# sourceMappingURL=build-paths.js.map
|
@@ -1 +0,0 @@
|
|
1
|
-
{"version":3,"file":"build-paths.js","sourceRoot":"","sources":["../../src/bin/keycloakify/build-paths.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,qCAAyB;AACzB,+BAAgC;AAChC,wCAAuC;AACvC,8CAA6C;AAC7C,yDAA2D;AAE3D,IAAM,sBAAsB,GAAG,OAAO,CAAC;AAEvC,IAAM,2BAA2B,GAAG,gBAAgB,CAAC;AAErD,IAAM,sBAAsB,GAAG,gBAAgB,CAAC;AAEzC,IAAM,sBAAsB,GAAG,cAAM,OAAA,OAAO,CAAC,GAAG,EAAE,EAAb,CAAa,CAAC;AAA7C,QAAA,sBAAsB,0BA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