@oliasoft-open-source/node-json-migrator 5.4.0 → 5.4.1-beta-1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.mjs CHANGED
@@ -1,943 +1,127 @@
1
1
  import path from "path";
2
- import { lstatSync, promises, readdir, readdirSync, readlinkSync, realpathSync } from "fs";
3
- import process$1 from "node:process";
4
- import os from "node:os";
5
- import tty from "node:tty";
6
- import vm from "node:vm";
7
- import { produce } from "immer";
8
- import { createHash } from "crypto";
9
2
  import { fileURLToPath } from "node:url";
10
3
  import { posix, win32 } from "node:path";
4
+ import { lstatSync, promises, readdir, readdirSync, readlinkSync, realpathSync } from "fs";
11
5
  import * as xi from "node:fs";
12
6
  import { lstat, readdir as readdir$1, readlink, realpath } from "node:fs/promises";
13
7
  import { EventEmitter } from "node:events";
14
8
  import Pe from "node:stream";
15
9
  import { StringDecoder } from "node:string_decoder";
10
+ import vm from "node:vm";
11
+ import { produce } from "immer";
12
+ import { createHash } from "crypto";
13
+ import process$1 from "node:process";
14
+ import os from "node:os";
15
+ import tty from "node:tty";
16
16
  import process$2 from "process";
17
17
  import { execSync, spawn } from "child_process";
18
- //#region node_modules/.pnpm/chalk@5.6.2/node_modules/chalk/source/vendor/ansi-styles/index.js
19
- const ANSI_BACKGROUND_OFFSET = 10;
20
- const wrapAnsi16 = (offset = 0) => (code) => `\u001B[${code + offset}m`;
21
- const wrapAnsi256 = (offset = 0) => (code) => `\u001B[${38 + offset};5;${code}m`;
22
- const wrapAnsi16m = (offset = 0) => (red, green, blue) => `\u001B[${38 + offset};2;${red};${green};${blue}m`;
23
- const styles$1 = {
24
- modifier: {
25
- reset: [0, 0],
26
- bold: [1, 22],
27
- dim: [2, 22],
28
- italic: [3, 23],
29
- underline: [4, 24],
30
- overline: [53, 55],
31
- inverse: [7, 27],
32
- hidden: [8, 28],
33
- strikethrough: [9, 29]
34
- },
35
- color: {
36
- black: [30, 39],
37
- red: [31, 39],
38
- green: [32, 39],
39
- yellow: [33, 39],
40
- blue: [34, 39],
41
- magenta: [35, 39],
42
- cyan: [36, 39],
43
- white: [37, 39],
44
- blackBright: [90, 39],
45
- gray: [90, 39],
46
- grey: [90, 39],
47
- redBright: [91, 39],
48
- greenBright: [92, 39],
49
- yellowBright: [93, 39],
50
- blueBright: [94, 39],
51
- magentaBright: [95, 39],
52
- cyanBright: [96, 39],
53
- whiteBright: [97, 39]
54
- },
55
- bgColor: {
56
- bgBlack: [40, 49],
57
- bgRed: [41, 49],
58
- bgGreen: [42, 49],
59
- bgYellow: [43, 49],
60
- bgBlue: [44, 49],
61
- bgMagenta: [45, 49],
62
- bgCyan: [46, 49],
63
- bgWhite: [47, 49],
64
- bgBlackBright: [100, 49],
65
- bgGray: [100, 49],
66
- bgGrey: [100, 49],
67
- bgRedBright: [101, 49],
68
- bgGreenBright: [102, 49],
69
- bgYellowBright: [103, 49],
70
- bgBlueBright: [104, 49],
71
- bgMagentaBright: [105, 49],
72
- bgCyanBright: [106, 49],
73
- bgWhiteBright: [107, 49]
74
- }
75
- };
76
- Object.keys(styles$1.modifier);
77
- const foregroundColorNames = Object.keys(styles$1.color);
78
- const backgroundColorNames = Object.keys(styles$1.bgColor);
79
- [...foregroundColorNames, ...backgroundColorNames];
80
- function assembleStyles() {
81
- const codes = /* @__PURE__ */ new Map();
82
- for (const [groupName, group] of Object.entries(styles$1)) {
83
- for (const [styleName, style] of Object.entries(group)) {
84
- styles$1[styleName] = {
85
- open: `\u001B[${style[0]}m`,
86
- close: `\u001B[${style[1]}m`
87
- };
88
- group[styleName] = styles$1[styleName];
89
- codes.set(style[0], style[1]);
18
+ //#region node_modules/.pnpm/glob@13.0.6/node_modules/glob/dist/esm/index.min.js
19
+ var Gt = (n, t, e) => {
20
+ let s = n instanceof RegExp ? ce(n, e) : n, i = t instanceof RegExp ? ce(t, e) : t, r = s !== null && i != null && ss(s, i, e);
21
+ return r && {
22
+ start: r[0],
23
+ end: r[1],
24
+ pre: e.slice(0, r[0]),
25
+ body: e.slice(r[0] + s.length, r[1]),
26
+ post: e.slice(r[1] + i.length)
27
+ };
28
+ }, ce = (n, t) => {
29
+ let e = t.match(n);
30
+ return e ? e[0] : null;
31
+ }, ss = (n, t, e) => {
32
+ let s, i, r, o, h, a = e.indexOf(n), l = e.indexOf(t, a + 1), u = a;
33
+ if (a >= 0 && l > 0) {
34
+ if (n === t) return [a, l];
35
+ for (s = [], r = e.length; u >= 0 && !h;) {
36
+ if (u === a) s.push(u), a = e.indexOf(n, u + 1);
37
+ else if (s.length === 1) {
38
+ let c = s.pop();
39
+ c !== void 0 && (h = [c, l]);
40
+ } else i = s.pop(), i !== void 0 && i < r && (r = i, o = l), l = e.indexOf(t, u + 1);
41
+ u = a < l && a >= 0 ? a : l;
90
42
  }
91
- Object.defineProperty(styles$1, groupName, {
92
- value: group,
93
- enumerable: false
94
- });
43
+ s.length && o !== void 0 && (h = [r, o]);
95
44
  }
96
- Object.defineProperty(styles$1, "codes", {
97
- value: codes,
98
- enumerable: false
99
- });
100
- styles$1.color.close = "\x1B[39m";
101
- styles$1.bgColor.close = "\x1B[49m";
102
- styles$1.color.ansi = wrapAnsi16();
103
- styles$1.color.ansi256 = wrapAnsi256();
104
- styles$1.color.ansi16m = wrapAnsi16m();
105
- styles$1.bgColor.ansi = wrapAnsi16(ANSI_BACKGROUND_OFFSET);
106
- styles$1.bgColor.ansi256 = wrapAnsi256(ANSI_BACKGROUND_OFFSET);
107
- styles$1.bgColor.ansi16m = wrapAnsi16m(ANSI_BACKGROUND_OFFSET);
108
- Object.defineProperties(styles$1, {
109
- rgbToAnsi256: {
110
- value(red, green, blue) {
111
- if (red === green && green === blue) {
112
- if (red < 8) return 16;
113
- if (red > 248) return 231;
114
- return Math.round((red - 8) / 247 * 24) + 232;
115
- }
116
- return 16 + 36 * Math.round(red / 255 * 5) + 6 * Math.round(green / 255 * 5) + Math.round(blue / 255 * 5);
117
- },
118
- enumerable: false
119
- },
120
- hexToRgb: {
121
- value(hex) {
122
- const matches = /[a-f\d]{6}|[a-f\d]{3}/i.exec(hex.toString(16));
123
- if (!matches) return [
124
- 0,
125
- 0,
126
- 0
127
- ];
128
- let [colorString] = matches;
129
- if (colorString.length === 3) colorString = [...colorString].map((character) => character + character).join("");
130
- const integer = Number.parseInt(colorString, 16);
131
- return [
132
- integer >> 16 & 255,
133
- integer >> 8 & 255,
134
- integer & 255
135
- ];
136
- },
137
- enumerable: false
138
- },
139
- hexToAnsi256: {
140
- value: (hex) => styles$1.rgbToAnsi256(...styles$1.hexToRgb(hex)),
141
- enumerable: false
142
- },
143
- ansi256ToAnsi: {
144
- value(code) {
145
- if (code < 8) return 30 + code;
146
- if (code < 16) return 90 + (code - 8);
147
- let red;
148
- let green;
149
- let blue;
150
- if (code >= 232) {
151
- red = ((code - 232) * 10 + 8) / 255;
152
- green = red;
153
- blue = red;
154
- } else {
155
- code -= 16;
156
- const remainder = code % 36;
157
- red = Math.floor(code / 36) / 5;
158
- green = Math.floor(remainder / 6) / 5;
159
- blue = remainder % 6 / 5;
160
- }
161
- const value = Math.max(red, green, blue) * 2;
162
- if (value === 0) return 30;
163
- let result = 30 + (Math.round(blue) << 2 | Math.round(green) << 1 | Math.round(red));
164
- if (value === 2) result += 60;
165
- return result;
166
- },
167
- enumerable: false
168
- },
169
- rgbToAnsi: {
170
- value: (red, green, blue) => styles$1.ansi256ToAnsi(styles$1.rgbToAnsi256(red, green, blue)),
171
- enumerable: false
172
- },
173
- hexToAnsi: {
174
- value: (hex) => styles$1.ansi256ToAnsi(styles$1.hexToAnsi256(hex)),
175
- enumerable: false
176
- }
177
- });
178
- return styles$1;
45
+ return h;
46
+ };
47
+ var fe = "\0SLASH" + Math.random() + "\0", ue = "\0OPEN" + Math.random() + "\0", qt = "\0CLOSE" + Math.random() + "\0", de = "\0COMMA" + Math.random() + "\0", pe = "\0PERIOD" + Math.random() + "\0", is = new RegExp(fe, "g"), rs = new RegExp(ue, "g"), ns = new RegExp(qt, "g"), os$1 = new RegExp(de, "g"), hs = new RegExp(pe, "g"), as = /\\\\/g, ls = /\\{/g, cs = /\\}/g, fs = /\\,/g, us = /\\./g, ds = 1e5;
48
+ function Ht(n) {
49
+ return isNaN(n) ? n.charCodeAt(0) : parseInt(n, 10);
179
50
  }
180
- const ansiStyles = assembleStyles();
181
- //#endregion
182
- //#region node_modules/.pnpm/chalk@5.6.2/node_modules/chalk/source/vendor/supports-color/index.js
183
- function hasFlag(flag, argv = globalThis.Deno ? globalThis.Deno.args : process$1.argv) {
184
- const prefix = flag.startsWith("-") ? "" : flag.length === 1 ? "-" : "--";
185
- const position = argv.indexOf(prefix + flag);
186
- const terminatorPosition = argv.indexOf("--");
187
- return position !== -1 && (terminatorPosition === -1 || position < terminatorPosition);
51
+ function ps(n) {
52
+ return n.replace(as, fe).replace(ls, ue).replace(cs, qt).replace(fs, de).replace(us, pe);
188
53
  }
189
- const { env } = process$1;
190
- let flagForceColor;
191
- if (hasFlag("no-color") || hasFlag("no-colors") || hasFlag("color=false") || hasFlag("color=never")) flagForceColor = 0;
192
- else if (hasFlag("color") || hasFlag("colors") || hasFlag("color=true") || hasFlag("color=always")) flagForceColor = 1;
193
- function envForceColor() {
194
- if ("FORCE_COLOR" in env) {
195
- if (env.FORCE_COLOR === "true") return 1;
196
- if (env.FORCE_COLOR === "false") return 0;
197
- return env.FORCE_COLOR.length === 0 ? 1 : Math.min(Number.parseInt(env.FORCE_COLOR, 10), 3);
198
- }
54
+ function ms(n) {
55
+ return n.replace(is, "\\").replace(rs, "{").replace(ns, "}").replace(os$1, ",").replace(hs, ".");
199
56
  }
200
- function translateLevel(level) {
201
- if (level === 0) return false;
202
- return {
203
- level,
204
- hasBasic: true,
205
- has256: level >= 2,
206
- has16m: level >= 3
207
- };
57
+ function me(n) {
58
+ if (!n) return [""];
59
+ let t = [], e = Gt("{", "}", n);
60
+ if (!e) return n.split(",");
61
+ let { pre: s, body: i, post: r } = e, o = s.split(",");
62
+ o[o.length - 1] += "{" + i + "}";
63
+ let h = me(r);
64
+ return r.length && (o[o.length - 1] += h.shift(), o.push.apply(o, h)), t.push.apply(t, o), t;
208
65
  }
209
- function _supportsColor(haveStream, { streamIsTTY, sniffFlags = true } = {}) {
210
- const noFlagForceColor = envForceColor();
211
- if (noFlagForceColor !== void 0) flagForceColor = noFlagForceColor;
212
- const forceColor = sniffFlags ? flagForceColor : noFlagForceColor;
213
- if (forceColor === 0) return 0;
214
- if (sniffFlags) {
215
- if (hasFlag("color=16m") || hasFlag("color=full") || hasFlag("color=truecolor")) return 3;
216
- if (hasFlag("color=256")) return 2;
217
- }
218
- if ("TF_BUILD" in env && "AGENT_NAME" in env) return 1;
219
- if (haveStream && !streamIsTTY && forceColor === void 0) return 0;
220
- const min = forceColor || 0;
221
- if (env.TERM === "dumb") return min;
222
- if (process$1.platform === "win32") {
223
- const osRelease = os.release().split(".");
224
- if (Number(osRelease[0]) >= 10 && Number(osRelease[2]) >= 10586) return Number(osRelease[2]) >= 14931 ? 3 : 2;
225
- return 1;
226
- }
227
- if ("CI" in env) {
228
- if ([
229
- "GITHUB_ACTIONS",
230
- "GITEA_ACTIONS",
231
- "CIRCLECI"
232
- ].some((key) => key in env)) return 3;
233
- if ([
234
- "TRAVIS",
235
- "APPVEYOR",
236
- "GITLAB_CI",
237
- "BUILDKITE",
238
- "DRONE"
239
- ].some((sign) => sign in env) || env.CI_NAME === "codeship") return 1;
240
- return min;
241
- }
242
- if ("TEAMCITY_VERSION" in env) return /^(9\.(0*[1-9]\d*)\.|\d{2,}\.)/.test(env.TEAMCITY_VERSION) ? 1 : 0;
243
- if (env.COLORTERM === "truecolor") return 3;
244
- if (env.TERM === "xterm-kitty") return 3;
245
- if (env.TERM === "xterm-ghostty") return 3;
246
- if (env.TERM === "wezterm") return 3;
247
- if ("TERM_PROGRAM" in env) {
248
- const version = Number.parseInt((env.TERM_PROGRAM_VERSION || "").split(".")[0], 10);
249
- switch (env.TERM_PROGRAM) {
250
- case "iTerm.app": return version >= 3 ? 3 : 2;
251
- case "Apple_Terminal": return 2;
252
- }
253
- }
254
- if (/-256(color)?$/i.test(env.TERM)) return 2;
255
- if (/^screen|^xterm|^vt100|^vt220|^rxvt|color|ansi|cygwin|linux/i.test(env.TERM)) return 1;
256
- if ("COLORTERM" in env) return 1;
257
- return min;
66
+ function ge(n, t = {}) {
67
+ if (!n) return [];
68
+ let { max: e = ds } = t;
69
+ return n.slice(0, 2) === "{}" && (n = "\\{\\}" + n.slice(2)), ht(ps(n), e, !0).map(ms);
258
70
  }
259
- function createSupportsColor(stream, options = {}) {
260
- return translateLevel(_supportsColor(stream, {
261
- streamIsTTY: stream && stream.isTTY,
262
- ...options
263
- }));
71
+ function gs(n) {
72
+ return "{" + n + "}";
264
73
  }
265
- const supportsColor = {
266
- stdout: createSupportsColor({ isTTY: tty.isatty(1) }),
267
- stderr: createSupportsColor({ isTTY: tty.isatty(2) })
268
- };
269
- //#endregion
270
- //#region node_modules/.pnpm/chalk@5.6.2/node_modules/chalk/source/utilities.js
271
- function stringReplaceAll(string, substring, replacer) {
272
- let index = string.indexOf(substring);
273
- if (index === -1) return string;
274
- const substringLength = substring.length;
275
- let endIndex = 0;
276
- let returnValue = "";
277
- do {
278
- returnValue += string.slice(endIndex, index) + substring + replacer;
279
- endIndex = index + substringLength;
280
- index = string.indexOf(substring, endIndex);
281
- } while (index !== -1);
282
- returnValue += string.slice(endIndex);
283
- return returnValue;
74
+ function ws(n) {
75
+ return /^-?0\d/.test(n);
284
76
  }
285
- function stringEncaseCRLFWithFirstIndex(string, prefix, postfix, index) {
286
- let endIndex = 0;
287
- let returnValue = "";
288
- do {
289
- const gotCR = string[index - 1] === "\r";
290
- returnValue += string.slice(endIndex, gotCR ? index - 1 : index) + prefix + (gotCR ? "\r\n" : "\n") + postfix;
291
- endIndex = index + 1;
292
- index = string.indexOf("\n", endIndex);
293
- } while (index !== -1);
294
- returnValue += string.slice(endIndex);
295
- return returnValue;
77
+ function ys(n, t) {
78
+ return n <= t;
296
79
  }
297
- //#endregion
298
- //#region node_modules/.pnpm/chalk@5.6.2/node_modules/chalk/source/index.js
299
- const { stdout: stdoutColor, stderr: stderrColor } = supportsColor;
300
- const GENERATOR = Symbol("GENERATOR");
301
- const STYLER = Symbol("STYLER");
302
- const IS_EMPTY = Symbol("IS_EMPTY");
303
- const levelMapping = [
304
- "ansi",
305
- "ansi",
306
- "ansi256",
307
- "ansi16m"
308
- ];
309
- const styles = Object.create(null);
310
- const applyOptions = (object, options = {}) => {
311
- if (options.level && !(Number.isInteger(options.level) && options.level >= 0 && options.level <= 3)) throw new Error("The `level` option should be an integer from 0 to 3");
312
- const colorLevel = stdoutColor ? stdoutColor.level : 0;
313
- object.level = options.level === void 0 ? colorLevel : options.level;
314
- };
315
- const chalkFactory = (options) => {
316
- const chalk = (...strings) => strings.join(" ");
317
- applyOptions(chalk, options);
318
- Object.setPrototypeOf(chalk, createChalk.prototype);
319
- return chalk;
320
- };
321
- function createChalk(options) {
322
- return chalkFactory(options);
80
+ function bs(n, t) {
81
+ return n >= t;
323
82
  }
324
- Object.setPrototypeOf(createChalk.prototype, Function.prototype);
325
- for (const [styleName, style] of Object.entries(ansiStyles)) styles[styleName] = { get() {
326
- const builder = createBuilder(this, createStyler(style.open, style.close, this[STYLER]), this[IS_EMPTY]);
327
- Object.defineProperty(this, styleName, { value: builder });
328
- return builder;
329
- } };
330
- styles.visible = { get() {
331
- const builder = createBuilder(this, this[STYLER], true);
332
- Object.defineProperty(this, "visible", { value: builder });
333
- return builder;
334
- } };
335
- const getModelAnsi = (model, level, type, ...arguments_) => {
336
- if (model === "rgb") {
337
- if (level === "ansi16m") return ansiStyles[type].ansi16m(...arguments_);
338
- if (level === "ansi256") return ansiStyles[type].ansi256(ansiStyles.rgbToAnsi256(...arguments_));
339
- return ansiStyles[type].ansi(ansiStyles.rgbToAnsi(...arguments_));
83
+ function ht(n, t, e) {
84
+ let s = [], i = Gt("{", "}", n);
85
+ if (!i) return [n];
86
+ let r = i.pre, o = i.post.length ? ht(i.post, t, !1) : [""];
87
+ if (/\$$/.test(i.pre)) for (let h = 0; h < o.length && h < t; h++) {
88
+ let a = r + "{" + i.body + "}" + o[h];
89
+ s.push(a);
340
90
  }
341
- if (model === "hex") return getModelAnsi("rgb", level, type, ...ansiStyles.hexToRgb(...arguments_));
342
- return ansiStyles[type][model](...arguments_);
343
- };
344
- for (const model of [
345
- "rgb",
346
- "hex",
347
- "ansi256"
348
- ]) {
349
- styles[model] = { get() {
350
- const { level } = this;
351
- return function(...arguments_) {
352
- const styler = createStyler(getModelAnsi(model, levelMapping[level], "color", ...arguments_), ansiStyles.color.close, this[STYLER]);
353
- return createBuilder(this, styler, this[IS_EMPTY]);
354
- };
355
- } };
356
- const bgModel = "bg" + model[0].toUpperCase() + model.slice(1);
357
- styles[bgModel] = { get() {
358
- const { level } = this;
359
- return function(...arguments_) {
360
- const styler = createStyler(getModelAnsi(model, levelMapping[level], "bgColor", ...arguments_), ansiStyles.bgColor.close, this[STYLER]);
361
- return createBuilder(this, styler, this[IS_EMPTY]);
362
- };
363
- } };
364
- }
365
- const proto = Object.defineProperties(() => {}, {
366
- ...styles,
367
- level: {
368
- enumerable: true,
369
- get() {
370
- return this[GENERATOR].level;
371
- },
372
- set(level) {
373
- this[GENERATOR].level = level;
91
+ else {
92
+ let h = /^-?\d+\.\.-?\d+(?:\.\.-?\d+)?$/.test(i.body), a = /^[a-zA-Z]\.\.[a-zA-Z](?:\.\.-?\d+)?$/.test(i.body), l = h || a, u = i.body.indexOf(",") >= 0;
93
+ if (!l && !u) return i.post.match(/,(?!,).*\}/) ? (n = i.pre + "{" + i.body + qt + i.post, ht(n, t, !0)) : [n];
94
+ let c;
95
+ if (l) c = i.body.split(/\.\./);
96
+ else if (c = me(i.body), c.length === 1 && c[0] !== void 0 && (c = ht(c[0], t, !1).map(gs), c.length === 1)) return o.map((f) => i.pre + c[0] + f);
97
+ let d;
98
+ if (l && c[0] !== void 0 && c[1] !== void 0) {
99
+ let f = Ht(c[0]), m = Ht(c[1]), p = Math.max(c[0].length, c[1].length), w = c.length === 3 && c[2] !== void 0 ? Math.abs(Ht(c[2])) : 1, g = ys;
100
+ m < f && (w *= -1, g = bs);
101
+ let E = c.some(ws);
102
+ d = [];
103
+ for (let y = f; g(y, m); y += w) {
104
+ let b;
105
+ if (a) b = String.fromCharCode(y), b === "\\" && (b = "");
106
+ else if (b = String(y), E) {
107
+ let z = p - b.length;
108
+ if (z > 0) {
109
+ let $ = new Array(z + 1).join("0");
110
+ y < 0 ? b = "-" + $ + b.slice(1) : b = $ + b;
111
+ }
112
+ }
113
+ d.push(b);
114
+ }
115
+ } else {
116
+ d = [];
117
+ for (let f = 0; f < c.length; f++) d.push.apply(d, ht(c[f], t, !1));
118
+ }
119
+ for (let f = 0; f < d.length; f++) for (let m = 0; m < o.length && s.length < t; m++) {
120
+ let p = r + d[f] + o[m];
121
+ (!e || l || p) && s.push(p);
374
122
  }
375
123
  }
376
- });
377
- const createStyler = (open, close, parent) => {
378
- let openAll;
379
- let closeAll;
380
- if (parent === void 0) {
381
- openAll = open;
382
- closeAll = close;
383
- } else {
384
- openAll = parent.openAll + open;
385
- closeAll = close + parent.closeAll;
386
- }
387
- return {
388
- open,
389
- close,
390
- openAll,
391
- closeAll,
392
- parent
393
- };
394
- };
395
- const createBuilder = (self, _styler, _isEmpty) => {
396
- const builder = (...arguments_) => applyStyle(builder, arguments_.length === 1 ? "" + arguments_[0] : arguments_.join(" "));
397
- Object.setPrototypeOf(builder, proto);
398
- builder[GENERATOR] = self;
399
- builder[STYLER] = _styler;
400
- builder[IS_EMPTY] = _isEmpty;
401
- return builder;
402
- };
403
- const applyStyle = (self, string) => {
404
- if (self.level <= 0 || !string) return self[IS_EMPTY] ? "" : string;
405
- let styler = self[STYLER];
406
- if (styler === void 0) return string;
407
- const { openAll, closeAll } = styler;
408
- if (string.includes("\x1B")) while (styler !== void 0) {
409
- string = stringReplaceAll(string, styler.close, styler.open);
410
- styler = styler.parent;
411
- }
412
- const lfIndex = string.indexOf("\n");
413
- if (lfIndex !== -1) string = stringEncaseCRLFWithFirstIndex(string, closeAll, openAll, lfIndex);
414
- return openAll + string + closeAll;
415
- };
416
- Object.defineProperties(createChalk.prototype, styles);
417
- const chalk = createChalk();
418
- createChalk({ level: stderrColor ? stderrColor.level : 0 });
419
- //#endregion
420
- //#region node_modules/.pnpm/es-toolkit@1.45.1/node_modules/es-toolkit/dist/array/difference.mjs
421
- function difference(firstArr, secondArr) {
422
- const secondSet = new Set(secondArr);
423
- return firstArr.filter((item) => !secondSet.has(item));
424
- }
425
- //#endregion
426
- //#region node_modules/.pnpm/es-toolkit@1.45.1/node_modules/es-toolkit/dist/array/flatten.mjs
427
- function flatten(arr, depth = 1) {
428
- const result = [];
429
- const flooredDepth = Math.floor(depth);
430
- const recursive = (arr, currentDepth) => {
431
- for (let i = 0; i < arr.length; i++) {
432
- const item = arr[i];
433
- if (Array.isArray(item) && currentDepth < flooredDepth) recursive(item, currentDepth + 1);
434
- else result.push(item);
435
- }
436
- };
437
- recursive(arr, 0);
438
- return result;
439
- }
440
- //#endregion
441
- //#region node_modules/.pnpm/es-toolkit@1.45.1/node_modules/es-toolkit/dist/array/intersection.mjs
442
- function intersection(firstArr, secondArr) {
443
- const secondSet = new Set(secondArr);
444
- return firstArr.filter((item) => secondSet.has(item));
445
- }
446
- //#endregion
447
- //#region node_modules/.pnpm/es-toolkit@1.45.1/node_modules/es-toolkit/dist/compat/predicate/isSymbol.mjs
448
- function isSymbol(value) {
449
- return typeof value === "symbol" || value instanceof Symbol;
450
- }
451
- //#endregion
452
- //#region node_modules/.pnpm/es-toolkit@1.45.1/node_modules/es-toolkit/dist/array/uniq.mjs
453
- function uniq(arr) {
454
- return [...new Set(arr)];
455
- }
456
- //#endregion
457
- //#region node_modules/.pnpm/es-toolkit@1.45.1/node_modules/es-toolkit/dist/array/union.mjs
458
- function union(arr1, arr2) {
459
- return uniq(arr1.concat(arr2));
460
- }
461
- //#endregion
462
- //#region node_modules/.pnpm/es-toolkit@1.45.1/node_modules/es-toolkit/dist/array/xor.mjs
463
- function xor(arr1, arr2) {
464
- return difference(union(arr1, arr2), intersection(arr1, arr2));
465
- }
466
- //#endregion
467
- //#region node_modules/.pnpm/es-toolkit@1.45.1/node_modules/es-toolkit/dist/function/noop.mjs
468
- function noop() {}
469
- //#endregion
470
- //#region node_modules/.pnpm/es-toolkit@1.45.1/node_modules/es-toolkit/dist/predicate/isPlainObject.mjs
471
- function isPlainObject(value) {
472
- if (!value || typeof value !== "object") return false;
473
- const proto = Object.getPrototypeOf(value);
474
- if (!(proto === null || proto === Object.prototype || Object.getPrototypeOf(proto) === null)) return false;
475
- return Object.prototype.toString.call(value) === "[object Object]";
476
- }
477
- //#endregion
478
- //#region node_modules/.pnpm/es-toolkit@1.45.1/node_modules/es-toolkit/dist/_internal/isUnsafeProperty.mjs
479
- function isUnsafeProperty(key) {
480
- return key === "__proto__";
481
- }
482
- //#endregion
483
- //#region node_modules/.pnpm/es-toolkit@1.45.1/node_modules/es-toolkit/dist/object/merge.mjs
484
- function merge(target, source) {
485
- const sourceKeys = Object.keys(source);
486
- for (let i = 0; i < sourceKeys.length; i++) {
487
- const key = sourceKeys[i];
488
- if (isUnsafeProperty(key)) continue;
489
- const sourceValue = source[key];
490
- const targetValue = target[key];
491
- if (isMergeableValue(sourceValue) && isMergeableValue(targetValue)) target[key] = merge(targetValue, sourceValue);
492
- else if (Array.isArray(sourceValue)) target[key] = merge([], sourceValue);
493
- else if (isPlainObject(sourceValue)) target[key] = merge({}, sourceValue);
494
- else if (targetValue === void 0 || sourceValue !== void 0) target[key] = sourceValue;
495
- }
496
- return target;
497
- }
498
- function isMergeableValue(value) {
499
- return isPlainObject(value) || Array.isArray(value);
500
- }
501
- //#endregion
502
- //#region node_modules/.pnpm/es-toolkit@1.45.1/node_modules/es-toolkit/dist/object/omit.mjs
503
- function omit(obj, keys) {
504
- const result = { ...obj };
505
- for (let i = 0; i < keys.length; i++) {
506
- const key = keys[i];
507
- delete result[key];
508
- }
509
- return result;
510
- }
511
- //#endregion
512
- //#region node_modules/.pnpm/es-toolkit@1.45.1/node_modules/es-toolkit/dist/_internal/isEqualsSameValueZero.mjs
513
- function isEqualsSameValueZero(value, other) {
514
- return value === other || Number.isNaN(value) && Number.isNaN(other);
515
- }
516
- //#endregion
517
- //#region node_modules/.pnpm/es-toolkit@1.45.1/node_modules/es-toolkit/dist/predicate/isLength.mjs
518
- function isLength(value) {
519
- return Number.isSafeInteger(value) && value >= 0;
520
- }
521
- //#endregion
522
- //#region node_modules/.pnpm/es-toolkit@1.45.1/node_modules/es-toolkit/dist/predicate/isString.mjs
523
- function isString(value) {
524
- return typeof value === "string";
525
- }
526
- //#endregion
527
- //#region src/validator/ajv-validators.ts
528
- const planSchemaValidator = validate14;
529
- const schema32 = {
530
- "type": "array",
531
- "items": {
532
- "type": "object",
533
- "properties": {
534
- "fileHash": { "type": ["string"] },
535
- "fileName": { "type": "string" },
536
- "sequence": {
537
- "type": "string",
538
- "pattern": "^[1-9][0-9]*(.[1-9][0-9]*)*$"
539
- }
540
- },
541
- "required": [
542
- "fileHash",
543
- "fileName",
544
- "sequence"
545
- ],
546
- "additionalProperties": false
547
- }
548
- };
549
- const pattern0 = /* @__PURE__ */ new RegExp("^[1-9][0-9]*(.[1-9][0-9]*)*$", "u");
550
- function validate14(data, { instancePath = "", parentData, parentDataProperty, rootData = data } = {}) {
551
- let vErrors = null;
552
- let errors = 0;
553
- if (Array.isArray(data)) {
554
- const len0 = data.length;
555
- for (let i0 = 0; i0 < len0; i0++) {
556
- let data0 = data[i0];
557
- if (data0 && typeof data0 == "object" && !Array.isArray(data0)) {
558
- if (data0.fileHash === void 0) {
559
- const err0 = {
560
- instancePath: instancePath + "/" + i0,
561
- schemaPath: "#/items/required",
562
- keyword: "required",
563
- params: { missingProperty: "fileHash" },
564
- message: "must have required property 'fileHash'"
565
- };
566
- if (vErrors === null) vErrors = [err0];
567
- else vErrors.push(err0);
568
- errors++;
569
- }
570
- if (data0.fileName === void 0) {
571
- const err1 = {
572
- instancePath: instancePath + "/" + i0,
573
- schemaPath: "#/items/required",
574
- keyword: "required",
575
- params: { missingProperty: "fileName" },
576
- message: "must have required property 'fileName'"
577
- };
578
- if (vErrors === null) vErrors = [err1];
579
- else vErrors.push(err1);
580
- errors++;
581
- }
582
- if (data0.sequence === void 0) {
583
- const err2 = {
584
- instancePath: instancePath + "/" + i0,
585
- schemaPath: "#/items/required",
586
- keyword: "required",
587
- params: { missingProperty: "sequence" },
588
- message: "must have required property 'sequence'"
589
- };
590
- if (vErrors === null) vErrors = [err2];
591
- else vErrors.push(err2);
592
- errors++;
593
- }
594
- for (const key0 in data0) if (!(key0 === "fileHash" || key0 === "fileName" || key0 === "sequence")) {
595
- const err3 = {
596
- instancePath: instancePath + "/" + i0,
597
- schemaPath: "#/items/additionalProperties",
598
- keyword: "additionalProperties",
599
- params: { additionalProperty: key0 },
600
- message: "must NOT have additional properties"
601
- };
602
- if (vErrors === null) vErrors = [err3];
603
- else vErrors.push(err3);
604
- errors++;
605
- }
606
- if (data0.fileHash !== void 0) {
607
- if (typeof data0.fileHash !== "string") {
608
- const err4 = {
609
- instancePath: instancePath + "/" + i0 + "/fileHash",
610
- schemaPath: "#/items/properties/fileHash/type",
611
- keyword: "type",
612
- params: { type: schema32.items.properties.fileHash.type },
613
- message: "must be string"
614
- };
615
- if (vErrors === null) vErrors = [err4];
616
- else vErrors.push(err4);
617
- errors++;
618
- }
619
- }
620
- if (data0.fileName !== void 0) {
621
- if (typeof data0.fileName !== "string") {
622
- const err5 = {
623
- instancePath: instancePath + "/" + i0 + "/fileName",
624
- schemaPath: "#/items/properties/fileName/type",
625
- keyword: "type",
626
- params: { type: "string" },
627
- message: "must be string"
628
- };
629
- if (vErrors === null) vErrors = [err5];
630
- else vErrors.push(err5);
631
- errors++;
632
- }
633
- }
634
- if (data0.sequence !== void 0) {
635
- let data3 = data0.sequence;
636
- if (typeof data3 === "string") {
637
- if (!pattern0.test(data3)) {
638
- const err6 = {
639
- instancePath: instancePath + "/" + i0 + "/sequence",
640
- schemaPath: "#/items/properties/sequence/pattern",
641
- keyword: "pattern",
642
- params: { pattern: "^[1-9][0-9]*(.[1-9][0-9]*)*$" },
643
- message: "must match pattern \"^[1-9][0-9]*(.[1-9][0-9]*)*$\""
644
- };
645
- if (vErrors === null) vErrors = [err6];
646
- else vErrors.push(err6);
647
- errors++;
648
- }
649
- } else {
650
- const err7 = {
651
- instancePath: instancePath + "/" + i0 + "/sequence",
652
- schemaPath: "#/items/properties/sequence/type",
653
- keyword: "type",
654
- params: { type: "string" },
655
- message: "must be string"
656
- };
657
- if (vErrors === null) vErrors = [err7];
658
- else vErrors.push(err7);
659
- errors++;
660
- }
661
- }
662
- } else {
663
- const err8 = {
664
- instancePath: instancePath + "/" + i0,
665
- schemaPath: "#/items/type",
666
- keyword: "type",
667
- params: { type: "object" },
668
- message: "must be object"
669
- };
670
- if (vErrors === null) vErrors = [err8];
671
- else vErrors.push(err8);
672
- errors++;
673
- }
674
- }
675
- } else {
676
- const err9 = {
677
- instancePath,
678
- schemaPath: "#/type",
679
- keyword: "type",
680
- params: { type: "array" },
681
- message: "must be array"
682
- };
683
- if (vErrors === null) vErrors = [err9];
684
- else vErrors.push(err9);
685
- errors++;
686
- }
687
- validate14.errors = vErrors;
688
- return errors === 0;
689
- }
690
- //#endregion
691
- //#region src/validator/validator.ts
692
- const isNonEmptyString = (input) => isString(input) && input.length > 0;
693
- /**
694
- * Validates if a plan matches the schema
695
- */
696
- const validatePlan = (plan) => {
697
- const valid = planSchemaValidator(plan);
698
- const errors = planSchemaValidator.errors;
699
- if (errors?.length) errors.forEach((e) => console.error(`${e.message}${e.instancePath ? `at ${e.instancePath}` : ""}`));
700
- return valid;
701
- };
702
- /**
703
- * Validates if file description format is valid
704
- */
705
- const validateFileDescription = (description) => {
706
- if (!description) return false;
707
- return /^([a-z]+|(([a-z]+-)+[a-z]+))$/g.test(description);
708
- };
709
- /**
710
- * Validates if fileName format is valid
711
- */
712
- const validateFileName = (fileName) => {
713
- return /^([a-z]+|(([a-z]+-)+[a-z]+))(.js|.skip.js)$/g.test(fileName);
714
- };
715
- /**
716
- * Throws if file names are invalid
717
- */
718
- const throwIfFileNamesInvalid = (fileEntries) => {
719
- const invalidFileNames = fileEntries.filter((f) => !f.isValidFileName).map((f) => f.fileName);
720
- if (invalidFileNames.length) {
721
- invalidFileNames.forEach((name) => console.error(chalk.red(name)));
722
- throw new Error("Invalid migration filename format (use kebab-case)");
723
- }
724
- };
725
- /**
726
- * Warns if files have been removed
727
- */
728
- const warnIfFilesHaveBeenRemovedFromPlan = (migrationEntries, historicalMigrations) => {
729
- const fileNames = migrationEntries.map((f) => f.fileName);
730
- const deletedFilesNames = historicalMigrations.filter((e) => !fileNames.includes(e.fileName)).map((e) => e.fileName);
731
- if (deletedFilesNames.length) {
732
- deletedFilesNames.forEach((name) => console.warn(chalk.yellow(name)));
733
- console.warn(chalk.yellow("Previously executed migration files have been deleted from plan.json (rename file to .skip.js and replace with a new file instead)"));
734
- }
735
- };
736
- /**
737
- * Throws error if any pre-existing file has changed
738
- */
739
- const throwIfFilesHaveChanged = (migrationEntries) => {
740
- const changedFilesNames = migrationEntries.filter((m) => {
741
- const { fileHash, fileHashFromPlan, fileHashFromHistory, skippedFileHashes } = m;
742
- const matchesHistory = !isNonEmptyString(fileHashFromHistory) || [fileHash].concat(skippedFileHashes).includes(fileHashFromHistory);
743
- const matchesPlan = !isNonEmptyString(fileHashFromPlan) || [fileHash].concat(skippedFileHashes).includes(fileHashFromPlan);
744
- return !(matchesHistory && matchesPlan);
745
- }).map((f) => f.fileName);
746
- if (changedFilesNames.length) {
747
- changedFilesNames.forEach((name) => console.error(chalk.red(name)));
748
- throw new Error("Not allowed to change migration files (for unreleased local work, you can use the `force` option)");
749
- }
750
- };
751
- /**
752
- * Throws error if previous sequence numbers have changed
753
- */
754
- const throwIfSequenceHasChanged = (migrationEntries) => {
755
- const changeSequences = migrationEntries.filter((m) => {
756
- const { sequence, sequenceFromHistory } = m;
757
- return isString(sequenceFromHistory) && sequenceFromHistory !== sequence;
758
- }).map((f) => f.fileName);
759
- if (changeSequences.length) {
760
- changeSequences.forEach((name) => console.error(chalk.red(name)));
761
- throw new Error("Not allowed to change migration sequences in plan.json");
762
- }
763
- };
764
- /**
765
- * Throws error if sequence numbers are not unique
766
- */
767
- const throwIfSequenceNotUnique = (migrationEntries) => {
768
- const repeatedSequenceNumbers = migrationEntries.map((f) => f.sequence).filter(((s) => (v) => s.has(v) || !s.add(v))(/* @__PURE__ */ new Set()));
769
- const duplicates = migrationEntries.filter((f) => repeatedSequenceNumbers.includes(f.sequence)).map((f) => f.fileName);
770
- if (duplicates.length) {
771
- duplicates.forEach((fileName) => console.error(chalk.red(fileName)));
772
- throw new Error("Migrations must have unique sequence numbers in plan.json");
773
- }
774
- };
775
- /**
776
- * Throws error if sequence numbers are not unique
777
- */
778
- const throwIfSequenceHasIntegerGaps = (migrationEntries) => {
779
- const toInteger = (sequence) => parseInt(sequence.split(".")[0], 10);
780
- const unique = (arr) => Array.from(new Set(arr));
781
- const orderedUniqueSequenceIntegers = unique(migrationEntries.map((s) => s.sequence).map((s) => toInteger(s))).sort((a, b) => a - b);
782
- const max = orderedUniqueSequenceIntegers[orderedUniqueSequenceIntegers.length - 1];
783
- const missing = xor(orderedUniqueSequenceIntegers, Array.from({ length: max }, (_v, k) => k + 1));
784
- if (missing.length) throw new Error(`Migration sequence numbers in plan.json have unexpected gaps: ${missing.join(", ")}`);
785
- };
786
- /**
787
- * Throws error if file names are not unique
788
- */
789
- const throwIfFileNamesNotUnique = (migrationEntries) => {
790
- const repeatedFileNames = migrationEntries.map((f) => f.fileName).filter(((s) => (v) => s.has(v) || !s.add(v))(/* @__PURE__ */ new Set()));
791
- if (repeatedFileNames.length) {
792
- repeatedFileNames.forEach((fileName) => console.error(chalk.red(fileName)));
793
- throw new Error("Migration file names must be unique");
794
- }
795
- };
796
- /**
797
- * Throws error if files listed in plan.json are found
798
- */
799
- const throwIfFilesNotFound = (migrationEntries) => {
800
- const migrationsWithoutFiles = migrationEntries.filter((m) => !m.script || !m.script && !m.migrator);
801
- if (migrationsWithoutFiles.length) {
802
- migrationsWithoutFiles.forEach((migration) => console.error(chalk.red(migration.fileName)));
803
- throw new Error("Migration files from plan.json are missing from filesystem");
804
- }
805
- };
806
- //#endregion
807
- //#region src/helpers/helpers.ts
808
- const capitalize = (word) => {
809
- if (!word) return "";
810
- return word[0].toUpperCase() + word.slice(1);
811
- };
812
- //#endregion
813
- //#region src/plan/loader-module.ts
814
- const lazyImportMigration = (script) => {
815
- if (!script) return noop;
816
- const patchedScript = script.replace(/import\s+\{?\s*produce\s*}?\s+from\s+['"]immer['"];?/, "").replace(/export\s+default\s+/, "const migration = ").replace(/export\s+(const|function|async function)\s+/g, "$1 ");
817
- return (payload, metaData) => {
818
- const context = {
819
- payload,
820
- metaData,
821
- produce
822
- };
823
- return vm.runInNewContext(`${patchedScript}; migration(payload, metaData);`, context);
824
- };
825
- };
826
- const LoaderModule = { lazyImportMigration };
827
- //#endregion
828
- //#region src/hash/hash.ts
829
- /**
830
- * Generate SHA256 hash from a string
831
- */
832
- const hash = (string) => createHash("sha256").update(string).digest("hex");
833
- //#endregion
834
- //#region node_modules/.pnpm/glob@13.0.6/node_modules/glob/dist/esm/index.min.js
835
- var Gt = (n, t, e) => {
836
- let s = n instanceof RegExp ? ce(n, e) : n, i = t instanceof RegExp ? ce(t, e) : t, r = s !== null && i != null && ss(s, i, e);
837
- return r && {
838
- start: r[0],
839
- end: r[1],
840
- pre: e.slice(0, r[0]),
841
- body: e.slice(r[0] + s.length, r[1]),
842
- post: e.slice(r[1] + i.length)
843
- };
844
- }, ce = (n, t) => {
845
- let e = t.match(n);
846
- return e ? e[0] : null;
847
- }, ss = (n, t, e) => {
848
- let s, i, r, o, h, a = e.indexOf(n), l = e.indexOf(t, a + 1), u = a;
849
- if (a >= 0 && l > 0) {
850
- if (n === t) return [a, l];
851
- for (s = [], r = e.length; u >= 0 && !h;) {
852
- if (u === a) s.push(u), a = e.indexOf(n, u + 1);
853
- else if (s.length === 1) {
854
- let c = s.pop();
855
- c !== void 0 && (h = [c, l]);
856
- } else i = s.pop(), i !== void 0 && i < r && (r = i, o = l), l = e.indexOf(t, u + 1);
857
- u = a < l && a >= 0 ? a : l;
858
- }
859
- s.length && o !== void 0 && (h = [r, o]);
860
- }
861
- return h;
862
- };
863
- var fe = "\0SLASH" + Math.random() + "\0", ue = "\0OPEN" + Math.random() + "\0", qt = "\0CLOSE" + Math.random() + "\0", de = "\0COMMA" + Math.random() + "\0", pe = "\0PERIOD" + Math.random() + "\0", is = new RegExp(fe, "g"), rs = new RegExp(ue, "g"), ns = new RegExp(qt, "g"), os$1 = new RegExp(de, "g"), hs = new RegExp(pe, "g"), as = /\\\\/g, ls = /\\{/g, cs = /\\}/g, fs = /\\,/g, us = /\\./g, ds = 1e5;
864
- function Ht(n) {
865
- return isNaN(n) ? n.charCodeAt(0) : parseInt(n, 10);
866
- }
867
- function ps(n) {
868
- return n.replace(as, fe).replace(ls, ue).replace(cs, qt).replace(fs, de).replace(us, pe);
869
- }
870
- function ms(n) {
871
- return n.replace(is, "\\").replace(rs, "{").replace(ns, "}").replace(os$1, ",").replace(hs, ".");
872
- }
873
- function me(n) {
874
- if (!n) return [""];
875
- let t = [], e = Gt("{", "}", n);
876
- if (!e) return n.split(",");
877
- let { pre: s, body: i, post: r } = e, o = s.split(",");
878
- o[o.length - 1] += "{" + i + "}";
879
- let h = me(r);
880
- return r.length && (o[o.length - 1] += h.shift(), o.push.apply(o, h)), t.push.apply(t, o), t;
881
- }
882
- function ge(n, t = {}) {
883
- if (!n) return [];
884
- let { max: e = ds } = t;
885
- return n.slice(0, 2) === "{}" && (n = "\\{\\}" + n.slice(2)), ht(ps(n), e, !0).map(ms);
886
- }
887
- function gs(n) {
888
- return "{" + n + "}";
889
- }
890
- function ws(n) {
891
- return /^-?0\d/.test(n);
892
- }
893
- function ys(n, t) {
894
- return n <= t;
895
- }
896
- function bs(n, t) {
897
- return n >= t;
898
- }
899
- function ht(n, t, e) {
900
- let s = [], i = Gt("{", "}", n);
901
- if (!i) return [n];
902
- let r = i.pre, o = i.post.length ? ht(i.post, t, !1) : [""];
903
- if (/\$$/.test(i.pre)) for (let h = 0; h < o.length && h < t; h++) {
904
- let a = r + "{" + i.body + "}" + o[h];
905
- s.push(a);
906
- }
907
- else {
908
- let h = /^-?\d+\.\.-?\d+(?:\.\.-?\d+)?$/.test(i.body), a = /^[a-zA-Z]\.\.[a-zA-Z](?:\.\.-?\d+)?$/.test(i.body), l = h || a, u = i.body.indexOf(",") >= 0;
909
- if (!l && !u) return i.post.match(/,(?!,).*\}/) ? (n = i.pre + "{" + i.body + qt + i.post, ht(n, t, !0)) : [n];
910
- let c;
911
- if (l) c = i.body.split(/\.\./);
912
- else if (c = me(i.body), c.length === 1 && c[0] !== void 0 && (c = ht(c[0], t, !1).map(gs), c.length === 1)) return o.map((f) => i.pre + c[0] + f);
913
- let d;
914
- if (l && c[0] !== void 0 && c[1] !== void 0) {
915
- let f = Ht(c[0]), m = Ht(c[1]), p = Math.max(c[0].length, c[1].length), w = c.length === 3 && c[2] !== void 0 ? Math.abs(Ht(c[2])) : 1, g = ys;
916
- m < f && (w *= -1, g = bs);
917
- let E = c.some(ws);
918
- d = [];
919
- for (let y = f; g(y, m); y += w) {
920
- let b;
921
- if (a) b = String.fromCharCode(y), b === "\\" && (b = "");
922
- else if (b = String(y), E) {
923
- let z = p - b.length;
924
- if (z > 0) {
925
- let $ = new Array(z + 1).join("0");
926
- y < 0 ? b = "-" + $ + b.slice(1) : b = $ + b;
927
- }
928
- }
929
- d.push(b);
930
- }
931
- } else {
932
- d = [];
933
- for (let f = 0; f < c.length; f++) d.push.apply(d, ht(c[f], t, !1));
934
- }
935
- for (let f = 0; f < d.length; f++) for (let m = 0; m < o.length && s.length < t; m++) {
936
- let p = r + d[f] + o[m];
937
- (!e || l || p) && s.push(p);
938
- }
939
- }
940
- return s;
124
+ return s;
941
125
  }
942
126
  var at = (n) => {
943
127
  if (typeof n != "string") throw new TypeError("invalid pattern");
@@ -3638,535 +2822,1345 @@ var Li = (n, t) => typeof n == "string" ? new ot([n], t) : Array.isArray(n) ? ne
3638
2822
  }
3639
2823
  return this.matchCheckTest(r, e);
3640
2824
  }
3641
- matchCheckTest(t, e) {
3642
- return t && (this.maxDepth === Infinity || t.depth() <= this.maxDepth) && (!e || t.canReaddir()) && (!this.opts.nodir || !t.isDirectory()) && (!this.opts.nodir || !this.opts.follow || !t.isSymbolicLink() || !t.realpathCached()?.isDirectory()) && !this.#r(t) ? t : void 0;
2825
+ matchCheckTest(t, e) {
2826
+ return t && (this.maxDepth === Infinity || t.depth() <= this.maxDepth) && (!e || t.canReaddir()) && (!this.opts.nodir || !t.isDirectory()) && (!this.opts.nodir || !this.opts.follow || !t.isSymbolicLink() || !t.realpathCached()?.isDirectory()) && !this.#r(t) ? t : void 0;
2827
+ }
2828
+ matchCheckSync(t, e) {
2829
+ if (e && this.opts.nodir) return;
2830
+ let s;
2831
+ if (this.opts.realpath) {
2832
+ if (s = t.realpathCached() || t.realpathSync(), !s) return;
2833
+ t = s;
2834
+ }
2835
+ let r = t.isUnknown() || this.opts.stat ? t.lstatSync() : t;
2836
+ if (this.opts.follow && this.opts.nodir && r?.isSymbolicLink()) {
2837
+ let o = r.realpathSync();
2838
+ o && (o?.isUnknown() || this.opts.stat) && o.lstatSync();
2839
+ }
2840
+ return this.matchCheckTest(r, e);
2841
+ }
2842
+ matchFinish(t, e) {
2843
+ if (this.#r(t)) return;
2844
+ if (!this.includeChildMatches && this.#s?.add) {
2845
+ let r = `${t.relativePosix()}/**`;
2846
+ this.#s.add(r);
2847
+ }
2848
+ let s = this.opts.absolute === void 0 ? e : this.opts.absolute;
2849
+ this.seen.add(t);
2850
+ let i = this.opts.mark && t.isDirectory() ? this.#n : "";
2851
+ if (this.opts.withFileTypes) this.matchEmit(t);
2852
+ else if (s) {
2853
+ let r = this.opts.posix ? t.fullpathPosix() : t.fullpath();
2854
+ this.matchEmit(r + i);
2855
+ } else {
2856
+ let r = this.opts.posix ? t.relativePosix() : t.relative(), o = this.opts.dotRelative && !r.startsWith(".." + this.#n) ? "." + this.#n : "";
2857
+ this.matchEmit(r ? o + r + i : "." + i);
2858
+ }
2859
+ }
2860
+ async match(t, e, s) {
2861
+ let i = await this.matchCheck(t, s);
2862
+ i && this.matchFinish(i, e);
2863
+ }
2864
+ matchSync(t, e, s) {
2865
+ let i = this.matchCheckSync(t, s);
2866
+ i && this.matchFinish(i, e);
2867
+ }
2868
+ walkCB(t, e, s) {
2869
+ this.signal?.aborted && s(), this.walkCB2(t, e, new Et(this.opts), s);
2870
+ }
2871
+ walkCB2(t, e, s, i) {
2872
+ if (this.#o(t)) return i();
2873
+ if (this.signal?.aborted && i(), this.paused) {
2874
+ this.onResume(() => this.walkCB2(t, e, s, i));
2875
+ return;
2876
+ }
2877
+ s.processPatterns(t, e);
2878
+ let r = 1, o = () => {
2879
+ --r === 0 && i();
2880
+ };
2881
+ for (let [h, a, l] of s.matches.entries()) this.#r(h) || (r++, this.match(h, a, l).then(() => o()));
2882
+ for (let h of s.subwalkTargets()) {
2883
+ if (this.maxDepth !== Infinity && h.depth() >= this.maxDepth) continue;
2884
+ r++;
2885
+ let a = h.readdirCached();
2886
+ h.calledReaddir() ? this.walkCB3(h, a, s, o) : h.readdirCB((l, u) => this.walkCB3(h, u, s, o), !0);
2887
+ }
2888
+ o();
2889
+ }
2890
+ walkCB3(t, e, s, i) {
2891
+ s = s.filterEntries(t, e);
2892
+ let r = 1, o = () => {
2893
+ --r === 0 && i();
2894
+ };
2895
+ for (let [h, a, l] of s.matches.entries()) this.#r(h) || (r++, this.match(h, a, l).then(() => o()));
2896
+ for (let [h, a] of s.subwalks.entries()) r++, this.walkCB2(h, a, s.child(), o);
2897
+ o();
2898
+ }
2899
+ walkCBSync(t, e, s) {
2900
+ this.signal?.aborted && s(), this.walkCB2Sync(t, e, new Et(this.opts), s);
2901
+ }
2902
+ walkCB2Sync(t, e, s, i) {
2903
+ if (this.#o(t)) return i();
2904
+ if (this.signal?.aborted && i(), this.paused) {
2905
+ this.onResume(() => this.walkCB2Sync(t, e, s, i));
2906
+ return;
2907
+ }
2908
+ s.processPatterns(t, e);
2909
+ let r = 1, o = () => {
2910
+ --r === 0 && i();
2911
+ };
2912
+ for (let [h, a, l] of s.matches.entries()) this.#r(h) || this.matchSync(h, a, l);
2913
+ for (let h of s.subwalkTargets()) {
2914
+ if (this.maxDepth !== Infinity && h.depth() >= this.maxDepth) continue;
2915
+ r++;
2916
+ let a = h.readdirSync();
2917
+ this.walkCB3Sync(h, a, s, o);
2918
+ }
2919
+ o();
2920
+ }
2921
+ walkCB3Sync(t, e, s, i) {
2922
+ s = s.filterEntries(t, e);
2923
+ let r = 1, o = () => {
2924
+ --r === 0 && i();
2925
+ };
2926
+ for (let [h, a, l] of s.matches.entries()) this.#r(h) || this.matchSync(h, a, l);
2927
+ for (let [h, a] of s.subwalks.entries()) r++, this.walkCB2Sync(h, a, s.child(), o);
2928
+ o();
2929
+ }
2930
+ }, xt = class extends zt {
2931
+ matches = /* @__PURE__ */ new Set();
2932
+ constructor(t, e, s) {
2933
+ super(t, e, s);
2934
+ }
2935
+ matchEmit(t) {
2936
+ this.matches.add(t);
2937
+ }
2938
+ async walk() {
2939
+ if (this.signal?.aborted) throw this.signal.reason;
2940
+ return this.path.isUnknown() && await this.path.lstat(), await new Promise((t, e) => {
2941
+ this.walkCB(this.path, this.patterns, () => {
2942
+ this.signal?.aborted ? e(this.signal.reason) : t(this.matches);
2943
+ });
2944
+ }), this.matches;
2945
+ }
2946
+ walkSync() {
2947
+ if (this.signal?.aborted) throw this.signal.reason;
2948
+ return this.path.isUnknown() && this.path.lstatSync(), this.walkCBSync(this.path, this.patterns, () => {
2949
+ if (this.signal?.aborted) throw this.signal.reason;
2950
+ }), this.matches;
2951
+ }
2952
+ }, vt = class extends zt {
2953
+ results;
2954
+ constructor(t, e, s) {
2955
+ super(t, e, s), this.results = new V({
2956
+ signal: this.signal,
2957
+ objectMode: !0
2958
+ }), this.results.on("drain", () => this.resume()), this.results.on("resume", () => this.resume());
2959
+ }
2960
+ matchEmit(t) {
2961
+ this.results.write(t), this.results.flowing || this.pause();
2962
+ }
2963
+ stream() {
2964
+ let t = this.path;
2965
+ return t.isUnknown() ? t.lstat().then(() => {
2966
+ this.walkCB(t, this.patterns, () => this.results.end());
2967
+ }) : this.walkCB(t, this.patterns, () => this.results.end()), this.results;
2968
+ }
2969
+ streamSync() {
2970
+ return this.path.isUnknown() && this.path.lstatSync(), this.walkCBSync(this.path, this.patterns, () => this.results.end()), this.results;
2971
+ }
2972
+ };
2973
+ var Pi = typeof process == "object" && process && typeof process.platform == "string" ? process.platform : "linux", I = class {
2974
+ absolute;
2975
+ cwd;
2976
+ root;
2977
+ dot;
2978
+ dotRelative;
2979
+ follow;
2980
+ ignore;
2981
+ magicalBraces;
2982
+ mark;
2983
+ matchBase;
2984
+ maxDepth;
2985
+ nobrace;
2986
+ nocase;
2987
+ nodir;
2988
+ noext;
2989
+ noglobstar;
2990
+ pattern;
2991
+ platform;
2992
+ realpath;
2993
+ scurry;
2994
+ stat;
2995
+ signal;
2996
+ windowsPathsNoEscape;
2997
+ withFileTypes;
2998
+ includeChildMatches;
2999
+ opts;
3000
+ patterns;
3001
+ constructor(t, e) {
3002
+ if (!e) throw new TypeError("glob options required");
3003
+ if (this.withFileTypes = !!e.withFileTypes, this.signal = e.signal, this.follow = !!e.follow, this.dot = !!e.dot, this.dotRelative = !!e.dotRelative, this.nodir = !!e.nodir, this.mark = !!e.mark, e.cwd ? (e.cwd instanceof URL || e.cwd.startsWith("file://")) && (e.cwd = fileURLToPath(e.cwd)) : this.cwd = "", this.cwd = e.cwd || "", this.root = e.root, this.magicalBraces = !!e.magicalBraces, this.nobrace = !!e.nobrace, this.noext = !!e.noext, this.realpath = !!e.realpath, this.absolute = e.absolute, this.includeChildMatches = e.includeChildMatches !== !1, this.noglobstar = !!e.noglobstar, this.matchBase = !!e.matchBase, this.maxDepth = typeof e.maxDepth == "number" ? e.maxDepth : Infinity, this.stat = !!e.stat, this.ignore = e.ignore, this.withFileTypes && this.absolute !== void 0) throw new Error("cannot set absolute and withFileTypes:true");
3004
+ if (typeof t == "string" && (t = [t]), this.windowsPathsNoEscape = !!e.windowsPathsNoEscape || e.allowWindowsEscape === !1, this.windowsPathsNoEscape && (t = t.map((a) => a.replace(/\\/g, "/"))), this.matchBase) {
3005
+ if (e.noglobstar) throw new TypeError("base matching requires globstar");
3006
+ t = t.map((a) => a.includes("/") ? a : `./**/${a}`);
3007
+ }
3008
+ if (this.pattern = t, this.platform = e.platform || Pi, this.opts = {
3009
+ ...e,
3010
+ platform: this.platform
3011
+ }, e.scurry) {
3012
+ if (this.scurry = e.scurry, e.nocase !== void 0 && e.nocase !== e.scurry.nocase) throw new Error("nocase option contradicts provided scurry option");
3013
+ } else this.scurry = new (e.platform === "win32" ? it : e.platform === "darwin" ? St : e.platform ? rt : Xe)(this.cwd, {
3014
+ nocase: e.nocase,
3015
+ fs: e.fs
3016
+ });
3017
+ this.nocase = this.scurry.nocase;
3018
+ let s = this.platform === "darwin" || this.platform === "win32", i = {
3019
+ braceExpandMax: 1e4,
3020
+ ...e,
3021
+ dot: this.dot,
3022
+ matchBase: this.matchBase,
3023
+ nobrace: this.nobrace,
3024
+ nocase: this.nocase,
3025
+ nocaseMagicOnly: s,
3026
+ nocomment: !0,
3027
+ noext: this.noext,
3028
+ nonegate: !0,
3029
+ optimizationLevel: 2,
3030
+ platform: this.platform,
3031
+ windowsPathsNoEscape: this.windowsPathsNoEscape,
3032
+ debug: !!this.opts.debug
3033
+ }, [o, h] = this.pattern.map((a) => new D(a, i)).reduce((a, l) => (a[0].push(...l.set), a[1].push(...l.globParts), a), [[], []]);
3034
+ this.patterns = o.map((a, l) => {
3035
+ let u = h[l];
3036
+ if (!u) throw new Error("invalid pattern object");
3037
+ return new nt(a, u, 0, this.platform);
3038
+ });
3039
+ }
3040
+ async walk() {
3041
+ return [...await new xt(this.patterns, this.scurry.cwd, {
3042
+ ...this.opts,
3043
+ maxDepth: this.maxDepth !== Infinity ? this.maxDepth + this.scurry.cwd.depth() : Infinity,
3044
+ platform: this.platform,
3045
+ nocase: this.nocase,
3046
+ includeChildMatches: this.includeChildMatches
3047
+ }).walk()];
3048
+ }
3049
+ walkSync() {
3050
+ return [...new xt(this.patterns, this.scurry.cwd, {
3051
+ ...this.opts,
3052
+ maxDepth: this.maxDepth !== Infinity ? this.maxDepth + this.scurry.cwd.depth() : Infinity,
3053
+ platform: this.platform,
3054
+ nocase: this.nocase,
3055
+ includeChildMatches: this.includeChildMatches
3056
+ }).walkSync()];
3057
+ }
3058
+ stream() {
3059
+ return new vt(this.patterns, this.scurry.cwd, {
3060
+ ...this.opts,
3061
+ maxDepth: this.maxDepth !== Infinity ? this.maxDepth + this.scurry.cwd.depth() : Infinity,
3062
+ platform: this.platform,
3063
+ nocase: this.nocase,
3064
+ includeChildMatches: this.includeChildMatches
3065
+ }).stream();
3066
+ }
3067
+ streamSync() {
3068
+ return new vt(this.patterns, this.scurry.cwd, {
3069
+ ...this.opts,
3070
+ maxDepth: this.maxDepth !== Infinity ? this.maxDepth + this.scurry.cwd.depth() : Infinity,
3071
+ platform: this.platform,
3072
+ nocase: this.nocase,
3073
+ includeChildMatches: this.includeChildMatches
3074
+ }).streamSync();
3075
+ }
3076
+ iterateSync() {
3077
+ return this.streamSync()[Symbol.iterator]();
3078
+ }
3079
+ [Symbol.iterator]() {
3080
+ return this.iterateSync();
3643
3081
  }
3644
- matchCheckSync(t, e) {
3645
- if (e && this.opts.nodir) return;
3646
- let s;
3647
- if (this.opts.realpath) {
3648
- if (s = t.realpathCached() || t.realpathSync(), !s) return;
3649
- t = s;
3650
- }
3651
- let r = t.isUnknown() || this.opts.stat ? t.lstatSync() : t;
3652
- if (this.opts.follow && this.opts.nodir && r?.isSymbolicLink()) {
3653
- let o = r.realpathSync();
3654
- o && (o?.isUnknown() || this.opts.stat) && o.lstatSync();
3655
- }
3656
- return this.matchCheckTest(r, e);
3082
+ iterate() {
3083
+ return this.stream()[Symbol.asyncIterator]();
3657
3084
  }
3658
- matchFinish(t, e) {
3659
- if (this.#r(t)) return;
3660
- if (!this.includeChildMatches && this.#s?.add) {
3661
- let r = `${t.relativePosix()}/**`;
3662
- this.#s.add(r);
3663
- }
3664
- let s = this.opts.absolute === void 0 ? e : this.opts.absolute;
3665
- this.seen.add(t);
3666
- let i = this.opts.mark && t.isDirectory() ? this.#n : "";
3667
- if (this.opts.withFileTypes) this.matchEmit(t);
3668
- else if (s) {
3669
- let r = this.opts.posix ? t.fullpathPosix() : t.fullpath();
3670
- this.matchEmit(r + i);
3671
- } else {
3672
- let r = this.opts.posix ? t.relativePosix() : t.relative(), o = this.opts.dotRelative && !r.startsWith(".." + this.#n) ? "." + this.#n : "";
3673
- this.matchEmit(r ? o + r + i : "." + i);
3674
- }
3085
+ [Symbol.asyncIterator]() {
3086
+ return this.iterate();
3675
3087
  }
3676
- async match(t, e, s) {
3677
- let i = await this.matchCheck(t, s);
3678
- i && this.matchFinish(i, e);
3088
+ };
3089
+ var le = (n, t = {}) => {
3090
+ Array.isArray(n) || (n = [n]);
3091
+ for (let e of n) if (new D(e, t).hasMagic()) return !0;
3092
+ return !1;
3093
+ };
3094
+ function Bt(n, t = {}) {
3095
+ return new I(n, t).streamSync();
3096
+ }
3097
+ function Qe(n, t = {}) {
3098
+ return new I(n, t).stream();
3099
+ }
3100
+ function ts(n, t = {}) {
3101
+ return new I(n, t).walkSync();
3102
+ }
3103
+ async function Je(n, t = {}) {
3104
+ return new I(n, t).walk();
3105
+ }
3106
+ function Ut(n, t = {}) {
3107
+ return new I(n, t).iterateSync();
3108
+ }
3109
+ function es(n, t = {}) {
3110
+ return new I(n, t).iterate();
3111
+ }
3112
+ var ji = Bt, Ii = Object.assign(Qe, { sync: Bt }), zi = Ut, Bi = Object.assign(es, { sync: Ut }), Ui = Object.assign(ts, {
3113
+ stream: Bt,
3114
+ iterate: Ut
3115
+ }), Ze = Object.assign(Je, {
3116
+ glob: Je,
3117
+ globSync: ts,
3118
+ sync: Ui,
3119
+ globStream: Qe,
3120
+ stream: Ii,
3121
+ globStreamSync: Bt,
3122
+ streamSync: ji,
3123
+ globIterate: es,
3124
+ iterate: Bi,
3125
+ globIterateSync: Ut,
3126
+ iterateSync: zi,
3127
+ Glob: I,
3128
+ hasMagic: le,
3129
+ escape: tt,
3130
+ unescape: W
3131
+ });
3132
+ Ze.glob = Ze;
3133
+ //#endregion
3134
+ //#region node_modules/.pnpm/es-toolkit@1.45.1/node_modules/es-toolkit/dist/predicate/isLength.mjs
3135
+ function isLength(value) {
3136
+ return Number.isSafeInteger(value) && value >= 0;
3137
+ }
3138
+ //#endregion
3139
+ //#region node_modules/.pnpm/es-toolkit@1.45.1/node_modules/es-toolkit/dist/compat/predicate/isArrayLike.mjs
3140
+ function isArrayLike(value) {
3141
+ return value != null && typeof value !== "function" && isLength(value.length);
3142
+ }
3143
+ //#endregion
3144
+ //#region node_modules/.pnpm/es-toolkit@1.45.1/node_modules/es-toolkit/dist/array/flatten.mjs
3145
+ function flatten(arr, depth = 1) {
3146
+ const result = [];
3147
+ const flooredDepth = Math.floor(depth);
3148
+ const recursive = (arr, currentDepth) => {
3149
+ for (let i = 0; i < arr.length; i++) {
3150
+ const item = arr[i];
3151
+ if (Array.isArray(item) && currentDepth < flooredDepth) recursive(item, currentDepth + 1);
3152
+ else result.push(item);
3153
+ }
3154
+ };
3155
+ recursive(arr, 0);
3156
+ return result;
3157
+ }
3158
+ //#endregion
3159
+ //#region node_modules/.pnpm/es-toolkit@1.45.1/node_modules/es-toolkit/dist/_internal/isUnsafeProperty.mjs
3160
+ function isUnsafeProperty(key) {
3161
+ return key === "__proto__";
3162
+ }
3163
+ //#endregion
3164
+ //#region node_modules/.pnpm/es-toolkit@1.45.1/node_modules/es-toolkit/dist/compat/_internal/toKey.mjs
3165
+ function toKey(value) {
3166
+ if (typeof value === "string" || typeof value === "symbol") return value;
3167
+ if (Object.is(value?.valueOf?.(), -0)) return "-0";
3168
+ return String(value);
3169
+ }
3170
+ //#endregion
3171
+ //#region node_modules/.pnpm/es-toolkit@1.45.1/node_modules/es-toolkit/dist/compat/util/toString.mjs
3172
+ function toString(value) {
3173
+ if (value == null) return "";
3174
+ if (typeof value === "string") return value;
3175
+ if (Array.isArray(value)) return value.map(toString).join(",");
3176
+ const result = String(value);
3177
+ if (result === "0" && Object.is(Number(value), -0)) return "-0";
3178
+ return result;
3179
+ }
3180
+ //#endregion
3181
+ //#region node_modules/.pnpm/es-toolkit@1.45.1/node_modules/es-toolkit/dist/compat/util/toPath.mjs
3182
+ function toPath(deepKey) {
3183
+ if (Array.isArray(deepKey)) return deepKey.map(toKey);
3184
+ if (typeof deepKey === "symbol") return [deepKey];
3185
+ deepKey = toString(deepKey);
3186
+ const result = [];
3187
+ const length = deepKey.length;
3188
+ if (length === 0) return result;
3189
+ let index = 0;
3190
+ let key = "";
3191
+ let quoteChar = "";
3192
+ let bracket = false;
3193
+ if (deepKey.charCodeAt(0) === 46) {
3194
+ result.push("");
3195
+ index++;
3679
3196
  }
3680
- matchSync(t, e, s) {
3681
- let i = this.matchCheckSync(t, s);
3682
- i && this.matchFinish(i, e);
3197
+ while (index < length) {
3198
+ const char = deepKey[index];
3199
+ if (quoteChar) if (char === "\\" && index + 1 < length) {
3200
+ index++;
3201
+ key += deepKey[index];
3202
+ } else if (char === quoteChar) quoteChar = "";
3203
+ else key += char;
3204
+ else if (bracket) if (char === "\"" || char === "'") quoteChar = char;
3205
+ else if (char === "]") {
3206
+ bracket = false;
3207
+ result.push(key);
3208
+ key = "";
3209
+ } else key += char;
3210
+ else if (char === "[") {
3211
+ bracket = true;
3212
+ if (key) {
3213
+ result.push(key);
3214
+ key = "";
3215
+ }
3216
+ } else if (char === ".") {
3217
+ if (key) {
3218
+ result.push(key);
3219
+ key = "";
3220
+ }
3221
+ } else key += char;
3222
+ index++;
3683
3223
  }
3684
- walkCB(t, e, s) {
3685
- this.signal?.aborted && s(), this.walkCB2(t, e, new Et(this.opts), s);
3224
+ if (key) result.push(key);
3225
+ return result;
3226
+ }
3227
+ //#endregion
3228
+ //#region node_modules/.pnpm/es-toolkit@1.45.1/node_modules/es-toolkit/dist/compat/predicate/isObject.mjs
3229
+ function isObject(value) {
3230
+ return value !== null && (typeof value === "object" || typeof value === "function");
3231
+ }
3232
+ //#endregion
3233
+ //#region node_modules/.pnpm/es-toolkit@1.45.1/node_modules/es-toolkit/dist/_internal/isEqualsSameValueZero.mjs
3234
+ function isEqualsSameValueZero(value, other) {
3235
+ return value === other || Number.isNaN(value) && Number.isNaN(other);
3236
+ }
3237
+ //#endregion
3238
+ //#region node_modules/.pnpm/es-toolkit@1.45.1/node_modules/es-toolkit/dist/compat/_internal/isIndex.mjs
3239
+ const IS_UNSIGNED_INTEGER = /^(?:0|[1-9]\d*)$/;
3240
+ function isIndex(value, length = Number.MAX_SAFE_INTEGER) {
3241
+ switch (typeof value) {
3242
+ case "number": return Number.isInteger(value) && value >= 0 && value < length;
3243
+ case "symbol": return false;
3244
+ case "string": return IS_UNSIGNED_INTEGER.test(value);
3686
3245
  }
3687
- walkCB2(t, e, s, i) {
3688
- if (this.#o(t)) return i();
3689
- if (this.signal?.aborted && i(), this.paused) {
3690
- this.onResume(() => this.walkCB2(t, e, s, i));
3691
- return;
3692
- }
3693
- s.processPatterns(t, e);
3694
- let r = 1, o = () => {
3695
- --r === 0 && i();
3696
- };
3697
- for (let [h, a, l] of s.matches.entries()) this.#r(h) || (r++, this.match(h, a, l).then(() => o()));
3698
- for (let h of s.subwalkTargets()) {
3699
- if (this.maxDepth !== Infinity && h.depth() >= this.maxDepth) continue;
3700
- r++;
3701
- let a = h.readdirCached();
3702
- h.calledReaddir() ? this.walkCB3(h, a, s, o) : h.readdirCB((l, u) => this.walkCB3(h, u, s, o), !0);
3246
+ }
3247
+ //#endregion
3248
+ //#region node_modules/.pnpm/es-toolkit@1.45.1/node_modules/es-toolkit/dist/array/difference.mjs
3249
+ function difference(firstArr, secondArr) {
3250
+ const secondSet = new Set(secondArr);
3251
+ return firstArr.filter((item) => !secondSet.has(item));
3252
+ }
3253
+ //#endregion
3254
+ //#region node_modules/.pnpm/es-toolkit@1.45.1/node_modules/es-toolkit/dist/compat/predicate/isSymbol.mjs
3255
+ function isSymbol(value) {
3256
+ return typeof value === "symbol" || value instanceof Symbol;
3257
+ }
3258
+ //#endregion
3259
+ //#region node_modules/.pnpm/es-toolkit@1.45.1/node_modules/es-toolkit/dist/compat/_internal/isIterateeCall.mjs
3260
+ function isIterateeCall(value, index, object) {
3261
+ if (!isObject(object)) return false;
3262
+ if (typeof index === "number" && isArrayLike(object) && isIndex(index) && index < object.length || typeof index === "string" && index in object) return isEqualsSameValueZero(object[index], value);
3263
+ return false;
3264
+ }
3265
+ //#endregion
3266
+ //#region node_modules/.pnpm/es-toolkit@1.45.1/node_modules/es-toolkit/dist/array/intersection.mjs
3267
+ function intersection(firstArr, secondArr) {
3268
+ const secondSet = new Set(secondArr);
3269
+ return firstArr.filter((item) => secondSet.has(item));
3270
+ }
3271
+ //#endregion
3272
+ //#region node_modules/.pnpm/es-toolkit@1.45.1/node_modules/es-toolkit/dist/array/uniq.mjs
3273
+ function uniq(arr) {
3274
+ return [...new Set(arr)];
3275
+ }
3276
+ //#endregion
3277
+ //#region node_modules/.pnpm/es-toolkit@1.45.1/node_modules/es-toolkit/dist/compat/_internal/compareValues.mjs
3278
+ function getPriority(a) {
3279
+ if (typeof a === "symbol") return 1;
3280
+ if (a === null) return 2;
3281
+ if (a === void 0) return 3;
3282
+ if (a !== a) return 4;
3283
+ return 0;
3284
+ }
3285
+ const compareValues = (a, b, order) => {
3286
+ if (a !== b) {
3287
+ const aPriority = getPriority(a);
3288
+ const bPriority = getPriority(b);
3289
+ if (aPriority === bPriority && aPriority === 0) {
3290
+ if (a < b) return order === "desc" ? 1 : -1;
3291
+ if (a > b) return order === "desc" ? -1 : 1;
3703
3292
  }
3704
- o();
3705
- }
3706
- walkCB3(t, e, s, i) {
3707
- s = s.filterEntries(t, e);
3708
- let r = 1, o = () => {
3709
- --r === 0 && i();
3710
- };
3711
- for (let [h, a, l] of s.matches.entries()) this.#r(h) || (r++, this.match(h, a, l).then(() => o()));
3712
- for (let [h, a] of s.subwalks.entries()) r++, this.walkCB2(h, a, s.child(), o);
3713
- o();
3714
- }
3715
- walkCBSync(t, e, s) {
3716
- this.signal?.aborted && s(), this.walkCB2Sync(t, e, new Et(this.opts), s);
3293
+ return order === "desc" ? bPriority - aPriority : aPriority - bPriority;
3717
3294
  }
3718
- walkCB2Sync(t, e, s, i) {
3719
- if (this.#o(t)) return i();
3720
- if (this.signal?.aborted && i(), this.paused) {
3721
- this.onResume(() => this.walkCB2Sync(t, e, s, i));
3722
- return;
3295
+ return 0;
3296
+ };
3297
+ //#endregion
3298
+ //#region node_modules/.pnpm/es-toolkit@1.45.1/node_modules/es-toolkit/dist/compat/_internal/isKey.mjs
3299
+ const regexIsDeepProp = /\.|\[(?:[^[\]]*|(["'])(?:(?!\1)[^\\]|\\.)*?\1)\]/;
3300
+ const regexIsPlainProp = /^\w*$/;
3301
+ function isKey(value, object) {
3302
+ if (Array.isArray(value)) return false;
3303
+ if (typeof value === "number" || typeof value === "boolean" || value == null || isSymbol(value)) return true;
3304
+ return typeof value === "string" && (regexIsPlainProp.test(value) || !regexIsDeepProp.test(value)) || object != null && Object.hasOwn(object, value);
3305
+ }
3306
+ //#endregion
3307
+ //#region node_modules/.pnpm/es-toolkit@1.45.1/node_modules/es-toolkit/dist/compat/array/orderBy.mjs
3308
+ function orderBy(collection, criteria, orders, guard) {
3309
+ if (collection == null) return [];
3310
+ orders = guard ? void 0 : orders;
3311
+ if (!Array.isArray(collection)) collection = Object.values(collection);
3312
+ if (!Array.isArray(criteria)) criteria = criteria == null ? [null] : [criteria];
3313
+ if (criteria.length === 0) criteria = [null];
3314
+ if (!Array.isArray(orders)) orders = orders == null ? [] : [orders];
3315
+ orders = orders.map((order) => String(order));
3316
+ const getValueByNestedPath = (object, path) => {
3317
+ let target = object;
3318
+ for (let i = 0; i < path.length && target != null; ++i) target = target[path[i]];
3319
+ return target;
3320
+ };
3321
+ const getValueByCriterion = (criterion, object) => {
3322
+ if (object == null || criterion == null) return object;
3323
+ if (typeof criterion === "object" && "key" in criterion) {
3324
+ if (Object.hasOwn(object, criterion.key)) return object[criterion.key];
3325
+ return getValueByNestedPath(object, criterion.path);
3723
3326
  }
3724
- s.processPatterns(t, e);
3725
- let r = 1, o = () => {
3726
- --r === 0 && i();
3327
+ if (typeof criterion === "function") return criterion(object);
3328
+ if (Array.isArray(criterion)) return getValueByNestedPath(object, criterion);
3329
+ if (typeof object === "object") return object[criterion];
3330
+ return object;
3331
+ };
3332
+ const preparedCriteria = criteria.map((criterion) => {
3333
+ if (Array.isArray(criterion) && criterion.length === 1) criterion = criterion[0];
3334
+ if (criterion == null || typeof criterion === "function" || Array.isArray(criterion) || isKey(criterion)) return criterion;
3335
+ return {
3336
+ key: criterion,
3337
+ path: toPath(criterion)
3727
3338
  };
3728
- for (let [h, a, l] of s.matches.entries()) this.#r(h) || this.matchSync(h, a, l);
3729
- for (let h of s.subwalkTargets()) {
3730
- if (this.maxDepth !== Infinity && h.depth() >= this.maxDepth) continue;
3731
- r++;
3732
- let a = h.readdirSync();
3733
- this.walkCB3Sync(h, a, s, o);
3339
+ });
3340
+ return collection.map((item) => ({
3341
+ original: item,
3342
+ criteria: preparedCriteria.map((criterion) => getValueByCriterion(criterion, item))
3343
+ })).slice().sort((a, b) => {
3344
+ for (let i = 0; i < preparedCriteria.length; i++) {
3345
+ const comparedResult = compareValues(a.criteria[i], b.criteria[i], orders[i]);
3346
+ if (comparedResult !== 0) return comparedResult;
3734
3347
  }
3735
- o();
3736
- }
3737
- walkCB3Sync(t, e, s, i) {
3738
- s = s.filterEntries(t, e);
3739
- let r = 1, o = () => {
3740
- --r === 0 && i();
3741
- };
3742
- for (let [h, a, l] of s.matches.entries()) this.#r(h) || this.matchSync(h, a, l);
3743
- for (let [h, a] of s.subwalks.entries()) r++, this.walkCB2Sync(h, a, s.child(), o);
3744
- o();
3745
- }
3746
- }, xt = class extends zt {
3747
- matches = /* @__PURE__ */ new Set();
3748
- constructor(t, e, s) {
3749
- super(t, e, s);
3750
- }
3751
- matchEmit(t) {
3752
- this.matches.add(t);
3753
- }
3754
- async walk() {
3755
- if (this.signal?.aborted) throw this.signal.reason;
3756
- return this.path.isUnknown() && await this.path.lstat(), await new Promise((t, e) => {
3757
- this.walkCB(this.path, this.patterns, () => {
3758
- this.signal?.aborted ? e(this.signal.reason) : t(this.matches);
3759
- });
3760
- }), this.matches;
3761
- }
3762
- walkSync() {
3763
- if (this.signal?.aborted) throw this.signal.reason;
3764
- return this.path.isUnknown() && this.path.lstatSync(), this.walkCBSync(this.path, this.patterns, () => {
3765
- if (this.signal?.aborted) throw this.signal.reason;
3766
- }), this.matches;
3767
- }
3768
- }, vt = class extends zt {
3769
- results;
3770
- constructor(t, e, s) {
3771
- super(t, e, s), this.results = new V({
3772
- signal: this.signal,
3773
- objectMode: !0
3774
- }), this.results.on("drain", () => this.resume()), this.results.on("resume", () => this.resume());
3775
- }
3776
- matchEmit(t) {
3777
- this.results.write(t), this.results.flowing || this.pause();
3348
+ return 0;
3349
+ }).map((item) => item.original);
3350
+ }
3351
+ //#endregion
3352
+ //#region node_modules/.pnpm/es-toolkit@1.45.1/node_modules/es-toolkit/dist/compat/array/sortBy.mjs
3353
+ function sortBy(collection, ...criteria) {
3354
+ const length = criteria.length;
3355
+ if (length > 1 && isIterateeCall(collection, criteria[0], criteria[1])) criteria = [];
3356
+ else if (length > 2 && isIterateeCall(criteria[0], criteria[1], criteria[2])) criteria = [criteria[0]];
3357
+ return orderBy(collection, flatten(criteria), ["asc"]);
3358
+ }
3359
+ //#endregion
3360
+ //#region node_modules/.pnpm/es-toolkit@1.45.1/node_modules/es-toolkit/dist/predicate/isPlainObject.mjs
3361
+ function isPlainObject(value) {
3362
+ if (!value || typeof value !== "object") return false;
3363
+ const proto = Object.getPrototypeOf(value);
3364
+ if (!(proto === null || proto === Object.prototype || Object.getPrototypeOf(proto) === null)) return false;
3365
+ return Object.prototype.toString.call(value) === "[object Object]";
3366
+ }
3367
+ //#endregion
3368
+ //#region node_modules/.pnpm/es-toolkit@1.45.1/node_modules/es-toolkit/dist/function/noop.mjs
3369
+ function noop() {}
3370
+ //#endregion
3371
+ //#region src/glob/glob.ts
3372
+ /**
3373
+ * Sorts migration file paths
3374
+ *
3375
+ * @param {Array<String>} filePaths
3376
+ * @returns {Array<String>} sorted files
3377
+ */
3378
+ const sortFilePathsByFilename = (filePaths) => sortBy(filePaths, (file) => {
3379
+ return path.parse(file).base;
3380
+ });
3381
+ /**
3382
+ * Gets paths to entity migrations in a directory
3383
+ *
3384
+ * @param {String} pathToMigrations
3385
+ * @returns {Promise<Array<String>>} matching migration filePaths
3386
+ */
3387
+ const getMigrationFilePaths = async (pathToMigrations) => {
3388
+ const filePath = (pattern) => `${pathToMigrations}${pattern}`;
3389
+ return sortFilePathsByFilename(await Ze(filePath("/**/*.js"), { ignore: [
3390
+ filePath("/**/*.skip?([0-9]*).js"),
3391
+ filePath("/**/index.js"),
3392
+ filePath("/**/plan.json"),
3393
+ filePath("/**/*.bundle.js"),
3394
+ filePath("/**/*.test.js"),
3395
+ filePath("/**/*.spec.js"),
3396
+ filePath("/**/__tests__/*"),
3397
+ filePath("/**/__test__/*")
3398
+ ] }));
3399
+ };
3400
+ /**
3401
+ * Gets paths to skipped migrations in a directory
3402
+ *
3403
+ * @param {String} pathToMigrations
3404
+ * @returns {Promise<Array<String>>} skipped migration filePaths
3405
+ */
3406
+ const getSkippedFilePaths = async (pathToMigrations) => {
3407
+ const filePath = (pattern) => `${pathToMigrations}${pattern}`;
3408
+ return sortFilePathsByFilename(await Ze(filePath("/**/*.skip?([0-9]*).js"), { ignore: [
3409
+ filePath("/**/index.js"),
3410
+ filePath("/**/plan.json"),
3411
+ filePath("/**/*.bundle.js"),
3412
+ filePath("/**/*.test.js"),
3413
+ filePath("/**/*.spec.js"),
3414
+ filePath("/**/__tests__/*"),
3415
+ filePath("/**/__test__/*")
3416
+ ] }));
3417
+ };
3418
+ //#endregion
3419
+ //#region node_modules/.pnpm/es-toolkit@1.45.1/node_modules/es-toolkit/dist/array/union.mjs
3420
+ function union(arr1, arr2) {
3421
+ return uniq(arr1.concat(arr2));
3422
+ }
3423
+ //#endregion
3424
+ //#region node_modules/.pnpm/es-toolkit@1.45.1/node_modules/es-toolkit/dist/array/xor.mjs
3425
+ function xor(arr1, arr2) {
3426
+ return difference(union(arr1, arr2), intersection(arr1, arr2));
3427
+ }
3428
+ //#endregion
3429
+ //#region node_modules/.pnpm/es-toolkit@1.45.1/node_modules/es-toolkit/dist/object/merge.mjs
3430
+ function merge(target, source) {
3431
+ const sourceKeys = Object.keys(source);
3432
+ for (let i = 0; i < sourceKeys.length; i++) {
3433
+ const key = sourceKeys[i];
3434
+ if (isUnsafeProperty(key)) continue;
3435
+ const sourceValue = source[key];
3436
+ const targetValue = target[key];
3437
+ if (isMergeableValue(sourceValue) && isMergeableValue(targetValue)) target[key] = merge(targetValue, sourceValue);
3438
+ else if (Array.isArray(sourceValue)) target[key] = merge([], sourceValue);
3439
+ else if (isPlainObject(sourceValue)) target[key] = merge({}, sourceValue);
3440
+ else if (targetValue === void 0 || sourceValue !== void 0) target[key] = sourceValue;
3778
3441
  }
3779
- stream() {
3780
- let t = this.path;
3781
- return t.isUnknown() ? t.lstat().then(() => {
3782
- this.walkCB(t, this.patterns, () => this.results.end());
3783
- }) : this.walkCB(t, this.patterns, () => this.results.end()), this.results;
3442
+ return target;
3443
+ }
3444
+ function isMergeableValue(value) {
3445
+ return isPlainObject(value) || Array.isArray(value);
3446
+ }
3447
+ //#endregion
3448
+ //#region node_modules/.pnpm/es-toolkit@1.45.1/node_modules/es-toolkit/dist/object/omit.mjs
3449
+ function omit(obj, keys) {
3450
+ const result = { ...obj };
3451
+ for (let i = 0; i < keys.length; i++) {
3452
+ const key = keys[i];
3453
+ delete result[key];
3784
3454
  }
3785
- streamSync() {
3786
- return this.path.isUnknown() && this.path.lstatSync(), this.walkCBSync(this.path, this.patterns, () => this.results.end()), this.results;
3455
+ return result;
3456
+ }
3457
+ //#endregion
3458
+ //#region node_modules/.pnpm/es-toolkit@1.45.1/node_modules/es-toolkit/dist/predicate/isString.mjs
3459
+ function isString(value) {
3460
+ return typeof value === "string";
3461
+ }
3462
+ //#endregion
3463
+ //#region src/plan/loader-module.ts
3464
+ const lazyImportMigration = (script) => {
3465
+ if (!script) return noop;
3466
+ const patchedScript = script.replace(/import\s+\{?\s*produce\s*}?\s+from\s+['"]immer['"];?/, "").replace(/export\s+default\s+/, "const migration = ").replace(/export\s+(const|function|async function)\s+/g, "$1 ");
3467
+ return (payload, metaData) => {
3468
+ const context = {
3469
+ payload,
3470
+ metaData,
3471
+ produce
3472
+ };
3473
+ return vm.runInNewContext(`${patchedScript}; migration(payload, metaData);`, context);
3474
+ };
3475
+ };
3476
+ const LoaderModule = { lazyImportMigration };
3477
+ //#endregion
3478
+ //#region src/hash/hash.ts
3479
+ /**
3480
+ * Generate SHA256 hash from a string
3481
+ */
3482
+ const hash = (string) => createHash("sha256").update(string).digest("hex");
3483
+ //#endregion
3484
+ //#region node_modules/.pnpm/chalk@5.6.2/node_modules/chalk/source/vendor/ansi-styles/index.js
3485
+ const ANSI_BACKGROUND_OFFSET = 10;
3486
+ const wrapAnsi16 = (offset = 0) => (code) => `\u001B[${code + offset}m`;
3487
+ const wrapAnsi256 = (offset = 0) => (code) => `\u001B[${38 + offset};5;${code}m`;
3488
+ const wrapAnsi16m = (offset = 0) => (red, green, blue) => `\u001B[${38 + offset};2;${red};${green};${blue}m`;
3489
+ const styles$1 = {
3490
+ modifier: {
3491
+ reset: [0, 0],
3492
+ bold: [1, 22],
3493
+ dim: [2, 22],
3494
+ italic: [3, 23],
3495
+ underline: [4, 24],
3496
+ overline: [53, 55],
3497
+ inverse: [7, 27],
3498
+ hidden: [8, 28],
3499
+ strikethrough: [9, 29]
3500
+ },
3501
+ color: {
3502
+ black: [30, 39],
3503
+ red: [31, 39],
3504
+ green: [32, 39],
3505
+ yellow: [33, 39],
3506
+ blue: [34, 39],
3507
+ magenta: [35, 39],
3508
+ cyan: [36, 39],
3509
+ white: [37, 39],
3510
+ blackBright: [90, 39],
3511
+ gray: [90, 39],
3512
+ grey: [90, 39],
3513
+ redBright: [91, 39],
3514
+ greenBright: [92, 39],
3515
+ yellowBright: [93, 39],
3516
+ blueBright: [94, 39],
3517
+ magentaBright: [95, 39],
3518
+ cyanBright: [96, 39],
3519
+ whiteBright: [97, 39]
3520
+ },
3521
+ bgColor: {
3522
+ bgBlack: [40, 49],
3523
+ bgRed: [41, 49],
3524
+ bgGreen: [42, 49],
3525
+ bgYellow: [43, 49],
3526
+ bgBlue: [44, 49],
3527
+ bgMagenta: [45, 49],
3528
+ bgCyan: [46, 49],
3529
+ bgWhite: [47, 49],
3530
+ bgBlackBright: [100, 49],
3531
+ bgGray: [100, 49],
3532
+ bgGrey: [100, 49],
3533
+ bgRedBright: [101, 49],
3534
+ bgGreenBright: [102, 49],
3535
+ bgYellowBright: [103, 49],
3536
+ bgBlueBright: [104, 49],
3537
+ bgMagentaBright: [105, 49],
3538
+ bgCyanBright: [106, 49],
3539
+ bgWhiteBright: [107, 49]
3787
3540
  }
3788
3541
  };
3789
- var Pi = typeof process == "object" && process && typeof process.platform == "string" ? process.platform : "linux", I = class {
3790
- absolute;
3791
- cwd;
3792
- root;
3793
- dot;
3794
- dotRelative;
3795
- follow;
3796
- ignore;
3797
- magicalBraces;
3798
- mark;
3799
- matchBase;
3800
- maxDepth;
3801
- nobrace;
3802
- nocase;
3803
- nodir;
3804
- noext;
3805
- noglobstar;
3806
- pattern;
3807
- platform;
3808
- realpath;
3809
- scurry;
3810
- stat;
3811
- signal;
3812
- windowsPathsNoEscape;
3813
- withFileTypes;
3814
- includeChildMatches;
3815
- opts;
3816
- patterns;
3817
- constructor(t, e) {
3818
- if (!e) throw new TypeError("glob options required");
3819
- if (this.withFileTypes = !!e.withFileTypes, this.signal = e.signal, this.follow = !!e.follow, this.dot = !!e.dot, this.dotRelative = !!e.dotRelative, this.nodir = !!e.nodir, this.mark = !!e.mark, e.cwd ? (e.cwd instanceof URL || e.cwd.startsWith("file://")) && (e.cwd = fileURLToPath(e.cwd)) : this.cwd = "", this.cwd = e.cwd || "", this.root = e.root, this.magicalBraces = !!e.magicalBraces, this.nobrace = !!e.nobrace, this.noext = !!e.noext, this.realpath = !!e.realpath, this.absolute = e.absolute, this.includeChildMatches = e.includeChildMatches !== !1, this.noglobstar = !!e.noglobstar, this.matchBase = !!e.matchBase, this.maxDepth = typeof e.maxDepth == "number" ? e.maxDepth : Infinity, this.stat = !!e.stat, this.ignore = e.ignore, this.withFileTypes && this.absolute !== void 0) throw new Error("cannot set absolute and withFileTypes:true");
3820
- if (typeof t == "string" && (t = [t]), this.windowsPathsNoEscape = !!e.windowsPathsNoEscape || e.allowWindowsEscape === !1, this.windowsPathsNoEscape && (t = t.map((a) => a.replace(/\\/g, "/"))), this.matchBase) {
3821
- if (e.noglobstar) throw new TypeError("base matching requires globstar");
3822
- t = t.map((a) => a.includes("/") ? a : `./**/${a}`);
3542
+ Object.keys(styles$1.modifier);
3543
+ const foregroundColorNames = Object.keys(styles$1.color);
3544
+ const backgroundColorNames = Object.keys(styles$1.bgColor);
3545
+ [...foregroundColorNames, ...backgroundColorNames];
3546
+ function assembleStyles() {
3547
+ const codes = /* @__PURE__ */ new Map();
3548
+ for (const [groupName, group] of Object.entries(styles$1)) {
3549
+ for (const [styleName, style] of Object.entries(group)) {
3550
+ styles$1[styleName] = {
3551
+ open: `\u001B[${style[0]}m`,
3552
+ close: `\u001B[${style[1]}m`
3553
+ };
3554
+ group[styleName] = styles$1[styleName];
3555
+ codes.set(style[0], style[1]);
3823
3556
  }
3824
- if (this.pattern = t, this.platform = e.platform || Pi, this.opts = {
3825
- ...e,
3826
- platform: this.platform
3827
- }, e.scurry) {
3828
- if (this.scurry = e.scurry, e.nocase !== void 0 && e.nocase !== e.scurry.nocase) throw new Error("nocase option contradicts provided scurry option");
3829
- } else this.scurry = new (e.platform === "win32" ? it : e.platform === "darwin" ? St : e.platform ? rt : Xe)(this.cwd, {
3830
- nocase: e.nocase,
3831
- fs: e.fs
3832
- });
3833
- this.nocase = this.scurry.nocase;
3834
- let s = this.platform === "darwin" || this.platform === "win32", i = {
3835
- braceExpandMax: 1e4,
3836
- ...e,
3837
- dot: this.dot,
3838
- matchBase: this.matchBase,
3839
- nobrace: this.nobrace,
3840
- nocase: this.nocase,
3841
- nocaseMagicOnly: s,
3842
- nocomment: !0,
3843
- noext: this.noext,
3844
- nonegate: !0,
3845
- optimizationLevel: 2,
3846
- platform: this.platform,
3847
- windowsPathsNoEscape: this.windowsPathsNoEscape,
3848
- debug: !!this.opts.debug
3849
- }, [o, h] = this.pattern.map((a) => new D(a, i)).reduce((a, l) => (a[0].push(...l.set), a[1].push(...l.globParts), a), [[], []]);
3850
- this.patterns = o.map((a, l) => {
3851
- let u = h[l];
3852
- if (!u) throw new Error("invalid pattern object");
3853
- return new nt(a, u, 0, this.platform);
3557
+ Object.defineProperty(styles$1, groupName, {
3558
+ value: group,
3559
+ enumerable: false
3854
3560
  });
3855
3561
  }
3856
- async walk() {
3857
- return [...await new xt(this.patterns, this.scurry.cwd, {
3858
- ...this.opts,
3859
- maxDepth: this.maxDepth !== Infinity ? this.maxDepth + this.scurry.cwd.depth() : Infinity,
3860
- platform: this.platform,
3861
- nocase: this.nocase,
3862
- includeChildMatches: this.includeChildMatches
3863
- }).walk()];
3864
- }
3865
- walkSync() {
3866
- return [...new xt(this.patterns, this.scurry.cwd, {
3867
- ...this.opts,
3868
- maxDepth: this.maxDepth !== Infinity ? this.maxDepth + this.scurry.cwd.depth() : Infinity,
3869
- platform: this.platform,
3870
- nocase: this.nocase,
3871
- includeChildMatches: this.includeChildMatches
3872
- }).walkSync()];
3873
- }
3874
- stream() {
3875
- return new vt(this.patterns, this.scurry.cwd, {
3876
- ...this.opts,
3877
- maxDepth: this.maxDepth !== Infinity ? this.maxDepth + this.scurry.cwd.depth() : Infinity,
3878
- platform: this.platform,
3879
- nocase: this.nocase,
3880
- includeChildMatches: this.includeChildMatches
3881
- }).stream();
3882
- }
3883
- streamSync() {
3884
- return new vt(this.patterns, this.scurry.cwd, {
3885
- ...this.opts,
3886
- maxDepth: this.maxDepth !== Infinity ? this.maxDepth + this.scurry.cwd.depth() : Infinity,
3887
- platform: this.platform,
3888
- nocase: this.nocase,
3889
- includeChildMatches: this.includeChildMatches
3890
- }).streamSync();
3562
+ Object.defineProperty(styles$1, "codes", {
3563
+ value: codes,
3564
+ enumerable: false
3565
+ });
3566
+ styles$1.color.close = "\x1B[39m";
3567
+ styles$1.bgColor.close = "\x1B[49m";
3568
+ styles$1.color.ansi = wrapAnsi16();
3569
+ styles$1.color.ansi256 = wrapAnsi256();
3570
+ styles$1.color.ansi16m = wrapAnsi16m();
3571
+ styles$1.bgColor.ansi = wrapAnsi16(ANSI_BACKGROUND_OFFSET);
3572
+ styles$1.bgColor.ansi256 = wrapAnsi256(ANSI_BACKGROUND_OFFSET);
3573
+ styles$1.bgColor.ansi16m = wrapAnsi16m(ANSI_BACKGROUND_OFFSET);
3574
+ Object.defineProperties(styles$1, {
3575
+ rgbToAnsi256: {
3576
+ value(red, green, blue) {
3577
+ if (red === green && green === blue) {
3578
+ if (red < 8) return 16;
3579
+ if (red > 248) return 231;
3580
+ return Math.round((red - 8) / 247 * 24) + 232;
3581
+ }
3582
+ return 16 + 36 * Math.round(red / 255 * 5) + 6 * Math.round(green / 255 * 5) + Math.round(blue / 255 * 5);
3583
+ },
3584
+ enumerable: false
3585
+ },
3586
+ hexToRgb: {
3587
+ value(hex) {
3588
+ const matches = /[a-f\d]{6}|[a-f\d]{3}/i.exec(hex.toString(16));
3589
+ if (!matches) return [
3590
+ 0,
3591
+ 0,
3592
+ 0
3593
+ ];
3594
+ let [colorString] = matches;
3595
+ if (colorString.length === 3) colorString = [...colorString].map((character) => character + character).join("");
3596
+ const integer = Number.parseInt(colorString, 16);
3597
+ return [
3598
+ integer >> 16 & 255,
3599
+ integer >> 8 & 255,
3600
+ integer & 255
3601
+ ];
3602
+ },
3603
+ enumerable: false
3604
+ },
3605
+ hexToAnsi256: {
3606
+ value: (hex) => styles$1.rgbToAnsi256(...styles$1.hexToRgb(hex)),
3607
+ enumerable: false
3608
+ },
3609
+ ansi256ToAnsi: {
3610
+ value(code) {
3611
+ if (code < 8) return 30 + code;
3612
+ if (code < 16) return 90 + (code - 8);
3613
+ let red;
3614
+ let green;
3615
+ let blue;
3616
+ if (code >= 232) {
3617
+ red = ((code - 232) * 10 + 8) / 255;
3618
+ green = red;
3619
+ blue = red;
3620
+ } else {
3621
+ code -= 16;
3622
+ const remainder = code % 36;
3623
+ red = Math.floor(code / 36) / 5;
3624
+ green = Math.floor(remainder / 6) / 5;
3625
+ blue = remainder % 6 / 5;
3626
+ }
3627
+ const value = Math.max(red, green, blue) * 2;
3628
+ if (value === 0) return 30;
3629
+ let result = 30 + (Math.round(blue) << 2 | Math.round(green) << 1 | Math.round(red));
3630
+ if (value === 2) result += 60;
3631
+ return result;
3632
+ },
3633
+ enumerable: false
3634
+ },
3635
+ rgbToAnsi: {
3636
+ value: (red, green, blue) => styles$1.ansi256ToAnsi(styles$1.rgbToAnsi256(red, green, blue)),
3637
+ enumerable: false
3638
+ },
3639
+ hexToAnsi: {
3640
+ value: (hex) => styles$1.ansi256ToAnsi(styles$1.hexToAnsi256(hex)),
3641
+ enumerable: false
3642
+ }
3643
+ });
3644
+ return styles$1;
3645
+ }
3646
+ const ansiStyles = assembleStyles();
3647
+ //#endregion
3648
+ //#region node_modules/.pnpm/chalk@5.6.2/node_modules/chalk/source/vendor/supports-color/index.js
3649
+ function hasFlag(flag, argv = globalThis.Deno ? globalThis.Deno.args : process$1.argv) {
3650
+ const prefix = flag.startsWith("-") ? "" : flag.length === 1 ? "-" : "--";
3651
+ const position = argv.indexOf(prefix + flag);
3652
+ const terminatorPosition = argv.indexOf("--");
3653
+ return position !== -1 && (terminatorPosition === -1 || position < terminatorPosition);
3654
+ }
3655
+ const { env } = process$1;
3656
+ let flagForceColor;
3657
+ if (hasFlag("no-color") || hasFlag("no-colors") || hasFlag("color=false") || hasFlag("color=never")) flagForceColor = 0;
3658
+ else if (hasFlag("color") || hasFlag("colors") || hasFlag("color=true") || hasFlag("color=always")) flagForceColor = 1;
3659
+ function envForceColor() {
3660
+ if ("FORCE_COLOR" in env) {
3661
+ if (env.FORCE_COLOR === "true") return 1;
3662
+ if (env.FORCE_COLOR === "false") return 0;
3663
+ return env.FORCE_COLOR.length === 0 ? 1 : Math.min(Number.parseInt(env.FORCE_COLOR, 10), 3);
3891
3664
  }
3892
- iterateSync() {
3893
- return this.streamSync()[Symbol.iterator]();
3665
+ }
3666
+ function translateLevel(level) {
3667
+ if (level === 0) return false;
3668
+ return {
3669
+ level,
3670
+ hasBasic: true,
3671
+ has256: level >= 2,
3672
+ has16m: level >= 3
3673
+ };
3674
+ }
3675
+ function _supportsColor(haveStream, { streamIsTTY, sniffFlags = true } = {}) {
3676
+ const noFlagForceColor = envForceColor();
3677
+ if (noFlagForceColor !== void 0) flagForceColor = noFlagForceColor;
3678
+ const forceColor = sniffFlags ? flagForceColor : noFlagForceColor;
3679
+ if (forceColor === 0) return 0;
3680
+ if (sniffFlags) {
3681
+ if (hasFlag("color=16m") || hasFlag("color=full") || hasFlag("color=truecolor")) return 3;
3682
+ if (hasFlag("color=256")) return 2;
3894
3683
  }
3895
- [Symbol.iterator]() {
3896
- return this.iterateSync();
3684
+ if ("TF_BUILD" in env && "AGENT_NAME" in env) return 1;
3685
+ if (haveStream && !streamIsTTY && forceColor === void 0) return 0;
3686
+ const min = forceColor || 0;
3687
+ if (env.TERM === "dumb") return min;
3688
+ if (process$1.platform === "win32") {
3689
+ const osRelease = os.release().split(".");
3690
+ if (Number(osRelease[0]) >= 10 && Number(osRelease[2]) >= 10586) return Number(osRelease[2]) >= 14931 ? 3 : 2;
3691
+ return 1;
3897
3692
  }
3898
- iterate() {
3899
- return this.stream()[Symbol.asyncIterator]();
3693
+ if ("CI" in env) {
3694
+ if ([
3695
+ "GITHUB_ACTIONS",
3696
+ "GITEA_ACTIONS",
3697
+ "CIRCLECI"
3698
+ ].some((key) => key in env)) return 3;
3699
+ if ([
3700
+ "TRAVIS",
3701
+ "APPVEYOR",
3702
+ "GITLAB_CI",
3703
+ "BUILDKITE",
3704
+ "DRONE"
3705
+ ].some((sign) => sign in env) || env.CI_NAME === "codeship") return 1;
3706
+ return min;
3900
3707
  }
3901
- [Symbol.asyncIterator]() {
3902
- return this.iterate();
3708
+ if ("TEAMCITY_VERSION" in env) return /^(9\.(0*[1-9]\d*)\.|\d{2,}\.)/.test(env.TEAMCITY_VERSION) ? 1 : 0;
3709
+ if (env.COLORTERM === "truecolor") return 3;
3710
+ if (env.TERM === "xterm-kitty") return 3;
3711
+ if (env.TERM === "xterm-ghostty") return 3;
3712
+ if (env.TERM === "wezterm") return 3;
3713
+ if ("TERM_PROGRAM" in env) {
3714
+ const version = Number.parseInt((env.TERM_PROGRAM_VERSION || "").split(".")[0], 10);
3715
+ switch (env.TERM_PROGRAM) {
3716
+ case "iTerm.app": return version >= 3 ? 3 : 2;
3717
+ case "Apple_Terminal": return 2;
3718
+ }
3903
3719
  }
3904
- };
3905
- var le = (n, t = {}) => {
3906
- Array.isArray(n) || (n = [n]);
3907
- for (let e of n) if (new D(e, t).hasMagic()) return !0;
3908
- return !1;
3909
- };
3910
- function Bt(n, t = {}) {
3911
- return new I(n, t).streamSync();
3912
- }
3913
- function Qe(n, t = {}) {
3914
- return new I(n, t).stream();
3915
- }
3916
- function ts(n, t = {}) {
3917
- return new I(n, t).walkSync();
3918
- }
3919
- async function Je(n, t = {}) {
3920
- return new I(n, t).walk();
3921
- }
3922
- function Ut(n, t = {}) {
3923
- return new I(n, t).iterateSync();
3720
+ if (/-256(color)?$/i.test(env.TERM)) return 2;
3721
+ if (/^screen|^xterm|^vt100|^vt220|^rxvt|color|ansi|cygwin|linux/i.test(env.TERM)) return 1;
3722
+ if ("COLORTERM" in env) return 1;
3723
+ return min;
3924
3724
  }
3925
- function es(n, t = {}) {
3926
- return new I(n, t).iterate();
3725
+ function createSupportsColor(stream, options = {}) {
3726
+ return translateLevel(_supportsColor(stream, {
3727
+ streamIsTTY: stream && stream.isTTY,
3728
+ ...options
3729
+ }));
3927
3730
  }
3928
- var ji = Bt, Ii = Object.assign(Qe, { sync: Bt }), zi = Ut, Bi = Object.assign(es, { sync: Ut }), Ui = Object.assign(ts, {
3929
- stream: Bt,
3930
- iterate: Ut
3931
- }), Ze = Object.assign(Je, {
3932
- glob: Je,
3933
- globSync: ts,
3934
- sync: Ui,
3935
- globStream: Qe,
3936
- stream: Ii,
3937
- globStreamSync: Bt,
3938
- streamSync: ji,
3939
- globIterate: es,
3940
- iterate: Bi,
3941
- globIterateSync: Ut,
3942
- iterateSync: zi,
3943
- Glob: I,
3944
- hasMagic: le,
3945
- escape: tt,
3946
- unescape: W
3947
- });
3948
- Ze.glob = Ze;
3731
+ const supportsColor = {
3732
+ stdout: createSupportsColor({ isTTY: tty.isatty(1) }),
3733
+ stderr: createSupportsColor({ isTTY: tty.isatty(2) })
3734
+ };
3949
3735
  //#endregion
3950
- //#region node_modules/.pnpm/es-toolkit@1.45.1/node_modules/es-toolkit/dist/compat/predicate/isArrayLike.mjs
3951
- function isArrayLike(value) {
3952
- return value != null && typeof value !== "function" && isLength(value.length);
3736
+ //#region node_modules/.pnpm/chalk@5.6.2/node_modules/chalk/source/utilities.js
3737
+ function stringReplaceAll(string, substring, replacer) {
3738
+ let index = string.indexOf(substring);
3739
+ if (index === -1) return string;
3740
+ const substringLength = substring.length;
3741
+ let endIndex = 0;
3742
+ let returnValue = "";
3743
+ do {
3744
+ returnValue += string.slice(endIndex, index) + substring + replacer;
3745
+ endIndex = index + substringLength;
3746
+ index = string.indexOf(substring, endIndex);
3747
+ } while (index !== -1);
3748
+ returnValue += string.slice(endIndex);
3749
+ return returnValue;
3953
3750
  }
3954
- //#endregion
3955
- //#region node_modules/.pnpm/es-toolkit@1.45.1/node_modules/es-toolkit/dist/compat/_internal/toKey.mjs
3956
- function toKey(value) {
3957
- if (typeof value === "string" || typeof value === "symbol") return value;
3958
- if (Object.is(value?.valueOf?.(), -0)) return "-0";
3959
- return String(value);
3751
+ function stringEncaseCRLFWithFirstIndex(string, prefix, postfix, index) {
3752
+ let endIndex = 0;
3753
+ let returnValue = "";
3754
+ do {
3755
+ const gotCR = string[index - 1] === "\r";
3756
+ returnValue += string.slice(endIndex, gotCR ? index - 1 : index) + prefix + (gotCR ? "\r\n" : "\n") + postfix;
3757
+ endIndex = index + 1;
3758
+ index = string.indexOf("\n", endIndex);
3759
+ } while (index !== -1);
3760
+ returnValue += string.slice(endIndex);
3761
+ return returnValue;
3960
3762
  }
3961
3763
  //#endregion
3962
- //#region node_modules/.pnpm/es-toolkit@1.45.1/node_modules/es-toolkit/dist/compat/util/toString.mjs
3963
- function toString(value) {
3964
- if (value == null) return "";
3965
- if (typeof value === "string") return value;
3966
- if (Array.isArray(value)) return value.map(toString).join(",");
3967
- const result = String(value);
3968
- if (result === "0" && Object.is(Number(value), -0)) return "-0";
3969
- return result;
3764
+ //#region node_modules/.pnpm/chalk@5.6.2/node_modules/chalk/source/index.js
3765
+ const { stdout: stdoutColor, stderr: stderrColor } = supportsColor;
3766
+ const GENERATOR = Symbol("GENERATOR");
3767
+ const STYLER = Symbol("STYLER");
3768
+ const IS_EMPTY = Symbol("IS_EMPTY");
3769
+ const levelMapping = [
3770
+ "ansi",
3771
+ "ansi",
3772
+ "ansi256",
3773
+ "ansi16m"
3774
+ ];
3775
+ const styles = Object.create(null);
3776
+ const applyOptions = (object, options = {}) => {
3777
+ if (options.level && !(Number.isInteger(options.level) && options.level >= 0 && options.level <= 3)) throw new Error("The `level` option should be an integer from 0 to 3");
3778
+ const colorLevel = stdoutColor ? stdoutColor.level : 0;
3779
+ object.level = options.level === void 0 ? colorLevel : options.level;
3780
+ };
3781
+ const chalkFactory = (options) => {
3782
+ const chalk = (...strings) => strings.join(" ");
3783
+ applyOptions(chalk, options);
3784
+ Object.setPrototypeOf(chalk, createChalk.prototype);
3785
+ return chalk;
3786
+ };
3787
+ function createChalk(options) {
3788
+ return chalkFactory(options);
3789
+ }
3790
+ Object.setPrototypeOf(createChalk.prototype, Function.prototype);
3791
+ for (const [styleName, style] of Object.entries(ansiStyles)) styles[styleName] = { get() {
3792
+ const builder = createBuilder(this, createStyler(style.open, style.close, this[STYLER]), this[IS_EMPTY]);
3793
+ Object.defineProperty(this, styleName, { value: builder });
3794
+ return builder;
3795
+ } };
3796
+ styles.visible = { get() {
3797
+ const builder = createBuilder(this, this[STYLER], true);
3798
+ Object.defineProperty(this, "visible", { value: builder });
3799
+ return builder;
3800
+ } };
3801
+ const getModelAnsi = (model, level, type, ...arguments_) => {
3802
+ if (model === "rgb") {
3803
+ if (level === "ansi16m") return ansiStyles[type].ansi16m(...arguments_);
3804
+ if (level === "ansi256") return ansiStyles[type].ansi256(ansiStyles.rgbToAnsi256(...arguments_));
3805
+ return ansiStyles[type].ansi(ansiStyles.rgbToAnsi(...arguments_));
3806
+ }
3807
+ if (model === "hex") return getModelAnsi("rgb", level, type, ...ansiStyles.hexToRgb(...arguments_));
3808
+ return ansiStyles[type][model](...arguments_);
3809
+ };
3810
+ for (const model of [
3811
+ "rgb",
3812
+ "hex",
3813
+ "ansi256"
3814
+ ]) {
3815
+ styles[model] = { get() {
3816
+ const { level } = this;
3817
+ return function(...arguments_) {
3818
+ const styler = createStyler(getModelAnsi(model, levelMapping[level], "color", ...arguments_), ansiStyles.color.close, this[STYLER]);
3819
+ return createBuilder(this, styler, this[IS_EMPTY]);
3820
+ };
3821
+ } };
3822
+ const bgModel = "bg" + model[0].toUpperCase() + model.slice(1);
3823
+ styles[bgModel] = { get() {
3824
+ const { level } = this;
3825
+ return function(...arguments_) {
3826
+ const styler = createStyler(getModelAnsi(model, levelMapping[level], "bgColor", ...arguments_), ansiStyles.bgColor.close, this[STYLER]);
3827
+ return createBuilder(this, styler, this[IS_EMPTY]);
3828
+ };
3829
+ } };
3970
3830
  }
3971
- //#endregion
3972
- //#region node_modules/.pnpm/es-toolkit@1.45.1/node_modules/es-toolkit/dist/compat/util/toPath.mjs
3973
- function toPath(deepKey) {
3974
- if (Array.isArray(deepKey)) return deepKey.map(toKey);
3975
- if (typeof deepKey === "symbol") return [deepKey];
3976
- deepKey = toString(deepKey);
3977
- const result = [];
3978
- const length = deepKey.length;
3979
- if (length === 0) return result;
3980
- let index = 0;
3981
- let key = "";
3982
- let quoteChar = "";
3983
- let bracket = false;
3984
- if (deepKey.charCodeAt(0) === 46) {
3985
- result.push("");
3986
- index++;
3831
+ const proto = Object.defineProperties(() => {}, {
3832
+ ...styles,
3833
+ level: {
3834
+ enumerable: true,
3835
+ get() {
3836
+ return this[GENERATOR].level;
3837
+ },
3838
+ set(level) {
3839
+ this[GENERATOR].level = level;
3840
+ }
3987
3841
  }
3988
- while (index < length) {
3989
- const char = deepKey[index];
3990
- if (quoteChar) if (char === "\\" && index + 1 < length) {
3991
- index++;
3992
- key += deepKey[index];
3993
- } else if (char === quoteChar) quoteChar = "";
3994
- else key += char;
3995
- else if (bracket) if (char === "\"" || char === "'") quoteChar = char;
3996
- else if (char === "]") {
3997
- bracket = false;
3998
- result.push(key);
3999
- key = "";
4000
- } else key += char;
4001
- else if (char === "[") {
4002
- bracket = true;
4003
- if (key) {
4004
- result.push(key);
4005
- key = "";
4006
- }
4007
- } else if (char === ".") {
4008
- if (key) {
4009
- result.push(key);
4010
- key = "";
4011
- }
4012
- } else key += char;
4013
- index++;
3842
+ });
3843
+ const createStyler = (open, close, parent) => {
3844
+ let openAll;
3845
+ let closeAll;
3846
+ if (parent === void 0) {
3847
+ openAll = open;
3848
+ closeAll = close;
3849
+ } else {
3850
+ openAll = parent.openAll + open;
3851
+ closeAll = close + parent.closeAll;
4014
3852
  }
4015
- if (key) result.push(key);
4016
- return result;
4017
- }
4018
- //#endregion
4019
- //#region node_modules/.pnpm/es-toolkit@1.45.1/node_modules/es-toolkit/dist/compat/predicate/isObject.mjs
4020
- function isObject(value) {
4021
- return value !== null && (typeof value === "object" || typeof value === "function");
4022
- }
3853
+ return {
3854
+ open,
3855
+ close,
3856
+ openAll,
3857
+ closeAll,
3858
+ parent
3859
+ };
3860
+ };
3861
+ const createBuilder = (self, _styler, _isEmpty) => {
3862
+ const builder = (...arguments_) => applyStyle(builder, arguments_.length === 1 ? "" + arguments_[0] : arguments_.join(" "));
3863
+ Object.setPrototypeOf(builder, proto);
3864
+ builder[GENERATOR] = self;
3865
+ builder[STYLER] = _styler;
3866
+ builder[IS_EMPTY] = _isEmpty;
3867
+ return builder;
3868
+ };
3869
+ const applyStyle = (self, string) => {
3870
+ if (self.level <= 0 || !string) return self[IS_EMPTY] ? "" : string;
3871
+ let styler = self[STYLER];
3872
+ if (styler === void 0) return string;
3873
+ const { openAll, closeAll } = styler;
3874
+ if (string.includes("\x1B")) while (styler !== void 0) {
3875
+ string = stringReplaceAll(string, styler.close, styler.open);
3876
+ styler = styler.parent;
3877
+ }
3878
+ const lfIndex = string.indexOf("\n");
3879
+ if (lfIndex !== -1) string = stringEncaseCRLFWithFirstIndex(string, closeAll, openAll, lfIndex);
3880
+ return openAll + string + closeAll;
3881
+ };
3882
+ Object.defineProperties(createChalk.prototype, styles);
3883
+ const chalk = createChalk();
3884
+ createChalk({ level: stderrColor ? stderrColor.level : 0 });
4023
3885
  //#endregion
4024
- //#region node_modules/.pnpm/es-toolkit@1.45.1/node_modules/es-toolkit/dist/compat/_internal/isIndex.mjs
4025
- const IS_UNSIGNED_INTEGER = /^(?:0|[1-9]\d*)$/;
4026
- function isIndex(value, length = Number.MAX_SAFE_INTEGER) {
4027
- switch (typeof value) {
4028
- case "number": return Number.isInteger(value) && value >= 0 && value < length;
4029
- case "symbol": return false;
4030
- case "string": return IS_UNSIGNED_INTEGER.test(value);
3886
+ //#region src/validator/ajv-validators.ts
3887
+ const planSchemaValidator = validate14;
3888
+ const schema32 = {
3889
+ "type": "array",
3890
+ "items": {
3891
+ "type": "object",
3892
+ "properties": {
3893
+ "fileHash": { "type": ["string"] },
3894
+ "fileName": { "type": "string" },
3895
+ "sequence": {
3896
+ "type": "string",
3897
+ "pattern": "^[1-9][0-9]*(.[1-9][0-9]*)*$"
3898
+ }
3899
+ },
3900
+ "required": [
3901
+ "fileHash",
3902
+ "fileName",
3903
+ "sequence"
3904
+ ],
3905
+ "additionalProperties": false
3906
+ }
3907
+ };
3908
+ const pattern0 = /* @__PURE__ */ new RegExp("^[1-9][0-9]*(.[1-9][0-9]*)*$", "u");
3909
+ function validate14(data, { instancePath = "", parentData, parentDataProperty, rootData = data } = {}) {
3910
+ let vErrors = null;
3911
+ let errors = 0;
3912
+ if (Array.isArray(data)) {
3913
+ const len0 = data.length;
3914
+ for (let i0 = 0; i0 < len0; i0++) {
3915
+ let data0 = data[i0];
3916
+ if (data0 && typeof data0 == "object" && !Array.isArray(data0)) {
3917
+ if (data0.fileHash === void 0) {
3918
+ const err0 = {
3919
+ instancePath: instancePath + "/" + i0,
3920
+ schemaPath: "#/items/required",
3921
+ keyword: "required",
3922
+ params: { missingProperty: "fileHash" },
3923
+ message: "must have required property 'fileHash'"
3924
+ };
3925
+ if (vErrors === null) vErrors = [err0];
3926
+ else vErrors.push(err0);
3927
+ errors++;
3928
+ }
3929
+ if (data0.fileName === void 0) {
3930
+ const err1 = {
3931
+ instancePath: instancePath + "/" + i0,
3932
+ schemaPath: "#/items/required",
3933
+ keyword: "required",
3934
+ params: { missingProperty: "fileName" },
3935
+ message: "must have required property 'fileName'"
3936
+ };
3937
+ if (vErrors === null) vErrors = [err1];
3938
+ else vErrors.push(err1);
3939
+ errors++;
3940
+ }
3941
+ if (data0.sequence === void 0) {
3942
+ const err2 = {
3943
+ instancePath: instancePath + "/" + i0,
3944
+ schemaPath: "#/items/required",
3945
+ keyword: "required",
3946
+ params: { missingProperty: "sequence" },
3947
+ message: "must have required property 'sequence'"
3948
+ };
3949
+ if (vErrors === null) vErrors = [err2];
3950
+ else vErrors.push(err2);
3951
+ errors++;
3952
+ }
3953
+ for (const key0 in data0) if (!(key0 === "fileHash" || key0 === "fileName" || key0 === "sequence")) {
3954
+ const err3 = {
3955
+ instancePath: instancePath + "/" + i0,
3956
+ schemaPath: "#/items/additionalProperties",
3957
+ keyword: "additionalProperties",
3958
+ params: { additionalProperty: key0 },
3959
+ message: "must NOT have additional properties"
3960
+ };
3961
+ if (vErrors === null) vErrors = [err3];
3962
+ else vErrors.push(err3);
3963
+ errors++;
3964
+ }
3965
+ if (data0.fileHash !== void 0) {
3966
+ if (typeof data0.fileHash !== "string") {
3967
+ const err4 = {
3968
+ instancePath: instancePath + "/" + i0 + "/fileHash",
3969
+ schemaPath: "#/items/properties/fileHash/type",
3970
+ keyword: "type",
3971
+ params: { type: schema32.items.properties.fileHash.type },
3972
+ message: "must be string"
3973
+ };
3974
+ if (vErrors === null) vErrors = [err4];
3975
+ else vErrors.push(err4);
3976
+ errors++;
3977
+ }
3978
+ }
3979
+ if (data0.fileName !== void 0) {
3980
+ if (typeof data0.fileName !== "string") {
3981
+ const err5 = {
3982
+ instancePath: instancePath + "/" + i0 + "/fileName",
3983
+ schemaPath: "#/items/properties/fileName/type",
3984
+ keyword: "type",
3985
+ params: { type: "string" },
3986
+ message: "must be string"
3987
+ };
3988
+ if (vErrors === null) vErrors = [err5];
3989
+ else vErrors.push(err5);
3990
+ errors++;
3991
+ }
3992
+ }
3993
+ if (data0.sequence !== void 0) {
3994
+ let data3 = data0.sequence;
3995
+ if (typeof data3 === "string") {
3996
+ if (!pattern0.test(data3)) {
3997
+ const err6 = {
3998
+ instancePath: instancePath + "/" + i0 + "/sequence",
3999
+ schemaPath: "#/items/properties/sequence/pattern",
4000
+ keyword: "pattern",
4001
+ params: { pattern: "^[1-9][0-9]*(.[1-9][0-9]*)*$" },
4002
+ message: "must match pattern \"^[1-9][0-9]*(.[1-9][0-9]*)*$\""
4003
+ };
4004
+ if (vErrors === null) vErrors = [err6];
4005
+ else vErrors.push(err6);
4006
+ errors++;
4007
+ }
4008
+ } else {
4009
+ const err7 = {
4010
+ instancePath: instancePath + "/" + i0 + "/sequence",
4011
+ schemaPath: "#/items/properties/sequence/type",
4012
+ keyword: "type",
4013
+ params: { type: "string" },
4014
+ message: "must be string"
4015
+ };
4016
+ if (vErrors === null) vErrors = [err7];
4017
+ else vErrors.push(err7);
4018
+ errors++;
4019
+ }
4020
+ }
4021
+ } else {
4022
+ const err8 = {
4023
+ instancePath: instancePath + "/" + i0,
4024
+ schemaPath: "#/items/type",
4025
+ keyword: "type",
4026
+ params: { type: "object" },
4027
+ message: "must be object"
4028
+ };
4029
+ if (vErrors === null) vErrors = [err8];
4030
+ else vErrors.push(err8);
4031
+ errors++;
4032
+ }
4033
+ }
4034
+ } else {
4035
+ const err9 = {
4036
+ instancePath,
4037
+ schemaPath: "#/type",
4038
+ keyword: "type",
4039
+ params: { type: "array" },
4040
+ message: "must be array"
4041
+ };
4042
+ if (vErrors === null) vErrors = [err9];
4043
+ else vErrors.push(err9);
4044
+ errors++;
4031
4045
  }
4046
+ validate14.errors = vErrors;
4047
+ return errors === 0;
4032
4048
  }
4033
4049
  //#endregion
4034
- //#region node_modules/.pnpm/es-toolkit@1.45.1/node_modules/es-toolkit/dist/compat/_internal/isIterateeCall.mjs
4035
- function isIterateeCall(value, index, object) {
4036
- if (!isObject(object)) return false;
4037
- if (typeof index === "number" && isArrayLike(object) && isIndex(index) && index < object.length || typeof index === "string" && index in object) return isEqualsSameValueZero(object[index], value);
4038
- return false;
4039
- }
4040
- //#endregion
4041
- //#region node_modules/.pnpm/es-toolkit@1.45.1/node_modules/es-toolkit/dist/compat/_internal/compareValues.mjs
4042
- function getPriority(a) {
4043
- if (typeof a === "symbol") return 1;
4044
- if (a === null) return 2;
4045
- if (a === void 0) return 3;
4046
- if (a !== a) return 4;
4047
- return 0;
4048
- }
4049
- const compareValues = (a, b, order) => {
4050
- if (a !== b) {
4051
- const aPriority = getPriority(a);
4052
- const bPriority = getPriority(b);
4053
- if (aPriority === bPriority && aPriority === 0) {
4054
- if (a < b) return order === "desc" ? 1 : -1;
4055
- if (a > b) return order === "desc" ? -1 : 1;
4056
- }
4057
- return order === "desc" ? bPriority - aPriority : aPriority - bPriority;
4050
+ //#region src/validator/validator.ts
4051
+ const isNonEmptyString = (input) => isString(input) && input.length > 0;
4052
+ /**
4053
+ * Validates if a plan matches the schema
4054
+ */
4055
+ const validatePlan = (plan) => {
4056
+ const valid = planSchemaValidator(plan);
4057
+ const errors = planSchemaValidator.errors;
4058
+ if (errors?.length) errors.forEach((e) => console.error(`${e.message}${e.instancePath ? `at ${e.instancePath}` : ""}`));
4059
+ return valid;
4060
+ };
4061
+ /**
4062
+ * Validates if file description format is valid
4063
+ */
4064
+ const validateFileDescription = (description) => {
4065
+ if (!description) return false;
4066
+ return /^([a-z]+|(([a-z]+-)+[a-z]+))$/g.test(description);
4067
+ };
4068
+ /**
4069
+ * Validates if fileName format is valid
4070
+ */
4071
+ const validateFileName = (fileName) => {
4072
+ return /^([a-z]+|(([a-z]+-)+[a-z]+))(.js|.skip.js)$/g.test(fileName);
4073
+ };
4074
+ /**
4075
+ * Throws if file names are invalid
4076
+ */
4077
+ const throwIfFileNamesInvalid = (fileEntries) => {
4078
+ const invalidFileNames = fileEntries.filter((f) => !f.isValidFileName).map((f) => f.fileName);
4079
+ if (invalidFileNames.length) {
4080
+ invalidFileNames.forEach((name) => console.error(chalk.red(name)));
4081
+ throw new Error("Invalid migration filename format (use kebab-case)");
4058
4082
  }
4059
- return 0;
4060
4083
  };
4061
- //#endregion
4062
- //#region node_modules/.pnpm/es-toolkit@1.45.1/node_modules/es-toolkit/dist/compat/_internal/isKey.mjs
4063
- const regexIsDeepProp = /\.|\[(?:[^[\]]*|(["'])(?:(?!\1)[^\\]|\\.)*?\1)\]/;
4064
- const regexIsPlainProp = /^\w*$/;
4065
- function isKey(value, object) {
4066
- if (Array.isArray(value)) return false;
4067
- if (typeof value === "number" || typeof value === "boolean" || value == null || isSymbol(value)) return true;
4068
- return typeof value === "string" && (regexIsPlainProp.test(value) || !regexIsDeepProp.test(value)) || object != null && Object.hasOwn(object, value);
4069
- }
4070
- //#endregion
4071
- //#region node_modules/.pnpm/es-toolkit@1.45.1/node_modules/es-toolkit/dist/compat/array/orderBy.mjs
4072
- function orderBy(collection, criteria, orders, guard) {
4073
- if (collection == null) return [];
4074
- orders = guard ? void 0 : orders;
4075
- if (!Array.isArray(collection)) collection = Object.values(collection);
4076
- if (!Array.isArray(criteria)) criteria = criteria == null ? [null] : [criteria];
4077
- if (criteria.length === 0) criteria = [null];
4078
- if (!Array.isArray(orders)) orders = orders == null ? [] : [orders];
4079
- orders = orders.map((order) => String(order));
4080
- const getValueByNestedPath = (object, path) => {
4081
- let target = object;
4082
- for (let i = 0; i < path.length && target != null; ++i) target = target[path[i]];
4083
- return target;
4084
- };
4085
- const getValueByCriterion = (criterion, object) => {
4086
- if (object == null || criterion == null) return object;
4087
- if (typeof criterion === "object" && "key" in criterion) {
4088
- if (Object.hasOwn(object, criterion.key)) return object[criterion.key];
4089
- return getValueByNestedPath(object, criterion.path);
4090
- }
4091
- if (typeof criterion === "function") return criterion(object);
4092
- if (Array.isArray(criterion)) return getValueByNestedPath(object, criterion);
4093
- if (typeof object === "object") return object[criterion];
4094
- return object;
4095
- };
4096
- const preparedCriteria = criteria.map((criterion) => {
4097
- if (Array.isArray(criterion) && criterion.length === 1) criterion = criterion[0];
4098
- if (criterion == null || typeof criterion === "function" || Array.isArray(criterion) || isKey(criterion)) return criterion;
4099
- return {
4100
- key: criterion,
4101
- path: toPath(criterion)
4102
- };
4103
- });
4104
- return collection.map((item) => ({
4105
- original: item,
4106
- criteria: preparedCriteria.map((criterion) => getValueByCriterion(criterion, item))
4107
- })).slice().sort((a, b) => {
4108
- for (let i = 0; i < preparedCriteria.length; i++) {
4109
- const comparedResult = compareValues(a.criteria[i], b.criteria[i], orders[i]);
4110
- if (comparedResult !== 0) return comparedResult;
4111
- }
4112
- return 0;
4113
- }).map((item) => item.original);
4114
- }
4115
- //#endregion
4116
- //#region node_modules/.pnpm/es-toolkit@1.45.1/node_modules/es-toolkit/dist/compat/array/sortBy.mjs
4117
- function sortBy(collection, ...criteria) {
4118
- const length = criteria.length;
4119
- if (length > 1 && isIterateeCall(collection, criteria[0], criteria[1])) criteria = [];
4120
- else if (length > 2 && isIterateeCall(criteria[0], criteria[1], criteria[2])) criteria = [criteria[0]];
4121
- return orderBy(collection, flatten(criteria), ["asc"]);
4122
- }
4123
- //#endregion
4124
- //#region src/glob/glob.ts
4125
4084
  /**
4126
- * Sorts migration file paths
4127
- *
4128
- * @param {Array<String>} filePaths
4129
- * @returns {Array<String>} sorted files
4085
+ * Warns if files have been removed
4130
4086
  */
4131
- const sortFilePathsByFilename = (filePaths) => sortBy(filePaths, (file) => {
4132
- return path.parse(file).base;
4133
- });
4087
+ const warnIfFilesHaveBeenRemovedFromPlan = (migrationEntries, historicalMigrations) => {
4088
+ const fileNames = migrationEntries.map((f) => f.fileName);
4089
+ const deletedFilesNames = historicalMigrations.filter((e) => !fileNames.includes(e.fileName)).map((e) => e.fileName);
4090
+ if (deletedFilesNames.length) {
4091
+ deletedFilesNames.forEach((name) => console.warn(chalk.yellow(name)));
4092
+ console.warn(chalk.yellow("Previously executed migration files have been deleted from plan.json (rename file to .skip.js and replace with a new file instead)"));
4093
+ }
4094
+ };
4134
4095
  /**
4135
- * Gets paths to entity migrations in a directory
4136
- *
4137
- * @param {String} pathToMigrations
4138
- * @returns {Promise<Array<String>>} matching migration filePaths
4096
+ * Throws error if any pre-existing file has changed
4139
4097
  */
4140
- const getMigrationFilePaths = async (pathToMigrations) => {
4141
- const filePath = (pattern) => `${pathToMigrations}${pattern}`;
4142
- return sortFilePathsByFilename(await Ze(filePath("/**/*.js"), { ignore: [
4143
- filePath("/**/*.skip?([0-9]*).js"),
4144
- filePath("/**/index.js"),
4145
- filePath("/**/plan.json"),
4146
- filePath("/**/*.bundle.js"),
4147
- filePath("/**/*.test.js"),
4148
- filePath("/**/*.spec.js"),
4149
- filePath("/**/__tests__/*"),
4150
- filePath("/**/__test__/*")
4151
- ] }));
4098
+ const throwIfFilesHaveChanged = (migrationEntries) => {
4099
+ const changedFilesNames = migrationEntries.filter((m) => {
4100
+ const { fileHash, fileHashFromPlan, fileHashFromHistory, skippedFileHashes } = m;
4101
+ const matchesHistory = !isNonEmptyString(fileHashFromHistory) || [fileHash].concat(skippedFileHashes).includes(fileHashFromHistory);
4102
+ const matchesPlan = !isNonEmptyString(fileHashFromPlan) || [fileHash].concat(skippedFileHashes).includes(fileHashFromPlan);
4103
+ return !(matchesHistory && matchesPlan);
4104
+ }).map((f) => f.fileName);
4105
+ if (changedFilesNames.length) {
4106
+ changedFilesNames.forEach((name) => console.error(chalk.red(name)));
4107
+ throw new Error("Not allowed to change migration files (for unreleased local work, you can use the `force` option)");
4108
+ }
4152
4109
  };
4153
4110
  /**
4154
- * Gets paths to skipped migrations in a directory
4155
- *
4156
- * @param {String} pathToMigrations
4157
- * @returns {Promise<Array<String>>} skipped migration filePaths
4111
+ * Throws error if previous sequence numbers have changed
4158
4112
  */
4159
- const getSkippedFilePaths = async (pathToMigrations) => {
4160
- const filePath = (pattern) => `${pathToMigrations}${pattern}`;
4161
- return sortFilePathsByFilename(await Ze(filePath("/**/*.skip?([0-9]*).js"), { ignore: [
4162
- filePath("/**/index.js"),
4163
- filePath("/**/plan.json"),
4164
- filePath("/**/*.bundle.js"),
4165
- filePath("/**/*.test.js"),
4166
- filePath("/**/*.spec.js"),
4167
- filePath("/**/__tests__/*"),
4168
- filePath("/**/__test__/*")
4169
- ] }));
4113
+ const throwIfSequenceHasChanged = (migrationEntries) => {
4114
+ const changeSequences = migrationEntries.filter((m) => {
4115
+ const { sequence, sequenceFromHistory } = m;
4116
+ return isString(sequenceFromHistory) && sequenceFromHistory !== sequence;
4117
+ }).map((f) => f.fileName);
4118
+ if (changeSequences.length) {
4119
+ changeSequences.forEach((name) => console.error(chalk.red(name)));
4120
+ throw new Error("Not allowed to change migration sequences in plan.json");
4121
+ }
4122
+ };
4123
+ /**
4124
+ * Throws error if sequence numbers are not unique
4125
+ */
4126
+ const throwIfSequenceNotUnique = (migrationEntries) => {
4127
+ const repeatedSequenceNumbers = migrationEntries.map((f) => f.sequence).filter(((s) => (v) => s.has(v) || !s.add(v))(/* @__PURE__ */ new Set()));
4128
+ const duplicates = migrationEntries.filter((f) => repeatedSequenceNumbers.includes(f.sequence)).map((f) => f.fileName);
4129
+ if (duplicates.length) {
4130
+ duplicates.forEach((fileName) => console.error(chalk.red(fileName)));
4131
+ throw new Error("Migrations must have unique sequence numbers in plan.json");
4132
+ }
4133
+ };
4134
+ /**
4135
+ * Throws error if sequence numbers are not unique
4136
+ */
4137
+ const throwIfSequenceHasIntegerGaps = (migrationEntries) => {
4138
+ const toInteger = (sequence) => parseInt(sequence.split(".")[0], 10);
4139
+ const unique = (arr) => Array.from(new Set(arr));
4140
+ const orderedUniqueSequenceIntegers = unique(migrationEntries.map((s) => s.sequence).map((s) => toInteger(s))).sort((a, b) => a - b);
4141
+ const max = orderedUniqueSequenceIntegers[orderedUniqueSequenceIntegers.length - 1];
4142
+ const missing = xor(orderedUniqueSequenceIntegers, Array.from({ length: max }, (_v, k) => k + 1));
4143
+ if (missing.length) throw new Error(`Migration sequence numbers in plan.json have unexpected gaps: ${missing.join(", ")}`);
4144
+ };
4145
+ /**
4146
+ * Throws error if file names are not unique
4147
+ */
4148
+ const throwIfFileNamesNotUnique = (migrationEntries) => {
4149
+ const repeatedFileNames = migrationEntries.map((f) => f.fileName).filter(((s) => (v) => s.has(v) || !s.add(v))(/* @__PURE__ */ new Set()));
4150
+ if (repeatedFileNames.length) {
4151
+ repeatedFileNames.forEach((fileName) => console.error(chalk.red(fileName)));
4152
+ throw new Error("Migration file names must be unique");
4153
+ }
4154
+ };
4155
+ /**
4156
+ * Throws error if files listed in plan.json are found
4157
+ */
4158
+ const throwIfFilesNotFound = (migrationEntries) => {
4159
+ const migrationsWithoutFiles = migrationEntries.filter((m) => !m.script || !m.script && !m.migrator);
4160
+ if (migrationsWithoutFiles.length) {
4161
+ migrationsWithoutFiles.forEach((migration) => console.error(chalk.red(migration.fileName)));
4162
+ throw new Error("Migration files from plan.json are missing from filesystem");
4163
+ }
4170
4164
  };
4171
4165
  //#endregion
4172
4166
  //#region src/database/database.ts
@@ -4500,6 +4494,28 @@ const getPlannedMigrations = async ({ config }) => {
4500
4494
  };
4501
4495
  const PlanModule = { getPlannedMigrations };
4502
4496
  //#endregion
4497
+ //#region src/plan/check-migration-plan.ts
4498
+ /** Check the committed plan against migration files without modifying files or accessing a database. */
4499
+ const checkMigrationPlan = async ({ directory }) => {
4500
+ const committedPlan = parsePlan$1(await readPlan(directory));
4501
+ const { validatedPlan } = await getPlannedMigrations({ config: {
4502
+ directory,
4503
+ dry: true
4504
+ } });
4505
+ for (const migration of validatedPlan) if (committedPlan.find((entry) => entry.fileName === migration.fileName)?.fileHash !== migration.fileHash) throw new Error(`Migration plan is out of date: ${migration.fileName}. Update and commit plan.json.`);
4506
+ const filePaths = await getMigrationFilePaths(directory);
4507
+ for (const filePath of filePaths) {
4508
+ const fileName = path.basename(filePath);
4509
+ if (!committedPlan.some((entry) => entry.fileName === fileName)) throw new Error(`Migration file is missing from plan.json: ${fileName}.`);
4510
+ }
4511
+ };
4512
+ //#endregion
4513
+ //#region src/helpers/helpers.ts
4514
+ const capitalize = (word) => {
4515
+ if (!word) return "";
4516
+ return word[0].toUpperCase() + word.slice(1);
4517
+ };
4518
+ //#endregion
4503
4519
  //#region src/create/create.ts
4504
4520
  const templateMigrationFileWithMetaDataLegacy = (entity) => `import produce from 'immer';
4505
4521
  //other imports not allowed
@@ -4940,4 +4956,4 @@ const printVersionHistory = async ({ config }) => {
4940
4956
  }
4941
4957
  };
4942
4958
  //#endregion
4943
- export { createMigration, getPlannedMigrations, getPlannedVersion, getVersions, migrate, migrateAll, pipe, printVersionHistory };
4959
+ export { checkMigrationPlan, createMigration, getPlannedMigrations, getPlannedVersion, getVersions, migrate, migrateAll, pipe, printVersionHistory };