@keycloakify/angular 0.0.11 → 0.1.1

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 (61) hide show
  1. package/bin/108.index.js +242 -0
  2. package/bin/338.index.js +104 -54
  3. package/bin/402.index.js +1250 -0
  4. package/bin/758.index.js +777 -53
  5. package/bin/{925.index.js → 84.index.js} +124 -624
  6. package/bin/main.js +59 -4
  7. package/package.json +1 -1
  8. package/src/bin/add-story.ts +126 -0
  9. package/src/bin/eject-page.ts +49 -11
  10. package/src/bin/initialize-account-theme/boilerplate/KcContextMock.ts +47 -1
  11. package/src/bin/main.ts +2 -4
  12. package/src/bin/tools/nodeModulesBinDirPath.ts +38 -0
  13. package/src/bin/tools/runPrettier.ts +89 -0
  14. package/src/bin/tools/transformCodebase_async.ts +89 -0
  15. package/src/bin/update-kc-gen.ts +20 -15
  16. package/stories/account/pages/account.stories.ts +133 -0
  17. package/stories/account/pages/applications.stories.ts +196 -0
  18. package/stories/account/pages/federated-identity.stories.ts +78 -0
  19. package/stories/account/pages/log.stories.ts +147 -0
  20. package/stories/account/pages/password.stories.ts +104 -0
  21. package/stories/account/pages/sessions.stories.ts +143 -0
  22. package/stories/account/pages/totp.stories.ts +100 -0
  23. package/stories/login/pages/code.stories.ts +51 -0
  24. package/stories/login/pages/delete-account-confirm.stories.ts +43 -0
  25. package/stories/login/pages/delete-credential.stories.ts +56 -0
  26. package/stories/login/pages/error.stories.ts +56 -0
  27. package/stories/login/pages/frontchannel-logout.stories.ts +26 -0
  28. package/stories/login/pages/idp-review-user-profile.stories.ts +60 -0
  29. package/stories/login/pages/info.stories.ts +94 -0
  30. package/stories/login/pages/login-config-totp.stories.ts +57 -0
  31. package/stories/login/pages/login-device-verify-user-code.stories.ts +14 -0
  32. package/stories/login/pages/login-idp-link-confirm-override.stories.ts +17 -0
  33. package/stories/login/pages/login-idp-link-confirm.stories.ts +103 -0
  34. package/stories/login/pages/login-idp-link-email.stories.ts +102 -0
  35. package/stories/login/pages/login-oauth-grant.stories.ts +68 -0
  36. package/stories/login/pages/login-oauth2-device-verify-user-code.stories.ts +15 -0
  37. package/stories/login/pages/login-otp.stories.ts +94 -0
  38. package/stories/login/pages/login-page-expired.stories.ts +31 -0
  39. package/stories/login/pages/login-passkeys-conditional-authenticate.stories.ts +16 -0
  40. package/stories/login/pages/login-password.stories.ts +52 -0
  41. package/stories/login/pages/login-recovery-authn-code-config.stories.ts +31 -0
  42. package/stories/login/pages/login-recovery-authn-code-input.stories.ts +16 -0
  43. package/stories/login/pages/login-reset-otp.stories.ts +71 -0
  44. package/stories/login/pages/login-reset-password.stories.ts +50 -0
  45. package/stories/login/pages/login-update-password.stories.ts +46 -0
  46. package/stories/login/pages/login-update-profile.stories.ts +31 -0
  47. package/stories/login/pages/login-username.stories.ts +28 -0
  48. package/stories/login/pages/login-verify-email.stories.ts +98 -0
  49. package/stories/login/pages/login-x509-info.stories.ts +40 -0
  50. package/stories/login/pages/login.stories.ts +260 -0
  51. package/stories/login/pages/logout-confirm.stories.ts +44 -0
  52. package/stories/login/pages/register.stories.ts +230 -0
  53. package/stories/login/pages/saml-post-form.stories.ts +17 -0
  54. package/stories/login/pages/select-authenticator.stories.ts +95 -0
  55. package/stories/login/pages/terms.stories.ts +79 -0
  56. package/stories/login/pages/update-email.stories.ts +31 -0
  57. package/stories/login/pages/webauthn-authenticate.stories.ts +126 -0
  58. package/stories/login/pages/webauthn-error.stories.ts +62 -0
  59. package/stories/login/pages/webauthn-register.stories.ts +46 -0
  60. package/src/bin/tools/runFormat.ts +0 -71
  61. package/src/stories/login/pages/login/login.stories.ts +0 -146
@@ -1,9 +1,9 @@
1
1
  "use strict";
2
- exports.id = 925;
3
- exports.ids = [925];
2
+ exports.id = 84;
3
+ exports.ids = [84];
4
4
  exports.modules = {
5
5
 
6
- /***/ 925:
6
+ /***/ 84:
7
7
  /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
8
8
 
9
9
 
@@ -160,7 +160,7 @@ function rmSync(dirPath, options) {
160
160
  removeDir_rec(dirPath);
161
161
  }
162
162
 
163
- ;// CONCATENATED MODULE: ./dist/bin/tools/transformCodebase.js
163
+ ;// CONCATENATED MODULE: ./dist/bin/tools/transformCodebase_async.js
164
164
 
165
165
 
166
166
 
@@ -170,7 +170,7 @@ function rmSync(dirPath, options) {
170
170
  * If source and destination are the same this function can be used to apply the transformation in place
171
171
  * like filtering out some files or modifying them.
172
172
  * */
173
- function transformCodebase(params) {
173
+ async function transformCodebase(params) {
174
174
  const { srcDirPath, transformSourceCode } = params;
175
175
  const isTargetSameAsSource = external_path_.relative(srcDirPath, params.destDirPath) === '';
176
176
  const destDirPath = isTargetSameAsSource
@@ -194,7 +194,7 @@ function transformCodebase(params) {
194
194
  external_fs_.copyFileSync(filePath, destFilePath);
195
195
  continue;
196
196
  }
197
- const transformSourceCodeResult = transformSourceCode({
197
+ const transformSourceCodeResult = await transformSourceCode({
198
198
  sourceCode: external_fs_.readFileSync(filePath),
199
199
  filePath,
200
200
  fileRelativePath
@@ -257,8 +257,8 @@ function replaceAll(string, searchValue, replaceValue) {
257
257
  return string.replace(regexFromString, replaceValue);
258
258
  }
259
259
 
260
- // EXTERNAL MODULE: ./dist/bin/tools/runFormat.js
261
- var runFormat = __webpack_require__(49);
260
+ // EXTERNAL MODULE: ./dist/bin/tools/runPrettier.js + 1 modules
261
+ var runPrettier = __webpack_require__(199);
262
262
  ;// CONCATENATED MODULE: ./dist/bin/eject-page.js
263
263
 
264
264
 
@@ -348,12 +348,24 @@ async function command(params) {
348
348
  continue;
349
349
  }
350
350
  const localThemeTypeDirPath = (0,external_path_.join)((0,getThisCodebaseRootDirPath/* getThisCodebaseRootDirPath */.J)(), 'src', themeType);
351
- transformCodebase({
351
+ await transformCodebase({
352
352
  srcDirPath: (0,external_path_.join)(localThemeTypeDirPath, componentDirRelativeToThemeTypePath_i),
353
353
  destDirPath,
354
- transformSourceCode: ({ filePath, sourceCode }) => {
354
+ transformSourceCode: async ({ filePath, sourceCode }) => {
355
355
  if (!filePath.endsWith('.ts')) {
356
- return { modifiedSourceCode: sourceCode };
356
+ let modifiedSourceCode_str = sourceCode.toString('utf8');
357
+ run_prettier: {
358
+ if (!(await (0,runPrettier/* getIsPrettierAvailable */.L)())) {
359
+ break run_prettier;
360
+ }
361
+ modifiedSourceCode_str = await (0,runPrettier/* runPrettier */.JS)({
362
+ filePath,
363
+ sourceCode: modifiedSourceCode_str
364
+ });
365
+ }
366
+ return {
367
+ modifiedSourceCode: Buffer.from(modifiedSourceCode_str, 'utf8')
368
+ };
357
369
  }
358
370
  if (filePath.endsWith('index.ts')) {
359
371
  return undefined;
@@ -382,6 +394,15 @@ async function command(params) {
382
394
  })
383
395
  });
384
396
  });
397
+ run_prettier: {
398
+ if (!(await (0,runPrettier/* getIsPrettierAvailable */.L)())) {
399
+ break run_prettier;
400
+ }
401
+ modifiedSourceCode_str = await (0,runPrettier/* runPrettier */.JS)({
402
+ filePath,
403
+ sourceCode: modifiedSourceCode_str
404
+ });
405
+ }
385
406
  return {
386
407
  modifiedSourceCode: Buffer.from(modifiedSourceCode_str, 'utf8')
387
408
  };
@@ -390,9 +411,6 @@ async function command(params) {
390
411
  console.log(`${source/* default */.Ay.green('✓')} ${source/* default */.Ay.bold(`.${external_path_.sep}` + (0,external_path_.relative)(process.cwd(), destDirPath))} moved from the @keycloakify/angular to your project`);
391
412
  }
392
413
  }
393
- (0,runFormat/* runFormat */.J)({
394
- packageJsonFilePath: buildContext.packageJsonFilePath
395
- });
396
414
  edit_KcPage: {
397
415
  if (pageIdOrComponent !== templateValue &&
398
416
  pageIdOrComponent !== userProfileFormFieldsValue) {
@@ -400,13 +418,23 @@ async function command(params) {
400
418
  }
401
419
  const kcAppTsFilePath = (0,external_path_.join)(buildContext.themeSrcDirPath, themeType, 'KcPage.ts');
402
420
  const kcAppTsCode = external_fs_.readFileSync(kcAppTsFilePath).toString('utf8');
403
- const modifiedKcAppTsCode = (() => {
421
+ const modifiedKcAppTsCode = await (async () => {
404
422
  const componentRelativeDirPath_posix = componentDirRelativeToThemeTypePath
405
423
  .split(external_path_.sep)
406
424
  .join('/');
407
- return kcAppTsCode.replace(`@keycloakify/angular/${themeType}/${componentRelativeDirPath_posix}`, componentRelativeDirPath_posix_to_componentRelativeFilePath_posix({
425
+ let sourceCode = kcAppTsCode.replace(`@keycloakify/angular/${themeType}/${componentRelativeDirPath_posix}`, componentRelativeDirPath_posix_to_componentRelativeFilePath_posix({
408
426
  componentRelativeDirPath_posix: `./${componentRelativeDirPath_posix}`
409
427
  }));
428
+ run_prettier: {
429
+ if (!(await (0,runPrettier/* getIsPrettierAvailable */.L)())) {
430
+ break run_prettier;
431
+ }
432
+ sourceCode = await (0,runPrettier/* runPrettier */.JS)({
433
+ filePath: kcAppTsFilePath,
434
+ sourceCode
435
+ });
436
+ }
437
+ return sourceCode;
410
438
  })();
411
439
  if (modifiedKcAppTsCode === kcAppTsCode) {
412
440
  console.log(source/* default */.Ay.red('Unable to automatically update KcPage.ts, please update it manually'));
@@ -500,637 +528,109 @@ function getThisCodebaseRootDirPath() {
500
528
 
501
529
  /***/ }),
502
530
 
503
- /***/ 49:
531
+ /***/ 199:
504
532
  /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
505
533
 
506
- /* harmony export */ __webpack_require__.d(__webpack_exports__, {
507
- /* harmony export */ J: () => (/* binding */ runFormat)
508
- /* harmony export */ });
509
- /* harmony import */ var fs__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(896);
510
- /* harmony import */ var fs__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(fs__WEBPACK_IMPORTED_MODULE_0__);
511
- /* harmony import */ var path__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(928);
512
- /* harmony import */ var path__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(path__WEBPACK_IMPORTED_MODULE_1__);
513
- /* harmony import */ var tsafe_assert__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(966);
514
- /* harmony import */ var chalk__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(797);
515
- /* harmony import */ var tsafe_id__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(94);
516
- /* harmony import */ var zod__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(383);
517
- /* harmony import */ var tsafe_is__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(289);
518
- /* harmony import */ var child_process__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(317);
519
- /* harmony import */ var child_process__WEBPACK_IMPORTED_MODULE_4___default = /*#__PURE__*/__webpack_require__.n(child_process__WEBPACK_IMPORTED_MODULE_4__);
520
-
521
-
522
-
523
-
524
534
 
535
+ // EXPORTS
536
+ __webpack_require__.d(__webpack_exports__, {
537
+ L: () => (/* binding */ getIsPrettierAvailable),
538
+ JS: () => (/* binding */ runPrettier)
539
+ });
525
540
 
541
+ // UNUSED EXPORTS: getPrettierAndConfig
526
542
 
543
+ // EXTERNAL MODULE: external "path"
544
+ var external_path_ = __webpack_require__(928);
545
+ ;// CONCATENATED MODULE: ./dist/bin/tools/nodeModulesBinDirPath.js
527
546
 
528
- function runFormat(params) {
529
- const { packageJsonFilePath } = params;
530
- const parsedPackageJson = (() => {
531
- const zParsedPackageJson = (() => {
532
- const zTargetType = zod__WEBPACK_IMPORTED_MODULE_5__.z.object({
533
- scripts: zod__WEBPACK_IMPORTED_MODULE_5__.z.record(zod__WEBPACK_IMPORTED_MODULE_5__.z.string()).optional()
534
- });
535
- (0,tsafe_assert__WEBPACK_IMPORTED_MODULE_2__/* .assert */ .v)();
536
- return (0,tsafe_id__WEBPACK_IMPORTED_MODULE_6__.id)(zTargetType);
537
- })();
538
- const parsedPackageJson = JSON.parse(fs__WEBPACK_IMPORTED_MODULE_0__.readFileSync(packageJsonFilePath).toString('utf8'));
539
- zParsedPackageJson.parse(parsedPackageJson);
540
- (0,tsafe_assert__WEBPACK_IMPORTED_MODULE_2__/* .assert */ .v)((0,tsafe_is__WEBPACK_IMPORTED_MODULE_3__.is)(parsedPackageJson));
541
- return parsedPackageJson;
542
- })();
543
- const { scripts } = parsedPackageJson;
544
- if (scripts === undefined) {
545
- return;
547
+ let cache = undefined;
548
+ function getNodeModulesBinDirPath() {
549
+ if (cache !== undefined) {
550
+ return cache;
546
551
  }
547
- for (const scriptName of ['format', 'lint']) {
548
- if (!(scriptName in scripts)) {
552
+ const binPath = process.argv[1];
553
+ const segments = ['.bin'];
554
+ let foundNodeModules = false;
555
+ for (const segment of binPath.split(external_path_.sep).reverse()) {
556
+ skip_segment: {
557
+ if (foundNodeModules) {
558
+ break skip_segment;
559
+ }
560
+ if (segment === 'node_modules') {
561
+ foundNodeModules = true;
562
+ break skip_segment;
563
+ }
549
564
  continue;
550
565
  }
551
- const command = `npm run ${scriptName}`;
552
- console.log(chalk__WEBPACK_IMPORTED_MODULE_7__/* ["default"] */ .Ay.grey(`$ ${command}`));
553
- try {
554
- child_process__WEBPACK_IMPORTED_MODULE_4__.execSync(`npm run ${scriptName}`, {
555
- stdio: 'inherit',
556
- cwd: (0,path__WEBPACK_IMPORTED_MODULE_1__.dirname)(packageJsonFilePath)
557
- });
558
- }
559
- catch (_a) {
560
- console.log(chalk__WEBPACK_IMPORTED_MODULE_7__/* ["default"] */ .Ay.yellow(`\`${command}\` failed, please format your code manually, continuing...`));
561
- }
562
- return;
566
+ segments.unshift(segment);
563
567
  }
568
+ const nodeModulesBinDirPath = segments.join(external_path_.sep);
569
+ cache = nodeModulesBinDirPath;
570
+ return nodeModulesBinDirPath;
564
571
  }
565
572
 
573
+ // EXTERNAL MODULE: external "fs/promises"
574
+ var promises_ = __webpack_require__(943);
575
+ // EXTERNAL MODULE: ./node_modules/tsafe/esm/id.mjs
576
+ var id = __webpack_require__(94);
577
+ // EXTERNAL MODULE: ./node_modules/tsafe/esm/assert.mjs + 1 modules
578
+ var assert = __webpack_require__(966);
579
+ // EXTERNAL MODULE: ./node_modules/chalk/source/index.js + 3 modules
580
+ var source = __webpack_require__(797);
581
+ ;// CONCATENATED MODULE: ./dist/bin/tools/runPrettier.js
566
582
 
567
- /***/ }),
568
-
569
- /***/ 672:
570
- /***/ ((__unused_webpack_module, exports) => {
571
-
572
-
573
-
574
- Object.defineProperty(exports, "__esModule", ({
575
- value: true
576
- }));
577
- exports.withPromise = exports.withCallback = void 0;
578
-
579
- /**
580
- * Open the input with a normal callback function
581
- *
582
- * @param {Input} input - input object
583
- * @param {function} valueMapper - function which maps the resulting id and value back to the expected format
584
- * @param {function} callback - callback function
585
- */
586
- const withCallback = (input, valueMapper, callback) => {
587
- input.open();
588
- input.onSelect((id, value) => callback(valueMapper(id, value)));
589
- };
590
- /**
591
- * Open the input with a promise
592
- *
593
- * @param {Input} input - input object
594
- * @param {function} valueMapper - function which maps the resulting id and value back to the expected format
595
- */
596
-
597
-
598
- exports.withCallback = withCallback;
599
-
600
- const withPromise = (input, valueMapper) => {
601
- return new Promise((resolve, reject) => {
602
- input.open();
603
- input.onSelect((id, value) => {
604
- if (id === null) {
605
- reject();
606
- } else {
607
- resolve(valueMapper(id, value));
608
- }
609
- });
610
- });
611
- };
612
-
613
- exports.withPromise = withPromise;
614
-
615
- /***/ }),
616
-
617
- /***/ 546:
618
- /***/ ((module, exports, __webpack_require__) => {
619
-
620
-
621
-
622
- Object.defineProperty(exports, "__esModule", ({
623
- value: true
624
- }));
625
- exports["default"] = void 0;
626
-
627
- var _input = _interopRequireDefault(__webpack_require__(938));
628
-
629
- var _renderer = _interopRequireDefault(__webpack_require__(547));
630
-
631
- var _callbackMappers = __webpack_require__(672);
632
-
633
- var _valueMappers = __webpack_require__(348);
634
-
635
- function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
636
-
637
- 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; }
638
-
639
- 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; }
640
-
641
- /**
642
- * Default options
643
- */
644
- const defaultOptions = {
645
- outputStream: process.stdout,
646
- inputStream: process.stdin,
647
- values: [],
648
- defaultValue: 0,
649
- selected: '(x)',
650
- unselected: '( )',
651
- indentation: 0,
652
- cleanup: true,
653
- valueRenderer: value => value
654
- };
655
- /**
656
- * Create an instance of cli-select with the given options
657
- *
658
- * @param {object} options - options for cli-select
659
- * @param {function} callback - if specified, a callback will be used, otherwise a promise gets returned (optional)
660
- */
661
-
662
- const creator = (options, callback) => {
663
- // merge options with default options
664
- options = _objectSpread({}, defaultOptions, options); // create renderer and input instances
665
-
666
- const renderer = new _renderer.default(options, options.outputStream);
667
- const input = new _input.default(options.inputStream);
668
- input.setDefaultValue(options.defaultValue);
669
- input.attachRenderer(renderer); // handle array and object values
670
-
671
- let valueMapper;
672
-
673
- if (Array.isArray(options.values)) {
674
- valueMapper = (0, _valueMappers.withArrayValues)(options);
675
- } else {
676
- valueMapper = (0, _valueMappers.withObjectValues)(options);
677
- } // map values
678
-
679
-
680
- options.values = valueMapper.input;
681
- input.setValues(options.values); // handle different callback methods
682
-
683
- if (typeof callback === 'function') {
684
- return (0, _callbackMappers.withCallback)(input, valueMapper.output, callback);
685
- } else {
686
- return (0, _callbackMappers.withPromise)(input, valueMapper.output);
687
- }
688
- };
689
-
690
- exports = module.exports = creator;
691
- Object.defineProperty(exports, "__esModule", ({
692
- value: true
693
- }));
694
- var _default = creator;
695
- exports["default"] = _default;
696
-
697
- /***/ }),
698
-
699
- /***/ 938:
700
- /***/ ((__unused_webpack_module, exports, __webpack_require__) => {
701
-
702
-
703
-
704
- Object.defineProperty(exports, "__esModule", ({
705
- value: true
706
- }));
707
- exports["default"] = void 0;
708
-
709
- var _readline = _interopRequireDefault(__webpack_require__(785));
710
-
711
- function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
712
-
713
- /**
714
- * Handle cli input
715
- */
716
- class Input {
717
- /**
718
- * Input constructor
719
- *
720
- * @param {any} stream - stream to catch (optional)
721
- */
722
- constructor(stream = process.stdin) {
723
- // set default values
724
- this.stream = stream;
725
- this.values = [];
726
- this.selectedValue = 0;
727
-
728
- this.onSelectListener = () => {};
729
-
730
- this.onKeyPress = this.onKeyPress.bind(this);
731
- }
732
- /**
733
- * Set the available values
734
- *
735
- * @param {array} values - all available values
736
- */
737
-
738
-
739
- setValues(values) {
740
- this.values = values;
741
-
742
- if (this.renderer) {
743
- this.renderer.setValues(values);
744
- }
745
- }
746
- /**
747
- * Set the default value
748
- *
749
- * @param {number} defaultValue - default value id
750
- */
751
-
752
-
753
- setDefaultValue(defaultValue) {
754
- this.selectedValue = defaultValue;
755
- }
756
- /**
757
- * Attach a renderer to the input catcher
758
- *
759
- * @param {Renderer} renderer - renderer to use for rendering responses
760
- */
761
-
762
-
763
- attachRenderer(renderer) {
764
- this.renderer = renderer;
765
- this.renderer.setValues(this.values);
766
- }
767
- /**
768
- * Register an on select listener
769
- *
770
- * @param {function} listener - listener function which receives two parameters: valueId and value
771
- */
772
-
773
-
774
- onSelect(listener) {
775
- this.onSelectListener = listener;
776
- }
777
- /**
778
- * Open the stream and listen for input
779
- */
780
-
781
-
782
- open() {
783
- // register keypress event
784
- _readline.default.emitKeypressEvents(this.stream); // handle keypress
785
-
786
-
787
- this.stream.on('keypress', this.onKeyPress); // initially render the response
788
-
789
- if (this.renderer) {
790
- this.renderer.render(this.selectedValue);
791
- } // hide pressed keys and start listening on input
792
-
793
-
794
- this.stream.setRawMode(true);
795
- this.stream.resume();
796
- }
797
- /**
798
- * Close the stream
799
- *
800
- * @param {boolean} cancelled - true if no value was selected (optional)
801
- */
802
-
803
-
804
- close(cancelled = false) {
805
- // reset stream properties
806
- this.stream.setRawMode(false);
807
- this.stream.pause(); // cleanup the output
808
-
809
- if (this.renderer) {
810
- this.renderer.cleanup();
811
- } // call the on select listener
812
-
813
-
814
- if (cancelled) {
815
- this.onSelectListener(null);
816
- } else {
817
- this.onSelectListener(this.selectedValue, this.values[this.selectedValue]);
818
- }
819
-
820
- this.stream.removeListener('keypress', this.onKeyPress);
821
- }
822
- /**
823
- * Render the response
824
- */
825
583
 
826
584
 
827
- render() {
828
- if (!this.renderer) {
829
- return;
830
- }
831
585
 
832
- this.renderer.render(this.selectedValue);
833
- }
834
- /**
835
- * Handle key press event
836
- *
837
- * @param {string} string - input string
838
- * @param {object} key - object containing information about the pressed key
839
- */
840
586
 
841
587
 
842
- onKeyPress(string, key) {
843
- if (key) {
844
- if (key.name === 'up' && this.selectedValue > 0) {
845
- this.selectedValue--;
846
- this.render();
847
- } else if (key.name === 'down' && this.selectedValue + 1 < this.values.length) {
848
- this.selectedValue++;
849
- this.render();
850
- } else if (key.name === 'return') {
851
- this.close();
852
- } else if (key.name === 'escape' || key.name === 'c' && key.ctrl) {
853
- this.close(true);
854
- }
588
+ getIsPrettierAvailable.cache = (0,id.id)(undefined);
589
+ async function getIsPrettierAvailable() {
590
+ var _a;
591
+ if (getIsPrettierAvailable.cache !== undefined) {
592
+ return getIsPrettierAvailable.cache;
855
593
  }
856
- }
857
-
594
+ const nodeModulesBinDirPath = getNodeModulesBinDirPath();
595
+ const prettierBinPath = (0,external_path_.join)(nodeModulesBinDirPath, 'prettier');
596
+ const stats = await promises_.stat(prettierBinPath).catch(() => undefined);
597
+ const isPrettierAvailable = (_a = stats === null || stats === void 0 ? void 0 : stats.isFile()) !== null && _a !== void 0 ? _a : false;
598
+ getIsPrettierAvailable.cache = isPrettierAvailable;
599
+ return isPrettierAvailable;
858
600
  }
859
-
860
- exports["default"] = Input;
861
-
862
- /***/ }),
863
-
864
- /***/ 547:
865
- /***/ ((__unused_webpack_module, exports, __webpack_require__) => {
866
-
867
-
868
-
869
- Object.defineProperty(exports, "__esModule", ({
870
- value: true
871
- }));
872
- exports["default"] = void 0;
873
-
874
- var _readline = _interopRequireDefault(__webpack_require__(785));
875
-
876
- var _ansiEscapes = __webpack_require__(719);
877
-
878
- function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
879
-
880
- /**
881
- * Response renderer
882
- */
883
- class Renderer {
884
- /**
885
- * Renderer constructor
886
- *
887
- * @param {object} options - renderer options
888
- * @param {any} stream - stream to write to (optional)
889
- */
890
- constructor(options, stream = process.stdout) {
891
- this.options = options;
892
- this.stream = stream;
893
- this.values = [];
894
- this.initialRender = true;
895
- }
896
- /**
897
- * Set the available values
898
- *
899
- * @param {array} values - all available values
900
- */
901
-
902
-
903
- setValues(values) {
904
- this.values = values;
905
- }
906
- /**
907
- * Render the values
908
- *
909
- * @param {number} selectedValue - selected value (optional)
910
- */
911
-
912
-
913
- render(selectedValue = 0) {
914
- if (this.initialRender) {
915
- // hide the cursor initially
916
- this.initialRender = false;
917
- this.stream.write(_ansiEscapes.cursorHide);
918
- } else {
919
- // remove previous lines and values
920
- this.stream.write((0, _ansiEscapes.eraseLines)(this.values.length));
921
- } // output the current values
922
-
923
-
924
- this.values.forEach((value, index) => {
925
- const symbol = selectedValue === index ? this.options.selected : this.options.unselected;
926
- const indentation = ' '.repeat(this.options.indentation);
927
- const renderedValue = this.options.valueRenderer(value, selectedValue === index);
928
- const end = index !== this.values.length - 1 ? '\n' : '';
929
- this.stream.write(indentation + symbol + ' ' + renderedValue + end);
930
- });
931
- }
932
- /**
933
- * Cleanup the console at the end
934
- */
935
-
936
-
937
- cleanup() {
938
- this.stream.write((0, _ansiEscapes.eraseLines)(this.values.length));
939
- this.stream.write(_ansiEscapes.cursorShow);
940
- }
941
-
601
+ getPrettierAndConfig.cache = (0,id.id)(undefined);
602
+ async function getPrettierAndConfig() {
603
+ (0,assert/* assert */.v)(getIsPrettierAvailable());
604
+ if (getPrettierAndConfig.cache !== undefined) {
605
+ return getPrettierAndConfig.cache;
606
+ }
607
+ const prettier = await Promise.resolve(/* import() */).then(__webpack_require__.t.bind(__webpack_require__, 824, 23));
608
+ const prettierAndConfig = {
609
+ prettier,
610
+ config: await prettier.resolveConfig((0,external_path_.join)(getNodeModulesBinDirPath(), '..'))
611
+ };
612
+ getPrettierAndConfig.cache = prettierAndConfig;
613
+ return prettierAndConfig;
942
614
  }
943
-
944
- exports["default"] = Renderer;
945
-
946
- /***/ }),
947
-
948
- /***/ 348:
949
- /***/ ((__unused_webpack_module, exports) => {
950
-
951
-
952
-
953
- Object.defineProperty(exports, "__esModule", ({
954
- value: true
955
- }));
956
- exports.withObjectValues = exports.withArrayValues = void 0;
957
-
958
- /**
959
- * Map incoming and outgoing values if the initial values are an array
960
- *
961
- * @param {object} options - cli-select options
962
- */
963
- const withArrayValues = options => {
964
- return {
965
- input: options.values,
966
- output: (id, value) => {
967
- return {
968
- id,
969
- value
970
- };
615
+ async function runPrettier(params) {
616
+ const { sourceCode, filePath } = params;
617
+ let formattedSourceCode;
618
+ try {
619
+ const { prettier, config } = await getPrettierAndConfig();
620
+ const { ignored, inferredParser } = await prettier.getFileInfo(filePath, {
621
+ resolveConfig: true
622
+ });
623
+ if (ignored) {
624
+ return sourceCode;
625
+ }
626
+ formattedSourceCode = await prettier.format(sourceCode, Object.assign(Object.assign({}, config), { filePath, parser: inferredParser !== null && inferredParser !== void 0 ? inferredParser : undefined }));
971
627
  }
972
- };
973
- };
974
- /**
975
- * Map incoming and outgoing values if the initial values are an object
976
- *
977
- * @param {object} options - cli-select options
978
- */
979
-
980
-
981
- exports.withArrayValues = withArrayValues;
982
-
983
- const withObjectValues = options => {
984
- const originalValues = options.values;
985
- return {
986
- input: Object.values(originalValues),
987
- output: (id, value) => {
988
- return {
989
- id: Object.keys(originalValues)[id],
990
- value
991
- };
628
+ catch (error) {
629
+ console.log(source/* default */.Ay.red(`You probably need to upgrade the version of prettier in your project`));
630
+ throw error;
992
631
  }
993
- };
994
- };
995
-
996
- exports.withObjectValues = withObjectValues;
997
-
998
- /***/ }),
999
-
1000
- /***/ 719:
1001
- /***/ ((module) => {
1002
-
1003
-
1004
- const x = module.exports;
1005
- const ESC = '\u001B[';
1006
- const OSC = '\u001B]';
1007
- const BEL = '\u0007';
1008
- const SEP = ';';
1009
- const isTerminalApp = process.env.TERM_PROGRAM === 'Apple_Terminal';
1010
-
1011
- x.cursorTo = (x, y) => {
1012
- if (typeof x !== 'number') {
1013
- throw new TypeError('The `x` argument is required');
1014
- }
1015
-
1016
- if (typeof y !== 'number') {
1017
- return ESC + (x + 1) + 'G';
1018
- }
1019
-
1020
- return ESC + (y + 1) + ';' + (x + 1) + 'H';
1021
- };
1022
-
1023
- x.cursorMove = (x, y) => {
1024
- if (typeof x !== 'number') {
1025
- throw new TypeError('The `x` argument is required');
1026
- }
1027
-
1028
- let ret = '';
1029
-
1030
- if (x < 0) {
1031
- ret += ESC + (-x) + 'D';
1032
- } else if (x > 0) {
1033
- ret += ESC + x + 'C';
1034
- }
1035
-
1036
- if (y < 0) {
1037
- ret += ESC + (-y) + 'A';
1038
- } else if (y > 0) {
1039
- ret += ESC + y + 'B';
1040
- }
1041
-
1042
- return ret;
1043
- };
1044
-
1045
- x.cursorUp = count => ESC + (typeof count === 'number' ? count : 1) + 'A';
1046
- x.cursorDown = count => ESC + (typeof count === 'number' ? count : 1) + 'B';
1047
- x.cursorForward = count => ESC + (typeof count === 'number' ? count : 1) + 'C';
1048
- x.cursorBackward = count => ESC + (typeof count === 'number' ? count : 1) + 'D';
1049
-
1050
- x.cursorLeft = ESC + 'G';
1051
- x.cursorSavePosition = ESC + (isTerminalApp ? '7' : 's');
1052
- x.cursorRestorePosition = ESC + (isTerminalApp ? '8' : 'u');
1053
- x.cursorGetPosition = ESC + '6n';
1054
- x.cursorNextLine = ESC + 'E';
1055
- x.cursorPrevLine = ESC + 'F';
1056
- x.cursorHide = ESC + '?25l';
1057
- x.cursorShow = ESC + '?25h';
1058
-
1059
- x.eraseLines = count => {
1060
- let clear = '';
1061
-
1062
- for (let i = 0; i < count; i++) {
1063
- clear += x.eraseLine + (i < count - 1 ? x.cursorUp() : '');
1064
- }
1065
-
1066
- if (count) {
1067
- clear += x.cursorLeft;
1068
- }
1069
-
1070
- return clear;
1071
- };
1072
-
1073
- x.eraseEndLine = ESC + 'K';
1074
- x.eraseStartLine = ESC + '1K';
1075
- x.eraseLine = ESC + '2K';
1076
- x.eraseDown = ESC + 'J';
1077
- x.eraseUp = ESC + '1J';
1078
- x.eraseScreen = ESC + '2J';
1079
- x.scrollUp = ESC + 'S';
1080
- x.scrollDown = ESC + 'T';
1081
-
1082
- x.clearScreen = '\u001Bc';
1083
-
1084
- x.clearTerminal = process.platform === 'win32' ?
1085
- `${x.eraseScreen}${ESC}0f` :
1086
- // 1. Erases the screen (Only done in case `2` is not supported)
1087
- // 2. Erases the whole screen including scrollback buffer
1088
- // 3. Moves cursor to the top-left position
1089
- // More info: https://www.real-world-systems.com/docs/ANSIcode.html
1090
- `${x.eraseScreen}${ESC}3J${ESC}H`;
1091
-
1092
- x.beep = BEL;
1093
-
1094
- x.link = (text, url) => {
1095
- return [
1096
- OSC,
1097
- '8',
1098
- SEP,
1099
- SEP,
1100
- url,
1101
- BEL,
1102
- text,
1103
- OSC,
1104
- '8',
1105
- SEP,
1106
- SEP,
1107
- BEL
1108
- ].join('');
1109
- };
1110
-
1111
- x.image = (buf, opts) => {
1112
- opts = opts || {};
1113
-
1114
- let ret = OSC + '1337;File=inline=1';
1115
-
1116
- if (opts.width) {
1117
- ret += `;width=${opts.width}`;
1118
- }
1119
-
1120
- if (opts.height) {
1121
- ret += `;height=${opts.height}`;
1122
- }
1123
-
1124
- if (opts.preserveAspectRatio === false) {
1125
- ret += ';preserveAspectRatio=0';
1126
- }
1127
-
1128
- return ret + ':' + buf.toString('base64') + BEL;
1129
- };
1130
-
1131
- x.iTerm = {};
1132
-
1133
- x.iTerm.setCwd = cwd => OSC + '50;CurrentDir=' + (cwd || process.cwd()) + BEL;
632
+ return formattedSourceCode;
633
+ }
1134
634
 
1135
635
 
1136
636
  /***/ })