keycloakify 10.0.0-rc.118 → 10.0.0-rc.119

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.
Files changed (48) hide show
  1. package/bin/{490.index.js → 246.index.js} +20 -2
  2. package/bin/31.index.js +151 -159
  3. package/bin/440.index.js +27 -22
  4. package/bin/526.index.js +168 -56
  5. package/bin/599.index.js +560 -0
  6. package/bin/622.index.js +4 -2
  7. package/bin/{36.index.js → 678.index.js} +577 -71
  8. package/bin/{180.index.js → 697.index.js} +611 -526
  9. package/bin/743.index.js +70 -0
  10. package/bin/780.index.js +729 -0
  11. package/bin/932.index.js +725 -48
  12. package/bin/{966.index.js → 941.index.js} +2 -19
  13. package/bin/main.js +19 -7
  14. package/bin/shared/buildContext.d.ts +28 -19
  15. package/bin/shared/buildContext.js.map +1 -1
  16. package/bin/shared/getLatestsSemVersionedTag.d.ts +10 -0
  17. package/bin/shared/getLatestsSemVersionedTag.js.map +1 -0
  18. package/bin/shared/promptKeycloakVersion.js.map +1 -1
  19. package/package.json +24 -5
  20. package/src/bin/initialize-account-theme/copyBoilerplate.ts +32 -0
  21. package/src/bin/initialize-account-theme/index.ts +1 -0
  22. package/src/bin/initialize-account-theme/initialize-account-theme.ts +95 -0
  23. package/src/bin/initialize-account-theme/initializeAccountTheme_multiPage.ts +21 -0
  24. package/src/bin/initialize-account-theme/initializeAccountTheme_singlePage.ts +150 -0
  25. package/src/bin/initialize-account-theme/src/multi-page/KcContext.ts +12 -0
  26. package/src/bin/initialize-account-theme/src/multi-page/KcPage.tsx +25 -0
  27. package/src/bin/initialize-account-theme/src/multi-page/KcPageStory.tsx +38 -0
  28. package/src/bin/initialize-account-theme/src/multi-page/i18n.ts +5 -0
  29. package/src/bin/initialize-account-theme/src/single-page/KcContext.ts +7 -0
  30. package/src/bin/initialize-account-theme/src/single-page/KcPage.tsx +11 -0
  31. package/src/bin/initialize-account-theme/updateAccountThemeImplementationInConfig.ts +92 -0
  32. package/src/bin/keycloakify/buildJars/buildJar.ts +2 -2
  33. package/src/bin/keycloakify/buildJars/buildJars.ts +3 -4
  34. package/src/bin/keycloakify/generateResources/generateResourcesForMainTheme.ts +26 -20
  35. package/src/bin/keycloakify/keycloakify.ts +1 -1
  36. package/src/bin/keycloakify/replacers/replaceImportsInJsCode/replaceImportsInJsCode.ts +2 -2
  37. package/src/bin/main.ts +14 -0
  38. package/src/bin/shared/buildContext.ts +246 -225
  39. package/src/bin/shared/getLatestsSemVersionedTag.ts +180 -0
  40. package/src/bin/shared/promptKeycloakVersion.ts +8 -77
  41. package/src/bin/start-keycloak/appBuild.ts +13 -9
  42. package/src/bin/tools/downloadAndExtractArchive.ts +4 -2
  43. package/src/bin/tools/npmInstall.ts +63 -0
  44. package/src/bin/tools/octokit-addons/getLatestsSemVersionedTag.ts +3 -2
  45. package/src/bin/tsconfig.json +3 -1
  46. package/src/vite-plugin/vite-plugin.ts +7 -5
  47. package/vite-plugin/index.js +156 -180
  48. package/vite-plugin/vite-plugin.d.ts +6 -4
@@ -0,0 +1,729 @@
1
+ "use strict";
2
+ exports.id = 780;
3
+ exports.ids = [780];
4
+ exports.modules = {
5
+
6
+ /***/ 75780:
7
+ /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
8
+
9
+ // ESM COMPAT FLAG
10
+ __webpack_require__.r(__webpack_exports__);
11
+
12
+ // EXPORTS
13
+ __webpack_require__.d(__webpack_exports__, {
14
+ "command": () => (/* reexport */ command)
15
+ });
16
+
17
+ // EXTERNAL MODULE: ./dist/bin/shared/buildContext.js + 1 modules
18
+ var shared_buildContext = __webpack_require__(56031);
19
+ // EXTERNAL MODULE: ./node_modules/cli-select/dist/index.js
20
+ var dist = __webpack_require__(99398);
21
+ var dist_default = /*#__PURE__*/__webpack_require__.n(dist);
22
+ // EXTERNAL MODULE: external "child_process"
23
+ var external_child_process_ = __webpack_require__(32081);
24
+ var external_child_process_default = /*#__PURE__*/__webpack_require__.n(external_child_process_);
25
+ // EXTERNAL MODULE: ./node_modules/chalk/source/index.js
26
+ var source = __webpack_require__(78818);
27
+ var source_default = /*#__PURE__*/__webpack_require__.n(source);
28
+ // EXTERNAL MODULE: external "path"
29
+ var external_path_ = __webpack_require__(71017);
30
+ // EXTERNAL MODULE: external "fs"
31
+ var external_fs_ = __webpack_require__(57147);
32
+ // EXTERNAL MODULE: ./node_modules/tsafe/assert.js
33
+ var assert = __webpack_require__(88078);
34
+ // EXTERNAL MODULE: ./node_modules/zod/lib/index.mjs
35
+ var lib = __webpack_require__(52300);
36
+ // EXTERNAL MODULE: ./node_modules/tsafe/id.js
37
+ var id = __webpack_require__(43047);
38
+ ;// CONCATENATED MODULE: ./dist/bin/initialize-account-theme/updateAccountThemeImplementationInConfig.js
39
+
40
+
41
+
42
+
43
+
44
+
45
+ (0,assert.assert)();
46
+ function updateAccountThemeImplementationInConfig(params) {
47
+ const { buildContext, accountThemeType } = params;
48
+ switch (buildContext.bundler) {
49
+ case "vite":
50
+ {
51
+ const viteConfigPath = (0,external_path_.join)(buildContext.projectDirPath, "vite.config.ts");
52
+ if (!external_fs_.existsSync(viteConfigPath)) {
53
+ console.log(source_default().bold(`You must manually set the accountThemeImplementation to "${accountThemeType}" in your vite config`));
54
+ break;
55
+ }
56
+ const viteConfigContent = external_fs_.readFileSync(viteConfigPath)
57
+ .toString("utf8");
58
+ const modifiedViteConfigContent = viteConfigContent.replace(/accountThemeImplementation\s*:\s*"none"/, `accountThemeImplementation: "${accountThemeType}"`);
59
+ if (modifiedViteConfigContent === viteConfigContent) {
60
+ console.log(source_default().bold(`You must manually set the accountThemeImplementation to "${accountThemeType}" in your vite.config.ts`));
61
+ break;
62
+ }
63
+ external_fs_.writeFileSync(viteConfigPath, modifiedViteConfigContent);
64
+ }
65
+ break;
66
+ case "webpack":
67
+ {
68
+ const parsedPackageJson = (() => {
69
+ const zParsedPackageJson = (() => {
70
+ const zTargetType = lib.z.object({
71
+ keycloakify: lib.z.record(lib.z.string())
72
+ });
73
+ (0,assert.assert)();
74
+ return (0,id.id)(zTargetType);
75
+ })();
76
+ return zParsedPackageJson.parse(JSON.parse(external_fs_.readFileSync(buildContext.packageJsonFilePath)
77
+ .toString("utf8")));
78
+ })();
79
+ parsedPackageJson.keycloakify.accountThemeImplementation =
80
+ accountThemeType;
81
+ }
82
+ break;
83
+ }
84
+ }
85
+ //# sourceMappingURL=updateAccountThemeImplementationInConfig.js.map
86
+ ;// CONCATENATED MODULE: ./dist/bin/initialize-account-theme/initialize-account-theme.js
87
+
88
+
89
+
90
+
91
+
92
+
93
+
94
+ async function command(params) {
95
+ const { cliCommandOptions } = params;
96
+ const buildContext = (0,shared_buildContext/* getBuildContext */.s)({ cliCommandOptions });
97
+ const accountThemeSrcDirPath = (0,external_path_.join)(buildContext.themeSrcDirPath, "account");
98
+ if (external_fs_.existsSync(accountThemeSrcDirPath)) {
99
+ console.warn(source_default().red(`There is already a ${(0,external_path_.relative)(process.cwd(), accountThemeSrcDirPath)} directory in your project. Aborting.`));
100
+ process.exit(-1);
101
+ }
102
+ exit_if_uncommitted_changes: {
103
+ let hasUncommittedChanges = undefined;
104
+ try {
105
+ hasUncommittedChanges =
106
+ external_child_process_default().execSync(`git status --porcelain`, {
107
+ cwd: buildContext.projectDirPath
108
+ })
109
+ .toString()
110
+ .trim() !== "";
111
+ }
112
+ catch (_a) {
113
+ // Probably not a git repository
114
+ break exit_if_uncommitted_changes;
115
+ }
116
+ if (!hasUncommittedChanges) {
117
+ break exit_if_uncommitted_changes;
118
+ }
119
+ console.warn([
120
+ source_default().red("Please commit or stash your changes before running this command.\n"),
121
+ "This command will modify your project's files so it's better to have a clean working directory",
122
+ "so that you can easily see what has been changed and revert if needed."
123
+ ].join(" "));
124
+ process.exit(-1);
125
+ }
126
+ const { value: accountThemeType } = await dist_default()({
127
+ values: ["Single-Page", "Multi-Page"]
128
+ }).catch(() => {
129
+ process.exit(-1);
130
+ });
131
+ switch (accountThemeType) {
132
+ case "Multi-Page":
133
+ {
134
+ const { initializeAccountTheme_multiPage } = await __webpack_require__.e(/* import() */ 743).then(__webpack_require__.bind(__webpack_require__, 22743));
135
+ await initializeAccountTheme_multiPage({
136
+ accountThemeSrcDirPath
137
+ });
138
+ }
139
+ break;
140
+ case "Single-Page":
141
+ {
142
+ const { initializeAccountTheme_singlePage } = await Promise.all(/* import() */[__webpack_require__.e(525), __webpack_require__.e(697), __webpack_require__.e(599)]).then(__webpack_require__.bind(__webpack_require__, 97599));
143
+ await initializeAccountTheme_singlePage({
144
+ accountThemeSrcDirPath,
145
+ buildContext
146
+ });
147
+ }
148
+ break;
149
+ }
150
+ updateAccountThemeImplementationInConfig({ buildContext, accountThemeType });
151
+ }
152
+ //# sourceMappingURL=initialize-account-theme.js.map
153
+ ;// CONCATENATED MODULE: ./dist/bin/initialize-account-theme/index.js
154
+
155
+ //# sourceMappingURL=index.js.map
156
+
157
+ /***/ }),
158
+
159
+ /***/ 18512:
160
+ /***/ ((module) => {
161
+
162
+
163
+ const x = module.exports;
164
+ const ESC = '\u001B[';
165
+ const OSC = '\u001B]';
166
+ const BEL = '\u0007';
167
+ const SEP = ';';
168
+ const isTerminalApp = process.env.TERM_PROGRAM === 'Apple_Terminal';
169
+
170
+ x.cursorTo = (x, y) => {
171
+ if (typeof x !== 'number') {
172
+ throw new TypeError('The `x` argument is required');
173
+ }
174
+
175
+ if (typeof y !== 'number') {
176
+ return ESC + (x + 1) + 'G';
177
+ }
178
+
179
+ return ESC + (y + 1) + ';' + (x + 1) + 'H';
180
+ };
181
+
182
+ x.cursorMove = (x, y) => {
183
+ if (typeof x !== 'number') {
184
+ throw new TypeError('The `x` argument is required');
185
+ }
186
+
187
+ let ret = '';
188
+
189
+ if (x < 0) {
190
+ ret += ESC + (-x) + 'D';
191
+ } else if (x > 0) {
192
+ ret += ESC + x + 'C';
193
+ }
194
+
195
+ if (y < 0) {
196
+ ret += ESC + (-y) + 'A';
197
+ } else if (y > 0) {
198
+ ret += ESC + y + 'B';
199
+ }
200
+
201
+ return ret;
202
+ };
203
+
204
+ x.cursorUp = count => ESC + (typeof count === 'number' ? count : 1) + 'A';
205
+ x.cursorDown = count => ESC + (typeof count === 'number' ? count : 1) + 'B';
206
+ x.cursorForward = count => ESC + (typeof count === 'number' ? count : 1) + 'C';
207
+ x.cursorBackward = count => ESC + (typeof count === 'number' ? count : 1) + 'D';
208
+
209
+ x.cursorLeft = ESC + 'G';
210
+ x.cursorSavePosition = ESC + (isTerminalApp ? '7' : 's');
211
+ x.cursorRestorePosition = ESC + (isTerminalApp ? '8' : 'u');
212
+ x.cursorGetPosition = ESC + '6n';
213
+ x.cursorNextLine = ESC + 'E';
214
+ x.cursorPrevLine = ESC + 'F';
215
+ x.cursorHide = ESC + '?25l';
216
+ x.cursorShow = ESC + '?25h';
217
+
218
+ x.eraseLines = count => {
219
+ let clear = '';
220
+
221
+ for (let i = 0; i < count; i++) {
222
+ clear += x.eraseLine + (i < count - 1 ? x.cursorUp() : '');
223
+ }
224
+
225
+ if (count) {
226
+ clear += x.cursorLeft;
227
+ }
228
+
229
+ return clear;
230
+ };
231
+
232
+ x.eraseEndLine = ESC + 'K';
233
+ x.eraseStartLine = ESC + '1K';
234
+ x.eraseLine = ESC + '2K';
235
+ x.eraseDown = ESC + 'J';
236
+ x.eraseUp = ESC + '1J';
237
+ x.eraseScreen = ESC + '2J';
238
+ x.scrollUp = ESC + 'S';
239
+ x.scrollDown = ESC + 'T';
240
+
241
+ x.clearScreen = '\u001Bc';
242
+
243
+ x.clearTerminal = process.platform === 'win32' ?
244
+ `${x.eraseScreen}${ESC}0f` :
245
+ // 1. Erases the screen (Only done in case `2` is not supported)
246
+ // 2. Erases the whole screen including scrollback buffer
247
+ // 3. Moves cursor to the top-left position
248
+ // More info: https://www.real-world-systems.com/docs/ANSIcode.html
249
+ `${x.eraseScreen}${ESC}3J${ESC}H`;
250
+
251
+ x.beep = BEL;
252
+
253
+ x.link = (text, url) => {
254
+ return [
255
+ OSC,
256
+ '8',
257
+ SEP,
258
+ SEP,
259
+ url,
260
+ BEL,
261
+ text,
262
+ OSC,
263
+ '8',
264
+ SEP,
265
+ SEP,
266
+ BEL
267
+ ].join('');
268
+ };
269
+
270
+ x.image = (buf, opts) => {
271
+ opts = opts || {};
272
+
273
+ let ret = OSC + '1337;File=inline=1';
274
+
275
+ if (opts.width) {
276
+ ret += `;width=${opts.width}`;
277
+ }
278
+
279
+ if (opts.height) {
280
+ ret += `;height=${opts.height}`;
281
+ }
282
+
283
+ if (opts.preserveAspectRatio === false) {
284
+ ret += ';preserveAspectRatio=0';
285
+ }
286
+
287
+ return ret + ':' + buf.toString('base64') + BEL;
288
+ };
289
+
290
+ x.iTerm = {};
291
+
292
+ x.iTerm.setCwd = cwd => OSC + '50;CurrentDir=' + (cwd || process.cwd()) + BEL;
293
+
294
+
295
+ /***/ }),
296
+
297
+ /***/ 39340:
298
+ /***/ ((__unused_webpack_module, exports) => {
299
+
300
+
301
+
302
+ Object.defineProperty(exports, "__esModule", ({
303
+ value: true
304
+ }));
305
+ exports.withPromise = exports.withCallback = void 0;
306
+
307
+ /**
308
+ * Open the input with a normal callback function
309
+ *
310
+ * @param {Input} input - input object
311
+ * @param {function} valueMapper - function which maps the resulting id and value back to the expected format
312
+ * @param {function} callback - callback function
313
+ */
314
+ const withCallback = (input, valueMapper, callback) => {
315
+ input.open();
316
+ input.onSelect((id, value) => callback(valueMapper(id, value)));
317
+ };
318
+ /**
319
+ * Open the input with a promise
320
+ *
321
+ * @param {Input} input - input object
322
+ * @param {function} valueMapper - function which maps the resulting id and value back to the expected format
323
+ */
324
+
325
+
326
+ exports.withCallback = withCallback;
327
+
328
+ const withPromise = (input, valueMapper) => {
329
+ return new Promise((resolve, reject) => {
330
+ input.open();
331
+ input.onSelect((id, value) => {
332
+ if (id === null) {
333
+ reject();
334
+ } else {
335
+ resolve(valueMapper(id, value));
336
+ }
337
+ });
338
+ });
339
+ };
340
+
341
+ exports.withPromise = withPromise;
342
+
343
+ /***/ }),
344
+
345
+ /***/ 99398:
346
+ /***/ ((module, exports, __webpack_require__) => {
347
+
348
+
349
+
350
+ Object.defineProperty(exports, "__esModule", ({
351
+ value: true
352
+ }));
353
+ exports["default"] = void 0;
354
+
355
+ var _input = _interopRequireDefault(__webpack_require__(25730));
356
+
357
+ var _renderer = _interopRequireDefault(__webpack_require__(16059));
358
+
359
+ var _callbackMappers = __webpack_require__(39340);
360
+
361
+ var _valueMappers = __webpack_require__(26730);
362
+
363
+ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
364
+
365
+ 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; }
366
+
367
+ 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; }
368
+
369
+ /**
370
+ * Default options
371
+ */
372
+ const defaultOptions = {
373
+ outputStream: process.stdout,
374
+ inputStream: process.stdin,
375
+ values: [],
376
+ defaultValue: 0,
377
+ selected: '(x)',
378
+ unselected: '( )',
379
+ indentation: 0,
380
+ cleanup: true,
381
+ valueRenderer: value => value
382
+ };
383
+ /**
384
+ * Create an instance of cli-select with the given options
385
+ *
386
+ * @param {object} options - options for cli-select
387
+ * @param {function} callback - if specified, a callback will be used, otherwise a promise gets returned (optional)
388
+ */
389
+
390
+ const creator = (options, callback) => {
391
+ // merge options with default options
392
+ options = _objectSpread({}, defaultOptions, options); // create renderer and input instances
393
+
394
+ const renderer = new _renderer.default(options, options.outputStream);
395
+ const input = new _input.default(options.inputStream);
396
+ input.setDefaultValue(options.defaultValue);
397
+ input.attachRenderer(renderer); // handle array and object values
398
+
399
+ let valueMapper;
400
+
401
+ if (Array.isArray(options.values)) {
402
+ valueMapper = (0, _valueMappers.withArrayValues)(options);
403
+ } else {
404
+ valueMapper = (0, _valueMappers.withObjectValues)(options);
405
+ } // map values
406
+
407
+
408
+ options.values = valueMapper.input;
409
+ input.setValues(options.values); // handle different callback methods
410
+
411
+ if (typeof callback === 'function') {
412
+ return (0, _callbackMappers.withCallback)(input, valueMapper.output, callback);
413
+ } else {
414
+ return (0, _callbackMappers.withPromise)(input, valueMapper.output);
415
+ }
416
+ };
417
+
418
+ exports = module.exports = creator;
419
+ Object.defineProperty(exports, "__esModule", ({
420
+ value: true
421
+ }));
422
+ var _default = creator;
423
+ exports["default"] = _default;
424
+
425
+ /***/ }),
426
+
427
+ /***/ 25730:
428
+ /***/ ((__unused_webpack_module, exports, __webpack_require__) => {
429
+
430
+
431
+
432
+ Object.defineProperty(exports, "__esModule", ({
433
+ value: true
434
+ }));
435
+ exports["default"] = void 0;
436
+
437
+ var _readline = _interopRequireDefault(__webpack_require__(14521));
438
+
439
+ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
440
+
441
+ /**
442
+ * Handle cli input
443
+ */
444
+ class Input {
445
+ /**
446
+ * Input constructor
447
+ *
448
+ * @param {any} stream - stream to catch (optional)
449
+ */
450
+ constructor(stream = process.stdin) {
451
+ // set default values
452
+ this.stream = stream;
453
+ this.values = [];
454
+ this.selectedValue = 0;
455
+
456
+ this.onSelectListener = () => {};
457
+
458
+ this.onKeyPress = this.onKeyPress.bind(this);
459
+ }
460
+ /**
461
+ * Set the available values
462
+ *
463
+ * @param {array} values - all available values
464
+ */
465
+
466
+
467
+ setValues(values) {
468
+ this.values = values;
469
+
470
+ if (this.renderer) {
471
+ this.renderer.setValues(values);
472
+ }
473
+ }
474
+ /**
475
+ * Set the default value
476
+ *
477
+ * @param {number} defaultValue - default value id
478
+ */
479
+
480
+
481
+ setDefaultValue(defaultValue) {
482
+ this.selectedValue = defaultValue;
483
+ }
484
+ /**
485
+ * Attach a renderer to the input catcher
486
+ *
487
+ * @param {Renderer} renderer - renderer to use for rendering responses
488
+ */
489
+
490
+
491
+ attachRenderer(renderer) {
492
+ this.renderer = renderer;
493
+ this.renderer.setValues(this.values);
494
+ }
495
+ /**
496
+ * Register an on select listener
497
+ *
498
+ * @param {function} listener - listener function which receives two parameters: valueId and value
499
+ */
500
+
501
+
502
+ onSelect(listener) {
503
+ this.onSelectListener = listener;
504
+ }
505
+ /**
506
+ * Open the stream and listen for input
507
+ */
508
+
509
+
510
+ open() {
511
+ // register keypress event
512
+ _readline.default.emitKeypressEvents(this.stream); // handle keypress
513
+
514
+
515
+ this.stream.on('keypress', this.onKeyPress); // initially render the response
516
+
517
+ if (this.renderer) {
518
+ this.renderer.render(this.selectedValue);
519
+ } // hide pressed keys and start listening on input
520
+
521
+
522
+ this.stream.setRawMode(true);
523
+ this.stream.resume();
524
+ }
525
+ /**
526
+ * Close the stream
527
+ *
528
+ * @param {boolean} cancelled - true if no value was selected (optional)
529
+ */
530
+
531
+
532
+ close(cancelled = false) {
533
+ // reset stream properties
534
+ this.stream.setRawMode(false);
535
+ this.stream.pause(); // cleanup the output
536
+
537
+ if (this.renderer) {
538
+ this.renderer.cleanup();
539
+ } // call the on select listener
540
+
541
+
542
+ if (cancelled) {
543
+ this.onSelectListener(null);
544
+ } else {
545
+ this.onSelectListener(this.selectedValue, this.values[this.selectedValue]);
546
+ }
547
+
548
+ this.stream.removeListener('keypress', this.onKeyPress);
549
+ }
550
+ /**
551
+ * Render the response
552
+ */
553
+
554
+
555
+ render() {
556
+ if (!this.renderer) {
557
+ return;
558
+ }
559
+
560
+ this.renderer.render(this.selectedValue);
561
+ }
562
+ /**
563
+ * Handle key press event
564
+ *
565
+ * @param {string} string - input string
566
+ * @param {object} key - object containing information about the pressed key
567
+ */
568
+
569
+
570
+ onKeyPress(string, key) {
571
+ if (key) {
572
+ if (key.name === 'up' && this.selectedValue > 0) {
573
+ this.selectedValue--;
574
+ this.render();
575
+ } else if (key.name === 'down' && this.selectedValue + 1 < this.values.length) {
576
+ this.selectedValue++;
577
+ this.render();
578
+ } else if (key.name === 'return') {
579
+ this.close();
580
+ } else if (key.name === 'escape' || key.name === 'c' && key.ctrl) {
581
+ this.close(true);
582
+ }
583
+ }
584
+ }
585
+
586
+ }
587
+
588
+ exports["default"] = Input;
589
+
590
+ /***/ }),
591
+
592
+ /***/ 16059:
593
+ /***/ ((__unused_webpack_module, exports, __webpack_require__) => {
594
+
595
+
596
+
597
+ Object.defineProperty(exports, "__esModule", ({
598
+ value: true
599
+ }));
600
+ exports["default"] = void 0;
601
+
602
+ var _readline = _interopRequireDefault(__webpack_require__(14521));
603
+
604
+ var _ansiEscapes = __webpack_require__(18512);
605
+
606
+ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
607
+
608
+ /**
609
+ * Response renderer
610
+ */
611
+ class Renderer {
612
+ /**
613
+ * Renderer constructor
614
+ *
615
+ * @param {object} options - renderer options
616
+ * @param {any} stream - stream to write to (optional)
617
+ */
618
+ constructor(options, stream = process.stdout) {
619
+ this.options = options;
620
+ this.stream = stream;
621
+ this.values = [];
622
+ this.initialRender = true;
623
+ }
624
+ /**
625
+ * Set the available values
626
+ *
627
+ * @param {array} values - all available values
628
+ */
629
+
630
+
631
+ setValues(values) {
632
+ this.values = values;
633
+ }
634
+ /**
635
+ * Render the values
636
+ *
637
+ * @param {number} selectedValue - selected value (optional)
638
+ */
639
+
640
+
641
+ render(selectedValue = 0) {
642
+ if (this.initialRender) {
643
+ // hide the cursor initially
644
+ this.initialRender = false;
645
+ this.stream.write(_ansiEscapes.cursorHide);
646
+ } else {
647
+ // remove previous lines and values
648
+ this.stream.write((0, _ansiEscapes.eraseLines)(this.values.length));
649
+ } // output the current values
650
+
651
+
652
+ this.values.forEach((value, index) => {
653
+ const symbol = selectedValue === index ? this.options.selected : this.options.unselected;
654
+ const indentation = ' '.repeat(this.options.indentation);
655
+ const renderedValue = this.options.valueRenderer(value, selectedValue === index);
656
+ const end = index !== this.values.length - 1 ? '\n' : '';
657
+ this.stream.write(indentation + symbol + ' ' + renderedValue + end);
658
+ });
659
+ }
660
+ /**
661
+ * Cleanup the console at the end
662
+ */
663
+
664
+
665
+ cleanup() {
666
+ this.stream.write((0, _ansiEscapes.eraseLines)(this.values.length));
667
+ this.stream.write(_ansiEscapes.cursorShow);
668
+ }
669
+
670
+ }
671
+
672
+ exports["default"] = Renderer;
673
+
674
+ /***/ }),
675
+
676
+ /***/ 26730:
677
+ /***/ ((__unused_webpack_module, exports) => {
678
+
679
+
680
+
681
+ Object.defineProperty(exports, "__esModule", ({
682
+ value: true
683
+ }));
684
+ exports.withObjectValues = exports.withArrayValues = void 0;
685
+
686
+ /**
687
+ * Map incoming and outgoing values if the initial values are an array
688
+ *
689
+ * @param {object} options - cli-select options
690
+ */
691
+ const withArrayValues = options => {
692
+ return {
693
+ input: options.values,
694
+ output: (id, value) => {
695
+ return {
696
+ id,
697
+ value
698
+ };
699
+ }
700
+ };
701
+ };
702
+ /**
703
+ * Map incoming and outgoing values if the initial values are an object
704
+ *
705
+ * @param {object} options - cli-select options
706
+ */
707
+
708
+
709
+ exports.withArrayValues = withArrayValues;
710
+
711
+ const withObjectValues = options => {
712
+ const originalValues = options.values;
713
+ return {
714
+ input: Object.values(originalValues),
715
+ output: (id, value) => {
716
+ return {
717
+ id: Object.keys(originalValues)[id],
718
+ value
719
+ };
720
+ }
721
+ };
722
+ };
723
+
724
+ exports.withObjectValues = withObjectValues;
725
+
726
+ /***/ })
727
+
728
+ };
729
+ ;