keycloakify 11.3.19 → 11.3.21
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/124.index.js +676 -0
- package/bin/356.index.js +700 -0
- package/bin/40.index.js +41 -21
- package/bin/{903.index.js → 450.index.js} +2 -680
- package/bin/453.index.js +143 -85
- package/bin/573.index.js +51 -24
- package/bin/{599.index.js → 735.index.js} +438 -121
- package/bin/786.index.js +129 -78
- package/bin/805.index.js +674 -0
- package/bin/854.index.js +68 -0
- package/bin/{780.index.js → 921.index.js} +168 -109
- package/bin/932.index.js +41 -21
- package/bin/97.index.js +125 -75
- package/bin/eject-file.d.ts +7 -0
- package/bin/keycloakify/generateResources/generateMessageProperties.d.ts +1 -1
- package/bin/keycloakify/generateResources/readFieldNameUsage.d.ts +1 -1
- package/bin/main.js +70 -7
- package/bin/postinstall/getUiModuleFileSourceCodeReadyToBeCopied.d.ts +12 -0
- package/bin/postinstall/index.d.ts +1 -0
- package/bin/postinstall/installUiModulesPeerDependencies.d.ts +11 -0
- package/bin/postinstall/managedGitignoreFile.d.ts +14 -0
- package/bin/postinstall/postinstall.d.ts +4 -0
- package/bin/postinstall/uiModuleMeta.d.ts +21 -0
- package/bin/shared/buildContext.d.ts +3 -0
- package/bin/shared/constants.d.ts +2 -1
- package/bin/shared/constants.js +2 -1
- package/bin/shared/constants.js.map +1 -1
- package/bin/shared/customHandler.d.ts +1 -1
- package/bin/shared/customHandler.js.map +1 -1
- package/bin/shared/exitIfUncommittedChanges.d.ts +3 -0
- package/bin/tools/crawlAsync.d.ts +6 -0
- package/bin/tools/getInstalledModuleDirPath.d.ts +5 -0
- package/bin/tools/listInstalledModules.d.ts +12 -0
- package/bin/tools/nodeModulesBinDirPath.d.ts +1 -0
- package/bin/tools/runPrettier.d.ts +17 -0
- package/package.json +34 -6
- package/src/bin/add-story.ts +28 -10
- package/src/bin/eject-file.ts +68 -0
- package/src/bin/eject-page.ts +51 -31
- package/src/bin/initialize-account-theme/initialize-account-theme.ts +4 -32
- package/src/bin/initialize-account-theme/initializeAccountTheme_singlePage.ts +2 -16
- package/src/bin/keycloakify/generateResources/generateMessageProperties.ts +1 -1
- package/src/bin/keycloakify/generateResources/generateResources.ts +58 -26
- package/src/bin/keycloakify/generateResources/readFieldNameUsage.ts +1 -1
- package/src/bin/main.ts +50 -0
- package/src/bin/postinstall/getUiModuleFileSourceCodeReadyToBeCopied.ts +73 -0
- package/src/bin/postinstall/index.ts +1 -0
- package/src/bin/postinstall/installUiModulesPeerDependencies.ts +158 -0
- package/src/bin/postinstall/managedGitignoreFile.ts +136 -0
- package/src/bin/postinstall/postinstall.ts +79 -0
- package/src/bin/postinstall/uiModuleMeta.ts +309 -0
- package/src/bin/shared/buildContext.ts +11 -5
- package/src/bin/shared/constants.ts +3 -1
- package/src/bin/shared/customHandler.ts +1 -0
- package/src/bin/shared/customHandler_delegate.ts +2 -27
- package/src/bin/shared/exitIfUncommittedChanges.ts +36 -0
- package/src/bin/tools/crawlAsync.ts +51 -0
- package/src/bin/tools/getInstalledModuleDirPath.ts +51 -0
- package/src/bin/tools/listInstalledModules.ts +131 -0
- package/src/bin/tools/nodeModulesBinDirPath.ts +38 -0
- package/src/bin/tools/npmInstall.ts +411 -15
- package/src/bin/tools/readThisNpmPackageVersion.ts +8 -0
- package/src/bin/tools/runPrettier.ts +106 -0
- package/src/bin/update-kc-gen.ts +28 -17
- package/vite-plugin/index.js +9237 -9163
- package/bin/tools/runFormat.d.ts +0 -3
- package/src/bin/tools/runFormat.ts +0 -76
@@ -0,0 +1,17 @@
|
|
1
|
+
export declare function getIsPrettierAvailable(): Promise<boolean>;
|
2
|
+
export declare namespace getIsPrettierAvailable {
|
3
|
+
var cache: boolean | undefined;
|
4
|
+
}
|
5
|
+
type PrettierAndConfigHash = {
|
6
|
+
prettier: typeof import("prettier");
|
7
|
+
configHash: string;
|
8
|
+
};
|
9
|
+
export declare function getPrettier(): Promise<PrettierAndConfigHash>;
|
10
|
+
export declare namespace getPrettier {
|
11
|
+
var cache: PrettierAndConfigHash | undefined;
|
12
|
+
}
|
13
|
+
export declare function runPrettier(params: {
|
14
|
+
sourceCode: string;
|
15
|
+
filePath: string;
|
16
|
+
}): Promise<string>;
|
17
|
+
export {};
|
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "keycloakify",
|
3
|
-
"version": "11.3.
|
3
|
+
"version": "11.3.21",
|
4
4
|
"description": "Framework to create custom Keycloak UIs",
|
5
5
|
"repository": {
|
6
6
|
"type": "git",
|
@@ -647,6 +647,7 @@
|
|
647
647
|
"src/account/pages/Totp.tsx",
|
648
648
|
"src/bin/add-story.ts",
|
649
649
|
"src/bin/copy-keycloak-resources-to-public.ts",
|
650
|
+
"src/bin/eject-file.ts",
|
650
651
|
"src/bin/eject-page.ts",
|
651
652
|
"src/bin/initialize-account-theme/copyBoilerplate.ts",
|
652
653
|
"src/bin/initialize-account-theme/index.ts",
|
@@ -683,11 +684,18 @@
|
|
683
684
|
"src/bin/keycloakify/replacers/replaceImportsInJsCode/vite.ts",
|
684
685
|
"src/bin/keycloakify/replacers/replaceImportsInJsCode/webpack.ts",
|
685
686
|
"src/bin/main.ts",
|
687
|
+
"src/bin/postinstall/getUiModuleFileSourceCodeReadyToBeCopied.ts",
|
688
|
+
"src/bin/postinstall/index.ts",
|
689
|
+
"src/bin/postinstall/installUiModulesPeerDependencies.ts",
|
690
|
+
"src/bin/postinstall/managedGitignoreFile.ts",
|
691
|
+
"src/bin/postinstall/postinstall.ts",
|
692
|
+
"src/bin/postinstall/uiModuleMeta.ts",
|
686
693
|
"src/bin/shared/KeycloakVersionRange.ts",
|
687
694
|
"src/bin/shared/buildContext.ts",
|
688
695
|
"src/bin/shared/constants.ts",
|
689
696
|
"src/bin/shared/customHandler.ts",
|
690
697
|
"src/bin/shared/customHandler_delegate.ts",
|
698
|
+
"src/bin/shared/exitIfUncommittedChanges.ts",
|
691
699
|
"src/bin/shared/getLatestsSemVersionedTag.ts",
|
692
700
|
"src/bin/shared/metaInfKeycloakThemes.ts",
|
693
701
|
"src/bin/shared/promptKeycloakVersion.ts",
|
@@ -708,6 +716,7 @@
|
|
708
716
|
"src/bin/tools/String.prototype.replaceAll.ts",
|
709
717
|
"src/bin/tools/assertNoPnpmDlx.ts",
|
710
718
|
"src/bin/tools/crawl.ts",
|
719
|
+
"src/bin/tools/crawlAsync.ts",
|
711
720
|
"src/bin/tools/crc32.ts",
|
712
721
|
"src/bin/tools/deflate.ts",
|
713
722
|
"src/bin/tools/downloadAndExtractArchive.ts",
|
@@ -718,15 +727,18 @@
|
|
718
727
|
"src/bin/tools/fs.rm.ts",
|
719
728
|
"src/bin/tools/fs.rmSync.ts",
|
720
729
|
"src/bin/tools/getAbsoluteAndInOsFormatPath.ts",
|
730
|
+
"src/bin/tools/getInstalledModuleDirPath.ts",
|
721
731
|
"src/bin/tools/getThisCodebaseRootDirPath.ts",
|
722
732
|
"src/bin/tools/isInside.ts",
|
723
733
|
"src/bin/tools/kebabCaseToSnakeCase.ts",
|
734
|
+
"src/bin/tools/listInstalledModules.ts",
|
735
|
+
"src/bin/tools/nodeModulesBinDirPath.ts",
|
724
736
|
"src/bin/tools/npmInstall.ts",
|
725
737
|
"src/bin/tools/octokit-addons/getLatestsSemVersionedTag.ts",
|
726
738
|
"src/bin/tools/octokit-addons/listTags.ts",
|
727
739
|
"src/bin/tools/partitionPromiseSettledResults.ts",
|
728
740
|
"src/bin/tools/readThisNpmPackageVersion.ts",
|
729
|
-
"src/bin/tools/
|
741
|
+
"src/bin/tools/runPrettier.ts",
|
730
742
|
"src/bin/tools/tee.ts",
|
731
743
|
"src/bin/tools/transformCodebase.ts",
|
732
744
|
"src/bin/tools/trimIndent.ts",
|
@@ -996,6 +1008,7 @@
|
|
996
1008
|
"tools/waitForElementMountedOnDom.js.map",
|
997
1009
|
"bin/add-story.d.ts",
|
998
1010
|
"bin/copy-keycloak-resources-to-public.d.ts",
|
1011
|
+
"bin/eject-file.d.ts",
|
999
1012
|
"bin/eject-page.d.ts",
|
1000
1013
|
"bin/initialize-account-theme/copyBoilerplate.d.ts",
|
1001
1014
|
"bin/initialize-account-theme/index.d.ts",
|
@@ -1025,10 +1038,17 @@
|
|
1025
1038
|
"bin/keycloakify/replacers/replaceImportsInJsCode/vite.d.ts",
|
1026
1039
|
"bin/keycloakify/replacers/replaceImportsInJsCode/webpack.d.ts",
|
1027
1040
|
"bin/main.d.ts",
|
1041
|
+
"bin/postinstall/getUiModuleFileSourceCodeReadyToBeCopied.d.ts",
|
1042
|
+
"bin/postinstall/index.d.ts",
|
1043
|
+
"bin/postinstall/installUiModulesPeerDependencies.d.ts",
|
1044
|
+
"bin/postinstall/managedGitignoreFile.d.ts",
|
1045
|
+
"bin/postinstall/postinstall.d.ts",
|
1046
|
+
"bin/postinstall/uiModuleMeta.d.ts",
|
1028
1047
|
"bin/shared/buildContext.d.ts",
|
1029
1048
|
"bin/shared/constants.d.ts",
|
1030
1049
|
"bin/shared/customHandler_delegate.d.ts",
|
1031
1050
|
"bin/shared/customHandler.d.ts",
|
1051
|
+
"bin/shared/exitIfUncommittedChanges.d.ts",
|
1032
1052
|
"bin/shared/getLatestsSemVersionedTag.d.ts",
|
1033
1053
|
"bin/shared/KeycloakVersionRange.d.ts",
|
1034
1054
|
"bin/shared/metaInfKeycloakThemes.d.ts",
|
@@ -1039,6 +1059,7 @@
|
|
1039
1059
|
"bin/start-keycloak/start-keycloak.d.ts",
|
1040
1060
|
"bin/tools/assertNoPnpmDlx.d.ts",
|
1041
1061
|
"bin/tools/crawl.d.ts",
|
1062
|
+
"bin/tools/crawlAsync.d.ts",
|
1042
1063
|
"bin/tools/crc32.d.ts",
|
1043
1064
|
"bin/tools/deflate.d.ts",
|
1044
1065
|
"bin/tools/downloadAndExtractArchive.d.ts",
|
@@ -1049,16 +1070,19 @@
|
|
1049
1070
|
"bin/tools/fs.rm.d.ts",
|
1050
1071
|
"bin/tools/fs.rmSync.d.ts",
|
1051
1072
|
"bin/tools/getAbsoluteAndInOsFormatPath.d.ts",
|
1073
|
+
"bin/tools/getInstalledModuleDirPath.d.ts",
|
1052
1074
|
"bin/tools/getThisCodebaseRootDirPath.d.ts",
|
1053
1075
|
"bin/tools/isInside.d.ts",
|
1054
1076
|
"bin/tools/kebabCaseToSnakeCase.d.ts",
|
1077
|
+
"bin/tools/listInstalledModules.d.ts",
|
1078
|
+
"bin/tools/nodeModulesBinDirPath.d.ts",
|
1055
1079
|
"bin/tools/npmInstall.d.ts",
|
1056
1080
|
"bin/tools/octokit-addons/getLatestsSemVersionedTag.d.ts",
|
1057
1081
|
"bin/tools/octokit-addons/listTags.d.ts",
|
1058
1082
|
"bin/tools/OptionalIfCanBeUndefined.d.ts",
|
1059
1083
|
"bin/tools/partitionPromiseSettledResults.d.ts",
|
1060
1084
|
"bin/tools/readThisNpmPackageVersion.d.ts",
|
1061
|
-
"bin/tools/
|
1085
|
+
"bin/tools/runPrettier.d.ts",
|
1062
1086
|
"bin/tools/SemVer.d.ts",
|
1063
1087
|
"bin/tools/String.prototype.replaceAll.d.ts",
|
1064
1088
|
"bin/tools/tee.d.ts",
|
@@ -1066,23 +1090,27 @@
|
|
1066
1090
|
"bin/tools/trimIndent.d.ts",
|
1067
1091
|
"bin/update-kc-gen.d.ts",
|
1068
1092
|
"bin/main.js",
|
1093
|
+
"bin/124.index.js",
|
1069
1094
|
"bin/20.index.js",
|
1070
1095
|
"bin/266.index.js",
|
1071
1096
|
"bin/304.index.js",
|
1072
1097
|
"bin/33.index.js",
|
1098
|
+
"bin/356.index.js",
|
1073
1099
|
"bin/36.index.js",
|
1074
1100
|
"bin/40.index.js",
|
1101
|
+
"bin/450.index.js",
|
1075
1102
|
"bin/453.index.js",
|
1076
1103
|
"bin/526.index.js",
|
1077
1104
|
"bin/573.index.js",
|
1078
|
-
"bin/599.index.js",
|
1079
1105
|
"bin/720.index.js",
|
1106
|
+
"bin/735.index.js",
|
1080
1107
|
"bin/743.index.js",
|
1081
|
-
"bin/780.index.js",
|
1082
1108
|
"bin/783.index.js",
|
1083
1109
|
"bin/786.index.js",
|
1110
|
+
"bin/805.index.js",
|
1111
|
+
"bin/854.index.js",
|
1084
1112
|
"bin/877.index.js",
|
1085
|
-
"bin/
|
1113
|
+
"bin/921.index.js",
|
1086
1114
|
"bin/932.index.js",
|
1087
1115
|
"bin/97.index.js",
|
1088
1116
|
"bin/shared/constants.js",
|
package/src/bin/add-story.ts
CHANGED
@@ -5,8 +5,7 @@ import {
|
|
5
5
|
ACCOUNT_THEME_PAGE_IDS,
|
6
6
|
type LoginThemePageId,
|
7
7
|
type AccountThemePageId,
|
8
|
-
THEME_TYPES
|
9
|
-
type ThemeType
|
8
|
+
THEME_TYPES
|
10
9
|
} from "./shared/constants";
|
11
10
|
import { capitalize } from "tsafe/capitalize";
|
12
11
|
import * as fs from "fs";
|
@@ -15,7 +14,7 @@ import { kebabCaseToCamelCase } from "./tools/kebabCaseToSnakeCase";
|
|
15
14
|
import { assert, Equals } from "tsafe/assert";
|
16
15
|
import type { BuildContext } from "./shared/buildContext";
|
17
16
|
import chalk from "chalk";
|
18
|
-
import {
|
17
|
+
import { runPrettier, getIsPrettierAvailable } from "./tools/runPrettier";
|
19
18
|
import { maybeDelegateCommandToCustomHandler } from "./shared/customHandler_delegate";
|
20
19
|
|
21
20
|
export async function command(params: { buildContext: BuildContext }) {
|
@@ -39,6 +38,8 @@ export async function command(params: { buildContext: BuildContext }) {
|
|
39
38
|
return buildContext.implementedThemeTypes.account.isImplemented;
|
40
39
|
case "login":
|
41
40
|
return buildContext.implementedThemeTypes.login.isImplemented;
|
41
|
+
case "admin":
|
42
|
+
return buildContext.implementedThemeTypes.admin.isImplemented;
|
42
43
|
}
|
43
44
|
assert<Equals<typeof themeType, never>>(false);
|
44
45
|
});
|
@@ -49,7 +50,7 @@ export async function command(params: { buildContext: BuildContext }) {
|
|
49
50
|
return values[0];
|
50
51
|
}
|
51
52
|
|
52
|
-
const { value } = await cliSelect
|
53
|
+
const { value } = await cliSelect({
|
53
54
|
values
|
54
55
|
}).catch(() => {
|
55
56
|
process.exit(-1);
|
@@ -68,6 +69,16 @@ export async function command(params: { buildContext: BuildContext }) {
|
|
68
69
|
);
|
69
70
|
|
70
71
|
process.exit(0);
|
72
|
+
return;
|
73
|
+
}
|
74
|
+
|
75
|
+
if (themeType === "admin") {
|
76
|
+
console.log(
|
77
|
+
`${chalk.red("✗")} Sorry, there is no Storybook support for the Account UI.`
|
78
|
+
);
|
79
|
+
|
80
|
+
process.exit(0);
|
81
|
+
return;
|
71
82
|
}
|
72
83
|
|
73
84
|
console.log(`→ ${themeType}`);
|
@@ -108,7 +119,7 @@ export async function command(params: { buildContext: BuildContext }) {
|
|
108
119
|
process.exit(-1);
|
109
120
|
}
|
110
121
|
|
111
|
-
|
122
|
+
let sourceCode = fs
|
112
123
|
.readFileSync(
|
113
124
|
pathJoin(
|
114
125
|
getThisCodebaseRootDirPath(),
|
@@ -122,6 +133,17 @@ export async function command(params: { buildContext: BuildContext }) {
|
|
122
133
|
.replace('import React from "react";\n', "")
|
123
134
|
.replace(/from "[./]+dist\//, 'from "keycloakify/');
|
124
135
|
|
136
|
+
run_prettier: {
|
137
|
+
if (!(await getIsPrettierAvailable())) {
|
138
|
+
break run_prettier;
|
139
|
+
}
|
140
|
+
|
141
|
+
sourceCode = await runPrettier({
|
142
|
+
filePath: targetFilePath,
|
143
|
+
sourceCode: sourceCode
|
144
|
+
});
|
145
|
+
}
|
146
|
+
|
125
147
|
{
|
126
148
|
const targetDirPath = pathDirname(targetFilePath);
|
127
149
|
|
@@ -130,11 +152,7 @@ export async function command(params: { buildContext: BuildContext }) {
|
|
130
152
|
}
|
131
153
|
}
|
132
154
|
|
133
|
-
fs.writeFileSync(targetFilePath, Buffer.from(
|
134
|
-
|
135
|
-
runFormat({
|
136
|
-
packageJsonFilePath: buildContext.packageJsonFilePath
|
137
|
-
});
|
155
|
+
fs.writeFileSync(targetFilePath, Buffer.from(sourceCode, "utf8"));
|
138
156
|
|
139
157
|
console.log(
|
140
158
|
[
|
@@ -0,0 +1,68 @@
|
|
1
|
+
import type { BuildContext } from "./shared/buildContext";
|
2
|
+
import { getUiModuleFileSourceCodeReadyToBeCopied } from "./postinstall/getUiModuleFileSourceCodeReadyToBeCopied";
|
3
|
+
import { getAbsoluteAndInOsFormatPath } from "./tools/getAbsoluteAndInOsFormatPath";
|
4
|
+
import { relative as pathRelative, dirname as pathDirname, join as pathJoin } from "path";
|
5
|
+
import { getUiModuleMetas } from "./postinstall/uiModuleMeta";
|
6
|
+
import { getInstalledModuleDirPath } from "./tools/getInstalledModuleDirPath";
|
7
|
+
import * as fsPr from "fs/promises";
|
8
|
+
import {
|
9
|
+
readManagedGitignoreFile,
|
10
|
+
writeManagedGitignoreFile
|
11
|
+
} from "./postinstall/managedGitignoreFile";
|
12
|
+
|
13
|
+
export async function command(params: {
|
14
|
+
buildContext: BuildContext;
|
15
|
+
cliCommandOptions: {
|
16
|
+
file: string;
|
17
|
+
};
|
18
|
+
}) {
|
19
|
+
const { buildContext, cliCommandOptions } = params;
|
20
|
+
|
21
|
+
const fileRelativePath = pathRelative(
|
22
|
+
buildContext.themeSrcDirPath,
|
23
|
+
getAbsoluteAndInOsFormatPath({
|
24
|
+
cwd: buildContext.themeSrcDirPath,
|
25
|
+
pathIsh: cliCommandOptions.file
|
26
|
+
})
|
27
|
+
);
|
28
|
+
|
29
|
+
const uiModuleMetas = await getUiModuleMetas({ buildContext });
|
30
|
+
|
31
|
+
const uiModuleMeta = uiModuleMetas.find(({ files }) =>
|
32
|
+
files.map(({ fileRelativePath }) => fileRelativePath).includes(fileRelativePath)
|
33
|
+
);
|
34
|
+
|
35
|
+
if (!uiModuleMeta) {
|
36
|
+
throw new Error(`No UI module found for the file ${fileRelativePath}`);
|
37
|
+
}
|
38
|
+
|
39
|
+
const uiModuleDirPath = await getInstalledModuleDirPath({
|
40
|
+
moduleName: uiModuleMeta.moduleName,
|
41
|
+
packageJsonDirPath: pathDirname(buildContext.packageJsonFilePath),
|
42
|
+
projectDirPath: buildContext.projectDirPath
|
43
|
+
});
|
44
|
+
|
45
|
+
const sourceCode = await getUiModuleFileSourceCodeReadyToBeCopied({
|
46
|
+
buildContext,
|
47
|
+
fileRelativePath,
|
48
|
+
isForEjection: true,
|
49
|
+
uiModuleName: uiModuleMeta.moduleName,
|
50
|
+
uiModuleDirPath,
|
51
|
+
uiModuleVersion: uiModuleMeta.version
|
52
|
+
});
|
53
|
+
|
54
|
+
await fsPr.writeFile(
|
55
|
+
pathJoin(buildContext.themeSrcDirPath, fileRelativePath),
|
56
|
+
sourceCode
|
57
|
+
);
|
58
|
+
|
59
|
+
const { ejectedFilesRelativePaths } = await readManagedGitignoreFile({
|
60
|
+
buildContext
|
61
|
+
});
|
62
|
+
|
63
|
+
await writeManagedGitignoreFile({
|
64
|
+
buildContext,
|
65
|
+
uiModuleMetas,
|
66
|
+
ejectedFilesRelativePaths: [...ejectedFilesRelativePaths, fileRelativePath]
|
67
|
+
});
|
68
|
+
}
|
package/src/bin/eject-page.ts
CHANGED
@@ -7,8 +7,7 @@ import {
|
|
7
7
|
ACCOUNT_THEME_PAGE_IDS,
|
8
8
|
type LoginThemePageId,
|
9
9
|
type AccountThemePageId,
|
10
|
-
THEME_TYPES
|
11
|
-
type ThemeType
|
10
|
+
THEME_TYPES
|
12
11
|
} from "./shared/constants";
|
13
12
|
import { capitalize } from "tsafe/capitalize";
|
14
13
|
import * as fs from "fs";
|
@@ -23,7 +22,7 @@ import { assert, Equals } from "tsafe/assert";
|
|
23
22
|
import type { BuildContext } from "./shared/buildContext";
|
24
23
|
import chalk from "chalk";
|
25
24
|
import { maybeDelegateCommandToCustomHandler } from "./shared/customHandler_delegate";
|
26
|
-
import {
|
25
|
+
import { runPrettier, getIsPrettierAvailable } from "./tools/runPrettier";
|
27
26
|
|
28
27
|
export async function command(params: { buildContext: BuildContext }) {
|
29
28
|
const { buildContext } = params;
|
@@ -46,6 +45,8 @@ export async function command(params: { buildContext: BuildContext }) {
|
|
46
45
|
return buildContext.implementedThemeTypes.account.isImplemented;
|
47
46
|
case "login":
|
48
47
|
return buildContext.implementedThemeTypes.login.isImplemented;
|
48
|
+
case "admin":
|
49
|
+
return buildContext.implementedThemeTypes.admin.isImplemented;
|
49
50
|
}
|
50
51
|
assert<Equals<typeof themeType, never>>(false);
|
51
52
|
});
|
@@ -56,7 +57,7 @@ export async function command(params: { buildContext: BuildContext }) {
|
|
56
57
|
return values[0];
|
57
58
|
}
|
58
59
|
|
59
|
-
const { value } = await cliSelect
|
60
|
+
const { value } = await cliSelect({
|
60
61
|
values
|
61
62
|
}).catch(() => {
|
62
63
|
process.exit(-1);
|
@@ -65,6 +66,14 @@ export async function command(params: { buildContext: BuildContext }) {
|
|
65
66
|
return value;
|
66
67
|
})();
|
67
68
|
|
69
|
+
if (themeType === "admin") {
|
70
|
+
console.log(
|
71
|
+
"Use `npx keycloakify eject-file` command instead, see documentation"
|
72
|
+
);
|
73
|
+
|
74
|
+
process.exit(-1);
|
75
|
+
}
|
76
|
+
|
68
77
|
if (
|
69
78
|
themeType === "account" &&
|
70
79
|
(assert(buildContext.implementedThemeTypes.account.isImplemented),
|
@@ -74,13 +83,13 @@ export async function command(params: { buildContext: BuildContext }) {
|
|
74
83
|
pathDirname(buildContext.packageJsonFilePath),
|
75
84
|
"node_modules",
|
76
85
|
"@keycloakify",
|
77
|
-
|
86
|
+
`keycloak-account-ui`,
|
78
87
|
"src"
|
79
88
|
);
|
80
89
|
|
81
90
|
console.log(
|
82
91
|
[
|
83
|
-
`There isn't an interactive CLI to eject components of the
|
92
|
+
`There isn't an interactive CLI to eject components of the Account SPA UI.`,
|
84
93
|
`You can however copy paste into your codebase the any file or directory from the following source directory:`,
|
85
94
|
``,
|
86
95
|
`${chalk.bold(pathJoin(pathRelative(process.cwd(), srcDirPath)))}`,
|
@@ -89,41 +98,44 @@ export async function command(params: { buildContext: BuildContext }) {
|
|
89
98
|
);
|
90
99
|
|
91
100
|
eject_entrypoint: {
|
92
|
-
const
|
101
|
+
const kcUiTsxFileRelativePath = `KcAccountUi.tsx` as const;
|
93
102
|
|
94
|
-
const
|
95
|
-
buildContext.themeSrcDirPath,
|
96
|
-
"account"
|
97
|
-
);
|
103
|
+
const themeSrcDirPath = pathJoin(buildContext.themeSrcDirPath, "account");
|
98
104
|
|
99
|
-
const targetFilePath = pathJoin(
|
100
|
-
accountThemeSrcDirPath,
|
101
|
-
kcAccountUiTsxFileRelativePath
|
102
|
-
);
|
105
|
+
const targetFilePath = pathJoin(themeSrcDirPath, kcUiTsxFileRelativePath);
|
103
106
|
|
104
107
|
if (fs.existsSync(targetFilePath)) {
|
105
108
|
break eject_entrypoint;
|
106
109
|
}
|
107
110
|
|
108
|
-
fs.cpSync(
|
109
|
-
pathJoin(srcDirPath, kcAccountUiTsxFileRelativePath),
|
110
|
-
targetFilePath
|
111
|
-
);
|
111
|
+
fs.cpSync(pathJoin(srcDirPath, kcUiTsxFileRelativePath), targetFilePath);
|
112
112
|
|
113
113
|
{
|
114
|
-
const kcPageTsxFilePath = pathJoin(
|
114
|
+
const kcPageTsxFilePath = pathJoin(themeSrcDirPath, "KcPage.tsx");
|
115
115
|
|
116
116
|
const kcPageTsxCode = fs.readFileSync(kcPageTsxFilePath).toString("utf8");
|
117
117
|
|
118
|
-
const componentName = pathBasename(
|
119
|
-
|
120
|
-
|
118
|
+
const componentName = pathBasename(kcUiTsxFileRelativePath).replace(
|
119
|
+
/.tsx$/,
|
120
|
+
""
|
121
|
+
);
|
121
122
|
|
122
|
-
|
123
|
+
let modifiedKcPageTsxCode = kcPageTsxCode.replace(
|
123
124
|
`@keycloakify/keycloak-account-ui/${componentName}`,
|
124
125
|
`./${componentName}`
|
125
126
|
);
|
126
127
|
|
128
|
+
run_prettier: {
|
129
|
+
if (!(await getIsPrettierAvailable())) {
|
130
|
+
break run_prettier;
|
131
|
+
}
|
132
|
+
|
133
|
+
modifiedKcPageTsxCode = await runPrettier({
|
134
|
+
filePath: kcPageTsxFilePath,
|
135
|
+
sourceCode: modifiedKcPageTsxCode
|
136
|
+
});
|
137
|
+
}
|
138
|
+
|
127
139
|
fs.writeFileSync(
|
128
140
|
kcPageTsxFilePath,
|
129
141
|
Buffer.from(modifiedKcPageTsxCode, "utf8")
|
@@ -139,13 +151,14 @@ export async function command(params: { buildContext: BuildContext }) {
|
|
139
151
|
[
|
140
152
|
`To help you get started ${chalk.bold(pathRelative(process.cwd(), targetFilePath))} has been copied into your project.`,
|
141
153
|
`The next step is usually to eject ${chalk.bold(routesTsxFilePath)}`,
|
142
|
-
`with \`cp ${routesTsxFilePath} ${pathRelative(process.cwd(),
|
143
|
-
`then update the import of routes in ${
|
154
|
+
`with \`cp ${routesTsxFilePath} ${pathRelative(process.cwd(), themeSrcDirPath)}\``,
|
155
|
+
`then update the import of routes in ${kcUiTsxFileRelativePath}.`
|
144
156
|
].join("\n")
|
145
157
|
);
|
146
158
|
}
|
147
159
|
|
148
160
|
process.exit(0);
|
161
|
+
return;
|
149
162
|
}
|
150
163
|
|
151
164
|
console.log(`→ ${themeType}`);
|
@@ -222,7 +235,7 @@ export async function command(params: { buildContext: BuildContext }) {
|
|
222
235
|
process.exit(-1);
|
223
236
|
}
|
224
237
|
|
225
|
-
|
238
|
+
let componentCode = fs
|
226
239
|
.readFileSync(
|
227
240
|
pathJoin(
|
228
241
|
getThisCodebaseRootDirPath(),
|
@@ -234,6 +247,17 @@ export async function command(params: { buildContext: BuildContext }) {
|
|
234
247
|
)
|
235
248
|
.toString("utf8");
|
236
249
|
|
250
|
+
run_prettier: {
|
251
|
+
if (!(await getIsPrettierAvailable())) {
|
252
|
+
break run_prettier;
|
253
|
+
}
|
254
|
+
|
255
|
+
componentCode = await runPrettier({
|
256
|
+
filePath: targetFilePath,
|
257
|
+
sourceCode: componentCode
|
258
|
+
});
|
259
|
+
}
|
260
|
+
|
237
261
|
{
|
238
262
|
const targetDirPath = pathDirname(targetFilePath);
|
239
263
|
|
@@ -244,10 +268,6 @@ export async function command(params: { buildContext: BuildContext }) {
|
|
244
268
|
|
245
269
|
fs.writeFileSync(targetFilePath, Buffer.from(componentCode, "utf8"));
|
246
270
|
|
247
|
-
runFormat({
|
248
|
-
packageJsonFilePath: buildContext.packageJsonFilePath
|
249
|
-
});
|
250
|
-
|
251
271
|
console.log(
|
252
272
|
`${chalk.green("✓")} ${chalk.bold(
|
253
273
|
pathJoin(".", pathRelative(process.cwd(), targetFilePath))
|
@@ -1,12 +1,12 @@
|
|
1
1
|
import type { BuildContext } from "../shared/buildContext";
|
2
2
|
import cliSelect from "cli-select";
|
3
|
-
import child_process from "child_process";
|
4
3
|
import chalk from "chalk";
|
5
4
|
import { join as pathJoin, relative as pathRelative } from "path";
|
6
5
|
import * as fs from "fs";
|
7
6
|
import { updateAccountThemeImplementationInConfig } from "./updateAccountThemeImplementationInConfig";
|
8
7
|
import { command as updateKcGenCommand } from "../update-kc-gen";
|
9
8
|
import { maybeDelegateCommandToCustomHandler } from "../shared/customHandler_delegate";
|
9
|
+
import { exitIfUncommittedChanges } from "../shared/exitIfUncommittedChanges";
|
10
10
|
|
11
11
|
export async function command(params: { buildContext: BuildContext }) {
|
12
12
|
const { buildContext } = params;
|
@@ -38,37 +38,9 @@ export async function command(params: { buildContext: BuildContext }) {
|
|
38
38
|
process.exit(-1);
|
39
39
|
}
|
40
40
|
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
try {
|
45
|
-
hasUncommittedChanges =
|
46
|
-
child_process
|
47
|
-
.execSync(`git status --porcelain`, {
|
48
|
-
cwd: buildContext.projectDirPath
|
49
|
-
})
|
50
|
-
.toString()
|
51
|
-
.trim() !== "";
|
52
|
-
} catch {
|
53
|
-
// Probably not a git repository
|
54
|
-
break exit_if_uncommitted_changes;
|
55
|
-
}
|
56
|
-
|
57
|
-
if (!hasUncommittedChanges) {
|
58
|
-
break exit_if_uncommitted_changes;
|
59
|
-
}
|
60
|
-
console.warn(
|
61
|
-
[
|
62
|
-
chalk.red(
|
63
|
-
"Please commit or stash your changes before running this command.\n"
|
64
|
-
),
|
65
|
-
"This command will modify your project's files so it's better to have a clean working directory",
|
66
|
-
"so that you can easily see what has been changed and revert if needed."
|
67
|
-
].join(" ")
|
68
|
-
);
|
69
|
-
|
70
|
-
process.exit(-1);
|
71
|
-
}
|
41
|
+
exitIfUncommittedChanges({
|
42
|
+
projectDirPath: buildContext.projectDirPath
|
43
|
+
});
|
72
44
|
|
73
45
|
const { value: accountThemeType } = await cliSelect({
|
74
46
|
values: ["Single-Page" as const, "Multi-Page" as const]
|
@@ -1,4 +1,4 @@
|
|
1
|
-
import {
|
1
|
+
import { relative as pathRelative, dirname as pathDirname } from "path";
|
2
2
|
import type { BuildContext } from "../shared/buildContext";
|
3
3
|
import * as fs from "fs";
|
4
4
|
import chalk from "chalk";
|
@@ -14,7 +14,6 @@ import { is } from "tsafe/is";
|
|
14
14
|
import { id } from "tsafe/id";
|
15
15
|
import { npmInstall } from "../tools/npmInstall";
|
16
16
|
import { copyBoilerplate } from "./copyBoilerplate";
|
17
|
-
import { getThisCodebaseRootDirPath } from "../tools/getThisCodebaseRootDirPath";
|
18
17
|
|
19
18
|
type BuildContextLike = BuildContextLike_getLatestsSemVersionedTag & {
|
20
19
|
fetchOptions: BuildContext["fetchOptions"];
|
@@ -121,20 +120,7 @@ export async function initializeAccountTheme_singlePage(params: {
|
|
121
120
|
JSON.stringify(parsedPackageJson, undefined, 4)
|
122
121
|
);
|
123
122
|
|
124
|
-
|
125
|
-
if (
|
126
|
-
JSON.parse(
|
127
|
-
fs
|
128
|
-
.readFileSync(pathJoin(getThisCodebaseRootDirPath(), "package.json"))
|
129
|
-
.toString("utf8")
|
130
|
-
)["version"] === "0.0.0"
|
131
|
-
) {
|
132
|
-
//NOTE: Linked version
|
133
|
-
break run_npm_install;
|
134
|
-
}
|
135
|
-
|
136
|
-
npmInstall({ packageJsonDirPath: pathDirname(buildContext.packageJsonFilePath) });
|
137
|
-
}
|
123
|
+
npmInstall({ packageJsonDirPath: pathDirname(buildContext.packageJsonFilePath) });
|
138
124
|
|
139
125
|
copyBoilerplate({
|
140
126
|
accountThemeType: "Single-Page",
|
@@ -22,7 +22,7 @@ assert<BuildContext extends BuildContextLike ? true : false>();
|
|
22
22
|
|
23
23
|
export function generateMessageProperties(params: {
|
24
24
|
buildContext: BuildContextLike;
|
25
|
-
themeType: ThemeType
|
25
|
+
themeType: Exclude<ThemeType, "admin">;
|
26
26
|
}): {
|
27
27
|
languageTags: string[];
|
28
28
|
writeMessagePropertiesFiles: (params: {
|