keycloakify 11.8.18 → 11.8.20
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/bin/355.index.js +180 -12
- package/bin/363.index.js +98 -8
- package/bin/369.index.js +1 -833
- package/bin/40.index.js +198 -8
- package/bin/453.index.js +1 -833
- package/bin/658.index.js +1 -1
- package/bin/780.index.js +180 -12
- package/bin/786.index.js +179 -11
- package/bin/932.index.js +204 -12
- package/bin/949.index.js +1031 -0
- package/bin/97.index.js +174 -8
- package/bin/main.js +2 -2
- package/bin/shared/customHandler_delegate.d.ts +2 -2
- package/bin/tools/nodeModulesBinDirPath.d.ts +6 -1
- package/package.json +2 -1
- package/src/bin/add-story.ts +1 -1
- package/src/bin/copy-keycloak-resources-to-public.ts +1 -1
- package/src/bin/eject-page.ts +1 -1
- package/src/bin/initialize-account-theme/initialize-account-theme.ts +1 -1
- package/src/bin/initialize-admin-theme.ts +1 -1
- package/src/bin/initialize-email-theme.ts +2 -2
- package/src/bin/shared/customHandler_delegate.ts +5 -3
- package/src/bin/tools/nodeModulesBinDirPath.ts +138 -6
- package/src/bin/tools/runPrettier.ts +5 -3
- package/src/bin/update-kc-gen.ts +1 -1
- package/vite-plugin/index.js +8979 -8804
package/bin/949.index.js
ADDED
@@ -0,0 +1,1031 @@
|
|
1
|
+
"use strict";
|
2
|
+
exports.id = 949;
|
3
|
+
exports.ids = [949];
|
4
|
+
exports.modules = {
|
5
|
+
|
6
|
+
/***/ 72138:
|
7
|
+
/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
|
8
|
+
|
9
|
+
|
10
|
+
// EXPORTS
|
11
|
+
__webpack_require__.d(__webpack_exports__, {
|
12
|
+
"q": () => (/* binding */ maybeDelegateCommandToCustomHandler)
|
13
|
+
});
|
14
|
+
|
15
|
+
// EXTERNAL MODULE: ./node_modules/tsafe/esm/assert.mjs + 1 modules
|
16
|
+
var esm_assert = __webpack_require__(29041);
|
17
|
+
// EXTERNAL MODULE: ./dist/bin/shared/constants.js
|
18
|
+
var constants = __webpack_require__(173);
|
19
|
+
;// CONCATENATED MODULE: ./dist/bin/shared/customHandler.js
|
20
|
+
|
21
|
+
|
22
|
+
const BIN_NAME = "_keycloakify-custom-handler";
|
23
|
+
const NOT_IMPLEMENTED_EXIT_CODE = 78;
|
24
|
+
function readParams(params) {
|
25
|
+
const { apiVersion } = params;
|
26
|
+
assert(apiVersion === "v1");
|
27
|
+
const commandName = (() => {
|
28
|
+
const envValue = process.env[CUSTOM_HANDLER_ENV_NAMES.COMMAND_NAME];
|
29
|
+
assert(envValue !== undefined);
|
30
|
+
return envValue;
|
31
|
+
})();
|
32
|
+
const buildContext = (() => {
|
33
|
+
const envValue = process.env[CUSTOM_HANDLER_ENV_NAMES.BUILD_CONTEXT];
|
34
|
+
assert(envValue !== undefined);
|
35
|
+
return JSON.parse(envValue);
|
36
|
+
})();
|
37
|
+
return { commandName, buildContext };
|
38
|
+
}
|
39
|
+
//# sourceMappingURL=customHandler.js.map
|
40
|
+
// EXTERNAL MODULE: external "child_process"
|
41
|
+
var external_child_process_ = __webpack_require__(32081);
|
42
|
+
// EXTERNAL MODULE: ./dist/bin/tools/nodeModulesBinDirPath.js
|
43
|
+
var tools_nodeModulesBinDirPath = __webpack_require__(73776);
|
44
|
+
// EXTERNAL MODULE: external "fs"
|
45
|
+
var external_fs_ = __webpack_require__(57147);
|
46
|
+
;// CONCATENATED MODULE: ./dist/bin/shared/customHandler_delegate.js
|
47
|
+
|
48
|
+
|
49
|
+
|
50
|
+
|
51
|
+
|
52
|
+
|
53
|
+
(0,esm_assert/* assert */.h)();
|
54
|
+
async function maybeDelegateCommandToCustomHandler(params) {
|
55
|
+
const { commandName, buildContext } = params;
|
56
|
+
const nodeModulesBinDirPath = await (0,tools_nodeModulesBinDirPath/* getNodeModulesBinDirPath */.K)({
|
57
|
+
packageJsonFilePath: buildContext.packageJsonFilePath
|
58
|
+
});
|
59
|
+
if (!external_fs_.readdirSync(nodeModulesBinDirPath).includes(BIN_NAME)) {
|
60
|
+
return { hasBeenHandled: false };
|
61
|
+
}
|
62
|
+
try {
|
63
|
+
external_child_process_.execSync(`npx ${BIN_NAME}`, {
|
64
|
+
stdio: "inherit",
|
65
|
+
env: Object.assign(Object.assign({}, process.env), { [constants/* CUSTOM_HANDLER_ENV_NAMES.COMMAND_NAME */._S.COMMAND_NAME]: commandName, [constants/* CUSTOM_HANDLER_ENV_NAMES.BUILD_CONTEXT */._S.BUILD_CONTEXT]: JSON.stringify(buildContext) })
|
66
|
+
});
|
67
|
+
}
|
68
|
+
catch (error) {
|
69
|
+
const status = error.status;
|
70
|
+
if (status === NOT_IMPLEMENTED_EXIT_CODE) {
|
71
|
+
return { hasBeenHandled: false };
|
72
|
+
}
|
73
|
+
process.exit(status);
|
74
|
+
}
|
75
|
+
return { hasBeenHandled: true };
|
76
|
+
}
|
77
|
+
//# sourceMappingURL=customHandler_delegate.js.map
|
78
|
+
|
79
|
+
/***/ }),
|
80
|
+
|
81
|
+
/***/ 43765:
|
82
|
+
/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
|
83
|
+
|
84
|
+
/* harmony export */ __webpack_require__.d(__webpack_exports__, {
|
85
|
+
/* harmony export */ "o": () => (/* binding */ existsAsync)
|
86
|
+
/* harmony export */ });
|
87
|
+
/* harmony import */ var fs_promises__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(73292);
|
88
|
+
/* harmony import */ var fs_promises__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(fs_promises__WEBPACK_IMPORTED_MODULE_0__);
|
89
|
+
|
90
|
+
async function existsAsync(path) {
|
91
|
+
try {
|
92
|
+
await fs_promises__WEBPACK_IMPORTED_MODULE_0__.stat(path);
|
93
|
+
return true;
|
94
|
+
}
|
95
|
+
catch (error) {
|
96
|
+
if (error.code === "ENOENT")
|
97
|
+
return false;
|
98
|
+
throw error;
|
99
|
+
}
|
100
|
+
}
|
101
|
+
//# sourceMappingURL=fs.existsAsync.js.map
|
102
|
+
|
103
|
+
/***/ }),
|
104
|
+
|
105
|
+
/***/ 93721:
|
106
|
+
/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
|
107
|
+
|
108
|
+
|
109
|
+
// EXPORTS
|
110
|
+
__webpack_require__.d(__webpack_exports__, {
|
111
|
+
"p": () => (/* binding */ getInstalledModuleDirPath)
|
112
|
+
});
|
113
|
+
|
114
|
+
// EXTERNAL MODULE: external "path"
|
115
|
+
var external_path_ = __webpack_require__(71017);
|
116
|
+
// EXTERNAL MODULE: ./dist/bin/tools/fs.existsAsync.js
|
117
|
+
var fs_existsAsync = __webpack_require__(43765);
|
118
|
+
// EXTERNAL MODULE: external "child_process"
|
119
|
+
var external_child_process_ = __webpack_require__(32081);
|
120
|
+
// EXTERNAL MODULE: ./node_modules/tsafe/esm/assert.mjs + 1 modules
|
121
|
+
var assert = __webpack_require__(29041);
|
122
|
+
;// CONCATENATED MODULE: ./dist/bin/tools/isRootPath.js
|
123
|
+
|
124
|
+
function getIsRootPath(filePath) {
|
125
|
+
const path_normalized = (0,external_path_.normalize)(filePath);
|
126
|
+
// Unix-like root ("/")
|
127
|
+
if (path_normalized === "/") {
|
128
|
+
return true;
|
129
|
+
}
|
130
|
+
// Check for Windows drive root (e.g., "C:\\")
|
131
|
+
if (/^[a-zA-Z]:\\$/.test(path_normalized)) {
|
132
|
+
return true;
|
133
|
+
}
|
134
|
+
// Check for UNC root (e.g., "\\server\share")
|
135
|
+
if (/^\\\\[^\\]+\\[^\\]+\\?$/.test(path_normalized)) {
|
136
|
+
return true;
|
137
|
+
}
|
138
|
+
return false;
|
139
|
+
}
|
140
|
+
//# sourceMappingURL=isRootPath.js.map
|
141
|
+
;// CONCATENATED MODULE: ./dist/bin/tools/getInstalledModuleDirPath.js
|
142
|
+
|
143
|
+
|
144
|
+
|
145
|
+
|
146
|
+
|
147
|
+
async function getInstalledModuleDirPath(params) {
|
148
|
+
const { moduleName, packageJsonDirPath } = params;
|
149
|
+
{
|
150
|
+
let dirPath = packageJsonDirPath;
|
151
|
+
while (true) {
|
152
|
+
const dirPath_candidate = (0,external_path_.join)(dirPath, "node_modules", ...moduleName.split("/"));
|
153
|
+
let doesExist;
|
154
|
+
try {
|
155
|
+
doesExist = await (0,fs_existsAsync/* existsAsync */.o)(dirPath_candidate);
|
156
|
+
}
|
157
|
+
catch (_a) {
|
158
|
+
doesExist = false;
|
159
|
+
}
|
160
|
+
if (doesExist) {
|
161
|
+
return dirPath_candidate;
|
162
|
+
}
|
163
|
+
if (getIsRootPath(dirPath)) {
|
164
|
+
break;
|
165
|
+
}
|
166
|
+
dirPath = (0,external_path_.join)(dirPath, "..");
|
167
|
+
}
|
168
|
+
}
|
169
|
+
const dirPath = external_child_process_.execSync(`npm list ${moduleName}`, {
|
170
|
+
cwd: packageJsonDirPath
|
171
|
+
})
|
172
|
+
.toString("utf8")
|
173
|
+
.trim();
|
174
|
+
(0,assert/* assert */.h)(dirPath !== "");
|
175
|
+
return dirPath;
|
176
|
+
}
|
177
|
+
//# sourceMappingURL=getInstalledModuleDirPath.js.map
|
178
|
+
|
179
|
+
/***/ }),
|
180
|
+
|
181
|
+
/***/ 17192:
|
182
|
+
/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
|
183
|
+
|
184
|
+
/* harmony export */ __webpack_require__.d(__webpack_exports__, {
|
185
|
+
/* harmony export */ "A": () => (/* binding */ kebabCaseToCamelCase)
|
186
|
+
/* harmony export */ });
|
187
|
+
/* harmony import */ var tsafe_capitalize__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(14899);
|
188
|
+
|
189
|
+
function kebabCaseToCamelCase(kebabCaseString) {
|
190
|
+
const [first, ...rest] = kebabCaseString.split("-");
|
191
|
+
return [first, ...rest.map(tsafe_capitalize__WEBPACK_IMPORTED_MODULE_0__/* .capitalize */ .k)].join("");
|
192
|
+
}
|
193
|
+
//# sourceMappingURL=kebabCaseToSnakeCase.js.map
|
194
|
+
|
195
|
+
/***/ }),
|
196
|
+
|
197
|
+
/***/ 73776:
|
198
|
+
/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
|
199
|
+
|
200
|
+
/* harmony export */ __webpack_require__.d(__webpack_exports__, {
|
201
|
+
/* harmony export */ "K": () => (/* binding */ getNodeModulesBinDirPath)
|
202
|
+
/* harmony export */ });
|
203
|
+
/* harmony import */ var path__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(71017);
|
204
|
+
/* harmony import */ var path__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(path__WEBPACK_IMPORTED_MODULE_0__);
|
205
|
+
/* harmony import */ var _getThisCodebaseRootDirPath__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(58822);
|
206
|
+
/* harmony import */ var _getInstalledModuleDirPath__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(93721);
|
207
|
+
/* harmony import */ var _fs_existsAsync__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(43765);
|
208
|
+
/* harmony import */ var zod__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(52300);
|
209
|
+
/* harmony import */ var fs_promises__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(73292);
|
210
|
+
/* harmony import */ var fs_promises__WEBPACK_IMPORTED_MODULE_4___default = /*#__PURE__*/__webpack_require__.n(fs_promises__WEBPACK_IMPORTED_MODULE_4__);
|
211
|
+
/* harmony import */ var tsafe_assert__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(29041);
|
212
|
+
/* harmony import */ var tsafe_id__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(38469);
|
213
|
+
|
214
|
+
|
215
|
+
|
216
|
+
|
217
|
+
|
218
|
+
|
219
|
+
|
220
|
+
|
221
|
+
let cache_bestEffort = undefined;
|
222
|
+
/** NOTE: Careful, this function can fail when the binary
|
223
|
+
* Used is not in the node_modules directory of the project
|
224
|
+
* (for example when running tests with vscode extension we'll get
|
225
|
+
* '/Users/dylan/.vscode/extensions/vitest.explorer-1.16.0/dist/worker.js'
|
226
|
+
*
|
227
|
+
* instead of
|
228
|
+
* '/Users/joseph/.nvm/versions/node/v22.12.0/bin/node'
|
229
|
+
* or
|
230
|
+
* '/Users/joseph/github/keycloakify-starter/node_modules/.bin/vite'
|
231
|
+
*
|
232
|
+
* as the value of process.argv[1]
|
233
|
+
*/
|
234
|
+
function getNodeModulesBinDirPath_bestEffort() {
|
235
|
+
if (cache_bestEffort !== undefined) {
|
236
|
+
return cache_bestEffort;
|
237
|
+
}
|
238
|
+
const binPath = process.argv[1];
|
239
|
+
const segments = [".bin"];
|
240
|
+
let foundNodeModules = false;
|
241
|
+
for (const segment of binPath.split(path__WEBPACK_IMPORTED_MODULE_0__.sep).reverse()) {
|
242
|
+
skip_segment: {
|
243
|
+
if (foundNodeModules) {
|
244
|
+
break skip_segment;
|
245
|
+
}
|
246
|
+
if (segment === "node_modules") {
|
247
|
+
foundNodeModules = true;
|
248
|
+
break skip_segment;
|
249
|
+
}
|
250
|
+
continue;
|
251
|
+
}
|
252
|
+
segments.unshift(segment);
|
253
|
+
}
|
254
|
+
if (!foundNodeModules) {
|
255
|
+
throw new Error(`Could not find node_modules in path ${binPath}`);
|
256
|
+
}
|
257
|
+
const nodeModulesBinDirPath = segments.join(path__WEBPACK_IMPORTED_MODULE_0__.sep);
|
258
|
+
cache_bestEffort = nodeModulesBinDirPath;
|
259
|
+
return nodeModulesBinDirPath;
|
260
|
+
}
|
261
|
+
let cache_withPackageJsonFileDirPath = undefined;
|
262
|
+
async function getNodeModulesBinDirPath_withPackageJsonFileDirPath(params) {
|
263
|
+
const { packageJsonFilePath } = params;
|
264
|
+
use_cache: {
|
265
|
+
if (cache_withPackageJsonFileDirPath === undefined) {
|
266
|
+
break use_cache;
|
267
|
+
}
|
268
|
+
if (cache_withPackageJsonFileDirPath.packageJsonFilePath !== packageJsonFilePath) {
|
269
|
+
cache_withPackageJsonFileDirPath = undefined;
|
270
|
+
break use_cache;
|
271
|
+
}
|
272
|
+
return cache_withPackageJsonFileDirPath.nodeModulesBinDirPath;
|
273
|
+
}
|
274
|
+
// [...]node_modules/keycloakify
|
275
|
+
const installedModuleDirPath = await (0,_getInstalledModuleDirPath__WEBPACK_IMPORTED_MODULE_2__/* .getInstalledModuleDirPath */ .p)({
|
276
|
+
// Here it will always be "keycloakify" but since we are in tools/ we make something generic
|
277
|
+
moduleName: await (async () => {
|
278
|
+
const zParsedPackageJson = (() => {
|
279
|
+
const zTargetType = zod__WEBPACK_IMPORTED_MODULE_6__.z.object({
|
280
|
+
name: zod__WEBPACK_IMPORTED_MODULE_6__.z.string()
|
281
|
+
});
|
282
|
+
tsafe_assert__WEBPACK_IMPORTED_MODULE_5__/* .assert */ .h;
|
283
|
+
return (0,tsafe_id__WEBPACK_IMPORTED_MODULE_7__.id)(zTargetType);
|
284
|
+
})();
|
285
|
+
const parsedPackageJson = JSON.parse((await fs_promises__WEBPACK_IMPORTED_MODULE_4__.readFile((0,path__WEBPACK_IMPORTED_MODULE_0__.join)((0,_getThisCodebaseRootDirPath__WEBPACK_IMPORTED_MODULE_1__/* .getThisCodebaseRootDirPath */ .e)(), "package.json"))).toString("utf8"));
|
286
|
+
zParsedPackageJson.parse(parsedPackageJson);
|
287
|
+
(0,tsafe_assert__WEBPACK_IMPORTED_MODULE_5__/* .assert */ .h)((0,tsafe_assert__WEBPACK_IMPORTED_MODULE_5__.is)(parsedPackageJson));
|
288
|
+
return parsedPackageJson.name;
|
289
|
+
})(),
|
290
|
+
packageJsonDirPath: (0,path__WEBPACK_IMPORTED_MODULE_0__.dirname)(packageJsonFilePath)
|
291
|
+
});
|
292
|
+
const segments = installedModuleDirPath.split(path__WEBPACK_IMPORTED_MODULE_0__.sep);
|
293
|
+
while (true) {
|
294
|
+
const segment = segments.pop();
|
295
|
+
if (segment === undefined) {
|
296
|
+
throw new Error(`Could not find .bin directory relative to ${packageJsonFilePath}`);
|
297
|
+
}
|
298
|
+
if (segment !== "node_modules") {
|
299
|
+
continue;
|
300
|
+
}
|
301
|
+
const candidate = (0,path__WEBPACK_IMPORTED_MODULE_0__.join)(segments.join(path__WEBPACK_IMPORTED_MODULE_0__.sep), segment, ".bin");
|
302
|
+
if (!(await (0,_fs_existsAsync__WEBPACK_IMPORTED_MODULE_3__/* .existsAsync */ .o)(candidate))) {
|
303
|
+
continue;
|
304
|
+
}
|
305
|
+
cache_withPackageJsonFileDirPath = {
|
306
|
+
packageJsonFilePath,
|
307
|
+
nodeModulesBinDirPath: candidate
|
308
|
+
};
|
309
|
+
break;
|
310
|
+
}
|
311
|
+
return cache_withPackageJsonFileDirPath.nodeModulesBinDirPath;
|
312
|
+
}
|
313
|
+
function getNodeModulesBinDirPath(params) {
|
314
|
+
const { packageJsonFilePath } = params !== null && params !== void 0 ? params : {};
|
315
|
+
return packageJsonFilePath === undefined
|
316
|
+
? getNodeModulesBinDirPath_bestEffort()
|
317
|
+
: getNodeModulesBinDirPath_withPackageJsonFileDirPath({ packageJsonFilePath });
|
318
|
+
}
|
319
|
+
//# sourceMappingURL=nodeModulesBinDirPath.js.map
|
320
|
+
|
321
|
+
/***/ }),
|
322
|
+
|
323
|
+
/***/ 48433:
|
324
|
+
/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
|
325
|
+
|
326
|
+
/* harmony export */ __webpack_require__.d(__webpack_exports__, {
|
327
|
+
/* harmony export */ "LG": () => (/* binding */ getPrettier),
|
328
|
+
/* harmony export */ "MT": () => (/* binding */ getIsPrettierAvailable),
|
329
|
+
/* harmony export */ "eY": () => (/* binding */ runPrettier)
|
330
|
+
/* harmony export */ });
|
331
|
+
/* harmony import */ var _nodeModulesBinDirPath__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(73776);
|
332
|
+
/* harmony import */ var path__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(71017);
|
333
|
+
/* harmony import */ var path__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(path__WEBPACK_IMPORTED_MODULE_1__);
|
334
|
+
/* harmony import */ var fs_promises__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(73292);
|
335
|
+
/* harmony import */ var fs_promises__WEBPACK_IMPORTED_MODULE_2___default = /*#__PURE__*/__webpack_require__.n(fs_promises__WEBPACK_IMPORTED_MODULE_2__);
|
336
|
+
/* harmony import */ var tsafe_id__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(38469);
|
337
|
+
/* harmony import */ var tsafe_assert__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(29041);
|
338
|
+
/* harmony import */ var chalk__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(78818);
|
339
|
+
/* harmony import */ var chalk__WEBPACK_IMPORTED_MODULE_4___default = /*#__PURE__*/__webpack_require__.n(chalk__WEBPACK_IMPORTED_MODULE_4__);
|
340
|
+
/* harmony import */ var crypto__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(6113);
|
341
|
+
/* harmony import */ var crypto__WEBPACK_IMPORTED_MODULE_5___default = /*#__PURE__*/__webpack_require__.n(crypto__WEBPACK_IMPORTED_MODULE_5__);
|
342
|
+
/* harmony import */ var tsafe_symToStr__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(76030);
|
343
|
+
/* harmony import */ var _readThisNpmPackageVersion__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(64795);
|
344
|
+
|
345
|
+
|
346
|
+
|
347
|
+
|
348
|
+
|
349
|
+
|
350
|
+
|
351
|
+
|
352
|
+
|
353
|
+
getIsPrettierAvailable.cache = (0,tsafe_id__WEBPACK_IMPORTED_MODULE_7__.id)(undefined);
|
354
|
+
async function getIsPrettierAvailable() {
|
355
|
+
var _a;
|
356
|
+
if (getIsPrettierAvailable.cache !== undefined) {
|
357
|
+
return getIsPrettierAvailable.cache;
|
358
|
+
}
|
359
|
+
const nodeModulesBinDirPath = (0,_nodeModulesBinDirPath__WEBPACK_IMPORTED_MODULE_0__/* .getNodeModulesBinDirPath */ .K)({
|
360
|
+
packageJsonFilePath: undefined
|
361
|
+
});
|
362
|
+
const prettierBinPath = (0,path__WEBPACK_IMPORTED_MODULE_1__.join)(nodeModulesBinDirPath, "prettier");
|
363
|
+
const stats = await fs_promises__WEBPACK_IMPORTED_MODULE_2__.stat(prettierBinPath).catch(() => undefined);
|
364
|
+
const isPrettierAvailable = (_a = stats === null || stats === void 0 ? void 0 : stats.isFile()) !== null && _a !== void 0 ? _a : false;
|
365
|
+
getIsPrettierAvailable.cache = isPrettierAvailable;
|
366
|
+
return isPrettierAvailable;
|
367
|
+
}
|
368
|
+
getPrettier.cache = (0,tsafe_id__WEBPACK_IMPORTED_MODULE_7__.id)(undefined);
|
369
|
+
async function getPrettier() {
|
370
|
+
(0,tsafe_assert__WEBPACK_IMPORTED_MODULE_3__/* .assert */ .h)(getIsPrettierAvailable());
|
371
|
+
if (getPrettier.cache !== undefined) {
|
372
|
+
return getPrettier.cache;
|
373
|
+
}
|
374
|
+
let prettier = (0,tsafe_id__WEBPACK_IMPORTED_MODULE_7__.id)(undefined);
|
375
|
+
import_prettier: {
|
376
|
+
// NOTE: When module is linked we want to make sure we import the correct version
|
377
|
+
// of prettier, that is the one of the project, not the one of this repo.
|
378
|
+
// So we do a sketchy eval to bypass ncc.
|
379
|
+
// We make sure to only do that when linking, otherwise we import properly.
|
380
|
+
if ((0,_readThisNpmPackageVersion__WEBPACK_IMPORTED_MODULE_6__/* .readThisNpmPackageVersion */ .K)().startsWith("0.0.0")) {
|
381
|
+
eval(`${(0,tsafe_symToStr__WEBPACK_IMPORTED_MODULE_8__/* .symToStr */ .r)({ prettier })} = require("${(0,path__WEBPACK_IMPORTED_MODULE_1__.resolve)((0,path__WEBPACK_IMPORTED_MODULE_1__.join)((0,_nodeModulesBinDirPath__WEBPACK_IMPORTED_MODULE_0__/* .getNodeModulesBinDirPath */ .K)({ packageJsonFilePath: undefined }), "..", "prettier"))}")`);
|
382
|
+
(0,tsafe_assert__WEBPACK_IMPORTED_MODULE_3__/* .assert */ .h)(!(0,tsafe_assert__WEBPACK_IMPORTED_MODULE_3__.is)(prettier));
|
383
|
+
break import_prettier;
|
384
|
+
}
|
385
|
+
prettier = await Promise.resolve(/* import() */).then(__webpack_require__.t.bind(__webpack_require__, 79421, 23));
|
386
|
+
}
|
387
|
+
const configHash = await (async () => {
|
388
|
+
const configFilePath = await prettier.resolveConfigFile((0,path__WEBPACK_IMPORTED_MODULE_1__.join)((0,_nodeModulesBinDirPath__WEBPACK_IMPORTED_MODULE_0__/* .getNodeModulesBinDirPath */ .K)({ packageJsonFilePath: undefined }), ".."));
|
389
|
+
if (configFilePath === null) {
|
390
|
+
return "";
|
391
|
+
}
|
392
|
+
const data = await fs_promises__WEBPACK_IMPORTED_MODULE_2__.readFile(configFilePath);
|
393
|
+
return crypto__WEBPACK_IMPORTED_MODULE_5__.createHash("sha256").update(data).digest("hex");
|
394
|
+
})();
|
395
|
+
const prettierAndConfig = {
|
396
|
+
prettier,
|
397
|
+
configHash
|
398
|
+
};
|
399
|
+
getPrettier.cache = prettierAndConfig;
|
400
|
+
return prettierAndConfig;
|
401
|
+
}
|
402
|
+
async function runPrettier(params) {
|
403
|
+
const { sourceCode, filePath } = params;
|
404
|
+
let formattedSourceCode;
|
405
|
+
try {
|
406
|
+
const { prettier } = await getPrettier();
|
407
|
+
const { ignored, inferredParser } = await prettier.getFileInfo(filePath, {
|
408
|
+
resolveConfig: true
|
409
|
+
});
|
410
|
+
if (ignored || inferredParser === null) {
|
411
|
+
return sourceCode;
|
412
|
+
}
|
413
|
+
const config = await prettier.resolveConfig(filePath);
|
414
|
+
formattedSourceCode = await prettier.format(sourceCode, Object.assign(Object.assign({}, config), { filePath, parser: inferredParser }));
|
415
|
+
}
|
416
|
+
catch (error) {
|
417
|
+
console.log(chalk__WEBPACK_IMPORTED_MODULE_4___default().red(`You probably need to upgrade the version of prettier in your project`));
|
418
|
+
throw error;
|
419
|
+
}
|
420
|
+
return formattedSourceCode;
|
421
|
+
}
|
422
|
+
//# sourceMappingURL=runPrettier.js.map
|
423
|
+
|
424
|
+
/***/ }),
|
425
|
+
|
426
|
+
/***/ 18512:
|
427
|
+
/***/ ((module) => {
|
428
|
+
|
429
|
+
|
430
|
+
const x = module.exports;
|
431
|
+
const ESC = '\u001B[';
|
432
|
+
const OSC = '\u001B]';
|
433
|
+
const BEL = '\u0007';
|
434
|
+
const SEP = ';';
|
435
|
+
const isTerminalApp = process.env.TERM_PROGRAM === 'Apple_Terminal';
|
436
|
+
|
437
|
+
x.cursorTo = (x, y) => {
|
438
|
+
if (typeof x !== 'number') {
|
439
|
+
throw new TypeError('The `x` argument is required');
|
440
|
+
}
|
441
|
+
|
442
|
+
if (typeof y !== 'number') {
|
443
|
+
return ESC + (x + 1) + 'G';
|
444
|
+
}
|
445
|
+
|
446
|
+
return ESC + (y + 1) + ';' + (x + 1) + 'H';
|
447
|
+
};
|
448
|
+
|
449
|
+
x.cursorMove = (x, y) => {
|
450
|
+
if (typeof x !== 'number') {
|
451
|
+
throw new TypeError('The `x` argument is required');
|
452
|
+
}
|
453
|
+
|
454
|
+
let ret = '';
|
455
|
+
|
456
|
+
if (x < 0) {
|
457
|
+
ret += ESC + (-x) + 'D';
|
458
|
+
} else if (x > 0) {
|
459
|
+
ret += ESC + x + 'C';
|
460
|
+
}
|
461
|
+
|
462
|
+
if (y < 0) {
|
463
|
+
ret += ESC + (-y) + 'A';
|
464
|
+
} else if (y > 0) {
|
465
|
+
ret += ESC + y + 'B';
|
466
|
+
}
|
467
|
+
|
468
|
+
return ret;
|
469
|
+
};
|
470
|
+
|
471
|
+
x.cursorUp = count => ESC + (typeof count === 'number' ? count : 1) + 'A';
|
472
|
+
x.cursorDown = count => ESC + (typeof count === 'number' ? count : 1) + 'B';
|
473
|
+
x.cursorForward = count => ESC + (typeof count === 'number' ? count : 1) + 'C';
|
474
|
+
x.cursorBackward = count => ESC + (typeof count === 'number' ? count : 1) + 'D';
|
475
|
+
|
476
|
+
x.cursorLeft = ESC + 'G';
|
477
|
+
x.cursorSavePosition = ESC + (isTerminalApp ? '7' : 's');
|
478
|
+
x.cursorRestorePosition = ESC + (isTerminalApp ? '8' : 'u');
|
479
|
+
x.cursorGetPosition = ESC + '6n';
|
480
|
+
x.cursorNextLine = ESC + 'E';
|
481
|
+
x.cursorPrevLine = ESC + 'F';
|
482
|
+
x.cursorHide = ESC + '?25l';
|
483
|
+
x.cursorShow = ESC + '?25h';
|
484
|
+
|
485
|
+
x.eraseLines = count => {
|
486
|
+
let clear = '';
|
487
|
+
|
488
|
+
for (let i = 0; i < count; i++) {
|
489
|
+
clear += x.eraseLine + (i < count - 1 ? x.cursorUp() : '');
|
490
|
+
}
|
491
|
+
|
492
|
+
if (count) {
|
493
|
+
clear += x.cursorLeft;
|
494
|
+
}
|
495
|
+
|
496
|
+
return clear;
|
497
|
+
};
|
498
|
+
|
499
|
+
x.eraseEndLine = ESC + 'K';
|
500
|
+
x.eraseStartLine = ESC + '1K';
|
501
|
+
x.eraseLine = ESC + '2K';
|
502
|
+
x.eraseDown = ESC + 'J';
|
503
|
+
x.eraseUp = ESC + '1J';
|
504
|
+
x.eraseScreen = ESC + '2J';
|
505
|
+
x.scrollUp = ESC + 'S';
|
506
|
+
x.scrollDown = ESC + 'T';
|
507
|
+
|
508
|
+
x.clearScreen = '\u001Bc';
|
509
|
+
|
510
|
+
x.clearTerminal = process.platform === 'win32' ?
|
511
|
+
`${x.eraseScreen}${ESC}0f` :
|
512
|
+
// 1. Erases the screen (Only done in case `2` is not supported)
|
513
|
+
// 2. Erases the whole screen including scrollback buffer
|
514
|
+
// 3. Moves cursor to the top-left position
|
515
|
+
// More info: https://www.real-world-systems.com/docs/ANSIcode.html
|
516
|
+
`${x.eraseScreen}${ESC}3J${ESC}H`;
|
517
|
+
|
518
|
+
x.beep = BEL;
|
519
|
+
|
520
|
+
x.link = (text, url) => {
|
521
|
+
return [
|
522
|
+
OSC,
|
523
|
+
'8',
|
524
|
+
SEP,
|
525
|
+
SEP,
|
526
|
+
url,
|
527
|
+
BEL,
|
528
|
+
text,
|
529
|
+
OSC,
|
530
|
+
'8',
|
531
|
+
SEP,
|
532
|
+
SEP,
|
533
|
+
BEL
|
534
|
+
].join('');
|
535
|
+
};
|
536
|
+
|
537
|
+
x.image = (buf, opts) => {
|
538
|
+
opts = opts || {};
|
539
|
+
|
540
|
+
let ret = OSC + '1337;File=inline=1';
|
541
|
+
|
542
|
+
if (opts.width) {
|
543
|
+
ret += `;width=${opts.width}`;
|
544
|
+
}
|
545
|
+
|
546
|
+
if (opts.height) {
|
547
|
+
ret += `;height=${opts.height}`;
|
548
|
+
}
|
549
|
+
|
550
|
+
if (opts.preserveAspectRatio === false) {
|
551
|
+
ret += ';preserveAspectRatio=0';
|
552
|
+
}
|
553
|
+
|
554
|
+
return ret + ':' + buf.toString('base64') + BEL;
|
555
|
+
};
|
556
|
+
|
557
|
+
x.iTerm = {};
|
558
|
+
|
559
|
+
x.iTerm.setCwd = cwd => OSC + '50;CurrentDir=' + (cwd || process.cwd()) + BEL;
|
560
|
+
|
561
|
+
|
562
|
+
/***/ }),
|
563
|
+
|
564
|
+
/***/ 39340:
|
565
|
+
/***/ ((__unused_webpack_module, exports) => {
|
566
|
+
|
567
|
+
|
568
|
+
|
569
|
+
Object.defineProperty(exports, "__esModule", ({
|
570
|
+
value: true
|
571
|
+
}));
|
572
|
+
exports.withPromise = exports.withCallback = void 0;
|
573
|
+
|
574
|
+
/**
|
575
|
+
* Open the input with a normal callback function
|
576
|
+
*
|
577
|
+
* @param {Input} input - input object
|
578
|
+
* @param {function} valueMapper - function which maps the resulting id and value back to the expected format
|
579
|
+
* @param {function} callback - callback function
|
580
|
+
*/
|
581
|
+
const withCallback = (input, valueMapper, callback) => {
|
582
|
+
input.open();
|
583
|
+
input.onSelect((id, value) => callback(valueMapper(id, value)));
|
584
|
+
};
|
585
|
+
/**
|
586
|
+
* Open the input with a promise
|
587
|
+
*
|
588
|
+
* @param {Input} input - input object
|
589
|
+
* @param {function} valueMapper - function which maps the resulting id and value back to the expected format
|
590
|
+
*/
|
591
|
+
|
592
|
+
|
593
|
+
exports.withCallback = withCallback;
|
594
|
+
|
595
|
+
const withPromise = (input, valueMapper) => {
|
596
|
+
return new Promise((resolve, reject) => {
|
597
|
+
input.open();
|
598
|
+
input.onSelect((id, value) => {
|
599
|
+
if (id === null) {
|
600
|
+
reject();
|
601
|
+
} else {
|
602
|
+
resolve(valueMapper(id, value));
|
603
|
+
}
|
604
|
+
});
|
605
|
+
});
|
606
|
+
};
|
607
|
+
|
608
|
+
exports.withPromise = withPromise;
|
609
|
+
|
610
|
+
/***/ }),
|
611
|
+
|
612
|
+
/***/ 99398:
|
613
|
+
/***/ ((module, exports, __webpack_require__) => {
|
614
|
+
|
615
|
+
|
616
|
+
|
617
|
+
Object.defineProperty(exports, "__esModule", ({
|
618
|
+
value: true
|
619
|
+
}));
|
620
|
+
exports["default"] = void 0;
|
621
|
+
|
622
|
+
var _input = _interopRequireDefault(__webpack_require__(25730));
|
623
|
+
|
624
|
+
var _renderer = _interopRequireDefault(__webpack_require__(16059));
|
625
|
+
|
626
|
+
var _callbackMappers = __webpack_require__(39340);
|
627
|
+
|
628
|
+
var _valueMappers = __webpack_require__(26730);
|
629
|
+
|
630
|
+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
631
|
+
|
632
|
+
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; }
|
633
|
+
|
634
|
+
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; }
|
635
|
+
|
636
|
+
/**
|
637
|
+
* Default options
|
638
|
+
*/
|
639
|
+
const defaultOptions = {
|
640
|
+
outputStream: process.stdout,
|
641
|
+
inputStream: process.stdin,
|
642
|
+
values: [],
|
643
|
+
defaultValue: 0,
|
644
|
+
selected: '(x)',
|
645
|
+
unselected: '( )',
|
646
|
+
indentation: 0,
|
647
|
+
cleanup: true,
|
648
|
+
valueRenderer: value => value
|
649
|
+
};
|
650
|
+
/**
|
651
|
+
* Create an instance of cli-select with the given options
|
652
|
+
*
|
653
|
+
* @param {object} options - options for cli-select
|
654
|
+
* @param {function} callback - if specified, a callback will be used, otherwise a promise gets returned (optional)
|
655
|
+
*/
|
656
|
+
|
657
|
+
const creator = (options, callback) => {
|
658
|
+
// merge options with default options
|
659
|
+
options = _objectSpread({}, defaultOptions, options); // create renderer and input instances
|
660
|
+
|
661
|
+
const renderer = new _renderer.default(options, options.outputStream);
|
662
|
+
const input = new _input.default(options.inputStream);
|
663
|
+
input.setDefaultValue(options.defaultValue);
|
664
|
+
input.attachRenderer(renderer); // handle array and object values
|
665
|
+
|
666
|
+
let valueMapper;
|
667
|
+
|
668
|
+
if (Array.isArray(options.values)) {
|
669
|
+
valueMapper = (0, _valueMappers.withArrayValues)(options);
|
670
|
+
} else {
|
671
|
+
valueMapper = (0, _valueMappers.withObjectValues)(options);
|
672
|
+
} // map values
|
673
|
+
|
674
|
+
|
675
|
+
options.values = valueMapper.input;
|
676
|
+
input.setValues(options.values); // handle different callback methods
|
677
|
+
|
678
|
+
if (typeof callback === 'function') {
|
679
|
+
return (0, _callbackMappers.withCallback)(input, valueMapper.output, callback);
|
680
|
+
} else {
|
681
|
+
return (0, _callbackMappers.withPromise)(input, valueMapper.output);
|
682
|
+
}
|
683
|
+
};
|
684
|
+
|
685
|
+
exports = module.exports = creator;
|
686
|
+
Object.defineProperty(exports, "__esModule", ({
|
687
|
+
value: true
|
688
|
+
}));
|
689
|
+
var _default = creator;
|
690
|
+
exports["default"] = _default;
|
691
|
+
|
692
|
+
/***/ }),
|
693
|
+
|
694
|
+
/***/ 25730:
|
695
|
+
/***/ ((__unused_webpack_module, exports, __webpack_require__) => {
|
696
|
+
|
697
|
+
|
698
|
+
|
699
|
+
Object.defineProperty(exports, "__esModule", ({
|
700
|
+
value: true
|
701
|
+
}));
|
702
|
+
exports["default"] = void 0;
|
703
|
+
|
704
|
+
var _readline = _interopRequireDefault(__webpack_require__(14521));
|
705
|
+
|
706
|
+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
707
|
+
|
708
|
+
/**
|
709
|
+
* Handle cli input
|
710
|
+
*/
|
711
|
+
class Input {
|
712
|
+
/**
|
713
|
+
* Input constructor
|
714
|
+
*
|
715
|
+
* @param {any} stream - stream to catch (optional)
|
716
|
+
*/
|
717
|
+
constructor(stream = process.stdin) {
|
718
|
+
// set default values
|
719
|
+
this.stream = stream;
|
720
|
+
this.values = [];
|
721
|
+
this.selectedValue = 0;
|
722
|
+
|
723
|
+
this.onSelectListener = () => {};
|
724
|
+
|
725
|
+
this.onKeyPress = this.onKeyPress.bind(this);
|
726
|
+
}
|
727
|
+
/**
|
728
|
+
* Set the available values
|
729
|
+
*
|
730
|
+
* @param {array} values - all available values
|
731
|
+
*/
|
732
|
+
|
733
|
+
|
734
|
+
setValues(values) {
|
735
|
+
this.values = values;
|
736
|
+
|
737
|
+
if (this.renderer) {
|
738
|
+
this.renderer.setValues(values);
|
739
|
+
}
|
740
|
+
}
|
741
|
+
/**
|
742
|
+
* Set the default value
|
743
|
+
*
|
744
|
+
* @param {number} defaultValue - default value id
|
745
|
+
*/
|
746
|
+
|
747
|
+
|
748
|
+
setDefaultValue(defaultValue) {
|
749
|
+
this.selectedValue = defaultValue;
|
750
|
+
}
|
751
|
+
/**
|
752
|
+
* Attach a renderer to the input catcher
|
753
|
+
*
|
754
|
+
* @param {Renderer} renderer - renderer to use for rendering responses
|
755
|
+
*/
|
756
|
+
|
757
|
+
|
758
|
+
attachRenderer(renderer) {
|
759
|
+
this.renderer = renderer;
|
760
|
+
this.renderer.setValues(this.values);
|
761
|
+
}
|
762
|
+
/**
|
763
|
+
* Register an on select listener
|
764
|
+
*
|
765
|
+
* @param {function} listener - listener function which receives two parameters: valueId and value
|
766
|
+
*/
|
767
|
+
|
768
|
+
|
769
|
+
onSelect(listener) {
|
770
|
+
this.onSelectListener = listener;
|
771
|
+
}
|
772
|
+
/**
|
773
|
+
* Open the stream and listen for input
|
774
|
+
*/
|
775
|
+
|
776
|
+
|
777
|
+
open() {
|
778
|
+
// register keypress event
|
779
|
+
_readline.default.emitKeypressEvents(this.stream); // handle keypress
|
780
|
+
|
781
|
+
|
782
|
+
this.stream.on('keypress', this.onKeyPress); // initially render the response
|
783
|
+
|
784
|
+
if (this.renderer) {
|
785
|
+
this.renderer.render(this.selectedValue);
|
786
|
+
} // hide pressed keys and start listening on input
|
787
|
+
|
788
|
+
|
789
|
+
this.stream.setRawMode(true);
|
790
|
+
this.stream.resume();
|
791
|
+
}
|
792
|
+
/**
|
793
|
+
* Close the stream
|
794
|
+
*
|
795
|
+
* @param {boolean} cancelled - true if no value was selected (optional)
|
796
|
+
*/
|
797
|
+
|
798
|
+
|
799
|
+
close(cancelled = false) {
|
800
|
+
// reset stream properties
|
801
|
+
this.stream.setRawMode(false);
|
802
|
+
this.stream.pause(); // cleanup the output
|
803
|
+
|
804
|
+
if (this.renderer) {
|
805
|
+
this.renderer.cleanup();
|
806
|
+
} // call the on select listener
|
807
|
+
|
808
|
+
|
809
|
+
if (cancelled) {
|
810
|
+
this.onSelectListener(null);
|
811
|
+
} else {
|
812
|
+
this.onSelectListener(this.selectedValue, this.values[this.selectedValue]);
|
813
|
+
}
|
814
|
+
|
815
|
+
this.stream.removeListener('keypress', this.onKeyPress);
|
816
|
+
}
|
817
|
+
/**
|
818
|
+
* Render the response
|
819
|
+
*/
|
820
|
+
|
821
|
+
|
822
|
+
render() {
|
823
|
+
if (!this.renderer) {
|
824
|
+
return;
|
825
|
+
}
|
826
|
+
|
827
|
+
this.renderer.render(this.selectedValue);
|
828
|
+
}
|
829
|
+
/**
|
830
|
+
* Handle key press event
|
831
|
+
*
|
832
|
+
* @param {string} string - input string
|
833
|
+
* @param {object} key - object containing information about the pressed key
|
834
|
+
*/
|
835
|
+
|
836
|
+
|
837
|
+
onKeyPress(string, key) {
|
838
|
+
if (key) {
|
839
|
+
if (key.name === 'up' && this.selectedValue > 0) {
|
840
|
+
this.selectedValue--;
|
841
|
+
this.render();
|
842
|
+
} else if (key.name === 'down' && this.selectedValue + 1 < this.values.length) {
|
843
|
+
this.selectedValue++;
|
844
|
+
this.render();
|
845
|
+
} else if (key.name === 'return') {
|
846
|
+
this.close();
|
847
|
+
} else if (key.name === 'escape' || key.name === 'c' && key.ctrl) {
|
848
|
+
this.close(true);
|
849
|
+
}
|
850
|
+
}
|
851
|
+
}
|
852
|
+
|
853
|
+
}
|
854
|
+
|
855
|
+
exports["default"] = Input;
|
856
|
+
|
857
|
+
/***/ }),
|
858
|
+
|
859
|
+
/***/ 16059:
|
860
|
+
/***/ ((__unused_webpack_module, exports, __webpack_require__) => {
|
861
|
+
|
862
|
+
|
863
|
+
|
864
|
+
Object.defineProperty(exports, "__esModule", ({
|
865
|
+
value: true
|
866
|
+
}));
|
867
|
+
exports["default"] = void 0;
|
868
|
+
|
869
|
+
var _readline = _interopRequireDefault(__webpack_require__(14521));
|
870
|
+
|
871
|
+
var _ansiEscapes = __webpack_require__(18512);
|
872
|
+
|
873
|
+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
874
|
+
|
875
|
+
/**
|
876
|
+
* Response renderer
|
877
|
+
*/
|
878
|
+
class Renderer {
|
879
|
+
/**
|
880
|
+
* Renderer constructor
|
881
|
+
*
|
882
|
+
* @param {object} options - renderer options
|
883
|
+
* @param {any} stream - stream to write to (optional)
|
884
|
+
*/
|
885
|
+
constructor(options, stream = process.stdout) {
|
886
|
+
this.options = options;
|
887
|
+
this.stream = stream;
|
888
|
+
this.values = [];
|
889
|
+
this.initialRender = true;
|
890
|
+
}
|
891
|
+
/**
|
892
|
+
* Set the available values
|
893
|
+
*
|
894
|
+
* @param {array} values - all available values
|
895
|
+
*/
|
896
|
+
|
897
|
+
|
898
|
+
setValues(values) {
|
899
|
+
this.values = values;
|
900
|
+
}
|
901
|
+
/**
|
902
|
+
* Render the values
|
903
|
+
*
|
904
|
+
* @param {number} selectedValue - selected value (optional)
|
905
|
+
*/
|
906
|
+
|
907
|
+
|
908
|
+
render(selectedValue = 0) {
|
909
|
+
if (this.initialRender) {
|
910
|
+
// hide the cursor initially
|
911
|
+
this.initialRender = false;
|
912
|
+
this.stream.write(_ansiEscapes.cursorHide);
|
913
|
+
} else {
|
914
|
+
// remove previous lines and values
|
915
|
+
this.stream.write((0, _ansiEscapes.eraseLines)(this.values.length));
|
916
|
+
} // output the current values
|
917
|
+
|
918
|
+
|
919
|
+
this.values.forEach((value, index) => {
|
920
|
+
const symbol = selectedValue === index ? this.options.selected : this.options.unselected;
|
921
|
+
const indentation = ' '.repeat(this.options.indentation);
|
922
|
+
const renderedValue = this.options.valueRenderer(value, selectedValue === index);
|
923
|
+
const end = index !== this.values.length - 1 ? '\n' : '';
|
924
|
+
this.stream.write(indentation + symbol + ' ' + renderedValue + end);
|
925
|
+
});
|
926
|
+
}
|
927
|
+
/**
|
928
|
+
* Cleanup the console at the end
|
929
|
+
*/
|
930
|
+
|
931
|
+
|
932
|
+
cleanup() {
|
933
|
+
this.stream.write((0, _ansiEscapes.eraseLines)(this.values.length));
|
934
|
+
this.stream.write(_ansiEscapes.cursorShow);
|
935
|
+
}
|
936
|
+
|
937
|
+
}
|
938
|
+
|
939
|
+
exports["default"] = Renderer;
|
940
|
+
|
941
|
+
/***/ }),
|
942
|
+
|
943
|
+
/***/ 26730:
|
944
|
+
/***/ ((__unused_webpack_module, exports) => {
|
945
|
+
|
946
|
+
|
947
|
+
|
948
|
+
Object.defineProperty(exports, "__esModule", ({
|
949
|
+
value: true
|
950
|
+
}));
|
951
|
+
exports.withObjectValues = exports.withArrayValues = void 0;
|
952
|
+
|
953
|
+
/**
|
954
|
+
* Map incoming and outgoing values if the initial values are an array
|
955
|
+
*
|
956
|
+
* @param {object} options - cli-select options
|
957
|
+
*/
|
958
|
+
const withArrayValues = options => {
|
959
|
+
return {
|
960
|
+
input: options.values,
|
961
|
+
output: (id, value) => {
|
962
|
+
return {
|
963
|
+
id,
|
964
|
+
value
|
965
|
+
};
|
966
|
+
}
|
967
|
+
};
|
968
|
+
};
|
969
|
+
/**
|
970
|
+
* Map incoming and outgoing values if the initial values are an object
|
971
|
+
*
|
972
|
+
* @param {object} options - cli-select options
|
973
|
+
*/
|
974
|
+
|
975
|
+
|
976
|
+
exports.withArrayValues = withArrayValues;
|
977
|
+
|
978
|
+
const withObjectValues = options => {
|
979
|
+
const originalValues = options.values;
|
980
|
+
return {
|
981
|
+
input: Object.values(originalValues),
|
982
|
+
output: (id, value) => {
|
983
|
+
return {
|
984
|
+
id: Object.keys(originalValues)[id],
|
985
|
+
value
|
986
|
+
};
|
987
|
+
}
|
988
|
+
};
|
989
|
+
};
|
990
|
+
|
991
|
+
exports.withObjectValues = withObjectValues;
|
992
|
+
|
993
|
+
/***/ }),
|
994
|
+
|
995
|
+
/***/ 14899:
|
996
|
+
/***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => {
|
997
|
+
|
998
|
+
/* harmony export */ __webpack_require__.d(__webpack_exports__, {
|
999
|
+
/* harmony export */ "k": () => (/* binding */ capitalize)
|
1000
|
+
/* harmony export */ });
|
1001
|
+
/** @see <https://docs.tsafe.dev/capitalize> */
|
1002
|
+
function capitalize(str) {
|
1003
|
+
return (str.charAt(0).toUpperCase() + str.slice(1));
|
1004
|
+
}
|
1005
|
+
|
1006
|
+
|
1007
|
+
//# sourceMappingURL=capitalize.mjs.map
|
1008
|
+
|
1009
|
+
|
1010
|
+
/***/ }),
|
1011
|
+
|
1012
|
+
/***/ 76030:
|
1013
|
+
/***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => {
|
1014
|
+
|
1015
|
+
/* harmony export */ __webpack_require__.d(__webpack_exports__, {
|
1016
|
+
/* harmony export */ "r": () => (/* binding */ symToStr)
|
1017
|
+
/* harmony export */ });
|
1018
|
+
/** @see <https://docs.tsafe.dev/main/symtostr> */
|
1019
|
+
function symToStr(wrap) {
|
1020
|
+
// @ts-expect-error: We know better
|
1021
|
+
return Object.keys(wrap)[0];
|
1022
|
+
}
|
1023
|
+
|
1024
|
+
|
1025
|
+
//# sourceMappingURL=symToStr.mjs.map
|
1026
|
+
|
1027
|
+
|
1028
|
+
/***/ })
|
1029
|
+
|
1030
|
+
};
|
1031
|
+
;
|