keycloakify 11.4.2 → 11.4.4
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/account/i18n/withJsx/i18nBuilder.d.ts +1 -1
- package/bin/392.index.js +68 -32
- package/bin/start-keycloak/appBuild.d.ts +0 -4
- package/login/i18n/withJsx/i18nBuilder.d.ts +1 -1
- package/package.json +1 -1
- package/src/account/i18n/withJsx/i18nBuilder.ts +1 -1
- package/src/bin/initialize-account-theme/src/multi-page/i18n.ts +3 -5
- package/src/bin/start-keycloak/appBuild.ts +95 -48
- package/src/login/i18n/withJsx/i18nBuilder.ts +1 -1
@@ -12,7 +12,7 @@ export type I18nBuilder<ThemeName extends string = never, MessageKey_themeDefine
|
|
12
12
|
}) => I18nBuilder<ThemeName, MessageKey_themeDefined, LanguageTag_notInDefaultSet, ExcludedMethod | "withExtraLanguages">;
|
13
13
|
withCustomTranslations: <MessageKey_themeDefined extends string>(messagesByLanguageTag_themeDefined: Partial<{
|
14
14
|
[LanguageTag in LanguageTag_defaultSet | LanguageTag_notInDefaultSet]: Record<MessageKey_themeDefined, string | Record<ThemeName, string>>;
|
15
|
-
}>) => I18nBuilder<ThemeName, MessageKey_themeDefined, LanguageTag_notInDefaultSet, ExcludedMethod | "withCustomTranslations">;
|
15
|
+
}>) => I18nBuilder<ThemeName, string extends MessageKey_themeDefined ? never : MessageKey_themeDefined, LanguageTag_notInDefaultSet, ExcludedMethod | "withCustomTranslations">;
|
16
16
|
build: () => ReturnTypeOfCreateUseI18n<MessageKey_themeDefined, LanguageTag_notInDefaultSet>;
|
17
17
|
}, ExcludedMethod>;
|
18
18
|
export declare const i18nBuilder: I18nBuilder<never, never, never, never>;
|
package/bin/392.index.js
CHANGED
@@ -50,6 +50,10 @@ var runExclusive = __webpack_require__(81708);
|
|
50
50
|
var extractArchive = __webpack_require__(29121);
|
51
51
|
// EXTERNAL MODULE: ./node_modules/evt/tools/Deferred.js
|
52
52
|
var Deferred = __webpack_require__(50689);
|
53
|
+
// EXTERNAL MODULE: ./node_modules/tsafe/esm/id.mjs
|
54
|
+
var id = __webpack_require__(38469);
|
55
|
+
// EXTERNAL MODULE: ./node_modules/zod/lib/index.mjs
|
56
|
+
var lib = __webpack_require__(52300);
|
53
57
|
;// CONCATENATED MODULE: ./dist/bin/start-keycloak/appBuild.js
|
54
58
|
|
55
59
|
|
@@ -59,42 +63,26 @@ var Deferred = __webpack_require__(50689);
|
|
59
63
|
|
60
64
|
|
61
65
|
|
66
|
+
|
67
|
+
|
62
68
|
(0,assert/* assert */.h)();
|
63
69
|
async function appBuild(params) {
|
64
|
-
const { buildContext } = params;
|
65
|
-
switch (buildContext.bundler) {
|
66
|
-
case "vite":
|
67
|
-
return appBuild_vite({ buildContext });
|
68
|
-
case "webpack":
|
69
|
-
return appBuild_webpack({ buildContext });
|
70
|
-
}
|
71
|
-
}
|
72
|
-
async function appBuild_vite(params) {
|
73
|
-
const { buildContext } = params;
|
74
|
-
(0,assert/* assert */.h)(buildContext.bundler === "vite");
|
75
|
-
const dIsSuccess = new Deferred.Deferred();
|
76
|
-
console.log(source_default().blue("$ npx vite build"));
|
77
|
-
const child = external_child_process_.spawn("npx", ["vite", "build"], {
|
78
|
-
cwd: buildContext.projectDirPath,
|
79
|
-
shell: true
|
80
|
-
});
|
81
|
-
child.stdout.on("data", data => {
|
82
|
-
if (data.toString("utf8").includes("gzip:")) {
|
83
|
-
return;
|
84
|
-
}
|
85
|
-
process.stdout.write(data);
|
86
|
-
});
|
87
|
-
child.stderr.on("data", data => process.stderr.write(data));
|
88
|
-
child.on("exit", code => dIsSuccess.resolve(code === 0));
|
89
|
-
const isSuccess = await dIsSuccess.pr;
|
90
|
-
return { isAppBuildSuccess: isSuccess };
|
91
|
-
}
|
92
|
-
async function appBuild_webpack(params) {
|
93
70
|
var _a;
|
94
71
|
const { buildContext } = params;
|
95
|
-
|
96
|
-
|
97
|
-
|
72
|
+
const { parsedPackageJson } = (() => {
|
73
|
+
const zParsedPackageJson = (() => {
|
74
|
+
const zTargetType = lib.z.object({
|
75
|
+
scripts: lib.z.record(lib.z.string()).optional()
|
76
|
+
});
|
77
|
+
(0,assert/* assert */.h)();
|
78
|
+
return (0,id.id)(zTargetType);
|
79
|
+
})();
|
80
|
+
const parsedPackageJson = JSON.parse(external_fs_.readFileSync(buildContext.packageJsonFilePath).toString("utf8"));
|
81
|
+
zParsedPackageJson.parse(parsedPackageJson);
|
82
|
+
(0,assert/* assert */.h)((0,assert.is)(parsedPackageJson));
|
83
|
+
return { parsedPackageJson };
|
84
|
+
})();
|
85
|
+
const entries = Object.entries((_a = parsedPackageJson.scripts) !== null && _a !== void 0 ? _a : {}).filter(([, scriptCommand]) => scriptCommand.includes("keycloakify build"));
|
98
86
|
if (entries.length === 0) {
|
99
87
|
console.log(source_default().red([
|
100
88
|
`You should have a script in your package.json at ${(0,external_path_.relative)(process.cwd(), (0,external_path_.dirname)(buildContext.packageJsonFilePath))}`,
|
@@ -124,6 +112,54 @@ async function appBuild_webpack(params) {
|
|
124
112
|
console.log(source_default().red(`Your ${scriptName} script should look like "... && keycloakify build ..."`));
|
125
113
|
process.exit(-1);
|
126
114
|
}
|
115
|
+
common_case: {
|
116
|
+
if (appBuildSubCommands.length !== 1) {
|
117
|
+
break common_case;
|
118
|
+
}
|
119
|
+
const [appBuildSubCommand] = appBuildSubCommands;
|
120
|
+
const isNpmRunBuild = (() => {
|
121
|
+
for (const packageManager of ["npm", "yarn", "pnpm", "bun", "deno"]) {
|
122
|
+
for (const doUseRun of [true, false]) {
|
123
|
+
if (`${packageManager}${doUseRun ? " run " : " "}build` ===
|
124
|
+
appBuildSubCommand) {
|
125
|
+
return true;
|
126
|
+
}
|
127
|
+
}
|
128
|
+
}
|
129
|
+
return false;
|
130
|
+
})();
|
131
|
+
if (!isNpmRunBuild) {
|
132
|
+
break common_case;
|
133
|
+
}
|
134
|
+
const { scripts } = parsedPackageJson;
|
135
|
+
(0,assert/* assert */.h)(scripts !== undefined);
|
136
|
+
const buildCmd = scripts.build;
|
137
|
+
if (buildCmd !== "tsc && vite build") {
|
138
|
+
break common_case;
|
139
|
+
}
|
140
|
+
if (scripts.prebuild !== undefined) {
|
141
|
+
break common_case;
|
142
|
+
}
|
143
|
+
if (scripts.postbuild !== undefined) {
|
144
|
+
break common_case;
|
145
|
+
}
|
146
|
+
const dIsSuccess = new Deferred.Deferred();
|
147
|
+
console.log(source_default().blue("$ npx vite build"));
|
148
|
+
const child = external_child_process_.spawn("npx", ["vite", "build"], {
|
149
|
+
cwd: buildContext.projectDirPath,
|
150
|
+
shell: true
|
151
|
+
});
|
152
|
+
child.stdout.on("data", data => {
|
153
|
+
if (data.toString("utf8").includes("gzip:")) {
|
154
|
+
return;
|
155
|
+
}
|
156
|
+
process.stdout.write(data);
|
157
|
+
});
|
158
|
+
child.stderr.on("data", data => process.stderr.write(data));
|
159
|
+
child.on("exit", code => dIsSuccess.resolve(code === 0));
|
160
|
+
const isSuccess = await dIsSuccess.pr;
|
161
|
+
return { isAppBuildSuccess: isSuccess };
|
162
|
+
}
|
127
163
|
let commandCwd = (0,external_path_.dirname)(buildContext.packageJsonFilePath);
|
128
164
|
for (const subCommand of appBuildSubCommands) {
|
129
165
|
const dIsSuccess = new Deferred.Deferred();
|
@@ -1,9 +1,5 @@
|
|
1
|
-
import type { BuildContext } from "../shared/buildContext";
|
2
1
|
export type BuildContextLike = {
|
3
2
|
projectDirPath: string;
|
4
|
-
keycloakifyBuildDirPath: string;
|
5
|
-
bundler: BuildContext["bundler"];
|
6
|
-
projectBuildDirPath: string;
|
7
3
|
packageJsonFilePath: string;
|
8
4
|
};
|
9
5
|
export declare function appBuild(params: {
|
@@ -12,7 +12,7 @@ export type I18nBuilder<ThemeName extends string = never, MessageKey_themeDefine
|
|
12
12
|
}) => I18nBuilder<ThemeName, MessageKey_themeDefined, LanguageTag_notInDefaultSet, ExcludedMethod | "withExtraLanguages">;
|
13
13
|
withCustomTranslations: <MessageKey_themeDefined extends string>(messagesByLanguageTag_themeDefined: Partial<{
|
14
14
|
[LanguageTag in LanguageTag_defaultSet | LanguageTag_notInDefaultSet]: Record<MessageKey_themeDefined, string | Record<ThemeName, string>>;
|
15
|
-
}>) => I18nBuilder<ThemeName, MessageKey_themeDefined, LanguageTag_notInDefaultSet, ExcludedMethod | "withCustomTranslations">;
|
15
|
+
}>) => I18nBuilder<ThemeName, string extends MessageKey_themeDefined ? never : MessageKey_themeDefined, LanguageTag_notInDefaultSet, ExcludedMethod | "withCustomTranslations">;
|
16
16
|
build: () => ReturnTypeOfCreateUseI18n<MessageKey_themeDefined, LanguageTag_notInDefaultSet>;
|
17
17
|
}, ExcludedMethod>;
|
18
18
|
export declare const i18nBuilder: I18nBuilder<never, never, never, never>;
|
package/package.json
CHANGED
@@ -1,11 +1,9 @@
|
|
1
1
|
import { i18nBuilder } from "keycloakify/account";
|
2
2
|
import type { ThemeName } from "../kc.gen";
|
3
3
|
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
.withCustomTranslations({})
|
8
|
-
.build();
|
4
|
+
/** @see: https://docs.keycloakify.dev/i18n */
|
5
|
+
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
6
|
+
const { useI18n, ofTypeI18n } = i18nBuilder.withThemeName<ThemeName>().build();
|
9
7
|
|
10
8
|
type I18n = typeof ofTypeI18n;
|
11
9
|
|
@@ -1,18 +1,17 @@
|
|
1
1
|
import * as child_process from "child_process";
|
2
2
|
import { Deferred } from "evt/tools/Deferred";
|
3
|
-
import { assert } from "tsafe/assert";
|
3
|
+
import { assert, is, type Equals } from "tsafe/assert";
|
4
|
+
import { id } from "tsafe/id";
|
4
5
|
import type { BuildContext } from "../shared/buildContext";
|
5
6
|
import chalk from "chalk";
|
6
7
|
import { sep as pathSep, join as pathJoin } from "path";
|
7
8
|
import { getAbsoluteAndInOsFormatPath } from "../tools/getAbsoluteAndInOsFormatPath";
|
8
9
|
import * as fs from "fs";
|
9
10
|
import { dirname as pathDirname, relative as pathRelative } from "path";
|
11
|
+
import { z } from "zod";
|
10
12
|
|
11
13
|
export type BuildContextLike = {
|
12
14
|
projectDirPath: string;
|
13
|
-
keycloakifyBuildDirPath: string;
|
14
|
-
bundler: BuildContext["bundler"];
|
15
|
-
projectBuildDirPath: string;
|
16
15
|
packageJsonFilePath: string;
|
17
16
|
};
|
18
17
|
|
@@ -23,58 +22,36 @@ export async function appBuild(params: {
|
|
23
22
|
}): Promise<{ isAppBuildSuccess: boolean }> {
|
24
23
|
const { buildContext } = params;
|
25
24
|
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
return appBuild_webpack({ buildContext });
|
31
|
-
}
|
32
|
-
}
|
33
|
-
|
34
|
-
async function appBuild_vite(params: {
|
35
|
-
buildContext: BuildContextLike;
|
36
|
-
}): Promise<{ isAppBuildSuccess: boolean }> {
|
37
|
-
const { buildContext } = params;
|
38
|
-
|
39
|
-
assert(buildContext.bundler === "vite");
|
25
|
+
const { parsedPackageJson } = (() => {
|
26
|
+
type ParsedPackageJson = {
|
27
|
+
scripts?: Record<string, string>;
|
28
|
+
};
|
40
29
|
|
41
|
-
|
30
|
+
const zParsedPackageJson = (() => {
|
31
|
+
type TargetType = ParsedPackageJson;
|
42
32
|
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
cwd: buildContext.projectDirPath,
|
47
|
-
shell: true
|
48
|
-
});
|
49
|
-
|
50
|
-
child.stdout.on("data", data => {
|
51
|
-
if (data.toString("utf8").includes("gzip:")) {
|
52
|
-
return;
|
53
|
-
}
|
54
|
-
|
55
|
-
process.stdout.write(data);
|
56
|
-
});
|
33
|
+
const zTargetType = z.object({
|
34
|
+
scripts: z.record(z.string()).optional()
|
35
|
+
});
|
57
36
|
|
58
|
-
|
37
|
+
assert<Equals<z.infer<typeof zTargetType>, TargetType>>();
|
59
38
|
|
60
|
-
|
39
|
+
return id<z.ZodType<TargetType>>(zTargetType);
|
40
|
+
})();
|
41
|
+
const parsedPackageJson = JSON.parse(
|
42
|
+
fs.readFileSync(buildContext.packageJsonFilePath).toString("utf8")
|
43
|
+
);
|
61
44
|
|
62
|
-
|
45
|
+
zParsedPackageJson.parse(parsedPackageJson);
|
63
46
|
|
64
|
-
|
65
|
-
}
|
47
|
+
assert(is<ParsedPackageJson>(parsedPackageJson));
|
66
48
|
|
67
|
-
|
68
|
-
|
69
|
-
}): Promise<{ isAppBuildSuccess: boolean }> {
|
70
|
-
const { buildContext } = params;
|
71
|
-
|
72
|
-
assert(buildContext.bundler === "webpack");
|
49
|
+
return { parsedPackageJson };
|
50
|
+
})();
|
73
51
|
|
74
|
-
const entries = Object.entries(
|
75
|
-
(
|
76
|
-
|
77
|
-
).filter(([, scriptCommand]) => scriptCommand.includes("keycloakify build"));
|
52
|
+
const entries = Object.entries(parsedPackageJson.scripts ?? {}).filter(
|
53
|
+
([, scriptCommand]) => scriptCommand.includes("keycloakify build")
|
54
|
+
);
|
78
55
|
|
79
56
|
if (entries.length === 0) {
|
80
57
|
console.log(
|
@@ -127,6 +104,76 @@ async function appBuild_webpack(params: {
|
|
127
104
|
process.exit(-1);
|
128
105
|
}
|
129
106
|
|
107
|
+
common_case: {
|
108
|
+
if (appBuildSubCommands.length !== 1) {
|
109
|
+
break common_case;
|
110
|
+
}
|
111
|
+
|
112
|
+
const [appBuildSubCommand] = appBuildSubCommands;
|
113
|
+
|
114
|
+
const isNpmRunBuild = (() => {
|
115
|
+
for (const packageManager of ["npm", "yarn", "pnpm", "bun", "deno"]) {
|
116
|
+
for (const doUseRun of [true, false]) {
|
117
|
+
if (
|
118
|
+
`${packageManager}${doUseRun ? " run " : " "}build` ===
|
119
|
+
appBuildSubCommand
|
120
|
+
) {
|
121
|
+
return true;
|
122
|
+
}
|
123
|
+
}
|
124
|
+
}
|
125
|
+
|
126
|
+
return false;
|
127
|
+
})();
|
128
|
+
|
129
|
+
if (!isNpmRunBuild) {
|
130
|
+
break common_case;
|
131
|
+
}
|
132
|
+
|
133
|
+
const { scripts } = parsedPackageJson;
|
134
|
+
|
135
|
+
assert(scripts !== undefined);
|
136
|
+
|
137
|
+
const buildCmd = scripts.build;
|
138
|
+
|
139
|
+
if (buildCmd !== "tsc && vite build") {
|
140
|
+
break common_case;
|
141
|
+
}
|
142
|
+
|
143
|
+
if (scripts.prebuild !== undefined) {
|
144
|
+
break common_case;
|
145
|
+
}
|
146
|
+
|
147
|
+
if (scripts.postbuild !== undefined) {
|
148
|
+
break common_case;
|
149
|
+
}
|
150
|
+
|
151
|
+
const dIsSuccess = new Deferred<boolean>();
|
152
|
+
|
153
|
+
console.log(chalk.blue("$ npx vite build"));
|
154
|
+
|
155
|
+
const child = child_process.spawn("npx", ["vite", "build"], {
|
156
|
+
cwd: buildContext.projectDirPath,
|
157
|
+
shell: true
|
158
|
+
});
|
159
|
+
|
160
|
+
child.stdout.on("data", data => {
|
161
|
+
if (data.toString("utf8").includes("gzip:")) {
|
162
|
+
return;
|
163
|
+
}
|
164
|
+
|
165
|
+
process.stdout.write(data);
|
166
|
+
});
|
167
|
+
|
168
|
+
child.stderr.on("data", data => process.stderr.write(data));
|
169
|
+
|
170
|
+
child.on("exit", code => dIsSuccess.resolve(code === 0));
|
171
|
+
|
172
|
+
const isSuccess = await dIsSuccess.pr;
|
173
|
+
|
174
|
+
return { isAppBuildSuccess: isSuccess };
|
175
|
+
}
|
176
|
+
|
130
177
|
let commandCwd = pathDirname(buildContext.packageJsonFilePath);
|
131
178
|
|
132
179
|
for (const subCommand of appBuildSubCommands) {
|