keycloakify 11.7.4 → 11.8.0
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/{911.index.js → 297.index.js} +18918 -11359
- package/bin/355.index.js +41 -703
- package/bin/363.index.js +3 -0
- package/bin/369.index.js +968 -0
- package/bin/656.index.js +111 -0
- package/bin/{288.index.js → 664.index.js} +13 -119
- package/bin/780.index.js +9 -7
- package/bin/880.index.js +215 -160
- package/bin/932.index.js +965 -0
- package/bin/97.index.js +2092 -770
- package/bin/main.js +52 -24
- package/bin/shared/buildContext.d.ts +11 -3
- package/package.json +10 -13
- package/src/bin/initialize-account-theme/initialize-account-theme.ts +29 -27
- package/src/bin/initialize-email-theme.ts +103 -53
- package/src/bin/keycloakify/generateResources/generateResources.ts +285 -205
- package/src/bin/shared/{initializeSpa/addSyncExtensionsToPostinstallScript.ts → addSyncExtensionsToPostinstallScript.ts} +1 -1
- package/src/bin/shared/buildContext.ts +69 -24
- package/src/bin/shared/{initializeSpa/initializeSpa.ts → initializeSpa.ts} +3 -3
- package/src/bin/sync-extensions/getExtensionModuleFileSourceCodeReadyToBeCopied.ts +6 -0
- package/vite-plugin/index.js +48 -20
- package/bin/313.index.js +0 -377
- package/bin/678.index.js +0 -7565
- package/bin/9.index.js +0 -850
- package/bin/947.index.js +0 -1565
- package/bin/shared/initializeSpa/index.d.ts +0 -1
- package/src/bin/shared/initializeSpa/index.ts +0 -1
- /package/bin/shared/{initializeSpa/addSyncExtensionsToPostinstallScript.d.ts → addSyncExtensionsToPostinstallScript.d.ts} +0 -0
- /package/bin/shared/{initializeSpa/initializeSpa.d.ts → initializeSpa.d.ts} +0 -0
package/bin/97.index.js
CHANGED
@@ -3,30 +3,162 @@ exports.id = 97;
|
|
3
3
|
exports.ids = [97];
|
4
4
|
exports.modules = {
|
5
5
|
|
6
|
-
/***/
|
6
|
+
/***/ 64097:
|
7
7
|
/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
|
8
8
|
|
9
|
+
// ESM COMPAT FLAG
|
9
10
|
__webpack_require__.r(__webpack_exports__);
|
10
|
-
/* harmony export */ __webpack_require__.d(__webpack_exports__, {
|
11
|
-
/* harmony export */ "command": () => (/* binding */ command)
|
12
|
-
/* harmony export */ });
|
13
|
-
/* harmony import */ var _tools_getThisCodebaseRootDirPath__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(58822);
|
14
|
-
/* harmony import */ var cli_select__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(99398);
|
15
|
-
/* harmony import */ var cli_select__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(cli_select__WEBPACK_IMPORTED_MODULE_1__);
|
16
|
-
/* harmony import */ var _shared_constants__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(173);
|
17
|
-
/* harmony import */ var tsafe_capitalize__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(14899);
|
18
|
-
/* harmony import */ var fs__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(57147);
|
19
|
-
/* harmony import */ var fs__WEBPACK_IMPORTED_MODULE_3___default = /*#__PURE__*/__webpack_require__.n(fs__WEBPACK_IMPORTED_MODULE_3__);
|
20
|
-
/* harmony import */ var path__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(71017);
|
21
|
-
/* harmony import */ var path__WEBPACK_IMPORTED_MODULE_4___default = /*#__PURE__*/__webpack_require__.n(path__WEBPACK_IMPORTED_MODULE_4__);
|
22
|
-
/* harmony import */ var _tools_kebabCaseToSnakeCase__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(17192);
|
23
|
-
/* harmony import */ var tsafe_assert__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(29041);
|
24
|
-
/* harmony import */ var chalk__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(78818);
|
25
|
-
/* harmony import */ var chalk__WEBPACK_IMPORTED_MODULE_6___default = /*#__PURE__*/__webpack_require__.n(chalk__WEBPACK_IMPORTED_MODULE_6__);
|
26
|
-
/* harmony import */ var _tools_runPrettier__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(48433);
|
27
|
-
/* harmony import */ var _shared_customHandler_delegate__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(72138);
|
28
11
|
|
12
|
+
// EXPORTS
|
13
|
+
__webpack_require__.d(__webpack_exports__, {
|
14
|
+
"command": () => (/* reexport */ command)
|
15
|
+
});
|
29
16
|
|
17
|
+
// EXTERNAL MODULE: ./node_modules/tsafe/esm/exclude.mjs
|
18
|
+
var exclude = __webpack_require__(83101);
|
19
|
+
// EXTERNAL MODULE: ./dist/bin/shared/constants.js
|
20
|
+
var constants = __webpack_require__(173);
|
21
|
+
// EXTERNAL MODULE: ./dist/bin/tools/SemVer.js
|
22
|
+
var SemVer = __webpack_require__(12171);
|
23
|
+
// EXTERNAL MODULE: ./node_modules/tsafe/esm/assert.mjs + 1 modules
|
24
|
+
var assert = __webpack_require__(29041);
|
25
|
+
// EXTERNAL MODULE: external "fs"
|
26
|
+
var external_fs_ = __webpack_require__(57147);
|
27
|
+
var external_fs_default = /*#__PURE__*/__webpack_require__.n(external_fs_);
|
28
|
+
// EXTERNAL MODULE: external "path"
|
29
|
+
var external_path_ = __webpack_require__(71017);
|
30
|
+
// EXTERNAL MODULE: external "child_process"
|
31
|
+
var external_child_process_ = __webpack_require__(32081);
|
32
|
+
var external_child_process_default = /*#__PURE__*/__webpack_require__.n(external_child_process_);
|
33
|
+
// EXTERNAL MODULE: ./node_modules/chalk/source/index.js
|
34
|
+
var source = __webpack_require__(78818);
|
35
|
+
var source_default = /*#__PURE__*/__webpack_require__.n(source);
|
36
|
+
// EXTERNAL MODULE: ./node_modules/chokidar/index.js
|
37
|
+
var chokidar = __webpack_require__(42677);
|
38
|
+
// EXTERNAL MODULE: ./node_modules/powerhooks/tools/waitForDebounce.js
|
39
|
+
var tools_waitForDebounce = __webpack_require__(18721);
|
40
|
+
// EXTERNAL MODULE: ./dist/bin/tools/getThisCodebaseRootDirPath.js
|
41
|
+
var getThisCodebaseRootDirPath = __webpack_require__(58822);
|
42
|
+
// EXTERNAL MODULE: ./dist/bin/tools/getAbsoluteAndInOsFormatPath.js
|
43
|
+
var getAbsoluteAndInOsFormatPath = __webpack_require__(84794);
|
44
|
+
// EXTERNAL MODULE: ./node_modules/cli-select/dist/index.js
|
45
|
+
var dist = __webpack_require__(99398);
|
46
|
+
var dist_default = /*#__PURE__*/__webpack_require__.n(dist);
|
47
|
+
// EXTERNAL MODULE: ./node_modules/run-exclusive/lib/runExclusive.js
|
48
|
+
var runExclusive = __webpack_require__(81708);
|
49
|
+
// EXTERNAL MODULE: external "fs/promises"
|
50
|
+
var promises_ = __webpack_require__(73292);
|
51
|
+
var promises_default = /*#__PURE__*/__webpack_require__.n(promises_);
|
52
|
+
// EXTERNAL MODULE: ./node_modules/yauzl/index.js
|
53
|
+
var yauzl = __webpack_require__(78781);
|
54
|
+
// EXTERNAL MODULE: external "stream"
|
55
|
+
var external_stream_ = __webpack_require__(12781);
|
56
|
+
var external_stream_default = /*#__PURE__*/__webpack_require__.n(external_stream_);
|
57
|
+
// EXTERNAL MODULE: ./node_modules/evt/tools/Deferred.js
|
58
|
+
var Deferred = __webpack_require__(50689);
|
59
|
+
// EXTERNAL MODULE: ./dist/bin/tools/fs.existsAsync.js
|
60
|
+
var fs_existsAsync = __webpack_require__(43765);
|
61
|
+
;// CONCATENATED MODULE: ./dist/bin/tools/extractArchive.js
|
62
|
+
|
63
|
+
|
64
|
+
|
65
|
+
|
66
|
+
|
67
|
+
|
68
|
+
|
69
|
+
async function extractArchive(params) {
|
70
|
+
const { archiveFilePath, onArchiveFile } = params;
|
71
|
+
const zipFile = await new Promise((resolve, reject) => {
|
72
|
+
yauzl.open(archiveFilePath, { lazyEntries: true }, async (error, zipFile) => {
|
73
|
+
if (error) {
|
74
|
+
reject(error);
|
75
|
+
return;
|
76
|
+
}
|
77
|
+
resolve(zipFile);
|
78
|
+
});
|
79
|
+
});
|
80
|
+
const dDone = new Deferred.Deferred();
|
81
|
+
zipFile.once("end", () => {
|
82
|
+
zipFile.close();
|
83
|
+
dDone.resolve();
|
84
|
+
});
|
85
|
+
const writeFile = async (entry, params) => {
|
86
|
+
const { filePath, modifiedData } = params;
|
87
|
+
{
|
88
|
+
const dirPath = (0,external_path_.dirname)(filePath);
|
89
|
+
if (!(await (0,fs_existsAsync/* existsAsync */.o)(dirPath))) {
|
90
|
+
await promises_default().mkdir(dirPath, { recursive: true });
|
91
|
+
}
|
92
|
+
}
|
93
|
+
if (modifiedData !== undefined) {
|
94
|
+
await promises_default().writeFile(filePath, modifiedData);
|
95
|
+
return;
|
96
|
+
}
|
97
|
+
const readStream = await new Promise(resolve => zipFile.openReadStream(entry, async (error, readStream) => {
|
98
|
+
if (error) {
|
99
|
+
dDone.reject(error);
|
100
|
+
return;
|
101
|
+
}
|
102
|
+
resolve(readStream);
|
103
|
+
}));
|
104
|
+
const dDoneWithFile = new Deferred.Deferred();
|
105
|
+
external_stream_default().pipeline(readStream, external_fs_default().createWriteStream(filePath), error => {
|
106
|
+
if (error) {
|
107
|
+
dDone.reject(error);
|
108
|
+
return;
|
109
|
+
}
|
110
|
+
dDoneWithFile.resolve();
|
111
|
+
});
|
112
|
+
await dDoneWithFile.pr;
|
113
|
+
};
|
114
|
+
const readFile = (entry) => new Promise(resolve => zipFile.openReadStream(entry, async (error, readStream) => {
|
115
|
+
if (error) {
|
116
|
+
dDone.reject(error);
|
117
|
+
return;
|
118
|
+
}
|
119
|
+
const chunks = [];
|
120
|
+
readStream.on("data", chunk => {
|
121
|
+
chunks.push(chunk);
|
122
|
+
});
|
123
|
+
readStream.on("end", () => {
|
124
|
+
resolve(Buffer.concat(chunks));
|
125
|
+
});
|
126
|
+
readStream.on("error", error => {
|
127
|
+
dDone.reject(error);
|
128
|
+
});
|
129
|
+
}));
|
130
|
+
zipFile.on("entry", async (entry) => {
|
131
|
+
handle_file: {
|
132
|
+
// NOTE: Skip directories
|
133
|
+
if (entry.fileName.endsWith("/")) {
|
134
|
+
break handle_file;
|
135
|
+
}
|
136
|
+
let hasEarlyExitBeenCalled = false;
|
137
|
+
await onArchiveFile({
|
138
|
+
relativeFilePathInArchive: entry.fileName.split("/").join(external_path_.sep),
|
139
|
+
readFile: () => readFile(entry),
|
140
|
+
writeFile: params => writeFile(entry, params),
|
141
|
+
earlyExit: () => {
|
142
|
+
hasEarlyExitBeenCalled = true;
|
143
|
+
}
|
144
|
+
});
|
145
|
+
if (hasEarlyExitBeenCalled) {
|
146
|
+
zipFile.close();
|
147
|
+
dDone.resolve();
|
148
|
+
return;
|
149
|
+
}
|
150
|
+
}
|
151
|
+
zipFile.readEntry();
|
152
|
+
});
|
153
|
+
zipFile.readEntry();
|
154
|
+
await dDone.pr;
|
155
|
+
}
|
156
|
+
//# sourceMappingURL=extractArchive.js.map
|
157
|
+
// EXTERNAL MODULE: ./node_modules/tsafe/esm/id.mjs
|
158
|
+
var id = __webpack_require__(38469);
|
159
|
+
// EXTERNAL MODULE: ./node_modules/zod/lib/index.mjs
|
160
|
+
var lib = __webpack_require__(52300);
|
161
|
+
;// CONCATENATED MODULE: ./dist/bin/start-keycloak/appBuild.js
|
30
162
|
|
31
163
|
|
32
164
|
|
@@ -36,188 +168,1982 @@ __webpack_require__.r(__webpack_exports__);
|
|
36
168
|
|
37
169
|
|
38
170
|
|
39
|
-
|
171
|
+
|
172
|
+
(0,assert/* assert */.h)();
|
173
|
+
async function appBuild(params) {
|
174
|
+
var _a;
|
175
|
+
const { buildContext } = params;
|
176
|
+
const { parsedPackageJson } = (() => {
|
177
|
+
const zParsedPackageJson = (() => {
|
178
|
+
const zTargetType = lib.z.object({
|
179
|
+
scripts: lib.z.record(lib.z.string()).optional()
|
180
|
+
});
|
181
|
+
(0,assert/* assert */.h)();
|
182
|
+
return (0,id.id)(zTargetType);
|
183
|
+
})();
|
184
|
+
const parsedPackageJson = JSON.parse(external_fs_.readFileSync(buildContext.packageJsonFilePath).toString("utf8"));
|
185
|
+
zParsedPackageJson.parse(parsedPackageJson);
|
186
|
+
(0,assert/* assert */.h)((0,assert.is)(parsedPackageJson));
|
187
|
+
return { parsedPackageJson };
|
188
|
+
})();
|
189
|
+
const entries = Object.entries((_a = parsedPackageJson.scripts) !== null && _a !== void 0 ? _a : {}).filter(([, scriptCommand]) => scriptCommand.includes("keycloakify build"));
|
190
|
+
if (entries.length === 0) {
|
191
|
+
console.log(source_default().red([
|
192
|
+
`You should have a script in your package.json at ${(0,external_path_.relative)(process.cwd(), (0,external_path_.dirname)(buildContext.packageJsonFilePath))}`,
|
193
|
+
`that includes the 'keycloakify build' command`
|
194
|
+
].join(" ")));
|
195
|
+
process.exit(-1);
|
196
|
+
}
|
197
|
+
const entry = entries.length === 1
|
198
|
+
? entries[0]
|
199
|
+
: entries.find(([scriptName]) => scriptName === "build-keycloak-theme");
|
200
|
+
if (entry === undefined) {
|
201
|
+
console.log(source_default().red("There's multiple candidate script for building your app, name one 'build-keycloak-theme'"));
|
202
|
+
process.exit(-1);
|
203
|
+
}
|
204
|
+
const [scriptName, scriptCommand] = entry;
|
205
|
+
const { appBuildSubCommands } = (() => {
|
206
|
+
const appBuildSubCommands = [];
|
207
|
+
for (const subCmd of scriptCommand.split("&&").map(s => s.trim())) {
|
208
|
+
if (subCmd.includes("keycloakify build")) {
|
209
|
+
break;
|
210
|
+
}
|
211
|
+
appBuildSubCommands.push(subCmd);
|
212
|
+
}
|
213
|
+
return { appBuildSubCommands };
|
214
|
+
})();
|
215
|
+
if (appBuildSubCommands.length === 0) {
|
216
|
+
console.log(source_default().red(`Your ${scriptName} script should look like "... && keycloakify build ..."`));
|
217
|
+
process.exit(-1);
|
218
|
+
}
|
219
|
+
common_case: {
|
220
|
+
if (appBuildSubCommands.length !== 1) {
|
221
|
+
break common_case;
|
222
|
+
}
|
223
|
+
const [appBuildSubCommand] = appBuildSubCommands;
|
224
|
+
const isNpmRunBuild = (() => {
|
225
|
+
for (const packageManager of ["npm", "yarn", "pnpm", "bun", "deno"]) {
|
226
|
+
for (const doUseRun of [true, false]) {
|
227
|
+
if (`${packageManager}${doUseRun ? " run " : " "}build` ===
|
228
|
+
appBuildSubCommand) {
|
229
|
+
return true;
|
230
|
+
}
|
231
|
+
}
|
232
|
+
}
|
233
|
+
return false;
|
234
|
+
})();
|
235
|
+
if (!isNpmRunBuild) {
|
236
|
+
break common_case;
|
237
|
+
}
|
238
|
+
const { scripts } = parsedPackageJson;
|
239
|
+
(0,assert/* assert */.h)(scripts !== undefined);
|
240
|
+
const buildCmd = scripts.build;
|
241
|
+
if (buildCmd !== "tsc && vite build") {
|
242
|
+
break common_case;
|
243
|
+
}
|
244
|
+
if (scripts.prebuild !== undefined) {
|
245
|
+
break common_case;
|
246
|
+
}
|
247
|
+
if (scripts.postbuild !== undefined) {
|
248
|
+
break common_case;
|
249
|
+
}
|
250
|
+
const dIsSuccess = new Deferred.Deferred();
|
251
|
+
console.log(source_default().blue("$ npx vite build"));
|
252
|
+
const child = external_child_process_.spawn("npx", ["vite", "build"], {
|
253
|
+
cwd: buildContext.projectDirPath,
|
254
|
+
shell: true
|
255
|
+
});
|
256
|
+
child.stdout.on("data", data => {
|
257
|
+
if (data.toString("utf8").includes("gzip:")) {
|
258
|
+
return;
|
259
|
+
}
|
260
|
+
process.stdout.write(data);
|
261
|
+
});
|
262
|
+
child.stderr.on("data", data => process.stderr.write(data));
|
263
|
+
child.on("exit", code => dIsSuccess.resolve(code === 0));
|
264
|
+
const isSuccess = await dIsSuccess.pr;
|
265
|
+
return { isAppBuildSuccess: isSuccess };
|
266
|
+
}
|
267
|
+
let commandCwd = (0,external_path_.dirname)(buildContext.packageJsonFilePath);
|
268
|
+
for (const subCommand of appBuildSubCommands) {
|
269
|
+
const dIsSuccess = new Deferred.Deferred();
|
270
|
+
const [command, ...args] = subCommand.split(" ");
|
271
|
+
if (command === "cd") {
|
272
|
+
const [pathIsh] = args;
|
273
|
+
commandCwd = (0,getAbsoluteAndInOsFormatPath/* getAbsoluteAndInOsFormatPath */.c)({
|
274
|
+
pathIsh,
|
275
|
+
cwd: commandCwd
|
276
|
+
});
|
277
|
+
continue;
|
278
|
+
}
|
279
|
+
console.log(source_default().blue(`$ ${subCommand}`));
|
280
|
+
const child = external_child_process_.spawn(command, args, {
|
281
|
+
cwd: commandCwd,
|
282
|
+
env: Object.assign(Object.assign({}, process.env), { PATH: (() => {
|
283
|
+
var _a;
|
284
|
+
const separator = external_path_.sep === "/" ? ":" : ";";
|
285
|
+
return [
|
286
|
+
(0,external_path_.join)((0,external_path_.dirname)(buildContext.packageJsonFilePath), "node_modules", ".bin"),
|
287
|
+
...((_a = process.env.PATH) !== null && _a !== void 0 ? _a : "").split(separator)
|
288
|
+
].join(separator);
|
289
|
+
})() }),
|
290
|
+
shell: true
|
291
|
+
});
|
292
|
+
child.stdout.on("data", data => process.stdout.write(data));
|
293
|
+
child.stderr.on("data", data => process.stderr.write(data));
|
294
|
+
child.on("exit", code => dIsSuccess.resolve(code === 0));
|
295
|
+
const isSuccess = await dIsSuccess.pr;
|
296
|
+
if (!isSuccess) {
|
297
|
+
return { isAppBuildSuccess: false };
|
298
|
+
}
|
299
|
+
}
|
300
|
+
return { isAppBuildSuccess: true };
|
301
|
+
}
|
302
|
+
//# sourceMappingURL=appBuild.js.map
|
303
|
+
;// CONCATENATED MODULE: ./dist/bin/start-keycloak/keycloakifyBuild.js
|
304
|
+
|
305
|
+
|
306
|
+
|
307
|
+
|
308
|
+
|
309
|
+
(0,assert/* assert */.h)();
|
310
|
+
async function keycloakifyBuild(params) {
|
311
|
+
const { buildForKeycloakMajorVersionNumber, buildContext } = params;
|
312
|
+
const dResult = new Deferred.Deferred();
|
313
|
+
console.log(source_default().blue("$ npx keycloakify build"));
|
314
|
+
const child = external_child_process_.spawn("npx", ["keycloakify", "build"], {
|
315
|
+
cwd: buildContext.projectDirPath,
|
316
|
+
env: Object.assign(Object.assign({}, process.env), { [constants/* BUILD_FOR_KEYCLOAK_MAJOR_VERSION_ENV_NAME */.ac]: `${buildForKeycloakMajorVersionNumber}` }),
|
317
|
+
shell: true
|
318
|
+
});
|
319
|
+
child.stdout.on("data", data => process.stdout.write(data));
|
320
|
+
child.stderr.on("data", data => process.stderr.write(data));
|
321
|
+
child.on("exit", code => dResult.resolve({ isSuccess: code === 0 }));
|
322
|
+
const { isSuccess } = await dResult.pr;
|
323
|
+
return { isKeycloakifyBuildSuccess: isSuccess };
|
324
|
+
}
|
325
|
+
//# sourceMappingURL=keycloakifyBuild.js.map
|
326
|
+
// EXTERNAL MODULE: ./dist/bin/tools/isInside.js
|
327
|
+
var isInside = __webpack_require__(90665);
|
328
|
+
;// CONCATENATED MODULE: ./dist/bin/tools/fs.rm.js
|
329
|
+
|
330
|
+
|
331
|
+
|
332
|
+
/**
|
333
|
+
* Polyfill of fs.rm(dirPath, { "recursive": true })
|
334
|
+
* For older version of Node
|
335
|
+
*/
|
336
|
+
async function rm(dirPath, options) {
|
337
|
+
if (SemVer/* SemVer.compare */.h.compare(SemVer/* SemVer.parse */.h.parse(process.version), SemVer/* SemVer.parse */.h.parse("14.14.0")) > 0) {
|
338
|
+
return promises_.rm(dirPath, options);
|
339
|
+
}
|
340
|
+
const { force = true } = options;
|
341
|
+
if (force && !(await checkDirExists(dirPath))) {
|
342
|
+
return;
|
343
|
+
}
|
344
|
+
const removeDir_rec = async (dirPath) => Promise.all((await promises_.readdir(dirPath)).map(async (basename) => {
|
345
|
+
const fileOrDirpath = (0,external_path_.join)(dirPath, basename);
|
346
|
+
if ((await promises_.lstat(fileOrDirpath)).isDirectory()) {
|
347
|
+
await removeDir_rec(fileOrDirpath);
|
348
|
+
}
|
349
|
+
else {
|
350
|
+
await promises_.unlink(fileOrDirpath);
|
351
|
+
}
|
352
|
+
}));
|
353
|
+
await removeDir_rec(dirPath);
|
354
|
+
}
|
355
|
+
async function checkDirExists(dirPath) {
|
356
|
+
try {
|
357
|
+
await promises_.access(dirPath, promises_.constants.F_OK);
|
358
|
+
return true;
|
359
|
+
}
|
360
|
+
catch (_a) {
|
361
|
+
return false;
|
362
|
+
}
|
363
|
+
}
|
364
|
+
//# sourceMappingURL=fs.rm.js.map
|
365
|
+
// EXTERNAL MODULE: ./node_modules/make-fetch-happen/lib/index.js
|
366
|
+
var make_fetch_happen_lib = __webpack_require__(9525);
|
367
|
+
var lib_default = /*#__PURE__*/__webpack_require__.n(make_fetch_happen_lib);
|
368
|
+
// EXTERNAL MODULE: external "crypto"
|
369
|
+
var external_crypto_ = __webpack_require__(6113);
|
370
|
+
;// CONCATENATED MODULE: ./dist/bin/tools/downloadAndExtractArchive.js
|
371
|
+
|
372
|
+
|
373
|
+
|
374
|
+
|
375
|
+
|
376
|
+
|
377
|
+
|
378
|
+
|
379
|
+
async function downloadAndExtractArchive(params) {
|
380
|
+
var _a;
|
381
|
+
const { url, uniqueIdOfOnArchiveFile, onArchiveFile, cacheDirPath, fetchOptions } = params;
|
382
|
+
const archiveFileBasename = url.split("?")[0].split("/").reverse()[0];
|
383
|
+
const archiveFilePath = (0,external_path_.join)(cacheDirPath, archiveFileBasename);
|
384
|
+
download: {
|
385
|
+
await (0,promises_.mkdir)((0,external_path_.dirname)(archiveFilePath), { recursive: true });
|
386
|
+
if (await (0,fs_existsAsync/* existsAsync */.o)(archiveFilePath)) {
|
387
|
+
const isDownloaded = await SuccessTracker.getIsDownloaded({
|
388
|
+
cacheDirPath,
|
389
|
+
archiveFileBasename
|
390
|
+
});
|
391
|
+
if (isDownloaded) {
|
392
|
+
break download;
|
393
|
+
}
|
394
|
+
await (0,promises_.unlink)(archiveFilePath);
|
395
|
+
await SuccessTracker.removeFromDownloaded({
|
396
|
+
cacheDirPath,
|
397
|
+
archiveFileBasename
|
398
|
+
});
|
399
|
+
}
|
400
|
+
const response = await lib_default()(url, fetchOptions);
|
401
|
+
(_a = response.body) === null || _a === void 0 ? void 0 : _a.setMaxListeners(Number.MAX_VALUE);
|
402
|
+
(0,assert/* assert */.h)(typeof response.body !== "undefined" && response.body != null);
|
403
|
+
await (0,promises_.writeFile)(archiveFilePath, response.body);
|
404
|
+
await SuccessTracker.markAsDownloaded({
|
405
|
+
cacheDirPath,
|
406
|
+
archiveFileBasename
|
407
|
+
});
|
408
|
+
}
|
409
|
+
const extractDirBasename = `${archiveFileBasename.replace(/\.([^.]+)$/, (...[, ext]) => `_${ext}`)}_${uniqueIdOfOnArchiveFile}_${external_crypto_.createHash("sha256")
|
410
|
+
.update(onArchiveFile.toString())
|
411
|
+
.digest("hex")
|
412
|
+
.substring(0, 5)}`;
|
413
|
+
await Promise.all((await (0,promises_.readdir)(cacheDirPath))
|
414
|
+
.filter((() => {
|
415
|
+
const prefix = extractDirBasename
|
416
|
+
.split("_")
|
417
|
+
.reverse()
|
418
|
+
.slice(1)
|
419
|
+
.reverse()
|
420
|
+
.join("_");
|
421
|
+
return basename => basename !== extractDirBasename && basename.startsWith(prefix);
|
422
|
+
})())
|
423
|
+
.map(async (extractDirBasename) => {
|
424
|
+
await rm((0,external_path_.join)(cacheDirPath, extractDirBasename), {
|
425
|
+
recursive: true
|
426
|
+
});
|
427
|
+
await SuccessTracker.removeFromExtracted({
|
428
|
+
cacheDirPath,
|
429
|
+
extractDirBasename
|
430
|
+
});
|
431
|
+
}));
|
432
|
+
const extractedDirPath = (0,external_path_.join)(cacheDirPath, extractDirBasename);
|
433
|
+
extract_and_transform: {
|
434
|
+
if (await (0,fs_existsAsync/* existsAsync */.o)(extractedDirPath)) {
|
435
|
+
const isExtracted = await SuccessTracker.getIsExtracted({
|
436
|
+
cacheDirPath,
|
437
|
+
extractDirBasename
|
438
|
+
});
|
439
|
+
if (isExtracted) {
|
440
|
+
break extract_and_transform;
|
441
|
+
}
|
442
|
+
await rm(extractedDirPath, { recursive: true });
|
443
|
+
await SuccessTracker.removeFromExtracted({
|
444
|
+
cacheDirPath,
|
445
|
+
extractDirBasename
|
446
|
+
});
|
447
|
+
}
|
448
|
+
await extractArchive({
|
449
|
+
archiveFilePath,
|
450
|
+
onArchiveFile: async ({ relativeFilePathInArchive, readFile, writeFile }) => onArchiveFile({
|
451
|
+
fileRelativePath: relativeFilePathInArchive,
|
452
|
+
readFile,
|
453
|
+
writeFile: ({ fileRelativePath, modifiedData }) => writeFile({
|
454
|
+
filePath: (0,external_path_.join)(extractedDirPath, fileRelativePath),
|
455
|
+
modifiedData
|
456
|
+
})
|
457
|
+
})
|
458
|
+
});
|
459
|
+
await SuccessTracker.markAsExtracted({
|
460
|
+
cacheDirPath,
|
461
|
+
extractDirBasename
|
462
|
+
});
|
463
|
+
}
|
464
|
+
return { extractedDirPath, archiveFilePath };
|
465
|
+
}
|
466
|
+
var SuccessTracker;
|
467
|
+
(function (SuccessTracker) {
|
468
|
+
async function read(params) {
|
469
|
+
const { cacheDirPath } = params;
|
470
|
+
const filePath = (0,external_path_.join)(cacheDirPath, "downloadAndExtractArchive.json");
|
471
|
+
if (!(await (0,fs_existsAsync/* existsAsync */.o)(filePath))) {
|
472
|
+
return { archiveFileBasenames: [], extractDirBasenames: [] };
|
473
|
+
}
|
474
|
+
return JSON.parse((await (0,promises_.readFile)(filePath)).toString("utf8"));
|
475
|
+
}
|
476
|
+
async function write(params) {
|
477
|
+
const { cacheDirPath, successTracker } = params;
|
478
|
+
const filePath = (0,external_path_.join)(cacheDirPath, "downloadAndExtractArchive.json");
|
479
|
+
{
|
480
|
+
const dirPath = (0,external_path_.dirname)(filePath);
|
481
|
+
if (!(await (0,fs_existsAsync/* existsAsync */.o)(dirPath))) {
|
482
|
+
await (0,promises_.mkdir)(dirPath, { recursive: true });
|
483
|
+
}
|
484
|
+
}
|
485
|
+
await (0,promises_.writeFile)(filePath, JSON.stringify(successTracker));
|
486
|
+
}
|
487
|
+
async function markAsDownloaded(params) {
|
488
|
+
const { cacheDirPath, archiveFileBasename } = params;
|
489
|
+
const successTracker = await read({ cacheDirPath });
|
490
|
+
successTracker.archiveFileBasenames.push(archiveFileBasename);
|
491
|
+
await write({ cacheDirPath, successTracker });
|
492
|
+
}
|
493
|
+
SuccessTracker.markAsDownloaded = markAsDownloaded;
|
494
|
+
async function getIsDownloaded(params) {
|
495
|
+
const { cacheDirPath, archiveFileBasename } = params;
|
496
|
+
const successTracker = await read({ cacheDirPath });
|
497
|
+
return successTracker.archiveFileBasenames.includes(archiveFileBasename);
|
498
|
+
}
|
499
|
+
SuccessTracker.getIsDownloaded = getIsDownloaded;
|
500
|
+
async function removeFromDownloaded(params) {
|
501
|
+
const { cacheDirPath, archiveFileBasename } = params;
|
502
|
+
const successTracker = await read({ cacheDirPath });
|
503
|
+
successTracker.archiveFileBasenames = successTracker.archiveFileBasenames.filter(basename => basename !== archiveFileBasename);
|
504
|
+
await write({ cacheDirPath, successTracker });
|
505
|
+
}
|
506
|
+
SuccessTracker.removeFromDownloaded = removeFromDownloaded;
|
507
|
+
async function markAsExtracted(params) {
|
508
|
+
const { cacheDirPath, extractDirBasename } = params;
|
509
|
+
const successTracker = await read({ cacheDirPath });
|
510
|
+
successTracker.extractDirBasenames.push(extractDirBasename);
|
511
|
+
await write({ cacheDirPath, successTracker });
|
512
|
+
}
|
513
|
+
SuccessTracker.markAsExtracted = markAsExtracted;
|
514
|
+
async function getIsExtracted(params) {
|
515
|
+
const { cacheDirPath, extractDirBasename } = params;
|
516
|
+
const successTracker = await read({ cacheDirPath });
|
517
|
+
return successTracker.extractDirBasenames.includes(extractDirBasename);
|
518
|
+
}
|
519
|
+
SuccessTracker.getIsExtracted = getIsExtracted;
|
520
|
+
async function removeFromExtracted(params) {
|
521
|
+
const { cacheDirPath, extractDirBasename } = params;
|
522
|
+
const successTracker = await read({ cacheDirPath });
|
523
|
+
successTracker.extractDirBasenames = successTracker.extractDirBasenames.filter(basename => basename !== extractDirBasename);
|
524
|
+
await write({ cacheDirPath, successTracker });
|
525
|
+
}
|
526
|
+
SuccessTracker.removeFromExtracted = removeFromExtracted;
|
527
|
+
})(SuccessTracker || (SuccessTracker = {}));
|
528
|
+
//# sourceMappingURL=downloadAndExtractArchive.js.map
|
529
|
+
;// CONCATENATED MODULE: ./dist/bin/start-keycloak/startViteDevServer.js
|
530
|
+
|
531
|
+
|
532
|
+
|
533
|
+
|
534
|
+
|
535
|
+
(0,assert/* assert */.h)();
|
536
|
+
function startViteDevServer(params) {
|
537
|
+
const { buildContext } = params;
|
538
|
+
console.log(source_default().blue(`$ npx vite dev`));
|
539
|
+
const child = external_child_process_.spawn("npx", ["vite", "dev"], {
|
540
|
+
cwd: buildContext.projectDirPath,
|
541
|
+
env: Object.assign(Object.assign({}, process.env), { [constants/* VITE_PLUGIN_SUB_SCRIPTS_ENV_NAMES.READ_KC_CONTEXT_FROM_URL */.TE.READ_KC_CONTEXT_FROM_URL]: "true" }),
|
542
|
+
shell: true
|
543
|
+
});
|
544
|
+
child.stdout.on("data", data => {
|
545
|
+
if (!data.toString("utf8").includes("[vite] hmr")) {
|
546
|
+
return;
|
547
|
+
}
|
548
|
+
process.stdout.write(data);
|
549
|
+
});
|
550
|
+
child.stderr.on("data", data => process.stderr.write(data));
|
551
|
+
const dPort = new Deferred.Deferred();
|
552
|
+
{
|
553
|
+
const onData = (data) => {
|
554
|
+
//Local: http://localhost:8083/
|
555
|
+
const match = data
|
556
|
+
.toString("utf8")
|
557
|
+
.replace(/\x1b[[0-9;]*m/g, "")
|
558
|
+
.match(/Local:\s*http:\/\/(?:localhost|127\.0\.0\.1):(\d+)\//);
|
559
|
+
if (match === null) {
|
560
|
+
return;
|
561
|
+
}
|
562
|
+
child.stdout.off("data", onData);
|
563
|
+
const port = parseInt(match[1]);
|
564
|
+
(0,assert/* assert */.h)(!isNaN(port));
|
565
|
+
dPort.resolve(port);
|
566
|
+
};
|
567
|
+
child.stdout.on("data", onData);
|
568
|
+
}
|
569
|
+
return dPort.pr.then(port => ({ port }));
|
570
|
+
}
|
571
|
+
//# sourceMappingURL=startViteDevServer.js.map
|
572
|
+
// EXTERNAL MODULE: ./node_modules/tsafe/esm/is.mjs
|
573
|
+
var is = __webpack_require__(16453);
|
574
|
+
;// CONCATENATED MODULE: ./dist/bin/start-keycloak/realmConfig/ParsedRealmJson/ParsedRealmJson.js
|
575
|
+
|
576
|
+
|
577
|
+
|
578
|
+
const zParsedRealmJson = (() => {
|
579
|
+
const zTargetType = lib.z.object({
|
580
|
+
realm: lib.z.string(),
|
581
|
+
loginTheme: lib.z.string().optional(),
|
582
|
+
accountTheme: lib.z.string().optional(),
|
583
|
+
adminTheme: lib.z.string().optional(),
|
584
|
+
emailTheme: lib.z.string().optional(),
|
585
|
+
eventsListeners: lib.z.array(lib.z.string()),
|
586
|
+
users: lib.z.array(lib.z.object({
|
587
|
+
id: lib.z.string(),
|
588
|
+
email: lib.z.string(),
|
589
|
+
username: lib.z.string(),
|
590
|
+
credentials: lib.z.array(lib.z.object({
|
591
|
+
type: lib.z.string()
|
592
|
+
})),
|
593
|
+
clientRoles: lib.z.record(lib.z.array(lib.z.string())).optional()
|
594
|
+
})),
|
595
|
+
roles: lib.z.object({
|
596
|
+
client: lib.z.record(lib.z.array(lib.z.object({
|
597
|
+
name: lib.z.string(),
|
598
|
+
containerId: lib.z.string()
|
599
|
+
})))
|
600
|
+
}),
|
601
|
+
clients: lib.z.array(lib.z.object({
|
602
|
+
id: lib.z.string(),
|
603
|
+
clientId: lib.z.string(),
|
604
|
+
baseUrl: lib.z.string().optional(),
|
605
|
+
redirectUris: lib.z.array(lib.z.string()).optional(),
|
606
|
+
webOrigins: lib.z.array(lib.z.string()).optional(),
|
607
|
+
attributes: lib.z.object({
|
608
|
+
"post.logout.redirect.uris": lib.z.string().optional()
|
609
|
+
})
|
610
|
+
.optional(),
|
611
|
+
protocol: lib.z.string().optional(),
|
612
|
+
protocolMappers: lib.z.array(lib.z.object({
|
613
|
+
id: lib.z.string(),
|
614
|
+
name: lib.z.string(),
|
615
|
+
protocol: lib.z.string(),
|
616
|
+
protocolMapper: lib.z.string(),
|
617
|
+
consentRequired: lib.z.boolean(),
|
618
|
+
config: lib.z.record(lib.z.string()).optional()
|
619
|
+
}))
|
620
|
+
.optional()
|
621
|
+
}))
|
622
|
+
});
|
623
|
+
assert/* assert */.h;
|
624
|
+
return (0,id.id)(zTargetType);
|
625
|
+
})();
|
626
|
+
//# sourceMappingURL=ParsedRealmJson.js.map
|
627
|
+
;// CONCATENATED MODULE: ./dist/bin/start-keycloak/realmConfig/ParsedRealmJson/readRealmJsonFile.js
|
628
|
+
|
629
|
+
|
630
|
+
|
631
|
+
|
632
|
+
function readRealmJsonFile(params) {
|
633
|
+
const { realmJsonFilePath } = params;
|
634
|
+
const parsedRealmJson = JSON.parse(external_fs_.readFileSync(realmJsonFilePath).toString("utf8"));
|
635
|
+
zParsedRealmJson.parse(parsedRealmJson);
|
636
|
+
(0,assert/* assert */.h)((0,is.is)(parsedRealmJson));
|
637
|
+
return parsedRealmJson;
|
638
|
+
}
|
639
|
+
//# sourceMappingURL=readRealmJsonFile.js.map
|
640
|
+
;// CONCATENATED MODULE: ./dist/bin/start-keycloak/realmConfig/defaultConfig/defaultConfig.js
|
641
|
+
|
642
|
+
|
643
|
+
|
644
|
+
|
645
|
+
|
646
|
+
|
647
|
+
function getDefaultRealmJsonFilePath(params) {
|
648
|
+
const { keycloakMajorVersionNumber } = params;
|
649
|
+
return (0,external_path_.join)((0,getThisCodebaseRootDirPath/* getThisCodebaseRootDirPath */.e)(), "src", "bin", "start-keycloak", "realmConfig", "defaultConfig", `realm-kc-${keycloakMajorVersionNumber}.json`);
|
650
|
+
}
|
651
|
+
const { getSupportedKeycloakMajorVersions } = (() => {
|
652
|
+
let cache = undefined;
|
653
|
+
function getSupportedKeycloakMajorVersions() {
|
654
|
+
if (cache !== undefined) {
|
655
|
+
return cache;
|
656
|
+
}
|
657
|
+
cache = external_fs_.readdirSync((0,external_path_.dirname)(getDefaultRealmJsonFilePath({ keycloakMajorVersionNumber: 0 })))
|
658
|
+
.map(fileBasename => {
|
659
|
+
const match = fileBasename.match(/^realm-kc-(\d+)\.json$/);
|
660
|
+
if (match === null) {
|
661
|
+
return undefined;
|
662
|
+
}
|
663
|
+
const n = parseInt(match[1]);
|
664
|
+
(0,assert/* assert */.h)(!isNaN(n));
|
665
|
+
return n;
|
666
|
+
})
|
667
|
+
.filter((0,exclude/* exclude */.D)(undefined))
|
668
|
+
.sort((a, b) => b - a);
|
669
|
+
return cache;
|
670
|
+
}
|
671
|
+
return { getSupportedKeycloakMajorVersions };
|
672
|
+
})();
|
673
|
+
function getDefaultConfig(params) {
|
674
|
+
const { keycloakMajorVersionNumber } = params;
|
675
|
+
(0,assert/* assert */.h)(getSupportedKeycloakMajorVersions().includes(keycloakMajorVersionNumber), `We do not have a default config for Keycloak ${keycloakMajorVersionNumber}`);
|
676
|
+
return readRealmJsonFile({
|
677
|
+
realmJsonFilePath: getDefaultRealmJsonFilePath({
|
678
|
+
keycloakMajorVersionNumber
|
679
|
+
})
|
680
|
+
});
|
681
|
+
}
|
682
|
+
//# sourceMappingURL=defaultConfig.js.map
|
683
|
+
;// CONCATENATED MODULE: ./dist/bin/start-keycloak/realmConfig/defaultConfig/index.js
|
684
|
+
|
685
|
+
//# sourceMappingURL=index.js.map
|
686
|
+
// EXTERNAL MODULE: ./dist/bin/tools/readThisNpmPackageVersion.js
|
687
|
+
var readThisNpmPackageVersion = __webpack_require__(64795);
|
688
|
+
;// CONCATENATED MODULE: ./dist/bin/start-keycloak/getSupportedDockerImageTags.js
|
689
|
+
|
690
|
+
|
691
|
+
|
692
|
+
|
693
|
+
|
694
|
+
|
695
|
+
|
696
|
+
|
697
|
+
|
698
|
+
|
699
|
+
|
700
|
+
assert/* assert */.h;
|
701
|
+
async function getSupportedDockerImageTags(params) {
|
40
702
|
const { buildContext } = params;
|
41
|
-
|
42
|
-
|
703
|
+
{
|
704
|
+
const result = await getCachedValue({ cacheDirPath: buildContext.cacheDirPath });
|
705
|
+
if (result !== undefined) {
|
706
|
+
return result;
|
707
|
+
}
|
708
|
+
}
|
709
|
+
const tags_queryResponse = [];
|
710
|
+
await (async function callee(url) {
|
711
|
+
const r = await lib_default()(url, buildContext.fetchOptions);
|
712
|
+
await Promise.all([
|
713
|
+
(async () => {
|
714
|
+
tags_queryResponse.push(...lib.z.object({
|
715
|
+
tags: lib.z.array(lib.z.string())
|
716
|
+
})
|
717
|
+
.parse(await r.json()).tags);
|
718
|
+
})(),
|
719
|
+
(async () => {
|
720
|
+
const link = r.headers.get("link");
|
721
|
+
if (link === null) {
|
722
|
+
return;
|
723
|
+
}
|
724
|
+
const split = link.split(";").map(s => s.trim());
|
725
|
+
(0,assert/* assert */.h)(split.length === 2);
|
726
|
+
(0,assert/* assert */.h)(split[1] === 'rel="next"');
|
727
|
+
const match = split[0].match(/^<(.+)>$/);
|
728
|
+
(0,assert/* assert */.h)(match !== null);
|
729
|
+
const nextUrl = new URL(url).origin + match[1];
|
730
|
+
await callee(nextUrl);
|
731
|
+
})()
|
732
|
+
]);
|
733
|
+
})("https://quay.io/v2/keycloak/keycloak/tags/list");
|
734
|
+
const supportedKeycloakMajorVersions = getSupportedKeycloakMajorVersions();
|
735
|
+
const allSupportedTags_withVersion = tags_queryResponse
|
736
|
+
.map(tag => ({
|
737
|
+
tag,
|
738
|
+
version: (() => {
|
739
|
+
if (tag.includes("-")) {
|
740
|
+
return undefined;
|
741
|
+
}
|
742
|
+
let version;
|
743
|
+
try {
|
744
|
+
version = SemVer/* SemVer.parse */.h.parse(tag);
|
745
|
+
}
|
746
|
+
catch (_a) {
|
747
|
+
return undefined;
|
748
|
+
}
|
749
|
+
if (tag.split(".").length !== 3) {
|
750
|
+
return undefined;
|
751
|
+
}
|
752
|
+
if (!supportedKeycloakMajorVersions.includes(version.major)) {
|
753
|
+
return undefined;
|
754
|
+
}
|
755
|
+
return version;
|
756
|
+
})()
|
757
|
+
}))
|
758
|
+
.map(({ tag, version }) => (version === undefined ? undefined : { tag, version }))
|
759
|
+
.filter((0,exclude/* exclude */.D)(undefined))
|
760
|
+
.sort(({ version: a }, { version: b }) => SemVer/* SemVer.compare */.h.compare(b, a));
|
761
|
+
const latestTagByMajor = {};
|
762
|
+
for (const { version } of allSupportedTags_withVersion) {
|
763
|
+
const version_current = latestTagByMajor[version.major];
|
764
|
+
if (version_current === undefined ||
|
765
|
+
SemVer/* SemVer.compare */.h.compare(version_current, version) === -1) {
|
766
|
+
latestTagByMajor[version.major] = version;
|
767
|
+
}
|
768
|
+
}
|
769
|
+
const latestMajorTags = Object.entries(latestTagByMajor)
|
770
|
+
.sort(([a], [b]) => parseInt(b) - parseInt(a))
|
771
|
+
.map(([, version]) => version)
|
772
|
+
.map(version => {
|
773
|
+
(0,assert/* assert */.h)(version !== undefined);
|
774
|
+
if (!supportedKeycloakMajorVersions.includes(version.major)) {
|
775
|
+
return undefined;
|
776
|
+
}
|
777
|
+
return SemVer/* SemVer.stringify */.h.stringify(version);
|
778
|
+
})
|
779
|
+
.filter((0,exclude/* exclude */.D)(undefined));
|
780
|
+
const allSupportedTags = allSupportedTags_withVersion.map(({ tag }) => tag);
|
781
|
+
const result = {
|
782
|
+
latestMajorTags,
|
783
|
+
allSupportedTags
|
784
|
+
};
|
785
|
+
await setCachedValue({ cacheDirPath: buildContext.cacheDirPath, result });
|
786
|
+
return result;
|
787
|
+
}
|
788
|
+
const { getCachedValue, setCachedValue } = (() => {
|
789
|
+
const zResult = (() => {
|
790
|
+
const zTargetType = lib.z.object({
|
791
|
+
allSupportedTags: lib.z.array(lib.z.string()),
|
792
|
+
latestMajorTags: lib.z.array(lib.z.string())
|
793
|
+
});
|
794
|
+
assert/* assert */.h;
|
795
|
+
return (0,id.id)(zTargetType);
|
796
|
+
})();
|
797
|
+
const zCache = (() => {
|
798
|
+
const zTargetType = lib.z.object({
|
799
|
+
keycloakifyVersion: lib.z.string(),
|
800
|
+
time: lib.z.number(),
|
801
|
+
result: zResult
|
802
|
+
});
|
803
|
+
assert/* assert */.h;
|
804
|
+
return (0,id.id)(zTargetType);
|
805
|
+
})();
|
806
|
+
let inMemoryCachedResult = undefined;
|
807
|
+
function getCacheFilePath(params) {
|
808
|
+
const { cacheDirPath } = params;
|
809
|
+
return (0,external_path_.join)(cacheDirPath, "supportedDockerImageTags.json");
|
810
|
+
}
|
811
|
+
async function getCachedValue(params) {
|
812
|
+
const { cacheDirPath } = params;
|
813
|
+
if (inMemoryCachedResult !== undefined) {
|
814
|
+
return inMemoryCachedResult;
|
815
|
+
}
|
816
|
+
const cacheFilePath = getCacheFilePath({ cacheDirPath });
|
817
|
+
if (!(await (0,fs_existsAsync/* existsAsync */.o)(cacheFilePath))) {
|
818
|
+
return undefined;
|
819
|
+
}
|
820
|
+
let cache;
|
821
|
+
try {
|
822
|
+
cache = zCache.parse(JSON.parse(await promises_.readFile(cacheFilePath, "utf8")));
|
823
|
+
}
|
824
|
+
catch (_a) {
|
825
|
+
return undefined;
|
826
|
+
}
|
827
|
+
if (cache.keycloakifyVersion !== (0,readThisNpmPackageVersion/* readThisNpmPackageVersion */.K)()) {
|
828
|
+
return undefined;
|
829
|
+
}
|
830
|
+
if (Date.now() - cache.time > 3600 * 24) {
|
831
|
+
return undefined;
|
832
|
+
}
|
833
|
+
inMemoryCachedResult = cache.result;
|
834
|
+
return cache.result;
|
835
|
+
}
|
836
|
+
async function setCachedValue(params) {
|
837
|
+
const { cacheDirPath, result } = params;
|
838
|
+
inMemoryCachedResult = result;
|
839
|
+
const cacheFilePath = getCacheFilePath({ cacheDirPath });
|
840
|
+
{
|
841
|
+
const dirPath = (0,external_path_.dirname)(cacheFilePath);
|
842
|
+
if (!(await (0,fs_existsAsync/* existsAsync */.o)(dirPath))) {
|
843
|
+
await promises_.mkdir(dirPath, { recursive: true });
|
844
|
+
}
|
845
|
+
}
|
846
|
+
await promises_.writeFile(cacheFilePath, JSON.stringify(zCache.parse({
|
847
|
+
keycloakifyVersion: (0,readThisNpmPackageVersion/* readThisNpmPackageVersion */.K)(),
|
848
|
+
time: Date.now(),
|
849
|
+
result
|
850
|
+
}), null, 2));
|
851
|
+
}
|
852
|
+
return {
|
853
|
+
getCachedValue,
|
854
|
+
setCachedValue
|
855
|
+
};
|
856
|
+
})();
|
857
|
+
//# sourceMappingURL=getSupportedDockerImageTags.js.map
|
858
|
+
// EXTERNAL MODULE: ./node_modules/tsafe/esm/objectKeys.mjs
|
859
|
+
var objectKeys = __webpack_require__(23483);
|
860
|
+
// EXTERNAL MODULE: ./node_modules/evt/tools/inDepth/same.js
|
861
|
+
var same = __webpack_require__(33805);
|
862
|
+
;// CONCATENATED MODULE: ./dist/bin/start-keycloak/realmConfig/prepareRealmConfig.js
|
863
|
+
|
864
|
+
|
865
|
+
|
866
|
+
|
867
|
+
|
868
|
+
assert/* assert */.h;
|
869
|
+
function prepareRealmConfig(params) {
|
870
|
+
const { parsedRealmJson, keycloakMajorVersionNumber, buildContext } = params;
|
871
|
+
const { username } = addOrEditTestUser({
|
872
|
+
parsedRealmJson,
|
873
|
+
keycloakMajorVersionNumber
|
874
|
+
});
|
875
|
+
const { clientId } = addOrEditClient({
|
876
|
+
parsedRealmJson,
|
877
|
+
keycloakMajorVersionNumber
|
878
|
+
});
|
879
|
+
editAccountConsoleAndSecurityAdminConsole({ parsedRealmJson });
|
880
|
+
enableCustomThemes({
|
881
|
+
parsedRealmJson,
|
882
|
+
themeName: buildContext.themeNames[0],
|
883
|
+
implementedThemeTypes: buildContext.implementedThemeTypes
|
884
|
+
});
|
885
|
+
enable_custom_events_listeners: {
|
886
|
+
const name = "keycloakify-logging";
|
887
|
+
if (parsedRealmJson.eventsListeners.includes(name)) {
|
888
|
+
break enable_custom_events_listeners;
|
889
|
+
}
|
890
|
+
parsedRealmJson.eventsListeners.push(name);
|
891
|
+
parsedRealmJson.eventsListeners.sort();
|
892
|
+
}
|
893
|
+
return {
|
894
|
+
realmName: parsedRealmJson.realm,
|
895
|
+
clientName: clientId,
|
896
|
+
username
|
897
|
+
};
|
898
|
+
}
|
899
|
+
function enableCustomThemes(params) {
|
900
|
+
const { parsedRealmJson, themeName, implementedThemeTypes } = params;
|
901
|
+
for (const themeType of (0,objectKeys/* objectKeys */.Y)(implementedThemeTypes)) {
|
902
|
+
if (!implementedThemeTypes[themeType].isImplemented) {
|
903
|
+
continue;
|
904
|
+
}
|
905
|
+
parsedRealmJson[`${themeType}Theme`] = themeName;
|
906
|
+
}
|
907
|
+
}
|
908
|
+
function addOrEditTestUser(params) {
|
909
|
+
var _a, _b, _c, _d;
|
910
|
+
const { parsedRealmJson, keycloakMajorVersionNumber } = params;
|
911
|
+
const parsedRealmJson_default = getDefaultConfig({ keycloakMajorVersionNumber });
|
912
|
+
const [defaultUser_default] = parsedRealmJson_default.users;
|
913
|
+
(0,assert/* assert */.h)(defaultUser_default !== undefined);
|
914
|
+
const defaultUser_preexisting = parsedRealmJson.users.find(user => user.username === defaultUser_default.username);
|
915
|
+
const newUser = structuredClone((_a = defaultUser_preexisting !== null && defaultUser_preexisting !== void 0 ? defaultUser_preexisting : (() => {
|
916
|
+
const firstUser = parsedRealmJson.users[0];
|
917
|
+
if (firstUser === undefined) {
|
918
|
+
return undefined;
|
919
|
+
}
|
920
|
+
const firstUserCopy = structuredClone(firstUser);
|
921
|
+
firstUserCopy.id = defaultUser_default.id;
|
922
|
+
return firstUserCopy;
|
923
|
+
})()) !== null && _a !== void 0 ? _a : defaultUser_default);
|
924
|
+
newUser.username = defaultUser_default.username;
|
925
|
+
newUser.email = defaultUser_default.email;
|
926
|
+
delete_existing_password_credential_if_any: {
|
927
|
+
const i = newUser.credentials.findIndex(credential => credential.type === "password");
|
928
|
+
if (i === -1) {
|
929
|
+
break delete_existing_password_credential_if_any;
|
930
|
+
}
|
931
|
+
newUser.credentials.splice(i, 1);
|
932
|
+
}
|
933
|
+
{
|
934
|
+
const credential = defaultUser_default.credentials.find(credential => credential.type === "password");
|
935
|
+
(0,assert/* assert */.h)(credential !== undefined);
|
936
|
+
newUser.credentials.push(credential);
|
937
|
+
}
|
938
|
+
{
|
939
|
+
const nameByClientId = Object.fromEntries(parsedRealmJson.clients.map(client => [client.id, client.clientId]));
|
940
|
+
const newClientRoles = {};
|
941
|
+
for (const clientRole of Object.values(parsedRealmJson.roles.client).flat()) {
|
942
|
+
const clientName = nameByClientId[clientRole.containerId];
|
943
|
+
(0,assert/* assert */.h)(clientName !== undefined);
|
944
|
+
((_b = newClientRoles[clientName]) !== null && _b !== void 0 ? _b : (newClientRoles[clientName] = [])).push(clientRole.name);
|
945
|
+
}
|
946
|
+
const { same: sameSet } = (0,same.sameFactory)({
|
947
|
+
takeIntoAccountArraysOrdering: false
|
948
|
+
});
|
949
|
+
for (const [clientName, roles] of Object.entries(newClientRoles)) {
|
950
|
+
keep_previous_ordering_if_possible: {
|
951
|
+
const roles_previous = (_c = newUser.clientRoles) === null || _c === void 0 ? void 0 : _c[clientName];
|
952
|
+
if (roles_previous === undefined) {
|
953
|
+
break keep_previous_ordering_if_possible;
|
954
|
+
}
|
955
|
+
if (!sameSet(roles_previous, roles)) {
|
956
|
+
break keep_previous_ordering_if_possible;
|
957
|
+
}
|
958
|
+
continue;
|
959
|
+
}
|
960
|
+
((_d = newUser.clientRoles) !== null && _d !== void 0 ? _d : (newUser.clientRoles = {}))[clientName] = roles;
|
961
|
+
}
|
962
|
+
}
|
963
|
+
if (defaultUser_preexisting === undefined) {
|
964
|
+
parsedRealmJson.users.push(newUser);
|
965
|
+
}
|
966
|
+
else {
|
967
|
+
const i = parsedRealmJson.users.indexOf(defaultUser_preexisting);
|
968
|
+
(0,assert/* assert */.h)(i !== -1);
|
969
|
+
parsedRealmJson.users[i] = newUser;
|
970
|
+
}
|
971
|
+
return { username: newUser.username };
|
972
|
+
}
|
973
|
+
function addOrEditClient(params) {
|
974
|
+
var _a;
|
975
|
+
const { parsedRealmJson, keycloakMajorVersionNumber } = params;
|
976
|
+
const parsedRealmJson_default = getDefaultConfig({ keycloakMajorVersionNumber });
|
977
|
+
const testClient_default = (() => {
|
978
|
+
const clients = parsedRealmJson_default.clients.filter(client => {
|
979
|
+
return JSON.stringify(client).includes(constants/* TEST_APP_URL */.jp);
|
980
|
+
});
|
981
|
+
(0,assert/* assert */.h)(clients.length === 1);
|
982
|
+
return clients[0];
|
983
|
+
})();
|
984
|
+
const clientIds_builtIn = parsedRealmJson_default.clients
|
985
|
+
.map(client => client.clientId)
|
986
|
+
.filter(clientId => clientId !== testClient_default.clientId);
|
987
|
+
const testClient_preexisting = (() => {
|
988
|
+
const clients = parsedRealmJson.clients
|
989
|
+
.filter(client => !clientIds_builtIn.includes(client.clientId))
|
990
|
+
.filter(client => client.protocol === "openid-connect");
|
991
|
+
{
|
992
|
+
const client = clients.find(client => client.clientId === testClient_default.clientId);
|
993
|
+
if (client !== undefined) {
|
994
|
+
return client;
|
995
|
+
}
|
996
|
+
}
|
997
|
+
{
|
998
|
+
const client = clients.find(client => {
|
999
|
+
var _a;
|
1000
|
+
return ((_a = client.redirectUris) === null || _a === void 0 ? void 0 : _a.find(redirectUri => redirectUri.startsWith(constants/* TEST_APP_URL */.jp))) !== undefined;
|
1001
|
+
});
|
1002
|
+
if (client !== undefined) {
|
1003
|
+
return client;
|
1004
|
+
}
|
1005
|
+
}
|
1006
|
+
const [client] = clients;
|
1007
|
+
if (client === undefined) {
|
1008
|
+
return undefined;
|
1009
|
+
}
|
1010
|
+
return client;
|
1011
|
+
})();
|
1012
|
+
let testClient;
|
1013
|
+
if (testClient_preexisting !== undefined) {
|
1014
|
+
testClient = testClient_preexisting;
|
1015
|
+
}
|
1016
|
+
else {
|
1017
|
+
testClient = structuredClone(testClient_default);
|
1018
|
+
delete testClient.protocolMappers;
|
1019
|
+
parsedRealmJson.clients.push(testClient);
|
1020
|
+
}
|
1021
|
+
testClient.redirectUris = [
|
1022
|
+
`${constants/* TEST_APP_URL */.jp}/*`,
|
1023
|
+
"http://localhost*",
|
1024
|
+
"http://127.0.0.1*"
|
1025
|
+
]
|
1026
|
+
.sort()
|
1027
|
+
.reverse();
|
1028
|
+
((_a = testClient.attributes) !== null && _a !== void 0 ? _a : (testClient.attributes = {}))["post.logout.redirect.uris"] = "+";
|
1029
|
+
testClient.webOrigins = ["*"];
|
1030
|
+
return { clientId: testClient.clientId };
|
1031
|
+
}
|
1032
|
+
function editAccountConsoleAndSecurityAdminConsole(params) {
|
1033
|
+
var _a, _b, _c, _d, _e;
|
1034
|
+
const { parsedRealmJson } = params;
|
1035
|
+
for (const clientId of ["account-console", "security-admin-console"]) {
|
1036
|
+
const client = parsedRealmJson.clients.find(client => client.clientId === clientId);
|
1037
|
+
(0,assert/* assert */.h)(client !== undefined);
|
1038
|
+
{
|
1039
|
+
const arr = ((_a = client.redirectUris) !== null && _a !== void 0 ? _a : (client.redirectUris = []));
|
1040
|
+
for (const value of ["http://localhost*", "http://127.0.0.1*"]) {
|
1041
|
+
if (!arr.includes(value)) {
|
1042
|
+
arr.push(value);
|
1043
|
+
}
|
1044
|
+
}
|
1045
|
+
(_b = client.redirectUris) === null || _b === void 0 ? void 0 : _b.sort().reverse();
|
1046
|
+
}
|
1047
|
+
((_c = client.attributes) !== null && _c !== void 0 ? _c : (client.attributes = {}))["post.logout.redirect.uris"] = "+";
|
1048
|
+
client.webOrigins = ["*"];
|
1049
|
+
admin_specific: {
|
1050
|
+
if (clientId !== "security-admin-console") {
|
1051
|
+
break admin_specific;
|
1052
|
+
}
|
1053
|
+
const protocolMapper_preexisting = (_d = client.protocolMappers) === null || _d === void 0 ? void 0 : _d.find(protocolMapper => {
|
1054
|
+
if (protocolMapper.protocolMapper !== "oidc-hardcoded-claim-mapper") {
|
1055
|
+
return false;
|
1056
|
+
}
|
1057
|
+
if (protocolMapper.protocol !== "openid-connect") {
|
1058
|
+
return false;
|
1059
|
+
}
|
1060
|
+
if (protocolMapper.config === undefined) {
|
1061
|
+
return false;
|
1062
|
+
}
|
1063
|
+
if (protocolMapper.config["claim.name"] !== "allowed-origins") {
|
1064
|
+
return false;
|
1065
|
+
}
|
1066
|
+
return true;
|
1067
|
+
});
|
1068
|
+
let protocolMapper;
|
1069
|
+
const config = {
|
1070
|
+
"introspection.token.claim": "true",
|
1071
|
+
"claim.value": '["*"]',
|
1072
|
+
"userinfo.token.claim": "true",
|
1073
|
+
"id.token.claim": "false",
|
1074
|
+
"lightweight.claim": "true",
|
1075
|
+
"access.token.claim": "true",
|
1076
|
+
"claim.name": "allowed-origins",
|
1077
|
+
"jsonType.label": "JSON",
|
1078
|
+
"access.tokenResponse.claim": "false"
|
1079
|
+
};
|
1080
|
+
if (protocolMapper_preexisting !== undefined) {
|
1081
|
+
protocolMapper = protocolMapper_preexisting;
|
1082
|
+
}
|
1083
|
+
else {
|
1084
|
+
protocolMapper = {
|
1085
|
+
id: "8fd0d584-7052-4d04-a615-d18a71050873",
|
1086
|
+
name: "allowed-origins",
|
1087
|
+
protocol: "openid-connect",
|
1088
|
+
protocolMapper: "oidc-hardcoded-claim-mapper",
|
1089
|
+
consentRequired: false,
|
1090
|
+
config
|
1091
|
+
};
|
1092
|
+
((_e = client.protocolMappers) !== null && _e !== void 0 ? _e : (client.protocolMappers = [])).push(protocolMapper);
|
1093
|
+
}
|
1094
|
+
(0,assert/* assert */.h)(protocolMapper.config !== undefined);
|
1095
|
+
if (config !== protocolMapper.config) {
|
1096
|
+
Object.assign(protocolMapper.config, config);
|
1097
|
+
}
|
1098
|
+
}
|
1099
|
+
}
|
1100
|
+
}
|
1101
|
+
//# sourceMappingURL=prepareRealmConfig.js.map
|
1102
|
+
// EXTERNAL MODULE: ./dist/bin/tools/runPrettier.js
|
1103
|
+
var runPrettier = __webpack_require__(48433);
|
1104
|
+
;// CONCATENATED MODULE: ./dist/bin/tools/Stringifyable.js
|
1105
|
+
|
1106
|
+
|
1107
|
+
|
1108
|
+
|
1109
|
+
const zStringifyableAtomic = (() => {
|
1110
|
+
const zTargetType = lib.z.union([lib.z.string(), lib.z.number(), lib.z.boolean(), lib.z["null"]()]);
|
1111
|
+
(0,assert/* assert */.h)();
|
1112
|
+
return (0,id.id)(zTargetType);
|
1113
|
+
})();
|
1114
|
+
const zStringifyable = lib.z.any()
|
1115
|
+
.superRefine((val, ctx) => {
|
1116
|
+
const isStringifyable = (0,same.same)(JSON.parse(JSON.stringify(val)), val);
|
1117
|
+
if (!isStringifyable) {
|
1118
|
+
ctx.addIssue({
|
1119
|
+
code: lib.z.ZodIssueCode.custom,
|
1120
|
+
message: "Not stringifyable"
|
1121
|
+
});
|
1122
|
+
}
|
1123
|
+
});
|
1124
|
+
function getIsAtomic(stringifyable) {
|
1125
|
+
return (["string", "number", "boolean"].includes(typeof stringifyable) ||
|
1126
|
+
stringifyable === null);
|
1127
|
+
}
|
1128
|
+
const { getValueAtPath } = (() => {
|
1129
|
+
function getValueAtPath_rec(stringifyable, path) {
|
1130
|
+
if (path.length === 0) {
|
1131
|
+
return stringifyable;
|
1132
|
+
}
|
1133
|
+
if (getIsAtomic(stringifyable)) {
|
1134
|
+
return undefined;
|
1135
|
+
}
|
1136
|
+
const [first, ...rest] = path;
|
1137
|
+
let dereferenced;
|
1138
|
+
if (stringifyable instanceof Array) {
|
1139
|
+
if (typeof first !== "number") {
|
1140
|
+
return undefined;
|
1141
|
+
}
|
1142
|
+
dereferenced = stringifyable[first];
|
1143
|
+
}
|
1144
|
+
else {
|
1145
|
+
if (typeof first !== "string") {
|
1146
|
+
return undefined;
|
1147
|
+
}
|
1148
|
+
dereferenced = stringifyable[first];
|
1149
|
+
}
|
1150
|
+
if (dereferenced === undefined) {
|
1151
|
+
return undefined;
|
1152
|
+
}
|
1153
|
+
return getValueAtPath_rec(dereferenced, rest);
|
1154
|
+
}
|
1155
|
+
function getValueAtPath(stringifyableObjectOrArray, path) {
|
1156
|
+
return getValueAtPath_rec(stringifyableObjectOrArray, path);
|
1157
|
+
}
|
1158
|
+
return { getValueAtPath };
|
1159
|
+
})();
|
1160
|
+
//# sourceMappingURL=Stringifyable.js.map
|
1161
|
+
;// CONCATENATED MODULE: ./dist/bin/tools/canonicalStringify.js
|
1162
|
+
|
1163
|
+
function canonicalStringify(params) {
|
1164
|
+
const { data, referenceData } = params;
|
1165
|
+
return JSON.stringify(makeDeterministicCopy({
|
1166
|
+
path: [],
|
1167
|
+
data,
|
1168
|
+
getCanonicalKeys: path => {
|
1169
|
+
const referenceValue = (() => {
|
1170
|
+
const path_patched = [];
|
1171
|
+
for (let i = 0; i < path.length; i++) {
|
1172
|
+
let value_i = getValueAtPath(referenceData, [
|
1173
|
+
...path_patched,
|
1174
|
+
path[i]
|
1175
|
+
]);
|
1176
|
+
if (value_i !== undefined) {
|
1177
|
+
path_patched.push(path[i]);
|
1178
|
+
continue;
|
1179
|
+
}
|
1180
|
+
if (typeof path[i] !== "number") {
|
1181
|
+
return undefined;
|
1182
|
+
}
|
1183
|
+
value_i = getValueAtPath(referenceData, [...path_patched, 0]);
|
1184
|
+
if (value_i !== undefined) {
|
1185
|
+
path_patched.push(0);
|
1186
|
+
continue;
|
1187
|
+
}
|
1188
|
+
return undefined;
|
1189
|
+
}
|
1190
|
+
return getValueAtPath(referenceData, path_patched);
|
1191
|
+
})();
|
1192
|
+
if (referenceValue === undefined) {
|
1193
|
+
return undefined;
|
1194
|
+
}
|
1195
|
+
if (getIsAtomic(referenceValue)) {
|
1196
|
+
return undefined;
|
1197
|
+
}
|
1198
|
+
if (referenceValue instanceof Array) {
|
1199
|
+
return undefined;
|
1200
|
+
}
|
1201
|
+
return Object.keys(referenceValue);
|
1202
|
+
}
|
1203
|
+
}), null, 2);
|
1204
|
+
}
|
1205
|
+
function makeDeterministicCopy(params) {
|
1206
|
+
const { path, data, getCanonicalKeys } = params;
|
1207
|
+
if (getIsAtomic(data)) {
|
1208
|
+
return data;
|
1209
|
+
}
|
1210
|
+
if (data instanceof Array) {
|
1211
|
+
return makeDeterministicCopy_array({
|
1212
|
+
path,
|
1213
|
+
data,
|
1214
|
+
getCanonicalKeys
|
1215
|
+
});
|
1216
|
+
}
|
1217
|
+
return makeDeterministicCopy_record({
|
1218
|
+
path,
|
1219
|
+
data,
|
1220
|
+
getCanonicalKeys
|
1221
|
+
});
|
1222
|
+
}
|
1223
|
+
function makeDeterministicCopy_record(params) {
|
1224
|
+
const { path, data, getCanonicalKeys } = params;
|
1225
|
+
const keysOfAtomicValues = [];
|
1226
|
+
const keysOfNonAtomicValues = [];
|
1227
|
+
for (const [key, value] of Object.entries(data)) {
|
1228
|
+
if (getIsAtomic(value)) {
|
1229
|
+
keysOfAtomicValues.push(key);
|
1230
|
+
}
|
1231
|
+
else {
|
1232
|
+
keysOfNonAtomicValues.push(key);
|
1233
|
+
}
|
1234
|
+
}
|
1235
|
+
keysOfAtomicValues.sort();
|
1236
|
+
keysOfNonAtomicValues.sort();
|
1237
|
+
const keys = [...keysOfAtomicValues, ...keysOfNonAtomicValues];
|
1238
|
+
reorder_according_to_canonical: {
|
1239
|
+
const canonicalKeys = getCanonicalKeys(path);
|
1240
|
+
if (canonicalKeys === undefined) {
|
1241
|
+
break reorder_according_to_canonical;
|
1242
|
+
}
|
1243
|
+
const keys_toPrepend = [];
|
1244
|
+
for (const key of canonicalKeys) {
|
1245
|
+
const indexOfKey = keys.indexOf(key);
|
1246
|
+
if (indexOfKey === -1) {
|
1247
|
+
continue;
|
1248
|
+
}
|
1249
|
+
keys.splice(indexOfKey, 1);
|
1250
|
+
keys_toPrepend.push(key);
|
1251
|
+
}
|
1252
|
+
keys.unshift(...keys_toPrepend);
|
1253
|
+
}
|
1254
|
+
const result = {};
|
1255
|
+
for (const key of keys) {
|
1256
|
+
result[key] = makeDeterministicCopy({
|
1257
|
+
path: [...path, key],
|
1258
|
+
data: data[key],
|
1259
|
+
getCanonicalKeys
|
1260
|
+
});
|
1261
|
+
}
|
1262
|
+
return result;
|
1263
|
+
}
|
1264
|
+
function makeDeterministicCopy_array(params) {
|
1265
|
+
const { path, data, getCanonicalKeys } = params;
|
1266
|
+
return [...data].map((entry, i) => makeDeterministicCopy({
|
1267
|
+
path: [...path, i],
|
1268
|
+
data: entry,
|
1269
|
+
getCanonicalKeys
|
1270
|
+
}));
|
1271
|
+
}
|
1272
|
+
//# sourceMappingURL=canonicalStringify.js.map
|
1273
|
+
;// CONCATENATED MODULE: ./dist/bin/start-keycloak/realmConfig/ParsedRealmJson/writeRealmJsonFile.js
|
1274
|
+
|
1275
|
+
|
1276
|
+
|
1277
|
+
|
1278
|
+
async function writeRealmJsonFile(params) {
|
1279
|
+
const { realmJsonFilePath, parsedRealmJson, keycloakMajorVersionNumber } = params;
|
1280
|
+
let sourceCode = canonicalStringify({
|
1281
|
+
data: parsedRealmJson,
|
1282
|
+
referenceData: getDefaultConfig({
|
1283
|
+
keycloakMajorVersionNumber
|
1284
|
+
})
|
1285
|
+
});
|
1286
|
+
if (await (0,runPrettier/* getIsPrettierAvailable */.MT)()) {
|
1287
|
+
sourceCode = await (0,runPrettier/* runPrettier */.eY)({
|
1288
|
+
sourceCode: sourceCode,
|
1289
|
+
filePath: realmJsonFilePath
|
1290
|
+
});
|
1291
|
+
}
|
1292
|
+
await promises_.writeFile(realmJsonFilePath, Buffer.from(sourceCode, "utf8"));
|
1293
|
+
}
|
1294
|
+
//# sourceMappingURL=writeRealmJsonFile.js.map
|
1295
|
+
;// CONCATENATED MODULE: ./dist/bin/start-keycloak/realmConfig/ParsedRealmJson/index.js
|
1296
|
+
|
1297
|
+
|
1298
|
+
//# sourceMappingURL=index.js.map
|
1299
|
+
;// CONCATENATED MODULE: ./dist/bin/start-keycloak/realmConfig/dumpContainerConfig.js
|
1300
|
+
|
1301
|
+
|
1302
|
+
|
1303
|
+
|
1304
|
+
|
1305
|
+
|
1306
|
+
|
1307
|
+
(0,assert/* assert */.h)();
|
1308
|
+
async function dumpContainerConfig(params) {
|
1309
|
+
const { realmName, keycloakMajorVersionNumber, buildContext } = params;
|
1310
|
+
// https://github.com/keycloak/keycloak/issues/33800
|
1311
|
+
const doesUseLockedH2Database = keycloakMajorVersionNumber >= 25;
|
1312
|
+
if (doesUseLockedH2Database) {
|
1313
|
+
const dCompleted = new Deferred.Deferred();
|
1314
|
+
const cmd = `docker exec ${constants/* CONTAINER_NAME */.sv} sh -c "cp -rp /opt/keycloak/data/h2 /tmp"`;
|
1315
|
+
external_child_process_default().exec(cmd, error => {
|
1316
|
+
if (error !== null) {
|
1317
|
+
dCompleted.reject(error);
|
1318
|
+
return;
|
1319
|
+
}
|
1320
|
+
dCompleted.resolve();
|
1321
|
+
});
|
1322
|
+
try {
|
1323
|
+
await dCompleted.pr;
|
1324
|
+
}
|
1325
|
+
catch (error) {
|
1326
|
+
(0,assert/* assert */.h)((0,assert.is)(error));
|
1327
|
+
console.log(source_default().red(`Docker command failed: ${cmd}`));
|
1328
|
+
console.log(source_default().red(error.message));
|
1329
|
+
throw error;
|
1330
|
+
}
|
1331
|
+
}
|
1332
|
+
{
|
1333
|
+
const dCompleted = new Deferred.Deferred();
|
1334
|
+
const child = external_child_process_default().spawn("docker", [
|
1335
|
+
...["exec", constants/* CONTAINER_NAME */.sv],
|
1336
|
+
...["/opt/keycloak/bin/kc.sh", "export"],
|
1337
|
+
...["--dir", "/tmp"],
|
1338
|
+
...["--realm", realmName],
|
1339
|
+
...["--users", "realm_file"],
|
1340
|
+
...(!doesUseLockedH2Database
|
1341
|
+
? []
|
1342
|
+
: [
|
1343
|
+
...["--db", "dev-file"],
|
1344
|
+
...[
|
1345
|
+
"--db-url",
|
1346
|
+
'"jdbc:h2:file:/tmp/h2/keycloakdb;NON_KEYWORDS=VALUE"'
|
1347
|
+
]
|
1348
|
+
])
|
1349
|
+
], { shell: true });
|
1350
|
+
let output = "";
|
1351
|
+
const onExit = (code) => {
|
1352
|
+
dCompleted.reject(new Error(`docker exec kc.sh export command failed with code ${code}`));
|
1353
|
+
};
|
1354
|
+
child.once("exit", onExit);
|
1355
|
+
child.stdout.on("data", data => {
|
1356
|
+
const outputStr = data.toString("utf8");
|
1357
|
+
if (outputStr.includes("Export finished successfully")) {
|
1358
|
+
child.removeListener("exit", onExit);
|
1359
|
+
// NOTE: On older Keycloak versions the process keeps running after the export is done.
|
1360
|
+
const timer = setTimeout(() => {
|
1361
|
+
child.removeListener("exit", onExit2);
|
1362
|
+
child.kill();
|
1363
|
+
dCompleted.resolve();
|
1364
|
+
}, 1500);
|
1365
|
+
const onExit2 = () => {
|
1366
|
+
clearTimeout(timer);
|
1367
|
+
dCompleted.resolve();
|
1368
|
+
};
|
1369
|
+
child.once("exit", onExit2);
|
1370
|
+
}
|
1371
|
+
output += outputStr;
|
1372
|
+
});
|
1373
|
+
child.stderr.on("data", data => (output += source_default().red(data.toString("utf8"))));
|
1374
|
+
try {
|
1375
|
+
await dCompleted.pr;
|
1376
|
+
}
|
1377
|
+
catch (error) {
|
1378
|
+
(0,assert/* assert */.h)((0,assert.is)(error));
|
1379
|
+
console.log(source_default().red(error.message));
|
1380
|
+
console.log(output);
|
1381
|
+
throw error;
|
1382
|
+
}
|
1383
|
+
}
|
1384
|
+
if (doesUseLockedH2Database) {
|
1385
|
+
const dCompleted = new Deferred.Deferred();
|
1386
|
+
const cmd = `docker exec ${constants/* CONTAINER_NAME */.sv} sh -c "rm -rf /tmp/h2"`;
|
1387
|
+
external_child_process_default().exec(cmd, error => {
|
1388
|
+
if (error !== null) {
|
1389
|
+
dCompleted.reject(error);
|
1390
|
+
return;
|
1391
|
+
}
|
1392
|
+
dCompleted.resolve();
|
1393
|
+
});
|
1394
|
+
try {
|
1395
|
+
await dCompleted.pr;
|
1396
|
+
}
|
1397
|
+
catch (error) {
|
1398
|
+
(0,assert/* assert */.h)((0,assert.is)(error));
|
1399
|
+
console.log(source_default().red(`Docker command failed: ${cmd}`));
|
1400
|
+
console.log(source_default().red(error.message));
|
1401
|
+
throw error;
|
1402
|
+
}
|
1403
|
+
}
|
1404
|
+
const targetRealmConfigJsonFilePath_tmp = (0,external_path_.join)(buildContext.cacheDirPath, "realm.json");
|
1405
|
+
{
|
1406
|
+
const dCompleted = new Deferred.Deferred();
|
1407
|
+
const cmd = `docker cp ${constants/* CONTAINER_NAME */.sv}:/tmp/${realmName}-realm.json ${(0,external_path_.basename)(targetRealmConfigJsonFilePath_tmp)}`;
|
1408
|
+
external_child_process_default().exec(cmd, {
|
1409
|
+
cwd: (0,external_path_.dirname)(targetRealmConfigJsonFilePath_tmp)
|
1410
|
+
}, error => {
|
1411
|
+
if (error !== null) {
|
1412
|
+
dCompleted.reject(error);
|
1413
|
+
return;
|
1414
|
+
}
|
1415
|
+
dCompleted.resolve();
|
1416
|
+
});
|
1417
|
+
try {
|
1418
|
+
await dCompleted.pr;
|
1419
|
+
}
|
1420
|
+
catch (error) {
|
1421
|
+
(0,assert/* assert */.h)((0,assert.is)(error));
|
1422
|
+
console.log(source_default().red(`Docker command failed: ${cmd}`));
|
1423
|
+
console.log(source_default().red(error.message));
|
1424
|
+
throw error;
|
1425
|
+
}
|
1426
|
+
}
|
1427
|
+
return readRealmJsonFile({
|
1428
|
+
realmJsonFilePath: targetRealmConfigJsonFilePath_tmp
|
1429
|
+
});
|
1430
|
+
}
|
1431
|
+
//# sourceMappingURL=dumpContainerConfig.js.map
|
1432
|
+
;// CONCATENATED MODULE: ./dist/bin/start-keycloak/realmConfig/realmConfig.js
|
1433
|
+
|
1434
|
+
|
1435
|
+
|
1436
|
+
|
1437
|
+
|
1438
|
+
|
1439
|
+
|
1440
|
+
|
1441
|
+
|
1442
|
+
|
1443
|
+
|
1444
|
+
assert/* assert */.h;
|
1445
|
+
async function getRealmConfig(params) {
|
1446
|
+
const { keycloakMajorVersionNumber, realmJsonFilePath_userProvided, buildContext } = params;
|
1447
|
+
const realmJsonFilePath = (0,external_path_.join)(buildContext.projectDirPath, ".keycloakify", `realm-kc-${keycloakMajorVersionNumber}.json`);
|
1448
|
+
const parsedRealmJson = await (async () => {
|
1449
|
+
if (realmJsonFilePath_userProvided !== undefined) {
|
1450
|
+
return readRealmJsonFile({
|
1451
|
+
realmJsonFilePath: realmJsonFilePath_userProvided
|
1452
|
+
});
|
1453
|
+
}
|
1454
|
+
if (await (0,fs_existsAsync/* existsAsync */.o)(realmJsonFilePath)) {
|
1455
|
+
return readRealmJsonFile({
|
1456
|
+
realmJsonFilePath
|
1457
|
+
});
|
1458
|
+
}
|
1459
|
+
return getDefaultConfig({ keycloakMajorVersionNumber });
|
1460
|
+
})();
|
1461
|
+
const { clientName, realmName, username } = prepareRealmConfig({
|
1462
|
+
parsedRealmJson,
|
1463
|
+
buildContext,
|
1464
|
+
keycloakMajorVersionNumber
|
1465
|
+
});
|
1466
|
+
{
|
1467
|
+
const dirPath = (0,external_path_.dirname)(realmJsonFilePath);
|
1468
|
+
if (!(await (0,fs_existsAsync/* existsAsync */.o)(dirPath))) {
|
1469
|
+
external_fs_.mkdirSync(dirPath, { recursive: true });
|
1470
|
+
}
|
1471
|
+
}
|
1472
|
+
await writeRealmJsonFile({
|
1473
|
+
realmJsonFilePath,
|
1474
|
+
parsedRealmJson,
|
1475
|
+
keycloakMajorVersionNumber
|
1476
|
+
});
|
1477
|
+
const { onRealmConfigChange } = (() => {
|
1478
|
+
const run = runExclusive.build(async () => {
|
1479
|
+
const start = Date.now();
|
1480
|
+
console.log(source_default().grey(`Changes detected to the '${realmName}' config, backing up...`));
|
1481
|
+
let parsedRealmJson;
|
1482
|
+
try {
|
1483
|
+
parsedRealmJson = await dumpContainerConfig({
|
1484
|
+
buildContext,
|
1485
|
+
realmName,
|
1486
|
+
keycloakMajorVersionNumber
|
1487
|
+
});
|
1488
|
+
}
|
1489
|
+
catch (error) {
|
1490
|
+
console.log(source_default().red(`Failed to backup '${realmName}' config:`));
|
1491
|
+
return;
|
1492
|
+
}
|
1493
|
+
await writeRealmJsonFile({
|
1494
|
+
realmJsonFilePath,
|
1495
|
+
parsedRealmJson,
|
1496
|
+
keycloakMajorVersionNumber
|
1497
|
+
});
|
1498
|
+
console.log([
|
1499
|
+
source_default().grey(`Save changed to \`.${external_path_.sep}${(0,external_path_.relative)(buildContext.projectDirPath, realmJsonFilePath)}\``),
|
1500
|
+
source_default().grey(`Next time you'll be running \`keycloakify start-keycloak\`, the realm '${realmName}' will be restored to this state.`),
|
1501
|
+
source_default().green(`✓ '${realmName}' config backed up completed in ${Date.now() - start}ms`)
|
1502
|
+
].join("\n"));
|
1503
|
+
});
|
1504
|
+
const { waitForDebounce } = (0,tools_waitForDebounce/* waitForDebounceFactory */.z)({
|
1505
|
+
delay: 1000
|
1506
|
+
});
|
1507
|
+
async function onRealmConfigChange() {
|
1508
|
+
await waitForDebounce();
|
1509
|
+
run();
|
1510
|
+
}
|
1511
|
+
return { onRealmConfigChange };
|
1512
|
+
})();
|
1513
|
+
return {
|
1514
|
+
realmJsonFilePath,
|
1515
|
+
clientName,
|
1516
|
+
realmName,
|
1517
|
+
username,
|
1518
|
+
onRealmConfigChange
|
1519
|
+
};
|
1520
|
+
}
|
1521
|
+
//# sourceMappingURL=realmConfig.js.map
|
1522
|
+
;// CONCATENATED MODULE: ./dist/bin/start-keycloak/realmConfig/index.js
|
1523
|
+
|
1524
|
+
//# sourceMappingURL=index.js.map
|
1525
|
+
;// CONCATENATED MODULE: ./dist/bin/start-keycloak/start-keycloak.js
|
1526
|
+
|
1527
|
+
|
1528
|
+
|
1529
|
+
|
1530
|
+
|
1531
|
+
|
1532
|
+
|
1533
|
+
|
1534
|
+
|
1535
|
+
|
1536
|
+
|
1537
|
+
|
1538
|
+
|
1539
|
+
|
1540
|
+
|
1541
|
+
|
1542
|
+
|
1543
|
+
|
1544
|
+
|
1545
|
+
|
1546
|
+
|
1547
|
+
|
1548
|
+
|
1549
|
+
|
1550
|
+
|
1551
|
+
async function command(params) {
|
1552
|
+
var _a, _b, _c, _d, _e;
|
1553
|
+
exit_if_docker_not_installed: {
|
1554
|
+
let commandOutput = undefined;
|
1555
|
+
try {
|
1556
|
+
commandOutput = (_a = external_child_process_.execSync("docker --version", {
|
1557
|
+
stdio: ["ignore", "pipe", "ignore"]
|
1558
|
+
})) === null || _a === void 0 ? void 0 : _a.toString("utf8");
|
1559
|
+
}
|
1560
|
+
catch (_f) { }
|
1561
|
+
if ((commandOutput === null || commandOutput === void 0 ? void 0 : commandOutput.includes("Docker")) || (commandOutput === null || commandOutput === void 0 ? void 0 : commandOutput.includes("podman"))) {
|
1562
|
+
break exit_if_docker_not_installed;
|
1563
|
+
}
|
1564
|
+
console.log([
|
1565
|
+
`${source_default().red("Docker required.")}`,
|
1566
|
+
`Install it with Docker Desktop: ${source_default().bold.underline("https://www.docker.com/products/docker-desktop/")}`,
|
1567
|
+
`(or any other way)`
|
1568
|
+
].join(" "));
|
1569
|
+
process.exit(1);
|
1570
|
+
}
|
1571
|
+
exit_if_docker_not_running: {
|
1572
|
+
let isDockerRunning;
|
1573
|
+
try {
|
1574
|
+
external_child_process_.execSync("docker info", { stdio: "ignore" });
|
1575
|
+
isDockerRunning = true;
|
1576
|
+
}
|
1577
|
+
catch (_g) {
|
1578
|
+
isDockerRunning = false;
|
1579
|
+
}
|
1580
|
+
if (isDockerRunning) {
|
1581
|
+
break exit_if_docker_not_running;
|
1582
|
+
}
|
1583
|
+
console.log([
|
1584
|
+
`${source_default().red("Docker daemon is not running.")}`,
|
1585
|
+
`Please start Docker Desktop and try again.`
|
1586
|
+
].join(" "));
|
1587
|
+
process.exit(1);
|
1588
|
+
}
|
1589
|
+
const { cliCommandOptions, buildContext } = params;
|
1590
|
+
const { allSupportedTags, latestMajorTags } = await getSupportedDockerImageTags({
|
43
1591
|
buildContext
|
44
1592
|
});
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
1593
|
+
const { dockerImageTag } = await (async () => {
|
1594
|
+
if (cliCommandOptions.keycloakVersion !== undefined) {
|
1595
|
+
const cliCommandOptions_keycloakVersion = cliCommandOptions.keycloakVersion;
|
1596
|
+
const tag = allSupportedTags.find(tag => tag.startsWith(cliCommandOptions_keycloakVersion));
|
1597
|
+
if (tag === undefined) {
|
1598
|
+
console.log(source_default().red([
|
1599
|
+
`We could not find a Keycloak Docker image for ${cliCommandOptions_keycloakVersion}`,
|
1600
|
+
`Example of valid values: --keycloak-version 26, --keycloak-version 26.0.7`
|
1601
|
+
].join("\n")));
|
1602
|
+
process.exit(1);
|
1603
|
+
}
|
1604
|
+
return { dockerImageTag: tag };
|
1605
|
+
}
|
1606
|
+
if (buildContext.startKeycloakOptions.dockerImage !== undefined) {
|
1607
|
+
return {
|
1608
|
+
dockerImageTag: buildContext.startKeycloakOptions.dockerImage.tag
|
1609
|
+
};
|
1610
|
+
}
|
1611
|
+
console.log([
|
1612
|
+
source_default().cyan("On which version of Keycloak do you want to test your theme?"),
|
1613
|
+
source_default().gray("You can also explicitly provide the version with `npx keycloakify start-keycloak --keycloak-version 26` (or any other version)")
|
1614
|
+
].join("\n"));
|
1615
|
+
const tag_userSelected = await (async () => {
|
1616
|
+
let tag;
|
1617
|
+
let latestMajorTags_copy = [...latestMajorTags];
|
1618
|
+
while (true) {
|
1619
|
+
const { value } = await dist_default()({
|
1620
|
+
values: latestMajorTags_copy
|
1621
|
+
}).catch(() => {
|
1622
|
+
process.exit(-1);
|
1623
|
+
});
|
1624
|
+
tag = value;
|
1625
|
+
{
|
1626
|
+
const doImplementAccountMpa = buildContext.implementedThemeTypes.account.isImplemented &&
|
1627
|
+
buildContext.implementedThemeTypes.account.type === "Multi-Page";
|
1628
|
+
if (doImplementAccountMpa && tag.startsWith("22.")) {
|
1629
|
+
console.log(source_default().yellow(`You are implementing a Multi-Page Account theme. Keycloak 22 is not supported, select another version`));
|
1630
|
+
latestMajorTags_copy = latestMajorTags_copy.filter(tag => !tag.startsWith("22."));
|
1631
|
+
continue;
|
1632
|
+
}
|
1633
|
+
}
|
1634
|
+
const readMajor = (tag) => {
|
1635
|
+
const major = parseInt(tag.split(".")[0]);
|
1636
|
+
(0,assert/* assert */.h)(!isNaN(major));
|
1637
|
+
return major;
|
1638
|
+
};
|
1639
|
+
{
|
1640
|
+
const major = readMajor(tag);
|
1641
|
+
const doImplementAdminTheme = buildContext.implementedThemeTypes.admin.isImplemented;
|
1642
|
+
const getIsSupported = (major) => major >= 23;
|
1643
|
+
if (doImplementAdminTheme && !getIsSupported(major)) {
|
1644
|
+
console.log(source_default().yellow(`You are implementing an Admin theme. Only Keycloak 23 and later are supported, select another version`));
|
1645
|
+
latestMajorTags_copy = latestMajorTags_copy.filter(tag => getIsSupported(readMajor(tag)));
|
1646
|
+
continue;
|
1647
|
+
}
|
1648
|
+
}
|
1649
|
+
{
|
1650
|
+
const doImplementAccountSpa = buildContext.implementedThemeTypes.account.isImplemented &&
|
1651
|
+
buildContext.implementedThemeTypes.account.type === "Single-Page";
|
1652
|
+
const major = readMajor(tag);
|
1653
|
+
const getIsSupported = (major) => major >= 19;
|
1654
|
+
if (doImplementAccountSpa && !getIsSupported(major)) {
|
1655
|
+
console.log(source_default().yellow(`You are implementing a Single-Page Account theme. Only Keycloak 19 and later are supported, select another version`));
|
1656
|
+
latestMajorTags_copy = latestMajorTags_copy.filter(tag => getIsSupported(readMajor(tag)));
|
1657
|
+
continue;
|
1658
|
+
}
|
1659
|
+
}
|
1660
|
+
break;
|
1661
|
+
}
|
1662
|
+
return tag;
|
1663
|
+
})();
|
1664
|
+
console.log(`→ ${tag_userSelected}`);
|
1665
|
+
return { dockerImageTag: tag_userSelected };
|
71
1666
|
})();
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
|
1667
|
+
const keycloakMajorVersionNumber = (() => {
|
1668
|
+
const [wrap] = getSupportedKeycloakMajorVersions()
|
1669
|
+
.map(majorVersionNumber => ({
|
1670
|
+
majorVersionNumber,
|
1671
|
+
index: dockerImageTag.indexOf(`${majorVersionNumber}`)
|
1672
|
+
}))
|
1673
|
+
.filter(({ index }) => index !== -1)
|
1674
|
+
.sort((a, b) => a.index - b.index);
|
1675
|
+
if (wrap === undefined) {
|
1676
|
+
try {
|
1677
|
+
const version = SemVer/* SemVer.parse */.h.parse(dockerImageTag);
|
1678
|
+
console.error(source_default().yellow(`Keycloak version ${version.major} is not supported, supported versions are ${getSupportedKeycloakMajorVersions().join(", ")}`));
|
1679
|
+
process.exit(1);
|
1680
|
+
}
|
1681
|
+
catch (_a) {
|
1682
|
+
// NOTE: Latest version
|
1683
|
+
const [n] = getSupportedKeycloakMajorVersions();
|
1684
|
+
console.warn(source_default().yellow(`Could not determine the major Keycloak version number from the docker image tag ${dockerImageTag}. Assuming ${n}`));
|
1685
|
+
return n;
|
1686
|
+
}
|
1687
|
+
}
|
1688
|
+
return wrap.majorVersionNumber;
|
1689
|
+
})();
|
1690
|
+
const { clientName, onRealmConfigChange, realmJsonFilePath, realmName, username } = await getRealmConfig({
|
1691
|
+
keycloakMajorVersionNumber,
|
1692
|
+
realmJsonFilePath_userProvided: await (async () => {
|
1693
|
+
if (cliCommandOptions.realmJsonFilePath !== undefined) {
|
1694
|
+
return (0,getAbsoluteAndInOsFormatPath/* getAbsoluteAndInOsFormatPath */.c)({
|
1695
|
+
pathIsh: cliCommandOptions.realmJsonFilePath,
|
1696
|
+
cwd: process.cwd()
|
1697
|
+
});
|
1698
|
+
}
|
1699
|
+
if (buildContext.startKeycloakOptions.realmJsonFilePath !== undefined) {
|
1700
|
+
(0,assert/* assert */.h)(await (0,fs_existsAsync/* existsAsync */.o)(buildContext.startKeycloakOptions.realmJsonFilePath), `${(0,external_path_.relative)(process.cwd(), buildContext.startKeycloakOptions.realmJsonFilePath)} does not exist`);
|
1701
|
+
return buildContext.startKeycloakOptions.realmJsonFilePath;
|
1702
|
+
}
|
1703
|
+
return undefined;
|
1704
|
+
})(),
|
1705
|
+
buildContext
|
98
1706
|
});
|
99
|
-
|
100
|
-
|
101
|
-
|
102
|
-
|
103
|
-
|
104
|
-
|
105
|
-
|
106
|
-
let sourceCode = fs__WEBPACK_IMPORTED_MODULE_3__.readFileSync((0,path__WEBPACK_IMPORTED_MODULE_4__.join)((0,_tools_getThisCodebaseRootDirPath__WEBPACK_IMPORTED_MODULE_0__/* .getThisCodebaseRootDirPath */ .e)(), "stories", themeType, "pages", componentBasename))
|
107
|
-
.toString("utf8")
|
108
|
-
.replace('import React from "react";\n', "")
|
109
|
-
.replace(/from "[./]+dist\//, 'from "keycloakify/');
|
110
|
-
run_prettier: {
|
111
|
-
if (!(await (0,_tools_runPrettier__WEBPACK_IMPORTED_MODULE_7__/* .getIsPrettierAvailable */ .MT)())) {
|
112
|
-
break run_prettier;
|
1707
|
+
{
|
1708
|
+
const { isAppBuildSuccess } = await appBuild({
|
1709
|
+
buildContext
|
1710
|
+
});
|
1711
|
+
if (!isAppBuildSuccess) {
|
1712
|
+
console.log(source_default().red(`App build failed, exiting. Try building your app (e.g 'npm run build') and see what's wrong.`));
|
1713
|
+
process.exit(1);
|
113
1714
|
}
|
114
|
-
|
115
|
-
|
116
|
-
|
1715
|
+
const { isKeycloakifyBuildSuccess } = await keycloakifyBuild({
|
1716
|
+
buildForKeycloakMajorVersionNumber: keycloakMajorVersionNumber,
|
1717
|
+
buildContext
|
1718
|
+
});
|
1719
|
+
if (!isKeycloakifyBuildSuccess) {
|
1720
|
+
console.log(source_default().red(`Keycloakify build failed, exiting. Try running 'npx keycloakify build' and see what's wrong.`));
|
1721
|
+
process.exit(1);
|
1722
|
+
}
|
1723
|
+
}
|
1724
|
+
const jarFilePath = external_fs_.readdirSync(buildContext.keycloakifyBuildDirPath)
|
1725
|
+
.filter(fileBasename => fileBasename.endsWith(".jar"))
|
1726
|
+
.map(fileBasename => (0,external_path_.join)(buildContext.keycloakifyBuildDirPath, fileBasename))
|
1727
|
+
.sort((a, b) => external_fs_.statSync(b).mtimeMs - external_fs_.statSync(a).mtimeMs)[0];
|
1728
|
+
(0,assert/* assert */.h)(jarFilePath !== undefined);
|
1729
|
+
const extensionJarFilePaths = [
|
1730
|
+
...(keycloakMajorVersionNumber <= 20
|
1731
|
+
? (console.log(source_default().yellow("WARNING: With older version of keycloak your changes to the realm configuration are not persisted")),
|
1732
|
+
[])
|
1733
|
+
: [
|
1734
|
+
(0,external_path_.join)((0,getThisCodebaseRootDirPath/* getThisCodebaseRootDirPath */.e)(), "src", "bin", "start-keycloak", constants/* KEYCLOAKIFY_LOGIN_JAR_BASENAME */.Tr)
|
1735
|
+
]),
|
1736
|
+
...(await Promise.all(buildContext.startKeycloakOptions.extensionJars.map(async (extensionJar) => {
|
1737
|
+
switch (extensionJar.type) {
|
1738
|
+
case "path": {
|
1739
|
+
(0,assert/* assert */.h)(await (0,fs_existsAsync/* existsAsync */.o)(extensionJar.path), `${extensionJar.path} does not exist`);
|
1740
|
+
return extensionJar.path;
|
1741
|
+
}
|
1742
|
+
case "url": {
|
1743
|
+
const { archiveFilePath } = await downloadAndExtractArchive({
|
1744
|
+
cacheDirPath: buildContext.cacheDirPath,
|
1745
|
+
fetchOptions: buildContext.fetchOptions,
|
1746
|
+
url: extensionJar.url,
|
1747
|
+
uniqueIdOfOnArchiveFile: "no extraction",
|
1748
|
+
onArchiveFile: async () => { }
|
1749
|
+
});
|
1750
|
+
return archiveFilePath;
|
1751
|
+
}
|
1752
|
+
}
|
1753
|
+
(0,assert/* assert */.h)(false);
|
1754
|
+
})))
|
1755
|
+
];
|
1756
|
+
async function extractThemeResourcesFromJar() {
|
1757
|
+
await extractArchive({
|
1758
|
+
archiveFilePath: jarFilePath,
|
1759
|
+
onArchiveFile: async ({ relativeFilePathInArchive, writeFile }) => {
|
1760
|
+
if ((0,isInside/* isInside */.V)({ dirPath: "theme", filePath: relativeFilePathInArchive })) {
|
1761
|
+
await writeFile({
|
1762
|
+
filePath: (0,external_path_.join)(buildContext.keycloakifyBuildDirPath, relativeFilePathInArchive)
|
1763
|
+
});
|
1764
|
+
}
|
1765
|
+
}
|
117
1766
|
});
|
118
1767
|
}
|
119
1768
|
{
|
120
|
-
const
|
121
|
-
if (
|
122
|
-
|
1769
|
+
const destDirPath = (0,external_path_.join)(buildContext.keycloakifyBuildDirPath, "theme");
|
1770
|
+
if (await (0,fs_existsAsync/* existsAsync */.o)(destDirPath)) {
|
1771
|
+
await rm(destDirPath, { recursive: true });
|
1772
|
+
}
|
1773
|
+
}
|
1774
|
+
await extractThemeResourcesFromJar();
|
1775
|
+
const jarFilePath_cacheDir = (0,external_path_.join)(buildContext.cacheDirPath, (0,external_path_.basename)(jarFilePath));
|
1776
|
+
external_fs_.copyFileSync(jarFilePath, jarFilePath_cacheDir);
|
1777
|
+
try {
|
1778
|
+
external_child_process_.execSync(`docker rm --force ${constants/* CONTAINER_NAME */.sv}`, {
|
1779
|
+
stdio: "ignore"
|
1780
|
+
});
|
1781
|
+
}
|
1782
|
+
catch (_h) { }
|
1783
|
+
const port = (_c = (_b = cliCommandOptions.port) !== null && _b !== void 0 ? _b : buildContext.startKeycloakOptions.port) !== null && _c !== void 0 ? _c : 8080;
|
1784
|
+
const doStartDevServer = (() => {
|
1785
|
+
const hasSpaUi = buildContext.implementedThemeTypes.admin.isImplemented ||
|
1786
|
+
(buildContext.implementedThemeTypes.account.isImplemented &&
|
1787
|
+
buildContext.implementedThemeTypes.account.type === "Single-Page");
|
1788
|
+
if (!hasSpaUi) {
|
1789
|
+
return false;
|
1790
|
+
}
|
1791
|
+
if (buildContext.bundler !== "vite") {
|
1792
|
+
console.log(source_default().yellow([
|
1793
|
+
`WARNING: Since you are using ${buildContext.bundler} instead of Vite,`,
|
1794
|
+
`you'll have to wait serval seconds for the changes you made on your account or admin theme to be reflected in the browser.\n`,
|
1795
|
+
`For a better development experience, consider migrating to Vite.`
|
1796
|
+
].join(" ")));
|
1797
|
+
return false;
|
1798
|
+
}
|
1799
|
+
if (keycloakMajorVersionNumber < 25) {
|
1800
|
+
console.log(source_default().yellow([
|
1801
|
+
`WARNING: Your account or admin theme can't be tested with hot module replacement on Keycloak ${keycloakMajorVersionNumber}.`,
|
1802
|
+
`This mean that you'll have to wait serval seconds for the changes to be reflected in the browser.`,
|
1803
|
+
`For a better development experience, select a more recent version of Keycloak.`
|
1804
|
+
].join("\n")));
|
1805
|
+
return false;
|
123
1806
|
}
|
1807
|
+
return true;
|
1808
|
+
})();
|
1809
|
+
let devServerPort = undefined;
|
1810
|
+
if (doStartDevServer) {
|
1811
|
+
const { port } = await startViteDevServer({ buildContext });
|
1812
|
+
devServerPort = port;
|
1813
|
+
}
|
1814
|
+
const SPACE_PLACEHOLDER = "SPACE_PLACEHOLDER_xKLmdPd";
|
1815
|
+
const dockerRunArgs = [
|
1816
|
+
`-p${SPACE_PLACEHOLDER}${port}:8080`,
|
1817
|
+
`--name${SPACE_PLACEHOLDER}${constants/* CONTAINER_NAME */.sv}`,
|
1818
|
+
...(keycloakMajorVersionNumber >= 26
|
1819
|
+
? [
|
1820
|
+
`-e${SPACE_PLACEHOLDER}KC_BOOTSTRAP_ADMIN_USERNAME=admin`,
|
1821
|
+
`-e${SPACE_PLACEHOLDER}KC_BOOTSTRAP_ADMIN_PASSWORD=admin`
|
1822
|
+
]
|
1823
|
+
: [
|
1824
|
+
`-e${SPACE_PLACEHOLDER}KEYCLOAK_ADMIN=admin`,
|
1825
|
+
`-e${SPACE_PLACEHOLDER}KEYCLOAK_ADMIN_PASSWORD=admin`
|
1826
|
+
]),
|
1827
|
+
...(devServerPort === undefined
|
1828
|
+
? []
|
1829
|
+
: [
|
1830
|
+
`-e${SPACE_PLACEHOLDER}${constants/* KEYCLOAKIFY_SPA_DEV_SERVER_PORT */.Sz}=${devServerPort}`
|
1831
|
+
]),
|
1832
|
+
...(buildContext.startKeycloakOptions.dockerExtraArgs.length === 0
|
1833
|
+
? []
|
1834
|
+
: [
|
1835
|
+
buildContext.startKeycloakOptions.dockerExtraArgs.join(SPACE_PLACEHOLDER)
|
1836
|
+
]),
|
1837
|
+
...(realmJsonFilePath === undefined
|
1838
|
+
? []
|
1839
|
+
: [
|
1840
|
+
`-v${SPACE_PLACEHOLDER}"${realmJsonFilePath}":/opt/keycloak/data/import/${realmName}-realm.json`
|
1841
|
+
]),
|
1842
|
+
`-v${SPACE_PLACEHOLDER}"${jarFilePath_cacheDir}":/opt/keycloak/providers/keycloak-theme.jar`,
|
1843
|
+
...extensionJarFilePaths.map(jarFilePath => `-v${SPACE_PLACEHOLDER}"${jarFilePath}":/opt/keycloak/providers/${(0,external_path_.basename)(jarFilePath)}`),
|
1844
|
+
...(keycloakMajorVersionNumber <= 20
|
1845
|
+
? [`-e${SPACE_PLACEHOLDER}JAVA_OPTS=-Dkeycloak.profile=preview`]
|
1846
|
+
: []),
|
1847
|
+
...[
|
1848
|
+
...buildContext.themeNames,
|
1849
|
+
...(external_fs_.existsSync((0,external_path_.join)(buildContext.keycloakifyBuildDirPath, "theme", "account-v1"))
|
1850
|
+
? ["account-v1"]
|
1851
|
+
: [])
|
1852
|
+
]
|
1853
|
+
.map(themeName => ({
|
1854
|
+
localDirPath: (0,external_path_.join)(buildContext.keycloakifyBuildDirPath, "theme", themeName),
|
1855
|
+
containerDirPath: `/opt/keycloak/themes/${themeName}`
|
1856
|
+
}))
|
1857
|
+
.map(({ localDirPath, containerDirPath }) => `-v${SPACE_PLACEHOLDER}"${localDirPath}":${containerDirPath}:rw`),
|
1858
|
+
...buildContext.environmentVariables
|
1859
|
+
.map(({ name }) => ({ name, envValue: process.env[name] }))
|
1860
|
+
.map(({ name, envValue }) => envValue === undefined ? undefined : { name, envValue })
|
1861
|
+
.filter((0,exclude/* exclude */.D)(undefined))
|
1862
|
+
.map(({ name, envValue }) => `--env${SPACE_PLACEHOLDER}${name}='${envValue.replace(/'/g, "'\\''")}'`),
|
1863
|
+
`${(_e = (_d = buildContext.startKeycloakOptions.dockerImage) === null || _d === void 0 ? void 0 : _d.reference) !== null && _e !== void 0 ? _e : "quay.io/keycloak/keycloak"}:${dockerImageTag}`,
|
1864
|
+
"start-dev",
|
1865
|
+
...(21 <= keycloakMajorVersionNumber && keycloakMajorVersionNumber < 24
|
1866
|
+
? ["--features=declarative-user-profile"]
|
1867
|
+
: []),
|
1868
|
+
...(realmJsonFilePath === undefined ? [] : ["--import-realm"]),
|
1869
|
+
...(buildContext.startKeycloakOptions.keycloakExtraArgs.length === 0
|
1870
|
+
? []
|
1871
|
+
: [
|
1872
|
+
buildContext.startKeycloakOptions.keycloakExtraArgs.join(SPACE_PLACEHOLDER)
|
1873
|
+
])
|
1874
|
+
];
|
1875
|
+
console.log(source_default().blue([
|
1876
|
+
`$ docker run \\`,
|
1877
|
+
...dockerRunArgs
|
1878
|
+
.map(arg => arg.replace(new RegExp(SPACE_PLACEHOLDER, "g"), " "))
|
1879
|
+
.map((line, i, arr) => ` ${line}${arr.length - 1 === i ? "" : " \\"}`)
|
1880
|
+
].join("\n")));
|
1881
|
+
const child = external_child_process_.spawn("docker", ["run", ...dockerRunArgs.map(line => line.split(SPACE_PLACEHOLDER)).flat()], { shell: true });
|
1882
|
+
child.stdout.on("data", async (data) => {
|
1883
|
+
if (data.toString("utf8").includes("keycloakify-logging: REALM_CONFIG_CHANGED")) {
|
1884
|
+
await onRealmConfigChange();
|
1885
|
+
return;
|
1886
|
+
}
|
1887
|
+
process.stdout.write(data);
|
1888
|
+
});
|
1889
|
+
child.stderr.on("data", data => process.stderr.write(data));
|
1890
|
+
child.on("exit", process.exit);
|
1891
|
+
const srcDirPath = (0,external_path_.join)(buildContext.projectDirPath, "src");
|
1892
|
+
{
|
1893
|
+
const kcHttpRelativePath = (() => {
|
1894
|
+
const match = buildContext.startKeycloakOptions.dockerExtraArgs
|
1895
|
+
.join(" ")
|
1896
|
+
.match(/KC_HTTP_RELATIVE_PATH=([^ ]+)/);
|
1897
|
+
if (match === null) {
|
1898
|
+
return undefined;
|
1899
|
+
}
|
1900
|
+
return match[1];
|
1901
|
+
})();
|
1902
|
+
const handler = async (data) => {
|
1903
|
+
if (!data.toString("utf8").includes("Listening on: http://0.0.0.0:8080")) {
|
1904
|
+
return;
|
1905
|
+
}
|
1906
|
+
child.stdout.off("data", handler);
|
1907
|
+
await new Promise(resolve => setTimeout(resolve, 1000));
|
1908
|
+
console.log([
|
1909
|
+
"",
|
1910
|
+
`The ftl files from ${source_default().bold(`.${external_path_.sep}${(0,external_path_.relative)(process.cwd(), (0,external_path_.join)(buildContext.keycloakifyBuildDirPath, "theme"))}`)} are mounted in the Keycloak container.`,
|
1911
|
+
"",
|
1912
|
+
`Keycloak Admin console: ${source_default().cyan.bold(`http://localhost:${port}${kcHttpRelativePath !== null && kcHttpRelativePath !== void 0 ? kcHttpRelativePath : ""}`)}`,
|
1913
|
+
`- user: ${source_default().cyan.bold("admin")}`,
|
1914
|
+
`- password: ${source_default().cyan.bold("admin")}`,
|
1915
|
+
"",
|
1916
|
+
"",
|
1917
|
+
`${source_default().green("Your theme is accessible at:")}`,
|
1918
|
+
`${source_default().green("➜")} ${source_default().cyan.bold((() => {
|
1919
|
+
const url = new URL(constants/* TEST_APP_URL */.jp);
|
1920
|
+
if (port !== 8080) {
|
1921
|
+
url.searchParams.set("port", `${port}`);
|
1922
|
+
}
|
1923
|
+
if (kcHttpRelativePath !== undefined) {
|
1924
|
+
url.searchParams.set("kcHttpRelativePath", kcHttpRelativePath);
|
1925
|
+
}
|
1926
|
+
if (realmName !== "myrealm") {
|
1927
|
+
url.searchParams.set("realm", realmName);
|
1928
|
+
}
|
1929
|
+
if (clientName !== "myclient") {
|
1930
|
+
url.searchParams.set("client", clientName);
|
1931
|
+
}
|
1932
|
+
return url.href;
|
1933
|
+
})())}`,
|
1934
|
+
"",
|
1935
|
+
"You can login with the following credentials:",
|
1936
|
+
`- username: ${source_default().cyan.bold(username)}`,
|
1937
|
+
`- password: ${source_default().cyan.bold("password123")}`,
|
1938
|
+
"",
|
1939
|
+
`Watching for changes in ${source_default().bold(`.${external_path_.sep}${(0,external_path_.relative)(process.cwd(), buildContext.projectDirPath)}`)}`
|
1940
|
+
].join("\n"));
|
1941
|
+
};
|
1942
|
+
child.stdout.on("data", handler);
|
1943
|
+
}
|
1944
|
+
{
|
1945
|
+
const runFullBuild = runExclusive.build(async () => {
|
1946
|
+
console.log(source_default().cyan("Detected changes in the theme. Rebuilding ..."));
|
1947
|
+
const { isAppBuildSuccess } = await appBuild({
|
1948
|
+
buildContext
|
1949
|
+
});
|
1950
|
+
if (!isAppBuildSuccess) {
|
1951
|
+
return;
|
1952
|
+
}
|
1953
|
+
const { isKeycloakifyBuildSuccess } = await keycloakifyBuild({
|
1954
|
+
buildForKeycloakMajorVersionNumber: keycloakMajorVersionNumber,
|
1955
|
+
buildContext
|
1956
|
+
});
|
1957
|
+
if (!isKeycloakifyBuildSuccess) {
|
1958
|
+
return;
|
1959
|
+
}
|
1960
|
+
await extractThemeResourcesFromJar();
|
1961
|
+
console.log(source_default().green("Theme rebuilt and updated in Keycloak."));
|
1962
|
+
});
|
1963
|
+
const { waitForDebounce } = (0,tools_waitForDebounce/* waitForDebounceFactory */.z)({ delay: 400 });
|
1964
|
+
chokidar.watch([
|
1965
|
+
srcDirPath,
|
1966
|
+
buildContext.publicDirPath,
|
1967
|
+
(0,external_path_.join)(buildContext.projectDirPath, "package.json"),
|
1968
|
+
(0,external_path_.join)(buildContext.projectDirPath, "vite.config.ts"),
|
1969
|
+
(0,external_path_.join)(buildContext.projectDirPath, "vite.config.js"),
|
1970
|
+
(0,external_path_.join)(buildContext.projectDirPath, "index.html"),
|
1971
|
+
(0,external_path_.join)((0,getThisCodebaseRootDirPath/* getThisCodebaseRootDirPath */.e)(), "src")
|
1972
|
+
], {
|
1973
|
+
ignoreInitial: true
|
1974
|
+
})
|
1975
|
+
.on("all", async (...[, filePath]) => {
|
1976
|
+
ignore_path_covered_by_hmr: {
|
1977
|
+
if (filePath.endsWith(".properties")) {
|
1978
|
+
break ignore_path_covered_by_hmr;
|
1979
|
+
}
|
1980
|
+
if (!doStartDevServer) {
|
1981
|
+
break ignore_path_covered_by_hmr;
|
1982
|
+
}
|
1983
|
+
ignore_account_spa: {
|
1984
|
+
const doImplementAccountSpa = buildContext.implementedThemeTypes.account.isImplemented &&
|
1985
|
+
buildContext.implementedThemeTypes.account.type ===
|
1986
|
+
"Single-Page";
|
1987
|
+
if (!doImplementAccountSpa) {
|
1988
|
+
break ignore_account_spa;
|
1989
|
+
}
|
1990
|
+
if (!(0,isInside/* isInside */.V)({
|
1991
|
+
dirPath: (0,external_path_.join)(buildContext.themeSrcDirPath, "account"),
|
1992
|
+
filePath
|
1993
|
+
})) {
|
1994
|
+
break ignore_account_spa;
|
1995
|
+
}
|
1996
|
+
return;
|
1997
|
+
}
|
1998
|
+
ignore_admin: {
|
1999
|
+
if (!buildContext.implementedThemeTypes.admin.isImplemented) {
|
2000
|
+
break ignore_admin;
|
2001
|
+
}
|
2002
|
+
if (!(0,isInside/* isInside */.V)({
|
2003
|
+
dirPath: (0,external_path_.join)(buildContext.themeSrcDirPath, "admin"),
|
2004
|
+
filePath
|
2005
|
+
})) {
|
2006
|
+
break ignore_admin;
|
2007
|
+
}
|
2008
|
+
return;
|
2009
|
+
}
|
2010
|
+
}
|
2011
|
+
console.log(`Detected changes in ${filePath}`);
|
2012
|
+
await waitForDebounce();
|
2013
|
+
runFullBuild();
|
2014
|
+
});
|
124
2015
|
}
|
125
|
-
fs__WEBPACK_IMPORTED_MODULE_3__.writeFileSync(targetFilePath, Buffer.from(sourceCode, "utf8"));
|
126
|
-
console.log([
|
127
|
-
`${chalk__WEBPACK_IMPORTED_MODULE_6___default().green("✓")} ${chalk__WEBPACK_IMPORTED_MODULE_6___default().bold((0,path__WEBPACK_IMPORTED_MODULE_4__.join)(".", (0,path__WEBPACK_IMPORTED_MODULE_4__.relative)(process.cwd(), targetFilePath)))} copy pasted from the Keycloakify source code into your project`,
|
128
|
-
`You can start storybook with ${chalk__WEBPACK_IMPORTED_MODULE_6___default().bold("npm run storybook")}`
|
129
|
-
].join("\n"));
|
130
2016
|
}
|
131
|
-
//# sourceMappingURL=
|
2017
|
+
//# sourceMappingURL=start-keycloak.js.map
|
2018
|
+
;// CONCATENATED MODULE: ./dist/bin/start-keycloak/index.js
|
2019
|
+
|
2020
|
+
//# sourceMappingURL=index.js.map
|
132
2021
|
|
133
2022
|
/***/ }),
|
134
2023
|
|
135
|
-
/***/
|
2024
|
+
/***/ 12171:
|
136
2025
|
/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
|
137
2026
|
|
2027
|
+
/* harmony export */ __webpack_require__.d(__webpack_exports__, {
|
2028
|
+
/* harmony export */ "h": () => (/* binding */ SemVer)
|
2029
|
+
/* harmony export */ });
|
2030
|
+
var SemVer;
|
2031
|
+
(function (SemVer) {
|
2032
|
+
const bumpTypes = ["major", "minor", "patch", "rc", "no bump"];
|
2033
|
+
function parse(versionStr) {
|
2034
|
+
const match = versionStr.match(/^v?([0-9]+)\.([0-9]+)(?:\.([0-9]+))?(?:-rc.([0-9]+))?$/);
|
2035
|
+
if (!match) {
|
2036
|
+
throw new Error(`${versionStr} is not a valid semantic version`);
|
2037
|
+
}
|
2038
|
+
const semVer = Object.assign({ major: parseInt(match[1]), minor: parseInt(match[2]), patch: (() => {
|
2039
|
+
const str = match[3];
|
2040
|
+
return str === undefined ? 0 : parseInt(str);
|
2041
|
+
})() }, (() => {
|
2042
|
+
const str = match[4];
|
2043
|
+
return str === undefined ? {} : { rc: parseInt(str) };
|
2044
|
+
})());
|
2045
|
+
const initialStr = stringify(semVer);
|
2046
|
+
Object.defineProperty(semVer, "parsedFrom", {
|
2047
|
+
enumerable: true,
|
2048
|
+
get: function () {
|
2049
|
+
const currentStr = stringify(this);
|
2050
|
+
if (currentStr !== initialStr) {
|
2051
|
+
throw new Error(`SemVer.parsedFrom can't be read anymore, the version have been modified from ${initialStr} to ${currentStr}`);
|
2052
|
+
}
|
2053
|
+
return versionStr;
|
2054
|
+
}
|
2055
|
+
});
|
2056
|
+
return semVer;
|
2057
|
+
}
|
2058
|
+
SemVer.parse = parse;
|
2059
|
+
function stringify(v) {
|
2060
|
+
return `${v.major}.${v.minor}.${v.patch}${v.rc === undefined ? "" : `-rc.${v.rc}`}`;
|
2061
|
+
}
|
2062
|
+
SemVer.stringify = stringify;
|
2063
|
+
/**
|
2064
|
+
*
|
2065
|
+
* v1 < v2 => -1
|
2066
|
+
* v1 === v2 => 0
|
2067
|
+
* v1 > v2 => 1
|
2068
|
+
*
|
2069
|
+
*/
|
2070
|
+
function compare(v1, v2) {
|
2071
|
+
const sign = (diff) => (diff === 0 ? 0 : diff < 0 ? -1 : 1);
|
2072
|
+
const noUndefined = (n) => n !== null && n !== void 0 ? n : Infinity;
|
2073
|
+
for (const level of ["major", "minor", "patch", "rc"]) {
|
2074
|
+
if (noUndefined(v1[level]) !== noUndefined(v2[level])) {
|
2075
|
+
return sign(noUndefined(v1[level]) - noUndefined(v2[level]));
|
2076
|
+
}
|
2077
|
+
}
|
2078
|
+
return 0;
|
2079
|
+
}
|
2080
|
+
SemVer.compare = compare;
|
2081
|
+
/*
|
2082
|
+
console.log(compare(parse("3.0.0-rc.3"), parse("3.0.0")) === -1 )
|
2083
|
+
console.log(compare(parse("3.0.0-rc.3"), parse("3.0.0-rc.4")) === -1 )
|
2084
|
+
console.log(compare(parse("3.0.0-rc.3"), parse("4.0.0")) === -1 )
|
2085
|
+
*/
|
2086
|
+
function bumpType(params) {
|
2087
|
+
const versionAhead = typeof params.versionAhead === "string"
|
2088
|
+
? parse(params.versionAhead)
|
2089
|
+
: params.versionAhead;
|
2090
|
+
const versionBehind = typeof params.versionBehind === "string"
|
2091
|
+
? parse(params.versionBehind)
|
2092
|
+
: params.versionBehind;
|
2093
|
+
if (compare(versionBehind, versionAhead) === 1) {
|
2094
|
+
throw new Error(`Version regression ${stringify(versionBehind)} -> ${stringify(versionAhead)}`);
|
2095
|
+
}
|
2096
|
+
for (const level of ["major", "minor", "patch", "rc"]) {
|
2097
|
+
if (versionBehind[level] !== versionAhead[level]) {
|
2098
|
+
return level;
|
2099
|
+
}
|
2100
|
+
}
|
2101
|
+
return "no bump";
|
2102
|
+
}
|
2103
|
+
SemVer.bumpType = bumpType;
|
2104
|
+
})(SemVer || (SemVer = {}));
|
2105
|
+
//# sourceMappingURL=SemVer.js.map
|
138
2106
|
|
139
|
-
|
140
|
-
__webpack_require__.d(__webpack_exports__, {
|
141
|
-
"q": () => (/* binding */ maybeDelegateCommandToCustomHandler)
|
142
|
-
});
|
143
|
-
|
144
|
-
// EXTERNAL MODULE: ./node_modules/tsafe/esm/assert.mjs + 1 modules
|
145
|
-
var esm_assert = __webpack_require__(29041);
|
146
|
-
// EXTERNAL MODULE: ./dist/bin/shared/constants.js
|
147
|
-
var constants = __webpack_require__(173);
|
148
|
-
;// CONCATENATED MODULE: ./dist/bin/shared/customHandler.js
|
149
|
-
|
150
|
-
|
151
|
-
const BIN_NAME = "_keycloakify-custom-handler";
|
152
|
-
const NOT_IMPLEMENTED_EXIT_CODE = 78;
|
153
|
-
function readParams(params) {
|
154
|
-
const { apiVersion } = params;
|
155
|
-
assert(apiVersion === "v1");
|
156
|
-
const commandName = (() => {
|
157
|
-
const envValue = process.env[CUSTOM_HANDLER_ENV_NAMES.COMMAND_NAME];
|
158
|
-
assert(envValue !== undefined);
|
159
|
-
return envValue;
|
160
|
-
})();
|
161
|
-
const buildContext = (() => {
|
162
|
-
const envValue = process.env[CUSTOM_HANDLER_ENV_NAMES.BUILD_CONTEXT];
|
163
|
-
assert(envValue !== undefined);
|
164
|
-
return JSON.parse(envValue);
|
165
|
-
})();
|
166
|
-
return { commandName, buildContext };
|
167
|
-
}
|
168
|
-
//# sourceMappingURL=customHandler.js.map
|
169
|
-
// EXTERNAL MODULE: external "child_process"
|
170
|
-
var external_child_process_ = __webpack_require__(32081);
|
171
|
-
// EXTERNAL MODULE: ./dist/bin/tools/nodeModulesBinDirPath.js
|
172
|
-
var tools_nodeModulesBinDirPath = __webpack_require__(73776);
|
173
|
-
// EXTERNAL MODULE: external "fs"
|
174
|
-
var external_fs_ = __webpack_require__(57147);
|
175
|
-
;// CONCATENATED MODULE: ./dist/bin/shared/customHandler_delegate.js
|
176
|
-
|
177
|
-
|
178
|
-
|
2107
|
+
/***/ }),
|
179
2108
|
|
2109
|
+
/***/ 43765:
|
2110
|
+
/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
|
180
2111
|
|
2112
|
+
/* harmony export */ __webpack_require__.d(__webpack_exports__, {
|
2113
|
+
/* harmony export */ "o": () => (/* binding */ existsAsync)
|
2114
|
+
/* harmony export */ });
|
2115
|
+
/* harmony import */ var fs_promises__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(73292);
|
2116
|
+
/* harmony import */ var fs_promises__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(fs_promises__WEBPACK_IMPORTED_MODULE_0__);
|
181
2117
|
|
182
|
-
|
183
|
-
function maybeDelegateCommandToCustomHandler(params) {
|
184
|
-
const { commandName, buildContext } = params;
|
185
|
-
const nodeModulesBinDirPath = (0,tools_nodeModulesBinDirPath/* getNodeModulesBinDirPath */.K)();
|
186
|
-
if (!external_fs_.readdirSync(nodeModulesBinDirPath).includes(BIN_NAME)) {
|
187
|
-
return { hasBeenHandled: false };
|
188
|
-
}
|
2118
|
+
async function existsAsync(path) {
|
189
2119
|
try {
|
190
|
-
|
191
|
-
|
192
|
-
env: Object.assign(Object.assign({}, process.env), { [constants/* CUSTOM_HANDLER_ENV_NAMES.COMMAND_NAME */._S.COMMAND_NAME]: commandName, [constants/* CUSTOM_HANDLER_ENV_NAMES.BUILD_CONTEXT */._S.BUILD_CONTEXT]: JSON.stringify(buildContext) })
|
193
|
-
});
|
2120
|
+
await fs_promises__WEBPACK_IMPORTED_MODULE_0__.stat(path);
|
2121
|
+
return true;
|
194
2122
|
}
|
195
2123
|
catch (error) {
|
196
|
-
|
197
|
-
|
198
|
-
|
199
|
-
}
|
200
|
-
process.exit(status);
|
2124
|
+
if (error.code === "ENOENT")
|
2125
|
+
return false;
|
2126
|
+
throw error;
|
201
2127
|
}
|
202
|
-
return { hasBeenHandled: true };
|
203
2128
|
}
|
204
|
-
//# sourceMappingURL=
|
2129
|
+
//# sourceMappingURL=fs.existsAsync.js.map
|
205
2130
|
|
206
2131
|
/***/ }),
|
207
2132
|
|
208
|
-
/***/
|
2133
|
+
/***/ 90665:
|
209
2134
|
/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
|
210
2135
|
|
211
2136
|
/* harmony export */ __webpack_require__.d(__webpack_exports__, {
|
212
|
-
/* harmony export */ "
|
2137
|
+
/* harmony export */ "V": () => (/* binding */ isInside)
|
213
2138
|
/* harmony export */ });
|
214
|
-
/* harmony import */ var
|
2139
|
+
/* harmony import */ var path__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(71017);
|
2140
|
+
/* harmony import */ var path__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(path__WEBPACK_IMPORTED_MODULE_0__);
|
215
2141
|
|
216
|
-
function
|
217
|
-
const
|
218
|
-
return
|
2142
|
+
function isInside(params) {
|
2143
|
+
const { dirPath, filePath } = params;
|
2144
|
+
return !(0,path__WEBPACK_IMPORTED_MODULE_0__.relative)(dirPath, filePath).startsWith("..");
|
219
2145
|
}
|
220
|
-
//# sourceMappingURL=
|
2146
|
+
//# sourceMappingURL=isInside.js.map
|
221
2147
|
|
222
2148
|
/***/ }),
|
223
2149
|
|
@@ -358,610 +2284,6 @@ async function runPrettier(params) {
|
|
358
2284
|
}
|
359
2285
|
//# sourceMappingURL=runPrettier.js.map
|
360
2286
|
|
361
|
-
/***/ }),
|
362
|
-
|
363
|
-
/***/ 18512:
|
364
|
-
/***/ ((module) => {
|
365
|
-
|
366
|
-
|
367
|
-
const x = module.exports;
|
368
|
-
const ESC = '\u001B[';
|
369
|
-
const OSC = '\u001B]';
|
370
|
-
const BEL = '\u0007';
|
371
|
-
const SEP = ';';
|
372
|
-
const isTerminalApp = process.env.TERM_PROGRAM === 'Apple_Terminal';
|
373
|
-
|
374
|
-
x.cursorTo = (x, y) => {
|
375
|
-
if (typeof x !== 'number') {
|
376
|
-
throw new TypeError('The `x` argument is required');
|
377
|
-
}
|
378
|
-
|
379
|
-
if (typeof y !== 'number') {
|
380
|
-
return ESC + (x + 1) + 'G';
|
381
|
-
}
|
382
|
-
|
383
|
-
return ESC + (y + 1) + ';' + (x + 1) + 'H';
|
384
|
-
};
|
385
|
-
|
386
|
-
x.cursorMove = (x, y) => {
|
387
|
-
if (typeof x !== 'number') {
|
388
|
-
throw new TypeError('The `x` argument is required');
|
389
|
-
}
|
390
|
-
|
391
|
-
let ret = '';
|
392
|
-
|
393
|
-
if (x < 0) {
|
394
|
-
ret += ESC + (-x) + 'D';
|
395
|
-
} else if (x > 0) {
|
396
|
-
ret += ESC + x + 'C';
|
397
|
-
}
|
398
|
-
|
399
|
-
if (y < 0) {
|
400
|
-
ret += ESC + (-y) + 'A';
|
401
|
-
} else if (y > 0) {
|
402
|
-
ret += ESC + y + 'B';
|
403
|
-
}
|
404
|
-
|
405
|
-
return ret;
|
406
|
-
};
|
407
|
-
|
408
|
-
x.cursorUp = count => ESC + (typeof count === 'number' ? count : 1) + 'A';
|
409
|
-
x.cursorDown = count => ESC + (typeof count === 'number' ? count : 1) + 'B';
|
410
|
-
x.cursorForward = count => ESC + (typeof count === 'number' ? count : 1) + 'C';
|
411
|
-
x.cursorBackward = count => ESC + (typeof count === 'number' ? count : 1) + 'D';
|
412
|
-
|
413
|
-
x.cursorLeft = ESC + 'G';
|
414
|
-
x.cursorSavePosition = ESC + (isTerminalApp ? '7' : 's');
|
415
|
-
x.cursorRestorePosition = ESC + (isTerminalApp ? '8' : 'u');
|
416
|
-
x.cursorGetPosition = ESC + '6n';
|
417
|
-
x.cursorNextLine = ESC + 'E';
|
418
|
-
x.cursorPrevLine = ESC + 'F';
|
419
|
-
x.cursorHide = ESC + '?25l';
|
420
|
-
x.cursorShow = ESC + '?25h';
|
421
|
-
|
422
|
-
x.eraseLines = count => {
|
423
|
-
let clear = '';
|
424
|
-
|
425
|
-
for (let i = 0; i < count; i++) {
|
426
|
-
clear += x.eraseLine + (i < count - 1 ? x.cursorUp() : '');
|
427
|
-
}
|
428
|
-
|
429
|
-
if (count) {
|
430
|
-
clear += x.cursorLeft;
|
431
|
-
}
|
432
|
-
|
433
|
-
return clear;
|
434
|
-
};
|
435
|
-
|
436
|
-
x.eraseEndLine = ESC + 'K';
|
437
|
-
x.eraseStartLine = ESC + '1K';
|
438
|
-
x.eraseLine = ESC + '2K';
|
439
|
-
x.eraseDown = ESC + 'J';
|
440
|
-
x.eraseUp = ESC + '1J';
|
441
|
-
x.eraseScreen = ESC + '2J';
|
442
|
-
x.scrollUp = ESC + 'S';
|
443
|
-
x.scrollDown = ESC + 'T';
|
444
|
-
|
445
|
-
x.clearScreen = '\u001Bc';
|
446
|
-
|
447
|
-
x.clearTerminal = process.platform === 'win32' ?
|
448
|
-
`${x.eraseScreen}${ESC}0f` :
|
449
|
-
// 1. Erases the screen (Only done in case `2` is not supported)
|
450
|
-
// 2. Erases the whole screen including scrollback buffer
|
451
|
-
// 3. Moves cursor to the top-left position
|
452
|
-
// More info: https://www.real-world-systems.com/docs/ANSIcode.html
|
453
|
-
`${x.eraseScreen}${ESC}3J${ESC}H`;
|
454
|
-
|
455
|
-
x.beep = BEL;
|
456
|
-
|
457
|
-
x.link = (text, url) => {
|
458
|
-
return [
|
459
|
-
OSC,
|
460
|
-
'8',
|
461
|
-
SEP,
|
462
|
-
SEP,
|
463
|
-
url,
|
464
|
-
BEL,
|
465
|
-
text,
|
466
|
-
OSC,
|
467
|
-
'8',
|
468
|
-
SEP,
|
469
|
-
SEP,
|
470
|
-
BEL
|
471
|
-
].join('');
|
472
|
-
};
|
473
|
-
|
474
|
-
x.image = (buf, opts) => {
|
475
|
-
opts = opts || {};
|
476
|
-
|
477
|
-
let ret = OSC + '1337;File=inline=1';
|
478
|
-
|
479
|
-
if (opts.width) {
|
480
|
-
ret += `;width=${opts.width}`;
|
481
|
-
}
|
482
|
-
|
483
|
-
if (opts.height) {
|
484
|
-
ret += `;height=${opts.height}`;
|
485
|
-
}
|
486
|
-
|
487
|
-
if (opts.preserveAspectRatio === false) {
|
488
|
-
ret += ';preserveAspectRatio=0';
|
489
|
-
}
|
490
|
-
|
491
|
-
return ret + ':' + buf.toString('base64') + BEL;
|
492
|
-
};
|
493
|
-
|
494
|
-
x.iTerm = {};
|
495
|
-
|
496
|
-
x.iTerm.setCwd = cwd => OSC + '50;CurrentDir=' + (cwd || process.cwd()) + BEL;
|
497
|
-
|
498
|
-
|
499
|
-
/***/ }),
|
500
|
-
|
501
|
-
/***/ 39340:
|
502
|
-
/***/ ((__unused_webpack_module, exports) => {
|
503
|
-
|
504
|
-
|
505
|
-
|
506
|
-
Object.defineProperty(exports, "__esModule", ({
|
507
|
-
value: true
|
508
|
-
}));
|
509
|
-
exports.withPromise = exports.withCallback = void 0;
|
510
|
-
|
511
|
-
/**
|
512
|
-
* Open the input with a normal callback function
|
513
|
-
*
|
514
|
-
* @param {Input} input - input object
|
515
|
-
* @param {function} valueMapper - function which maps the resulting id and value back to the expected format
|
516
|
-
* @param {function} callback - callback function
|
517
|
-
*/
|
518
|
-
const withCallback = (input, valueMapper, callback) => {
|
519
|
-
input.open();
|
520
|
-
input.onSelect((id, value) => callback(valueMapper(id, value)));
|
521
|
-
};
|
522
|
-
/**
|
523
|
-
* Open the input with a promise
|
524
|
-
*
|
525
|
-
* @param {Input} input - input object
|
526
|
-
* @param {function} valueMapper - function which maps the resulting id and value back to the expected format
|
527
|
-
*/
|
528
|
-
|
529
|
-
|
530
|
-
exports.withCallback = withCallback;
|
531
|
-
|
532
|
-
const withPromise = (input, valueMapper) => {
|
533
|
-
return new Promise((resolve, reject) => {
|
534
|
-
input.open();
|
535
|
-
input.onSelect((id, value) => {
|
536
|
-
if (id === null) {
|
537
|
-
reject();
|
538
|
-
} else {
|
539
|
-
resolve(valueMapper(id, value));
|
540
|
-
}
|
541
|
-
});
|
542
|
-
});
|
543
|
-
};
|
544
|
-
|
545
|
-
exports.withPromise = withPromise;
|
546
|
-
|
547
|
-
/***/ }),
|
548
|
-
|
549
|
-
/***/ 99398:
|
550
|
-
/***/ ((module, exports, __webpack_require__) => {
|
551
|
-
|
552
|
-
|
553
|
-
|
554
|
-
Object.defineProperty(exports, "__esModule", ({
|
555
|
-
value: true
|
556
|
-
}));
|
557
|
-
exports["default"] = void 0;
|
558
|
-
|
559
|
-
var _input = _interopRequireDefault(__webpack_require__(25730));
|
560
|
-
|
561
|
-
var _renderer = _interopRequireDefault(__webpack_require__(16059));
|
562
|
-
|
563
|
-
var _callbackMappers = __webpack_require__(39340);
|
564
|
-
|
565
|
-
var _valueMappers = __webpack_require__(26730);
|
566
|
-
|
567
|
-
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
568
|
-
|
569
|
-
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; var ownKeys = Object.keys(source); if (typeof Object.getOwnPropertySymbols === 'function') { ownKeys = ownKeys.concat(Object.getOwnPropertySymbols(source).filter(function (sym) { return Object.getOwnPropertyDescriptor(source, sym).enumerable; })); } ownKeys.forEach(function (key) { _defineProperty(target, key, source[key]); }); } return target; }
|
570
|
-
|
571
|
-
function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
572
|
-
|
573
|
-
/**
|
574
|
-
* Default options
|
575
|
-
*/
|
576
|
-
const defaultOptions = {
|
577
|
-
outputStream: process.stdout,
|
578
|
-
inputStream: process.stdin,
|
579
|
-
values: [],
|
580
|
-
defaultValue: 0,
|
581
|
-
selected: '(x)',
|
582
|
-
unselected: '( )',
|
583
|
-
indentation: 0,
|
584
|
-
cleanup: true,
|
585
|
-
valueRenderer: value => value
|
586
|
-
};
|
587
|
-
/**
|
588
|
-
* Create an instance of cli-select with the given options
|
589
|
-
*
|
590
|
-
* @param {object} options - options for cli-select
|
591
|
-
* @param {function} callback - if specified, a callback will be used, otherwise a promise gets returned (optional)
|
592
|
-
*/
|
593
|
-
|
594
|
-
const creator = (options, callback) => {
|
595
|
-
// merge options with default options
|
596
|
-
options = _objectSpread({}, defaultOptions, options); // create renderer and input instances
|
597
|
-
|
598
|
-
const renderer = new _renderer.default(options, options.outputStream);
|
599
|
-
const input = new _input.default(options.inputStream);
|
600
|
-
input.setDefaultValue(options.defaultValue);
|
601
|
-
input.attachRenderer(renderer); // handle array and object values
|
602
|
-
|
603
|
-
let valueMapper;
|
604
|
-
|
605
|
-
if (Array.isArray(options.values)) {
|
606
|
-
valueMapper = (0, _valueMappers.withArrayValues)(options);
|
607
|
-
} else {
|
608
|
-
valueMapper = (0, _valueMappers.withObjectValues)(options);
|
609
|
-
} // map values
|
610
|
-
|
611
|
-
|
612
|
-
options.values = valueMapper.input;
|
613
|
-
input.setValues(options.values); // handle different callback methods
|
614
|
-
|
615
|
-
if (typeof callback === 'function') {
|
616
|
-
return (0, _callbackMappers.withCallback)(input, valueMapper.output, callback);
|
617
|
-
} else {
|
618
|
-
return (0, _callbackMappers.withPromise)(input, valueMapper.output);
|
619
|
-
}
|
620
|
-
};
|
621
|
-
|
622
|
-
exports = module.exports = creator;
|
623
|
-
Object.defineProperty(exports, "__esModule", ({
|
624
|
-
value: true
|
625
|
-
}));
|
626
|
-
var _default = creator;
|
627
|
-
exports["default"] = _default;
|
628
|
-
|
629
|
-
/***/ }),
|
630
|
-
|
631
|
-
/***/ 25730:
|
632
|
-
/***/ ((__unused_webpack_module, exports, __webpack_require__) => {
|
633
|
-
|
634
|
-
|
635
|
-
|
636
|
-
Object.defineProperty(exports, "__esModule", ({
|
637
|
-
value: true
|
638
|
-
}));
|
639
|
-
exports["default"] = void 0;
|
640
|
-
|
641
|
-
var _readline = _interopRequireDefault(__webpack_require__(14521));
|
642
|
-
|
643
|
-
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
644
|
-
|
645
|
-
/**
|
646
|
-
* Handle cli input
|
647
|
-
*/
|
648
|
-
class Input {
|
649
|
-
/**
|
650
|
-
* Input constructor
|
651
|
-
*
|
652
|
-
* @param {any} stream - stream to catch (optional)
|
653
|
-
*/
|
654
|
-
constructor(stream = process.stdin) {
|
655
|
-
// set default values
|
656
|
-
this.stream = stream;
|
657
|
-
this.values = [];
|
658
|
-
this.selectedValue = 0;
|
659
|
-
|
660
|
-
this.onSelectListener = () => {};
|
661
|
-
|
662
|
-
this.onKeyPress = this.onKeyPress.bind(this);
|
663
|
-
}
|
664
|
-
/**
|
665
|
-
* Set the available values
|
666
|
-
*
|
667
|
-
* @param {array} values - all available values
|
668
|
-
*/
|
669
|
-
|
670
|
-
|
671
|
-
setValues(values) {
|
672
|
-
this.values = values;
|
673
|
-
|
674
|
-
if (this.renderer) {
|
675
|
-
this.renderer.setValues(values);
|
676
|
-
}
|
677
|
-
}
|
678
|
-
/**
|
679
|
-
* Set the default value
|
680
|
-
*
|
681
|
-
* @param {number} defaultValue - default value id
|
682
|
-
*/
|
683
|
-
|
684
|
-
|
685
|
-
setDefaultValue(defaultValue) {
|
686
|
-
this.selectedValue = defaultValue;
|
687
|
-
}
|
688
|
-
/**
|
689
|
-
* Attach a renderer to the input catcher
|
690
|
-
*
|
691
|
-
* @param {Renderer} renderer - renderer to use for rendering responses
|
692
|
-
*/
|
693
|
-
|
694
|
-
|
695
|
-
attachRenderer(renderer) {
|
696
|
-
this.renderer = renderer;
|
697
|
-
this.renderer.setValues(this.values);
|
698
|
-
}
|
699
|
-
/**
|
700
|
-
* Register an on select listener
|
701
|
-
*
|
702
|
-
* @param {function} listener - listener function which receives two parameters: valueId and value
|
703
|
-
*/
|
704
|
-
|
705
|
-
|
706
|
-
onSelect(listener) {
|
707
|
-
this.onSelectListener = listener;
|
708
|
-
}
|
709
|
-
/**
|
710
|
-
* Open the stream and listen for input
|
711
|
-
*/
|
712
|
-
|
713
|
-
|
714
|
-
open() {
|
715
|
-
// register keypress event
|
716
|
-
_readline.default.emitKeypressEvents(this.stream); // handle keypress
|
717
|
-
|
718
|
-
|
719
|
-
this.stream.on('keypress', this.onKeyPress); // initially render the response
|
720
|
-
|
721
|
-
if (this.renderer) {
|
722
|
-
this.renderer.render(this.selectedValue);
|
723
|
-
} // hide pressed keys and start listening on input
|
724
|
-
|
725
|
-
|
726
|
-
this.stream.setRawMode(true);
|
727
|
-
this.stream.resume();
|
728
|
-
}
|
729
|
-
/**
|
730
|
-
* Close the stream
|
731
|
-
*
|
732
|
-
* @param {boolean} cancelled - true if no value was selected (optional)
|
733
|
-
*/
|
734
|
-
|
735
|
-
|
736
|
-
close(cancelled = false) {
|
737
|
-
// reset stream properties
|
738
|
-
this.stream.setRawMode(false);
|
739
|
-
this.stream.pause(); // cleanup the output
|
740
|
-
|
741
|
-
if (this.renderer) {
|
742
|
-
this.renderer.cleanup();
|
743
|
-
} // call the on select listener
|
744
|
-
|
745
|
-
|
746
|
-
if (cancelled) {
|
747
|
-
this.onSelectListener(null);
|
748
|
-
} else {
|
749
|
-
this.onSelectListener(this.selectedValue, this.values[this.selectedValue]);
|
750
|
-
}
|
751
|
-
|
752
|
-
this.stream.removeListener('keypress', this.onKeyPress);
|
753
|
-
}
|
754
|
-
/**
|
755
|
-
* Render the response
|
756
|
-
*/
|
757
|
-
|
758
|
-
|
759
|
-
render() {
|
760
|
-
if (!this.renderer) {
|
761
|
-
return;
|
762
|
-
}
|
763
|
-
|
764
|
-
this.renderer.render(this.selectedValue);
|
765
|
-
}
|
766
|
-
/**
|
767
|
-
* Handle key press event
|
768
|
-
*
|
769
|
-
* @param {string} string - input string
|
770
|
-
* @param {object} key - object containing information about the pressed key
|
771
|
-
*/
|
772
|
-
|
773
|
-
|
774
|
-
onKeyPress(string, key) {
|
775
|
-
if (key) {
|
776
|
-
if (key.name === 'up' && this.selectedValue > 0) {
|
777
|
-
this.selectedValue--;
|
778
|
-
this.render();
|
779
|
-
} else if (key.name === 'down' && this.selectedValue + 1 < this.values.length) {
|
780
|
-
this.selectedValue++;
|
781
|
-
this.render();
|
782
|
-
} else if (key.name === 'return') {
|
783
|
-
this.close();
|
784
|
-
} else if (key.name === 'escape' || key.name === 'c' && key.ctrl) {
|
785
|
-
this.close(true);
|
786
|
-
}
|
787
|
-
}
|
788
|
-
}
|
789
|
-
|
790
|
-
}
|
791
|
-
|
792
|
-
exports["default"] = Input;
|
793
|
-
|
794
|
-
/***/ }),
|
795
|
-
|
796
|
-
/***/ 16059:
|
797
|
-
/***/ ((__unused_webpack_module, exports, __webpack_require__) => {
|
798
|
-
|
799
|
-
|
800
|
-
|
801
|
-
Object.defineProperty(exports, "__esModule", ({
|
802
|
-
value: true
|
803
|
-
}));
|
804
|
-
exports["default"] = void 0;
|
805
|
-
|
806
|
-
var _readline = _interopRequireDefault(__webpack_require__(14521));
|
807
|
-
|
808
|
-
var _ansiEscapes = __webpack_require__(18512);
|
809
|
-
|
810
|
-
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
811
|
-
|
812
|
-
/**
|
813
|
-
* Response renderer
|
814
|
-
*/
|
815
|
-
class Renderer {
|
816
|
-
/**
|
817
|
-
* Renderer constructor
|
818
|
-
*
|
819
|
-
* @param {object} options - renderer options
|
820
|
-
* @param {any} stream - stream to write to (optional)
|
821
|
-
*/
|
822
|
-
constructor(options, stream = process.stdout) {
|
823
|
-
this.options = options;
|
824
|
-
this.stream = stream;
|
825
|
-
this.values = [];
|
826
|
-
this.initialRender = true;
|
827
|
-
}
|
828
|
-
/**
|
829
|
-
* Set the available values
|
830
|
-
*
|
831
|
-
* @param {array} values - all available values
|
832
|
-
*/
|
833
|
-
|
834
|
-
|
835
|
-
setValues(values) {
|
836
|
-
this.values = values;
|
837
|
-
}
|
838
|
-
/**
|
839
|
-
* Render the values
|
840
|
-
*
|
841
|
-
* @param {number} selectedValue - selected value (optional)
|
842
|
-
*/
|
843
|
-
|
844
|
-
|
845
|
-
render(selectedValue = 0) {
|
846
|
-
if (this.initialRender) {
|
847
|
-
// hide the cursor initially
|
848
|
-
this.initialRender = false;
|
849
|
-
this.stream.write(_ansiEscapes.cursorHide);
|
850
|
-
} else {
|
851
|
-
// remove previous lines and values
|
852
|
-
this.stream.write((0, _ansiEscapes.eraseLines)(this.values.length));
|
853
|
-
} // output the current values
|
854
|
-
|
855
|
-
|
856
|
-
this.values.forEach((value, index) => {
|
857
|
-
const symbol = selectedValue === index ? this.options.selected : this.options.unselected;
|
858
|
-
const indentation = ' '.repeat(this.options.indentation);
|
859
|
-
const renderedValue = this.options.valueRenderer(value, selectedValue === index);
|
860
|
-
const end = index !== this.values.length - 1 ? '\n' : '';
|
861
|
-
this.stream.write(indentation + symbol + ' ' + renderedValue + end);
|
862
|
-
});
|
863
|
-
}
|
864
|
-
/**
|
865
|
-
* Cleanup the console at the end
|
866
|
-
*/
|
867
|
-
|
868
|
-
|
869
|
-
cleanup() {
|
870
|
-
this.stream.write((0, _ansiEscapes.eraseLines)(this.values.length));
|
871
|
-
this.stream.write(_ansiEscapes.cursorShow);
|
872
|
-
}
|
873
|
-
|
874
|
-
}
|
875
|
-
|
876
|
-
exports["default"] = Renderer;
|
877
|
-
|
878
|
-
/***/ }),
|
879
|
-
|
880
|
-
/***/ 26730:
|
881
|
-
/***/ ((__unused_webpack_module, exports) => {
|
882
|
-
|
883
|
-
|
884
|
-
|
885
|
-
Object.defineProperty(exports, "__esModule", ({
|
886
|
-
value: true
|
887
|
-
}));
|
888
|
-
exports.withObjectValues = exports.withArrayValues = void 0;
|
889
|
-
|
890
|
-
/**
|
891
|
-
* Map incoming and outgoing values if the initial values are an array
|
892
|
-
*
|
893
|
-
* @param {object} options - cli-select options
|
894
|
-
*/
|
895
|
-
const withArrayValues = options => {
|
896
|
-
return {
|
897
|
-
input: options.values,
|
898
|
-
output: (id, value) => {
|
899
|
-
return {
|
900
|
-
id,
|
901
|
-
value
|
902
|
-
};
|
903
|
-
}
|
904
|
-
};
|
905
|
-
};
|
906
|
-
/**
|
907
|
-
* Map incoming and outgoing values if the initial values are an object
|
908
|
-
*
|
909
|
-
* @param {object} options - cli-select options
|
910
|
-
*/
|
911
|
-
|
912
|
-
|
913
|
-
exports.withArrayValues = withArrayValues;
|
914
|
-
|
915
|
-
const withObjectValues = options => {
|
916
|
-
const originalValues = options.values;
|
917
|
-
return {
|
918
|
-
input: Object.values(originalValues),
|
919
|
-
output: (id, value) => {
|
920
|
-
return {
|
921
|
-
id: Object.keys(originalValues)[id],
|
922
|
-
value
|
923
|
-
};
|
924
|
-
}
|
925
|
-
};
|
926
|
-
};
|
927
|
-
|
928
|
-
exports.withObjectValues = withObjectValues;
|
929
|
-
|
930
|
-
/***/ }),
|
931
|
-
|
932
|
-
/***/ 14899:
|
933
|
-
/***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => {
|
934
|
-
|
935
|
-
/* harmony export */ __webpack_require__.d(__webpack_exports__, {
|
936
|
-
/* harmony export */ "k": () => (/* binding */ capitalize)
|
937
|
-
/* harmony export */ });
|
938
|
-
/** @see <https://docs.tsafe.dev/capitalize> */
|
939
|
-
function capitalize(str) {
|
940
|
-
return (str.charAt(0).toUpperCase() + str.slice(1));
|
941
|
-
}
|
942
|
-
|
943
|
-
|
944
|
-
//# sourceMappingURL=capitalize.mjs.map
|
945
|
-
|
946
|
-
|
947
|
-
/***/ }),
|
948
|
-
|
949
|
-
/***/ 76030:
|
950
|
-
/***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => {
|
951
|
-
|
952
|
-
/* harmony export */ __webpack_require__.d(__webpack_exports__, {
|
953
|
-
/* harmony export */ "r": () => (/* binding */ symToStr)
|
954
|
-
/* harmony export */ });
|
955
|
-
/** @see <https://docs.tsafe.dev/main/symtostr> */
|
956
|
-
function symToStr(wrap) {
|
957
|
-
// @ts-expect-error: We know better
|
958
|
-
return Object.keys(wrap)[0];
|
959
|
-
}
|
960
|
-
|
961
|
-
|
962
|
-
//# sourceMappingURL=symToStr.mjs.map
|
963
|
-
|
964
|
-
|
965
2287
|
/***/ })
|
966
2288
|
|
967
2289
|
};
|