@keycloakify/svelte 0.2.6 → 0.2.7

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.
@@ -6,7 +6,8 @@ export const modules = {
6
6
  /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
7
7
 
8
8
  /* harmony export */ __webpack_require__.d(__webpack_exports__, {
9
- /* harmony export */ J: () => (/* binding */ getThisCodebaseRootDirPath)
9
+ /* harmony export */ J: () => (/* binding */ getThisCodebaseRootDirPath),
10
+ /* harmony export */ x: () => (/* binding */ getNearestPackageJsonDirPath)
10
11
  /* harmony export */ });
11
12
  /* harmony import */ var fs__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(896);
12
13
  /* harmony import */ var fs__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(fs__WEBPACK_IMPORTED_MODULE_0__);
@@ -31,6 +32,12 @@ function getThisCodebaseRootDirPath() {
31
32
  }
32
33
  return (result = getThisCodebaseRootDirPath_rec(__dirname));
33
34
  }
35
+ function getNearestPackageJsonDirPath(dirPath) {
36
+ if (fs__WEBPACK_IMPORTED_MODULE_0__.existsSync(path__WEBPACK_IMPORTED_MODULE_1__.join(dirPath, 'package.json'))) {
37
+ return dirPath;
38
+ }
39
+ return getNearestPackageJsonDirPath(path__WEBPACK_IMPORTED_MODULE_1__.join(dirPath, '..'));
40
+ }
34
41
 
35
42
 
36
43
  /***/ }),
@@ -43,13 +50,35 @@ function getThisCodebaseRootDirPath() {
43
50
  /* harmony export */ });
44
51
  /* harmony import */ var path__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(928);
45
52
  /* harmony import */ var path__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(path__WEBPACK_IMPORTED_MODULE_0__);
53
+ /* harmony import */ var _getThisCodebaseRootDirPath__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(697);
54
+
46
55
 
47
56
  let cache = undefined;
57
+ /** NOTE: Careful, this function can fail when the binary
58
+ * Used is not in the node_modules directory of the project
59
+ * (for example when running tests with vscode extension we'll get
60
+ * '/Users/dylan/.vscode/extensions/vitest.explorer-1.16.0/dist/worker.js'
61
+ *
62
+ * instead of
63
+ * '/Users/joseph/.nvm/versions/node/v22.12.0/bin/node'
64
+ * or
65
+ * '/Users/joseph/github/keycloakify-starter/node_modules/.bin/vite'
66
+ *
67
+ * as the value of process.argv[1]
68
+ */
48
69
  function getNodeModulesBinDirPath() {
49
70
  if (cache !== undefined) {
50
71
  return cache;
51
72
  }
52
73
  const binPath = process.argv[1];
74
+ special_case_running_not_from_distribution: {
75
+ if (!binPath.endsWith('.ts')) {
76
+ break special_case_running_not_from_distribution;
77
+ }
78
+ const packageJsonDirPath = (0,_getThisCodebaseRootDirPath__WEBPACK_IMPORTED_MODULE_1__/* .getNearestPackageJsonDirPath */ .x)((0,path__WEBPACK_IMPORTED_MODULE_0__.dirname)(binPath));
79
+ const nodeModulesBinDirPath = (0,path__WEBPACK_IMPORTED_MODULE_0__.join)(packageJsonDirPath, 'node_modules', '.bin');
80
+ return nodeModulesBinDirPath;
81
+ }
53
82
  const segments = ['.bin'];
54
83
  let foundNodeModules = false;
55
84
  for (const segment of binPath.split(path__WEBPACK_IMPORTED_MODULE_0__.sep).reverse()) {
@@ -65,42 +94,15 @@ function getNodeModulesBinDirPath() {
65
94
  }
66
95
  segments.unshift(segment);
67
96
  }
97
+ if (!foundNodeModules) {
98
+ throw new Error(`Could not find node_modules in path ${binPath}`);
99
+ }
68
100
  const nodeModulesBinDirPath = segments.join(path__WEBPACK_IMPORTED_MODULE_0__.sep);
69
101
  cache = nodeModulesBinDirPath;
70
102
  return nodeModulesBinDirPath;
71
103
  }
72
104
 
73
105
 
74
- /***/ }),
75
-
76
- /***/ 704:
77
- /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
78
-
79
- /* harmony export */ __webpack_require__.d(__webpack_exports__, {
80
- /* harmony export */ M: () => (/* binding */ readThisNpmPackageVersion)
81
- /* harmony export */ });
82
- /* harmony import */ var fs__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(896);
83
- /* harmony import */ var fs__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(fs__WEBPACK_IMPORTED_MODULE_0__);
84
- /* harmony import */ var path__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(928);
85
- /* harmony import */ var path__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(path__WEBPACK_IMPORTED_MODULE_1__);
86
- /* harmony import */ var tsafe_assert__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(966);
87
- /* harmony import */ var _getThisCodebaseRootDirPath__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(697);
88
-
89
-
90
-
91
-
92
- let cache = undefined;
93
- function readThisNpmPackageVersion() {
94
- if (cache !== undefined) {
95
- return cache;
96
- }
97
- const version = JSON.parse(fs__WEBPACK_IMPORTED_MODULE_0__.readFileSync((0,path__WEBPACK_IMPORTED_MODULE_1__.join)((0,_getThisCodebaseRootDirPath__WEBPACK_IMPORTED_MODULE_2__/* .getThisCodebaseRootDirPath */ .J)(), 'package.json')).toString('utf8'))['version'];
98
- (0,tsafe_assert__WEBPACK_IMPORTED_MODULE_3__/* .assert */ .v)(typeof version === 'string');
99
- cache = version;
100
- return version;
101
- }
102
-
103
-
104
106
  /***/ }),
105
107
 
106
108
  /***/ 479:
@@ -121,9 +123,8 @@ function readThisNpmPackageVersion() {
121
123
  /* harmony import */ var path__WEBPACK_IMPORTED_MODULE_3___default = /*#__PURE__*/__webpack_require__.n(path__WEBPACK_IMPORTED_MODULE_3__);
122
124
  /* harmony import */ var tsafe_assert__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(966);
123
125
  /* harmony import */ var tsafe_id__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(94);
124
- /* harmony import */ var tsafe_symToStr__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(886);
126
+ /* harmony import */ var tsafe_symToStr__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(886);
125
127
  /* harmony import */ var _nodeModulesBinDirPath__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(399);
126
- /* harmony import */ var _readThisNpmPackageVersion__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(704);
127
128
  /* module decorator */ module = __webpack_require__.hmd(module);
128
129
 
129
130
 
@@ -133,8 +134,6 @@ function readThisNpmPackageVersion() {
133
134
 
134
135
 
135
136
 
136
-
137
-
138
137
  getIsPrettierAvailable.cache = (0,tsafe_id__WEBPACK_IMPORTED_MODULE_4__.id)(undefined);
139
138
  async function getIsPrettierAvailable() {
140
139
  var _a;
@@ -156,36 +155,32 @@ async function getPrettier() {
156
155
  }
157
156
  let prettier = (0,tsafe_id__WEBPACK_IMPORTED_MODULE_4__.id)(undefined);
158
157
  import_prettier: {
159
- // NOTE: When module is linked we want to make sure we import the correct version
160
- // of prettier, that is the one of the project, not the one of this repo.
161
- // So we do a sketchy eval to bypass ncc.
162
- // We make sure to only do that when linking, otherwise we import properly.
163
- if ((0,_readThisNpmPackageVersion__WEBPACK_IMPORTED_MODULE_7__/* .readThisNpmPackageVersion */ .M)().startsWith('0.0.0')) {
164
- const prettierDirPath = (0,path__WEBPACK_IMPORTED_MODULE_3__.resolve)((0,path__WEBPACK_IMPORTED_MODULE_3__.join)((0,_nodeModulesBinDirPath__WEBPACK_IMPORTED_MODULE_5__/* .getNodeModulesBinDirPath */ .p)(), '..', 'prettier'));
165
- const isCJS = true && module.exports;
166
- if (isCJS) {
167
- eval(`${(0,tsafe_symToStr__WEBPACK_IMPORTED_MODULE_8__/* .symToStr */ .I)({ prettier })} = require("${prettierDirPath}")`);
168
- }
169
- else {
170
- // eslint-disable-next-line @typescript-eslint/no-unused-vars
171
- prettier = await new Promise((_resolve) => {
172
- eval(`import("file:///${(0,path__WEBPACK_IMPORTED_MODULE_3__.join)(prettierDirPath, 'index.mjs').replace(/\\/g, '/')}").then(prettier => _resolve(prettier))`);
173
- });
174
- }
175
- (0,tsafe_assert__WEBPACK_IMPORTED_MODULE_6__/* .assert */ .v)(!(0,tsafe_assert__WEBPACK_IMPORTED_MODULE_6__.is)(prettier));
176
- break import_prettier;
158
+ const prettierDirPath = (0,path__WEBPACK_IMPORTED_MODULE_3__.resolve)((0,path__WEBPACK_IMPORTED_MODULE_3__.join)((0,_nodeModulesBinDirPath__WEBPACK_IMPORTED_MODULE_5__/* .getNodeModulesBinDirPath */ .p)(), '..', 'prettier'));
159
+ const isCJS = true && module.exports;
160
+ if (isCJS) {
161
+ eval(`${(0,tsafe_symToStr__WEBPACK_IMPORTED_MODULE_7__/* .symToStr */ .I)({ prettier })} = require("${prettierDirPath}")`);
177
162
  }
178
- prettier = await Promise.resolve(/* import() */).then(__webpack_require__.bind(__webpack_require__, 261));
163
+ else {
164
+ // eslint-disable-next-line @typescript-eslint/no-unused-vars
165
+ prettier = await new Promise((_resolve) => {
166
+ eval(`import("file:///${(0,path__WEBPACK_IMPORTED_MODULE_3__.join)(prettierDirPath, 'index.mjs').replace(/\\/g, '/')}").then(prettier => _resolve(prettier))`);
167
+ });
168
+ }
169
+ (0,tsafe_assert__WEBPACK_IMPORTED_MODULE_6__/* .assert */ .v)(!(0,tsafe_assert__WEBPACK_IMPORTED_MODULE_6__.is)(prettier));
170
+ break import_prettier;
179
171
  }
180
172
  const configHash = await (async () => {
181
- const configFilePath = await prettier.resolveConfigFile((0,path__WEBPACK_IMPORTED_MODULE_3__.join)((0,_nodeModulesBinDirPath__WEBPACK_IMPORTED_MODULE_5__/* .getNodeModulesBinDirPath */ .p)(), '..'));
173
+ const configFilePath = await prettier.resolveConfigFile((0,path__WEBPACK_IMPORTED_MODULE_3__.join)((0,_nodeModulesBinDirPath__WEBPACK_IMPORTED_MODULE_5__/* .getNodeModulesBinDirPath */ .p)(), '..', '..'));
182
174
  if (configFilePath === null) {
183
175
  return '';
184
176
  }
185
177
  const data = await fs_promises__WEBPACK_IMPORTED_MODULE_2__.readFile(configFilePath);
186
178
  return crypto__WEBPACK_IMPORTED_MODULE_1__.createHash('sha256').update(data).digest('hex');
187
179
  })();
188
- const prettierAndConfig = { prettier, configHash };
180
+ const prettierAndConfig = {
181
+ prettier,
182
+ configHash,
183
+ };
189
184
  getPrettier.cache = prettierAndConfig;
190
185
  return prettierAndConfig;
191
186
  }
@@ -194,18 +189,20 @@ async function runPrettier(params) {
194
189
  let formattedSourceCode;
195
190
  try {
196
191
  const { prettier } = await getPrettier();
197
- const { ignored, inferredParser } = await prettier.getFileInfo(filePath, { resolveConfig: true });
198
- if (ignored) {
192
+ const { ignored, inferredParser } = await prettier.getFileInfo(filePath, {
193
+ resolveConfig: true,
194
+ });
195
+ if (ignored || inferredParser === null) {
199
196
  return sourceCode;
200
197
  }
201
198
  const config = await prettier.resolveConfig(filePath);
202
- formattedSourceCode = await prettier.format(sourceCode, Object.assign(Object.assign({}, config), { filePath, parser: inferredParser !== null && inferredParser !== void 0 ? inferredParser : undefined }));
199
+ formattedSourceCode = await prettier.format(typeof sourceCode === 'string' ? sourceCode : sourceCode.toString('utf8'), Object.assign(Object.assign({}, config), { filePath, parser: inferredParser }));
203
200
  }
204
201
  catch (error) {
205
202
  console.log(chalk__WEBPACK_IMPORTED_MODULE_0___default().red(`You probably need to upgrade the version of prettier in your project`));
206
203
  throw error;
207
204
  }
208
- return formattedSourceCode;
205
+ return typeof sourceCode === 'string' ? formattedSourceCode : Buffer.from(formattedSourceCode, 'utf8');
209
206
  }
210
207
 
211
208
 
@@ -682,7 +682,8 @@ async function command(params) {
682
682
  /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
683
683
 
684
684
  /* harmony export */ __webpack_require__.d(__webpack_exports__, {
685
- /* harmony export */ J: () => (/* binding */ getThisCodebaseRootDirPath)
685
+ /* harmony export */ J: () => (/* binding */ getThisCodebaseRootDirPath),
686
+ /* harmony export */ x: () => (/* binding */ getNearestPackageJsonDirPath)
686
687
  /* harmony export */ });
687
688
  /* harmony import */ var fs__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(896);
688
689
  /* harmony import */ var fs__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(fs__WEBPACK_IMPORTED_MODULE_0__);
@@ -707,6 +708,12 @@ function getThisCodebaseRootDirPath() {
707
708
  }
708
709
  return (result = getThisCodebaseRootDirPath_rec(__dirname));
709
710
  }
711
+ function getNearestPackageJsonDirPath(dirPath) {
712
+ if (fs__WEBPACK_IMPORTED_MODULE_0__.existsSync(path__WEBPACK_IMPORTED_MODULE_1__.join(dirPath, 'package.json'))) {
713
+ return dirPath;
714
+ }
715
+ return getNearestPackageJsonDirPath(path__WEBPACK_IMPORTED_MODULE_1__.join(dirPath, '..'));
716
+ }
710
717
 
711
718
 
712
719
  /***/ }),
@@ -735,13 +742,35 @@ function kebabCaseToCamelCase(kebabCaseString) {
735
742
  /* harmony export */ });
736
743
  /* harmony import */ var path__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(928);
737
744
  /* harmony import */ var path__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(path__WEBPACK_IMPORTED_MODULE_0__);
745
+ /* harmony import */ var _getThisCodebaseRootDirPath__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(697);
746
+
738
747
 
739
748
  let cache = undefined;
749
+ /** NOTE: Careful, this function can fail when the binary
750
+ * Used is not in the node_modules directory of the project
751
+ * (for example when running tests with vscode extension we'll get
752
+ * '/Users/dylan/.vscode/extensions/vitest.explorer-1.16.0/dist/worker.js'
753
+ *
754
+ * instead of
755
+ * '/Users/joseph/.nvm/versions/node/v22.12.0/bin/node'
756
+ * or
757
+ * '/Users/joseph/github/keycloakify-starter/node_modules/.bin/vite'
758
+ *
759
+ * as the value of process.argv[1]
760
+ */
740
761
  function getNodeModulesBinDirPath() {
741
762
  if (cache !== undefined) {
742
763
  return cache;
743
764
  }
744
765
  const binPath = process.argv[1];
766
+ special_case_running_not_from_distribution: {
767
+ if (!binPath.endsWith('.ts')) {
768
+ break special_case_running_not_from_distribution;
769
+ }
770
+ const packageJsonDirPath = (0,_getThisCodebaseRootDirPath__WEBPACK_IMPORTED_MODULE_1__/* .getNearestPackageJsonDirPath */ .x)((0,path__WEBPACK_IMPORTED_MODULE_0__.dirname)(binPath));
771
+ const nodeModulesBinDirPath = (0,path__WEBPACK_IMPORTED_MODULE_0__.join)(packageJsonDirPath, 'node_modules', '.bin');
772
+ return nodeModulesBinDirPath;
773
+ }
745
774
  const segments = ['.bin'];
746
775
  let foundNodeModules = false;
747
776
  for (const segment of binPath.split(path__WEBPACK_IMPORTED_MODULE_0__.sep).reverse()) {
@@ -757,42 +786,15 @@ function getNodeModulesBinDirPath() {
757
786
  }
758
787
  segments.unshift(segment);
759
788
  }
789
+ if (!foundNodeModules) {
790
+ throw new Error(`Could not find node_modules in path ${binPath}`);
791
+ }
760
792
  const nodeModulesBinDirPath = segments.join(path__WEBPACK_IMPORTED_MODULE_0__.sep);
761
793
  cache = nodeModulesBinDirPath;
762
794
  return nodeModulesBinDirPath;
763
795
  }
764
796
 
765
797
 
766
- /***/ }),
767
-
768
- /***/ 704:
769
- /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
770
-
771
- /* harmony export */ __webpack_require__.d(__webpack_exports__, {
772
- /* harmony export */ M: () => (/* binding */ readThisNpmPackageVersion)
773
- /* harmony export */ });
774
- /* harmony import */ var fs__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(896);
775
- /* harmony import */ var fs__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(fs__WEBPACK_IMPORTED_MODULE_0__);
776
- /* harmony import */ var path__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(928);
777
- /* harmony import */ var path__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(path__WEBPACK_IMPORTED_MODULE_1__);
778
- /* harmony import */ var tsafe_assert__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(966);
779
- /* harmony import */ var _getThisCodebaseRootDirPath__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(697);
780
-
781
-
782
-
783
-
784
- let cache = undefined;
785
- function readThisNpmPackageVersion() {
786
- if (cache !== undefined) {
787
- return cache;
788
- }
789
- const version = JSON.parse(fs__WEBPACK_IMPORTED_MODULE_0__.readFileSync((0,path__WEBPACK_IMPORTED_MODULE_1__.join)((0,_getThisCodebaseRootDirPath__WEBPACK_IMPORTED_MODULE_2__/* .getThisCodebaseRootDirPath */ .J)(), 'package.json')).toString('utf8'))['version'];
790
- (0,tsafe_assert__WEBPACK_IMPORTED_MODULE_3__/* .assert */ .v)(typeof version === 'string');
791
- cache = version;
792
- return version;
793
- }
794
-
795
-
796
798
  /***/ }),
797
799
 
798
800
  /***/ 479:
@@ -813,9 +815,8 @@ function readThisNpmPackageVersion() {
813
815
  /* harmony import */ var path__WEBPACK_IMPORTED_MODULE_3___default = /*#__PURE__*/__webpack_require__.n(path__WEBPACK_IMPORTED_MODULE_3__);
814
816
  /* harmony import */ var tsafe_assert__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(966);
815
817
  /* harmony import */ var tsafe_id__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(94);
816
- /* harmony import */ var tsafe_symToStr__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(886);
818
+ /* harmony import */ var tsafe_symToStr__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(886);
817
819
  /* harmony import */ var _nodeModulesBinDirPath__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(399);
818
- /* harmony import */ var _readThisNpmPackageVersion__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(704);
819
820
  /* module decorator */ module = __webpack_require__.hmd(module);
820
821
 
821
822
 
@@ -825,8 +826,6 @@ function readThisNpmPackageVersion() {
825
826
 
826
827
 
827
828
 
828
-
829
-
830
829
  getIsPrettierAvailable.cache = (0,tsafe_id__WEBPACK_IMPORTED_MODULE_4__.id)(undefined);
831
830
  async function getIsPrettierAvailable() {
832
831
  var _a;
@@ -848,36 +847,32 @@ async function getPrettier() {
848
847
  }
849
848
  let prettier = (0,tsafe_id__WEBPACK_IMPORTED_MODULE_4__.id)(undefined);
850
849
  import_prettier: {
851
- // NOTE: When module is linked we want to make sure we import the correct version
852
- // of prettier, that is the one of the project, not the one of this repo.
853
- // So we do a sketchy eval to bypass ncc.
854
- // We make sure to only do that when linking, otherwise we import properly.
855
- if ((0,_readThisNpmPackageVersion__WEBPACK_IMPORTED_MODULE_7__/* .readThisNpmPackageVersion */ .M)().startsWith('0.0.0')) {
856
- const prettierDirPath = (0,path__WEBPACK_IMPORTED_MODULE_3__.resolve)((0,path__WEBPACK_IMPORTED_MODULE_3__.join)((0,_nodeModulesBinDirPath__WEBPACK_IMPORTED_MODULE_5__/* .getNodeModulesBinDirPath */ .p)(), '..', 'prettier'));
857
- const isCJS = true && module.exports;
858
- if (isCJS) {
859
- eval(`${(0,tsafe_symToStr__WEBPACK_IMPORTED_MODULE_8__/* .symToStr */ .I)({ prettier })} = require("${prettierDirPath}")`);
860
- }
861
- else {
862
- // eslint-disable-next-line @typescript-eslint/no-unused-vars
863
- prettier = await new Promise((_resolve) => {
864
- eval(`import("file:///${(0,path__WEBPACK_IMPORTED_MODULE_3__.join)(prettierDirPath, 'index.mjs').replace(/\\/g, '/')}").then(prettier => _resolve(prettier))`);
865
- });
866
- }
867
- (0,tsafe_assert__WEBPACK_IMPORTED_MODULE_6__/* .assert */ .v)(!(0,tsafe_assert__WEBPACK_IMPORTED_MODULE_6__.is)(prettier));
868
- break import_prettier;
850
+ const prettierDirPath = (0,path__WEBPACK_IMPORTED_MODULE_3__.resolve)((0,path__WEBPACK_IMPORTED_MODULE_3__.join)((0,_nodeModulesBinDirPath__WEBPACK_IMPORTED_MODULE_5__/* .getNodeModulesBinDirPath */ .p)(), '..', 'prettier'));
851
+ const isCJS = true && module.exports;
852
+ if (isCJS) {
853
+ eval(`${(0,tsafe_symToStr__WEBPACK_IMPORTED_MODULE_7__/* .symToStr */ .I)({ prettier })} = require("${prettierDirPath}")`);
869
854
  }
870
- prettier = await Promise.resolve(/* import() */).then(__webpack_require__.bind(__webpack_require__, 261));
855
+ else {
856
+ // eslint-disable-next-line @typescript-eslint/no-unused-vars
857
+ prettier = await new Promise((_resolve) => {
858
+ eval(`import("file:///${(0,path__WEBPACK_IMPORTED_MODULE_3__.join)(prettierDirPath, 'index.mjs').replace(/\\/g, '/')}").then(prettier => _resolve(prettier))`);
859
+ });
860
+ }
861
+ (0,tsafe_assert__WEBPACK_IMPORTED_MODULE_6__/* .assert */ .v)(!(0,tsafe_assert__WEBPACK_IMPORTED_MODULE_6__.is)(prettier));
862
+ break import_prettier;
871
863
  }
872
864
  const configHash = await (async () => {
873
- const configFilePath = await prettier.resolveConfigFile((0,path__WEBPACK_IMPORTED_MODULE_3__.join)((0,_nodeModulesBinDirPath__WEBPACK_IMPORTED_MODULE_5__/* .getNodeModulesBinDirPath */ .p)(), '..'));
865
+ const configFilePath = await prettier.resolveConfigFile((0,path__WEBPACK_IMPORTED_MODULE_3__.join)((0,_nodeModulesBinDirPath__WEBPACK_IMPORTED_MODULE_5__/* .getNodeModulesBinDirPath */ .p)(), '..', '..'));
874
866
  if (configFilePath === null) {
875
867
  return '';
876
868
  }
877
869
  const data = await fs_promises__WEBPACK_IMPORTED_MODULE_2__.readFile(configFilePath);
878
870
  return crypto__WEBPACK_IMPORTED_MODULE_1__.createHash('sha256').update(data).digest('hex');
879
871
  })();
880
- const prettierAndConfig = { prettier, configHash };
872
+ const prettierAndConfig = {
873
+ prettier,
874
+ configHash,
875
+ };
881
876
  getPrettier.cache = prettierAndConfig;
882
877
  return prettierAndConfig;
883
878
  }
@@ -886,18 +881,20 @@ async function runPrettier(params) {
886
881
  let formattedSourceCode;
887
882
  try {
888
883
  const { prettier } = await getPrettier();
889
- const { ignored, inferredParser } = await prettier.getFileInfo(filePath, { resolveConfig: true });
890
- if (ignored) {
884
+ const { ignored, inferredParser } = await prettier.getFileInfo(filePath, {
885
+ resolveConfig: true,
886
+ });
887
+ if (ignored || inferredParser === null) {
891
888
  return sourceCode;
892
889
  }
893
890
  const config = await prettier.resolveConfig(filePath);
894
- formattedSourceCode = await prettier.format(sourceCode, Object.assign(Object.assign({}, config), { filePath, parser: inferredParser !== null && inferredParser !== void 0 ? inferredParser : undefined }));
891
+ formattedSourceCode = await prettier.format(typeof sourceCode === 'string' ? sourceCode : sourceCode.toString('utf8'), Object.assign(Object.assign({}, config), { filePath, parser: inferredParser }));
895
892
  }
896
893
  catch (error) {
897
894
  console.log(chalk__WEBPACK_IMPORTED_MODULE_0___default().red(`You probably need to upgrade the version of prettier in your project`));
898
895
  throw error;
899
896
  }
900
- return formattedSourceCode;
897
+ return typeof sourceCode === 'string' ? formattedSourceCode : Buffer.from(formattedSourceCode, 'utf8');
901
898
  }
902
899
 
903
900
 
@@ -145,7 +145,8 @@ async function command(params) {
145
145
  /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
146
146
 
147
147
  /* harmony export */ __webpack_require__.d(__webpack_exports__, {
148
- /* harmony export */ J: () => (/* binding */ getThisCodebaseRootDirPath)
148
+ /* harmony export */ J: () => (/* binding */ getThisCodebaseRootDirPath),
149
+ /* harmony export */ x: () => (/* binding */ getNearestPackageJsonDirPath)
149
150
  /* harmony export */ });
150
151
  /* harmony import */ var fs__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(896);
151
152
  /* harmony import */ var fs__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(fs__WEBPACK_IMPORTED_MODULE_0__);
@@ -170,6 +171,12 @@ function getThisCodebaseRootDirPath() {
170
171
  }
171
172
  return (result = getThisCodebaseRootDirPath_rec(__dirname));
172
173
  }
174
+ function getNearestPackageJsonDirPath(dirPath) {
175
+ if (fs__WEBPACK_IMPORTED_MODULE_0__.existsSync(path__WEBPACK_IMPORTED_MODULE_1__.join(dirPath, 'package.json'))) {
176
+ return dirPath;
177
+ }
178
+ return getNearestPackageJsonDirPath(path__WEBPACK_IMPORTED_MODULE_1__.join(dirPath, '..'));
179
+ }
173
180
 
174
181
 
175
182
  /***/ }),
@@ -182,13 +189,35 @@ function getThisCodebaseRootDirPath() {
182
189
  /* harmony export */ });
183
190
  /* harmony import */ var path__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(928);
184
191
  /* harmony import */ var path__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(path__WEBPACK_IMPORTED_MODULE_0__);
192
+ /* harmony import */ var _getThisCodebaseRootDirPath__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(697);
193
+
185
194
 
186
195
  let cache = undefined;
196
+ /** NOTE: Careful, this function can fail when the binary
197
+ * Used is not in the node_modules directory of the project
198
+ * (for example when running tests with vscode extension we'll get
199
+ * '/Users/dylan/.vscode/extensions/vitest.explorer-1.16.0/dist/worker.js'
200
+ *
201
+ * instead of
202
+ * '/Users/joseph/.nvm/versions/node/v22.12.0/bin/node'
203
+ * or
204
+ * '/Users/joseph/github/keycloakify-starter/node_modules/.bin/vite'
205
+ *
206
+ * as the value of process.argv[1]
207
+ */
187
208
  function getNodeModulesBinDirPath() {
188
209
  if (cache !== undefined) {
189
210
  return cache;
190
211
  }
191
212
  const binPath = process.argv[1];
213
+ special_case_running_not_from_distribution: {
214
+ if (!binPath.endsWith('.ts')) {
215
+ break special_case_running_not_from_distribution;
216
+ }
217
+ const packageJsonDirPath = (0,_getThisCodebaseRootDirPath__WEBPACK_IMPORTED_MODULE_1__/* .getNearestPackageJsonDirPath */ .x)((0,path__WEBPACK_IMPORTED_MODULE_0__.dirname)(binPath));
218
+ const nodeModulesBinDirPath = (0,path__WEBPACK_IMPORTED_MODULE_0__.join)(packageJsonDirPath, 'node_modules', '.bin');
219
+ return nodeModulesBinDirPath;
220
+ }
192
221
  const segments = ['.bin'];
193
222
  let foundNodeModules = false;
194
223
  for (const segment of binPath.split(path__WEBPACK_IMPORTED_MODULE_0__.sep).reverse()) {
@@ -204,42 +233,15 @@ function getNodeModulesBinDirPath() {
204
233
  }
205
234
  segments.unshift(segment);
206
235
  }
236
+ if (!foundNodeModules) {
237
+ throw new Error(`Could not find node_modules in path ${binPath}`);
238
+ }
207
239
  const nodeModulesBinDirPath = segments.join(path__WEBPACK_IMPORTED_MODULE_0__.sep);
208
240
  cache = nodeModulesBinDirPath;
209
241
  return nodeModulesBinDirPath;
210
242
  }
211
243
 
212
244
 
213
- /***/ }),
214
-
215
- /***/ 704:
216
- /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
217
-
218
- /* harmony export */ __webpack_require__.d(__webpack_exports__, {
219
- /* harmony export */ M: () => (/* binding */ readThisNpmPackageVersion)
220
- /* harmony export */ });
221
- /* harmony import */ var fs__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(896);
222
- /* harmony import */ var fs__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(fs__WEBPACK_IMPORTED_MODULE_0__);
223
- /* harmony import */ var path__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(928);
224
- /* harmony import */ var path__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(path__WEBPACK_IMPORTED_MODULE_1__);
225
- /* harmony import */ var tsafe_assert__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(966);
226
- /* harmony import */ var _getThisCodebaseRootDirPath__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(697);
227
-
228
-
229
-
230
-
231
- let cache = undefined;
232
- function readThisNpmPackageVersion() {
233
- if (cache !== undefined) {
234
- return cache;
235
- }
236
- const version = JSON.parse(fs__WEBPACK_IMPORTED_MODULE_0__.readFileSync((0,path__WEBPACK_IMPORTED_MODULE_1__.join)((0,_getThisCodebaseRootDirPath__WEBPACK_IMPORTED_MODULE_2__/* .getThisCodebaseRootDirPath */ .J)(), 'package.json')).toString('utf8'))['version'];
237
- (0,tsafe_assert__WEBPACK_IMPORTED_MODULE_3__/* .assert */ .v)(typeof version === 'string');
238
- cache = version;
239
- return version;
240
- }
241
-
242
-
243
245
  /***/ }),
244
246
 
245
247
  /***/ 479:
@@ -260,9 +262,8 @@ function readThisNpmPackageVersion() {
260
262
  /* harmony import */ var path__WEBPACK_IMPORTED_MODULE_3___default = /*#__PURE__*/__webpack_require__.n(path__WEBPACK_IMPORTED_MODULE_3__);
261
263
  /* harmony import */ var tsafe_assert__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(966);
262
264
  /* harmony import */ var tsafe_id__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(94);
263
- /* harmony import */ var tsafe_symToStr__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(886);
265
+ /* harmony import */ var tsafe_symToStr__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(886);
264
266
  /* harmony import */ var _nodeModulesBinDirPath__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(399);
265
- /* harmony import */ var _readThisNpmPackageVersion__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(704);
266
267
  /* module decorator */ module = __webpack_require__.hmd(module);
267
268
 
268
269
 
@@ -272,8 +273,6 @@ function readThisNpmPackageVersion() {
272
273
 
273
274
 
274
275
 
275
-
276
-
277
276
  getIsPrettierAvailable.cache = (0,tsafe_id__WEBPACK_IMPORTED_MODULE_4__.id)(undefined);
278
277
  async function getIsPrettierAvailable() {
279
278
  var _a;
@@ -295,36 +294,32 @@ async function getPrettier() {
295
294
  }
296
295
  let prettier = (0,tsafe_id__WEBPACK_IMPORTED_MODULE_4__.id)(undefined);
297
296
  import_prettier: {
298
- // NOTE: When module is linked we want to make sure we import the correct version
299
- // of prettier, that is the one of the project, not the one of this repo.
300
- // So we do a sketchy eval to bypass ncc.
301
- // We make sure to only do that when linking, otherwise we import properly.
302
- if ((0,_readThisNpmPackageVersion__WEBPACK_IMPORTED_MODULE_7__/* .readThisNpmPackageVersion */ .M)().startsWith('0.0.0')) {
303
- const prettierDirPath = (0,path__WEBPACK_IMPORTED_MODULE_3__.resolve)((0,path__WEBPACK_IMPORTED_MODULE_3__.join)((0,_nodeModulesBinDirPath__WEBPACK_IMPORTED_MODULE_5__/* .getNodeModulesBinDirPath */ .p)(), '..', 'prettier'));
304
- const isCJS = true && module.exports;
305
- if (isCJS) {
306
- eval(`${(0,tsafe_symToStr__WEBPACK_IMPORTED_MODULE_8__/* .symToStr */ .I)({ prettier })} = require("${prettierDirPath}")`);
307
- }
308
- else {
309
- // eslint-disable-next-line @typescript-eslint/no-unused-vars
310
- prettier = await new Promise((_resolve) => {
311
- eval(`import("file:///${(0,path__WEBPACK_IMPORTED_MODULE_3__.join)(prettierDirPath, 'index.mjs').replace(/\\/g, '/')}").then(prettier => _resolve(prettier))`);
312
- });
313
- }
314
- (0,tsafe_assert__WEBPACK_IMPORTED_MODULE_6__/* .assert */ .v)(!(0,tsafe_assert__WEBPACK_IMPORTED_MODULE_6__.is)(prettier));
315
- break import_prettier;
297
+ const prettierDirPath = (0,path__WEBPACK_IMPORTED_MODULE_3__.resolve)((0,path__WEBPACK_IMPORTED_MODULE_3__.join)((0,_nodeModulesBinDirPath__WEBPACK_IMPORTED_MODULE_5__/* .getNodeModulesBinDirPath */ .p)(), '..', 'prettier'));
298
+ const isCJS = true && module.exports;
299
+ if (isCJS) {
300
+ eval(`${(0,tsafe_symToStr__WEBPACK_IMPORTED_MODULE_7__/* .symToStr */ .I)({ prettier })} = require("${prettierDirPath}")`);
316
301
  }
317
- prettier = await Promise.resolve(/* import() */).then(__webpack_require__.bind(__webpack_require__, 261));
302
+ else {
303
+ // eslint-disable-next-line @typescript-eslint/no-unused-vars
304
+ prettier = await new Promise((_resolve) => {
305
+ eval(`import("file:///${(0,path__WEBPACK_IMPORTED_MODULE_3__.join)(prettierDirPath, 'index.mjs').replace(/\\/g, '/')}").then(prettier => _resolve(prettier))`);
306
+ });
307
+ }
308
+ (0,tsafe_assert__WEBPACK_IMPORTED_MODULE_6__/* .assert */ .v)(!(0,tsafe_assert__WEBPACK_IMPORTED_MODULE_6__.is)(prettier));
309
+ break import_prettier;
318
310
  }
319
311
  const configHash = await (async () => {
320
- const configFilePath = await prettier.resolveConfigFile((0,path__WEBPACK_IMPORTED_MODULE_3__.join)((0,_nodeModulesBinDirPath__WEBPACK_IMPORTED_MODULE_5__/* .getNodeModulesBinDirPath */ .p)(), '..'));
312
+ const configFilePath = await prettier.resolveConfigFile((0,path__WEBPACK_IMPORTED_MODULE_3__.join)((0,_nodeModulesBinDirPath__WEBPACK_IMPORTED_MODULE_5__/* .getNodeModulesBinDirPath */ .p)(), '..', '..'));
321
313
  if (configFilePath === null) {
322
314
  return '';
323
315
  }
324
316
  const data = await fs_promises__WEBPACK_IMPORTED_MODULE_2__.readFile(configFilePath);
325
317
  return crypto__WEBPACK_IMPORTED_MODULE_1__.createHash('sha256').update(data).digest('hex');
326
318
  })();
327
- const prettierAndConfig = { prettier, configHash };
319
+ const prettierAndConfig = {
320
+ prettier,
321
+ configHash,
322
+ };
328
323
  getPrettier.cache = prettierAndConfig;
329
324
  return prettierAndConfig;
330
325
  }
@@ -333,18 +328,20 @@ async function runPrettier(params) {
333
328
  let formattedSourceCode;
334
329
  try {
335
330
  const { prettier } = await getPrettier();
336
- const { ignored, inferredParser } = await prettier.getFileInfo(filePath, { resolveConfig: true });
337
- if (ignored) {
331
+ const { ignored, inferredParser } = await prettier.getFileInfo(filePath, {
332
+ resolveConfig: true,
333
+ });
334
+ if (ignored || inferredParser === null) {
338
335
  return sourceCode;
339
336
  }
340
337
  const config = await prettier.resolveConfig(filePath);
341
- formattedSourceCode = await prettier.format(sourceCode, Object.assign(Object.assign({}, config), { filePath, parser: inferredParser !== null && inferredParser !== void 0 ? inferredParser : undefined }));
338
+ formattedSourceCode = await prettier.format(typeof sourceCode === 'string' ? sourceCode : sourceCode.toString('utf8'), Object.assign(Object.assign({}, config), { filePath, parser: inferredParser }));
342
339
  }
343
340
  catch (error) {
344
341
  console.log(chalk__WEBPACK_IMPORTED_MODULE_0___default().red(`You probably need to upgrade the version of prettier in your project`));
345
342
  throw error;
346
343
  }
347
- return formattedSourceCode;
344
+ return typeof sourceCode === 'string' ? formattedSourceCode : Buffer.from(formattedSourceCode, 'utf8');
348
345
  }
349
346
 
350
347
 
@@ -784,7 +784,8 @@ async function command(params) {
784
784
  /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
785
785
 
786
786
  /* harmony export */ __webpack_require__.d(__webpack_exports__, {
787
- /* harmony export */ J: () => (/* binding */ getThisCodebaseRootDirPath)
787
+ /* harmony export */ J: () => (/* binding */ getThisCodebaseRootDirPath),
788
+ /* harmony export */ x: () => (/* binding */ getNearestPackageJsonDirPath)
788
789
  /* harmony export */ });
789
790
  /* harmony import */ var fs__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(896);
790
791
  /* harmony import */ var fs__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(fs__WEBPACK_IMPORTED_MODULE_0__);
@@ -809,6 +810,12 @@ function getThisCodebaseRootDirPath() {
809
810
  }
810
811
  return (result = getThisCodebaseRootDirPath_rec(__dirname));
811
812
  }
813
+ function getNearestPackageJsonDirPath(dirPath) {
814
+ if (fs__WEBPACK_IMPORTED_MODULE_0__.existsSync(path__WEBPACK_IMPORTED_MODULE_1__.join(dirPath, 'package.json'))) {
815
+ return dirPath;
816
+ }
817
+ return getNearestPackageJsonDirPath(path__WEBPACK_IMPORTED_MODULE_1__.join(dirPath, '..'));
818
+ }
812
819
 
813
820
 
814
821
  /***/ }),
@@ -837,13 +844,35 @@ function kebabCaseToCamelCase(kebabCaseString) {
837
844
  /* harmony export */ });
838
845
  /* harmony import */ var path__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(928);
839
846
  /* harmony import */ var path__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(path__WEBPACK_IMPORTED_MODULE_0__);
847
+ /* harmony import */ var _getThisCodebaseRootDirPath__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(697);
848
+
840
849
 
841
850
  let cache = undefined;
851
+ /** NOTE: Careful, this function can fail when the binary
852
+ * Used is not in the node_modules directory of the project
853
+ * (for example when running tests with vscode extension we'll get
854
+ * '/Users/dylan/.vscode/extensions/vitest.explorer-1.16.0/dist/worker.js'
855
+ *
856
+ * instead of
857
+ * '/Users/joseph/.nvm/versions/node/v22.12.0/bin/node'
858
+ * or
859
+ * '/Users/joseph/github/keycloakify-starter/node_modules/.bin/vite'
860
+ *
861
+ * as the value of process.argv[1]
862
+ */
842
863
  function getNodeModulesBinDirPath() {
843
864
  if (cache !== undefined) {
844
865
  return cache;
845
866
  }
846
867
  const binPath = process.argv[1];
868
+ special_case_running_not_from_distribution: {
869
+ if (!binPath.endsWith('.ts')) {
870
+ break special_case_running_not_from_distribution;
871
+ }
872
+ const packageJsonDirPath = (0,_getThisCodebaseRootDirPath__WEBPACK_IMPORTED_MODULE_1__/* .getNearestPackageJsonDirPath */ .x)((0,path__WEBPACK_IMPORTED_MODULE_0__.dirname)(binPath));
873
+ const nodeModulesBinDirPath = (0,path__WEBPACK_IMPORTED_MODULE_0__.join)(packageJsonDirPath, 'node_modules', '.bin');
874
+ return nodeModulesBinDirPath;
875
+ }
847
876
  const segments = ['.bin'];
848
877
  let foundNodeModules = false;
849
878
  for (const segment of binPath.split(path__WEBPACK_IMPORTED_MODULE_0__.sep).reverse()) {
@@ -859,42 +888,15 @@ function getNodeModulesBinDirPath() {
859
888
  }
860
889
  segments.unshift(segment);
861
890
  }
891
+ if (!foundNodeModules) {
892
+ throw new Error(`Could not find node_modules in path ${binPath}`);
893
+ }
862
894
  const nodeModulesBinDirPath = segments.join(path__WEBPACK_IMPORTED_MODULE_0__.sep);
863
895
  cache = nodeModulesBinDirPath;
864
896
  return nodeModulesBinDirPath;
865
897
  }
866
898
 
867
899
 
868
- /***/ }),
869
-
870
- /***/ 704:
871
- /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
872
-
873
- /* harmony export */ __webpack_require__.d(__webpack_exports__, {
874
- /* harmony export */ M: () => (/* binding */ readThisNpmPackageVersion)
875
- /* harmony export */ });
876
- /* harmony import */ var fs__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(896);
877
- /* harmony import */ var fs__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(fs__WEBPACK_IMPORTED_MODULE_0__);
878
- /* harmony import */ var path__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(928);
879
- /* harmony import */ var path__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(path__WEBPACK_IMPORTED_MODULE_1__);
880
- /* harmony import */ var tsafe_assert__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(966);
881
- /* harmony import */ var _getThisCodebaseRootDirPath__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(697);
882
-
883
-
884
-
885
-
886
- let cache = undefined;
887
- function readThisNpmPackageVersion() {
888
- if (cache !== undefined) {
889
- return cache;
890
- }
891
- const version = JSON.parse(fs__WEBPACK_IMPORTED_MODULE_0__.readFileSync((0,path__WEBPACK_IMPORTED_MODULE_1__.join)((0,_getThisCodebaseRootDirPath__WEBPACK_IMPORTED_MODULE_2__/* .getThisCodebaseRootDirPath */ .J)(), 'package.json')).toString('utf8'))['version'];
892
- (0,tsafe_assert__WEBPACK_IMPORTED_MODULE_3__/* .assert */ .v)(typeof version === 'string');
893
- cache = version;
894
- return version;
895
- }
896
-
897
-
898
900
  /***/ }),
899
901
 
900
902
  /***/ 479:
@@ -915,9 +917,8 @@ function readThisNpmPackageVersion() {
915
917
  /* harmony import */ var path__WEBPACK_IMPORTED_MODULE_3___default = /*#__PURE__*/__webpack_require__.n(path__WEBPACK_IMPORTED_MODULE_3__);
916
918
  /* harmony import */ var tsafe_assert__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(966);
917
919
  /* harmony import */ var tsafe_id__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(94);
918
- /* harmony import */ var tsafe_symToStr__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(886);
920
+ /* harmony import */ var tsafe_symToStr__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(886);
919
921
  /* harmony import */ var _nodeModulesBinDirPath__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(399);
920
- /* harmony import */ var _readThisNpmPackageVersion__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(704);
921
922
  /* module decorator */ module = __webpack_require__.hmd(module);
922
923
 
923
924
 
@@ -927,8 +928,6 @@ function readThisNpmPackageVersion() {
927
928
 
928
929
 
929
930
 
930
-
931
-
932
931
  getIsPrettierAvailable.cache = (0,tsafe_id__WEBPACK_IMPORTED_MODULE_4__.id)(undefined);
933
932
  async function getIsPrettierAvailable() {
934
933
  var _a;
@@ -950,36 +949,32 @@ async function getPrettier() {
950
949
  }
951
950
  let prettier = (0,tsafe_id__WEBPACK_IMPORTED_MODULE_4__.id)(undefined);
952
951
  import_prettier: {
953
- // NOTE: When module is linked we want to make sure we import the correct version
954
- // of prettier, that is the one of the project, not the one of this repo.
955
- // So we do a sketchy eval to bypass ncc.
956
- // We make sure to only do that when linking, otherwise we import properly.
957
- if ((0,_readThisNpmPackageVersion__WEBPACK_IMPORTED_MODULE_7__/* .readThisNpmPackageVersion */ .M)().startsWith('0.0.0')) {
958
- const prettierDirPath = (0,path__WEBPACK_IMPORTED_MODULE_3__.resolve)((0,path__WEBPACK_IMPORTED_MODULE_3__.join)((0,_nodeModulesBinDirPath__WEBPACK_IMPORTED_MODULE_5__/* .getNodeModulesBinDirPath */ .p)(), '..', 'prettier'));
959
- const isCJS = true && module.exports;
960
- if (isCJS) {
961
- eval(`${(0,tsafe_symToStr__WEBPACK_IMPORTED_MODULE_8__/* .symToStr */ .I)({ prettier })} = require("${prettierDirPath}")`);
962
- }
963
- else {
964
- // eslint-disable-next-line @typescript-eslint/no-unused-vars
965
- prettier = await new Promise((_resolve) => {
966
- eval(`import("file:///${(0,path__WEBPACK_IMPORTED_MODULE_3__.join)(prettierDirPath, 'index.mjs').replace(/\\/g, '/')}").then(prettier => _resolve(prettier))`);
967
- });
968
- }
969
- (0,tsafe_assert__WEBPACK_IMPORTED_MODULE_6__/* .assert */ .v)(!(0,tsafe_assert__WEBPACK_IMPORTED_MODULE_6__.is)(prettier));
970
- break import_prettier;
952
+ const prettierDirPath = (0,path__WEBPACK_IMPORTED_MODULE_3__.resolve)((0,path__WEBPACK_IMPORTED_MODULE_3__.join)((0,_nodeModulesBinDirPath__WEBPACK_IMPORTED_MODULE_5__/* .getNodeModulesBinDirPath */ .p)(), '..', 'prettier'));
953
+ const isCJS = true && module.exports;
954
+ if (isCJS) {
955
+ eval(`${(0,tsafe_symToStr__WEBPACK_IMPORTED_MODULE_7__/* .symToStr */ .I)({ prettier })} = require("${prettierDirPath}")`);
956
+ }
957
+ else {
958
+ // eslint-disable-next-line @typescript-eslint/no-unused-vars
959
+ prettier = await new Promise((_resolve) => {
960
+ eval(`import("file:///${(0,path__WEBPACK_IMPORTED_MODULE_3__.join)(prettierDirPath, 'index.mjs').replace(/\\/g, '/')}").then(prettier => _resolve(prettier))`);
961
+ });
971
962
  }
972
- prettier = await Promise.resolve(/* import() */).then(__webpack_require__.bind(__webpack_require__, 261));
963
+ (0,tsafe_assert__WEBPACK_IMPORTED_MODULE_6__/* .assert */ .v)(!(0,tsafe_assert__WEBPACK_IMPORTED_MODULE_6__.is)(prettier));
964
+ break import_prettier;
973
965
  }
974
966
  const configHash = await (async () => {
975
- const configFilePath = await prettier.resolveConfigFile((0,path__WEBPACK_IMPORTED_MODULE_3__.join)((0,_nodeModulesBinDirPath__WEBPACK_IMPORTED_MODULE_5__/* .getNodeModulesBinDirPath */ .p)(), '..'));
967
+ const configFilePath = await prettier.resolveConfigFile((0,path__WEBPACK_IMPORTED_MODULE_3__.join)((0,_nodeModulesBinDirPath__WEBPACK_IMPORTED_MODULE_5__/* .getNodeModulesBinDirPath */ .p)(), '..', '..'));
976
968
  if (configFilePath === null) {
977
969
  return '';
978
970
  }
979
971
  const data = await fs_promises__WEBPACK_IMPORTED_MODULE_2__.readFile(configFilePath);
980
972
  return crypto__WEBPACK_IMPORTED_MODULE_1__.createHash('sha256').update(data).digest('hex');
981
973
  })();
982
- const prettierAndConfig = { prettier, configHash };
974
+ const prettierAndConfig = {
975
+ prettier,
976
+ configHash,
977
+ };
983
978
  getPrettier.cache = prettierAndConfig;
984
979
  return prettierAndConfig;
985
980
  }
@@ -988,18 +983,20 @@ async function runPrettier(params) {
988
983
  let formattedSourceCode;
989
984
  try {
990
985
  const { prettier } = await getPrettier();
991
- const { ignored, inferredParser } = await prettier.getFileInfo(filePath, { resolveConfig: true });
992
- if (ignored) {
986
+ const { ignored, inferredParser } = await prettier.getFileInfo(filePath, {
987
+ resolveConfig: true,
988
+ });
989
+ if (ignored || inferredParser === null) {
993
990
  return sourceCode;
994
991
  }
995
992
  const config = await prettier.resolveConfig(filePath);
996
- formattedSourceCode = await prettier.format(sourceCode, Object.assign(Object.assign({}, config), { filePath, parser: inferredParser !== null && inferredParser !== void 0 ? inferredParser : undefined }));
993
+ formattedSourceCode = await prettier.format(typeof sourceCode === 'string' ? sourceCode : sourceCode.toString('utf8'), Object.assign(Object.assign({}, config), { filePath, parser: inferredParser }));
997
994
  }
998
995
  catch (error) {
999
996
  console.log(chalk__WEBPACK_IMPORTED_MODULE_0___default().red(`You probably need to upgrade the version of prettier in your project`));
1000
997
  throw error;
1001
998
  }
1002
- return formattedSourceCode;
999
+ return typeof sourceCode === 'string' ? formattedSourceCode : Buffer.from(formattedSourceCode, 'utf8');
1003
1000
  }
1004
1001
 
1005
1002
 
@@ -1,5 +1,4 @@
1
1
  #!/usr/bin/env node
2
- import * as __WEBPACK_EXTERNAL_MODULE_prettier__ from "prettier";
3
2
  import { createRequire as __WEBPACK_EXTERNAL_createRequire } from "module";
4
3
  /******/ var __webpack_modules__ = ({
5
4
 
@@ -2034,13 +2033,6 @@ module.exports = {
2034
2033
  };
2035
2034
 
2036
2035
 
2037
- /***/ }),
2038
-
2039
- /***/ 261:
2040
- /***/ ((module) => {
2041
-
2042
- module.exports = __WEBPACK_EXTERNAL_MODULE_prettier__;
2043
-
2044
2036
  /***/ }),
2045
2037
 
2046
2038
  /***/ 317:
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@keycloakify/svelte",
3
- "version": "0.2.6",
3
+ "version": "0.2.7",
4
4
  "description": "Svelte Components for Keycloakify",
5
5
  "keywords": [
6
6
  "keycloak",
@@ -20,3 +20,10 @@ export function getThisCodebaseRootDirPath(): string {
20
20
 
21
21
  return (result = getThisCodebaseRootDirPath_rec(__dirname));
22
22
  }
23
+
24
+ export function getNearestPackageJsonDirPath(dirPath: string): string {
25
+ if (fs.existsSync(path.join(dirPath, 'package.json'))) {
26
+ return dirPath;
27
+ }
28
+ return getNearestPackageJsonDirPath(path.join(dirPath, '..'));
29
+ }
@@ -1,7 +1,20 @@
1
- import { sep as pathSep } from 'path';
1
+ import { dirname as pathDirname, join as pathJoin, sep as pathSep } from 'path';
2
+ import { getNearestPackageJsonDirPath } from './getThisCodebaseRootDirPath';
2
3
 
3
4
  let cache: string | undefined = undefined;
4
5
 
6
+ /** NOTE: Careful, this function can fail when the binary
7
+ * Used is not in the node_modules directory of the project
8
+ * (for example when running tests with vscode extension we'll get
9
+ * '/Users/dylan/.vscode/extensions/vitest.explorer-1.16.0/dist/worker.js'
10
+ *
11
+ * instead of
12
+ * '/Users/joseph/.nvm/versions/node/v22.12.0/bin/node'
13
+ * or
14
+ * '/Users/joseph/github/keycloakify-starter/node_modules/.bin/vite'
15
+ *
16
+ * as the value of process.argv[1]
17
+ */
5
18
  export function getNodeModulesBinDirPath() {
6
19
  if (cache !== undefined) {
7
20
  return cache;
@@ -9,6 +22,18 @@ export function getNodeModulesBinDirPath() {
9
22
 
10
23
  const binPath = process.argv[1];
11
24
 
25
+ special_case_running_not_from_distribution: {
26
+ if (!binPath.endsWith('.ts')) {
27
+ break special_case_running_not_from_distribution;
28
+ }
29
+
30
+ const packageJsonDirPath = getNearestPackageJsonDirPath(pathDirname(binPath));
31
+
32
+ const nodeModulesBinDirPath = pathJoin(packageJsonDirPath, 'node_modules', '.bin');
33
+
34
+ return nodeModulesBinDirPath;
35
+ }
36
+
12
37
  const segments: string[] = ['.bin'];
13
38
 
14
39
  let foundNodeModules = false;
@@ -30,6 +55,10 @@ export function getNodeModulesBinDirPath() {
30
55
  segments.unshift(segment);
31
56
  }
32
57
 
58
+ if (!foundNodeModules) {
59
+ throw new Error(`Could not find node_modules in path ${binPath}`);
60
+ }
61
+
33
62
  const nodeModulesBinDirPath = segments.join(pathSep);
34
63
 
35
64
  cache = nodeModulesBinDirPath;
@@ -2,12 +2,10 @@ import chalk from 'chalk';
2
2
  import * as crypto from 'crypto';
3
3
  import * as fsPr from 'fs/promises';
4
4
  import { join as pathJoin, resolve as pathResolve } from 'path';
5
- import { assert } from 'tsafe/assert';
5
+ import { assert, is } from 'tsafe/assert';
6
6
  import { id } from 'tsafe/id';
7
- import { is } from 'tsafe/is';
8
7
  import { symToStr } from 'tsafe/symToStr';
9
8
  import { getNodeModulesBinDirPath } from './nodeModulesBinDirPath';
10
- import { readThisNpmPackageVersion } from './readThisNpmPackageVersion';
11
9
 
12
10
  getIsPrettierAvailable.cache = id<boolean | undefined>(undefined);
13
11
 
@@ -29,7 +27,10 @@ export async function getIsPrettierAvailable(): Promise<boolean> {
29
27
  return isPrettierAvailable;
30
28
  }
31
29
 
32
- type PrettierAndConfigHash = { prettier: typeof import('prettier'); configHash: string };
30
+ type PrettierAndConfigHash = {
31
+ prettier: typeof import('prettier');
32
+ configHash: string;
33
+ };
33
34
 
34
35
  getPrettier.cache = id<PrettierAndConfigHash | undefined>(undefined);
35
36
 
@@ -43,36 +44,28 @@ export async function getPrettier(): Promise<PrettierAndConfigHash> {
43
44
  let prettier = id<typeof import('prettier') | undefined>(undefined);
44
45
 
45
46
  import_prettier: {
46
- // NOTE: When module is linked we want to make sure we import the correct version
47
- // of prettier, that is the one of the project, not the one of this repo.
48
- // So we do a sketchy eval to bypass ncc.
49
- // We make sure to only do that when linking, otherwise we import properly.
50
- if (readThisNpmPackageVersion().startsWith('0.0.0')) {
51
- const prettierDirPath = pathResolve(pathJoin(getNodeModulesBinDirPath(), '..', 'prettier'));
52
-
53
- const isCJS = typeof module !== 'undefined' && module.exports;
54
-
55
- if (isCJS) {
56
- eval(`${symToStr({ prettier })} = require("${prettierDirPath}")`);
57
- } else {
58
- // eslint-disable-next-line @typescript-eslint/no-unused-vars
59
- prettier = await new Promise((_resolve) => {
60
- eval(
61
- `import("file:///${pathJoin(prettierDirPath, 'index.mjs').replace(/\\/g, '/')}").then(prettier => _resolve(prettier))`,
62
- );
63
- });
64
- }
65
-
66
- assert(!is<undefined>(prettier));
67
-
68
- break import_prettier;
47
+ const prettierDirPath = pathResolve(pathJoin(getNodeModulesBinDirPath(), '..', 'prettier'));
48
+
49
+ const isCJS = typeof module !== 'undefined' && module.exports;
50
+
51
+ if (isCJS) {
52
+ eval(`${symToStr({ prettier })} = require("${prettierDirPath}")`);
53
+ } else {
54
+ // eslint-disable-next-line @typescript-eslint/no-unused-vars
55
+ prettier = await new Promise((_resolve) => {
56
+ eval(
57
+ `import("file:///${pathJoin(prettierDirPath, 'index.mjs').replace(/\\/g, '/')}").then(prettier => _resolve(prettier))`,
58
+ );
59
+ });
69
60
  }
70
61
 
71
- prettier = await import('prettier');
62
+ assert(!is<undefined>(prettier));
63
+
64
+ break import_prettier;
72
65
  }
73
66
 
74
67
  const configHash = await (async () => {
75
- const configFilePath = await prettier.resolveConfigFile(pathJoin(getNodeModulesBinDirPath(), '..'));
68
+ const configFilePath = await prettier.resolveConfigFile(pathJoin(getNodeModulesBinDirPath(), '..', '..'));
76
69
 
77
70
  if (configFilePath === null) {
78
71
  return '';
@@ -83,14 +76,19 @@ export async function getPrettier(): Promise<PrettierAndConfigHash> {
83
76
  return crypto.createHash('sha256').update(data).digest('hex');
84
77
  })();
85
78
 
86
- const prettierAndConfig: PrettierAndConfigHash = { prettier, configHash };
79
+ const prettierAndConfig: PrettierAndConfigHash = {
80
+ prettier,
81
+ configHash,
82
+ };
87
83
 
88
84
  getPrettier.cache = prettierAndConfig;
89
85
 
90
86
  return prettierAndConfig;
91
87
  }
92
88
 
93
- export async function runPrettier(params: { sourceCode: string; filePath: string }): Promise<string> {
89
+ export async function runPrettier(params: { sourceCode: string; filePath: string }): Promise<string>;
90
+ export async function runPrettier(params: { sourceCode: Buffer; filePath: string }): Promise<Buffer>;
91
+ export async function runPrettier(params: { sourceCode: string | Buffer; filePath: string }): Promise<string | Buffer> {
94
92
  const { sourceCode, filePath } = params;
95
93
 
96
94
  let formattedSourceCode: string;
@@ -98,24 +96,29 @@ export async function runPrettier(params: { sourceCode: string; filePath: string
98
96
  try {
99
97
  const { prettier } = await getPrettier();
100
98
 
101
- const { ignored, inferredParser } = await prettier.getFileInfo(filePath, { resolveConfig: true });
99
+ const { ignored, inferredParser } = await prettier.getFileInfo(filePath, {
100
+ resolveConfig: true,
101
+ });
102
102
 
103
- if (ignored) {
103
+ if (ignored || inferredParser === null) {
104
104
  return sourceCode;
105
105
  }
106
106
 
107
107
  const config = await prettier.resolveConfig(filePath);
108
108
 
109
- formattedSourceCode = await prettier.format(sourceCode, {
110
- ...config,
111
- filePath,
112
- parser: inferredParser ?? undefined,
113
- });
109
+ formattedSourceCode = await prettier.format(
110
+ typeof sourceCode === 'string' ? sourceCode : sourceCode.toString('utf8'),
111
+ {
112
+ ...config,
113
+ filePath,
114
+ parser: inferredParser,
115
+ },
116
+ );
114
117
  } catch (error) {
115
118
  console.log(chalk.red(`You probably need to upgrade the version of prettier in your project`));
116
119
 
117
120
  throw error;
118
121
  }
119
122
 
120
- return formattedSourceCode;
123
+ return typeof sourceCode === 'string' ? formattedSourceCode : Buffer.from(formattedSourceCode, 'utf8');
121
124
  }
@@ -1,22 +0,0 @@
1
- import * as fs from 'fs';
2
- import { join as pathJoin } from 'path';
3
- import { assert } from 'tsafe/assert';
4
- import { getThisCodebaseRootDirPath } from './getThisCodebaseRootDirPath';
5
-
6
- let cache: string | undefined = undefined;
7
-
8
- export function readThisNpmPackageVersion(): string {
9
- if (cache !== undefined) {
10
- return cache;
11
- }
12
-
13
- const version = JSON.parse(fs.readFileSync(pathJoin(getThisCodebaseRootDirPath(), 'package.json')).toString('utf8'))[
14
- 'version'
15
- ];
16
-
17
- assert(typeof version === 'string');
18
-
19
- cache = version;
20
-
21
- return version;
22
- }