keycloakify 10.0.0-rc.5 → 10.0.0-rc.6
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/eject-keycloak-page.js +84 -19
- package/bin/eject-keycloak-page.js.map +1 -1
- package/bin/main.js +81 -20
- package/bin/main.js.map +1 -1
- package/package.json +7 -6
- package/src/bin/eject-keycloak-page.ts +63 -10
- package/src/bin/main.ts +59 -19
@@ -1,5 +1,28 @@
|
|
1
1
|
#!/usr/bin/env node
|
2
2
|
"use strict";
|
3
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
4
|
+
if (k2 === undefined) k2 = k;
|
5
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
6
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
7
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
8
|
+
}
|
9
|
+
Object.defineProperty(o, k2, desc);
|
10
|
+
}) : (function(o, m, k, k2) {
|
11
|
+
if (k2 === undefined) k2 = k;
|
12
|
+
o[k2] = m[k];
|
13
|
+
}));
|
14
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
15
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
16
|
+
}) : function(o, v) {
|
17
|
+
o["default"] = v;
|
18
|
+
});
|
19
|
+
var __importStar = (this && this.__importStar) || function (mod) {
|
20
|
+
if (mod && mod.__esModule) return mod;
|
21
|
+
var result = {};
|
22
|
+
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
23
|
+
__setModuleDefault(result, mod);
|
24
|
+
return result;
|
25
|
+
};
|
3
26
|
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
4
27
|
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
5
28
|
return new (P || (P = Promise))(function (resolve, reject) {
|
@@ -70,8 +93,7 @@ var getThisCodebaseRootDirPath_1 = require("./tools/getThisCodebaseRootDirPath")
|
|
70
93
|
var cli_select_1 = __importDefault(require("cli-select"));
|
71
94
|
var pageIds_1 = require("./shared/pageIds");
|
72
95
|
var capitalize_1 = require("tsafe/capitalize");
|
73
|
-
var
|
74
|
-
var fs_1 = require("fs");
|
96
|
+
var fs = __importStar(require("fs"));
|
75
97
|
var path_1 = require("path");
|
76
98
|
var kebabCaseToSnakeCase_1 = require("./tools/kebabCaseToSnakeCase");
|
77
99
|
var assert_1 = require("tsafe/assert");
|
@@ -80,15 +102,15 @@ var constants_1 = require("./shared/constants");
|
|
80
102
|
var buildOptions_1 = require("./shared/buildOptions");
|
81
103
|
function command(params) {
|
82
104
|
return __awaiter(this, void 0, void 0, function () {
|
83
|
-
var cliCommandOptions, buildOptions, themeType, pageId,
|
84
|
-
return __generator(this, function (
|
85
|
-
switch (
|
105
|
+
var cliCommandOptions, buildOptions, themeType, pageId, componentPageBasename, themeSrcDirPath, targetFilePath, targetDirPath, componentPageContent, userProfileFormFieldComponentName;
|
106
|
+
return __generator(this, function (_a) {
|
107
|
+
switch (_a.label) {
|
86
108
|
case 0:
|
87
109
|
cliCommandOptions = params.cliCommandOptions;
|
88
110
|
buildOptions = (0, buildOptions_1.readBuildOptions)({
|
89
111
|
cliCommandOptions: cliCommandOptions
|
90
112
|
});
|
91
|
-
console.log("
|
113
|
+
console.log("Theme type:");
|
92
114
|
return [4 /*yield*/, (0, cli_select_1.default)({
|
93
115
|
"values": __spreadArray([], __read(constants_1.themeTypes), false)
|
94
116
|
}).catch(function () {
|
@@ -96,8 +118,8 @@ function command(params) {
|
|
96
118
|
process.exit(-1);
|
97
119
|
})];
|
98
120
|
case 1:
|
99
|
-
themeType = (
|
100
|
-
console.log("Select
|
121
|
+
themeType = (_a.sent()).value;
|
122
|
+
console.log("Select the page you want to customize:");
|
101
123
|
return [4 /*yield*/, (0, cli_select_1.default)({
|
102
124
|
"values": (function () {
|
103
125
|
switch (themeType) {
|
@@ -113,21 +135,64 @@ function command(params) {
|
|
113
135
|
process.exit(-1);
|
114
136
|
})];
|
115
137
|
case 2:
|
116
|
-
pageId = (
|
117
|
-
|
138
|
+
pageId = (_a.sent()).value;
|
139
|
+
componentPageBasename = (0, capitalize_1.capitalize)((0, kebabCaseToSnakeCase_1.kebabCaseToCamelCase)(pageId)).replace(/ftl$/, "tsx");
|
118
140
|
themeSrcDirPath = (0, getThemeSrcDirPath_1.getThemeSrcDirPath)({ "reactAppRootDirPath": buildOptions.reactAppRootDirPath }).themeSrcDirPath;
|
119
|
-
targetFilePath = (0, path_1.join)(themeSrcDirPath, themeType, "pages",
|
120
|
-
if (
|
141
|
+
targetFilePath = (0, path_1.join)(themeSrcDirPath, themeType, "pages", componentPageBasename);
|
142
|
+
if (fs.existsSync(targetFilePath)) {
|
121
143
|
console.log("".concat(pageId, " is already ejected, ").concat((0, path_1.relative)(process.cwd(), targetFilePath), " already exists"));
|
122
144
|
process.exit(-1);
|
123
145
|
}
|
124
|
-
|
125
|
-
|
126
|
-
|
127
|
-
|
128
|
-
|
129
|
-
|
130
|
-
|
146
|
+
{
|
147
|
+
targetDirPath = (0, path_1.dirname)(targetFilePath);
|
148
|
+
if (!fs.existsSync(targetDirPath)) {
|
149
|
+
fs.mkdirSync(targetDirPath, { "recursive": true });
|
150
|
+
}
|
151
|
+
}
|
152
|
+
componentPageContent = fs
|
153
|
+
.readFileSync((0, path_1.join)((0, getThisCodebaseRootDirPath_1.getThisCodebaseRootDirPath)(), "src", themeType, "pages", componentPageBasename))
|
154
|
+
.toString("utf8");
|
155
|
+
fs.writeFileSync(targetFilePath, Buffer.from(componentPageContent, "utf8"));
|
156
|
+
userProfileFormFieldComponentName = "UserProfileFormFields";
|
157
|
+
console.log(__spreadArray(__spreadArray([
|
158
|
+
"",
|
159
|
+
"`".concat((0, path_1.join)(".", (0, path_1.relative)(process.cwd(), targetFilePath)), "` copy pasted from the Keycloakify source code into your project."),
|
160
|
+
"",
|
161
|
+
"You now need to update your page router:",
|
162
|
+
"",
|
163
|
+
"`".concat((0, path_1.join)(".", (0, path_1.relative)(process.cwd(), themeSrcDirPath), themeType, "KcApp.tsx"), "`:"),
|
164
|
+
"```",
|
165
|
+
"// ...",
|
166
|
+
"",
|
167
|
+
"+const ".concat(componentPageBasename.replace(/.tsx$/, ""), " = lazy(() => import(\"./pages/").concat(componentPageBasename, "\"));"),
|
168
|
+
"",
|
169
|
+
" export default function KcApp(props: { kcContext: KcContext; }) {",
|
170
|
+
"",
|
171
|
+
" // ...",
|
172
|
+
"",
|
173
|
+
" return (",
|
174
|
+
" <Suspense>",
|
175
|
+
" {(() => {",
|
176
|
+
" switch (kcContext.pageId) {",
|
177
|
+
" // ...",
|
178
|
+
" case \"".concat(pageId, "\": return ("),
|
179
|
+
"+ <Login",
|
180
|
+
"+ {...{ kcContext, i18n, classes }}",
|
181
|
+
"+ Template={Template}"
|
182
|
+
], __read((!componentPageContent.includes(userProfileFormFieldComponentName)
|
183
|
+
? []
|
184
|
+
: ["+ ".concat(userProfileFormFieldComponentName, "={").concat(userProfileFormFieldComponentName, "}")])), false), [
|
185
|
+
"+ doUseDefaultCss={true}",
|
186
|
+
"+ />",
|
187
|
+
"+ );",
|
188
|
+
" default: return <Fallback /* .. */ />;",
|
189
|
+
" }",
|
190
|
+
" })()}",
|
191
|
+
" </Suspense>",
|
192
|
+
" );",
|
193
|
+
" }",
|
194
|
+
"```"
|
195
|
+
], false).join("\n"));
|
131
196
|
return [2 /*return*/];
|
132
197
|
}
|
133
198
|
});
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"eject-keycloak-page.js","sourceRoot":"","sources":["../src/bin/eject-keycloak-page.ts"],"names":[],"mappings":"
|
1
|
+
{"version":3,"file":"eject-keycloak-page.js","sourceRoot":"","sources":["../src/bin/eject-keycloak-page.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;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K,IAAA,WAAQ,EAAC,GAAG,EAAE,IAAA,eAAY,EAAC,OAAO,CAAC,GAAG,EAAE,EAAE,cAAc,CAAC,CAAC,sEAAoE;wBACnI,EAAE;wBACF,0CAA0C;wBAC1C,EAAE;wBACF,WAAK,IAAA,WAAQ,EAAC,GAAG,EAAE,IAAA,eAAY,EAAC,OAAO,CAAC,GAAG,EAAE,EAAE,eAAe,CAAC,EAAE,SAAS,EAAE,WAAW,CAAC,OAAK;wBAC7F,KAAK;wBACL,QAAQ;wBACR,EAAE;wBACF,iBAAU,qBAAqB,CAAC,OAAO,CAAC,OAAO,EAAE,EAAE,CAAC,4CAAiC,qBAAqB,UAAM;wBAChH,EAAE;wBACF,oEAAoE;wBACpE,EAAE;wBACF,aAAa;wBACb,EAAE;wBACF,eAAe;wBACf,qBAAqB;wBACrB,wBAAwB;wBACxB,8CAA8C;wBAC9C,6BAA6B;wBAC7B,sCAA8B,MAAM,iBAAa;wBACjD,iCAAiC;wBACjC,gEAAgE;wBAChE,kDAAkD;8BAC/C,CAAC,CAAC,oBAAoB,CAAC,QAAQ,CAAC,iCAAiC,CAAC;wBACjE,CAAC,CAAC,EAAE;wBACJ,CAAC,CAAC,CAAC,uCAAgC,iCAAiC,eAAK,iCAAiC,MAAG,CAAC,CAAC;wBACnH,qDAAqD;wBACrD,6BAA6B;wBAC7B,yBAAyB;wBACzB,6DAA6D;wBAC7D,oBAAoB;wBACpB,oBAAoB;wBACpB,sBAAsB;wBACtB,SAAS;wBACT,IAAI;wBACJ,KAAK;8BACP,IAAI,CAAC,IAAI,CAAC,CACf,CAAC;;;;;CACL;AAxGD,0BAwGC"}
|
package/bin/main.js
CHANGED
@@ -88,25 +88,65 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
88
88
|
var termost_1 = require("termost");
|
89
89
|
var child_process = __importStar(require("child_process"));
|
90
90
|
var program = (0, termost_1.termost)("Keycloak theme builder");
|
91
|
+
var optionsKeys = [];
|
91
92
|
program
|
92
93
|
.option({
|
93
94
|
"key": "reactAppRootDirPath",
|
94
|
-
"name":
|
95
|
+
"name": (function () {
|
96
|
+
var long = "project";
|
97
|
+
var short = "p";
|
98
|
+
optionsKeys.push(long, short);
|
99
|
+
return { long: long, short: short };
|
100
|
+
})(),
|
95
101
|
"description": "https://docs.keycloakify.dev/build-options#project-or-p-cli-option",
|
96
102
|
"defaultValue": undefined
|
97
103
|
})
|
98
104
|
.option({
|
99
105
|
"key": "isSilent",
|
100
|
-
"name":
|
106
|
+
"name": (function () {
|
107
|
+
var name = "silent";
|
108
|
+
optionsKeys.push(name);
|
109
|
+
return name;
|
110
|
+
})(),
|
101
111
|
"description": "https://docs.keycloakify.dev/build-options#silent",
|
102
112
|
"defaultValue": false
|
103
113
|
});
|
114
|
+
function skip(_context, argv) {
|
115
|
+
var unrecognizedOptionKey = Object.keys(argv.options).find(function (key) { return !optionsKeys.includes(key); });
|
116
|
+
if (unrecognizedOptionKey !== undefined) {
|
117
|
+
console.error("keycloakify: Unrecognized option: ".concat(unrecognizedOptionKey.length === 1 ? "-" : "--").concat(unrecognizedOptionKey));
|
118
|
+
process.exit(1);
|
119
|
+
}
|
120
|
+
return false;
|
121
|
+
}
|
122
|
+
function runAndLogErrors(fn) {
|
123
|
+
return __awaiter(this, void 0, void 0, function () {
|
124
|
+
var error_1;
|
125
|
+
return __generator(this, function (_a) {
|
126
|
+
switch (_a.label) {
|
127
|
+
case 0:
|
128
|
+
_a.trys.push([0, 2, , 3]);
|
129
|
+
return [4 /*yield*/, fn()];
|
130
|
+
case 1:
|
131
|
+
_a.sent();
|
132
|
+
return [3 /*break*/, 3];
|
133
|
+
case 2:
|
134
|
+
error_1 = _a.sent();
|
135
|
+
console.error(error_1);
|
136
|
+
process.exit(1);
|
137
|
+
return [3 /*break*/, 3];
|
138
|
+
case 3: return [2 /*return*/];
|
139
|
+
}
|
140
|
+
});
|
141
|
+
});
|
142
|
+
}
|
104
143
|
program
|
105
144
|
.command({
|
106
145
|
"name": "build",
|
107
146
|
"description": "Build the theme (default subcommand)."
|
108
147
|
})
|
109
148
|
.task({
|
149
|
+
skip: skip,
|
110
150
|
"handler": function (cliCommandOptions) { return __awaiter(void 0, void 0, void 0, function () {
|
111
151
|
var command;
|
112
152
|
return __generator(this, function (_a) {
|
@@ -114,7 +154,10 @@ program
|
|
114
154
|
case 0: return [4 /*yield*/, Promise.resolve().then(function () { return __importStar(require("./keycloakify")); })];
|
115
155
|
case 1:
|
116
156
|
command = (_a.sent()).command;
|
117
|
-
return [
|
157
|
+
return [4 /*yield*/, runAndLogErrors(function () { return command({ cliCommandOptions: cliCommandOptions }); })];
|
158
|
+
case 2:
|
159
|
+
_a.sent();
|
160
|
+
return [2 /*return*/];
|
118
161
|
}
|
119
162
|
});
|
120
163
|
}); }
|
@@ -125,6 +168,7 @@ program
|
|
125
168
|
"description": "Download the built-in Keycloak theme."
|
126
169
|
})
|
127
170
|
.task({
|
171
|
+
skip: skip,
|
128
172
|
"handler": function (cliCommandOptions) { return __awaiter(void 0, void 0, void 0, function () {
|
129
173
|
var command;
|
130
174
|
return __generator(this, function (_a) {
|
@@ -132,7 +176,10 @@ program
|
|
132
176
|
case 0: return [4 /*yield*/, Promise.resolve().then(function () { return __importStar(require("./download-builtin-keycloak-theme")); })];
|
133
177
|
case 1:
|
134
178
|
command = (_a.sent()).command;
|
135
|
-
return [
|
179
|
+
return [4 /*yield*/, runAndLogErrors(function () { return command({ cliCommandOptions: cliCommandOptions }); })];
|
180
|
+
case 2:
|
181
|
+
_a.sent();
|
182
|
+
return [2 /*return*/];
|
136
183
|
}
|
137
184
|
});
|
138
185
|
}); }
|
@@ -143,6 +190,7 @@ program
|
|
143
190
|
"description": "Eject a Keycloak page."
|
144
191
|
})
|
145
192
|
.task({
|
193
|
+
skip: skip,
|
146
194
|
"handler": function (cliCommandOptions) { return __awaiter(void 0, void 0, void 0, function () {
|
147
195
|
var command;
|
148
196
|
return __generator(this, function (_a) {
|
@@ -150,7 +198,10 @@ program
|
|
150
198
|
case 0: return [4 /*yield*/, Promise.resolve().then(function () { return __importStar(require("./eject-keycloak-page")); })];
|
151
199
|
case 1:
|
152
200
|
command = (_a.sent()).command;
|
153
|
-
return [
|
201
|
+
return [4 /*yield*/, runAndLogErrors(function () { return command({ cliCommandOptions: cliCommandOptions }); })];
|
202
|
+
case 2:
|
203
|
+
_a.sent();
|
204
|
+
return [2 /*return*/];
|
154
205
|
}
|
155
206
|
});
|
156
207
|
}); }
|
@@ -161,6 +212,7 @@ program
|
|
161
212
|
"description": "Initialize an email theme."
|
162
213
|
})
|
163
214
|
.task({
|
215
|
+
skip: skip,
|
164
216
|
"handler": function (cliCommandOptions) { return __awaiter(void 0, void 0, void 0, function () {
|
165
217
|
var command;
|
166
218
|
return __generator(this, function (_a) {
|
@@ -168,46 +220,54 @@ program
|
|
168
220
|
case 0: return [4 /*yield*/, Promise.resolve().then(function () { return __importStar(require("./initialize-email-theme")); })];
|
169
221
|
case 1:
|
170
222
|
command = (_a.sent()).command;
|
171
|
-
return [
|
223
|
+
return [4 /*yield*/, runAndLogErrors(function () { return command({ cliCommandOptions: cliCommandOptions }); })];
|
224
|
+
case 2:
|
225
|
+
_a.sent();
|
226
|
+
return [2 /*return*/];
|
172
227
|
}
|
173
228
|
});
|
174
229
|
}); }
|
175
230
|
});
|
176
231
|
program
|
177
232
|
.command({
|
178
|
-
"name": "
|
179
|
-
"description":
|
180
|
-
"Copy Keycloak default theme resources to the public directory.",
|
181
|
-
"This command is meant to be explicitly used in Webpack projects only."
|
182
|
-
].join(" ")
|
233
|
+
"name": "start-keycloak-container",
|
234
|
+
"description": "Spin up a Keycloak container with the theme preloaded and the realm pre configured."
|
183
235
|
})
|
184
236
|
.task({
|
237
|
+
skip: skip,
|
185
238
|
"handler": function (cliCommandOptions) { return __awaiter(void 0, void 0, void 0, function () {
|
186
239
|
var command;
|
187
240
|
return __generator(this, function (_a) {
|
188
241
|
switch (_a.label) {
|
189
|
-
case 0: return [4 /*yield*/, Promise.resolve().then(function () { return __importStar(require("./
|
242
|
+
case 0: return [4 /*yield*/, Promise.resolve().then(function () { return __importStar(require("./start-keycloak-container")); })];
|
190
243
|
case 1:
|
191
244
|
command = (_a.sent()).command;
|
192
|
-
return [
|
245
|
+
return [4 /*yield*/, runAndLogErrors(function () { return command({ cliCommandOptions: cliCommandOptions }); })];
|
246
|
+
case 2:
|
247
|
+
_a.sent();
|
248
|
+
return [2 /*return*/];
|
193
249
|
}
|
194
250
|
});
|
195
251
|
}); }
|
196
252
|
});
|
197
253
|
program
|
198
254
|
.command({
|
199
|
-
"name": "
|
200
|
-
"description": "
|
255
|
+
"name": "copy-keycloak-resources-to-public",
|
256
|
+
"description": "(Webpack/Create-React-App only) Copy Keycloak default theme resources to the public directory."
|
201
257
|
})
|
202
258
|
.task({
|
259
|
+
skip: skip,
|
203
260
|
"handler": function (cliCommandOptions) { return __awaiter(void 0, void 0, void 0, function () {
|
204
261
|
var command;
|
205
262
|
return __generator(this, function (_a) {
|
206
263
|
switch (_a.label) {
|
207
|
-
case 0: return [4 /*yield*/, Promise.resolve().then(function () { return __importStar(require("./
|
264
|
+
case 0: return [4 /*yield*/, Promise.resolve().then(function () { return __importStar(require("./copy-keycloak-resources-to-public")); })];
|
208
265
|
case 1:
|
209
266
|
command = (_a.sent()).command;
|
210
|
-
return [
|
267
|
+
return [4 /*yield*/, runAndLogErrors(function () { return command({ cliCommandOptions: cliCommandOptions }); })];
|
268
|
+
case 2:
|
269
|
+
_a.sent();
|
270
|
+
return [2 /*return*/];
|
211
271
|
}
|
212
272
|
});
|
213
273
|
}); }
|
@@ -215,10 +275,11 @@ program
|
|
215
275
|
// Fallback to build command if no command is provided
|
216
276
|
{
|
217
277
|
var _a = __read(process.argv), rest = _a.slice(2);
|
218
|
-
if (rest.length === 0 ||
|
219
|
-
child_process.spawnSync("npx", __spreadArray(["keycloakify", "build"], __read(rest), false), {
|
278
|
+
if (rest.length === 0 || (rest[0].startsWith("-") && rest[0] !== "--help" && rest[0] !== "-h")) {
|
279
|
+
var status_1 = child_process.spawnSync("npx", __spreadArray(["keycloakify", "build"], __read(rest), false), {
|
220
280
|
"stdio": "inherit"
|
221
|
-
});
|
281
|
+
}).status;
|
282
|
+
process.exit(status_1 !== null && status_1 !== void 0 ? status_1 : 1);
|
222
283
|
}
|
223
284
|
}
|
224
285
|
//# sourceMappingURL=main.js.map
|
package/bin/main.js.map
CHANGED
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"main.js","sourceRoot":"","sources":["../src/bin/main.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAEA,mCAAkC;AAClC,2DAA+C;AAO/C,IAAM,OAAO,GAAG,IAAA,iBAAO,EAAoB,wBAAwB,CAAC,CAAC;AAErE,OAAO;KACF,MAAM,CAAC;IACJ,KAAK,EAAE,qBAAqB;IAC5B,MAAM,EAAE,
|
1
|
+
{"version":3,"file":"main.js","sourceRoot":"","sources":["../src/bin/main.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAEA,mCAAkC;AAClC,2DAA+C;AAO/C,IAAM,OAAO,GAAG,IAAA,iBAAO,EAAoB,wBAAwB,CAAC,CAAC;AAErE,IAAM,WAAW,GAAa,EAAE,CAAC;AAEjC,OAAO;KACF,MAAM,CAAC;IACJ,KAAK,EAAE,qBAAqB;IAC5B,MAAM,EAAE,CAAC;QACL,IAAM,IAAI,GAAG,SAAS,CAAC;QACvB,IAAM,KAAK,GAAG,GAAG,CAAC;QAElB,WAAW,CAAC,IAAI,CAAC,IAAI,EAAE,KAAK,CAAC,CAAC;QAE9B,OAAO,EAAE,IAAI,MAAA,EAAE,KAAK,OAAA,EAAE,CAAC;IAC3B,CAAC,CAAC,EAAE;IACJ,aAAa,EAAE,oEAAoE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AAC,CAAC,CAAC,KAAK,IAAI,CAAC,EAAE,CAAC;QACrF,IAAA,QAAM,GAAK,aAAa,CAAC,SAAS,CAAC,KAAK,iBAAG,aAAa,EAAE,OAAO,UAAK,IAAI,WAAG;YACjF,OAAO,EAAE,SAAS;SACrB,CAAC,OAFY,CAEX;QAEH,OAAO,CAAC,IAAI,CAAC,QAAM,aAAN,QAAM,cAAN,QAAM,GAAI,CAAC,CAAC,CAAC;IAC9B,CAAC;AACL,CAAC"}
|
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "keycloakify",
|
3
|
-
"version": "10.0.0-rc.
|
3
|
+
"version": "10.0.0-rc.6",
|
4
4
|
"description": "Create Keycloak themes using React",
|
5
5
|
"repository": {
|
6
6
|
"type": "git",
|
@@ -1179,6 +1179,7 @@
|
|
1179
1179
|
"@types/react-dom": "^18.0.11",
|
1180
1180
|
"@types/yauzl": "^2.10.0",
|
1181
1181
|
"@types/yazl": "^2.4.2",
|
1182
|
+
"chokidar-cli": "^3.0.0",
|
1182
1183
|
"concurrently": "^8.0.1",
|
1183
1184
|
"copyfiles": "^2.4.1",
|
1184
1185
|
"eslint-plugin-storybook": "^0.6.7",
|
@@ -1195,9 +1196,9 @@
|
|
1195
1196
|
"tsc-alias": "^1.8.3",
|
1196
1197
|
"tss-react": "^4.8.2",
|
1197
1198
|
"typescript": "^5.4.5",
|
1199
|
+
"vite": "^5.0.12",
|
1198
1200
|
"vitest": "^0.29.8",
|
1199
|
-
"zod-to-json-schema": "^3.20.4"
|
1200
|
-
"vite": "^5.0.12"
|
1201
|
+
"zod-to-json-schema": "^3.20.4"
|
1201
1202
|
},
|
1202
1203
|
"dependencies": {
|
1203
1204
|
"@babel/generator": "^7.22.9",
|
@@ -1207,17 +1208,17 @@
|
|
1207
1208
|
"cheerio": "^1.0.0-rc.5",
|
1208
1209
|
"cli-select": "^1.1.2",
|
1209
1210
|
"evt": "^2.5.7",
|
1211
|
+
"magic-string": "^0.30.7",
|
1210
1212
|
"make-fetch-happen": "^11.0.3",
|
1211
1213
|
"minimal-polyfills": "^2.2.2",
|
1212
1214
|
"minimist": "^1.2.6",
|
1213
1215
|
"react-markdown": "^5.0.3",
|
1214
1216
|
"recast": "^0.23.3",
|
1215
1217
|
"rfc4648": "^1.5.2",
|
1218
|
+
"termost": "^0.12.0",
|
1216
1219
|
"tsafe": "^1.6.0",
|
1217
1220
|
"yauzl": "^2.10.0",
|
1218
1221
|
"yazl": "^2.5.1",
|
1219
|
-
"zod": "^3.17.10"
|
1220
|
-
"magic-string": "^0.30.7",
|
1221
|
-
"termost": "^0.12.0"
|
1222
|
+
"zod": "^3.17.10"
|
1222
1223
|
}
|
1223
1224
|
}
|
@@ -4,9 +4,8 @@ import { getThisCodebaseRootDirPath } from "./tools/getThisCodebaseRootDirPath";
|
|
4
4
|
import cliSelect from "cli-select";
|
5
5
|
import { loginThemePageIds, accountThemePageIds, type LoginThemePageId, type AccountThemePageId } from "./shared/pageIds";
|
6
6
|
import { capitalize } from "tsafe/capitalize";
|
7
|
-
import
|
8
|
-
import {
|
9
|
-
import { join as pathJoin, relative as pathRelative } from "path";
|
7
|
+
import * as fs from "fs";
|
8
|
+
import { join as pathJoin, relative as pathRelative, dirname as pathDirname } from "path";
|
10
9
|
import { kebabCaseToCamelCase } from "./tools/kebabCaseToSnakeCase";
|
11
10
|
import { assert, Equals } from "tsafe/assert";
|
12
11
|
import { getThemeSrcDirPath } from "./shared/getThemeSrcDirPath";
|
@@ -21,7 +20,7 @@ export async function command(params: { cliCommandOptions: CliCommandOptions })
|
|
21
20
|
cliCommandOptions
|
22
21
|
});
|
23
22
|
|
24
|
-
console.log("
|
23
|
+
console.log("Theme type:");
|
25
24
|
|
26
25
|
const { value: themeType } = await cliSelect<ThemeType>({
|
27
26
|
"values": [...themeTypes]
|
@@ -31,7 +30,7 @@ export async function command(params: { cliCommandOptions: CliCommandOptions })
|
|
31
30
|
process.exit(-1);
|
32
31
|
});
|
33
32
|
|
34
|
-
console.log("Select
|
33
|
+
console.log("Select the page you want to customize:");
|
35
34
|
|
36
35
|
const { value: pageId } = await cliSelect<LoginThemePageId | AccountThemePageId>({
|
37
36
|
"values": (() => {
|
@@ -49,19 +48,73 @@ export async function command(params: { cliCommandOptions: CliCommandOptions })
|
|
49
48
|
process.exit(-1);
|
50
49
|
});
|
51
50
|
|
52
|
-
const
|
51
|
+
const componentPageBasename = capitalize(kebabCaseToCamelCase(pageId)).replace(/ftl$/, "tsx");
|
53
52
|
|
54
53
|
const { themeSrcDirPath } = getThemeSrcDirPath({ "reactAppRootDirPath": buildOptions.reactAppRootDirPath });
|
55
54
|
|
56
|
-
const targetFilePath = pathJoin(themeSrcDirPath, themeType, "pages",
|
55
|
+
const targetFilePath = pathJoin(themeSrcDirPath, themeType, "pages", componentPageBasename);
|
57
56
|
|
58
|
-
if (existsSync(targetFilePath)) {
|
57
|
+
if (fs.existsSync(targetFilePath)) {
|
59
58
|
console.log(`${pageId} is already ejected, ${pathRelative(process.cwd(), targetFilePath)} already exists`);
|
60
59
|
|
61
60
|
process.exit(-1);
|
62
61
|
}
|
63
62
|
|
64
|
-
|
63
|
+
{
|
64
|
+
const targetDirPath = pathDirname(targetFilePath);
|
65
65
|
|
66
|
-
|
66
|
+
if (!fs.existsSync(targetDirPath)) {
|
67
|
+
fs.mkdirSync(targetDirPath, { "recursive": true });
|
68
|
+
}
|
69
|
+
}
|
70
|
+
|
71
|
+
const componentPageContent = fs
|
72
|
+
.readFileSync(pathJoin(getThisCodebaseRootDirPath(), "src", themeType, "pages", componentPageBasename))
|
73
|
+
.toString("utf8");
|
74
|
+
|
75
|
+
fs.writeFileSync(targetFilePath, Buffer.from(componentPageContent, "utf8"));
|
76
|
+
|
77
|
+
const userProfileFormFieldComponentName = "UserProfileFormFields";
|
78
|
+
|
79
|
+
console.log(
|
80
|
+
[
|
81
|
+
``,
|
82
|
+
`\`${pathJoin(".", pathRelative(process.cwd(), targetFilePath))}\` copy pasted from the Keycloakify source code into your project.`,
|
83
|
+
``,
|
84
|
+
`You now need to update your page router:`,
|
85
|
+
``,
|
86
|
+
`\`${pathJoin(".", pathRelative(process.cwd(), themeSrcDirPath), themeType, "KcApp.tsx")}\`:`,
|
87
|
+
"```",
|
88
|
+
`// ...`,
|
89
|
+
``,
|
90
|
+
`+const ${componentPageBasename.replace(/.tsx$/, "")} = lazy(() => import("./pages/${componentPageBasename}"));`,
|
91
|
+
``,
|
92
|
+
` export default function KcApp(props: { kcContext: KcContext; }) {`,
|
93
|
+
``,
|
94
|
+
` // ...`,
|
95
|
+
``,
|
96
|
+
` return (`,
|
97
|
+
` <Suspense>`,
|
98
|
+
` {(() => {`,
|
99
|
+
` switch (kcContext.pageId) {`,
|
100
|
+
` // ...`,
|
101
|
+
` case "${pageId}": return (`,
|
102
|
+
`+ <Login`,
|
103
|
+
`+ {...{ kcContext, i18n, classes }}`,
|
104
|
+
`+ Template={Template}`,
|
105
|
+
...(!componentPageContent.includes(userProfileFormFieldComponentName)
|
106
|
+
? []
|
107
|
+
: [`+ ${userProfileFormFieldComponentName}={${userProfileFormFieldComponentName}}`]),
|
108
|
+
`+ doUseDefaultCss={true}`,
|
109
|
+
`+ />`,
|
110
|
+
`+ );`,
|
111
|
+
` default: return <Fallback /* .. */ />;`,
|
112
|
+
` }`,
|
113
|
+
` })()}`,
|
114
|
+
` </Suspense>`,
|
115
|
+
` );`,
|
116
|
+
` }`,
|
117
|
+
"```"
|
118
|
+
].join("\n")
|
119
|
+
);
|
67
120
|
}
|
package/src/bin/main.ts
CHANGED
@@ -10,29 +10,65 @@ export type CliCommandOptions = {
|
|
10
10
|
|
11
11
|
const program = termost<CliCommandOptions>("Keycloak theme builder");
|
12
12
|
|
13
|
+
const optionsKeys: string[] = [];
|
14
|
+
|
13
15
|
program
|
14
16
|
.option({
|
15
17
|
"key": "reactAppRootDirPath",
|
16
|
-
"name":
|
18
|
+
"name": (() => {
|
19
|
+
const long = "project";
|
20
|
+
const short = "p";
|
21
|
+
|
22
|
+
optionsKeys.push(long, short);
|
23
|
+
|
24
|
+
return { long, short };
|
25
|
+
})(),
|
17
26
|
"description": "https://docs.keycloakify.dev/build-options#project-or-p-cli-option",
|
18
27
|
"defaultValue": undefined
|
19
28
|
})
|
20
29
|
.option({
|
21
30
|
"key": "isSilent",
|
22
|
-
"name":
|
31
|
+
"name": (() => {
|
32
|
+
const name = "silent";
|
33
|
+
|
34
|
+
optionsKeys.push(name);
|
35
|
+
|
36
|
+
return name;
|
37
|
+
})(),
|
23
38
|
"description": "https://docs.keycloakify.dev/build-options#silent",
|
24
39
|
"defaultValue": false
|
25
40
|
});
|
26
41
|
|
42
|
+
function skip(_context: any, argv: { options: Record<string, unknown> }) {
|
43
|
+
const unrecognizedOptionKey = Object.keys(argv.options).find(key => !optionsKeys.includes(key));
|
44
|
+
|
45
|
+
if (unrecognizedOptionKey !== undefined) {
|
46
|
+
console.error(`keycloakify: Unrecognized option: ${unrecognizedOptionKey.length === 1 ? "-" : "--"}${unrecognizedOptionKey}`);
|
47
|
+
process.exit(1);
|
48
|
+
}
|
49
|
+
|
50
|
+
return false;
|
51
|
+
}
|
52
|
+
|
53
|
+
async function runAndLogErrors(fn: () => Promise<void>) {
|
54
|
+
try {
|
55
|
+
await fn();
|
56
|
+
} catch (error) {
|
57
|
+
console.error(error);
|
58
|
+
process.exit(1);
|
59
|
+
}
|
60
|
+
}
|
61
|
+
|
27
62
|
program
|
28
63
|
.command({
|
29
64
|
"name": "build",
|
30
65
|
"description": "Build the theme (default subcommand)."
|
31
66
|
})
|
32
67
|
.task({
|
68
|
+
skip,
|
33
69
|
"handler": async cliCommandOptions => {
|
34
70
|
const { command } = await import("./keycloakify");
|
35
|
-
|
71
|
+
await runAndLogErrors(() => command({ cliCommandOptions }));
|
36
72
|
}
|
37
73
|
});
|
38
74
|
|
@@ -42,9 +78,10 @@ program
|
|
42
78
|
"description": "Download the built-in Keycloak theme."
|
43
79
|
})
|
44
80
|
.task({
|
81
|
+
skip,
|
45
82
|
"handler": async cliCommandOptions => {
|
46
83
|
const { command } = await import("./download-builtin-keycloak-theme");
|
47
|
-
|
84
|
+
await runAndLogErrors(() => command({ cliCommandOptions }));
|
48
85
|
}
|
49
86
|
});
|
50
87
|
|
@@ -54,9 +91,10 @@ program
|
|
54
91
|
"description": "Eject a Keycloak page."
|
55
92
|
})
|
56
93
|
.task({
|
94
|
+
skip,
|
57
95
|
"handler": async cliCommandOptions => {
|
58
96
|
const { command } = await import("./eject-keycloak-page");
|
59
|
-
|
97
|
+
await runAndLogErrors(() => command({ cliCommandOptions }));
|
60
98
|
}
|
61
99
|
});
|
62
100
|
|
@@ -66,36 +104,36 @@ program
|
|
66
104
|
"description": "Initialize an email theme."
|
67
105
|
})
|
68
106
|
.task({
|
107
|
+
skip,
|
69
108
|
"handler": async cliCommandOptions => {
|
70
109
|
const { command } = await import("./initialize-email-theme");
|
71
|
-
|
110
|
+
await runAndLogErrors(() => command({ cliCommandOptions }));
|
72
111
|
}
|
73
112
|
});
|
74
113
|
|
75
114
|
program
|
76
115
|
.command({
|
77
|
-
"name": "
|
78
|
-
"description":
|
79
|
-
"Copy Keycloak default theme resources to the public directory.",
|
80
|
-
"This command is meant to be explicitly used in Webpack projects only."
|
81
|
-
].join(" ")
|
116
|
+
"name": "start-keycloak-container",
|
117
|
+
"description": "Spin up a Keycloak container with the theme preloaded and the realm pre configured."
|
82
118
|
})
|
83
119
|
.task({
|
120
|
+
skip,
|
84
121
|
"handler": async cliCommandOptions => {
|
85
|
-
const { command } = await import("./
|
86
|
-
|
122
|
+
const { command } = await import("./start-keycloak-container");
|
123
|
+
await runAndLogErrors(() => command({ cliCommandOptions }));
|
87
124
|
}
|
88
125
|
});
|
89
126
|
|
90
127
|
program
|
91
128
|
.command({
|
92
|
-
"name": "
|
93
|
-
"description": "
|
129
|
+
"name": "copy-keycloak-resources-to-public",
|
130
|
+
"description": "(Webpack/Create-React-App only) Copy Keycloak default theme resources to the public directory."
|
94
131
|
})
|
95
132
|
.task({
|
133
|
+
skip,
|
96
134
|
"handler": async cliCommandOptions => {
|
97
|
-
const { command } = await import("./
|
98
|
-
|
135
|
+
const { command } = await import("./copy-keycloak-resources-to-public");
|
136
|
+
await runAndLogErrors(() => command({ cliCommandOptions }));
|
99
137
|
}
|
100
138
|
});
|
101
139
|
|
@@ -103,9 +141,11 @@ program
|
|
103
141
|
{
|
104
142
|
const [, , ...rest] = process.argv;
|
105
143
|
|
106
|
-
if (rest.length === 0 ||
|
107
|
-
child_process.spawnSync("npx", ["keycloakify", "build", ...rest], {
|
144
|
+
if (rest.length === 0 || (rest[0].startsWith("-") && rest[0] !== "--help" && rest[0] !== "-h")) {
|
145
|
+
const { status } = child_process.spawnSync("npx", ["keycloakify", "build", ...rest], {
|
108
146
|
"stdio": "inherit"
|
109
147
|
});
|
148
|
+
|
149
|
+
process.exit(status ?? 1);
|
110
150
|
}
|
111
151
|
}
|