create-vue 3.22.3 → 3.22.4
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/bundle.js +1257 -1421
- package/package.json +8 -9
- package/template/base/package.json +5 -5
- package/template/base/vite.config.js.ejs +1 -1
- package/template/config/cypress/package.json +2 -2
- package/template/config/cypress-ct/package.json +2 -2
- package/template/config/jsx/package.json +2 -2
- package/template/config/pinia/package.json +1 -1
- package/template/config/playwright/package.json +1 -1
- package/template/config/router/package.json +2 -2
- package/template/config/typescript/package.json +3 -3
- package/template/config/vitest/package.json +4 -4
- package/template/formatting/oxfmt/package.json +1 -1
- package/template/formatting/prettier/package.json +1 -1
- package/template/linting/base/package.json +3 -2
- package/template/linting/core/js/package.json +3 -3
- package/template/linting/core/ts/package.json +4 -4
- package/template/linting/cypress/package.json +1 -1
- package/template/linting/oxlint/package.json +4 -4
- package/template/linting/playwright/package.json +1 -1
- package/template/linting/vitest/package.json +1 -1
- package/template/tsconfig/vitest/package.json +1 -1
package/bundle.js
CHANGED
|
@@ -1,55 +1,38 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
/*! create-vue v3.22.
|
|
3
|
-
import
|
|
4
|
-
import
|
|
5
|
-
import "node:
|
|
6
|
-
import
|
|
7
|
-
import "node:path";
|
|
2
|
+
/*! create-vue v3.22.4 | MIT */
|
|
3
|
+
import * as fs$1 from "node:fs";
|
|
4
|
+
import fs from "node:fs";
|
|
5
|
+
import * as path$2 from "node:path";
|
|
6
|
+
import path from "node:path";
|
|
8
7
|
import { fileURLToPath, pathToFileURL } from "node:url";
|
|
9
|
-
import { parseArgs,
|
|
10
|
-
import
|
|
11
|
-
import "node:readline";
|
|
12
|
-
import
|
|
13
|
-
import "node:tty";
|
|
14
|
-
import * as path from "path";
|
|
8
|
+
import { parseArgs, styleText } from "node:util";
|
|
9
|
+
import process$1, { stdin, stdout } from "node:process";
|
|
10
|
+
import l__default from "node:readline";
|
|
11
|
+
import * as path$1 from "path";
|
|
15
12
|
//#region \0rolldown/runtime.js
|
|
16
|
-
var __create = Object.create;
|
|
17
|
-
var __defProp = Object.defineProperty;
|
|
18
|
-
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
19
|
-
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
20
|
-
var __getProtoOf = Object.getPrototypeOf;
|
|
21
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
22
13
|
var __commonJSMin = (cb, mod) => () => (mod || (cb((mod = { exports: {} }).exports, mod), cb = null), mod.exports);
|
|
23
|
-
var __copyProps = (to, from, except, desc) => {
|
|
24
|
-
if (from && typeof from === "object" || typeof from === "function") for (var keys = __getOwnPropNames(from), i = 0, n = keys.length, key; i < n; i++) {
|
|
25
|
-
key = keys[i];
|
|
26
|
-
if (!__hasOwnProp.call(to, key) && key !== except) __defProp(to, key, {
|
|
27
|
-
get: ((k) => from[k]).bind(null, key),
|
|
28
|
-
enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
|
|
29
|
-
});
|
|
30
|
-
}
|
|
31
|
-
return to;
|
|
32
|
-
};
|
|
33
|
-
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", {
|
|
34
|
-
value: mod,
|
|
35
|
-
enumerable: true
|
|
36
|
-
}) : target, mod));
|
|
37
|
-
var __require = /* @__PURE__ */ createRequire(import.meta.url);
|
|
38
14
|
//#endregion
|
|
39
|
-
//#region node_modules/.pnpm/fast-string-truncated-width@
|
|
40
|
-
const
|
|
41
|
-
|
|
42
|
-
|
|
15
|
+
//#region node_modules/.pnpm/fast-string-truncated-width@3.0.3/node_modules/fast-string-truncated-width/dist/utils.js
|
|
16
|
+
const getCodePointsLength = (() => {
|
|
17
|
+
const SURROGATE_PAIR_RE = /[\uD800-\uDBFF][\uDC00-\uDFFF]/g;
|
|
18
|
+
return (input) => {
|
|
19
|
+
let surrogatePairsNr = 0;
|
|
20
|
+
SURROGATE_PAIR_RE.lastIndex = 0;
|
|
21
|
+
while (SURROGATE_PAIR_RE.test(input)) surrogatePairsNr += 1;
|
|
22
|
+
return input.length - surrogatePairsNr;
|
|
23
|
+
};
|
|
24
|
+
})();
|
|
43
25
|
const isFullWidth = (x) => {
|
|
44
26
|
return x === 12288 || x >= 65281 && x <= 65376 || x >= 65504 && x <= 65510;
|
|
45
27
|
};
|
|
46
|
-
const
|
|
47
|
-
return x
|
|
28
|
+
const isWideNotCJKTNotEmoji = (x) => {
|
|
29
|
+
return x === 8987 || x === 9001 || x >= 12272 && x <= 12287 || x >= 12289 && x <= 12350 || x >= 12441 && x <= 12543 || x >= 12549 && x <= 12591 || x >= 12593 && x <= 12686 || x >= 12688 && x <= 12771 || x >= 12783 && x <= 12830 || x >= 12832 && x <= 12871 || x >= 12880 && x <= 19903 || x >= 65040 && x <= 65049 || x >= 65072 && x <= 65106 || x >= 65108 && x <= 65126 || x >= 65128 && x <= 65131 || x >= 127488 && x <= 127490 || x >= 127504 && x <= 127547 || x >= 127552 && x <= 127560 || x >= 131072 && x <= 196605 || x >= 196608 && x <= 262141;
|
|
48
30
|
};
|
|
49
31
|
//#endregion
|
|
50
|
-
//#region node_modules/.pnpm/fast-string-truncated-width@
|
|
51
|
-
const ANSI_RE = /[\u001b\u009b][[()#;?]*(?:[0-9]{1,4}(?:;[0-9]{0,4})*)?[0-9A-ORZcf-nqry=><]/y;
|
|
32
|
+
//#region node_modules/.pnpm/fast-string-truncated-width@3.0.3/node_modules/fast-string-truncated-width/dist/index.js
|
|
33
|
+
const ANSI_RE = /[\u001b\u009b][[()#;?]*(?:[0-9]{1,4}(?:;[0-9]{0,4})*)?[0-9A-ORZcf-nqry=><]|\u001b\]8;[^;]*;.*?(?:\u0007|\u001b\u005c)/y;
|
|
52
34
|
const CONTROL_RE = /[\x00-\x08\x0A-\x1F\x7F-\x9F]{1,1000}/y;
|
|
35
|
+
const CJKT_WIDE_RE = /(?:(?![\uFF61-\uFF9F\uFF00-\uFFEF])[\p{Script=Han}\p{Script=Hiragana}\p{Script=Katakana}\p{Script=Hangul}\p{Script=Tangut}]){1,1000}/uy;
|
|
53
36
|
const TAB_RE = /\t{1,1000}/y;
|
|
54
37
|
const EMOJI_RE = /[\u{1F1E6}-\u{1F1FF}]{2}|\u{1F3F4}[\u{E0061}-\u{E007A}]{2}[\u{E0030}-\u{E0039}\u{E0061}-\u{E007A}]{1,3}\u{E007F}|(?:\p{Emoji}\uFE0F\u20E3?|\p{Emoji_Modifier_Base}\p{Emoji_Modifier}?|\p{Emoji_Presentation})(?:\u200D(?:\p{Emoji_Modifier_Base}\p{Emoji_Modifier}?|\p{Emoji_Presentation}|\p{Emoji}\uFE0F\u20E3?))*/uy;
|
|
55
38
|
const LATIN_RE = /(?:[\x20-\x7E\xA0-\xFF](?!\uFE0F)){1,1000}/y;
|
|
@@ -62,14 +45,21 @@ const getStringTruncatedWidth = (input, truncationOptions = {}, widthOptions = {
|
|
|
62
45
|
const LIMIT = truncationOptions.limit ?? Infinity;
|
|
63
46
|
const ELLIPSIS = truncationOptions.ellipsis ?? "";
|
|
64
47
|
const ELLIPSIS_WIDTH = truncationOptions?.ellipsisWidth ?? (ELLIPSIS ? getStringTruncatedWidth(ELLIPSIS, NO_TRUNCATION$1, widthOptions).width : 0);
|
|
65
|
-
const ANSI_WIDTH =
|
|
48
|
+
const ANSI_WIDTH = 0;
|
|
66
49
|
const CONTROL_WIDTH = widthOptions.controlWidth ?? 0;
|
|
67
50
|
const TAB_WIDTH = widthOptions.tabWidth ?? 8;
|
|
68
|
-
const AMBIGUOUS_WIDTH = widthOptions.ambiguousWidth ?? 1;
|
|
69
51
|
const EMOJI_WIDTH = widthOptions.emojiWidth ?? 2;
|
|
70
|
-
const FULL_WIDTH_WIDTH =
|
|
52
|
+
const FULL_WIDTH_WIDTH = 2;
|
|
71
53
|
const REGULAR_WIDTH = widthOptions.regularWidth ?? 1;
|
|
72
|
-
const WIDE_WIDTH = widthOptions.wideWidth ??
|
|
54
|
+
const WIDE_WIDTH = widthOptions.wideWidth ?? FULL_WIDTH_WIDTH;
|
|
55
|
+
const PARSE_BLOCKS = [
|
|
56
|
+
[LATIN_RE, REGULAR_WIDTH],
|
|
57
|
+
[ANSI_RE, ANSI_WIDTH],
|
|
58
|
+
[CONTROL_RE, CONTROL_WIDTH],
|
|
59
|
+
[TAB_RE, TAB_WIDTH],
|
|
60
|
+
[EMOJI_RE, EMOJI_WIDTH],
|
|
61
|
+
[CJKT_WIDE_RE, WIDE_WIDTH]
|
|
62
|
+
];
|
|
73
63
|
let indexPrev = 0;
|
|
74
64
|
let index = 0;
|
|
75
65
|
let length = input.length;
|
|
@@ -88,8 +78,7 @@ const getStringTruncatedWidth = (input, truncationOptions = {}, widthOptions = {
|
|
|
88
78
|
for (const char of unmatched.replaceAll(MODIFIER_RE, "")) {
|
|
89
79
|
const codePoint = char.codePointAt(0) || 0;
|
|
90
80
|
if (isFullWidth(codePoint)) widthExtra = FULL_WIDTH_WIDTH;
|
|
91
|
-
else if (
|
|
92
|
-
else if (AMBIGUOUS_WIDTH !== REGULAR_WIDTH && isAmbiguous(codePoint)) widthExtra = AMBIGUOUS_WIDTH;
|
|
81
|
+
else if (isWideNotCJKTNotEmoji(codePoint)) widthExtra = WIDE_WIDTH;
|
|
93
82
|
else widthExtra = REGULAR_WIDTH;
|
|
94
83
|
if (width + widthExtra > truncationLimit) truncationIndex = Math.min(truncationIndex, Math.max(unmatchedStart, indexPrev) + lengthExtra);
|
|
95
84
|
if (width + widthExtra > LIMIT) {
|
|
@@ -101,77 +90,24 @@ const getStringTruncatedWidth = (input, truncationOptions = {}, widthOptions = {
|
|
|
101
90
|
}
|
|
102
91
|
unmatchedStart = unmatchedEnd = 0;
|
|
103
92
|
}
|
|
104
|
-
if (index >= length) break;
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
if (ANSI_RE.test(input)) {
|
|
122
|
-
if (width + ANSI_WIDTH > truncationLimit) truncationIndex = Math.min(truncationIndex, index);
|
|
123
|
-
if (width + ANSI_WIDTH > LIMIT) {
|
|
124
|
-
truncationEnabled = true;
|
|
125
|
-
break;
|
|
126
|
-
}
|
|
127
|
-
width += ANSI_WIDTH;
|
|
128
|
-
unmatchedStart = indexPrev;
|
|
129
|
-
unmatchedEnd = index;
|
|
130
|
-
index = indexPrev = ANSI_RE.lastIndex;
|
|
131
|
-
continue;
|
|
132
|
-
}
|
|
133
|
-
CONTROL_RE.lastIndex = index;
|
|
134
|
-
if (CONTROL_RE.test(input)) {
|
|
135
|
-
lengthExtra = CONTROL_RE.lastIndex - index;
|
|
136
|
-
widthExtra = lengthExtra * CONTROL_WIDTH;
|
|
137
|
-
if (width + widthExtra > truncationLimit) truncationIndex = Math.min(truncationIndex, index + Math.floor((truncationLimit - width) / CONTROL_WIDTH));
|
|
138
|
-
if (width + widthExtra > LIMIT) {
|
|
139
|
-
truncationEnabled = true;
|
|
140
|
-
break;
|
|
141
|
-
}
|
|
142
|
-
width += widthExtra;
|
|
143
|
-
unmatchedStart = indexPrev;
|
|
144
|
-
unmatchedEnd = index;
|
|
145
|
-
index = indexPrev = CONTROL_RE.lastIndex;
|
|
146
|
-
continue;
|
|
147
|
-
}
|
|
148
|
-
TAB_RE.lastIndex = index;
|
|
149
|
-
if (TAB_RE.test(input)) {
|
|
150
|
-
lengthExtra = TAB_RE.lastIndex - index;
|
|
151
|
-
widthExtra = lengthExtra * TAB_WIDTH;
|
|
152
|
-
if (width + widthExtra > truncationLimit) truncationIndex = Math.min(truncationIndex, index + Math.floor((truncationLimit - width) / TAB_WIDTH));
|
|
153
|
-
if (width + widthExtra > LIMIT) {
|
|
154
|
-
truncationEnabled = true;
|
|
155
|
-
break;
|
|
156
|
-
}
|
|
157
|
-
width += widthExtra;
|
|
158
|
-
unmatchedStart = indexPrev;
|
|
159
|
-
unmatchedEnd = index;
|
|
160
|
-
index = indexPrev = TAB_RE.lastIndex;
|
|
161
|
-
continue;
|
|
162
|
-
}
|
|
163
|
-
EMOJI_RE.lastIndex = index;
|
|
164
|
-
if (EMOJI_RE.test(input)) {
|
|
165
|
-
if (width + EMOJI_WIDTH > truncationLimit) truncationIndex = Math.min(truncationIndex, index);
|
|
166
|
-
if (width + EMOJI_WIDTH > LIMIT) {
|
|
167
|
-
truncationEnabled = true;
|
|
168
|
-
break;
|
|
93
|
+
if (index >= length) break outer;
|
|
94
|
+
for (let i = 0, l = PARSE_BLOCKS.length; i < l; i++) {
|
|
95
|
+
const [BLOCK_RE, BLOCK_WIDTH] = PARSE_BLOCKS[i];
|
|
96
|
+
BLOCK_RE.lastIndex = index;
|
|
97
|
+
if (BLOCK_RE.test(input)) {
|
|
98
|
+
lengthExtra = BLOCK_RE === CJKT_WIDE_RE ? getCodePointsLength(input.slice(index, BLOCK_RE.lastIndex)) : BLOCK_RE === EMOJI_RE ? 1 : BLOCK_RE.lastIndex - index;
|
|
99
|
+
widthExtra = lengthExtra * BLOCK_WIDTH;
|
|
100
|
+
if (width + widthExtra > truncationLimit) truncationIndex = Math.min(truncationIndex, index + Math.floor((truncationLimit - width) / BLOCK_WIDTH));
|
|
101
|
+
if (width + widthExtra > LIMIT) {
|
|
102
|
+
truncationEnabled = true;
|
|
103
|
+
break outer;
|
|
104
|
+
}
|
|
105
|
+
width += widthExtra;
|
|
106
|
+
unmatchedStart = indexPrev;
|
|
107
|
+
unmatchedEnd = index;
|
|
108
|
+
index = indexPrev = BLOCK_RE.lastIndex;
|
|
109
|
+
continue outer;
|
|
169
110
|
}
|
|
170
|
-
width += EMOJI_WIDTH;
|
|
171
|
-
unmatchedStart = indexPrev;
|
|
172
|
-
unmatchedEnd = index;
|
|
173
|
-
index = indexPrev = EMOJI_RE.lastIndex;
|
|
174
|
-
continue;
|
|
175
111
|
}
|
|
176
112
|
index += 1;
|
|
177
113
|
}
|
|
@@ -183,7 +119,7 @@ const getStringTruncatedWidth = (input, truncationOptions = {}, widthOptions = {
|
|
|
183
119
|
};
|
|
184
120
|
};
|
|
185
121
|
//#endregion
|
|
186
|
-
//#region node_modules/.pnpm/fast-string-width@
|
|
122
|
+
//#region node_modules/.pnpm/fast-string-width@3.0.2/node_modules/fast-string-width/dist/index.js
|
|
187
123
|
const NO_TRUNCATION = {
|
|
188
124
|
limit: Infinity,
|
|
189
125
|
ellipsis: "",
|
|
@@ -193,7 +129,7 @@ const fastStringWidth = (input, options = {}) => {
|
|
|
193
129
|
return getStringTruncatedWidth(input, NO_TRUNCATION, options).width;
|
|
194
130
|
};
|
|
195
131
|
//#endregion
|
|
196
|
-
//#region node_modules/.pnpm/fast-wrap-ansi@0.
|
|
132
|
+
//#region node_modules/.pnpm/fast-wrap-ansi@0.2.2/node_modules/fast-wrap-ansi/lib/main.js
|
|
197
133
|
const ESC = "\x1B";
|
|
198
134
|
const CSI = "";
|
|
199
135
|
const END_CODE = 39;
|
|
@@ -330,8 +266,10 @@ const exec = (string, columns, options = {}) => {
|
|
|
330
266
|
for (let i = 0; i < preString.length; i++) {
|
|
331
267
|
const character = preString[i];
|
|
332
268
|
returnValue += character;
|
|
333
|
-
if (!inSurrogate)
|
|
334
|
-
|
|
269
|
+
if (!inSurrogate) {
|
|
270
|
+
inSurrogate = character >= "\ud800" && character <= "\udbff";
|
|
271
|
+
if (inSurrogate) continue;
|
|
272
|
+
} else inSurrogate = false;
|
|
335
273
|
if (character === ESC || character === CSI) {
|
|
336
274
|
GROUP_REGEX.lastIndex = i + 1;
|
|
337
275
|
const groups = GROUP_REGEX.exec(preString)?.groups;
|
|
@@ -356,7 +294,7 @@ function wrapAnsi(string, columns, options) {
|
|
|
356
294
|
return String(string).normalize().split(CRLF_OR_LF).map((line) => exec(line, columns, options)).join("\n");
|
|
357
295
|
}
|
|
358
296
|
//#endregion
|
|
359
|
-
//#region node_modules/.pnpm/@clack+core@1.
|
|
297
|
+
//#region node_modules/.pnpm/@clack+core@1.4.1/node_modules/@clack/core/dist/index.mjs
|
|
360
298
|
var import_src = (/* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
361
299
|
const ESC = "\x1B";
|
|
362
300
|
const CSI = `${ESC}[`;
|
|
@@ -409,12 +347,12 @@ var import_src = (/* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
|
409
347
|
beep
|
|
410
348
|
};
|
|
411
349
|
})))();
|
|
412
|
-
function
|
|
413
|
-
if (!
|
|
414
|
-
const
|
|
415
|
-
return e
|
|
350
|
+
function findCursor(s, o, l) {
|
|
351
|
+
if (!l.some((r) => !r.disabled)) return s;
|
|
352
|
+
const t = s + o, n = Math.max(l.length - 1, 0), e = t < 0 ? n : t > n ? 0 : t;
|
|
353
|
+
return l[e].disabled ? findCursor(e, o < 0 ? -1 : 1, l) : e;
|
|
416
354
|
}
|
|
417
|
-
const
|
|
355
|
+
const settings = {
|
|
418
356
|
actions: new Set([
|
|
419
357
|
"up",
|
|
420
358
|
"down",
|
|
@@ -424,7 +362,7 @@ const u = {
|
|
|
424
362
|
"enter",
|
|
425
363
|
"cancel"
|
|
426
364
|
]),
|
|
427
|
-
aliases: new Map([
|
|
365
|
+
aliases: /* @__PURE__ */ new Map([
|
|
428
366
|
["k", "up"],
|
|
429
367
|
["j", "down"],
|
|
430
368
|
["h", "left"],
|
|
@@ -436,7 +374,7 @@ const u = {
|
|
|
436
374
|
cancel: "Canceled",
|
|
437
375
|
error: "Something went wrong"
|
|
438
376
|
},
|
|
439
|
-
withGuide:
|
|
377
|
+
withGuide: true,
|
|
440
378
|
date: {
|
|
441
379
|
monthNames: [...[
|
|
442
380
|
"January",
|
|
@@ -455,56 +393,67 @@ const u = {
|
|
|
455
393
|
messages: {
|
|
456
394
|
required: "Please enter a valid date",
|
|
457
395
|
invalidMonth: "There are only 12 months in a year",
|
|
458
|
-
invalidDay: (
|
|
459
|
-
afterMin: (
|
|
460
|
-
beforeMax: (
|
|
396
|
+
invalidDay: (n, e) => `There are only ${n} days in ${e}`,
|
|
397
|
+
afterMin: (n) => `Date must be on or after ${n.toISOString().slice(0, 10)}`,
|
|
398
|
+
beforeMax: (n) => `Date must be on or before ${n.toISOString().slice(0, 10)}`
|
|
461
399
|
}
|
|
462
400
|
}
|
|
463
401
|
};
|
|
464
|
-
function
|
|
465
|
-
if (typeof
|
|
466
|
-
for (const
|
|
467
|
-
return
|
|
402
|
+
function isActionKey(n, e) {
|
|
403
|
+
if (typeof n == "string") return settings.aliases.get(n) === e;
|
|
404
|
+
for (const s of n) if (s !== void 0 && isActionKey(s, e)) return true;
|
|
405
|
+
return false;
|
|
468
406
|
}
|
|
469
|
-
function
|
|
470
|
-
if (
|
|
471
|
-
const e =
|
|
472
|
-
`),
|
|
473
|
-
`),
|
|
474
|
-
for (let
|
|
407
|
+
function diffLines(i, s) {
|
|
408
|
+
if (i === s) return;
|
|
409
|
+
const e = i.split(`
|
|
410
|
+
`), t = s.split(`
|
|
411
|
+
`), r = Math.max(e.length, t.length), f = [];
|
|
412
|
+
for (let n = 0; n < r; n++) e[n] !== t[n] && f.push(n);
|
|
475
413
|
return {
|
|
476
|
-
lines:
|
|
414
|
+
lines: f,
|
|
477
415
|
numLinesBefore: e.length,
|
|
478
|
-
numLinesAfter:
|
|
479
|
-
numLines:
|
|
416
|
+
numLinesAfter: t.length,
|
|
417
|
+
numLines: r
|
|
480
418
|
};
|
|
481
419
|
}
|
|
482
420
|
globalThis.process.platform.startsWith("win");
|
|
483
|
-
const
|
|
484
|
-
function
|
|
485
|
-
return
|
|
421
|
+
const CANCEL_SYMBOL = Symbol("clack:cancel");
|
|
422
|
+
function isCancel(e) {
|
|
423
|
+
return e === CANCEL_SYMBOL;
|
|
486
424
|
}
|
|
487
|
-
function
|
|
488
|
-
const
|
|
489
|
-
|
|
425
|
+
function setRawMode(e, r) {
|
|
426
|
+
const o = e;
|
|
427
|
+
o.isTTY && o.setRawMode(r);
|
|
490
428
|
}
|
|
491
|
-
const
|
|
492
|
-
function
|
|
493
|
-
return wrapAnsi(
|
|
494
|
-
hard:
|
|
495
|
-
trim:
|
|
429
|
+
const getColumns = (e) => "columns" in e && typeof e.columns == "number" ? e.columns : 80, getRows = (e) => "rows" in e && typeof e.rows == "number" ? e.rows : 20;
|
|
430
|
+
function wrapTextWithPrefix(e, r, o, t = o, s = o, n) {
|
|
431
|
+
return wrapAnsi(r, getColumns(e ?? stdout) - o.length, {
|
|
432
|
+
hard: true,
|
|
433
|
+
trim: false
|
|
496
434
|
}).split(`
|
|
497
|
-
`).map((
|
|
435
|
+
`).map((c, i, m) => {
|
|
436
|
+
const d = n ? n(c, i) : c;
|
|
437
|
+
return i === 0 ? `${t}${d}` : i === m.length - 1 ? `${s}${d}` : `${o}${d}`;
|
|
438
|
+
}).join(`
|
|
498
439
|
`);
|
|
499
440
|
}
|
|
500
|
-
|
|
441
|
+
function runValidation(e, n) {
|
|
442
|
+
if ("~standard" in e) {
|
|
443
|
+
const a = e["~standard"].validate(n);
|
|
444
|
+
if (a instanceof Promise) throw new TypeError("Schema validation must be synchronous. Update `validate()` and remove any asynchronous logic.");
|
|
445
|
+
return a.issues?.at(0)?.message;
|
|
446
|
+
}
|
|
447
|
+
return e(n);
|
|
448
|
+
}
|
|
449
|
+
var V = class {
|
|
501
450
|
input;
|
|
502
451
|
output;
|
|
503
452
|
_abortSignal;
|
|
504
453
|
rl;
|
|
505
454
|
opts;
|
|
506
455
|
_render;
|
|
507
|
-
_track =
|
|
456
|
+
_track = false;
|
|
508
457
|
_prevFrame = "";
|
|
509
458
|
_subscribers = /* @__PURE__ */ new Map();
|
|
510
459
|
_cursor = 0;
|
|
@@ -512,55 +461,80 @@ let p = class {
|
|
|
512
461
|
error = "";
|
|
513
462
|
value;
|
|
514
463
|
userInput = "";
|
|
515
|
-
constructor(t, e =
|
|
516
|
-
const { input:
|
|
517
|
-
this.opts =
|
|
464
|
+
constructor(t, e = true) {
|
|
465
|
+
const { input: i = stdin, output: n = stdout, render: s, signal: r, ...o } = t;
|
|
466
|
+
this.opts = o, this.onKeypress = this.onKeypress.bind(this), this.close = this.close.bind(this), this.render = this.render.bind(this), this._render = s.bind(this), this._track = e, this._abortSignal = r, this.input = i, this.output = n;
|
|
518
467
|
}
|
|
468
|
+
/**
|
|
469
|
+
* Unsubscribe all listeners
|
|
470
|
+
*/
|
|
519
471
|
unsubscribe() {
|
|
520
472
|
this._subscribers.clear();
|
|
521
473
|
}
|
|
474
|
+
/**
|
|
475
|
+
* Set a subscriber with opts
|
|
476
|
+
* @param event - The event name
|
|
477
|
+
*/
|
|
522
478
|
setSubscriber(t, e) {
|
|
523
|
-
const
|
|
524
|
-
|
|
479
|
+
const i = this._subscribers.get(t) ?? [];
|
|
480
|
+
i.push(e), this._subscribers.set(t, i);
|
|
525
481
|
}
|
|
482
|
+
/**
|
|
483
|
+
* Subscribe to an event
|
|
484
|
+
* @param event - The event name
|
|
485
|
+
* @param cb - The callback
|
|
486
|
+
*/
|
|
526
487
|
on(t, e) {
|
|
527
488
|
this.setSubscriber(t, { cb: e });
|
|
528
489
|
}
|
|
490
|
+
/**
|
|
491
|
+
* Subscribe to an event once
|
|
492
|
+
* @param event - The event name
|
|
493
|
+
* @param cb - The callback
|
|
494
|
+
*/
|
|
529
495
|
once(t, e) {
|
|
530
496
|
this.setSubscriber(t, {
|
|
531
497
|
cb: e,
|
|
532
|
-
once:
|
|
498
|
+
once: true
|
|
533
499
|
});
|
|
534
500
|
}
|
|
501
|
+
/**
|
|
502
|
+
* Emit an event with data
|
|
503
|
+
* @param event - The event name
|
|
504
|
+
* @param data - The data to pass to the callback
|
|
505
|
+
*/
|
|
535
506
|
emit(t, ...e) {
|
|
536
|
-
const
|
|
537
|
-
for (const
|
|
538
|
-
for (const
|
|
507
|
+
const i = this._subscribers.get(t) ?? [], n = [];
|
|
508
|
+
for (const s of i) s.cb(...e), s.once && n.push(() => i.splice(i.indexOf(s), 1));
|
|
509
|
+
for (const s of n) s();
|
|
539
510
|
}
|
|
540
511
|
prompt() {
|
|
541
512
|
return new Promise((t) => {
|
|
542
513
|
if (this._abortSignal) {
|
|
543
|
-
if (this._abortSignal.aborted) return this.state = "cancel", this.close(), t(
|
|
514
|
+
if (this._abortSignal.aborted) return this.state = "cancel", this.close(), t(CANCEL_SYMBOL);
|
|
544
515
|
this._abortSignal.addEventListener("abort", () => {
|
|
545
516
|
this.state = "cancel", this.close();
|
|
546
|
-
}, { once:
|
|
517
|
+
}, { once: true });
|
|
547
518
|
}
|
|
548
|
-
this.rl =
|
|
519
|
+
this.rl = l__default.createInterface({
|
|
549
520
|
input: this.input,
|
|
550
521
|
tabSize: 2,
|
|
551
522
|
prompt: "",
|
|
552
523
|
escapeCodeTimeout: 50,
|
|
553
|
-
terminal:
|
|
554
|
-
}), this.rl.prompt(), this.opts.initialUserInput !== void 0 && this._setUserInput(this.opts.initialUserInput,
|
|
555
|
-
this.output.write(import_src.cursor.show), this.output.off("resize", this.render),
|
|
524
|
+
terminal: true
|
|
525
|
+
}), this.rl.prompt(), this.opts.initialUserInput !== void 0 && this._setUserInput(this.opts.initialUserInput, true), this.input.on("keypress", this.onKeypress), setRawMode(this.input, true), this.output.on("resize", this.render), this.render(), this.once("submit", () => {
|
|
526
|
+
this.output.write(import_src.cursor.show), this.output.off("resize", this.render), setRawMode(this.input, false), t(this.value);
|
|
556
527
|
}), this.once("cancel", () => {
|
|
557
|
-
this.output.write(import_src.cursor.show), this.output.off("resize", this.render),
|
|
528
|
+
this.output.write(import_src.cursor.show), this.output.off("resize", this.render), setRawMode(this.input, false), t(CANCEL_SYMBOL);
|
|
558
529
|
});
|
|
559
530
|
});
|
|
560
531
|
}
|
|
561
532
|
_isActionKey(t, e) {
|
|
562
533
|
return t === " ";
|
|
563
534
|
}
|
|
535
|
+
_shouldSubmit(t, e) {
|
|
536
|
+
return true;
|
|
537
|
+
}
|
|
564
538
|
_setValue(t) {
|
|
565
539
|
this.value = t, this.emit("value", this.value);
|
|
566
540
|
}
|
|
@@ -569,22 +543,22 @@ let p = class {
|
|
|
569
543
|
}
|
|
570
544
|
_clearUserInput() {
|
|
571
545
|
this.rl?.write(null, {
|
|
572
|
-
ctrl:
|
|
546
|
+
ctrl: true,
|
|
573
547
|
name: "u"
|
|
574
548
|
}), this._setUserInput("");
|
|
575
549
|
}
|
|
576
550
|
onKeypress(t, e) {
|
|
577
551
|
if (this._track && e.name !== "return" && (e.name && this._isActionKey(t, e) && this.rl?.write(null, {
|
|
578
|
-
ctrl:
|
|
552
|
+
ctrl: true,
|
|
579
553
|
name: "h"
|
|
580
|
-
}), this._cursor = this.rl?.cursor ?? 0, this._setUserInput(this.rl?.line)), this.state === "error" && (this.state = "active"), e?.name && (!this._track &&
|
|
554
|
+
}), this._cursor = this.rl?.cursor ?? 0, this._setUserInput(this.rl?.line)), this.state === "error" && (this.state = "active"), e?.name && (!this._track && settings.aliases.has(e.name) && this.emit("cursor", settings.aliases.get(e.name)), settings.actions.has(e.name) && this.emit("cursor", e.name)), t && (t.toLowerCase() === "y" || t.toLowerCase() === "n") && this.emit("confirm", t.toLowerCase() === "y"), this.emit("key", t, e), e?.name === "return" && this._shouldSubmit(t, e)) {
|
|
581
555
|
if (this.opts.validate) {
|
|
582
|
-
const
|
|
583
|
-
|
|
556
|
+
const i = runValidation(this.opts.validate, this.value);
|
|
557
|
+
i && (this.error = i instanceof Error ? i.message : i, this.state = "error", this.rl?.write(this.userInput));
|
|
584
558
|
}
|
|
585
559
|
this.state !== "error" && (this.state = "submit");
|
|
586
560
|
}
|
|
587
|
-
|
|
561
|
+
isActionKey([
|
|
588
562
|
t,
|
|
589
563
|
e?.name,
|
|
590
564
|
e?.sequence
|
|
@@ -592,48 +566,48 @@ let p = class {
|
|
|
592
566
|
}
|
|
593
567
|
close() {
|
|
594
568
|
this.input.unpipe(), this.input.removeListener("keypress", this.onKeypress), this.output.write(`
|
|
595
|
-
`),
|
|
569
|
+
`), setRawMode(this.input, false), this.rl?.close(), this.rl = void 0, this.emit(`${this.state}`, this.value), this.unsubscribe();
|
|
596
570
|
}
|
|
597
571
|
restoreCursor() {
|
|
598
572
|
const t = wrapAnsi(this._prevFrame, process.stdout.columns, {
|
|
599
|
-
hard:
|
|
600
|
-
trim:
|
|
573
|
+
hard: true,
|
|
574
|
+
trim: false
|
|
601
575
|
}).split(`
|
|
602
576
|
`).length - 1;
|
|
603
577
|
this.output.write(import_src.cursor.move(-999, t * -1));
|
|
604
578
|
}
|
|
605
579
|
render() {
|
|
606
580
|
const t = wrapAnsi(this._render(this) ?? "", process.stdout.columns, {
|
|
607
|
-
hard:
|
|
608
|
-
trim:
|
|
581
|
+
hard: true,
|
|
582
|
+
trim: false
|
|
609
583
|
});
|
|
610
584
|
if (t !== this._prevFrame) {
|
|
611
585
|
if (this.state === "initial") this.output.write(import_src.cursor.hide);
|
|
612
586
|
else {
|
|
613
|
-
const e =
|
|
587
|
+
const e = diffLines(this._prevFrame, t), i = getRows(this.output);
|
|
614
588
|
if (this.restoreCursor(), e) {
|
|
615
|
-
const
|
|
616
|
-
let
|
|
617
|
-
if (
|
|
589
|
+
const n = Math.max(0, e.numLinesAfter - i), s = Math.max(0, e.numLinesBefore - i);
|
|
590
|
+
let r = e.lines.find((o) => o >= n);
|
|
591
|
+
if (r === void 0) {
|
|
618
592
|
this._prevFrame = t;
|
|
619
593
|
return;
|
|
620
594
|
}
|
|
621
595
|
if (e.lines.length === 1) {
|
|
622
|
-
this.output.write(import_src.cursor.move(0,
|
|
623
|
-
const
|
|
596
|
+
this.output.write(import_src.cursor.move(0, r - s)), this.output.write(import_src.erase.lines(1));
|
|
597
|
+
const o = t.split(`
|
|
624
598
|
`);
|
|
625
|
-
this.output.write(
|
|
599
|
+
this.output.write(o[r]), this._prevFrame = t, this.output.write(import_src.cursor.move(0, o.length - r - 1));
|
|
626
600
|
return;
|
|
627
601
|
} else if (e.lines.length > 1) {
|
|
628
|
-
if (
|
|
602
|
+
if (n < s) r = n;
|
|
629
603
|
else {
|
|
630
|
-
const h =
|
|
604
|
+
const h = r - s;
|
|
631
605
|
h > 0 && this.output.write(import_src.cursor.move(0, h));
|
|
632
606
|
}
|
|
633
607
|
this.output.write(import_src.erase.down());
|
|
634
|
-
const
|
|
635
|
-
`).slice(
|
|
636
|
-
this.output.write(
|
|
608
|
+
const f = t.split(`
|
|
609
|
+
`).slice(r);
|
|
610
|
+
this.output.write(f.join(`
|
|
637
611
|
`)), this._prevFrame = t;
|
|
638
612
|
return;
|
|
639
613
|
}
|
|
@@ -644,7 +618,7 @@ let p = class {
|
|
|
644
618
|
}
|
|
645
619
|
}
|
|
646
620
|
};
|
|
647
|
-
var
|
|
621
|
+
var r = class extends V {
|
|
648
622
|
get cursor() {
|
|
649
623
|
return this.value ? 0 : 1;
|
|
650
624
|
}
|
|
@@ -652,53 +626,53 @@ var Q$1 = class extends p {
|
|
|
652
626
|
return this.cursor === 0;
|
|
653
627
|
}
|
|
654
628
|
constructor(t) {
|
|
655
|
-
super(t,
|
|
629
|
+
super(t, false), this.value = !!t.initialValue, this.on("userInput", () => {
|
|
656
630
|
this.value = this._value;
|
|
657
|
-
}), this.on("confirm", (
|
|
658
|
-
this.output.write(import_src.cursor.move(0, -1)), this.value =
|
|
631
|
+
}), this.on("confirm", (i) => {
|
|
632
|
+
this.output.write(import_src.cursor.move(0, -1)), this.value = i, this.state = "submit", this.close();
|
|
659
633
|
}), this.on("cursor", () => {
|
|
660
634
|
this.value = !this.value;
|
|
661
635
|
});
|
|
662
636
|
}
|
|
663
637
|
};
|
|
664
|
-
let
|
|
638
|
+
let a$1 = class a extends V {
|
|
665
639
|
options;
|
|
666
640
|
cursor = 0;
|
|
667
641
|
get _value() {
|
|
668
642
|
return this.options[this.cursor].value;
|
|
669
643
|
}
|
|
670
644
|
get _enabledOptions() {
|
|
671
|
-
return this.options.filter((
|
|
645
|
+
return this.options.filter((e) => e.disabled !== true);
|
|
672
646
|
}
|
|
673
647
|
toggleAll() {
|
|
674
|
-
const
|
|
675
|
-
this.value =
|
|
648
|
+
const e = this._enabledOptions, i = this.value !== void 0 && this.value.length === e.length;
|
|
649
|
+
this.value = i ? [] : e.map((t) => t.value);
|
|
676
650
|
}
|
|
677
651
|
toggleInvert() {
|
|
678
|
-
const
|
|
679
|
-
if (!
|
|
680
|
-
const
|
|
681
|
-
this.value =
|
|
652
|
+
const e = this.value;
|
|
653
|
+
if (!e) return;
|
|
654
|
+
const i = this._enabledOptions.filter((t) => !e.includes(t.value));
|
|
655
|
+
this.value = i.map((t) => t.value);
|
|
682
656
|
}
|
|
683
657
|
toggleValue() {
|
|
684
658
|
this.value === void 0 && (this.value = []);
|
|
685
|
-
const
|
|
686
|
-
this.value =
|
|
687
|
-
}
|
|
688
|
-
constructor(
|
|
689
|
-
super(
|
|
690
|
-
const
|
|
691
|
-
this.cursor = this.options[
|
|
692
|
-
|
|
693
|
-
}), this.on("cursor", (
|
|
694
|
-
switch (
|
|
659
|
+
const e = this.value.includes(this._value);
|
|
660
|
+
this.value = e ? this.value.filter((i) => i !== this._value) : [...this.value, this._value];
|
|
661
|
+
}
|
|
662
|
+
constructor(e) {
|
|
663
|
+
super(e, false), this.options = e.options, this.value = [...e.initialValues ?? []];
|
|
664
|
+
const i = Math.max(this.options.findIndex(({ value: t }) => t === e.cursorAt), 0);
|
|
665
|
+
this.cursor = this.options[i].disabled ? findCursor(i, 1, this.options) : i, this.on("key", (t, l) => {
|
|
666
|
+
l.name === "a" && this.toggleAll(), l.name === "i" && this.toggleInvert();
|
|
667
|
+
}), this.on("cursor", (t) => {
|
|
668
|
+
switch (t) {
|
|
695
669
|
case "left":
|
|
696
670
|
case "up":
|
|
697
|
-
this.cursor =
|
|
671
|
+
this.cursor = findCursor(this.cursor, -1, this.options);
|
|
698
672
|
break;
|
|
699
673
|
case "down":
|
|
700
674
|
case "right":
|
|
701
|
-
this.cursor =
|
|
675
|
+
this.cursor = findCursor(this.cursor, 1, this.options);
|
|
702
676
|
break;
|
|
703
677
|
case "space":
|
|
704
678
|
this.toggleValue();
|
|
@@ -707,7 +681,7 @@ let it$1 = class extends p {
|
|
|
707
681
|
});
|
|
708
682
|
}
|
|
709
683
|
};
|
|
710
|
-
var
|
|
684
|
+
var a = class extends V {
|
|
711
685
|
options;
|
|
712
686
|
cursor = 0;
|
|
713
687
|
get _selectedValue() {
|
|
@@ -717,30 +691,30 @@ var nt$1 = class extends p {
|
|
|
717
691
|
this.value = this._selectedValue.value;
|
|
718
692
|
}
|
|
719
693
|
constructor(t) {
|
|
720
|
-
super(t,
|
|
721
|
-
const
|
|
722
|
-
this.cursor = this.options[
|
|
723
|
-
switch (
|
|
694
|
+
super(t, false), this.options = t.options;
|
|
695
|
+
const i = this.options.findIndex(({ value: s }) => s === t.initialValue), e = i === -1 ? 0 : i;
|
|
696
|
+
this.cursor = this.options[e].disabled ? findCursor(e, 1, this.options) : e, this.changeValue(), this.on("cursor", (s) => {
|
|
697
|
+
switch (s) {
|
|
724
698
|
case "left":
|
|
725
699
|
case "up":
|
|
726
|
-
this.cursor =
|
|
700
|
+
this.cursor = findCursor(this.cursor, -1, this.options);
|
|
727
701
|
break;
|
|
728
702
|
case "down":
|
|
729
703
|
case "right":
|
|
730
|
-
this.cursor =
|
|
704
|
+
this.cursor = findCursor(this.cursor, 1, this.options);
|
|
731
705
|
break;
|
|
732
706
|
}
|
|
733
707
|
this.changeValue();
|
|
734
708
|
});
|
|
735
709
|
}
|
|
736
710
|
};
|
|
737
|
-
var
|
|
711
|
+
var n = class extends V {
|
|
738
712
|
get userInputWithCursor() {
|
|
739
713
|
if (this.state === "submit") return this.userInput;
|
|
740
714
|
const t = this.userInput;
|
|
741
715
|
if (this.cursor >= t.length) return `${this.userInput}\u2588`;
|
|
742
|
-
const e = t.slice(0, this.cursor), [s, ...
|
|
743
|
-
return `${e}${styleText("inverse", s)}${
|
|
716
|
+
const e = t.slice(0, this.cursor), [s, ...r] = t.slice(this.cursor);
|
|
717
|
+
return `${e}${styleText("inverse", s)}${r.join("")}`;
|
|
744
718
|
}
|
|
745
719
|
get cursor() {
|
|
746
720
|
return this._cursor;
|
|
@@ -757,182 +731,129 @@ var at$1 = class extends p {
|
|
|
757
731
|
}
|
|
758
732
|
};
|
|
759
733
|
//#endregion
|
|
760
|
-
//#region node_modules/.pnpm/@clack+prompts@1.
|
|
761
|
-
function
|
|
762
|
-
|
|
734
|
+
//#region node_modules/.pnpm/@clack+prompts@1.5.1/node_modules/@clack/prompts/dist/index.mjs
|
|
735
|
+
function isUnicodeSupported() {
|
|
736
|
+
if (process$1.platform !== "win32") return process$1.env.TERM !== "linux";
|
|
737
|
+
return Boolean(process$1.env.CI) || Boolean(process$1.env.WT_SESSION) || Boolean(process$1.env.TERMINUS_SUBLIME) || process$1.env.ConEmuTask === "{cmd::Cmder}" || process$1.env.TERM_PROGRAM === "Terminus-Sublime" || process$1.env.TERM_PROGRAM === "vscode" || process$1.env.TERM === "xterm-256color" || process$1.env.TERM === "alacritty" || process$1.env.TERMINAL_EMULATOR === "JetBrains-JediTerm";
|
|
763
738
|
}
|
|
764
|
-
const
|
|
765
|
-
w("┐", "T");
|
|
766
|
-
w("┘", "—");
|
|
767
|
-
const z = w("●", ">"), H = w("○", " "), te = w("◻", "[•]"), U = w("◼", "[+]"), J = w("◻", "[ ]");
|
|
768
|
-
w("▪", "•");
|
|
769
|
-
w("─", "-");
|
|
770
|
-
w("╮", "+");
|
|
771
|
-
w("├", "+");
|
|
772
|
-
w("╯", "+");
|
|
773
|
-
w("╰", "+");
|
|
774
|
-
w("╭", "+");
|
|
775
|
-
const he = w("●", "•"), pe = w("◆", "*"), me = w("▲", "!"), ge = w("■", "x"), V = (e) => {
|
|
739
|
+
const unicode = isUnicodeSupported(), unicodeOr = (e, o) => unicode ? e : o, S_STEP_ACTIVE = unicodeOr("◆", "*"), S_STEP_CANCEL = unicodeOr("■", "x"), S_STEP_ERROR = unicodeOr("▲", "x"), S_STEP_SUBMIT = unicodeOr("◇", "o"), S_BAR_START = unicodeOr("┌", "T"), S_BAR = unicodeOr("│", "|"), S_BAR_END = unicodeOr("└", "—"), S_RADIO_ACTIVE = unicodeOr("●", ">"), S_RADIO_INACTIVE = unicodeOr("○", " "), S_CHECKBOX_ACTIVE = unicodeOr("◻", "[•]"), S_CHECKBOX_SELECTED = unicodeOr("◼", "[+]"), S_CHECKBOX_INACTIVE = unicodeOr("◻", "[ ]"), symbol = (e) => {
|
|
776
740
|
switch (e) {
|
|
777
741
|
case "initial":
|
|
778
|
-
case "active": return styleText("cyan",
|
|
779
|
-
case "cancel": return styleText("red",
|
|
780
|
-
case "error": return styleText("yellow",
|
|
781
|
-
case "submit": return styleText("green",
|
|
742
|
+
case "active": return styleText("cyan", S_STEP_ACTIVE);
|
|
743
|
+
case "cancel": return styleText("red", S_STEP_CANCEL);
|
|
744
|
+
case "error": return styleText("yellow", S_STEP_ERROR);
|
|
745
|
+
case "submit": return styleText("green", S_STEP_SUBMIT);
|
|
782
746
|
}
|
|
783
|
-
},
|
|
747
|
+
}, symbolBar = (e) => {
|
|
784
748
|
switch (e) {
|
|
785
749
|
case "initial":
|
|
786
|
-
case "active": return styleText("cyan",
|
|
787
|
-
case "cancel": return styleText("red",
|
|
788
|
-
case "error": return styleText("yellow",
|
|
789
|
-
case "submit": return styleText("green",
|
|
790
|
-
}
|
|
791
|
-
}, et = (e, i, s, r, u) => {
|
|
792
|
-
let n = i, o = 0;
|
|
793
|
-
for (let c = s; c < r; c++) {
|
|
794
|
-
const a = e[c];
|
|
795
|
-
if (n = n - a.length, o++, n <= u) break;
|
|
750
|
+
case "active": return styleText("cyan", S_BAR);
|
|
751
|
+
case "cancel": return styleText("red", S_BAR);
|
|
752
|
+
case "error": return styleText("yellow", S_BAR);
|
|
753
|
+
case "submit": return styleText("green", S_BAR);
|
|
796
754
|
}
|
|
755
|
+
};
|
|
756
|
+
const E$1 = (l, o, g, c, h, O = false) => {
|
|
757
|
+
let r = o, w = 0;
|
|
758
|
+
if (O) for (let i = c - 1; i >= g && (r -= l[i].length, w++, !(r <= h)); i--);
|
|
759
|
+
else for (let i = g; i < c && (r -= l[i].length, w++, !(r <= h)); i++);
|
|
797
760
|
return {
|
|
798
|
-
lineCount:
|
|
799
|
-
removals:
|
|
761
|
+
lineCount: r,
|
|
762
|
+
removals: w
|
|
800
763
|
};
|
|
801
|
-
}
|
|
802
|
-
|
|
764
|
+
};
|
|
765
|
+
const limitOptions = ({ cursor: l, options: o, style: g, output: c = process.stdout, maxItems: h = Number.POSITIVE_INFINITY, columnPadding: O = 0, rowPadding: r = 4 }) => {
|
|
766
|
+
const i = getColumns(c) - O, I = getRows(c), C = styleText("dim", "..."), x = Math.max(I - r, 0), m = Math.max(Math.min(h, x), 5);
|
|
803
767
|
let p = 0;
|
|
804
|
-
|
|
805
|
-
let
|
|
806
|
-
const
|
|
807
|
-
let
|
|
808
|
-
|
|
809
|
-
const v = p + (
|
|
810
|
-
for (let
|
|
811
|
-
const
|
|
812
|
-
hard:
|
|
813
|
-
trim:
|
|
768
|
+
l >= m - 3 && (p = Math.max(Math.min(l - m + 3, o.length - m), 0));
|
|
769
|
+
let f = m < o.length && p > 0, u = m < o.length && p + m < o.length;
|
|
770
|
+
const W = Math.min(p + m, o.length), e = [];
|
|
771
|
+
let d = 0;
|
|
772
|
+
f && d++, u && d++;
|
|
773
|
+
const v = p + (f ? 1 : 0), P = W - (u ? 1 : 0);
|
|
774
|
+
for (let t = v; t < P; t++) {
|
|
775
|
+
const n = wrapAnsi(g(o[t], t === l), i, {
|
|
776
|
+
hard: true,
|
|
777
|
+
trim: false
|
|
814
778
|
}).split(`
|
|
815
779
|
`);
|
|
816
|
-
|
|
817
|
-
}
|
|
818
|
-
if (
|
|
819
|
-
let
|
|
820
|
-
const M =
|
|
821
|
-
|
|
822
|
-
|
|
823
|
-
|
|
824
|
-
|
|
825
|
-
|
|
826
|
-
|
|
780
|
+
e.push(n), d += n.length;
|
|
781
|
+
}
|
|
782
|
+
if (d > x) {
|
|
783
|
+
let t = 0, n = 0, s = d;
|
|
784
|
+
const M = l - v;
|
|
785
|
+
let a = x;
|
|
786
|
+
const T = () => E$1(e, s, 0, M, a), L = () => E$1(e, s, M + 1, e.length, a, true);
|
|
787
|
+
f ? ({lineCount: s, removals: t} = T(), s > a && (u || (a -= 1), {lineCount: s, removals: n} = L())) : (u || (a -= 1), {lineCount: s, removals: n} = L(), s > a && (a -= 1, {lineCount: s, removals: t} = T())), t > 0 && (f = true, e.splice(0, t)), n > 0 && (u = true, e.splice(e.length - n, n));
|
|
788
|
+
}
|
|
789
|
+
const b = [];
|
|
790
|
+
f && b.push(C);
|
|
791
|
+
for (const t of e) for (const n of t) b.push(n);
|
|
792
|
+
return u && b.push(C), b;
|
|
827
793
|
};
|
|
828
|
-
const
|
|
829
|
-
const
|
|
830
|
-
return new
|
|
831
|
-
active:
|
|
794
|
+
const confirm = (i) => {
|
|
795
|
+
const a = i.active ?? "Yes", s = i.inactive ?? "No";
|
|
796
|
+
return new r({
|
|
797
|
+
active: a,
|
|
832
798
|
inactive: s,
|
|
833
|
-
signal:
|
|
834
|
-
input:
|
|
835
|
-
output:
|
|
836
|
-
initialValue:
|
|
799
|
+
signal: i.signal,
|
|
800
|
+
input: i.input,
|
|
801
|
+
output: i.output,
|
|
802
|
+
initialValue: i.initialValue ?? true,
|
|
837
803
|
render() {
|
|
838
|
-
const
|
|
839
|
-
` : ""}${
|
|
840
|
-
`,
|
|
804
|
+
const e = i.withGuide ?? settings.withGuide, u = `${symbol(this.state)} `, l = e ? `${styleText("gray", S_BAR)} ` : "", f = wrapTextWithPrefix(i.output, i.message, l, u), o = `${e ? `${styleText("gray", S_BAR)}
|
|
805
|
+
` : ""}${f}
|
|
806
|
+
`, c = this.value ? a : s;
|
|
841
807
|
switch (this.state) {
|
|
842
|
-
case "submit": return `${
|
|
843
|
-
case "cancel": return `${
|
|
844
|
-
${styleText("gray",
|
|
808
|
+
case "submit": return `${o}${e ? `${styleText("gray", S_BAR)} ` : ""}${styleText("dim", c)}`;
|
|
809
|
+
case "cancel": return `${o}${e ? `${styleText("gray", S_BAR)} ` : ""}${styleText(["strikethrough", "dim"], c)}${e ? `
|
|
810
|
+
${styleText("gray", S_BAR)}` : ""}`;
|
|
845
811
|
default: {
|
|
846
|
-
const
|
|
847
|
-
return `${
|
|
848
|
-
${styleText("cyan",
|
|
849
|
-
` : ` ${styleText("dim", "/")} `}${this.value ? `${styleText("dim",
|
|
850
|
-
${
|
|
812
|
+
const r = e ? `${styleText("cyan", S_BAR)} ` : "", g = e ? styleText("cyan", S_BAR_END) : "";
|
|
813
|
+
return `${o}${r}${this.value ? `${styleText("green", S_RADIO_ACTIVE)} ${a}` : `${styleText("dim", S_RADIO_INACTIVE)} ${styleText("dim", a)}`}${i.vertical ? e ? `
|
|
814
|
+
${styleText("cyan", S_BAR)} ` : `
|
|
815
|
+
` : ` ${styleText("dim", "/")} `}${this.value ? `${styleText("dim", S_RADIO_INACTIVE)} ${styleText("dim", s)}` : `${styleText("green", S_RADIO_ACTIVE)} ${s}`}
|
|
816
|
+
${g}
|
|
851
817
|
`;
|
|
852
818
|
}
|
|
853
819
|
}
|
|
854
820
|
}
|
|
855
821
|
}).prompt();
|
|
856
|
-
}
|
|
857
|
-
|
|
858
|
-
|
|
859
|
-
|
|
860
|
-
const y = Array.isArray(e) ? e : e.split(`
|
|
861
|
-
`);
|
|
862
|
-
if (y.length > 0) {
|
|
863
|
-
const [p, ...m] = y;
|
|
864
|
-
p.length > 0 ? o.push(`${l}${p}`) : o.push(c ? i : "");
|
|
865
|
-
for (const g of m) g.length > 0 ? o.push(`${$}${g}`) : o.push(c ? s : "");
|
|
866
|
-
}
|
|
867
|
-
r.write(`${o.join(`
|
|
868
|
-
`)}
|
|
869
|
-
`);
|
|
870
|
-
},
|
|
871
|
-
info: (e, i) => {
|
|
872
|
-
O.message(e, {
|
|
873
|
-
...i,
|
|
874
|
-
symbol: styleText("blue", he)
|
|
875
|
-
});
|
|
876
|
-
},
|
|
877
|
-
success: (e, i) => {
|
|
878
|
-
O.message(e, {
|
|
879
|
-
...i,
|
|
880
|
-
symbol: styleText("green", pe)
|
|
881
|
-
});
|
|
882
|
-
},
|
|
883
|
-
step: (e, i) => {
|
|
884
|
-
O.message(e, {
|
|
885
|
-
...i,
|
|
886
|
-
symbol: styleText("green", F)
|
|
887
|
-
});
|
|
888
|
-
},
|
|
889
|
-
warn: (e, i) => {
|
|
890
|
-
O.message(e, {
|
|
891
|
-
...i,
|
|
892
|
-
symbol: styleText("yellow", me)
|
|
893
|
-
});
|
|
894
|
-
},
|
|
895
|
-
warning: (e, i) => {
|
|
896
|
-
O.warn(e, i);
|
|
897
|
-
},
|
|
898
|
-
error: (e, i) => {
|
|
899
|
-
O.message(e, {
|
|
900
|
-
...i,
|
|
901
|
-
symbol: styleText("red", ge)
|
|
902
|
-
});
|
|
903
|
-
}
|
|
904
|
-
}, pt = (e = "", i) => {
|
|
905
|
-
const s = i?.output ?? process.stdout, r = i?.withGuide ?? u.withGuide ? `${styleText("gray", E)} ` : "";
|
|
906
|
-
s.write(`${r}${styleText("red", e)}
|
|
822
|
+
};
|
|
823
|
+
const cancel = (o = "", t) => {
|
|
824
|
+
const i = t?.output ?? process.stdout, e = t?.withGuide ?? settings.withGuide ? `${styleText("gray", S_BAR_END)} ` : "";
|
|
825
|
+
i.write(`${e}${styleText("red", o)}
|
|
907
826
|
|
|
908
827
|
`);
|
|
909
|
-
},
|
|
910
|
-
const
|
|
911
|
-
|
|
828
|
+
}, intro = (o = "", t) => {
|
|
829
|
+
const i = t?.output ?? process.stdout, e = t?.withGuide ?? settings.withGuide ? `${styleText("gray", S_BAR_START)} ` : "";
|
|
830
|
+
i.write(`${e}${o}
|
|
912
831
|
`);
|
|
913
|
-
},
|
|
914
|
-
const
|
|
915
|
-
${styleText("gray",
|
|
916
|
-
|
|
832
|
+
}, outro = (o = "", t) => {
|
|
833
|
+
const i = t?.output ?? process.stdout, e = t?.withGuide ?? settings.withGuide ? `${styleText("gray", S_BAR)}
|
|
834
|
+
${styleText("gray", S_BAR_END)} ` : "";
|
|
835
|
+
i.write(`${e}${o}
|
|
917
836
|
|
|
918
837
|
`);
|
|
919
|
-
}
|
|
920
|
-
|
|
921
|
-
`)
|
|
922
|
-
|
|
923
|
-
|
|
924
|
-
|
|
925
|
-
|
|
926
|
-
|
|
927
|
-
|
|
928
|
-
|
|
929
|
-
|
|
930
|
-
|
|
931
|
-
|
|
932
|
-
|
|
933
|
-
|
|
934
|
-
|
|
935
|
-
|
|
838
|
+
};
|
|
839
|
+
const d = (n, a) => n.split(`
|
|
840
|
+
`).map((m) => a(m)).join(`
|
|
841
|
+
`);
|
|
842
|
+
const multiselect = (n) => {
|
|
843
|
+
const a = (t, o) => {
|
|
844
|
+
const r = t.label ?? String(t.value);
|
|
845
|
+
return o === "disabled" ? `${styleText("gray", S_CHECKBOX_INACTIVE)} ${d(r, (l) => styleText(["strikethrough", "gray"], l))}${t.hint ? ` ${styleText("dim", `(${t.hint ?? "disabled"})`)}` : ""}` : o === "active" ? `${styleText("cyan", S_CHECKBOX_ACTIVE)} ${r}${t.hint ? ` ${styleText("dim", `(${t.hint})`)}` : ""}` : o === "selected" ? `${styleText("green", S_CHECKBOX_SELECTED)} ${d(r, (l) => styleText("dim", l))}${t.hint ? ` ${styleText("dim", `(${t.hint})`)}` : ""}` : o === "cancelled" ? `${d(r, (l) => styleText(["strikethrough", "dim"], l))}` : o === "active-selected" ? `${styleText("green", S_CHECKBOX_SELECTED)} ${r}${t.hint ? ` ${styleText("dim", `(${t.hint})`)}` : ""}` : o === "submitted" ? `${d(r, (l) => styleText("dim", l))}` : `${styleText("dim", S_CHECKBOX_INACTIVE)} ${d(r, (l) => styleText("dim", l))}`;
|
|
846
|
+
}, m = n.required ?? true;
|
|
847
|
+
return new a$1({
|
|
848
|
+
options: n.options,
|
|
849
|
+
signal: n.signal,
|
|
850
|
+
input: n.input,
|
|
851
|
+
output: n.output,
|
|
852
|
+
initialValues: n.initialValues,
|
|
853
|
+
required: m,
|
|
854
|
+
cursorAt: n.cursorAt,
|
|
855
|
+
validate(t) {
|
|
856
|
+
if (m && (t === void 0 || t.length === 0)) return `Please select at least one option.
|
|
936
857
|
${styleText("reset", styleText("dim", `Press ${styleText([
|
|
937
858
|
"gray",
|
|
938
859
|
"bgWhite",
|
|
@@ -940,178 +861,157 @@ ${styleText("reset", styleText("dim", `Press ${styleText([
|
|
|
940
861
|
], " space ")} to select, ${styleText("gray", styleText("bgWhite", styleText("inverse", " enter ")))} to submit`))}`;
|
|
941
862
|
},
|
|
942
863
|
render() {
|
|
943
|
-
const
|
|
944
|
-
` : ""}${
|
|
945
|
-
`,
|
|
946
|
-
if (
|
|
947
|
-
const
|
|
948
|
-
return
|
|
864
|
+
const t = n.withGuide ?? settings.withGuide, o = wrapTextWithPrefix(n.output, n.message, t ? `${symbolBar(this.state)} ` : "", `${symbol(this.state)} `), r = `${t ? `${styleText("gray", S_BAR)}
|
|
865
|
+
` : ""}${o}
|
|
866
|
+
`, l = this.value ?? [], g = (i, u) => {
|
|
867
|
+
if (i.disabled) return a(i, "disabled");
|
|
868
|
+
const s = l.includes(i.value);
|
|
869
|
+
return u && s ? a(i, "active-selected") : s ? a(i, "selected") : a(i, u ? "active" : "inactive");
|
|
949
870
|
};
|
|
950
871
|
switch (this.state) {
|
|
951
872
|
case "submit": {
|
|
952
|
-
const
|
|
953
|
-
return `${
|
|
873
|
+
const i = this.options.filter(({ value: s }) => l.includes(s)).map((s) => a(s, "submitted")).join(styleText("dim", ", ")) || styleText("dim", "none");
|
|
874
|
+
return `${r}${wrapTextWithPrefix(n.output, i, t ? `${styleText("gray", S_BAR)} ` : "")}`;
|
|
954
875
|
}
|
|
955
876
|
case "cancel": {
|
|
956
|
-
const
|
|
957
|
-
if (
|
|
958
|
-
return `${
|
|
959
|
-
${styleText("gray",
|
|
877
|
+
const i = this.options.filter(({ value: s }) => l.includes(s)).map((s) => a(s, "cancelled")).join(styleText("dim", ", "));
|
|
878
|
+
if (i.trim() === "") return `${r}${styleText("gray", S_BAR)}`;
|
|
879
|
+
return `${r}${wrapTextWithPrefix(n.output, i, t ? `${styleText("gray", S_BAR)} ` : "")}${t ? `
|
|
880
|
+
${styleText("gray", S_BAR)}` : ""}`;
|
|
960
881
|
}
|
|
961
882
|
case "error": {
|
|
962
|
-
const
|
|
963
|
-
`).map((
|
|
964
|
-
`),
|
|
965
|
-
`).length,
|
|
883
|
+
const i = t ? `${styleText("yellow", S_BAR)} ` : "", u = this.error.split(`
|
|
884
|
+
`).map((h, x) => x === 0 ? `${t ? `${styleText("yellow", S_BAR_END)} ` : ""}${styleText("yellow", h)}` : ` ${h}`).join(`
|
|
885
|
+
`), s = r.split(`
|
|
886
|
+
`).length, v = u.split(`
|
|
966
887
|
`).length + 1;
|
|
967
|
-
return `${
|
|
968
|
-
output:
|
|
888
|
+
return `${r}${i}${limitOptions({
|
|
889
|
+
output: n.output,
|
|
969
890
|
options: this.options,
|
|
970
891
|
cursor: this.cursor,
|
|
971
|
-
maxItems:
|
|
972
|
-
columnPadding:
|
|
973
|
-
rowPadding:
|
|
974
|
-
style:
|
|
892
|
+
maxItems: n.maxItems,
|
|
893
|
+
columnPadding: i.length,
|
|
894
|
+
rowPadding: s + v,
|
|
895
|
+
style: g
|
|
975
896
|
}).join(`
|
|
976
|
-
${
|
|
977
|
-
${
|
|
897
|
+
${i}`)}
|
|
898
|
+
${u}
|
|
978
899
|
`;
|
|
979
900
|
}
|
|
980
901
|
default: {
|
|
981
|
-
const
|
|
982
|
-
`).length,
|
|
983
|
-
return `${
|
|
984
|
-
output:
|
|
902
|
+
const i = t ? `${styleText("cyan", S_BAR)} ` : "", u = r.split(`
|
|
903
|
+
`).length, s = t ? 2 : 1;
|
|
904
|
+
return `${r}${i}${limitOptions({
|
|
905
|
+
output: n.output,
|
|
985
906
|
options: this.options,
|
|
986
907
|
cursor: this.cursor,
|
|
987
|
-
maxItems:
|
|
988
|
-
columnPadding:
|
|
989
|
-
rowPadding:
|
|
990
|
-
style:
|
|
908
|
+
maxItems: n.maxItems,
|
|
909
|
+
columnPadding: i.length,
|
|
910
|
+
rowPadding: u + s,
|
|
911
|
+
style: g
|
|
991
912
|
}).join(`
|
|
992
|
-
${
|
|
993
|
-
${
|
|
913
|
+
${i}`)}
|
|
914
|
+
${t ? styleText("cyan", S_BAR_END) : ""}
|
|
994
915
|
`;
|
|
995
916
|
}
|
|
996
917
|
}
|
|
997
918
|
}
|
|
998
919
|
}).prompt();
|
|
999
920
|
};
|
|
1000
|
-
|
|
1001
|
-
const re = (e, i) => e.includes(`
|
|
921
|
+
const c = (e, a) => e.includes(`
|
|
1002
922
|
`) ? e.split(`
|
|
1003
|
-
`).map((
|
|
1004
|
-
`) :
|
|
1005
|
-
|
|
1006
|
-
|
|
1007
|
-
|
|
1008
|
-
|
|
1009
|
-
case "
|
|
1010
|
-
case "
|
|
1011
|
-
case "
|
|
1012
|
-
|
|
923
|
+
`).map((t) => a(t)).join(`
|
|
924
|
+
`) : a(e);
|
|
925
|
+
const select = (e) => {
|
|
926
|
+
const a$2 = (t, d) => {
|
|
927
|
+
const s = t.label ?? String(t.value);
|
|
928
|
+
switch (d) {
|
|
929
|
+
case "disabled": return `${styleText("gray", S_RADIO_INACTIVE)} ${c(s, (n) => styleText("gray", n))}${t.hint ? ` ${styleText("dim", `(${t.hint ?? "disabled"})`)}` : ""}`;
|
|
930
|
+
case "selected": return `${c(s, (n) => styleText("dim", n))}`;
|
|
931
|
+
case "active": return `${styleText("green", S_RADIO_ACTIVE)} ${s}${t.hint ? ` ${styleText("dim", `(${t.hint})`)}` : ""}`;
|
|
932
|
+
case "cancelled": return `${c(s, (n) => styleText(["strikethrough", "dim"], n))}`;
|
|
933
|
+
default: return `${styleText("dim", S_RADIO_INACTIVE)} ${c(s, (n) => styleText("dim", n))}`;
|
|
1013
934
|
}
|
|
1014
935
|
};
|
|
1015
|
-
return new
|
|
936
|
+
return new a({
|
|
1016
937
|
options: e.options,
|
|
1017
938
|
signal: e.signal,
|
|
1018
939
|
input: e.input,
|
|
1019
940
|
output: e.output,
|
|
1020
941
|
initialValue: e.initialValue,
|
|
1021
942
|
render() {
|
|
1022
|
-
const
|
|
943
|
+
const t = e.withGuide ?? settings.withGuide, d = `${symbol(this.state)} `, s = `${symbolBar(this.state)} `, n = wrapTextWithPrefix(e.output, e.message, s, d), u = `${t ? `${styleText("gray", S_BAR)}
|
|
1023
944
|
` : ""}${n}
|
|
1024
945
|
`;
|
|
1025
946
|
switch (this.state) {
|
|
1026
947
|
case "submit": {
|
|
1027
|
-
const
|
|
1028
|
-
return `${
|
|
948
|
+
const r = t ? `${styleText("gray", S_BAR)} ` : "";
|
|
949
|
+
return `${u}${wrapTextWithPrefix(e.output, a$2(this.options[this.cursor], "selected"), r)}`;
|
|
1029
950
|
}
|
|
1030
951
|
case "cancel": {
|
|
1031
|
-
const
|
|
1032
|
-
return `${
|
|
1033
|
-
${styleText("gray",
|
|
952
|
+
const r = t ? `${styleText("gray", S_BAR)} ` : "";
|
|
953
|
+
return `${u}${wrapTextWithPrefix(e.output, a$2(this.options[this.cursor], "cancelled"), r)}${t ? `
|
|
954
|
+
${styleText("gray", S_BAR)}` : ""}`;
|
|
1034
955
|
}
|
|
1035
956
|
default: {
|
|
1036
|
-
const
|
|
1037
|
-
`).length,
|
|
1038
|
-
return `${
|
|
957
|
+
const r = t ? `${styleText("cyan", S_BAR)} ` : "", l = t ? styleText("cyan", S_BAR_END) : "", g = u.split(`
|
|
958
|
+
`).length, h = t ? 2 : 1;
|
|
959
|
+
return `${u}${r}${limitOptions({
|
|
1039
960
|
output: e.output,
|
|
1040
961
|
cursor: this.cursor,
|
|
1041
962
|
options: this.options,
|
|
1042
963
|
maxItems: e.maxItems,
|
|
1043
|
-
columnPadding:
|
|
1044
|
-
rowPadding:
|
|
1045
|
-
style: (
|
|
964
|
+
columnPadding: r.length,
|
|
965
|
+
rowPadding: g + h,
|
|
966
|
+
style: (p, b) => a$2(p, p.disabled ? "disabled" : b ? "active" : "inactive")
|
|
1046
967
|
}).join(`
|
|
1047
|
-
${
|
|
1048
|
-
${
|
|
968
|
+
${r}`)}
|
|
969
|
+
${l}
|
|
1049
970
|
`;
|
|
1050
971
|
}
|
|
1051
972
|
}
|
|
1052
973
|
}
|
|
1053
974
|
}).prompt();
|
|
1054
|
-
}
|
|
1055
|
-
|
|
1056
|
-
|
|
1057
|
-
|
|
1058
|
-
|
|
1059
|
-
|
|
1060
|
-
|
|
1061
|
-
|
|
1062
|
-
|
|
1063
|
-
|
|
1064
|
-
const u = stripVTControlCharacters(r).length;
|
|
1065
|
-
s + u < process.stdout.columns ? (s += u, process.stdout.write(r)) : (process.stdout.write(`
|
|
1066
|
-
${je}${r.trimStart()}`), s = 3 + stripVTControlCharacters(r.trimStart()).length);
|
|
1067
|
-
}
|
|
1068
|
-
process.stdout.write(`
|
|
1069
|
-
`);
|
|
1070
|
-
},
|
|
1071
|
-
info: (e) => K.message(e, { symbol: styleText("blue", he) }),
|
|
1072
|
-
success: (e) => K.message(e, { symbol: styleText("green", pe) }),
|
|
1073
|
-
step: (e) => K.message(e, { symbol: styleText("green", F) }),
|
|
1074
|
-
warn: (e) => K.message(e, { symbol: styleText("yellow", me) }),
|
|
1075
|
-
warning: (e) => K.warn(e),
|
|
1076
|
-
error: (e) => K.message(e, { symbol: styleText("red", ge) })
|
|
1077
|
-
}, Ot = (e) => new at$1({
|
|
1078
|
-
validate: e.validate,
|
|
1079
|
-
placeholder: e.placeholder,
|
|
1080
|
-
defaultValue: e.defaultValue,
|
|
1081
|
-
initialValue: e.initialValue,
|
|
1082
|
-
output: e.output,
|
|
1083
|
-
signal: e.signal,
|
|
1084
|
-
input: e.input,
|
|
975
|
+
};
|
|
976
|
+
`${styleText("gray", S_BAR)}`;
|
|
977
|
+
const text = (t) => new n({
|
|
978
|
+
validate: t.validate,
|
|
979
|
+
placeholder: t.placeholder,
|
|
980
|
+
defaultValue: t.defaultValue,
|
|
981
|
+
initialValue: t.initialValue,
|
|
982
|
+
output: t.output,
|
|
983
|
+
signal: t.signal,
|
|
984
|
+
input: t.input,
|
|
1085
985
|
render() {
|
|
1086
|
-
const i =
|
|
1087
|
-
` : ""}${
|
|
1088
|
-
`,
|
|
986
|
+
const i = t?.withGuide ?? settings.withGuide, s = `${`${i ? `${styleText("gray", S_BAR)}
|
|
987
|
+
` : ""}${symbol(this.state)} `}${t.message}
|
|
988
|
+
`, c = t.placeholder ? styleText("inverse", t.placeholder[0]) + styleText("dim", t.placeholder.slice(1)) : styleText(["inverse", "hidden"], "_"), o = this.userInput ? this.userInputWithCursor : c, a = this.value ?? "";
|
|
1089
989
|
switch (this.state) {
|
|
1090
990
|
case "error": {
|
|
1091
|
-
const
|
|
991
|
+
const n = this.error ? ` ${styleText("yellow", this.error)}` : "", r = i ? `${styleText("yellow", S_BAR)} ` : "", d = i ? styleText("yellow", S_BAR_END) : "";
|
|
1092
992
|
return `${s.trim()}
|
|
1093
|
-
${
|
|
1094
|
-
${
|
|
993
|
+
${r}${o}
|
|
994
|
+
${d}${n}
|
|
1095
995
|
`;
|
|
1096
996
|
}
|
|
1097
997
|
case "submit": {
|
|
1098
|
-
const
|
|
1099
|
-
return `${s}${i ? styleText("gray",
|
|
998
|
+
const n = a ? ` ${styleText("dim", a)}` : "";
|
|
999
|
+
return `${s}${i ? styleText("gray", S_BAR) : ""}${n}`;
|
|
1100
1000
|
}
|
|
1101
1001
|
case "cancel": {
|
|
1102
|
-
const
|
|
1103
|
-
return `${s}${
|
|
1104
|
-
${
|
|
1002
|
+
const n = a ? ` ${styleText(["strikethrough", "dim"], a)}` : "", r = i ? styleText("gray", S_BAR) : "";
|
|
1003
|
+
return `${s}${r}${n}${a.trim() ? `
|
|
1004
|
+
${r}` : ""}`;
|
|
1105
1005
|
}
|
|
1106
|
-
default: return `${s}${i ? `${styleText("cyan",
|
|
1107
|
-
${i ? styleText("cyan",
|
|
1006
|
+
default: return `${s}${i ? `${styleText("cyan", S_BAR)} ` : ""}${o}
|
|
1007
|
+
${i ? styleText("cyan", S_BAR_END) : ""}
|
|
1108
1008
|
`;
|
|
1109
1009
|
}
|
|
1110
1010
|
}
|
|
1111
1011
|
}).prompt();
|
|
1112
1012
|
//#endregion
|
|
1113
|
-
//#region node_modules/.pnpm/
|
|
1114
|
-
var
|
|
1013
|
+
//#region node_modules/.pnpm/ejs@5.0.2/node_modules/ejs/lib/esm/utils.js
|
|
1014
|
+
var import_picocolors = (/* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
1115
1015
|
let p = process || {}, argv = p.argv || [], env = p.env || {};
|
|
1116
1016
|
let isColorSupported = !(!!env.NO_COLOR || argv.includes("--no-color")) && (!!env.FORCE_COLOR || argv.includes("--color") || p.platform === "win32" || (p.stdout || {}).isTTY && env.TERM !== "dumb" || !!env.CI);
|
|
1117
1017
|
let formatter = (open, close, replace = open) => (input) => {
|
|
@@ -1176,892 +1076,828 @@ var require_picocolors = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
|
1176
1076
|
};
|
|
1177
1077
|
module.exports = createColors();
|
|
1178
1078
|
module.exports.createColors = createColors;
|
|
1179
|
-
}));
|
|
1180
|
-
//#endregion
|
|
1181
|
-
//#region node_modules/.pnpm/ejs@3.1.10/node_modules/ejs/lib/utils.js
|
|
1079
|
+
})))();
|
|
1182
1080
|
/**
|
|
1183
1081
|
* Private utility functions
|
|
1184
1082
|
* @module utils
|
|
1185
1083
|
* @private
|
|
1186
1084
|
*/
|
|
1187
|
-
|
|
1188
|
-
|
|
1189
|
-
|
|
1190
|
-
|
|
1191
|
-
|
|
1192
|
-
|
|
1193
|
-
|
|
1194
|
-
|
|
1195
|
-
|
|
1196
|
-
|
|
1197
|
-
|
|
1198
|
-
|
|
1199
|
-
|
|
1200
|
-
|
|
1201
|
-
|
|
1202
|
-
|
|
1203
|
-
|
|
1204
|
-
|
|
1205
|
-
|
|
1206
|
-
|
|
1207
|
-
|
|
1208
|
-
|
|
1209
|
-
|
|
1210
|
-
|
|
1211
|
-
|
|
1212
|
-
|
|
1213
|
-
|
|
1214
|
-
|
|
1215
|
-
|
|
1216
|
-
|
|
1217
|
-
|
|
1218
|
-
|
|
1219
|
-
|
|
1220
|
-
|
|
1221
|
-
|
|
1222
|
-
|
|
1223
|
-
|
|
1224
|
-
|
|
1225
|
-
|
|
1226
|
-
|
|
1227
|
-
|
|
1228
|
-
|
|
1229
|
-
|
|
1230
|
-
|
|
1231
|
-
|
|
1232
|
-
|
|
1233
|
-
|
|
1234
|
-
|
|
1235
|
-
|
|
1236
|
-
|
|
1237
|
-
|
|
1238
|
-
|
|
1239
|
-
|
|
1240
|
-
|
|
1241
|
-
|
|
1242
|
-
|
|
1243
|
-
|
|
1244
|
-
|
|
1245
|
-
|
|
1246
|
-
|
|
1247
|
-
|
|
1248
|
-
|
|
1249
|
-
|
|
1085
|
+
const utils = {};
|
|
1086
|
+
var regExpChars = /[|\\{}()[\]^$+*?.]/g;
|
|
1087
|
+
var hasOwnProperty = Object.prototype.hasOwnProperty;
|
|
1088
|
+
var hasOwn = function(obj, key) {
|
|
1089
|
+
return hasOwnProperty.apply(obj, [key]);
|
|
1090
|
+
};
|
|
1091
|
+
utils.hasOwn = hasOwn;
|
|
1092
|
+
/**
|
|
1093
|
+
* Escape characters reserved in regular expressions.
|
|
1094
|
+
*
|
|
1095
|
+
* If `string` is `undefined` or `null`, the empty string is returned.
|
|
1096
|
+
*
|
|
1097
|
+
* @param {String} string Input string
|
|
1098
|
+
* @return {String} Escaped string
|
|
1099
|
+
* @static
|
|
1100
|
+
* @private
|
|
1101
|
+
*/
|
|
1102
|
+
utils.escapeRegExpChars = function(string) {
|
|
1103
|
+
// istanbul ignore if
|
|
1104
|
+
if (!string) return "";
|
|
1105
|
+
return String(string).replace(regExpChars, "\\$&");
|
|
1106
|
+
};
|
|
1107
|
+
var _ENCODE_HTML_RULES = {
|
|
1108
|
+
"&": "&",
|
|
1109
|
+
"<": "<",
|
|
1110
|
+
">": ">",
|
|
1111
|
+
"\"": """,
|
|
1112
|
+
"'": "'"
|
|
1113
|
+
};
|
|
1114
|
+
var _MATCH_HTML = /[&<>'"]/g;
|
|
1115
|
+
function encode_char(c) {
|
|
1116
|
+
return _ENCODE_HTML_RULES[c] || c;
|
|
1117
|
+
}
|
|
1118
|
+
/**
|
|
1119
|
+
* Stringified version of constants used by {@link module:utils.escapeXML}.
|
|
1120
|
+
*
|
|
1121
|
+
* @readonly
|
|
1122
|
+
* @type {String}
|
|
1123
|
+
*/
|
|
1124
|
+
var escapeFuncStr = "var _ENCODE_HTML_RULES = {\n \"&\": \"&\"\n , \"<\": \"<\"\n , \">\": \">\"\n , '\"': \""\"\n , \"'\": \"'\"\n }\n , _MATCH_HTML = /[&<>'\"]/g;\nfunction encode_char(c) {\n return _ENCODE_HTML_RULES[c] || c;\n};\n";
|
|
1125
|
+
/**
|
|
1126
|
+
* Escape characters reserved in XML.
|
|
1127
|
+
*
|
|
1128
|
+
* If `markup` is `undefined` or `null`, the empty string is returned.
|
|
1129
|
+
*
|
|
1130
|
+
* @implements {EscapeCallback}
|
|
1131
|
+
* @param {String} markup Input string
|
|
1132
|
+
* @return {String} Escaped string
|
|
1133
|
+
* @static
|
|
1134
|
+
* @private
|
|
1135
|
+
*/
|
|
1136
|
+
utils.escapeXML = function(markup) {
|
|
1137
|
+
return markup == void 0 ? "" : String(markup).replace(_MATCH_HTML, encode_char);
|
|
1138
|
+
};
|
|
1139
|
+
function escapeXMLToString() {
|
|
1140
|
+
return Function.prototype.toString.call(this) + ";\n" + escapeFuncStr;
|
|
1141
|
+
}
|
|
1142
|
+
try {
|
|
1143
|
+
if (typeof Object.defineProperty === "function") Object.defineProperty(utils.escapeXML, "toString", { value: escapeXMLToString });
|
|
1144
|
+
else utils.escapeXML.toString = escapeXMLToString;
|
|
1145
|
+
} catch (err) {
|
|
1146
|
+
console.warn("Unable to set escapeXML.toString (is the Function prototype frozen?)");
|
|
1147
|
+
}
|
|
1148
|
+
/**
|
|
1149
|
+
* Naive copy of properties from one object to another.
|
|
1150
|
+
* Does not recurse into non-scalar properties
|
|
1151
|
+
* Does not check to see if the property has a value before copying
|
|
1152
|
+
*
|
|
1153
|
+
* @param {Object} to Destination object
|
|
1154
|
+
* @param {Object} from Source object
|
|
1155
|
+
* @return {Object} Destination object
|
|
1156
|
+
* @static
|
|
1157
|
+
* @private
|
|
1158
|
+
*/
|
|
1159
|
+
utils.shallowCopy = function(to, from) {
|
|
1160
|
+
from = from || {};
|
|
1161
|
+
if (to !== null && to !== void 0) for (var p in from) {
|
|
1162
|
+
if (!hasOwn(from, p)) continue;
|
|
1163
|
+
if (p === "__proto__" || p === "constructor") continue;
|
|
1164
|
+
to[p] = from[p];
|
|
1250
1165
|
}
|
|
1251
|
-
|
|
1252
|
-
|
|
1253
|
-
|
|
1254
|
-
|
|
1255
|
-
|
|
1256
|
-
|
|
1257
|
-
|
|
1258
|
-
|
|
1259
|
-
|
|
1260
|
-
|
|
1261
|
-
|
|
1262
|
-
|
|
1263
|
-
|
|
1264
|
-
|
|
1166
|
+
return to;
|
|
1167
|
+
};
|
|
1168
|
+
/**
|
|
1169
|
+
* Naive copy of a list of key names, from one object to another.
|
|
1170
|
+
* Only copies property if it is actually defined
|
|
1171
|
+
* Does not recurse into non-scalar properties
|
|
1172
|
+
*
|
|
1173
|
+
* @param {Object} to Destination object
|
|
1174
|
+
* @param {Object} from Source object
|
|
1175
|
+
* @param {Array} list List of properties to copy
|
|
1176
|
+
* @return {Object} Destination object
|
|
1177
|
+
* @static
|
|
1178
|
+
* @private
|
|
1179
|
+
*/
|
|
1180
|
+
utils.shallowCopyFromList = function(to, from, list) {
|
|
1181
|
+
list = list || [];
|
|
1182
|
+
from = from || {};
|
|
1183
|
+
if (to !== null && to !== void 0) for (var i = 0; i < list.length; i++) {
|
|
1184
|
+
var p = list[i];
|
|
1185
|
+
if (typeof from[p] != "undefined") {
|
|
1265
1186
|
if (!hasOwn(from, p)) continue;
|
|
1266
1187
|
if (p === "__proto__" || p === "constructor") continue;
|
|
1267
1188
|
to[p] = from[p];
|
|
1268
1189
|
}
|
|
1269
|
-
|
|
1270
|
-
|
|
1271
|
-
|
|
1272
|
-
|
|
1273
|
-
|
|
1274
|
-
|
|
1275
|
-
|
|
1276
|
-
|
|
1277
|
-
|
|
1278
|
-
|
|
1279
|
-
|
|
1280
|
-
|
|
1281
|
-
|
|
1282
|
-
|
|
1283
|
-
|
|
1284
|
-
|
|
1285
|
-
|
|
1286
|
-
|
|
1287
|
-
|
|
1288
|
-
|
|
1289
|
-
|
|
1290
|
-
|
|
1291
|
-
|
|
1292
|
-
|
|
1293
|
-
|
|
1294
|
-
|
|
1295
|
-
|
|
1296
|
-
|
|
1297
|
-
|
|
1298
|
-
|
|
1299
|
-
|
|
1300
|
-
|
|
1301
|
-
|
|
1302
|
-
|
|
1303
|
-
|
|
1304
|
-
|
|
1305
|
-
|
|
1306
|
-
|
|
1307
|
-
|
|
1308
|
-
|
|
1309
|
-
|
|
1310
|
-
|
|
1311
|
-
|
|
1312
|
-
|
|
1313
|
-
|
|
1314
|
-
|
|
1315
|
-
|
|
1316
|
-
|
|
1317
|
-
|
|
1318
|
-
};
|
|
1319
|
-
/**
|
|
1320
|
-
* Transforms hyphen case variable into camel case.
|
|
1321
|
-
*
|
|
1322
|
-
* @param {String} string Hyphen case string
|
|
1323
|
-
* @return {String} Camel case string
|
|
1324
|
-
* @static
|
|
1325
|
-
* @private
|
|
1326
|
-
*/
|
|
1327
|
-
exports.hyphenToCamel = function(str) {
|
|
1328
|
-
return str.replace(/-[a-z]/g, function(match) {
|
|
1329
|
-
return match[1].toUpperCase();
|
|
1330
|
-
});
|
|
1190
|
+
}
|
|
1191
|
+
return to;
|
|
1192
|
+
};
|
|
1193
|
+
/**
|
|
1194
|
+
* Simple in-process cache implementation. Does not implement limits of any
|
|
1195
|
+
* sort.
|
|
1196
|
+
*
|
|
1197
|
+
* @implements {Cache}
|
|
1198
|
+
* @static
|
|
1199
|
+
* @private
|
|
1200
|
+
*/
|
|
1201
|
+
utils.cache = {
|
|
1202
|
+
_data: {},
|
|
1203
|
+
set: function(key, val) {
|
|
1204
|
+
this._data[key] = val;
|
|
1205
|
+
},
|
|
1206
|
+
get: function(key) {
|
|
1207
|
+
return this._data[key];
|
|
1208
|
+
},
|
|
1209
|
+
remove: function(key) {
|
|
1210
|
+
delete this._data[key];
|
|
1211
|
+
},
|
|
1212
|
+
reset: function() {
|
|
1213
|
+
this._data = {};
|
|
1214
|
+
}
|
|
1215
|
+
};
|
|
1216
|
+
/**
|
|
1217
|
+
* Transforms hyphen case variable into camel case.
|
|
1218
|
+
*
|
|
1219
|
+
* @param {String} string Hyphen case string
|
|
1220
|
+
* @return {String} Camel case string
|
|
1221
|
+
* @static
|
|
1222
|
+
* @private
|
|
1223
|
+
*/
|
|
1224
|
+
utils.hyphenToCamel = function(str) {
|
|
1225
|
+
return str.replace(/-[a-z]/g, function(match) {
|
|
1226
|
+
return match[1].toUpperCase();
|
|
1227
|
+
});
|
|
1228
|
+
};
|
|
1229
|
+
/**
|
|
1230
|
+
* Returns a null-prototype object in runtimes that support it
|
|
1231
|
+
*
|
|
1232
|
+
* @return {Object} Object, prototype will be set to null where possible
|
|
1233
|
+
* @static
|
|
1234
|
+
* @private
|
|
1235
|
+
*/
|
|
1236
|
+
utils.createNullProtoObjWherePossible = (function() {
|
|
1237
|
+
if (typeof Object.create == "function") return function() {
|
|
1238
|
+
return Object.create(null);
|
|
1331
1239
|
};
|
|
1332
|
-
|
|
1333
|
-
|
|
1334
|
-
*
|
|
1335
|
-
* @return {Object} Object, prototype will be set to null where possible
|
|
1336
|
-
* @static
|
|
1337
|
-
* @private
|
|
1338
|
-
*/
|
|
1339
|
-
exports.createNullProtoObjWherePossible = (function() {
|
|
1340
|
-
if (typeof Object.create == "function") return function() {
|
|
1341
|
-
return Object.create(null);
|
|
1342
|
-
};
|
|
1343
|
-
if (!({ __proto__: null } instanceof Object)) return function() {
|
|
1344
|
-
return { __proto__: null };
|
|
1345
|
-
};
|
|
1346
|
-
return function() {
|
|
1347
|
-
return {};
|
|
1348
|
-
};
|
|
1349
|
-
})();
|
|
1350
|
-
exports.hasOwnOnlyObject = function(obj) {
|
|
1351
|
-
var o = exports.createNullProtoObjWherePossible();
|
|
1352
|
-
for (var p in obj) if (hasOwn(obj, p)) o[p] = obj[p];
|
|
1353
|
-
return o;
|
|
1240
|
+
if (!({ __proto__: null } instanceof Object)) return function() {
|
|
1241
|
+
return { __proto__: null };
|
|
1354
1242
|
};
|
|
1355
|
-
|
|
1356
|
-
|
|
1357
|
-
//#region node_modules/.pnpm/ejs@3.1.10/node_modules/ejs/package.json
|
|
1358
|
-
var require_package = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
1359
|
-
module.exports = {
|
|
1360
|
-
"name": "ejs",
|
|
1361
|
-
"description": "Embedded JavaScript templates",
|
|
1362
|
-
"keywords": [
|
|
1363
|
-
"template",
|
|
1364
|
-
"engine",
|
|
1365
|
-
"ejs"
|
|
1366
|
-
],
|
|
1367
|
-
"version": "3.1.10",
|
|
1368
|
-
"author": "Matthew Eernisse <mde@fleegix.org> (http://fleegix.org)",
|
|
1369
|
-
"license": "Apache-2.0",
|
|
1370
|
-
"bin": { "ejs": "./bin/cli.js" },
|
|
1371
|
-
"main": "./lib/ejs.js",
|
|
1372
|
-
"jsdelivr": "ejs.min.js",
|
|
1373
|
-
"unpkg": "ejs.min.js",
|
|
1374
|
-
"repository": {
|
|
1375
|
-
"type": "git",
|
|
1376
|
-
"url": "git://github.com/mde/ejs.git"
|
|
1377
|
-
},
|
|
1378
|
-
"bugs": "https://github.com/mde/ejs/issues",
|
|
1379
|
-
"homepage": "https://github.com/mde/ejs",
|
|
1380
|
-
"dependencies": { "jake": "^10.8.5" },
|
|
1381
|
-
"devDependencies": {
|
|
1382
|
-
"browserify": "^16.5.1",
|
|
1383
|
-
"eslint": "^6.8.0",
|
|
1384
|
-
"git-directory-deploy": "^1.5.1",
|
|
1385
|
-
"jsdoc": "^4.0.2",
|
|
1386
|
-
"lru-cache": "^4.0.1",
|
|
1387
|
-
"mocha": "^10.2.0",
|
|
1388
|
-
"uglify-js": "^3.3.16"
|
|
1389
|
-
},
|
|
1390
|
-
"engines": { "node": ">=0.10.0" },
|
|
1391
|
-
"scripts": { "test": "npx jake test" }
|
|
1243
|
+
return function() {
|
|
1244
|
+
return {};
|
|
1392
1245
|
};
|
|
1393
|
-
}));
|
|
1246
|
+
})();
|
|
1247
|
+
/**
|
|
1248
|
+
* Copies own-properties from one object to a null-prototype object for basic
|
|
1249
|
+
* protection against prototype pollution
|
|
1250
|
+
*
|
|
1251
|
+
* @return {Object} Object with own-properties of input object
|
|
1252
|
+
* @static
|
|
1253
|
+
* @private
|
|
1254
|
+
*/
|
|
1255
|
+
utils.hasOwnOnlyObject = function(obj) {
|
|
1256
|
+
var o = utils.createNullProtoObjWherePossible();
|
|
1257
|
+
for (var p in obj) if (hasOwn(obj, p)) o[p] = obj[p];
|
|
1258
|
+
return o;
|
|
1259
|
+
};
|
|
1260
|
+
if (typeof exports != "undefined") module.exports = utils;
|
|
1394
1261
|
//#endregion
|
|
1395
|
-
//#region node_modules/.pnpm/ejs@
|
|
1396
|
-
|
|
1397
|
-
|
|
1398
|
-
|
|
1399
|
-
|
|
1400
|
-
|
|
1401
|
-
|
|
1402
|
-
|
|
1403
|
-
|
|
1404
|
-
|
|
1405
|
-
|
|
1406
|
-
|
|
1407
|
-
|
|
1408
|
-
|
|
1409
|
-
|
|
1410
|
-
|
|
1411
|
-
|
|
1412
|
-
|
|
1413
|
-
|
|
1414
|
-
|
|
1415
|
-
|
|
1416
|
-
|
|
1417
|
-
|
|
1418
|
-
|
|
1419
|
-
|
|
1420
|
-
|
|
1421
|
-
|
|
1422
|
-
|
|
1423
|
-
|
|
1424
|
-
|
|
1425
|
-
|
|
1426
|
-
|
|
1427
|
-
|
|
1428
|
-
|
|
1429
|
-
|
|
1430
|
-
|
|
1431
|
-
|
|
1432
|
-
|
|
1433
|
-
|
|
1434
|
-
|
|
1435
|
-
|
|
1436
|
-
|
|
1437
|
-
|
|
1438
|
-
|
|
1439
|
-
|
|
1440
|
-
|
|
1441
|
-
|
|
1442
|
-
|
|
1443
|
-
|
|
1444
|
-
|
|
1445
|
-
|
|
1446
|
-
|
|
1447
|
-
|
|
1448
|
-
|
|
1449
|
-
|
|
1450
|
-
|
|
1451
|
-
|
|
1452
|
-
|
|
1453
|
-
|
|
1454
|
-
|
|
1455
|
-
|
|
1456
|
-
|
|
1457
|
-
|
|
1458
|
-
|
|
1459
|
-
|
|
1460
|
-
|
|
1461
|
-
|
|
1462
|
-
|
|
1463
|
-
|
|
1464
|
-
|
|
1465
|
-
|
|
1466
|
-
|
|
1467
|
-
|
|
1468
|
-
|
|
1469
|
-
|
|
1470
|
-
|
|
1471
|
-
|
|
1472
|
-
|
|
1473
|
-
|
|
1474
|
-
|
|
1475
|
-
|
|
1476
|
-
|
|
1477
|
-
|
|
1478
|
-
|
|
1479
|
-
|
|
1480
|
-
|
|
1481
|
-
|
|
1482
|
-
|
|
1483
|
-
|
|
1484
|
-
|
|
1485
|
-
|
|
1486
|
-
|
|
1487
|
-
|
|
1488
|
-
|
|
1489
|
-
|
|
1490
|
-
|
|
1491
|
-
|
|
1492
|
-
|
|
1493
|
-
|
|
1494
|
-
|
|
1495
|
-
|
|
1496
|
-
|
|
1497
|
-
|
|
1498
|
-
|
|
1499
|
-
|
|
1500
|
-
|
|
1501
|
-
|
|
1502
|
-
|
|
1503
|
-
|
|
1504
|
-
|
|
1505
|
-
|
|
1506
|
-
|
|
1507
|
-
|
|
1508
|
-
|
|
1509
|
-
|
|
1510
|
-
|
|
1511
|
-
|
|
1512
|
-
|
|
1513
|
-
|
|
1514
|
-
|
|
1515
|
-
|
|
1516
|
-
|
|
1517
|
-
|
|
1518
|
-
|
|
1519
|
-
|
|
1520
|
-
|
|
1521
|
-
|
|
1522
|
-
|
|
1523
|
-
|
|
1524
|
-
|
|
1525
|
-
path = path.replace(/^\/*/, "");
|
|
1526
|
-
if (Array.isArray(options.root)) includePath = resolvePaths(path, options.root);
|
|
1527
|
-
else includePath = exports.resolveInclude(path, options.root || "/", true);
|
|
1528
|
-
} else {
|
|
1529
|
-
if (options.filename) {
|
|
1530
|
-
filePath = exports.resolveInclude(path, options.filename);
|
|
1531
|
-
if (fs$1.existsSync(filePath)) includePath = filePath;
|
|
1532
|
-
}
|
|
1533
|
-
if (!includePath && Array.isArray(views)) includePath = resolvePaths(path, views);
|
|
1534
|
-
if (!includePath && typeof options.includer !== "function") throw new Error("Could not find the include file \"" + options.escapeFunction(path) + "\"");
|
|
1262
|
+
//#region node_modules/.pnpm/ejs@5.0.2/node_modules/ejs/lib/esm/ejs.js
|
|
1263
|
+
/**
|
|
1264
|
+
* @file Embedded JavaScript templating engine. {@link http://ejs.co}
|
|
1265
|
+
* @author Matthew Eernisse <mde@fleegix.org>
|
|
1266
|
+
* @project EJS
|
|
1267
|
+
* @license {@link http://www.apache.org/licenses/LICENSE-2.0 Apache License, Version 2.0}
|
|
1268
|
+
*/
|
|
1269
|
+
/**
|
|
1270
|
+
* EJS internal functions.
|
|
1271
|
+
*
|
|
1272
|
+
* Technically this "module" lies in the same file as {@link module:ejs}, for
|
|
1273
|
+
* the sake of organization all the private functions re grouped into this
|
|
1274
|
+
* module.
|
|
1275
|
+
*
|
|
1276
|
+
* @module ejs-internal
|
|
1277
|
+
* @private
|
|
1278
|
+
*/
|
|
1279
|
+
/**
|
|
1280
|
+
* Embedded JavaScript templating engine.
|
|
1281
|
+
*
|
|
1282
|
+
* @module ejs
|
|
1283
|
+
* @public
|
|
1284
|
+
*/
|
|
1285
|
+
const DECLARATION_KEYWORD = "let";
|
|
1286
|
+
const ejs = {};
|
|
1287
|
+
/** @type {string} */
|
|
1288
|
+
let _DEFAULT_OPEN_DELIMITER = "<";
|
|
1289
|
+
let _DEFAULT_CLOSE_DELIMITER = ">";
|
|
1290
|
+
let _DEFAULT_DELIMITER = "%";
|
|
1291
|
+
let _DEFAULT_LOCALS_NAME = "locals";
|
|
1292
|
+
let _REGEX_STRING = "(<%%|%%>|<%=|<%-|<%_|<%#|<%|%>|-%>|_%>)";
|
|
1293
|
+
let _OPTS_PASSABLE_WITH_DATA = [
|
|
1294
|
+
"delimiter",
|
|
1295
|
+
"scope",
|
|
1296
|
+
"context",
|
|
1297
|
+
"debug",
|
|
1298
|
+
"compileDebug",
|
|
1299
|
+
"_with",
|
|
1300
|
+
"rmWhitespace",
|
|
1301
|
+
"strict",
|
|
1302
|
+
"filename",
|
|
1303
|
+
"async"
|
|
1304
|
+
];
|
|
1305
|
+
let _OPTS_PASSABLE_WITH_DATA_EXPRESS = _OPTS_PASSABLE_WITH_DATA.concat("cache");
|
|
1306
|
+
let _BOM = /^\uFEFF/;
|
|
1307
|
+
let _JS_IDENTIFIER = /^[a-zA-Z_$][0-9a-zA-Z_$]*$/;
|
|
1308
|
+
/**
|
|
1309
|
+
* EJS template function cache. This can be a LRU object from lru-cache NPM
|
|
1310
|
+
* module. By default, it is {@link module:utils.cache}, a simple in-process
|
|
1311
|
+
* cache that grows continuously.
|
|
1312
|
+
*
|
|
1313
|
+
* @type {Cache}
|
|
1314
|
+
*/
|
|
1315
|
+
ejs.cache = utils.cache;
|
|
1316
|
+
/**
|
|
1317
|
+
* Custom file loader. Useful for template preprocessing or restricting access
|
|
1318
|
+
* to a certain part of the filesystem.
|
|
1319
|
+
*
|
|
1320
|
+
* @type {fileLoader}
|
|
1321
|
+
*/
|
|
1322
|
+
ejs.fileLoader = fs.readFileSync;
|
|
1323
|
+
/**
|
|
1324
|
+
* Name of the object containing the locals.
|
|
1325
|
+
*
|
|
1326
|
+
* This variable is overridden by {@link Options}`.localsName` if it is not
|
|
1327
|
+
* `undefined`.
|
|
1328
|
+
*
|
|
1329
|
+
* @type {String}
|
|
1330
|
+
* @public
|
|
1331
|
+
*/
|
|
1332
|
+
ejs.localsName = _DEFAULT_LOCALS_NAME;
|
|
1333
|
+
/**
|
|
1334
|
+
* Promise implementation -- defaults to the native implementation if available
|
|
1335
|
+
* This is mostly just for testability
|
|
1336
|
+
*
|
|
1337
|
+
* @type {PromiseConstructorLike}
|
|
1338
|
+
* @public
|
|
1339
|
+
*/
|
|
1340
|
+
ejs.promiseImpl = new Function("return this;")().Promise;
|
|
1341
|
+
/**
|
|
1342
|
+
* Get the path to the included file from the parent file path and the
|
|
1343
|
+
* specified path.
|
|
1344
|
+
*
|
|
1345
|
+
* @param {String} name specified path
|
|
1346
|
+
* @param {String} filename parent file path
|
|
1347
|
+
* @param {Boolean} [isDir=false] whether the parent file path is a directory
|
|
1348
|
+
* @return {String}
|
|
1349
|
+
*/
|
|
1350
|
+
ejs.resolveInclude = function(name, filename, isDir) {
|
|
1351
|
+
let dirname = path.dirname;
|
|
1352
|
+
let extname = path.extname;
|
|
1353
|
+
let resolve = path.resolve;
|
|
1354
|
+
let includePath = resolve(isDir ? filename : dirname(filename), name);
|
|
1355
|
+
if (!extname(name)) includePath += ".ejs";
|
|
1356
|
+
return includePath;
|
|
1357
|
+
};
|
|
1358
|
+
/**
|
|
1359
|
+
* Try to resolve file path on multiple directories
|
|
1360
|
+
*
|
|
1361
|
+
* @param {String} name specified path
|
|
1362
|
+
* @param {Array<String>} paths list of possible parent directory paths
|
|
1363
|
+
* @return {String}
|
|
1364
|
+
*/
|
|
1365
|
+
function resolvePaths(name, paths) {
|
|
1366
|
+
let filePath;
|
|
1367
|
+
if (paths.some(function(v) {
|
|
1368
|
+
filePath = ejs.resolveInclude(name, v, true);
|
|
1369
|
+
return fs.existsSync(filePath);
|
|
1370
|
+
})) return filePath;
|
|
1371
|
+
}
|
|
1372
|
+
/**
|
|
1373
|
+
* Get the path to the included file by Options
|
|
1374
|
+
*
|
|
1375
|
+
* @param {String} path specified path
|
|
1376
|
+
* @param {Options} options compilation options
|
|
1377
|
+
* @return {String}
|
|
1378
|
+
*/
|
|
1379
|
+
function getIncludePath(path, options) {
|
|
1380
|
+
let includePath;
|
|
1381
|
+
let filePath;
|
|
1382
|
+
let views = options.views;
|
|
1383
|
+
let match = /^[A-Za-z]+:\\|^\//.exec(path);
|
|
1384
|
+
if (match && match.length) {
|
|
1385
|
+
path = path.replace(/^\/*/, "");
|
|
1386
|
+
if (Array.isArray(options.root)) includePath = resolvePaths(path, options.root);
|
|
1387
|
+
else includePath = ejs.resolveInclude(path, options.root || "/", true);
|
|
1388
|
+
} else {
|
|
1389
|
+
if (options.filename) {
|
|
1390
|
+
filePath = ejs.resolveInclude(path, options.filename);
|
|
1391
|
+
if (fs.existsSync(filePath)) includePath = filePath;
|
|
1535
1392
|
}
|
|
1536
|
-
|
|
1393
|
+
if (!includePath && Array.isArray(views)) includePath = resolvePaths(path, views);
|
|
1394
|
+
if (!includePath && typeof options.includer !== "function") throw new Error("Could not find the include file \"" + options.escapeFunction(path) + "\"");
|
|
1537
1395
|
}
|
|
1538
|
-
|
|
1539
|
-
|
|
1540
|
-
|
|
1541
|
-
|
|
1542
|
-
|
|
1543
|
-
|
|
1544
|
-
|
|
1545
|
-
|
|
1546
|
-
|
|
1547
|
-
|
|
1548
|
-
|
|
1549
|
-
|
|
1550
|
-
|
|
1551
|
-
|
|
1552
|
-
|
|
1553
|
-
|
|
1554
|
-
|
|
1555
|
-
|
|
1556
|
-
|
|
1557
|
-
|
|
1558
|
-
|
|
1559
|
-
|
|
1560
|
-
|
|
1561
|
-
|
|
1562
|
-
|
|
1563
|
-
|
|
1564
|
-
|
|
1565
|
-
|
|
1566
|
-
|
|
1567
|
-
|
|
1396
|
+
return includePath;
|
|
1397
|
+
}
|
|
1398
|
+
/**
|
|
1399
|
+
* Get the template from a string or a file, either compiled on-the-fly or
|
|
1400
|
+
* read from cache (if enabled), and cache the template if needed.
|
|
1401
|
+
*
|
|
1402
|
+
* If `template` is not set, the file specified in `options.filename` will be
|
|
1403
|
+
* read.
|
|
1404
|
+
*
|
|
1405
|
+
* If `options.cache` is true, this function reads the file from
|
|
1406
|
+
* `options.filename` so it must be set prior to calling this function.
|
|
1407
|
+
*
|
|
1408
|
+
* @memberof module:ejs-internal
|
|
1409
|
+
* @param {Options} options compilation options
|
|
1410
|
+
* @param {String} [template] template source
|
|
1411
|
+
* @return {TemplateFunction}
|
|
1412
|
+
* @static
|
|
1413
|
+
*/
|
|
1414
|
+
function handleCache(options, template) {
|
|
1415
|
+
let func;
|
|
1416
|
+
let filename = options.filename;
|
|
1417
|
+
let hasTemplate = arguments.length > 1;
|
|
1418
|
+
if (options.cache) {
|
|
1419
|
+
if (!filename) throw new Error("cache option requires a filename");
|
|
1420
|
+
func = ejs.cache.get(filename);
|
|
1421
|
+
if (func) return func;
|
|
1422
|
+
if (!hasTemplate) template = fileLoader(filename).toString().replace(_BOM, "");
|
|
1423
|
+
} else if (!hasTemplate) {
|
|
1424
|
+
// istanbul ignore if: should not happen at all
|
|
1425
|
+
if (!filename) throw new Error("Internal EJS error: no file name or template provided");
|
|
1426
|
+
template = fileLoader(filename).toString().replace(_BOM, "");
|
|
1427
|
+
}
|
|
1428
|
+
func = ejs.compile(template, options);
|
|
1429
|
+
if (options.cache) ejs.cache.set(filename, func);
|
|
1430
|
+
return func;
|
|
1431
|
+
}
|
|
1432
|
+
/**
|
|
1433
|
+
* Try calling handleCache with the given options and data and call the
|
|
1434
|
+
* callback with the result. If an error occurs, call the callback with
|
|
1435
|
+
* the error. Used by renderFile().
|
|
1436
|
+
*
|
|
1437
|
+
* @memberof module:ejs-internal
|
|
1438
|
+
* @param {Options} options compilation options
|
|
1439
|
+
* @param {Object} data template data
|
|
1440
|
+
* @param {RenderFileCallback} cb callback
|
|
1441
|
+
* @static
|
|
1442
|
+
*/
|
|
1443
|
+
function tryHandleCache(options, data, cb) {
|
|
1444
|
+
let result;
|
|
1445
|
+
if (!cb) if (typeof ejs.promiseImpl == "function") return new ejs.promiseImpl(function(resolve, reject) {
|
|
1446
|
+
try {
|
|
1447
|
+
result = handleCache(options)(data);
|
|
1448
|
+
resolve(result);
|
|
1449
|
+
} catch (err) {
|
|
1450
|
+
reject(err);
|
|
1568
1451
|
}
|
|
1569
|
-
|
|
1570
|
-
|
|
1571
|
-
|
|
1572
|
-
|
|
1573
|
-
|
|
1574
|
-
|
|
1575
|
-
|
|
1576
|
-
* the error. Used by renderFile().
|
|
1577
|
-
*
|
|
1578
|
-
* @memberof module:ejs-internal
|
|
1579
|
-
* @param {Options} options compilation options
|
|
1580
|
-
* @param {Object} data template data
|
|
1581
|
-
* @param {RenderFileCallback} cb callback
|
|
1582
|
-
* @static
|
|
1583
|
-
*/
|
|
1584
|
-
function tryHandleCache(options, data, cb) {
|
|
1585
|
-
var result;
|
|
1586
|
-
if (!cb) if (typeof exports.promiseImpl == "function") return new exports.promiseImpl(function(resolve, reject) {
|
|
1587
|
-
try {
|
|
1588
|
-
result = handleCache(options)(data);
|
|
1589
|
-
resolve(result);
|
|
1590
|
-
} catch (err) {
|
|
1591
|
-
reject(err);
|
|
1592
|
-
}
|
|
1593
|
-
});
|
|
1594
|
-
else throw new Error("Please provide a callback function");
|
|
1595
|
-
else {
|
|
1596
|
-
try {
|
|
1597
|
-
result = handleCache(options)(data);
|
|
1598
|
-
} catch (err) {
|
|
1599
|
-
return cb(err);
|
|
1600
|
-
}
|
|
1601
|
-
cb(null, result);
|
|
1452
|
+
});
|
|
1453
|
+
else throw new Error("Please provide a callback function");
|
|
1454
|
+
else {
|
|
1455
|
+
try {
|
|
1456
|
+
result = handleCache(options)(data);
|
|
1457
|
+
} catch (err) {
|
|
1458
|
+
return cb(err);
|
|
1602
1459
|
}
|
|
1460
|
+
cb(null, result);
|
|
1603
1461
|
}
|
|
1604
|
-
|
|
1605
|
-
|
|
1606
|
-
|
|
1607
|
-
|
|
1608
|
-
|
|
1609
|
-
|
|
1610
|
-
|
|
1611
|
-
|
|
1612
|
-
|
|
1613
|
-
|
|
1614
|
-
|
|
1615
|
-
|
|
1616
|
-
|
|
1617
|
-
|
|
1618
|
-
|
|
1619
|
-
|
|
1620
|
-
|
|
1621
|
-
|
|
1622
|
-
|
|
1623
|
-
|
|
1624
|
-
|
|
1625
|
-
|
|
1626
|
-
|
|
1627
|
-
|
|
1628
|
-
|
|
1629
|
-
|
|
1630
|
-
|
|
1631
|
-
|
|
1632
|
-
|
|
1633
|
-
|
|
1634
|
-
}
|
|
1462
|
+
}
|
|
1463
|
+
/**
|
|
1464
|
+
* fileLoader is independent
|
|
1465
|
+
*
|
|
1466
|
+
* @param {String} filePath ejs file path.
|
|
1467
|
+
* @return {String} The contents of the specified file.
|
|
1468
|
+
* @static
|
|
1469
|
+
*/
|
|
1470
|
+
function fileLoader(filePath) {
|
|
1471
|
+
return ejs.fileLoader(filePath);
|
|
1472
|
+
}
|
|
1473
|
+
/**
|
|
1474
|
+
* Get the template function.
|
|
1475
|
+
*
|
|
1476
|
+
* If `options.cache` is `true`, then the template is cached.
|
|
1477
|
+
*
|
|
1478
|
+
* @memberof module:ejs-internal
|
|
1479
|
+
* @param {String} path path for the specified file
|
|
1480
|
+
* @param {Options} options compilation options
|
|
1481
|
+
* @return {TemplateFunction}
|
|
1482
|
+
* @static
|
|
1483
|
+
*/
|
|
1484
|
+
function includeFile(path, options) {
|
|
1485
|
+
let opts = utils.shallowCopy(utils.createNullProtoObjWherePossible(), options);
|
|
1486
|
+
opts.filename = getIncludePath(path, opts);
|
|
1487
|
+
if (typeof options.includer === "function") {
|
|
1488
|
+
let includerResult = options.includer(path, opts.filename);
|
|
1489
|
+
if (includerResult) {
|
|
1490
|
+
if (includerResult.filename) opts.filename = includerResult.filename;
|
|
1491
|
+
if (includerResult.template) return handleCache(opts, includerResult.template);
|
|
1635
1492
|
}
|
|
1636
|
-
return handleCache(opts);
|
|
1637
|
-
}
|
|
1638
|
-
/**
|
|
1639
|
-
* Re-throw the given `err` in context to the `str` of ejs, `filename`, and
|
|
1640
|
-
* `lineno`.
|
|
1641
|
-
*
|
|
1642
|
-
* @implements {RethrowCallback}
|
|
1643
|
-
* @memberof module:ejs-internal
|
|
1644
|
-
* @param {Error} err Error object
|
|
1645
|
-
* @param {String} str EJS source
|
|
1646
|
-
* @param {String} flnm file name of the EJS file
|
|
1647
|
-
* @param {Number} lineno line number of the error
|
|
1648
|
-
* @param {EscapeCallback} esc
|
|
1649
|
-
* @static
|
|
1650
|
-
*/
|
|
1651
|
-
function rethrow(err, str, flnm, lineno, esc) {
|
|
1652
|
-
var lines = str.split("\n");
|
|
1653
|
-
var start = Math.max(lineno - 3, 0);
|
|
1654
|
-
var end = Math.min(lines.length, lineno + 3);
|
|
1655
|
-
var filename = esc(flnm);
|
|
1656
|
-
var context = lines.slice(start, end).map(function(line, i) {
|
|
1657
|
-
var curr = i + start + 1;
|
|
1658
|
-
return (curr == lineno ? " >> " : " ") + curr + "| " + line;
|
|
1659
|
-
}).join("\n");
|
|
1660
|
-
err.path = filename;
|
|
1661
|
-
err.message = (filename || "ejs") + ":" + lineno + "\n" + context + "\n\n" + err.message;
|
|
1662
|
-
throw err;
|
|
1663
|
-
}
|
|
1664
|
-
function stripSemi(str) {
|
|
1665
|
-
return str.replace(/;(\s*$)/, "$1");
|
|
1666
1493
|
}
|
|
1667
|
-
|
|
1668
|
-
|
|
1669
|
-
|
|
1670
|
-
|
|
1671
|
-
|
|
1672
|
-
|
|
1673
|
-
|
|
1674
|
-
|
|
1675
|
-
|
|
1676
|
-
|
|
1677
|
-
|
|
1678
|
-
|
|
1679
|
-
|
|
1680
|
-
|
|
1681
|
-
|
|
1682
|
-
|
|
1683
|
-
|
|
1684
|
-
|
|
1494
|
+
return handleCache(opts);
|
|
1495
|
+
}
|
|
1496
|
+
/**
|
|
1497
|
+
* Re-throw the given `err` in context to the `str` of ejs, `filename`, and
|
|
1498
|
+
* `lineno`.
|
|
1499
|
+
*
|
|
1500
|
+
* @implements {RethrowCallback}
|
|
1501
|
+
* @memberof module:ejs-internal
|
|
1502
|
+
* @param {Error} err Error object
|
|
1503
|
+
* @param {String} str EJS source
|
|
1504
|
+
* @param {String} flnm file name of the EJS file
|
|
1505
|
+
* @param {Number} lineno line number of the error
|
|
1506
|
+
* @param {EscapeCallback} esc
|
|
1507
|
+
* @static
|
|
1508
|
+
*/
|
|
1509
|
+
function rethrow(err, str, flnm, lineno, esc) {
|
|
1510
|
+
let lines = str.split("\n");
|
|
1511
|
+
let start = Math.max(lineno - 3, 0);
|
|
1512
|
+
let end = Math.min(lines.length, lineno + 3);
|
|
1513
|
+
let filename = esc(flnm);
|
|
1514
|
+
let context = lines.slice(start, end).map(function(line, i) {
|
|
1515
|
+
let curr = i + start + 1;
|
|
1516
|
+
return (curr == lineno ? " >> " : " ") + curr + "| " + line;
|
|
1517
|
+
}).join("\n");
|
|
1518
|
+
err.path = filename;
|
|
1519
|
+
err.message = (filename || "ejs") + ":" + lineno + "\n" + context + "\n\n" + err.message;
|
|
1520
|
+
throw err;
|
|
1521
|
+
}
|
|
1522
|
+
function stripSemi(str) {
|
|
1523
|
+
return str.replace(/;(\s*$)/, "$1");
|
|
1524
|
+
}
|
|
1525
|
+
/**
|
|
1526
|
+
* Compile the given `str` of ejs into a template function.
|
|
1527
|
+
*
|
|
1528
|
+
* @param {String} template EJS template
|
|
1529
|
+
*
|
|
1530
|
+
* @param {Options} [opts] compilation options
|
|
1531
|
+
*
|
|
1532
|
+
* @return {TemplateFunction}
|
|
1533
|
+
* Note that the return type of the function depends on the value of `opts.async`.
|
|
1534
|
+
* @public
|
|
1535
|
+
*/
|
|
1536
|
+
ejs.compile = function compile(template, opts) {
|
|
1537
|
+
let templ;
|
|
1538
|
+
if (opts && opts.scope) {
|
|
1539
|
+
console.warn("`scope` option is deprecated and will be removed in future EJS");
|
|
1540
|
+
if (!opts.context) opts.context = opts.scope;
|
|
1541
|
+
delete opts.scope;
|
|
1542
|
+
}
|
|
1543
|
+
templ = new Template(template, opts);
|
|
1544
|
+
return templ.compile();
|
|
1545
|
+
};
|
|
1546
|
+
/**
|
|
1547
|
+
* Render the given `template` of ejs.
|
|
1548
|
+
*
|
|
1549
|
+
* If you would like to include options but not data, you need to explicitly
|
|
1550
|
+
* call this function with `data` being an empty object or `null`.
|
|
1551
|
+
*
|
|
1552
|
+
* @param {String} template EJS template
|
|
1553
|
+
* @param {Object} [data={}] template data
|
|
1554
|
+
* @param {Options} [opts={}] compilation and rendering options
|
|
1555
|
+
* @return {(String|Promise<String>)}
|
|
1556
|
+
* Return value type depends on `opts.async`.
|
|
1557
|
+
* @public
|
|
1558
|
+
*/
|
|
1559
|
+
ejs.render = function(template, d, o) {
|
|
1560
|
+
let data = d || utils.createNullProtoObjWherePossible();
|
|
1561
|
+
let opts = o || utils.createNullProtoObjWherePossible();
|
|
1562
|
+
if (arguments.length == 2) utils.shallowCopyFromList(opts, data, _OPTS_PASSABLE_WITH_DATA);
|
|
1563
|
+
return handleCache(opts, template)(data);
|
|
1564
|
+
};
|
|
1565
|
+
/**
|
|
1566
|
+
* Render an EJS file at the given `path` and callback `cb(err, str)`.
|
|
1567
|
+
*
|
|
1568
|
+
* If you would like to include options but not data, you need to explicitly
|
|
1569
|
+
* call this function with `data` being an empty object or `null`.
|
|
1570
|
+
*
|
|
1571
|
+
* @param {String} path path to the EJS file
|
|
1572
|
+
* @param {Object} [data={}] template data
|
|
1573
|
+
* @param {Options} [opts={}] compilation and rendering options
|
|
1574
|
+
* @param {RenderFileCallback} cb callback
|
|
1575
|
+
* @public
|
|
1576
|
+
*/
|
|
1577
|
+
ejs.renderFile = function() {
|
|
1578
|
+
let args = Array.prototype.slice.call(arguments);
|
|
1579
|
+
let filename = args.shift();
|
|
1580
|
+
let cb;
|
|
1581
|
+
let opts = { filename };
|
|
1582
|
+
let data;
|
|
1583
|
+
let viewOpts;
|
|
1584
|
+
if (typeof arguments[arguments.length - 1] == "function") cb = args.pop();
|
|
1585
|
+
if (args.length) {
|
|
1586
|
+
data = args.shift();
|
|
1587
|
+
if (args.length) utils.shallowCopy(opts, args.pop());
|
|
1588
|
+
else {
|
|
1589
|
+
if (utils.hasOwn(data, "settings") && data.settings) {
|
|
1590
|
+
if (data.settings.views) opts.views = data.settings.views;
|
|
1591
|
+
if (data.settings["view cache"]) opts.cache = true;
|
|
1592
|
+
viewOpts = data.settings["view options"];
|
|
1593
|
+
if (viewOpts) utils.shallowCopy(opts, viewOpts);
|
|
1685
1594
|
}
|
|
1686
|
-
|
|
1687
|
-
delete opts.scope;
|
|
1595
|
+
utils.shallowCopyFromList(opts, data, _OPTS_PASSABLE_WITH_DATA_EXPRESS);
|
|
1688
1596
|
}
|
|
1689
|
-
|
|
1690
|
-
|
|
1691
|
-
|
|
1692
|
-
|
|
1693
|
-
|
|
1694
|
-
|
|
1695
|
-
|
|
1696
|
-
|
|
1697
|
-
|
|
1698
|
-
|
|
1699
|
-
|
|
1700
|
-
|
|
1701
|
-
|
|
1702
|
-
|
|
1703
|
-
|
|
1704
|
-
|
|
1705
|
-
|
|
1706
|
-
|
|
1707
|
-
|
|
1708
|
-
|
|
1709
|
-
|
|
1710
|
-
|
|
1711
|
-
|
|
1712
|
-
|
|
1713
|
-
|
|
1714
|
-
|
|
1715
|
-
|
|
1716
|
-
|
|
1717
|
-
|
|
1718
|
-
|
|
1719
|
-
|
|
1720
|
-
|
|
1721
|
-
|
|
1722
|
-
|
|
1723
|
-
|
|
1724
|
-
|
|
1725
|
-
|
|
1726
|
-
|
|
1727
|
-
|
|
1728
|
-
|
|
1729
|
-
|
|
1730
|
-
|
|
1731
|
-
|
|
1732
|
-
|
|
1733
|
-
|
|
1734
|
-
|
|
1735
|
-
|
|
1736
|
-
|
|
1737
|
-
|
|
1738
|
-
|
|
1739
|
-
|
|
1740
|
-
|
|
1741
|
-
|
|
1597
|
+
opts.filename = filename;
|
|
1598
|
+
} else data = utils.createNullProtoObjWherePossible();
|
|
1599
|
+
return tryHandleCache(opts, data, cb);
|
|
1600
|
+
};
|
|
1601
|
+
/**
|
|
1602
|
+
* Clear intermediate JavaScript cache. Calls {@link Cache#reset}.
|
|
1603
|
+
* @public
|
|
1604
|
+
*/
|
|
1605
|
+
/**
|
|
1606
|
+
* EJS template class
|
|
1607
|
+
* @public
|
|
1608
|
+
*/
|
|
1609
|
+
ejs.Template = Template;
|
|
1610
|
+
ejs.clearCache = function() {
|
|
1611
|
+
ejs.cache.reset();
|
|
1612
|
+
};
|
|
1613
|
+
function Template(text, optsParam) {
|
|
1614
|
+
let opts = utils.hasOwnOnlyObject(optsParam);
|
|
1615
|
+
let options = utils.createNullProtoObjWherePossible();
|
|
1616
|
+
this.templateText = text;
|
|
1617
|
+
/** @type {string | null} */
|
|
1618
|
+
this.mode = null;
|
|
1619
|
+
this.truncate = false;
|
|
1620
|
+
this.currentLine = 1;
|
|
1621
|
+
this.source = "";
|
|
1622
|
+
options.escapeFunction = opts.escape || opts.escapeFunction || utils.escapeXML;
|
|
1623
|
+
options.compileDebug = opts.compileDebug !== false;
|
|
1624
|
+
options.debug = !!opts.debug;
|
|
1625
|
+
options.filename = opts.filename;
|
|
1626
|
+
options.openDelimiter = opts.openDelimiter || ejs.openDelimiter || _DEFAULT_OPEN_DELIMITER;
|
|
1627
|
+
options.closeDelimiter = opts.closeDelimiter || ejs.closeDelimiter || _DEFAULT_CLOSE_DELIMITER;
|
|
1628
|
+
options.delimiter = opts.delimiter || ejs.delimiter || _DEFAULT_DELIMITER;
|
|
1629
|
+
options.strict = opts.strict || false;
|
|
1630
|
+
options.context = opts.context;
|
|
1631
|
+
options.cache = opts.cache || false;
|
|
1632
|
+
options.rmWhitespace = opts.rmWhitespace;
|
|
1633
|
+
options.root = opts.root;
|
|
1634
|
+
options.includer = opts.includer;
|
|
1635
|
+
options.outputFunctionName = opts.outputFunctionName;
|
|
1636
|
+
options.localsName = opts.localsName || ejs.localsName || _DEFAULT_LOCALS_NAME;
|
|
1637
|
+
options.views = opts.views;
|
|
1638
|
+
options.async = opts.async;
|
|
1639
|
+
options.destructuredLocals = opts.destructuredLocals;
|
|
1640
|
+
options.legacyInclude = typeof opts.legacyInclude != "undefined" ? !!opts.legacyInclude : true;
|
|
1641
|
+
if (options.strict) options._with = false;
|
|
1642
|
+
else options._with = typeof opts._with != "undefined" ? opts._with : true;
|
|
1643
|
+
this.opts = options;
|
|
1644
|
+
this.regex = this.createRegex();
|
|
1645
|
+
}
|
|
1646
|
+
Template.modes = {
|
|
1647
|
+
EVAL: "eval",
|
|
1648
|
+
ESCAPED: "escaped",
|
|
1649
|
+
RAW: "raw",
|
|
1650
|
+
COMMENT: "comment",
|
|
1651
|
+
LITERAL: "literal"
|
|
1652
|
+
};
|
|
1653
|
+
Template.prototype = {
|
|
1654
|
+
createRegex: function() {
|
|
1655
|
+
let str = _REGEX_STRING;
|
|
1656
|
+
let delim = utils.escapeRegExpChars(this.opts.delimiter);
|
|
1657
|
+
let open = utils.escapeRegExpChars(this.opts.openDelimiter);
|
|
1658
|
+
let close = utils.escapeRegExpChars(this.opts.closeDelimiter);
|
|
1659
|
+
str = str.replace(/%/g, delim).replace(/</g, open).replace(/>/g, close);
|
|
1660
|
+
return new RegExp(str);
|
|
1661
|
+
},
|
|
1662
|
+
compile: function() {
|
|
1663
|
+
/** @type {string} */
|
|
1664
|
+
let src;
|
|
1665
|
+
let fn;
|
|
1666
|
+
let opts = this.opts;
|
|
1667
|
+
let prepended = "";
|
|
1668
|
+
let appended = "";
|
|
1669
|
+
/** @type {EscapeCallback} */
|
|
1670
|
+
let escapeFn = opts.escapeFunction;
|
|
1671
|
+
/** @type {FunctionConstructor} */
|
|
1672
|
+
let ctor;
|
|
1673
|
+
/** @type {string} */
|
|
1674
|
+
let sanitizedFilename = opts.filename ? JSON.stringify(opts.filename) : "undefined";
|
|
1675
|
+
if (!this.source) {
|
|
1676
|
+
this.generateSource();
|
|
1677
|
+
prepended += ` ${DECLARATION_KEYWORD} __output = "";\n function __append(s) { if (s !== undefined && s !== null) __output += s }
|
|
1678
|
+
`;
|
|
1679
|
+
if (opts.outputFunctionName) {
|
|
1680
|
+
if (!_JS_IDENTIFIER.test(opts.outputFunctionName)) throw new Error("outputFunctionName is not a valid JS identifier.");
|
|
1681
|
+
prepended += ` ${DECLARATION_KEYWORD} ` + opts.outputFunctionName + " = __append;\n";
|
|
1742
1682
|
}
|
|
1743
|
-
opts.
|
|
1744
|
-
|
|
1745
|
-
|
|
1746
|
-
|
|
1747
|
-
|
|
1748
|
-
|
|
1749
|
-
|
|
1750
|
-
|
|
1751
|
-
/**
|
|
1752
|
-
* EJS template class
|
|
1753
|
-
* @public
|
|
1754
|
-
*/
|
|
1755
|
-
exports.Template = Template;
|
|
1756
|
-
exports.clearCache = function() {
|
|
1757
|
-
exports.cache.reset();
|
|
1758
|
-
};
|
|
1759
|
-
function Template(text, optsParam) {
|
|
1760
|
-
var opts = utils.hasOwnOnlyObject(optsParam);
|
|
1761
|
-
var options = utils.createNullProtoObjWherePossible();
|
|
1762
|
-
this.templateText = text;
|
|
1763
|
-
/** @type {string | null} */
|
|
1764
|
-
this.mode = null;
|
|
1765
|
-
this.truncate = false;
|
|
1766
|
-
this.currentLine = 1;
|
|
1767
|
-
this.source = "";
|
|
1768
|
-
options.client = opts.client || false;
|
|
1769
|
-
options.escapeFunction = opts.escape || opts.escapeFunction || utils.escapeXML;
|
|
1770
|
-
options.compileDebug = opts.compileDebug !== false;
|
|
1771
|
-
options.debug = !!opts.debug;
|
|
1772
|
-
options.filename = opts.filename;
|
|
1773
|
-
options.openDelimiter = opts.openDelimiter || exports.openDelimiter || _DEFAULT_OPEN_DELIMITER;
|
|
1774
|
-
options.closeDelimiter = opts.closeDelimiter || exports.closeDelimiter || _DEFAULT_CLOSE_DELIMITER;
|
|
1775
|
-
options.delimiter = opts.delimiter || exports.delimiter || _DEFAULT_DELIMITER;
|
|
1776
|
-
options.strict = opts.strict || false;
|
|
1777
|
-
options.context = opts.context;
|
|
1778
|
-
options.cache = opts.cache || false;
|
|
1779
|
-
options.rmWhitespace = opts.rmWhitespace;
|
|
1780
|
-
options.root = opts.root;
|
|
1781
|
-
options.includer = opts.includer;
|
|
1782
|
-
options.outputFunctionName = opts.outputFunctionName;
|
|
1783
|
-
options.localsName = opts.localsName || exports.localsName || _DEFAULT_LOCALS_NAME;
|
|
1784
|
-
options.views = opts.views;
|
|
1785
|
-
options.async = opts.async;
|
|
1786
|
-
options.destructuredLocals = opts.destructuredLocals;
|
|
1787
|
-
options.legacyInclude = typeof opts.legacyInclude != "undefined" ? !!opts.legacyInclude : true;
|
|
1788
|
-
if (options.strict) options._with = false;
|
|
1789
|
-
else options._with = typeof opts._with != "undefined" ? opts._with : true;
|
|
1790
|
-
this.opts = options;
|
|
1791
|
-
this.regex = this.createRegex();
|
|
1792
|
-
}
|
|
1793
|
-
Template.modes = {
|
|
1794
|
-
EVAL: "eval",
|
|
1795
|
-
ESCAPED: "escaped",
|
|
1796
|
-
RAW: "raw",
|
|
1797
|
-
COMMENT: "comment",
|
|
1798
|
-
LITERAL: "literal"
|
|
1799
|
-
};
|
|
1800
|
-
Template.prototype = {
|
|
1801
|
-
createRegex: function() {
|
|
1802
|
-
var str = _REGEX_STRING;
|
|
1803
|
-
var delim = utils.escapeRegExpChars(this.opts.delimiter);
|
|
1804
|
-
var open = utils.escapeRegExpChars(this.opts.openDelimiter);
|
|
1805
|
-
var close = utils.escapeRegExpChars(this.opts.closeDelimiter);
|
|
1806
|
-
str = str.replace(/%/g, delim).replace(/</g, open).replace(/>/g, close);
|
|
1807
|
-
return new RegExp(str);
|
|
1808
|
-
},
|
|
1809
|
-
compile: function() {
|
|
1810
|
-
/** @type {string} */
|
|
1811
|
-
var src;
|
|
1812
|
-
/** @type {ClientFunction} */
|
|
1813
|
-
var fn;
|
|
1814
|
-
var opts = this.opts;
|
|
1815
|
-
var prepended = "";
|
|
1816
|
-
var appended = "";
|
|
1817
|
-
/** @type {EscapeCallback} */
|
|
1818
|
-
var escapeFn = opts.escapeFunction;
|
|
1819
|
-
/** @type {FunctionConstructor} */
|
|
1820
|
-
var ctor;
|
|
1821
|
-
/** @type {string} */
|
|
1822
|
-
var sanitizedFilename = opts.filename ? JSON.stringify(opts.filename) : "undefined";
|
|
1823
|
-
if (!this.source) {
|
|
1824
|
-
this.generateSource();
|
|
1825
|
-
prepended += " var __output = \"\";\n function __append(s) { if (s !== undefined && s !== null) __output += s }\n";
|
|
1826
|
-
if (opts.outputFunctionName) {
|
|
1827
|
-
if (!_JS_IDENTIFIER.test(opts.outputFunctionName)) throw new Error("outputFunctionName is not a valid JS identifier.");
|
|
1828
|
-
prepended += " var " + opts.outputFunctionName + " = __append;\n";
|
|
1829
|
-
}
|
|
1830
|
-
if (opts.localsName && !_JS_IDENTIFIER.test(opts.localsName)) throw new Error("localsName is not a valid JS identifier.");
|
|
1831
|
-
if (opts.destructuredLocals && opts.destructuredLocals.length) {
|
|
1832
|
-
var destructuring = " var __locals = (" + opts.localsName + " || {}),\n";
|
|
1833
|
-
for (var i = 0; i < opts.destructuredLocals.length; i++) {
|
|
1834
|
-
var name = opts.destructuredLocals[i];
|
|
1835
|
-
if (!_JS_IDENTIFIER.test(name)) throw new Error("destructuredLocals[" + i + "] is not a valid JS identifier.");
|
|
1836
|
-
if (i > 0) destructuring += ",\n ";
|
|
1837
|
-
destructuring += name + " = __locals." + name;
|
|
1838
|
-
}
|
|
1839
|
-
prepended += destructuring + ";\n";
|
|
1683
|
+
if (opts.localsName && !_JS_IDENTIFIER.test(opts.localsName)) throw new Error("localsName is not a valid JS identifier.");
|
|
1684
|
+
if (opts.destructuredLocals && opts.destructuredLocals.length) {
|
|
1685
|
+
let destructuring = ` ${DECLARATION_KEYWORD} __locals = (` + opts.localsName + " || {}),\n";
|
|
1686
|
+
for (let i = 0; i < opts.destructuredLocals.length; i++) {
|
|
1687
|
+
let name = opts.destructuredLocals[i];
|
|
1688
|
+
if (!_JS_IDENTIFIER.test(name)) throw new Error("destructuredLocals[" + i + "] is not a valid JS identifier.");
|
|
1689
|
+
if (i > 0) destructuring += ",\n ";
|
|
1690
|
+
destructuring += name + " = __locals." + name;
|
|
1840
1691
|
}
|
|
1841
|
-
|
|
1842
|
-
prepended += " with (" + opts.localsName + " || {}) {\n";
|
|
1843
|
-
appended += " }\n";
|
|
1844
|
-
}
|
|
1845
|
-
appended += " return __output;\n";
|
|
1846
|
-
this.source = prepended + this.source + appended;
|
|
1692
|
+
prepended += destructuring + ";\n";
|
|
1847
1693
|
}
|
|
1848
|
-
if (opts.
|
|
1849
|
-
|
|
1850
|
-
|
|
1851
|
-
src = "escapeFn = escapeFn || " + escapeFn.toString() + ";\n" + src;
|
|
1852
|
-
if (opts.compileDebug) src = "rethrow = rethrow || " + rethrow.toString() + ";\n" + src;
|
|
1694
|
+
if (opts._with !== false) {
|
|
1695
|
+
prepended += " with (" + opts.localsName + " || {}) {\n";
|
|
1696
|
+
appended += " }\n";
|
|
1853
1697
|
}
|
|
1854
|
-
|
|
1855
|
-
|
|
1856
|
-
|
|
1857
|
-
|
|
1858
|
-
|
|
1859
|
-
|
|
1860
|
-
|
|
1861
|
-
|
|
1862
|
-
|
|
1863
|
-
|
|
1864
|
-
|
|
1865
|
-
|
|
1698
|
+
appended += " return __output;\n";
|
|
1699
|
+
this.source = prepended + this.source + appended;
|
|
1700
|
+
}
|
|
1701
|
+
if (opts.compileDebug) src = `${DECLARATION_KEYWORD} __line = 1
|
|
1702
|
+
, __lines = ` + JSON.stringify(this.templateText) + "\n , __filename = " + sanitizedFilename + ";\ntry {\n" + this.source + "} catch (e) {\n rethrow(e, __lines, __filename, __line, escapeFn);\n}\n";
|
|
1703
|
+
else src = this.source;
|
|
1704
|
+
if (opts.strict) src = "\"use strict\";\n" + src;
|
|
1705
|
+
if (opts.debug) console.log(src);
|
|
1706
|
+
if (opts.compileDebug && opts.filename) src = src + "\n//# sourceURL=" + sanitizedFilename + "\n";
|
|
1707
|
+
try {
|
|
1708
|
+
if (opts.async) try {
|
|
1709
|
+
ctor = new Function("return (async function(){}).constructor;")();
|
|
1866
1710
|
} catch (e) {
|
|
1867
|
-
|
|
1868
|
-
|
|
1869
|
-
|
|
1870
|
-
|
|
1871
|
-
|
|
1872
|
-
|
|
1873
|
-
|
|
1874
|
-
|
|
1875
|
-
|
|
1876
|
-
|
|
1711
|
+
if (e instanceof SyntaxError) throw new Error("This environment does not support async/await");
|
|
1712
|
+
else throw e;
|
|
1713
|
+
}
|
|
1714
|
+
else ctor = Function;
|
|
1715
|
+
fn = new ctor(opts.localsName + ", escapeFn, include, rethrow", src);
|
|
1716
|
+
} catch (e) {
|
|
1717
|
+
// istanbul ignore else
|
|
1718
|
+
if (e instanceof SyntaxError) {
|
|
1719
|
+
if (opts.filename) e.message += " in " + opts.filename;
|
|
1720
|
+
e.message += " while compiling ejs\n\n";
|
|
1721
|
+
e.message += "If the above error is not helpful, you may want to try EJS-Lint:\n";
|
|
1722
|
+
e.message += "https://github.com/RyanZim/EJS-Lint";
|
|
1723
|
+
if (!opts.async) {
|
|
1724
|
+
e.message += "\n";
|
|
1725
|
+
e.message += "Or, if you meant to create an async function, pass `async: true` as an option.";
|
|
1877
1726
|
}
|
|
1878
|
-
throw e;
|
|
1879
1727
|
}
|
|
1880
|
-
|
|
1881
|
-
|
|
1882
|
-
|
|
1883
|
-
|
|
1884
|
-
|
|
1885
|
-
|
|
1886
|
-
return
|
|
1887
|
-
data || utils.createNullProtoObjWherePossible(),
|
|
1888
|
-
escapeFn,
|
|
1889
|
-
include,
|
|
1890
|
-
rethrow
|
|
1891
|
-
]);
|
|
1728
|
+
throw e;
|
|
1729
|
+
}
|
|
1730
|
+
let returnedFn = function anonymous(data) {
|
|
1731
|
+
let include = function(path, includeData) {
|
|
1732
|
+
let d = utils.shallowCopy(utils.createNullProtoObjWherePossible(), data);
|
|
1733
|
+
if (includeData) d = utils.shallowCopy(d, includeData);
|
|
1734
|
+
return includeFile(path, opts)(d);
|
|
1892
1735
|
};
|
|
1893
|
-
|
|
1894
|
-
|
|
1895
|
-
|
|
1896
|
-
|
|
1897
|
-
|
|
1898
|
-
|
|
1899
|
-
|
|
1900
|
-
|
|
1901
|
-
|
|
1902
|
-
|
|
1903
|
-
|
|
1736
|
+
return fn.apply(opts.context, [
|
|
1737
|
+
data || utils.createNullProtoObjWherePossible(),
|
|
1738
|
+
escapeFn,
|
|
1739
|
+
include,
|
|
1740
|
+
rethrow
|
|
1741
|
+
]);
|
|
1742
|
+
};
|
|
1743
|
+
if (opts.filename && typeof Object.defineProperty === "function") {
|
|
1744
|
+
let filename = opts.filename;
|
|
1745
|
+
let basename = path.basename(filename, path.extname(filename));
|
|
1746
|
+
try {
|
|
1747
|
+
Object.defineProperty(returnedFn, "name", {
|
|
1748
|
+
value: basename,
|
|
1749
|
+
writable: false,
|
|
1750
|
+
enumerable: false,
|
|
1751
|
+
configurable: true
|
|
1752
|
+
});
|
|
1753
|
+
} catch (e) {}
|
|
1754
|
+
}
|
|
1755
|
+
return returnedFn;
|
|
1756
|
+
},
|
|
1757
|
+
generateSource: function() {
|
|
1758
|
+
if (this.opts.rmWhitespace) this.templateText = this.templateText.replace(/[\r\n]+/g, "\n").replace(/^\s+|\s+$/gm, "");
|
|
1759
|
+
let self = this;
|
|
1760
|
+
let d = this.opts.delimiter;
|
|
1761
|
+
let o = this.opts.openDelimiter;
|
|
1762
|
+
let c = this.opts.closeDelimiter;
|
|
1763
|
+
let openWhitespaceSlurpTag = utils.escapeRegExpChars(o + d + "_");
|
|
1764
|
+
let closeWhitespaceSlurpTag = utils.escapeRegExpChars("_" + d + c);
|
|
1765
|
+
let openWhitespaceSlurpReplacement = o + d + "_";
|
|
1766
|
+
let closeWhitespaceSlurpReplacement = "_" + d + c;
|
|
1767
|
+
this.templateText = this.templateText.replace(new RegExp("[ \\t]*" + openWhitespaceSlurpTag, "gm"), openWhitespaceSlurpReplacement).replace(new RegExp(closeWhitespaceSlurpTag + "[ \\t]*", "gm"), closeWhitespaceSlurpReplacement);
|
|
1768
|
+
let matches = this.parseTemplateText();
|
|
1769
|
+
if (matches && matches.length) matches.forEach(function(line, index) {
|
|
1770
|
+
let closing;
|
|
1771
|
+
if (line.indexOf(o + d) === 0 && line.indexOf(o + d + d) !== 0) {
|
|
1772
|
+
closing = matches[index + 2];
|
|
1773
|
+
if (!(closing == d + c || closing == "-" + d + c || closing == "_" + d + c)) throw new Error("Could not find matching close tag for \"" + line + "\".");
|
|
1904
1774
|
}
|
|
1905
|
-
|
|
1906
|
-
}
|
|
1907
|
-
|
|
1908
|
-
|
|
1909
|
-
|
|
1910
|
-
|
|
1911
|
-
|
|
1912
|
-
|
|
1913
|
-
|
|
1914
|
-
|
|
1915
|
-
|
|
1916
|
-
|
|
1917
|
-
|
|
1918
|
-
|
|
1919
|
-
|
|
1775
|
+
self.scanLine(line);
|
|
1776
|
+
});
|
|
1777
|
+
},
|
|
1778
|
+
parseTemplateText: function() {
|
|
1779
|
+
let str = this.templateText;
|
|
1780
|
+
let pat = this.regex;
|
|
1781
|
+
let result = pat.exec(str);
|
|
1782
|
+
let arr = [];
|
|
1783
|
+
let firstPos;
|
|
1784
|
+
while (result) {
|
|
1785
|
+
firstPos = result.index;
|
|
1786
|
+
if (firstPos !== 0) {
|
|
1787
|
+
arr.push(str.substring(0, firstPos));
|
|
1788
|
+
str = str.slice(firstPos);
|
|
1789
|
+
}
|
|
1790
|
+
arr.push(result[0]);
|
|
1791
|
+
str = str.slice(result[0].length);
|
|
1792
|
+
result = pat.exec(str);
|
|
1793
|
+
}
|
|
1794
|
+
if (str) arr.push(str);
|
|
1795
|
+
return arr;
|
|
1796
|
+
},
|
|
1797
|
+
_addOutput: function(line) {
|
|
1798
|
+
if (this.truncate) {
|
|
1799
|
+
line = line.replace(/^(?:\r\n|\r|\n)/, "");
|
|
1800
|
+
this.truncate = false;
|
|
1801
|
+
}
|
|
1802
|
+
if (!line) return line;
|
|
1803
|
+
line = line.replace(/\\/g, "\\\\");
|
|
1804
|
+
line = line.replace(/\n/g, "\\n");
|
|
1805
|
+
line = line.replace(/\r/g, "\\r");
|
|
1806
|
+
line = line.replace(/"/g, "\\\"");
|
|
1807
|
+
this.source += " ; __append(\"" + line + "\")\n";
|
|
1808
|
+
},
|
|
1809
|
+
scanLine: function(line) {
|
|
1810
|
+
let self = this;
|
|
1811
|
+
let d = this.opts.delimiter;
|
|
1812
|
+
let o = this.opts.openDelimiter;
|
|
1813
|
+
let c = this.opts.closeDelimiter;
|
|
1814
|
+
let newLineCount = 0;
|
|
1815
|
+
newLineCount = line.split("\n").length - 1;
|
|
1816
|
+
switch (line) {
|
|
1817
|
+
case o + d:
|
|
1818
|
+
case o + d + "_":
|
|
1819
|
+
this.mode = Template.modes.EVAL;
|
|
1820
|
+
break;
|
|
1821
|
+
case o + d + "=":
|
|
1822
|
+
this.mode = Template.modes.ESCAPED;
|
|
1823
|
+
break;
|
|
1824
|
+
case o + d + "-":
|
|
1825
|
+
this.mode = Template.modes.RAW;
|
|
1826
|
+
break;
|
|
1827
|
+
case o + d + "#":
|
|
1828
|
+
this.mode = Template.modes.COMMENT;
|
|
1829
|
+
break;
|
|
1830
|
+
case o + d + d:
|
|
1831
|
+
this.mode = Template.modes.LITERAL;
|
|
1832
|
+
this.source += " ; __append(\"" + line.replace(o + d + d, o + d) + "\")\n";
|
|
1833
|
+
break;
|
|
1834
|
+
case d + d + c:
|
|
1835
|
+
this.mode = Template.modes.LITERAL;
|
|
1836
|
+
this.source += " ; __append(\"" + line.replace(d + d + c, d + c) + "\")\n";
|
|
1837
|
+
break;
|
|
1838
|
+
case d + c:
|
|
1839
|
+
case "-" + d + c:
|
|
1840
|
+
case "_" + d + c:
|
|
1841
|
+
if (this.mode == Template.modes.LITERAL) this._addOutput(line);
|
|
1842
|
+
this.mode = null;
|
|
1843
|
+
this.truncate = line.indexOf("-") === 0 || line.indexOf("_") === 0;
|
|
1844
|
+
break;
|
|
1845
|
+
default: if (this.mode) {
|
|
1846
|
+
switch (this.mode) {
|
|
1847
|
+
case Template.modes.EVAL:
|
|
1848
|
+
case Template.modes.ESCAPED:
|
|
1849
|
+
case Template.modes.RAW: if (line.lastIndexOf("//") > line.lastIndexOf("\n")) line += "\n";
|
|
1920
1850
|
}
|
|
1921
|
-
|
|
1922
|
-
|
|
1923
|
-
|
|
1924
|
-
|
|
1925
|
-
|
|
1926
|
-
|
|
1927
|
-
|
|
1928
|
-
|
|
1929
|
-
|
|
1930
|
-
|
|
1931
|
-
|
|
1932
|
-
|
|
1933
|
-
|
|
1934
|
-
|
|
1851
|
+
switch (this.mode) {
|
|
1852
|
+
case Template.modes.EVAL:
|
|
1853
|
+
this.source += " ; " + line + "\n";
|
|
1854
|
+
break;
|
|
1855
|
+
case Template.modes.ESCAPED:
|
|
1856
|
+
this.source += " ; __append(escapeFn(" + stripSemi(line) + "))\n";
|
|
1857
|
+
break;
|
|
1858
|
+
case Template.modes.RAW:
|
|
1859
|
+
this.source += " ; __append(" + stripSemi(line) + ")\n";
|
|
1860
|
+
break;
|
|
1861
|
+
case Template.modes.COMMENT: break;
|
|
1862
|
+
case Template.modes.LITERAL:
|
|
1863
|
+
this._addOutput(line);
|
|
1864
|
+
break;
|
|
1935
1865
|
}
|
|
1936
|
-
|
|
1937
|
-
str = str.slice(result[0].length);
|
|
1938
|
-
result = pat.exec(str);
|
|
1939
|
-
}
|
|
1940
|
-
if (str) arr.push(str);
|
|
1941
|
-
return arr;
|
|
1942
|
-
},
|
|
1943
|
-
_addOutput: function(line) {
|
|
1944
|
-
if (this.truncate) {
|
|
1945
|
-
line = line.replace(/^(?:\r\n|\r|\n)/, "");
|
|
1946
|
-
this.truncate = false;
|
|
1947
|
-
}
|
|
1948
|
-
if (!line) return line;
|
|
1949
|
-
line = line.replace(/\\/g, "\\\\");
|
|
1950
|
-
line = line.replace(/\n/g, "\\n");
|
|
1951
|
-
line = line.replace(/\r/g, "\\r");
|
|
1952
|
-
line = line.replace(/"/g, "\\\"");
|
|
1953
|
-
this.source += " ; __append(\"" + line + "\")\n";
|
|
1954
|
-
},
|
|
1955
|
-
scanLine: function(line) {
|
|
1956
|
-
var self = this;
|
|
1957
|
-
var d = this.opts.delimiter;
|
|
1958
|
-
var o = this.opts.openDelimiter;
|
|
1959
|
-
var c = this.opts.closeDelimiter;
|
|
1960
|
-
var newLineCount = 0;
|
|
1961
|
-
newLineCount = line.split("\n").length - 1;
|
|
1962
|
-
switch (line) {
|
|
1963
|
-
case o + d:
|
|
1964
|
-
case o + d + "_":
|
|
1965
|
-
this.mode = Template.modes.EVAL;
|
|
1966
|
-
break;
|
|
1967
|
-
case o + d + "=":
|
|
1968
|
-
this.mode = Template.modes.ESCAPED;
|
|
1969
|
-
break;
|
|
1970
|
-
case o + d + "-":
|
|
1971
|
-
this.mode = Template.modes.RAW;
|
|
1972
|
-
break;
|
|
1973
|
-
case o + d + "#":
|
|
1974
|
-
this.mode = Template.modes.COMMENT;
|
|
1975
|
-
break;
|
|
1976
|
-
case o + d + d:
|
|
1977
|
-
this.mode = Template.modes.LITERAL;
|
|
1978
|
-
this.source += " ; __append(\"" + line.replace(o + d + d, o + d) + "\")\n";
|
|
1979
|
-
break;
|
|
1980
|
-
case d + d + c:
|
|
1981
|
-
this.mode = Template.modes.LITERAL;
|
|
1982
|
-
this.source += " ; __append(\"" + line.replace(d + d + c, d + c) + "\")\n";
|
|
1983
|
-
break;
|
|
1984
|
-
case d + c:
|
|
1985
|
-
case "-" + d + c:
|
|
1986
|
-
case "_" + d + c:
|
|
1987
|
-
if (this.mode == Template.modes.LITERAL) this._addOutput(line);
|
|
1988
|
-
this.mode = null;
|
|
1989
|
-
this.truncate = line.indexOf("-") === 0 || line.indexOf("_") === 0;
|
|
1990
|
-
break;
|
|
1991
|
-
default: if (this.mode) {
|
|
1992
|
-
switch (this.mode) {
|
|
1993
|
-
case Template.modes.EVAL:
|
|
1994
|
-
case Template.modes.ESCAPED:
|
|
1995
|
-
case Template.modes.RAW: if (line.lastIndexOf("//") > line.lastIndexOf("\n")) line += "\n";
|
|
1996
|
-
}
|
|
1997
|
-
switch (this.mode) {
|
|
1998
|
-
case Template.modes.EVAL:
|
|
1999
|
-
this.source += " ; " + line + "\n";
|
|
2000
|
-
break;
|
|
2001
|
-
case Template.modes.ESCAPED:
|
|
2002
|
-
this.source += " ; __append(escapeFn(" + stripSemi(line) + "))\n";
|
|
2003
|
-
break;
|
|
2004
|
-
case Template.modes.RAW:
|
|
2005
|
-
this.source += " ; __append(" + stripSemi(line) + ")\n";
|
|
2006
|
-
break;
|
|
2007
|
-
case Template.modes.COMMENT: break;
|
|
2008
|
-
case Template.modes.LITERAL:
|
|
2009
|
-
this._addOutput(line);
|
|
2010
|
-
break;
|
|
2011
|
-
}
|
|
2012
|
-
} else this._addOutput(line);
|
|
2013
|
-
}
|
|
2014
|
-
if (self.opts.compileDebug && newLineCount) {
|
|
2015
|
-
this.currentLine += newLineCount;
|
|
2016
|
-
this.source += " ; __line = " + this.currentLine + "\n";
|
|
2017
|
-
}
|
|
1866
|
+
} else this._addOutput(line);
|
|
2018
1867
|
}
|
|
2019
|
-
|
|
2020
|
-
|
|
2021
|
-
|
|
2022
|
-
|
|
2023
|
-
|
|
2024
|
-
|
|
2025
|
-
|
|
2026
|
-
|
|
2027
|
-
|
|
2028
|
-
|
|
2029
|
-
|
|
2030
|
-
|
|
2031
|
-
|
|
2032
|
-
|
|
2033
|
-
|
|
2034
|
-
|
|
2035
|
-
|
|
2036
|
-
|
|
2037
|
-
|
|
2038
|
-
|
|
2039
|
-
|
|
2040
|
-
|
|
2041
|
-
|
|
2042
|
-
|
|
2043
|
-
|
|
2044
|
-
|
|
2045
|
-
|
|
2046
|
-
|
|
2047
|
-
|
|
2048
|
-
|
|
2049
|
-
|
|
2050
|
-
/**
|
|
2051
|
-
* Name for detection of EJS.
|
|
2052
|
-
*
|
|
2053
|
-
* @readonly
|
|
2054
|
-
* @type {String}
|
|
2055
|
-
* @public
|
|
2056
|
-
*/
|
|
2057
|
-
exports.name = _NAME;
|
|
2058
|
-
/* istanbul ignore if */
|
|
2059
|
-
if (typeof window != "undefined") window.ejs = exports;
|
|
2060
|
-
}));
|
|
1868
|
+
if (self.opts.compileDebug && newLineCount) {
|
|
1869
|
+
this.currentLine += newLineCount;
|
|
1870
|
+
this.source += " ; __line = " + this.currentLine + "\n";
|
|
1871
|
+
}
|
|
1872
|
+
}
|
|
1873
|
+
};
|
|
1874
|
+
/**
|
|
1875
|
+
* Escape characters reserved in XML.
|
|
1876
|
+
*
|
|
1877
|
+
* This is simply an export of {@link module:utils.escapeXML}.
|
|
1878
|
+
*
|
|
1879
|
+
* If `markup` is `undefined` or `null`, the empty string is returned.
|
|
1880
|
+
*
|
|
1881
|
+
* @param {String} markup Input string
|
|
1882
|
+
* @return {String} Escaped string
|
|
1883
|
+
* @public
|
|
1884
|
+
* @func
|
|
1885
|
+
* */
|
|
1886
|
+
ejs.escapeXML = utils.escapeXML;
|
|
1887
|
+
/**
|
|
1888
|
+
* Express.js support.
|
|
1889
|
+
*
|
|
1890
|
+
* This is an alias for {@link module:ejs.renderFile}, in order to support
|
|
1891
|
+
* Express.js out-of-the-box.
|
|
1892
|
+
*
|
|
1893
|
+
* @func
|
|
1894
|
+
*/
|
|
1895
|
+
ejs.__express = ejs.renderFile;
|
|
1896
|
+
/* istanbul ignore if */
|
|
1897
|
+
if (typeof window != "undefined") window.ejs = ejs;
|
|
1898
|
+
if (typeof module != "undefined") module.exports = ejs;
|
|
2061
1899
|
//#endregion
|
|
2062
1900
|
//#region utils/banners.ts
|
|
2063
|
-
var import_picocolors = require_picocolors();
|
|
2064
|
-
var import_ejs = /* @__PURE__ */ __toESM(require_ejs(), 1);
|
|
2065
1901
|
const defaultBanner = "Vue.js - The Progressive JavaScript Framework";
|
|
2066
1902
|
const gradientBanner = "\x1B[38;2;66;211;146mV\x1B[39m\x1B[38;2;66;211;146mu\x1B[39m\x1B[38;2;66;211;146me\x1B[39m\x1B[38;2;66;211;146m.\x1B[39m\x1B[38;2;66;211;146mj\x1B[39m\x1B[38;2;67;209;149ms\x1B[39m \x1B[38;2;68;206;152m-\x1B[39m \x1B[38;2;69;204;155mT\x1B[39m\x1B[38;2;70;201;158mh\x1B[39m\x1B[38;2;71;199;162me\x1B[39m \x1B[38;2;72;196;165mP\x1B[39m\x1B[38;2;73;194;168mr\x1B[39m\x1B[38;2;74;192;171mo\x1B[39m\x1B[38;2;75;189;174mg\x1B[39m\x1B[38;2;76;187;177mr\x1B[39m\x1B[38;2;77;184;180me\x1B[39m\x1B[38;2;78;182;183ms\x1B[39m\x1B[38;2;79;179;186ms\x1B[39m\x1B[38;2;80;177;190mi\x1B[39m\x1B[38;2;81;175;193mv\x1B[39m\x1B[38;2;82;172;196me\x1B[39m \x1B[38;2;83;170;199mJ\x1B[39m\x1B[38;2;83;167;202ma\x1B[39m\x1B[38;2;84;165;205mv\x1B[39m\x1B[38;2;85;162;208ma\x1B[39m\x1B[38;2;86;160;211mS\x1B[39m\x1B[38;2;87;158;215mc\x1B[39m\x1B[38;2;88;155;218mr\x1B[39m\x1B[38;2;89;153;221mi\x1B[39m\x1B[38;2;90;150;224mp\x1B[39m\x1B[38;2;91;148;227mt\x1B[39m \x1B[38;2;92;145;230mF\x1B[39m\x1B[38;2;93;143;233mr\x1B[39m\x1B[38;2;94;141;236ma\x1B[39m\x1B[38;2;95;138;239mm\x1B[39m\x1B[38;2;96;136;243me\x1B[39m\x1B[38;2;97;133;246mw\x1B[39m\x1B[38;2;98;131;249mo\x1B[39m\x1B[38;2;99;128;252mr\x1B[39m\x1B[38;2;100;126;255mk\x1B[39m";
|
|
2067
1903
|
//#endregion
|
|
@@ -2115,33 +1951,33 @@ function sortDependencies(packageJson) {
|
|
|
2115
1951
|
* @param {string} dest destination filename of the copy operation
|
|
2116
1952
|
*/
|
|
2117
1953
|
function renderTemplate(src, dest, callbacks) {
|
|
2118
|
-
if (fs.statSync(src).isDirectory()) {
|
|
2119
|
-
if (path$
|
|
2120
|
-
fs.mkdirSync(dest, { recursive: true });
|
|
2121
|
-
for (const file of fs.readdirSync(src)) renderTemplate(path$
|
|
1954
|
+
if (fs$1.statSync(src).isDirectory()) {
|
|
1955
|
+
if (path$2.basename(src) === "node_modules") return;
|
|
1956
|
+
fs$1.mkdirSync(dest, { recursive: true });
|
|
1957
|
+
for (const file of fs$1.readdirSync(src)) renderTemplate(path$2.resolve(src, file), path$2.resolve(dest, file), callbacks);
|
|
2122
1958
|
return;
|
|
2123
1959
|
}
|
|
2124
|
-
const filename = path$
|
|
2125
|
-
if (filename === "package.json" && fs.existsSync(dest)) {
|
|
2126
|
-
const pkg = sortDependencies(deepMerge(JSON.parse(fs.readFileSync(dest, "utf8")), JSON.parse(fs.readFileSync(src, "utf8"))));
|
|
2127
|
-
fs.writeFileSync(dest, JSON.stringify(pkg, null, 2) + "\n");
|
|
1960
|
+
const filename = path$2.basename(src);
|
|
1961
|
+
if (filename === "package.json" && fs$1.existsSync(dest)) {
|
|
1962
|
+
const pkg = sortDependencies(deepMerge(JSON.parse(fs$1.readFileSync(dest, "utf8")), JSON.parse(fs$1.readFileSync(src, "utf8"))));
|
|
1963
|
+
fs$1.writeFileSync(dest, JSON.stringify(pkg, null, 2) + "\n");
|
|
2128
1964
|
return;
|
|
2129
1965
|
}
|
|
2130
|
-
if (filename === "extensions.json" && fs.existsSync(dest)) {
|
|
2131
|
-
const extensions = deepMerge(JSON.parse(fs.readFileSync(dest, "utf8")), JSON.parse(fs.readFileSync(src, "utf8")));
|
|
2132
|
-
fs.writeFileSync(dest, JSON.stringify(extensions, null, 2) + "\n");
|
|
1966
|
+
if (filename === "extensions.json" && fs$1.existsSync(dest)) {
|
|
1967
|
+
const extensions = deepMerge(JSON.parse(fs$1.readFileSync(dest, "utf8")), JSON.parse(fs$1.readFileSync(src, "utf8")));
|
|
1968
|
+
fs$1.writeFileSync(dest, JSON.stringify(extensions, null, 2) + "\n");
|
|
2133
1969
|
return;
|
|
2134
1970
|
}
|
|
2135
|
-
if (filename === "settings.json" && fs.existsSync(dest)) {
|
|
2136
|
-
const settings = deepMerge(JSON.parse(fs.readFileSync(dest, "utf8")), JSON.parse(fs.readFileSync(src, "utf8")));
|
|
2137
|
-
fs.writeFileSync(dest, JSON.stringify(settings, null, 2) + "\n");
|
|
1971
|
+
if (filename === "settings.json" && fs$1.existsSync(dest)) {
|
|
1972
|
+
const settings = deepMerge(JSON.parse(fs$1.readFileSync(dest, "utf8")), JSON.parse(fs$1.readFileSync(src, "utf8")));
|
|
1973
|
+
fs$1.writeFileSync(dest, JSON.stringify(settings, null, 2) + "\n");
|
|
2138
1974
|
return;
|
|
2139
1975
|
}
|
|
2140
|
-
if (filename.startsWith("_")) dest = path$
|
|
2141
|
-
if (filename === "_gitignore" && fs.existsSync(dest)) {
|
|
2142
|
-
const existing = fs.readFileSync(dest, "utf8");
|
|
2143
|
-
const newGitignore = fs.readFileSync(src, "utf8");
|
|
2144
|
-
fs.writeFileSync(dest, existing + "\n" + newGitignore);
|
|
1976
|
+
if (filename.startsWith("_")) dest = path$2.resolve(path$2.dirname(dest), filename.replace(/^_/, "."));
|
|
1977
|
+
if (filename === "_gitignore" && fs$1.existsSync(dest)) {
|
|
1978
|
+
const existing = fs$1.readFileSync(dest, "utf8");
|
|
1979
|
+
const newGitignore = fs$1.readFileSync(src, "utf8");
|
|
1980
|
+
fs$1.writeFileSync(dest, existing + "\n" + newGitignore);
|
|
2145
1981
|
return;
|
|
2146
1982
|
}
|
|
2147
1983
|
if (filename.endsWith(".data.mjs")) {
|
|
@@ -2152,17 +1988,17 @@ function renderTemplate(src, dest, callbacks) {
|
|
|
2152
1988
|
});
|
|
2153
1989
|
return;
|
|
2154
1990
|
}
|
|
2155
|
-
fs.copyFileSync(src, dest);
|
|
1991
|
+
fs$1.copyFileSync(src, dest);
|
|
2156
1992
|
}
|
|
2157
1993
|
//#endregion
|
|
2158
1994
|
//#region utils/directoryTraverse.ts
|
|
2159
1995
|
function preOrderDirectoryTraverse(dir, dirCallback, fileCallback) {
|
|
2160
|
-
for (const filename of fs.readdirSync(dir)) {
|
|
1996
|
+
for (const filename of fs$1.readdirSync(dir)) {
|
|
2161
1997
|
if (filename === ".git") continue;
|
|
2162
|
-
const fullpath = path$
|
|
2163
|
-
if (fs.lstatSync(fullpath).isDirectory()) {
|
|
1998
|
+
const fullpath = path$2.resolve(dir, filename);
|
|
1999
|
+
if (fs$1.lstatSync(fullpath).isDirectory()) {
|
|
2164
2000
|
dirCallback(fullpath);
|
|
2165
|
-
if (fs.existsSync(fullpath)) preOrderDirectoryTraverse(fullpath, dirCallback, fileCallback);
|
|
2001
|
+
if (fs$1.existsSync(fullpath)) preOrderDirectoryTraverse(fullpath, dirCallback, fileCallback);
|
|
2166
2002
|
continue;
|
|
2167
2003
|
}
|
|
2168
2004
|
fileCallback(fullpath);
|
|
@@ -2170,13 +2006,13 @@ function preOrderDirectoryTraverse(dir, dirCallback, fileCallback) {
|
|
|
2170
2006
|
}
|
|
2171
2007
|
const dotGitDirectoryState = { hasDotGitDirectory: false };
|
|
2172
2008
|
function postOrderDirectoryTraverse(dir, dirCallback, fileCallback) {
|
|
2173
|
-
for (const filename of fs.readdirSync(dir)) {
|
|
2009
|
+
for (const filename of fs$1.readdirSync(dir)) {
|
|
2174
2010
|
if (filename === ".git") {
|
|
2175
2011
|
dotGitDirectoryState.hasDotGitDirectory = true;
|
|
2176
2012
|
continue;
|
|
2177
2013
|
}
|
|
2178
|
-
const fullpath = path$
|
|
2179
|
-
if (fs.lstatSync(fullpath).isDirectory()) {
|
|
2014
|
+
const fullpath = path$2.resolve(dir, filename);
|
|
2015
|
+
if (fs$1.lstatSync(fullpath).isDirectory()) {
|
|
2180
2016
|
postOrderDirectoryTraverse(fullpath, dirCallback, fileCallback);
|
|
2181
2017
|
dirCallback(fullpath);
|
|
2182
2018
|
continue;
|
|
@@ -2339,43 +2175,43 @@ function getLocale() {
|
|
|
2339
2175
|
return linkLocale((process.env.LC_ALL || process.env.LC_MESSAGES || process.env.LANG || Intl.DateTimeFormat().resolvedOptions().locale || "en-US").split(".")[0].replace("_", "-"));
|
|
2340
2176
|
}
|
|
2341
2177
|
async function loadLanguageFile(filePath) {
|
|
2342
|
-
return await fs.promises.readFile(filePath, "utf-8").then((data) => {
|
|
2178
|
+
return await fs$1.promises.readFile(filePath, "utf-8").then((data) => {
|
|
2343
2179
|
const parsedData = JSON.parse(data);
|
|
2344
2180
|
if (parsedData) return parsedData;
|
|
2345
2181
|
});
|
|
2346
2182
|
}
|
|
2347
2183
|
async function getLanguage(localesRoot) {
|
|
2348
2184
|
const locale = getLocale();
|
|
2349
|
-
const languageFilePath = path$
|
|
2350
|
-
const fallbackPath = path$
|
|
2351
|
-
return fs.existsSync(languageFilePath) ? await loadLanguageFile(languageFilePath) : await loadLanguageFile(fallbackPath);
|
|
2185
|
+
const languageFilePath = path$2.resolve(localesRoot, `${locale}.json`);
|
|
2186
|
+
const fallbackPath = path$2.resolve(localesRoot, "en-US.json");
|
|
2187
|
+
return fs$1.existsSync(languageFilePath) ? await loadLanguageFile(languageFilePath) : await loadLanguageFile(fallbackPath);
|
|
2352
2188
|
}
|
|
2353
2189
|
//#endregion
|
|
2354
2190
|
//#region utils/trimBoilerplate.ts
|
|
2355
2191
|
function replaceContent(filepath, replacer) {
|
|
2356
|
-
const content = fs.readFileSync(filepath, "utf8");
|
|
2357
|
-
fs.writeFileSync(filepath, replacer(content));
|
|
2192
|
+
const content = fs$1.readFileSync(filepath, "utf8");
|
|
2193
|
+
fs$1.writeFileSync(filepath, replacer(content));
|
|
2358
2194
|
}
|
|
2359
2195
|
function trimBoilerplate(rootDir) {
|
|
2360
|
-
const srcDir = path.resolve(rootDir, "src");
|
|
2361
|
-
for (const filename of fs.readdirSync(srcDir)) {
|
|
2196
|
+
const srcDir = path$1.resolve(rootDir, "src");
|
|
2197
|
+
for (const filename of fs$1.readdirSync(srcDir)) {
|
|
2362
2198
|
if ([
|
|
2363
2199
|
"main.js",
|
|
2364
2200
|
"main.ts",
|
|
2365
2201
|
"router",
|
|
2366
2202
|
"stores"
|
|
2367
2203
|
].includes(filename)) continue;
|
|
2368
|
-
const fullpath = path.resolve(srcDir, filename);
|
|
2369
|
-
fs.rmSync(fullpath, { recursive: true });
|
|
2204
|
+
const fullpath = path$1.resolve(srcDir, filename);
|
|
2205
|
+
fs$1.rmSync(fullpath, { recursive: true });
|
|
2370
2206
|
}
|
|
2371
2207
|
}
|
|
2372
2208
|
function removeCSSImport(rootDir, needsTypeScript, needsCypressCT) {
|
|
2373
|
-
replaceContent(path.resolve(rootDir, needsTypeScript ? "src/main.ts" : "src/main.js"), (content) => content.replace("import './assets/main.css'\n\n", ""));
|
|
2374
|
-
if (needsCypressCT) replaceContent(path.resolve(rootDir, needsTypeScript ? "cypress/support/component.ts" : "cypress/support/component.js"), (content) => content.replace("import '@/assets/main.css'", "// import '@/assets/main.css'"));
|
|
2209
|
+
replaceContent(path$1.resolve(rootDir, needsTypeScript ? "src/main.ts" : "src/main.js"), (content) => content.replace("import './assets/main.css'\n\n", ""));
|
|
2210
|
+
if (needsCypressCT) replaceContent(path$1.resolve(rootDir, needsTypeScript ? "cypress/support/component.ts" : "cypress/support/component.js"), (content) => content.replace("import '@/assets/main.css'", "// import '@/assets/main.css'"));
|
|
2375
2211
|
}
|
|
2376
2212
|
function emptyRouterConfig(rootDir, needsTypeScript) {
|
|
2377
|
-
const srcDir = path.resolve(rootDir, "src");
|
|
2378
|
-
replaceContent(path.resolve(srcDir, needsTypeScript ? "router/index.ts" : "router/index.js"), (content) => content.replace(`import HomeView from '../views/HomeView.vue'\n`, "").replace(/routes:\s*\[[\s\S]*?\],/, "routes: [],"));
|
|
2213
|
+
const srcDir = path$1.resolve(rootDir, "src");
|
|
2214
|
+
replaceContent(path$1.resolve(srcDir, needsTypeScript ? "router/index.ts" : "router/index.js"), (content) => content.replace(`import HomeView from '../views/HomeView.vue'\n`, "").replace(/routes:\s*\[[\s\S]*?\],/, "routes: [],"));
|
|
2379
2215
|
}
|
|
2380
2216
|
//#endregion
|
|
2381
2217
|
//#region utils/applyVueBeta.ts
|
|
@@ -2428,7 +2264,7 @@ peerDependencyRules:
|
|
|
2428
2264
|
allowAny:
|
|
2429
2265
|
- 'vue'
|
|
2430
2266
|
`;
|
|
2431
|
-
fs.writeFileSync(path$
|
|
2267
|
+
fs$1.writeFileSync(path$2.resolve(root, "pnpm-workspace.yaml"), yamlContent, "utf-8");
|
|
2432
2268
|
}
|
|
2433
2269
|
}
|
|
2434
2270
|
//#endregion
|
|
@@ -2458,7 +2294,7 @@ function getPackageManagerOptions(preferred) {
|
|
|
2458
2294
|
//#endregion
|
|
2459
2295
|
//#region package.json
|
|
2460
2296
|
var name = "create-vue";
|
|
2461
|
-
var version = "3.22.
|
|
2297
|
+
var version = "3.22.4";
|
|
2462
2298
|
//#endregion
|
|
2463
2299
|
//#region index.ts
|
|
2464
2300
|
const language = await getLanguage(fileURLToPath(new URL("./locales", import.meta.url)));
|
|
@@ -2526,8 +2362,8 @@ function toValidPackageName(projectName) {
|
|
|
2526
2362
|
return projectName.trim().toLowerCase().replace(/\s+/g, "-").replace(/^[._]/, "").replace(/[^a-z0-9-~]+/g, "-");
|
|
2527
2363
|
}
|
|
2528
2364
|
function canSkipEmptying(dir) {
|
|
2529
|
-
if (!fs.existsSync(dir)) return true;
|
|
2530
|
-
const files = fs.readdirSync(dir);
|
|
2365
|
+
if (!fs$1.existsSync(dir)) return true;
|
|
2366
|
+
const files = fs$1.readdirSync(dir);
|
|
2531
2367
|
if (files.length === 0) return true;
|
|
2532
2368
|
if (files.length === 1 && files[0] === ".git") {
|
|
2533
2369
|
dotGitDirectoryState.hasDotGitDirectory = true;
|
|
@@ -2536,13 +2372,13 @@ function canSkipEmptying(dir) {
|
|
|
2536
2372
|
return false;
|
|
2537
2373
|
}
|
|
2538
2374
|
function emptyDir(dir) {
|
|
2539
|
-
if (!fs.existsSync(dir)) return;
|
|
2540
|
-
postOrderDirectoryTraverse(dir, (dir) => fs.rmdirSync(dir), (file) => fs.unlinkSync(file));
|
|
2375
|
+
if (!fs$1.existsSync(dir)) return;
|
|
2376
|
+
postOrderDirectoryTraverse(dir, (dir) => fs$1.rmdirSync(dir), (file) => fs$1.unlinkSync(file));
|
|
2541
2377
|
}
|
|
2542
2378
|
async function unwrapPrompt(maybeCancelPromise) {
|
|
2543
2379
|
const result = await maybeCancelPromise;
|
|
2544
|
-
if (
|
|
2545
|
-
|
|
2380
|
+
if (isCancel(result)) {
|
|
2381
|
+
cancel((0, import_picocolors.red)("✖") + ` ${language.errors.operationCancelled}`);
|
|
2546
2382
|
process.exit(0);
|
|
2547
2383
|
}
|
|
2548
2384
|
return result;
|
|
@@ -2639,41 +2475,41 @@ async function init() {
|
|
|
2639
2475
|
experimentFeatures: [],
|
|
2640
2476
|
needsBareboneTemplates: false
|
|
2641
2477
|
};
|
|
2642
|
-
|
|
2643
|
-
if (!targetDir) targetDir = result.projectName = result.packageName = (await unwrapPrompt(
|
|
2478
|
+
intro(process.stdout.isTTY && process.stdout.getColorDepth() > 8 ? gradientBanner : defaultBanner);
|
|
2479
|
+
if (!targetDir) targetDir = result.projectName = result.packageName = (await unwrapPrompt(text({
|
|
2644
2480
|
message: language.projectName.message,
|
|
2645
2481
|
placeholder: defaultProjectName,
|
|
2646
2482
|
defaultValue: defaultProjectName,
|
|
2647
2483
|
validate: (value) => !value || value.trim().length > 0 ? void 0 : language.projectName.invalidMessage
|
|
2648
2484
|
})))?.trim() || defaultProjectName;
|
|
2649
2485
|
if (!canSkipEmptying(targetDir) && !forceOverwrite) {
|
|
2650
|
-
result.shouldOverwrite = await unwrapPrompt(
|
|
2486
|
+
result.shouldOverwrite = await unwrapPrompt(confirm({
|
|
2651
2487
|
message: `${targetDir === "." ? language.shouldOverwrite.dirForPrompts.current : `${language.shouldOverwrite.dirForPrompts.target} "${targetDir}"`} ${language.shouldOverwrite.message}`,
|
|
2652
2488
|
initialValue: false
|
|
2653
2489
|
}));
|
|
2654
2490
|
if (!result.shouldOverwrite) {
|
|
2655
|
-
|
|
2491
|
+
cancel((0, import_picocolors.red)("✖") + ` ${language.errors.operationCancelled}`);
|
|
2656
2492
|
process.exit(0);
|
|
2657
2493
|
}
|
|
2658
2494
|
}
|
|
2659
|
-
if (!isValidPackageName(targetDir)) result.packageName = await unwrapPrompt(
|
|
2495
|
+
if (!isValidPackageName(targetDir)) result.packageName = await unwrapPrompt(text({
|
|
2660
2496
|
message: language.packageName.message,
|
|
2661
2497
|
initialValue: toValidPackageName(targetDir),
|
|
2662
2498
|
validate: (value) => isValidPackageName(value) ? void 0 : language.packageName.invalidMessage
|
|
2663
2499
|
}));
|
|
2664
2500
|
if (!isFeatureFlagsUsed) {
|
|
2665
|
-
result.needsTypeScript = await unwrapPrompt(
|
|
2501
|
+
result.needsTypeScript = await unwrapPrompt(confirm({
|
|
2666
2502
|
message: language.needsTypeScript.message,
|
|
2667
2503
|
initialValue: true
|
|
2668
2504
|
}));
|
|
2669
|
-
result.features = await unwrapPrompt(
|
|
2505
|
+
result.features = await unwrapPrompt(multiselect({
|
|
2670
2506
|
message: `${language.featureSelection.message} ${(0, import_picocolors.dim)(language.featureSelection.hint)}`,
|
|
2671
2507
|
options: FEATURE_OPTIONS,
|
|
2672
2508
|
required: false
|
|
2673
2509
|
}));
|
|
2674
2510
|
if (result.features.includes("e2e")) {
|
|
2675
2511
|
const hasVitest = result.features.includes("vitest");
|
|
2676
|
-
result.e2eFramework = await unwrapPrompt(
|
|
2512
|
+
result.e2eFramework = await unwrapPrompt(select({
|
|
2677
2513
|
message: `${language.e2eSelection.message} ${(0, import_picocolors.dim)(language.e2eSelection.hint)}`,
|
|
2678
2514
|
options: [{
|
|
2679
2515
|
value: "playwright",
|
|
@@ -2686,7 +2522,7 @@ async function init() {
|
|
|
2686
2522
|
}]
|
|
2687
2523
|
}));
|
|
2688
2524
|
}
|
|
2689
|
-
result.experimentFeatures = await unwrapPrompt(
|
|
2525
|
+
result.experimentFeatures = await unwrapPrompt(multiselect({
|
|
2690
2526
|
message: `${language.needsExperimentalFeatures.message} ${(0, import_picocolors.dim)(language.needsExperimentalFeatures.hint)}`,
|
|
2691
2527
|
options: EXPERIMENTAL_FEATURE_OPTIONS,
|
|
2692
2528
|
required: false
|
|
@@ -2696,14 +2532,14 @@ async function init() {
|
|
|
2696
2532
|
value: pm,
|
|
2697
2533
|
label: pm
|
|
2698
2534
|
}));
|
|
2699
|
-
result.packageManager = await unwrapPrompt(
|
|
2535
|
+
result.packageManager = await unwrapPrompt(select({
|
|
2700
2536
|
message: `${language.packageManagerSelection.message} ${(0, import_picocolors.dim)(language.packageManagerSelection.hint)}`,
|
|
2701
2537
|
options: packageManagerOptions
|
|
2702
2538
|
}));
|
|
2703
2539
|
}
|
|
2704
2540
|
}
|
|
2705
2541
|
if (argv.bare) result.needsBareboneTemplates = true;
|
|
2706
|
-
else if (!isFeatureFlagsUsed) result.needsBareboneTemplates = await unwrapPrompt(
|
|
2542
|
+
else if (!isFeatureFlagsUsed) result.needsBareboneTemplates = await unwrapPrompt(confirm({
|
|
2707
2543
|
message: language.needsBareboneTemplates.message,
|
|
2708
2544
|
initialValue: false
|
|
2709
2545
|
}));
|
|
@@ -2721,19 +2557,19 @@ async function init() {
|
|
|
2721
2557
|
const needsCypress = argv.cypress || argv.tests || argv["with-tests"] || e2eFramework === "cypress";
|
|
2722
2558
|
const needsCypressCT = needsCypress && !needsVitest;
|
|
2723
2559
|
const needsPlaywright = argv.playwright || e2eFramework === "playwright";
|
|
2724
|
-
const root = path$
|
|
2725
|
-
if (fs.existsSync(root) && result.shouldOverwrite) emptyDir(root);
|
|
2726
|
-
else if (!fs.existsSync(root)) fs.mkdirSync(root);
|
|
2560
|
+
const root = path$2.join(cwd, targetDir);
|
|
2561
|
+
if (fs$1.existsSync(root) && result.shouldOverwrite) emptyDir(root);
|
|
2562
|
+
else if (!fs$1.existsSync(root)) fs$1.mkdirSync(root);
|
|
2727
2563
|
console.log(`\n${language.infos.scaffolding} ${root}...`);
|
|
2728
2564
|
const pkg = {
|
|
2729
2565
|
name: result.packageName,
|
|
2730
2566
|
version: "0.0.0"
|
|
2731
2567
|
};
|
|
2732
|
-
fs.writeFileSync(path$
|
|
2568
|
+
fs$1.writeFileSync(path$2.resolve(root, "package.json"), JSON.stringify(pkg, null, 2));
|
|
2733
2569
|
const templateRoot = fileURLToPath(new URL("./template", import.meta.url));
|
|
2734
2570
|
const callbacks = [];
|
|
2735
2571
|
const render = function render(templateName) {
|
|
2736
|
-
renderTemplate(path$
|
|
2572
|
+
renderTemplate(path$2.resolve(templateRoot, templateName), root, callbacks);
|
|
2737
2573
|
};
|
|
2738
2574
|
render("base");
|
|
2739
2575
|
if (needsJsx) render("config/jsx");
|
|
@@ -2760,7 +2596,7 @@ async function init() {
|
|
|
2760
2596
|
render("tsconfig/vitest");
|
|
2761
2597
|
rootTsConfig.references.push({ path: "./tsconfig.vitest.json" });
|
|
2762
2598
|
}
|
|
2763
|
-
fs.writeFileSync(path$
|
|
2599
|
+
fs$1.writeFileSync(path$2.resolve(root, "tsconfig.json"), JSON.stringify(rootTsConfig, null, 2) + "\n", "utf-8");
|
|
2764
2600
|
}
|
|
2765
2601
|
if (needsEslint) {
|
|
2766
2602
|
render("linting/base");
|
|
@@ -2772,7 +2608,7 @@ async function init() {
|
|
|
2772
2608
|
if (needsVitest) render("linting/vitest");
|
|
2773
2609
|
render("linting/oxlint");
|
|
2774
2610
|
callbacks.push(async (dataStore) => {
|
|
2775
|
-
const oxlintrcPath = path$
|
|
2611
|
+
const oxlintrcPath = path$2.resolve(root, ".oxlintrc.json");
|
|
2776
2612
|
dataStore[oxlintrcPath] = {
|
|
2777
2613
|
needsTypeScript,
|
|
2778
2614
|
needsVitest
|
|
@@ -2791,11 +2627,11 @@ async function init() {
|
|
|
2791
2627
|
for (const cb of callbacks) await cb(dataStore);
|
|
2792
2628
|
preOrderDirectoryTraverse(root, () => {}, (filepath) => {
|
|
2793
2629
|
if (filepath.endsWith(".ejs")) {
|
|
2794
|
-
const template = fs.readFileSync(filepath, "utf-8");
|
|
2630
|
+
const template = fs$1.readFileSync(filepath, "utf-8");
|
|
2795
2631
|
const dest = filepath.replace(/\.ejs$/, "");
|
|
2796
|
-
const content =
|
|
2797
|
-
fs.writeFileSync(dest, content);
|
|
2798
|
-
fs.unlinkSync(filepath);
|
|
2632
|
+
const content = ejs.render(template, dataStore[dest]);
|
|
2633
|
+
fs$1.writeFileSync(dest, content);
|
|
2634
|
+
fs$1.unlinkSync(filepath);
|
|
2799
2635
|
}
|
|
2800
2636
|
});
|
|
2801
2637
|
if (needsBareboneTemplates) {
|
|
@@ -2809,15 +2645,15 @@ async function init() {
|
|
|
2809
2645
|
preOrderDirectoryTraverse(root, () => {}, (filepath) => {
|
|
2810
2646
|
if (filepath.endsWith(".js")) {
|
|
2811
2647
|
const tsFilePath = filepath.replace(/\.js$/, ".ts");
|
|
2812
|
-
if (fs.existsSync(tsFilePath)) fs.unlinkSync(filepath);
|
|
2813
|
-
else fs.renameSync(filepath, tsFilePath);
|
|
2814
|
-
} else if (path$
|
|
2648
|
+
if (fs$1.existsSync(tsFilePath)) fs$1.unlinkSync(filepath);
|
|
2649
|
+
else fs$1.renameSync(filepath, tsFilePath);
|
|
2650
|
+
} else if (path$2.basename(filepath) === "jsconfig.json") fs$1.unlinkSync(filepath);
|
|
2815
2651
|
});
|
|
2816
|
-
const indexHtmlPath = path$
|
|
2817
|
-
const indexHtmlContent = fs.readFileSync(indexHtmlPath, "utf8");
|
|
2818
|
-
fs.writeFileSync(indexHtmlPath, indexHtmlContent.replace("src/main.js", "src/main.ts"));
|
|
2652
|
+
const indexHtmlPath = path$2.resolve(root, "index.html");
|
|
2653
|
+
const indexHtmlContent = fs$1.readFileSync(indexHtmlPath, "utf8");
|
|
2654
|
+
fs$1.writeFileSync(indexHtmlPath, indexHtmlContent.replace("src/main.js", "src/main.ts"));
|
|
2819
2655
|
} else preOrderDirectoryTraverse(root, () => {}, (filepath) => {
|
|
2820
|
-
if (filepath.endsWith(".ts")) fs.unlinkSync(filepath);
|
|
2656
|
+
if (filepath.endsWith(".ts")) fs$1.unlinkSync(filepath);
|
|
2821
2657
|
});
|
|
2822
2658
|
if (needsBareboneTemplates) {
|
|
2823
2659
|
removeCSSImport(root, needsTypeScript, needsCypressCT);
|
|
@@ -2825,12 +2661,12 @@ async function init() {
|
|
|
2825
2661
|
}
|
|
2826
2662
|
const packageManager = result.packageManager ?? inferredPackageManager;
|
|
2827
2663
|
if (needsVueBeta) {
|
|
2828
|
-
const pkgPath = path$
|
|
2829
|
-
const pkg = JSON.parse(fs.readFileSync(pkgPath, "utf-8"));
|
|
2664
|
+
const pkgPath = path$2.resolve(root, "package.json");
|
|
2665
|
+
const pkg = JSON.parse(fs$1.readFileSync(pkgPath, "utf-8"));
|
|
2830
2666
|
applyVueBeta(root, packageManager, pkg);
|
|
2831
|
-
fs.writeFileSync(pkgPath, JSON.stringify(pkg, null, 2) + "\n");
|
|
2667
|
+
fs$1.writeFileSync(pkgPath, JSON.stringify(pkg, null, 2) + "\n");
|
|
2832
2668
|
}
|
|
2833
|
-
fs.writeFileSync(path$
|
|
2669
|
+
fs$1.writeFileSync(path$2.resolve(root, "README.md"), generateReadme({
|
|
2834
2670
|
projectName: result.projectName ?? result.packageName ?? defaultProjectName,
|
|
2835
2671
|
packageManager,
|
|
2836
2672
|
needsTypeScript,
|
|
@@ -2842,7 +2678,7 @@ async function init() {
|
|
|
2842
2678
|
}));
|
|
2843
2679
|
let outroMessage = `${language.infos.done}\n\n`;
|
|
2844
2680
|
if (root !== cwd) {
|
|
2845
|
-
const cdProjectName = path$
|
|
2681
|
+
const cdProjectName = path$2.relative(cwd, root);
|
|
2846
2682
|
outroMessage += ` ${(0, import_picocolors.bold)((0, import_picocolors.green)(`cd ${cdProjectName.includes(" ") ? `"${cdProjectName}"` : cdProjectName}`))}\n`;
|
|
2847
2683
|
}
|
|
2848
2684
|
outroMessage += ` ${(0, import_picocolors.bold)((0, import_picocolors.green)(getCommand(packageManager, "install")))}\n`;
|
|
@@ -2852,7 +2688,7 @@ async function init() {
|
|
|
2852
2688
|
${(0, import_picocolors.dim)("|")} ${language.infos.optionalGitCommand}
|
|
2853
2689
|
|
|
2854
2690
|
${(0, import_picocolors.bold)((0, import_picocolors.green)("git init && git add -A && git commit -m \"initial commit\""))}`;
|
|
2855
|
-
|
|
2691
|
+
outro(outroMessage);
|
|
2856
2692
|
}
|
|
2857
2693
|
init().catch((e) => {
|
|
2858
2694
|
console.error(e);
|