drizzle-kit 0.17.6 → 0.18.0-27440c3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (5) hide show
  1. package/index.d.ts +14 -0
  2. package/index.js +20477 -19023
  3. package/package.json +8 -4
  4. package/readme.md +10 -1
  5. package/utils.js +1054 -965
package/utils.js CHANGED
@@ -28,371 +28,873 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
28
28
  ));
29
29
  var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
30
30
 
31
- // node_modules/.pnpm/hanji@0.0.5/node_modules/hanji/readline.js
32
- var require_readline = __commonJS({
33
- "node_modules/.pnpm/hanji@0.0.5/node_modules/hanji/readline.js"(exports) {
34
- "use strict";
35
- Object.defineProperty(exports, "__esModule", { value: true });
36
- exports.prepareReadLine = void 0;
37
- var prepareReadLine = () => {
38
- const stdin = process.stdin;
39
- const stdout = process.stdout;
40
- const readline = require("readline");
41
- const rl = readline.createInterface({
42
- input: stdin,
43
- escapeCodeTimeout: 50
44
- });
45
- readline.emitKeypressEvents(stdin, rl);
46
- return {
47
- stdin,
48
- stdout,
49
- closable: rl
31
+ // node_modules/.pnpm/chalk@5.2.0/node_modules/chalk/source/vendor/ansi-styles/index.js
32
+ function assembleStyles() {
33
+ const codes = /* @__PURE__ */ new Map();
34
+ for (const [groupName, group] of Object.entries(styles)) {
35
+ for (const [styleName, style] of Object.entries(group)) {
36
+ styles[styleName] = {
37
+ open: `\x1B[${style[0]}m`,
38
+ close: `\x1B[${style[1]}m`
50
39
  };
51
- };
52
- exports.prepareReadLine = prepareReadLine;
40
+ group[styleName] = styles[styleName];
41
+ codes.set(style[0], style[1]);
42
+ }
43
+ Object.defineProperty(styles, groupName, {
44
+ value: group,
45
+ enumerable: false
46
+ });
53
47
  }
54
- });
55
-
56
- // node_modules/.pnpm/sisteransi@1.0.5/node_modules/sisteransi/src/index.js
57
- var require_src = __commonJS({
58
- "node_modules/.pnpm/sisteransi@1.0.5/node_modules/sisteransi/src/index.js"(exports, module2) {
59
- "use strict";
60
- var ESC = "\x1B";
61
- var CSI = `${ESC}[`;
62
- var beep = "\x07";
63
- var cursor = {
64
- to(x, y) {
65
- if (!y)
66
- return `${CSI}${x + 1}G`;
67
- return `${CSI}${y + 1};${x + 1}H`;
48
+ Object.defineProperty(styles, "codes", {
49
+ value: codes,
50
+ enumerable: false
51
+ });
52
+ styles.color.close = "\x1B[39m";
53
+ styles.bgColor.close = "\x1B[49m";
54
+ styles.color.ansi = wrapAnsi16();
55
+ styles.color.ansi256 = wrapAnsi256();
56
+ styles.color.ansi16m = wrapAnsi16m();
57
+ styles.bgColor.ansi = wrapAnsi16(ANSI_BACKGROUND_OFFSET);
58
+ styles.bgColor.ansi256 = wrapAnsi256(ANSI_BACKGROUND_OFFSET);
59
+ styles.bgColor.ansi16m = wrapAnsi16m(ANSI_BACKGROUND_OFFSET);
60
+ Object.defineProperties(styles, {
61
+ rgbToAnsi256: {
62
+ value(red, green, blue) {
63
+ if (red === green && green === blue) {
64
+ if (red < 8) {
65
+ return 16;
66
+ }
67
+ if (red > 248) {
68
+ return 231;
69
+ }
70
+ return Math.round((red - 8) / 247 * 24) + 232;
71
+ }
72
+ return 16 + 36 * Math.round(red / 255 * 5) + 6 * Math.round(green / 255 * 5) + Math.round(blue / 255 * 5);
68
73
  },
69
- move(x, y) {
70
- let ret = "";
71
- if (x < 0)
72
- ret += `${CSI}${-x}D`;
73
- else if (x > 0)
74
- ret += `${CSI}${x}C`;
75
- if (y < 0)
76
- ret += `${CSI}${-y}A`;
77
- else if (y > 0)
78
- ret += `${CSI}${y}B`;
79
- return ret;
74
+ enumerable: false
75
+ },
76
+ hexToRgb: {
77
+ value(hex) {
78
+ const matches = /[a-f\d]{6}|[a-f\d]{3}/i.exec(hex.toString(16));
79
+ if (!matches) {
80
+ return [0, 0, 0];
81
+ }
82
+ let [colorString] = matches;
83
+ if (colorString.length === 3) {
84
+ colorString = [...colorString].map((character) => character + character).join("");
85
+ }
86
+ const integer = Number.parseInt(colorString, 16);
87
+ return [
88
+ integer >> 16 & 255,
89
+ integer >> 8 & 255,
90
+ integer & 255
91
+ ];
80
92
  },
81
- up: (count = 1) => `${CSI}${count}A`,
82
- down: (count = 1) => `${CSI}${count}B`,
83
- forward: (count = 1) => `${CSI}${count}C`,
84
- backward: (count = 1) => `${CSI}${count}D`,
85
- nextLine: (count = 1) => `${CSI}E`.repeat(count),
86
- prevLine: (count = 1) => `${CSI}F`.repeat(count),
87
- left: `${CSI}G`,
88
- hide: `${CSI}?25l`,
89
- show: `${CSI}?25h`,
90
- save: `${ESC}7`,
91
- restore: `${ESC}8`
92
- };
93
- var scroll = {
94
- up: (count = 1) => `${CSI}S`.repeat(count),
95
- down: (count = 1) => `${CSI}T`.repeat(count)
96
- };
97
- var erase = {
98
- screen: `${CSI}2J`,
99
- up: (count = 1) => `${CSI}1J`.repeat(count),
100
- down: (count = 1) => `${CSI}J`.repeat(count),
101
- line: `${CSI}2K`,
102
- lineEnd: `${CSI}K`,
103
- lineStart: `${CSI}1K`,
104
- lines(count) {
105
- let clear = "";
106
- for (let i = 0; i < count; i++)
107
- clear += this.line + (i < count - 1 ? cursor.up() : "");
108
- if (count)
109
- clear += cursor.left;
110
- return clear;
111
- }
112
- };
113
- module2.exports = { cursor, scroll, erase, beep };
93
+ enumerable: false
94
+ },
95
+ hexToAnsi256: {
96
+ value: (hex) => styles.rgbToAnsi256(...styles.hexToRgb(hex)),
97
+ enumerable: false
98
+ },
99
+ ansi256ToAnsi: {
100
+ value(code) {
101
+ if (code < 8) {
102
+ return 30 + code;
103
+ }
104
+ if (code < 16) {
105
+ return 90 + (code - 8);
106
+ }
107
+ let red;
108
+ let green;
109
+ let blue;
110
+ if (code >= 232) {
111
+ red = ((code - 232) * 10 + 8) / 255;
112
+ green = red;
113
+ blue = red;
114
+ } else {
115
+ code -= 16;
116
+ const remainder = code % 36;
117
+ red = Math.floor(code / 36) / 5;
118
+ green = Math.floor(remainder / 6) / 5;
119
+ blue = remainder % 6 / 5;
120
+ }
121
+ const value = Math.max(red, green, blue) * 2;
122
+ if (value === 0) {
123
+ return 30;
124
+ }
125
+ let result = 30 + (Math.round(blue) << 2 | Math.round(green) << 1 | Math.round(red));
126
+ if (value === 2) {
127
+ result += 60;
128
+ }
129
+ return result;
130
+ },
131
+ enumerable: false
132
+ },
133
+ rgbToAnsi: {
134
+ value: (red, green, blue) => styles.ansi256ToAnsi(styles.rgbToAnsi256(red, green, blue)),
135
+ enumerable: false
136
+ },
137
+ hexToAnsi: {
138
+ value: (hex) => styles.ansi256ToAnsi(styles.hexToAnsi256(hex)),
139
+ enumerable: false
140
+ }
141
+ });
142
+ return styles;
143
+ }
144
+ var ANSI_BACKGROUND_OFFSET, wrapAnsi16, wrapAnsi256, wrapAnsi16m, styles, modifierNames, foregroundColorNames, backgroundColorNames, colorNames, ansiStyles, ansi_styles_default;
145
+ var init_ansi_styles = __esm({
146
+ "node_modules/.pnpm/chalk@5.2.0/node_modules/chalk/source/vendor/ansi-styles/index.js"() {
147
+ ANSI_BACKGROUND_OFFSET = 10;
148
+ wrapAnsi16 = (offset = 0) => (code) => `\x1B[${code + offset}m`;
149
+ wrapAnsi256 = (offset = 0) => (code) => `\x1B[${38 + offset};5;${code}m`;
150
+ wrapAnsi16m = (offset = 0) => (red, green, blue) => `\x1B[${38 + offset};2;${red};${green};${blue}m`;
151
+ styles = {
152
+ modifier: {
153
+ reset: [0, 0],
154
+ bold: [1, 22],
155
+ dim: [2, 22],
156
+ italic: [3, 23],
157
+ underline: [4, 24],
158
+ overline: [53, 55],
159
+ inverse: [7, 27],
160
+ hidden: [8, 28],
161
+ strikethrough: [9, 29]
162
+ },
163
+ color: {
164
+ black: [30, 39],
165
+ red: [31, 39],
166
+ green: [32, 39],
167
+ yellow: [33, 39],
168
+ blue: [34, 39],
169
+ magenta: [35, 39],
170
+ cyan: [36, 39],
171
+ white: [37, 39],
172
+ blackBright: [90, 39],
173
+ gray: [90, 39],
174
+ grey: [90, 39],
175
+ redBright: [91, 39],
176
+ greenBright: [92, 39],
177
+ yellowBright: [93, 39],
178
+ blueBright: [94, 39],
179
+ magentaBright: [95, 39],
180
+ cyanBright: [96, 39],
181
+ whiteBright: [97, 39]
182
+ },
183
+ bgColor: {
184
+ bgBlack: [40, 49],
185
+ bgRed: [41, 49],
186
+ bgGreen: [42, 49],
187
+ bgYellow: [43, 49],
188
+ bgBlue: [44, 49],
189
+ bgMagenta: [45, 49],
190
+ bgCyan: [46, 49],
191
+ bgWhite: [47, 49],
192
+ bgBlackBright: [100, 49],
193
+ bgGray: [100, 49],
194
+ bgGrey: [100, 49],
195
+ bgRedBright: [101, 49],
196
+ bgGreenBright: [102, 49],
197
+ bgYellowBright: [103, 49],
198
+ bgBlueBright: [104, 49],
199
+ bgMagentaBright: [105, 49],
200
+ bgCyanBright: [106, 49],
201
+ bgWhiteBright: [107, 49]
202
+ }
203
+ };
204
+ modifierNames = Object.keys(styles.modifier);
205
+ foregroundColorNames = Object.keys(styles.color);
206
+ backgroundColorNames = Object.keys(styles.bgColor);
207
+ colorNames = [...foregroundColorNames, ...backgroundColorNames];
208
+ ansiStyles = assembleStyles();
209
+ ansi_styles_default = ansiStyles;
114
210
  }
115
211
  });
116
212
 
117
- // node_modules/.pnpm/hanji@0.0.5/node_modules/hanji/utils.js
118
- var require_utils = __commonJS({
119
- "node_modules/.pnpm/hanji@0.0.5/node_modules/hanji/utils.js"(exports) {
120
- "use strict";
121
- Object.defineProperty(exports, "__esModule", { value: true });
122
- exports.clear = void 0;
123
- var sisteransi_1 = require_src();
124
- var strip = (str) => {
125
- const pattern = [
126
- "[\\u001B\\u009B][[\\]()#;?]*(?:(?:(?:(?:;[-a-zA-Z\\d\\/#&.:=?%@~_]+)*|[a-zA-Z\\d]+(?:;[-a-zA-Z\\d\\/#&.:=?%@~_]*)*)?\\u0007)",
127
- "(?:(?:\\d{1,4}(?:;\\d{0,4})*)?[\\dA-PRZcf-ntqry=><~]))"
128
- ].join("|");
129
- const RGX = new RegExp(pattern, "g");
130
- return typeof str === "string" ? str.replace(RGX, "") : str;
131
- };
132
- var stringWidth = (str) => [...strip(str)].length;
133
- var clear = function(prompt, perLine) {
134
- if (!perLine)
135
- return sisteransi_1.erase.line + sisteransi_1.cursor.to(0);
136
- let rows = 0;
137
- const lines = prompt.split(/\r?\n/);
138
- for (let line of lines) {
139
- rows += 1 + Math.floor(Math.max(stringWidth(line) - 1, 0) / perLine);
140
- }
141
- return sisteransi_1.erase.lines(rows);
142
- };
143
- exports.clear = clear;
213
+ // node_modules/.pnpm/chalk@5.2.0/node_modules/chalk/source/vendor/supports-color/index.js
214
+ function hasFlag(flag, argv = globalThis.Deno ? globalThis.Deno.args : import_node_process.default.argv) {
215
+ const prefix = flag.startsWith("-") ? "" : flag.length === 1 ? "-" : "--";
216
+ const position = argv.indexOf(prefix + flag);
217
+ const terminatorPosition = argv.indexOf("--");
218
+ return position !== -1 && (terminatorPosition === -1 || position < terminatorPosition);
219
+ }
220
+ function envForceColor() {
221
+ if ("FORCE_COLOR" in env) {
222
+ if (env.FORCE_COLOR === "true") {
223
+ return 1;
224
+ }
225
+ if (env.FORCE_COLOR === "false") {
226
+ return 0;
227
+ }
228
+ return env.FORCE_COLOR.length === 0 ? 1 : Math.min(Number.parseInt(env.FORCE_COLOR, 10), 3);
144
229
  }
145
- });
146
-
147
- // node_modules/.pnpm/lodash.throttle@4.1.1/node_modules/lodash.throttle/index.js
148
- var require_lodash = __commonJS({
149
- "node_modules/.pnpm/lodash.throttle@4.1.1/node_modules/lodash.throttle/index.js"(exports, module2) {
150
- var FUNC_ERROR_TEXT = "Expected a function";
151
- var NAN = 0 / 0;
152
- var symbolTag = "[object Symbol]";
153
- var reTrim = /^\s+|\s+$/g;
154
- var reIsBadHex = /^[-+]0x[0-9a-f]+$/i;
155
- var reIsBinary = /^0b[01]+$/i;
156
- var reIsOctal = /^0o[0-7]+$/i;
157
- var freeParseInt = parseInt;
158
- var freeGlobal = typeof global == "object" && global && global.Object === Object && global;
159
- var freeSelf = typeof self == "object" && self && self.Object === Object && self;
160
- var root = freeGlobal || freeSelf || Function("return this")();
161
- var objectProto = Object.prototype;
162
- var objectToString = objectProto.toString;
163
- var nativeMax = Math.max;
164
- var nativeMin = Math.min;
165
- var now = function() {
166
- return root.Date.now();
167
- };
168
- function debounce(func, wait, options) {
169
- var lastArgs, lastThis, maxWait, result, timerId, lastCallTime, lastInvokeTime = 0, leading = false, maxing = false, trailing = true;
170
- if (typeof func != "function") {
171
- throw new TypeError(FUNC_ERROR_TEXT);
172
- }
173
- wait = toNumber(wait) || 0;
174
- if (isObject(options)) {
175
- leading = !!options.leading;
176
- maxing = "maxWait" in options;
177
- maxWait = maxing ? nativeMax(toNumber(options.maxWait) || 0, wait) : maxWait;
178
- trailing = "trailing" in options ? !!options.trailing : trailing;
179
- }
180
- function invokeFunc(time) {
181
- var args = lastArgs, thisArg = lastThis;
182
- lastArgs = lastThis = void 0;
183
- lastInvokeTime = time;
184
- result = func.apply(thisArg, args);
185
- return result;
186
- }
187
- function leadingEdge(time) {
188
- lastInvokeTime = time;
189
- timerId = setTimeout(timerExpired, wait);
190
- return leading ? invokeFunc(time) : result;
191
- }
192
- function remainingWait(time) {
193
- var timeSinceLastCall = time - lastCallTime, timeSinceLastInvoke = time - lastInvokeTime, result2 = wait - timeSinceLastCall;
194
- return maxing ? nativeMin(result2, maxWait - timeSinceLastInvoke) : result2;
230
+ }
231
+ function translateLevel(level) {
232
+ if (level === 0) {
233
+ return false;
234
+ }
235
+ return {
236
+ level,
237
+ hasBasic: true,
238
+ has256: level >= 2,
239
+ has16m: level >= 3
240
+ };
241
+ }
242
+ function _supportsColor(haveStream, { streamIsTTY, sniffFlags = true } = {}) {
243
+ const noFlagForceColor = envForceColor();
244
+ if (noFlagForceColor !== void 0) {
245
+ flagForceColor = noFlagForceColor;
246
+ }
247
+ const forceColor = sniffFlags ? flagForceColor : noFlagForceColor;
248
+ if (forceColor === 0) {
249
+ return 0;
250
+ }
251
+ if (sniffFlags) {
252
+ if (hasFlag("color=16m") || hasFlag("color=full") || hasFlag("color=truecolor")) {
253
+ return 3;
254
+ }
255
+ if (hasFlag("color=256")) {
256
+ return 2;
257
+ }
258
+ }
259
+ if ("TF_BUILD" in env && "AGENT_NAME" in env) {
260
+ return 1;
261
+ }
262
+ if (haveStream && !streamIsTTY && forceColor === void 0) {
263
+ return 0;
264
+ }
265
+ const min = forceColor || 0;
266
+ if (env.TERM === "dumb") {
267
+ return min;
268
+ }
269
+ if (import_node_process.default.platform === "win32") {
270
+ const osRelease = import_node_os.default.release().split(".");
271
+ if (Number(osRelease[0]) >= 10 && Number(osRelease[2]) >= 10586) {
272
+ return Number(osRelease[2]) >= 14931 ? 3 : 2;
273
+ }
274
+ return 1;
275
+ }
276
+ if ("CI" in env) {
277
+ if ("GITHUB_ACTIONS" in env) {
278
+ return 3;
279
+ }
280
+ if (["TRAVIS", "CIRCLECI", "APPVEYOR", "GITLAB_CI", "BUILDKITE", "DRONE"].some((sign) => sign in env) || env.CI_NAME === "codeship") {
281
+ return 1;
282
+ }
283
+ return min;
284
+ }
285
+ if ("TEAMCITY_VERSION" in env) {
286
+ return /^(9\.(0*[1-9]\d*)\.|\d{2,}\.)/.test(env.TEAMCITY_VERSION) ? 1 : 0;
287
+ }
288
+ if (env.COLORTERM === "truecolor") {
289
+ return 3;
290
+ }
291
+ if (env.TERM === "xterm-kitty") {
292
+ return 3;
293
+ }
294
+ if ("TERM_PROGRAM" in env) {
295
+ const version = Number.parseInt((env.TERM_PROGRAM_VERSION || "").split(".")[0], 10);
296
+ switch (env.TERM_PROGRAM) {
297
+ case "iTerm.app": {
298
+ return version >= 3 ? 3 : 2;
195
299
  }
196
- function shouldInvoke(time) {
197
- var timeSinceLastCall = time - lastCallTime, timeSinceLastInvoke = time - lastInvokeTime;
198
- return lastCallTime === void 0 || timeSinceLastCall >= wait || timeSinceLastCall < 0 || maxing && timeSinceLastInvoke >= maxWait;
300
+ case "Apple_Terminal": {
301
+ return 2;
199
302
  }
200
- function timerExpired() {
201
- var time = now();
202
- if (shouldInvoke(time)) {
203
- return trailingEdge(time);
303
+ }
304
+ }
305
+ if (/-256(color)?$/i.test(env.TERM)) {
306
+ return 2;
307
+ }
308
+ if (/^screen|^xterm|^vt100|^vt220|^rxvt|color|ansi|cygwin|linux/i.test(env.TERM)) {
309
+ return 1;
310
+ }
311
+ if ("COLORTERM" in env) {
312
+ return 1;
313
+ }
314
+ return min;
315
+ }
316
+ function createSupportsColor(stream, options = {}) {
317
+ const level = _supportsColor(stream, {
318
+ streamIsTTY: stream && stream.isTTY,
319
+ ...options
320
+ });
321
+ return translateLevel(level);
322
+ }
323
+ var import_node_process, import_node_os, import_node_tty, env, flagForceColor, supportsColor, supports_color_default;
324
+ var init_supports_color = __esm({
325
+ "node_modules/.pnpm/chalk@5.2.0/node_modules/chalk/source/vendor/supports-color/index.js"() {
326
+ import_node_process = __toESM(require("process"), 1);
327
+ import_node_os = __toESM(require("os"), 1);
328
+ import_node_tty = __toESM(require("tty"), 1);
329
+ ({ env } = import_node_process.default);
330
+ if (hasFlag("no-color") || hasFlag("no-colors") || hasFlag("color=false") || hasFlag("color=never")) {
331
+ flagForceColor = 0;
332
+ } else if (hasFlag("color") || hasFlag("colors") || hasFlag("color=true") || hasFlag("color=always")) {
333
+ flagForceColor = 1;
334
+ }
335
+ supportsColor = {
336
+ stdout: createSupportsColor({ isTTY: import_node_tty.default.isatty(1) }),
337
+ stderr: createSupportsColor({ isTTY: import_node_tty.default.isatty(2) })
338
+ };
339
+ supports_color_default = supportsColor;
340
+ }
341
+ });
342
+
343
+ // node_modules/.pnpm/chalk@5.2.0/node_modules/chalk/source/utilities.js
344
+ function stringReplaceAll(string, substring, replacer) {
345
+ let index4 = string.indexOf(substring);
346
+ if (index4 === -1) {
347
+ return string;
348
+ }
349
+ const substringLength = substring.length;
350
+ let endIndex = 0;
351
+ let returnValue = "";
352
+ do {
353
+ returnValue += string.slice(endIndex, index4) + substring + replacer;
354
+ endIndex = index4 + substringLength;
355
+ index4 = string.indexOf(substring, endIndex);
356
+ } while (index4 !== -1);
357
+ returnValue += string.slice(endIndex);
358
+ return returnValue;
359
+ }
360
+ function stringEncaseCRLFWithFirstIndex(string, prefix, postfix, index4) {
361
+ let endIndex = 0;
362
+ let returnValue = "";
363
+ do {
364
+ const gotCR = string[index4 - 1] === "\r";
365
+ returnValue += string.slice(endIndex, gotCR ? index4 - 1 : index4) + prefix + (gotCR ? "\r\n" : "\n") + postfix;
366
+ endIndex = index4 + 1;
367
+ index4 = string.indexOf("\n", endIndex);
368
+ } while (index4 !== -1);
369
+ returnValue += string.slice(endIndex);
370
+ return returnValue;
371
+ }
372
+ var init_utilities = __esm({
373
+ "node_modules/.pnpm/chalk@5.2.0/node_modules/chalk/source/utilities.js"() {
374
+ }
375
+ });
376
+
377
+ // node_modules/.pnpm/chalk@5.2.0/node_modules/chalk/source/index.js
378
+ function createChalk(options) {
379
+ return chalkFactory(options);
380
+ }
381
+ var stdoutColor, stderrColor, GENERATOR, STYLER, IS_EMPTY, levelMapping, styles2, applyOptions, chalkFactory, getModelAnsi, usedModels, proto, createStyler, createBuilder, applyStyle, chalk, chalkStderr, source_default;
382
+ var init_source = __esm({
383
+ "node_modules/.pnpm/chalk@5.2.0/node_modules/chalk/source/index.js"() {
384
+ init_ansi_styles();
385
+ init_supports_color();
386
+ init_utilities();
387
+ init_ansi_styles();
388
+ ({ stdout: stdoutColor, stderr: stderrColor } = supports_color_default);
389
+ GENERATOR = Symbol("GENERATOR");
390
+ STYLER = Symbol("STYLER");
391
+ IS_EMPTY = Symbol("IS_EMPTY");
392
+ levelMapping = [
393
+ "ansi",
394
+ "ansi",
395
+ "ansi256",
396
+ "ansi16m"
397
+ ];
398
+ styles2 = /* @__PURE__ */ Object.create(null);
399
+ applyOptions = (object, options = {}) => {
400
+ if (options.level && !(Number.isInteger(options.level) && options.level >= 0 && options.level <= 3)) {
401
+ throw new Error("The `level` option should be an integer from 0 to 3");
402
+ }
403
+ const colorLevel = stdoutColor ? stdoutColor.level : 0;
404
+ object.level = options.level === void 0 ? colorLevel : options.level;
405
+ };
406
+ chalkFactory = (options) => {
407
+ const chalk2 = (...strings) => strings.join(" ");
408
+ applyOptions(chalk2, options);
409
+ Object.setPrototypeOf(chalk2, createChalk.prototype);
410
+ return chalk2;
411
+ };
412
+ Object.setPrototypeOf(createChalk.prototype, Function.prototype);
413
+ for (const [styleName, style] of Object.entries(ansi_styles_default)) {
414
+ styles2[styleName] = {
415
+ get() {
416
+ const builder = createBuilder(this, createStyler(style.open, style.close, this[STYLER]), this[IS_EMPTY]);
417
+ Object.defineProperty(this, styleName, { value: builder });
418
+ return builder;
204
419
  }
205
- timerId = setTimeout(timerExpired, remainingWait(time));
420
+ };
421
+ }
422
+ styles2.visible = {
423
+ get() {
424
+ const builder = createBuilder(this, this[STYLER], true);
425
+ Object.defineProperty(this, "visible", { value: builder });
426
+ return builder;
206
427
  }
207
- function trailingEdge(time) {
208
- timerId = void 0;
209
- if (trailing && lastArgs) {
210
- return invokeFunc(time);
428
+ };
429
+ getModelAnsi = (model, level, type, ...arguments_) => {
430
+ if (model === "rgb") {
431
+ if (level === "ansi16m") {
432
+ return ansi_styles_default[type].ansi16m(...arguments_);
211
433
  }
212
- lastArgs = lastThis = void 0;
213
- return result;
214
- }
215
- function cancel() {
216
- if (timerId !== void 0) {
217
- clearTimeout(timerId);
434
+ if (level === "ansi256") {
435
+ return ansi_styles_default[type].ansi256(ansi_styles_default.rgbToAnsi256(...arguments_));
218
436
  }
219
- lastInvokeTime = 0;
220
- lastArgs = lastCallTime = lastThis = timerId = void 0;
437
+ return ansi_styles_default[type].ansi(ansi_styles_default.rgbToAnsi(...arguments_));
221
438
  }
222
- function flush() {
223
- return timerId === void 0 ? result : trailingEdge(now());
439
+ if (model === "hex") {
440
+ return getModelAnsi("rgb", level, type, ...ansi_styles_default.hexToRgb(...arguments_));
224
441
  }
225
- function debounced() {
226
- var time = now(), isInvoking = shouldInvoke(time);
227
- lastArgs = arguments;
228
- lastThis = this;
229
- lastCallTime = time;
230
- if (isInvoking) {
231
- if (timerId === void 0) {
232
- return leadingEdge(lastCallTime);
233
- }
234
- if (maxing) {
235
- timerId = setTimeout(timerExpired, wait);
236
- return invokeFunc(lastCallTime);
237
- }
442
+ return ansi_styles_default[type][model](...arguments_);
443
+ };
444
+ usedModels = ["rgb", "hex", "ansi256"];
445
+ for (const model of usedModels) {
446
+ styles2[model] = {
447
+ get() {
448
+ const { level } = this;
449
+ return function(...arguments_) {
450
+ const styler = createStyler(getModelAnsi(model, levelMapping[level], "color", ...arguments_), ansi_styles_default.color.close, this[STYLER]);
451
+ return createBuilder(this, styler, this[IS_EMPTY]);
452
+ };
238
453
  }
239
- if (timerId === void 0) {
240
- timerId = setTimeout(timerExpired, wait);
454
+ };
455
+ const bgModel = "bg" + model[0].toUpperCase() + model.slice(1);
456
+ styles2[bgModel] = {
457
+ get() {
458
+ const { level } = this;
459
+ return function(...arguments_) {
460
+ const styler = createStyler(getModelAnsi(model, levelMapping[level], "bgColor", ...arguments_), ansi_styles_default.bgColor.close, this[STYLER]);
461
+ return createBuilder(this, styler, this[IS_EMPTY]);
462
+ };
241
463
  }
242
- return result;
243
- }
244
- debounced.cancel = cancel;
245
- debounced.flush = flush;
246
- return debounced;
464
+ };
247
465
  }
248
- function throttle(func, wait, options) {
249
- var leading = true, trailing = true;
250
- if (typeof func != "function") {
251
- throw new TypeError(FUNC_ERROR_TEXT);
466
+ proto = Object.defineProperties(() => {
467
+ }, {
468
+ ...styles2,
469
+ level: {
470
+ enumerable: true,
471
+ get() {
472
+ return this[GENERATOR].level;
473
+ },
474
+ set(level) {
475
+ this[GENERATOR].level = level;
476
+ }
252
477
  }
253
- if (isObject(options)) {
254
- leading = "leading" in options ? !!options.leading : leading;
255
- trailing = "trailing" in options ? !!options.trailing : trailing;
478
+ });
479
+ createStyler = (open, close, parent) => {
480
+ let openAll;
481
+ let closeAll;
482
+ if (parent === void 0) {
483
+ openAll = open;
484
+ closeAll = close;
485
+ } else {
486
+ openAll = parent.openAll + open;
487
+ closeAll = close + parent.closeAll;
256
488
  }
257
- return debounce(func, wait, {
258
- "leading": leading,
259
- "maxWait": wait,
260
- "trailing": trailing
261
- });
262
- }
263
- function isObject(value) {
264
- var type = typeof value;
265
- return !!value && (type == "object" || type == "function");
266
- }
267
- function isObjectLike(value) {
268
- return !!value && typeof value == "object";
269
- }
270
- function isSymbol(value) {
271
- return typeof value == "symbol" || isObjectLike(value) && objectToString.call(value) == symbolTag;
272
- }
273
- function toNumber(value) {
274
- if (typeof value == "number") {
275
- return value;
489
+ return {
490
+ open,
491
+ close,
492
+ openAll,
493
+ closeAll,
494
+ parent
495
+ };
496
+ };
497
+ createBuilder = (self2, _styler, _isEmpty) => {
498
+ const builder = (...arguments_) => applyStyle(builder, arguments_.length === 1 ? "" + arguments_[0] : arguments_.join(" "));
499
+ Object.setPrototypeOf(builder, proto);
500
+ builder[GENERATOR] = self2;
501
+ builder[STYLER] = _styler;
502
+ builder[IS_EMPTY] = _isEmpty;
503
+ return builder;
504
+ };
505
+ applyStyle = (self2, string) => {
506
+ if (self2.level <= 0 || !string) {
507
+ return self2[IS_EMPTY] ? "" : string;
276
508
  }
277
- if (isSymbol(value)) {
278
- return NAN;
509
+ let styler = self2[STYLER];
510
+ if (styler === void 0) {
511
+ return string;
279
512
  }
280
- if (isObject(value)) {
281
- var other = typeof value.valueOf == "function" ? value.valueOf() : value;
282
- value = isObject(other) ? other + "" : other;
513
+ const { openAll, closeAll } = styler;
514
+ if (string.includes("\x1B")) {
515
+ while (styler !== void 0) {
516
+ string = stringReplaceAll(string, styler.close, styler.open);
517
+ styler = styler.parent;
518
+ }
283
519
  }
284
- if (typeof value != "string") {
285
- return value === 0 ? value : +value;
520
+ const lfIndex = string.indexOf("\n");
521
+ if (lfIndex !== -1) {
522
+ string = stringEncaseCRLFWithFirstIndex(string, closeAll, openAll, lfIndex);
286
523
  }
287
- value = value.replace(reTrim, "");
288
- var isBinary = reIsBinary.test(value);
289
- return isBinary || reIsOctal.test(value) ? freeParseInt(value.slice(2), isBinary ? 2 : 8) : reIsBadHex.test(value) ? NAN : +value;
290
- }
291
- module2.exports = throttle;
524
+ return openAll + string + closeAll;
525
+ };
526
+ Object.defineProperties(createChalk.prototype, styles2);
527
+ chalk = createChalk();
528
+ chalkStderr = createChalk({ level: stderrColor ? stderrColor.level : 0 });
529
+ source_default = chalk;
292
530
  }
293
531
  });
294
532
 
295
- // node_modules/.pnpm/hanji@0.0.5/node_modules/hanji/index.js
296
- var require_hanji = __commonJS({
297
- "node_modules/.pnpm/hanji@0.0.5/node_modules/hanji/index.js"(exports) {
533
+ // node_modules/.pnpm/hanji@0.0.5/node_modules/hanji/readline.js
534
+ var require_readline = __commonJS({
535
+ "node_modules/.pnpm/hanji@0.0.5/node_modules/hanji/readline.js"(exports) {
298
536
  "use strict";
299
- var __awaiter = exports && exports.__awaiter || function(thisArg, _arguments, P, generator) {
300
- function adopt(value) {
301
- return value instanceof P ? value : new P(function(resolve) {
302
- resolve(value);
303
- });
304
- }
305
- return new (P || (P = Promise))(function(resolve, reject) {
306
- function fulfilled(value) {
307
- try {
308
- step(generator.next(value));
309
- } catch (e) {
310
- reject(e);
311
- }
312
- }
313
- function rejected(value) {
314
- try {
315
- step(generator["throw"](value));
316
- } catch (e) {
317
- reject(e);
318
- }
319
- }
320
- function step(result) {
321
- result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected);
322
- }
323
- step((generator = generator.apply(thisArg, _arguments || [])).next());
537
+ Object.defineProperty(exports, "__esModule", { value: true });
538
+ exports.prepareReadLine = void 0;
539
+ var prepareReadLine = () => {
540
+ const stdin = process.stdin;
541
+ const stdout = process.stdout;
542
+ const readline = require("readline");
543
+ const rl = readline.createInterface({
544
+ input: stdin,
545
+ escapeCodeTimeout: 50
324
546
  });
547
+ readline.emitKeypressEvents(stdin, rl);
548
+ return {
549
+ stdin,
550
+ stdout,
551
+ closable: rl
552
+ };
325
553
  };
326
- var __importDefault = exports && exports.__importDefault || function(mod) {
327
- return mod && mod.__esModule ? mod : { "default": mod };
554
+ exports.prepareReadLine = prepareReadLine;
555
+ }
556
+ });
557
+
558
+ // node_modules/.pnpm/sisteransi@1.0.5/node_modules/sisteransi/src/index.js
559
+ var require_src = __commonJS({
560
+ "node_modules/.pnpm/sisteransi@1.0.5/node_modules/sisteransi/src/index.js"(exports, module2) {
561
+ "use strict";
562
+ var ESC = "\x1B";
563
+ var CSI = `${ESC}[`;
564
+ var beep = "\x07";
565
+ var cursor = {
566
+ to(x, y) {
567
+ if (!y)
568
+ return `${CSI}${x + 1}G`;
569
+ return `${CSI}${y + 1};${x + 1}H`;
570
+ },
571
+ move(x, y) {
572
+ let ret = "";
573
+ if (x < 0)
574
+ ret += `${CSI}${-x}D`;
575
+ else if (x > 0)
576
+ ret += `${CSI}${x}C`;
577
+ if (y < 0)
578
+ ret += `${CSI}${-y}A`;
579
+ else if (y > 0)
580
+ ret += `${CSI}${y}B`;
581
+ return ret;
582
+ },
583
+ up: (count = 1) => `${CSI}${count}A`,
584
+ down: (count = 1) => `${CSI}${count}B`,
585
+ forward: (count = 1) => `${CSI}${count}C`,
586
+ backward: (count = 1) => `${CSI}${count}D`,
587
+ nextLine: (count = 1) => `${CSI}E`.repeat(count),
588
+ prevLine: (count = 1) => `${CSI}F`.repeat(count),
589
+ left: `${CSI}G`,
590
+ hide: `${CSI}?25l`,
591
+ show: `${CSI}?25h`,
592
+ save: `${ESC}7`,
593
+ restore: `${ESC}8`
594
+ };
595
+ var scroll = {
596
+ up: (count = 1) => `${CSI}S`.repeat(count),
597
+ down: (count = 1) => `${CSI}T`.repeat(count)
598
+ };
599
+ var erase = {
600
+ screen: `${CSI}2J`,
601
+ up: (count = 1) => `${CSI}1J`.repeat(count),
602
+ down: (count = 1) => `${CSI}J`.repeat(count),
603
+ line: `${CSI}2K`,
604
+ lineEnd: `${CSI}K`,
605
+ lineStart: `${CSI}1K`,
606
+ lines(count) {
607
+ let clear = "";
608
+ for (let i = 0; i < count; i++)
609
+ clear += this.line + (i < count - 1 ? cursor.up() : "");
610
+ if (count)
611
+ clear += cursor.left;
612
+ return clear;
613
+ }
328
614
  };
615
+ module2.exports = { cursor, scroll, erase, beep };
616
+ }
617
+ });
618
+
619
+ // node_modules/.pnpm/hanji@0.0.5/node_modules/hanji/utils.js
620
+ var require_utils = __commonJS({
621
+ "node_modules/.pnpm/hanji@0.0.5/node_modules/hanji/utils.js"(exports) {
622
+ "use strict";
329
623
  Object.defineProperty(exports, "__esModule", { value: true });
330
- exports.onTerminate = exports.renderWithTask = exports.render = exports.TaskTerminal = exports.TaskView = exports.Terminal = exports.deferred = exports.SelectState = exports.Prompt = void 0;
331
- var readline_1 = require_readline();
624
+ exports.clear = void 0;
332
625
  var sisteransi_1 = require_src();
333
- var utils_1 = require_utils();
334
- var lodash_throttle_1 = __importDefault(require_lodash());
335
- var Prompt2 = class {
336
- constructor() {
337
- this.attachCallbacks = [];
338
- this.detachCallbacks = [];
339
- this.inputCallbacks = [];
340
- }
341
- requestLayout() {
342
- this.terminal.requestLayout();
626
+ var strip = (str) => {
627
+ const pattern = [
628
+ "[\\u001B\\u009B][[\\]()#;?]*(?:(?:(?:(?:;[-a-zA-Z\\d\\/#&.:=?%@~_]+)*|[a-zA-Z\\d]+(?:;[-a-zA-Z\\d\\/#&.:=?%@~_]*)*)?\\u0007)",
629
+ "(?:(?:\\d{1,4}(?:;\\d{0,4})*)?[\\dA-PRZcf-ntqry=><~]))"
630
+ ].join("|");
631
+ const RGX = new RegExp(pattern, "g");
632
+ return typeof str === "string" ? str.replace(RGX, "") : str;
633
+ };
634
+ var stringWidth = (str) => [...strip(str)].length;
635
+ var clear = function(prompt, perLine) {
636
+ if (!perLine)
637
+ return sisteransi_1.erase.line + sisteransi_1.cursor.to(0);
638
+ let rows = 0;
639
+ const lines = prompt.split(/\r?\n/);
640
+ for (let line of lines) {
641
+ rows += 1 + Math.floor(Math.max(stringWidth(line) - 1, 0) / perLine);
343
642
  }
344
- on(type, callback) {
345
- if (type === "attach") {
346
- this.attachCallbacks.push(callback);
347
- } else if (type === "detach") {
348
- this.detachCallbacks.push(callback);
349
- } else if (type === "input") {
350
- this.inputCallbacks.push(callback);
351
- }
643
+ return sisteransi_1.erase.lines(rows);
644
+ };
645
+ exports.clear = clear;
646
+ }
647
+ });
648
+
649
+ // node_modules/.pnpm/lodash.throttle@4.1.1/node_modules/lodash.throttle/index.js
650
+ var require_lodash = __commonJS({
651
+ "node_modules/.pnpm/lodash.throttle@4.1.1/node_modules/lodash.throttle/index.js"(exports, module2) {
652
+ var FUNC_ERROR_TEXT = "Expected a function";
653
+ var NAN = 0 / 0;
654
+ var symbolTag = "[object Symbol]";
655
+ var reTrim = /^\s+|\s+$/g;
656
+ var reIsBadHex = /^[-+]0x[0-9a-f]+$/i;
657
+ var reIsBinary = /^0b[01]+$/i;
658
+ var reIsOctal = /^0o[0-7]+$/i;
659
+ var freeParseInt = parseInt;
660
+ var freeGlobal = typeof global == "object" && global && global.Object === Object && global;
661
+ var freeSelf = typeof self == "object" && self && self.Object === Object && self;
662
+ var root = freeGlobal || freeSelf || Function("return this")();
663
+ var objectProto = Object.prototype;
664
+ var objectToString = objectProto.toString;
665
+ var nativeMax = Math.max;
666
+ var nativeMin = Math.min;
667
+ var now = function() {
668
+ return root.Date.now();
669
+ };
670
+ function debounce(func, wait, options) {
671
+ var lastArgs, lastThis, maxWait, result, timerId, lastCallTime, lastInvokeTime = 0, leading = false, maxing = false, trailing = true;
672
+ if (typeof func != "function") {
673
+ throw new TypeError(FUNC_ERROR_TEXT);
352
674
  }
353
- attach(terminal) {
354
- this.terminal = terminal;
355
- this.attachCallbacks.forEach((it) => it(terminal));
675
+ wait = toNumber(wait) || 0;
676
+ if (isObject(options)) {
677
+ leading = !!options.leading;
678
+ maxing = "maxWait" in options;
679
+ maxWait = maxing ? nativeMax(toNumber(options.maxWait) || 0, wait) : maxWait;
680
+ trailing = "trailing" in options ? !!options.trailing : trailing;
356
681
  }
357
- detach(terminal) {
358
- this.detachCallbacks.forEach((it) => it(terminal));
359
- this.terminal = void 0;
682
+ function invokeFunc(time) {
683
+ var args = lastArgs, thisArg = lastThis;
684
+ lastArgs = lastThis = void 0;
685
+ lastInvokeTime = time;
686
+ result = func.apply(thisArg, args);
687
+ return result;
360
688
  }
361
- input(str, key) {
362
- this.inputCallbacks.forEach((it) => it(str, key));
689
+ function leadingEdge(time) {
690
+ lastInvokeTime = time;
691
+ timerId = setTimeout(timerExpired, wait);
692
+ return leading ? invokeFunc(time) : result;
363
693
  }
364
- };
365
- exports.Prompt = Prompt2;
366
- var SelectState2 = class {
367
- constructor(items) {
368
- this.items = items;
369
- this.selectedIdx = 0;
694
+ function remainingWait(time) {
695
+ var timeSinceLastCall = time - lastCallTime, timeSinceLastInvoke = time - lastInvokeTime, result2 = wait - timeSinceLastCall;
696
+ return maxing ? nativeMin(result2, maxWait - timeSinceLastInvoke) : result2;
370
697
  }
371
- bind(prompt) {
372
- prompt.on("input", (str, key) => {
373
- const invalidate = this.consume(str, key);
374
- if (invalidate)
375
- prompt.requestLayout();
376
- });
698
+ function shouldInvoke(time) {
699
+ var timeSinceLastCall = time - lastCallTime, timeSinceLastInvoke = time - lastInvokeTime;
700
+ return lastCallTime === void 0 || timeSinceLastCall >= wait || timeSinceLastCall < 0 || maxing && timeSinceLastInvoke >= maxWait;
377
701
  }
378
- consume(str, key) {
379
- if (!key)
380
- return false;
381
- if (key.name === "down") {
382
- this.selectedIdx = (this.selectedIdx + 1) % this.items.length;
383
- return true;
702
+ function timerExpired() {
703
+ var time = now();
704
+ if (shouldInvoke(time)) {
705
+ return trailingEdge(time);
384
706
  }
385
- if (key.name === "up") {
386
- this.selectedIdx -= 1;
387
- this.selectedIdx = this.selectedIdx < 0 ? this.items.length - 1 : this.selectedIdx;
388
- return true;
707
+ timerId = setTimeout(timerExpired, remainingWait(time));
708
+ }
709
+ function trailingEdge(time) {
710
+ timerId = void 0;
711
+ if (trailing && lastArgs) {
712
+ return invokeFunc(time);
389
713
  }
390
- return false;
714
+ lastArgs = lastThis = void 0;
715
+ return result;
391
716
  }
392
- };
393
- exports.SelectState = SelectState2;
394
- var deferred = () => {
395
- let resolve;
717
+ function cancel() {
718
+ if (timerId !== void 0) {
719
+ clearTimeout(timerId);
720
+ }
721
+ lastInvokeTime = 0;
722
+ lastArgs = lastCallTime = lastThis = timerId = void 0;
723
+ }
724
+ function flush() {
725
+ return timerId === void 0 ? result : trailingEdge(now());
726
+ }
727
+ function debounced() {
728
+ var time = now(), isInvoking = shouldInvoke(time);
729
+ lastArgs = arguments;
730
+ lastThis = this;
731
+ lastCallTime = time;
732
+ if (isInvoking) {
733
+ if (timerId === void 0) {
734
+ return leadingEdge(lastCallTime);
735
+ }
736
+ if (maxing) {
737
+ timerId = setTimeout(timerExpired, wait);
738
+ return invokeFunc(lastCallTime);
739
+ }
740
+ }
741
+ if (timerId === void 0) {
742
+ timerId = setTimeout(timerExpired, wait);
743
+ }
744
+ return result;
745
+ }
746
+ debounced.cancel = cancel;
747
+ debounced.flush = flush;
748
+ return debounced;
749
+ }
750
+ function throttle(func, wait, options) {
751
+ var leading = true, trailing = true;
752
+ if (typeof func != "function") {
753
+ throw new TypeError(FUNC_ERROR_TEXT);
754
+ }
755
+ if (isObject(options)) {
756
+ leading = "leading" in options ? !!options.leading : leading;
757
+ trailing = "trailing" in options ? !!options.trailing : trailing;
758
+ }
759
+ return debounce(func, wait, {
760
+ "leading": leading,
761
+ "maxWait": wait,
762
+ "trailing": trailing
763
+ });
764
+ }
765
+ function isObject(value) {
766
+ var type = typeof value;
767
+ return !!value && (type == "object" || type == "function");
768
+ }
769
+ function isObjectLike(value) {
770
+ return !!value && typeof value == "object";
771
+ }
772
+ function isSymbol(value) {
773
+ return typeof value == "symbol" || isObjectLike(value) && objectToString.call(value) == symbolTag;
774
+ }
775
+ function toNumber(value) {
776
+ if (typeof value == "number") {
777
+ return value;
778
+ }
779
+ if (isSymbol(value)) {
780
+ return NAN;
781
+ }
782
+ if (isObject(value)) {
783
+ var other = typeof value.valueOf == "function" ? value.valueOf() : value;
784
+ value = isObject(other) ? other + "" : other;
785
+ }
786
+ if (typeof value != "string") {
787
+ return value === 0 ? value : +value;
788
+ }
789
+ value = value.replace(reTrim, "");
790
+ var isBinary = reIsBinary.test(value);
791
+ return isBinary || reIsOctal.test(value) ? freeParseInt(value.slice(2), isBinary ? 2 : 8) : reIsBadHex.test(value) ? NAN : +value;
792
+ }
793
+ module2.exports = throttle;
794
+ }
795
+ });
796
+
797
+ // node_modules/.pnpm/hanji@0.0.5/node_modules/hanji/index.js
798
+ var require_hanji = __commonJS({
799
+ "node_modules/.pnpm/hanji@0.0.5/node_modules/hanji/index.js"(exports) {
800
+ "use strict";
801
+ var __awaiter = exports && exports.__awaiter || function(thisArg, _arguments, P, generator) {
802
+ function adopt(value) {
803
+ return value instanceof P ? value : new P(function(resolve) {
804
+ resolve(value);
805
+ });
806
+ }
807
+ return new (P || (P = Promise))(function(resolve, reject) {
808
+ function fulfilled(value) {
809
+ try {
810
+ step(generator.next(value));
811
+ } catch (e) {
812
+ reject(e);
813
+ }
814
+ }
815
+ function rejected(value) {
816
+ try {
817
+ step(generator["throw"](value));
818
+ } catch (e) {
819
+ reject(e);
820
+ }
821
+ }
822
+ function step(result) {
823
+ result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected);
824
+ }
825
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
826
+ });
827
+ };
828
+ var __importDefault = exports && exports.__importDefault || function(mod) {
829
+ return mod && mod.__esModule ? mod : { "default": mod };
830
+ };
831
+ Object.defineProperty(exports, "__esModule", { value: true });
832
+ exports.onTerminate = exports.renderWithTask = exports.render = exports.TaskTerminal = exports.TaskView = exports.Terminal = exports.deferred = exports.SelectState = exports.Prompt = void 0;
833
+ var readline_1 = require_readline();
834
+ var sisteransi_1 = require_src();
835
+ var utils_1 = require_utils();
836
+ var lodash_throttle_1 = __importDefault(require_lodash());
837
+ var Prompt2 = class {
838
+ constructor() {
839
+ this.attachCallbacks = [];
840
+ this.detachCallbacks = [];
841
+ this.inputCallbacks = [];
842
+ }
843
+ requestLayout() {
844
+ this.terminal.requestLayout();
845
+ }
846
+ on(type, callback) {
847
+ if (type === "attach") {
848
+ this.attachCallbacks.push(callback);
849
+ } else if (type === "detach") {
850
+ this.detachCallbacks.push(callback);
851
+ } else if (type === "input") {
852
+ this.inputCallbacks.push(callback);
853
+ }
854
+ }
855
+ attach(terminal) {
856
+ this.terminal = terminal;
857
+ this.attachCallbacks.forEach((it) => it(terminal));
858
+ }
859
+ detach(terminal) {
860
+ this.detachCallbacks.forEach((it) => it(terminal));
861
+ this.terminal = void 0;
862
+ }
863
+ input(str, key) {
864
+ this.inputCallbacks.forEach((it) => it(str, key));
865
+ }
866
+ };
867
+ exports.Prompt = Prompt2;
868
+ var SelectState2 = class {
869
+ constructor(items) {
870
+ this.items = items;
871
+ this.selectedIdx = 0;
872
+ }
873
+ bind(prompt) {
874
+ prompt.on("input", (str, key) => {
875
+ const invalidate = this.consume(str, key);
876
+ if (invalidate)
877
+ prompt.requestLayout();
878
+ });
879
+ }
880
+ consume(str, key) {
881
+ if (!key)
882
+ return false;
883
+ if (key.name === "down") {
884
+ this.selectedIdx = (this.selectedIdx + 1) % this.items.length;
885
+ return true;
886
+ }
887
+ if (key.name === "up") {
888
+ this.selectedIdx -= 1;
889
+ this.selectedIdx = this.selectedIdx < 0 ? this.items.length - 1 : this.selectedIdx;
890
+ return true;
891
+ }
892
+ return false;
893
+ }
894
+ };
895
+ exports.SelectState = SelectState2;
896
+ var deferred = () => {
897
+ let resolve;
396
898
  let reject;
397
899
  const promise = new Promise((res, rej) => {
398
900
  resolve = res;
@@ -16850,521 +17352,43 @@ var require_glob = __commonJS({
16850
17352
  this.cache[abs] = this.cache[abs] || c;
16851
17353
  if (needDir && c === "FILE")
16852
17354
  return cb();
16853
- return cb(null, c, stat);
16854
- };
16855
- }
16856
- });
16857
-
16858
- // src/serializer/index.ts
16859
- var import_node, import_glob;
16860
- var init_serializer = __esm({
16861
- "src/serializer/index.ts"() {
16862
- import_node = __toESM(require_node2());
16863
- import_glob = __toESM(require_glob());
16864
- }
16865
- });
16866
-
16867
- // src/utils.ts
16868
- var utils_exports = {};
16869
- __export(utils_exports, {
16870
- assertV1OutFolder: () => assertV1OutFolder,
16871
- columnRenameKey: () => columnRenameKey,
16872
- dryJournal: () => dryJournal,
16873
- kloudMeta: () => kloudMeta,
16874
- mapValues: () => mapValues,
16875
- prepareMigrationFolder: () => prepareMigrationFolder,
16876
- prepareMigrationMeta: () => prepareMigrationMeta,
16877
- prepareOutFolder: () => prepareOutFolder2,
16878
- schemaRenameKey: () => schemaRenameKey,
16879
- snapshotsPriorV4: () => snapshotsPriorV4,
16880
- statementsForDiffs: () => statementsForDiffs,
16881
- tableRenameKey: () => tableRenameKey,
16882
- validateWithReport: () => validateWithReport
16883
- });
16884
- module.exports = __toCommonJS(utils_exports);
16885
- var import_fs = require("fs");
16886
-
16887
- // node_modules/.pnpm/chalk@5.2.0/node_modules/chalk/source/vendor/ansi-styles/index.js
16888
- var ANSI_BACKGROUND_OFFSET = 10;
16889
- var wrapAnsi16 = (offset = 0) => (code) => `\x1B[${code + offset}m`;
16890
- var wrapAnsi256 = (offset = 0) => (code) => `\x1B[${38 + offset};5;${code}m`;
16891
- var wrapAnsi16m = (offset = 0) => (red, green, blue) => `\x1B[${38 + offset};2;${red};${green};${blue}m`;
16892
- var styles = {
16893
- modifier: {
16894
- reset: [0, 0],
16895
- bold: [1, 22],
16896
- dim: [2, 22],
16897
- italic: [3, 23],
16898
- underline: [4, 24],
16899
- overline: [53, 55],
16900
- inverse: [7, 27],
16901
- hidden: [8, 28],
16902
- strikethrough: [9, 29]
16903
- },
16904
- color: {
16905
- black: [30, 39],
16906
- red: [31, 39],
16907
- green: [32, 39],
16908
- yellow: [33, 39],
16909
- blue: [34, 39],
16910
- magenta: [35, 39],
16911
- cyan: [36, 39],
16912
- white: [37, 39],
16913
- blackBright: [90, 39],
16914
- gray: [90, 39],
16915
- grey: [90, 39],
16916
- redBright: [91, 39],
16917
- greenBright: [92, 39],
16918
- yellowBright: [93, 39],
16919
- blueBright: [94, 39],
16920
- magentaBright: [95, 39],
16921
- cyanBright: [96, 39],
16922
- whiteBright: [97, 39]
16923
- },
16924
- bgColor: {
16925
- bgBlack: [40, 49],
16926
- bgRed: [41, 49],
16927
- bgGreen: [42, 49],
16928
- bgYellow: [43, 49],
16929
- bgBlue: [44, 49],
16930
- bgMagenta: [45, 49],
16931
- bgCyan: [46, 49],
16932
- bgWhite: [47, 49],
16933
- bgBlackBright: [100, 49],
16934
- bgGray: [100, 49],
16935
- bgGrey: [100, 49],
16936
- bgRedBright: [101, 49],
16937
- bgGreenBright: [102, 49],
16938
- bgYellowBright: [103, 49],
16939
- bgBlueBright: [104, 49],
16940
- bgMagentaBright: [105, 49],
16941
- bgCyanBright: [106, 49],
16942
- bgWhiteBright: [107, 49]
16943
- }
16944
- };
16945
- var modifierNames = Object.keys(styles.modifier);
16946
- var foregroundColorNames = Object.keys(styles.color);
16947
- var backgroundColorNames = Object.keys(styles.bgColor);
16948
- var colorNames = [...foregroundColorNames, ...backgroundColorNames];
16949
- function assembleStyles() {
16950
- const codes = /* @__PURE__ */ new Map();
16951
- for (const [groupName, group] of Object.entries(styles)) {
16952
- for (const [styleName, style] of Object.entries(group)) {
16953
- styles[styleName] = {
16954
- open: `\x1B[${style[0]}m`,
16955
- close: `\x1B[${style[1]}m`
16956
- };
16957
- group[styleName] = styles[styleName];
16958
- codes.set(style[0], style[1]);
16959
- }
16960
- Object.defineProperty(styles, groupName, {
16961
- value: group,
16962
- enumerable: false
16963
- });
16964
- }
16965
- Object.defineProperty(styles, "codes", {
16966
- value: codes,
16967
- enumerable: false
16968
- });
16969
- styles.color.close = "\x1B[39m";
16970
- styles.bgColor.close = "\x1B[49m";
16971
- styles.color.ansi = wrapAnsi16();
16972
- styles.color.ansi256 = wrapAnsi256();
16973
- styles.color.ansi16m = wrapAnsi16m();
16974
- styles.bgColor.ansi = wrapAnsi16(ANSI_BACKGROUND_OFFSET);
16975
- styles.bgColor.ansi256 = wrapAnsi256(ANSI_BACKGROUND_OFFSET);
16976
- styles.bgColor.ansi16m = wrapAnsi16m(ANSI_BACKGROUND_OFFSET);
16977
- Object.defineProperties(styles, {
16978
- rgbToAnsi256: {
16979
- value(red, green, blue) {
16980
- if (red === green && green === blue) {
16981
- if (red < 8) {
16982
- return 16;
16983
- }
16984
- if (red > 248) {
16985
- return 231;
16986
- }
16987
- return Math.round((red - 8) / 247 * 24) + 232;
16988
- }
16989
- return 16 + 36 * Math.round(red / 255 * 5) + 6 * Math.round(green / 255 * 5) + Math.round(blue / 255 * 5);
16990
- },
16991
- enumerable: false
16992
- },
16993
- hexToRgb: {
16994
- value(hex) {
16995
- const matches = /[a-f\d]{6}|[a-f\d]{3}/i.exec(hex.toString(16));
16996
- if (!matches) {
16997
- return [0, 0, 0];
16998
- }
16999
- let [colorString] = matches;
17000
- if (colorString.length === 3) {
17001
- colorString = [...colorString].map((character) => character + character).join("");
17002
- }
17003
- const integer = Number.parseInt(colorString, 16);
17004
- return [
17005
- integer >> 16 & 255,
17006
- integer >> 8 & 255,
17007
- integer & 255
17008
- ];
17009
- },
17010
- enumerable: false
17011
- },
17012
- hexToAnsi256: {
17013
- value: (hex) => styles.rgbToAnsi256(...styles.hexToRgb(hex)),
17014
- enumerable: false
17015
- },
17016
- ansi256ToAnsi: {
17017
- value(code) {
17018
- if (code < 8) {
17019
- return 30 + code;
17020
- }
17021
- if (code < 16) {
17022
- return 90 + (code - 8);
17023
- }
17024
- let red;
17025
- let green;
17026
- let blue;
17027
- if (code >= 232) {
17028
- red = ((code - 232) * 10 + 8) / 255;
17029
- green = red;
17030
- blue = red;
17031
- } else {
17032
- code -= 16;
17033
- const remainder = code % 36;
17034
- red = Math.floor(code / 36) / 5;
17035
- green = Math.floor(remainder / 6) / 5;
17036
- blue = remainder % 6 / 5;
17037
- }
17038
- const value = Math.max(red, green, blue) * 2;
17039
- if (value === 0) {
17040
- return 30;
17041
- }
17042
- let result = 30 + (Math.round(blue) << 2 | Math.round(green) << 1 | Math.round(red));
17043
- if (value === 2) {
17044
- result += 60;
17045
- }
17046
- return result;
17047
- },
17048
- enumerable: false
17049
- },
17050
- rgbToAnsi: {
17051
- value: (red, green, blue) => styles.ansi256ToAnsi(styles.rgbToAnsi256(red, green, blue)),
17052
- enumerable: false
17053
- },
17054
- hexToAnsi: {
17055
- value: (hex) => styles.ansi256ToAnsi(styles.hexToAnsi256(hex)),
17056
- enumerable: false
17057
- }
17058
- });
17059
- return styles;
17060
- }
17061
- var ansiStyles = assembleStyles();
17062
- var ansi_styles_default = ansiStyles;
17063
-
17064
- // node_modules/.pnpm/chalk@5.2.0/node_modules/chalk/source/vendor/supports-color/index.js
17065
- var import_node_process = __toESM(require("process"), 1);
17066
- var import_node_os = __toESM(require("os"), 1);
17067
- var import_node_tty = __toESM(require("tty"), 1);
17068
- function hasFlag(flag, argv = globalThis.Deno ? globalThis.Deno.args : import_node_process.default.argv) {
17069
- const prefix = flag.startsWith("-") ? "" : flag.length === 1 ? "-" : "--";
17070
- const position = argv.indexOf(prefix + flag);
17071
- const terminatorPosition = argv.indexOf("--");
17072
- return position !== -1 && (terminatorPosition === -1 || position < terminatorPosition);
17073
- }
17074
- var { env } = import_node_process.default;
17075
- var flagForceColor;
17076
- if (hasFlag("no-color") || hasFlag("no-colors") || hasFlag("color=false") || hasFlag("color=never")) {
17077
- flagForceColor = 0;
17078
- } else if (hasFlag("color") || hasFlag("colors") || hasFlag("color=true") || hasFlag("color=always")) {
17079
- flagForceColor = 1;
17080
- }
17081
- function envForceColor() {
17082
- if ("FORCE_COLOR" in env) {
17083
- if (env.FORCE_COLOR === "true") {
17084
- return 1;
17085
- }
17086
- if (env.FORCE_COLOR === "false") {
17087
- return 0;
17088
- }
17089
- return env.FORCE_COLOR.length === 0 ? 1 : Math.min(Number.parseInt(env.FORCE_COLOR, 10), 3);
17090
- }
17091
- }
17092
- function translateLevel(level) {
17093
- if (level === 0) {
17094
- return false;
17095
- }
17096
- return {
17097
- level,
17098
- hasBasic: true,
17099
- has256: level >= 2,
17100
- has16m: level >= 3
17101
- };
17102
- }
17103
- function _supportsColor(haveStream, { streamIsTTY, sniffFlags = true } = {}) {
17104
- const noFlagForceColor = envForceColor();
17105
- if (noFlagForceColor !== void 0) {
17106
- flagForceColor = noFlagForceColor;
17107
- }
17108
- const forceColor = sniffFlags ? flagForceColor : noFlagForceColor;
17109
- if (forceColor === 0) {
17110
- return 0;
17111
- }
17112
- if (sniffFlags) {
17113
- if (hasFlag("color=16m") || hasFlag("color=full") || hasFlag("color=truecolor")) {
17114
- return 3;
17115
- }
17116
- if (hasFlag("color=256")) {
17117
- return 2;
17118
- }
17119
- }
17120
- if ("TF_BUILD" in env && "AGENT_NAME" in env) {
17121
- return 1;
17122
- }
17123
- if (haveStream && !streamIsTTY && forceColor === void 0) {
17124
- return 0;
17125
- }
17126
- const min = forceColor || 0;
17127
- if (env.TERM === "dumb") {
17128
- return min;
17129
- }
17130
- if (import_node_process.default.platform === "win32") {
17131
- const osRelease = import_node_os.default.release().split(".");
17132
- if (Number(osRelease[0]) >= 10 && Number(osRelease[2]) >= 10586) {
17133
- return Number(osRelease[2]) >= 14931 ? 3 : 2;
17134
- }
17135
- return 1;
17136
- }
17137
- if ("CI" in env) {
17138
- if ("GITHUB_ACTIONS" in env) {
17139
- return 3;
17140
- }
17141
- if (["TRAVIS", "CIRCLECI", "APPVEYOR", "GITLAB_CI", "BUILDKITE", "DRONE"].some((sign) => sign in env) || env.CI_NAME === "codeship") {
17142
- return 1;
17143
- }
17144
- return min;
17145
- }
17146
- if ("TEAMCITY_VERSION" in env) {
17147
- return /^(9\.(0*[1-9]\d*)\.|\d{2,}\.)/.test(env.TEAMCITY_VERSION) ? 1 : 0;
17148
- }
17149
- if (env.COLORTERM === "truecolor") {
17150
- return 3;
17151
- }
17152
- if (env.TERM === "xterm-kitty") {
17153
- return 3;
17154
- }
17155
- if ("TERM_PROGRAM" in env) {
17156
- const version = Number.parseInt((env.TERM_PROGRAM_VERSION || "").split(".")[0], 10);
17157
- switch (env.TERM_PROGRAM) {
17158
- case "iTerm.app": {
17159
- return version >= 3 ? 3 : 2;
17160
- }
17161
- case "Apple_Terminal": {
17162
- return 2;
17163
- }
17164
- }
17165
- }
17166
- if (/-256(color)?$/i.test(env.TERM)) {
17167
- return 2;
17168
- }
17169
- if (/^screen|^xterm|^vt100|^vt220|^rxvt|color|ansi|cygwin|linux/i.test(env.TERM)) {
17170
- return 1;
17171
- }
17172
- if ("COLORTERM" in env) {
17173
- return 1;
17174
- }
17175
- return min;
17176
- }
17177
- function createSupportsColor(stream, options = {}) {
17178
- const level = _supportsColor(stream, {
17179
- streamIsTTY: stream && stream.isTTY,
17180
- ...options
17181
- });
17182
- return translateLevel(level);
17183
- }
17184
- var supportsColor = {
17185
- stdout: createSupportsColor({ isTTY: import_node_tty.default.isatty(1) }),
17186
- stderr: createSupportsColor({ isTTY: import_node_tty.default.isatty(2) })
17187
- };
17188
- var supports_color_default = supportsColor;
17189
-
17190
- // node_modules/.pnpm/chalk@5.2.0/node_modules/chalk/source/utilities.js
17191
- function stringReplaceAll(string, substring, replacer) {
17192
- let index4 = string.indexOf(substring);
17193
- if (index4 === -1) {
17194
- return string;
17355
+ return cb(null, c, stat);
17356
+ };
17195
17357
  }
17196
- const substringLength = substring.length;
17197
- let endIndex = 0;
17198
- let returnValue = "";
17199
- do {
17200
- returnValue += string.slice(endIndex, index4) + substring + replacer;
17201
- endIndex = index4 + substringLength;
17202
- index4 = string.indexOf(substring, endIndex);
17203
- } while (index4 !== -1);
17204
- returnValue += string.slice(endIndex);
17205
- return returnValue;
17206
- }
17207
- function stringEncaseCRLFWithFirstIndex(string, prefix, postfix, index4) {
17208
- let endIndex = 0;
17209
- let returnValue = "";
17210
- do {
17211
- const gotCR = string[index4 - 1] === "\r";
17212
- returnValue += string.slice(endIndex, gotCR ? index4 - 1 : index4) + prefix + (gotCR ? "\r\n" : "\n") + postfix;
17213
- endIndex = index4 + 1;
17214
- index4 = string.indexOf("\n", endIndex);
17215
- } while (index4 !== -1);
17216
- returnValue += string.slice(endIndex);
17217
- return returnValue;
17218
- }
17358
+ });
17219
17359
 
17220
- // node_modules/.pnpm/chalk@5.2.0/node_modules/chalk/source/index.js
17221
- var { stdout: stdoutColor, stderr: stderrColor } = supports_color_default;
17222
- var GENERATOR = Symbol("GENERATOR");
17223
- var STYLER = Symbol("STYLER");
17224
- var IS_EMPTY = Symbol("IS_EMPTY");
17225
- var levelMapping = [
17226
- "ansi",
17227
- "ansi",
17228
- "ansi256",
17229
- "ansi16m"
17230
- ];
17231
- var styles2 = /* @__PURE__ */ Object.create(null);
17232
- var applyOptions = (object, options = {}) => {
17233
- if (options.level && !(Number.isInteger(options.level) && options.level >= 0 && options.level <= 3)) {
17234
- throw new Error("The `level` option should be an integer from 0 to 3");
17235
- }
17236
- const colorLevel = stdoutColor ? stdoutColor.level : 0;
17237
- object.level = options.level === void 0 ? colorLevel : options.level;
17238
- };
17239
- var chalkFactory = (options) => {
17240
- const chalk2 = (...strings) => strings.join(" ");
17241
- applyOptions(chalk2, options);
17242
- Object.setPrototypeOf(chalk2, createChalk.prototype);
17243
- return chalk2;
17244
- };
17245
- function createChalk(options) {
17246
- return chalkFactory(options);
17247
- }
17248
- Object.setPrototypeOf(createChalk.prototype, Function.prototype);
17249
- for (const [styleName, style] of Object.entries(ansi_styles_default)) {
17250
- styles2[styleName] = {
17251
- get() {
17252
- const builder = createBuilder(this, createStyler(style.open, style.close, this[STYLER]), this[IS_EMPTY]);
17253
- Object.defineProperty(this, styleName, { value: builder });
17254
- return builder;
17255
- }
17256
- };
17257
- }
17258
- styles2.visible = {
17259
- get() {
17260
- const builder = createBuilder(this, this[STYLER], true);
17261
- Object.defineProperty(this, "visible", { value: builder });
17262
- return builder;
17263
- }
17264
- };
17265
- var getModelAnsi = (model, level, type, ...arguments_) => {
17266
- if (model === "rgb") {
17267
- if (level === "ansi16m") {
17268
- return ansi_styles_default[type].ansi16m(...arguments_);
17269
- }
17270
- if (level === "ansi256") {
17271
- return ansi_styles_default[type].ansi256(ansi_styles_default.rgbToAnsi256(...arguments_));
17272
- }
17273
- return ansi_styles_default[type].ansi(ansi_styles_default.rgbToAnsi(...arguments_));
17274
- }
17275
- if (model === "hex") {
17276
- return getModelAnsi("rgb", level, type, ...ansi_styles_default.hexToRgb(...arguments_));
17277
- }
17278
- return ansi_styles_default[type][model](...arguments_);
17279
- };
17280
- var usedModels = ["rgb", "hex", "ansi256"];
17281
- for (const model of usedModels) {
17282
- styles2[model] = {
17283
- get() {
17284
- const { level } = this;
17285
- return function(...arguments_) {
17286
- const styler = createStyler(getModelAnsi(model, levelMapping[level], "color", ...arguments_), ansi_styles_default.color.close, this[STYLER]);
17287
- return createBuilder(this, styler, this[IS_EMPTY]);
17288
- };
17289
- }
17290
- };
17291
- const bgModel = "bg" + model[0].toUpperCase() + model.slice(1);
17292
- styles2[bgModel] = {
17293
- get() {
17294
- const { level } = this;
17295
- return function(...arguments_) {
17296
- const styler = createStyler(getModelAnsi(model, levelMapping[level], "bgColor", ...arguments_), ansi_styles_default.bgColor.close, this[STYLER]);
17297
- return createBuilder(this, styler, this[IS_EMPTY]);
17298
- };
17299
- }
17300
- };
17301
- }
17302
- var proto = Object.defineProperties(() => {
17303
- }, {
17304
- ...styles2,
17305
- level: {
17306
- enumerable: true,
17307
- get() {
17308
- return this[GENERATOR].level;
17309
- },
17310
- set(level) {
17311
- this[GENERATOR].level = level;
17312
- }
17360
+ // src/serializer/index.ts
17361
+ var import_node, import_glob;
17362
+ var init_serializer = __esm({
17363
+ "src/serializer/index.ts"() {
17364
+ import_node = __toESM(require_node2());
17365
+ import_glob = __toESM(require_glob());
17366
+ init_source();
17313
17367
  }
17314
17368
  });
17315
- var createStyler = (open, close, parent) => {
17316
- let openAll;
17317
- let closeAll;
17318
- if (parent === void 0) {
17319
- openAll = open;
17320
- closeAll = close;
17321
- } else {
17322
- openAll = parent.openAll + open;
17323
- closeAll = close + parent.closeAll;
17324
- }
17325
- return {
17326
- open,
17327
- close,
17328
- openAll,
17329
- closeAll,
17330
- parent
17331
- };
17332
- };
17333
- var createBuilder = (self2, _styler, _isEmpty) => {
17334
- const builder = (...arguments_) => applyStyle(builder, arguments_.length === 1 ? "" + arguments_[0] : arguments_.join(" "));
17335
- Object.setPrototypeOf(builder, proto);
17336
- builder[GENERATOR] = self2;
17337
- builder[STYLER] = _styler;
17338
- builder[IS_EMPTY] = _isEmpty;
17339
- return builder;
17340
- };
17341
- var applyStyle = (self2, string) => {
17342
- if (self2.level <= 0 || !string) {
17343
- return self2[IS_EMPTY] ? "" : string;
17344
- }
17345
- let styler = self2[STYLER];
17346
- if (styler === void 0) {
17347
- return string;
17348
- }
17349
- const { openAll, closeAll } = styler;
17350
- if (string.includes("\x1B")) {
17351
- while (styler !== void 0) {
17352
- string = stringReplaceAll(string, styler.close, styler.open);
17353
- styler = styler.parent;
17354
- }
17355
- }
17356
- const lfIndex = string.indexOf("\n");
17357
- if (lfIndex !== -1) {
17358
- string = stringEncaseCRLFWithFirstIndex(string, closeAll, openAll, lfIndex);
17359
- }
17360
- return openAll + string + closeAll;
17361
- };
17362
- Object.defineProperties(createChalk.prototype, styles2);
17363
- var chalk = createChalk();
17364
- var chalkStderr = createChalk({ level: stderrColor ? stderrColor.level : 0 });
17365
- var source_default = chalk;
17369
+
17370
+ // src/utils.ts
17371
+ var utils_exports = {};
17372
+ __export(utils_exports, {
17373
+ assertV1OutFolder: () => assertV1OutFolder,
17374
+ columnRenameKey: () => columnRenameKey,
17375
+ dryJournal: () => dryJournal,
17376
+ kloudMeta: () => kloudMeta,
17377
+ mapValues: () => mapValues,
17378
+ prepareMigrationFolder: () => prepareMigrationFolder,
17379
+ prepareMigrationMeta: () => prepareMigrationMeta,
17380
+ prepareOutFolder: () => prepareOutFolder2,
17381
+ schemaRenameKey: () => schemaRenameKey,
17382
+ snapshotsPriorV4: () => snapshotsPriorV4,
17383
+ statementsForDiffs: () => statementsForDiffs,
17384
+ tableRenameKey: () => tableRenameKey,
17385
+ validateWithReport: () => validateWithReport
17386
+ });
17387
+ module.exports = __toCommonJS(utils_exports);
17388
+ var import_fs = require("fs");
17366
17389
 
17367
17390
  // src/cli/views.ts
17391
+ init_source();
17368
17392
  var import_hanji = __toESM(require_hanji());
17369
17393
  var info = (msg, greyMsg = "") => {
17370
17394
  return `${source_default.blue.bold("Info:")} ${msg} ${greyMsg ? source_default.grey(greyMsg) : ""}`.trim();
@@ -21084,6 +21108,7 @@ var drySQLite = schema2.parse({
21084
21108
  var backwardCompatibleSqliteSchema = unionType([schemaV32, schemaV42, schema2]);
21085
21109
 
21086
21110
  // src/utils.ts
21111
+ init_source();
21087
21112
  var import_path = require("path");
21088
21113
 
21089
21114
  // src/jsonDiffer.js
@@ -21199,6 +21224,9 @@ var findAlternationsInTable = (table4, tableSchema) => {
21199
21224
  const addedIndexes = Object.fromEntries(
21200
21225
  Object.entries(table4.indexes__added || {}).concat(Object.entries(table4.indexes || {}).filter((it) => it[0].includes("__added"))).map((entry) => [entry[0].replace("__added", ""), entry[1]])
21201
21226
  );
21227
+ const alteredIndexes = Object.fromEntries(Object.entries(table4.indexes || {}).filter((it) => {
21228
+ return !it[0].endsWith("__deleted") && !it[0].endsWith("__added");
21229
+ }));
21202
21230
  const deletedForeignKeys = Object.fromEntries(
21203
21231
  Object.entries(table4.foreignKeys__deleted || {}).concat(Object.entries(table4.foreignKeys || {}).filter((it) => it[0].includes("__deleted"))).map((entry) => [entry[0].replace("__deleted", ""), entry[1]])
21204
21232
  );
@@ -21224,6 +21252,7 @@ var findAlternationsInTable = (table4, tableSchema) => {
21224
21252
  altered: mappedAltered,
21225
21253
  addedIndexes,
21226
21254
  deletedIndexes,
21255
+ alteredIndexes,
21227
21256
  addedForeignKeys,
21228
21257
  deletedForeignKeys,
21229
21258
  alteredForeignKeys,
@@ -21270,6 +21299,19 @@ var alternationsInColumn = (column4) => {
21270
21299
  return { ...others, notNull: { type: "deleted", value: it.notNull__deleted } };
21271
21300
  }
21272
21301
  return it;
21302
+ }).map((it) => {
21303
+ if ("primaryKey" in it) {
21304
+ return { ...it, primaryKey: { type: "changed", old: it.primaryKey.__old, new: it.primaryKey.__new } };
21305
+ }
21306
+ if ("primaryKey__added" in it) {
21307
+ const { notNull__added, ...others } = it;
21308
+ return { ...others, primaryKey: { type: "added", value: it.primaryKey__added } };
21309
+ }
21310
+ if ("primaryKey__deleted" in it) {
21311
+ const { notNull__deleted, ...others } = it;
21312
+ return { ...others, primaryKey: { type: "deleted", value: it.primaryKey__deleted } };
21313
+ }
21314
+ return it;
21273
21315
  }).map((it) => {
21274
21316
  if ("onUpdate" in it) {
21275
21317
  return { ...it, onUpdate: { type: "changed", old: it.onUpdate.__old, new: it.onUpdate.__new } };
@@ -21296,19 +21338,6 @@ var alternationsInColumn = (column4) => {
21296
21338
  return { ...others, autoincrement: { type: "deleted", value: it.autoincrement__deleted } };
21297
21339
  }
21298
21340
  return it;
21299
- }).map((it) => {
21300
- if ("primaryKey" in it) {
21301
- return { ...it, primaryKey: { type: "changed", old: it.primaryKey.__old, new: it.primaryKey.__new } };
21302
- }
21303
- if ("primaryKey__added" in it) {
21304
- const { primaryKey__added, ...others } = it;
21305
- return { ...others, primaryKey: { type: "added", value: it.primaryKey__added } };
21306
- }
21307
- if ("primaryKey__deleted" in it) {
21308
- const { primaryKey__deleted, ...others } = it;
21309
- return { ...others, primaryKey: { type: "deleted", value: it.primaryKey__deleted } };
21310
- }
21311
- return it;
21312
21341
  });
21313
21342
  return result[0];
21314
21343
  };
@@ -21318,6 +21347,7 @@ init_serializer();
21318
21347
 
21319
21348
  // src/cli/commands/migrate.ts
21320
21349
  var import_hanji2 = __toESM(require_hanji());
21350
+ init_source();
21321
21351
  var BREAKPOINT = "--> statement-breakpoint\n";
21322
21352
 
21323
21353
  // src/sqlgenerator.ts
@@ -21414,26 +21444,24 @@ var MySqlCreateTableConvertor = class extends Convertor {
21414
21444
  `;
21415
21445
  for (let i = 0; i < columns.length; i++) {
21416
21446
  const column4 = columns[i];
21417
- const primaryKeyStatement = column4.primaryKey ? "PRIMARY KEY" : "";
21418
- const notNullStatement = column4.notNull ? "NOT NULL" : "";
21419
- const defaultStatement = column4.default !== void 0 ? `DEFAULT ${column4.default}` : "";
21420
- const onUpdateStatement = column4.onUpdate ? `ON UPDATE CURRENT_TIMESTAMP` : "";
21421
- const autoincrementStatement = column4.autoincrement ? "AUTO_INCREMENT" : "";
21422
- statement += " " + `\`${column4.name}\` ${column4.type} ${autoincrementStatement} ${primaryKeyStatement} ${notNullStatement} ${defaultStatement} ${onUpdateStatement}`.replace(/ +/g, " ").trim();
21423
- statement += (i === columns.length - 1 ? "" : ",") + "\n";
21447
+ const primaryKeyStatement = column4.primaryKey ? " PRIMARY KEY" : "";
21448
+ const notNullStatement = column4.notNull ? " NOT NULL" : "";
21449
+ const defaultStatement = column4.default !== void 0 ? ` DEFAULT ${column4.default}` : "";
21450
+ const onUpdateStatement = column4.onUpdate ? ` ON UPDATE CURRENT_TIMESTAMP` : "";
21451
+ const autoincrementStatement = column4.autoincrement ? " AUTO_INCREMENT" : "";
21452
+ statement += " " + `\`${column4.name}\` ${column4.type}${autoincrementStatement}${primaryKeyStatement}${notNullStatement}${defaultStatement}${onUpdateStatement}`.trim();
21453
+ statement += i === columns.length - 1 ? "" : ",\n";
21424
21454
  }
21425
- statement += `);`;
21426
- statement += `
21427
- `;
21428
21455
  if (typeof compositePKs !== "undefined" && compositePKs.length > 0) {
21456
+ statement += ",\n";
21429
21457
  const compositePK4 = MySqlSquasher.unsquashPK(compositePKs[0]);
21430
- statement += BREAKPOINT;
21431
- statement += `ALTER TABLE ${tName} ADD PRIMARY KEY(\`${compositePK4.columns.join(
21432
- "`,`"
21433
- )}\`);`;
21458
+ statement += ` PRIMARY KEY(\`${compositePK4.columns.join("`,`")}\`)`;
21434
21459
  statement += `
21435
21460
  `;
21436
21461
  }
21462
+ statement += `);`;
21463
+ statement += `
21464
+ `;
21437
21465
  return statement;
21438
21466
  }
21439
21467
  };
@@ -21524,7 +21552,7 @@ var DropTableConvertor = class extends Convertor {
21524
21552
  }
21525
21553
  convert(statement) {
21526
21554
  const { tableName } = statement;
21527
- return `DROP TABLE ${tableName};`;
21555
+ return `DROP TABLE \`${tableName}\`;`;
21528
21556
  }
21529
21557
  };
21530
21558
  var PgRenameTableConvertor = class extends Convertor {
@@ -21631,12 +21659,13 @@ var MySqlAlterTableAddColumnConvertor = class extends Convertor {
21631
21659
  }
21632
21660
  convert(statement) {
21633
21661
  const { tableName, column: column4 } = statement;
21634
- const { name, type, notNull, primaryKey, autoincrement } = column4;
21635
- const defaultStatement = `${column4.default !== void 0 ? `DEFAULT ${column4.default}` : ""}`;
21636
- const notNullStatement = `${notNull ? "NOT NULL" : ""}`;
21637
- const primaryKeyStatement = `${primaryKey ? "PRIMARY KEY" : ""}`;
21638
- const autoincrementStatement = `${autoincrement ? "AUTO_INCREMENT" : ""}`;
21639
- return `ALTER TABLE \`${tableName}\` ADD \`${name}\` ${type} ${primaryKeyStatement} ${autoincrementStatement} ${defaultStatement} ${notNullStatement}`.replace(/ +/g, " ").trim() + ";";
21662
+ const { name, type, notNull, primaryKey, autoincrement, onUpdate } = column4;
21663
+ const defaultStatement = `${column4.default !== void 0 ? ` DEFAULT ${column4.default}` : ""}`;
21664
+ const notNullStatement = `${notNull ? " NOT NULL" : ""}`;
21665
+ const primaryKeyStatement = `${primaryKey ? " PRIMARY KEY" : ""}`;
21666
+ const autoincrementStatement = `${autoincrement ? " AUTO_INCREMENT" : ""}`;
21667
+ const onUpdateStatement = `${onUpdate ? " ON UPDATE CURRENT_TIMESTAMP" : ""}`;
21668
+ return `ALTER TABLE \`${tableName}\` ADD \`${name}\` ${type}${primaryKeyStatement}${autoincrementStatement}${defaultStatement}${notNullStatement}${onUpdateStatement};`;
21640
21669
  }
21641
21670
  };
21642
21671
  var SQLiteAlterTableAddColumnConvertor = class extends Convertor {
@@ -21711,27 +21740,25 @@ var PgAlterTableAlterColumnDropDefaultConvertor = class extends Convertor {
21711
21740
  return `ALTER TABLE "${tableName}" ALTER COLUMN "${columnName}" DROP DEFAULT;`;
21712
21741
  }
21713
21742
  };
21714
- var MySqlAlterTableAlterColumnSetDefaultConvertor = class extends Convertor {
21743
+ var MySqlAlterTableAddPk = class extends Convertor {
21715
21744
  can(statement, dialect3) {
21716
- return statement.type === "alter_table_alter_column_set_default" && dialect3 === "mysql";
21745
+ return statement.type === "alter_table_alter_column_set_pk" && dialect3 === "mysql";
21717
21746
  }
21718
21747
  convert(statement) {
21719
- const { tableName, columnName } = statement;
21720
- return `ALTER TABLE \`${tableName}\` ALTER COLUMN \`${columnName}\` SET DEFAULT ${statement.newDefaultValue};`;
21748
+ return `ALTER TABLE \`${statement.tableName}\` ADD PRIMARY KEY (\`${statement.columnName}\`);`;
21721
21749
  }
21722
21750
  };
21723
- var MySqlAlterTableAlterColumnDropDefaultConvertor = class extends Convertor {
21751
+ var MySqlAlterTableDropPk = class extends Convertor {
21724
21752
  can(statement, dialect3) {
21725
- return statement.type === "alter_table_alter_column_drop_default" && dialect3 === "mysql";
21753
+ return statement.type === "alter_table_alter_column_drop_pk" && dialect3 === "mysql";
21726
21754
  }
21727
21755
  convert(statement) {
21728
- const { tableName, columnName } = statement;
21729
- return `ALTER TABLE \`${tableName}\` ALTER COLUMN \`${columnName}\` DROP DEFAULT;`;
21756
+ return `ALTER TABLE \`${statement.tableName}\` DROP PRIMARY KEY`;
21730
21757
  }
21731
21758
  };
21732
21759
  var MySqlModifyColumn = class extends Convertor {
21733
21760
  can(statement, dialect3) {
21734
- return (statement.type === "alter_table_alter_column_set_type" || statement.type === "alter_table_alter_column_set_notnull" || statement.type === "alter_table_alter_column_drop_notnull" || statement.type === "alter_table_alter_column_drop_on_update" || statement.type === "alter_table_alter_column_set_on_update" || statement.type === "alter_table_alter_column_set_autoincrement" || statement.type === "alter_table_alter_column_drop_autoincrement") && dialect3 === "mysql";
21761
+ return (statement.type === "alter_table_alter_column_set_type" || statement.type === "alter_table_alter_column_set_notnull" || statement.type === "alter_table_alter_column_drop_notnull" || statement.type === "alter_table_alter_column_drop_on_update" || statement.type === "alter_table_alter_column_set_on_update" || statement.type === "alter_table_alter_column_set_autoincrement" || statement.type === "alter_table_alter_column_drop_autoincrement" || statement.type === "alter_table_alter_column_set_default" || statement.type === "alter_table_alter_column_drop_default") && dialect3 === "mysql";
21735
21762
  }
21736
21763
  convert(statement) {
21737
21764
  const { tableName, columnName } = statement;
@@ -21740,6 +21767,7 @@ var MySqlModifyColumn = class extends Convertor {
21740
21767
  let columnNotNull = "";
21741
21768
  let columnOnUpdate = "";
21742
21769
  let columnAutoincrement = "";
21770
+ let primaryKey = statement.columnPk ? " PRIMARY KEY" : "";
21743
21771
  if (statement.type === "alter_table_alter_column_drop_notnull") {
21744
21772
  columnType = ` ${statement.newDataType}`;
21745
21773
  columnDefault = statement.columnDefault ? ` DEFAULT ${statement.columnDefault}` : "";
@@ -21769,19 +21797,31 @@ var MySqlModifyColumn = class extends Convertor {
21769
21797
  columnOnUpdate = columnOnUpdate = statement.columnOnUpdate ? ` ON UPDATE CURRENT_TIMESTAMP` : "";
21770
21798
  columnType = ` ${statement.newDataType}`;
21771
21799
  columnDefault = statement.columnDefault ? ` DEFAULT ${statement.columnDefault}` : "";
21772
- columnAutoincrement = "AUTO_INCREMENT";
21800
+ columnAutoincrement = " AUTO_INCREMENT";
21773
21801
  } else if (statement.type === "alter_table_alter_column_drop_autoincrement") {
21774
21802
  columnNotNull = statement.columnNotNull ? ` NOT NULL` : "";
21775
21803
  columnOnUpdate = columnOnUpdate = statement.columnOnUpdate ? ` ON UPDATE CURRENT_TIMESTAMP` : "";
21776
21804
  columnType = ` ${statement.newDataType}`;
21777
21805
  columnDefault = statement.columnDefault ? ` DEFAULT ${statement.columnDefault}` : "";
21778
21806
  columnAutoincrement = "";
21807
+ } else if (statement.type === "alter_table_alter_column_set_default") {
21808
+ columnNotNull = statement.columnNotNull ? ` NOT NULL` : "";
21809
+ columnOnUpdate = columnOnUpdate = statement.columnOnUpdate ? ` ON UPDATE CURRENT_TIMESTAMP` : "";
21810
+ columnType = ` ${statement.newDataType}`;
21811
+ columnDefault = ` DEFAULT ${statement.newDefaultValue}`;
21812
+ columnAutoincrement = statement.columnAutoIncrement ? " AUTO_INCREMENT" : "";
21813
+ } else if (statement.type === "alter_table_alter_column_drop_default") {
21814
+ columnNotNull = statement.columnNotNull ? ` NOT NULL` : "";
21815
+ columnOnUpdate = columnOnUpdate = statement.columnOnUpdate ? ` ON UPDATE CURRENT_TIMESTAMP` : "";
21816
+ columnType = ` ${statement.newDataType}`;
21817
+ columnDefault = "";
21818
+ columnAutoincrement = statement.columnAutoIncrement ? " AUTO_INCREMENT" : "";
21779
21819
  } else {
21780
21820
  columnType = ` ${statement.newDataType}`;
21781
21821
  columnNotNull = statement.columnNotNull ? ` NOT NULL` : "";
21782
21822
  columnOnUpdate = columnOnUpdate = statement.columnOnUpdate ? ` ON UPDATE CURRENT_TIMESTAMP` : "";
21783
21823
  columnDefault = statement.columnDefault ? ` DEFAULT ${statement.columnDefault}` : "";
21784
- columnAutoincrement = statement.columnAutoIncrement ? "AUTO_INCREMENT" : "";
21824
+ columnAutoincrement = statement.columnAutoIncrement ? " AUTO_INCREMENT" : "";
21785
21825
  }
21786
21826
  columnDefault = columnDefault instanceof Date ? columnDefault.toISOString() : columnDefault;
21787
21827
  return `ALTER TABLE \`${tableName}\` MODIFY COLUMN \`${columnName}\`${columnType}${columnAutoincrement}${columnNotNull}${columnDefault}${columnOnUpdate};`;
@@ -21944,7 +21984,7 @@ var SqliteAlterTableAlterCompositePrimaryKeyConvertor = class extends Convertor
21944
21984
  };
21945
21985
  var PgAlterTableAlterColumnSetPrimaryKeyConvertor = class extends Convertor {
21946
21986
  can(statement, dialect3) {
21947
- return statement.type === "alter_table_alter_column_set_primarykey" && dialect3 === "pg";
21987
+ return statement.type === "alter_table_alter_column_set_pk" && dialect3 === "pg";
21948
21988
  }
21949
21989
  convert(statement) {
21950
21990
  const { tableName, columnName } = statement;
@@ -21953,7 +21993,7 @@ var PgAlterTableAlterColumnSetPrimaryKeyConvertor = class extends Convertor {
21953
21993
  };
21954
21994
  var PgAlterTableAlterColumnDropPrimaryKeyConvertor = class extends Convertor {
21955
21995
  can(statement, dialect3) {
21956
- return statement.type === "alter_table_alter_column_drop_primarykey" && dialect3 === "pg";
21996
+ return statement.type === "alter_table_alter_column_drop_pk" && dialect3 === "pg";
21957
21997
  }
21958
21998
  convert(statement) {
21959
21999
  const { tableName, columnName, schema: schema4 } = statement;
@@ -22105,7 +22145,6 @@ var PgAlterForeignKeyConvertor = class extends Convertor {
22105
22145
  sql += " WHEN duplicate_object THEN null;\n";
22106
22146
  sql += "END $$;\n";
22107
22147
  return sql;
22108
- throw new Error("TODO");
22109
22148
  }
22110
22149
  };
22111
22150
  var SqliteAlterForeignKeyConvertor = class extends Convertor {
@@ -22373,8 +22412,6 @@ convertors.push(new PgAlterTableAlterColumnDropNotNullConvertor());
22373
22412
  convertors.push(new PgAlterTableAlterColumnSetDefaultConvertor());
22374
22413
  convertors.push(new PgAlterTableAlterColumnDropDefaultConvertor());
22375
22414
  convertors.push(new MySqlModifyColumn());
22376
- convertors.push(new MySqlAlterTableAlterColumnSetDefaultConvertor());
22377
- convertors.push(new MySqlAlterTableAlterColumnDropDefaultConvertor());
22378
22415
  convertors.push(new PgCreateForeignKeyConvertor());
22379
22416
  convertors.push(new MySqlCreateForeignKeyConvertor());
22380
22417
  convertors.push(new PgAlterForeignKeyConvertor());
@@ -22405,8 +22442,10 @@ convertors.push(new SqliteAlterTableAlterCompositePrimaryKeyConvertor());
22405
22442
  convertors.push(new PgAlterTableCreateCompositePrimaryKeyConvertor());
22406
22443
  convertors.push(new PgAlterTableDeleteCompositePrimaryKeyConvertor());
22407
22444
  convertors.push(new PgAlterTableAlterCompositePrimaryKeyConvertor());
22408
- convertors.push(new MySqlAlterTableCreateCompositePrimaryKeyConvertor());
22409
22445
  convertors.push(new MySqlAlterTableDeleteCompositePrimaryKeyConvertor());
22446
+ convertors.push(new MySqlAlterTableDropPk());
22447
+ convertors.push(new MySqlAlterTableCreateCompositePrimaryKeyConvertor());
22448
+ convertors.push(new MySqlAlterTableAddPk());
22410
22449
  convertors.push(new MySqlAlterTableAlterCompositePrimaryKeyConvertor());
22411
22450
  var fromJson = (statements, dialect3) => {
22412
22451
  const result = statements.map((statement) => {
@@ -22419,7 +22458,7 @@ var fromJson = (statements, dialect3) => {
22419
22458
  return "";
22420
22459
  }
22421
22460
  return convertor.convert(statement);
22422
- });
22461
+ }).filter((it) => it !== "");
22423
22462
  return result;
22424
22463
  };
22425
22464
  https:
@@ -22610,8 +22649,10 @@ var _prepareSQLiteAddColumns = (tableName, columns, referenceData) => {
22610
22649
  });
22611
22650
  };
22612
22651
  var _prepareAlterColumns = (tableName, schema4, columns, json2) => {
22613
- var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n, _o;
22652
+ var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n, _o, _p;
22614
22653
  let statements = [];
22654
+ let dropPkStatements = [];
22655
+ let setPkStatements = [];
22615
22656
  for (const column4 of columns) {
22616
22657
  const columnName = typeof column4.name !== "string" ? column4.name.new : column4.name;
22617
22658
  const columnType = json2.tables[tableName].columns[columnName].type;
@@ -22619,57 +22660,25 @@ var _prepareAlterColumns = (tableName, schema4, columns, json2) => {
22619
22660
  const columnOnUpdate = json2.tables[tableName].columns[columnName].onUpdate;
22620
22661
  const columnNotNull = json2.tables[tableName].columns[columnName].notNull;
22621
22662
  const columnAutoIncrement = json2.tables[tableName].columns[columnName].autoincrement;
22622
- if (typeof column4.name !== "string") {
22623
- statements.push({
22624
- type: "alter_table_rename_column",
22625
- tableName,
22626
- oldColumnName: column4.name.old,
22627
- newColumnName: column4.name.new,
22628
- schema: schema4
22629
- });
22630
- }
22631
- if (((_a = column4.type) == null ? void 0 : _a.type) === "changed") {
22663
+ const columnPk = json2.tables[tableName].columns[columnName].primaryKey;
22664
+ if (((_a = column4.autoincrement) == null ? void 0 : _a.type) === "added") {
22632
22665
  statements.push({
22633
- type: "alter_table_alter_column_set_type",
22666
+ type: "alter_table_alter_column_set_autoincrement",
22634
22667
  tableName,
22635
22668
  columnName,
22636
- newDataType: column4.type.new,
22637
22669
  schema: schema4,
22670
+ newDataType: columnType,
22638
22671
  columnDefault,
22639
22672
  columnOnUpdate,
22640
22673
  columnNotNull,
22641
- columnAutoIncrement
22642
- });
22643
- }
22644
- if (((_b = column4.default) == null ? void 0 : _b.type) === "added") {
22645
- statements.push({
22646
- type: "alter_table_alter_column_set_default",
22647
- tableName,
22648
- columnName,
22649
- newDefaultValue: column4.default.value,
22650
- schema: schema4
22651
- });
22652
- }
22653
- if (((_c = column4.default) == null ? void 0 : _c.type) === "changed") {
22654
- statements.push({
22655
- type: "alter_table_alter_column_set_default",
22656
- tableName,
22657
- columnName,
22658
- newDefaultValue: column4.default.new,
22659
- schema: schema4
22660
- });
22661
- }
22662
- if (((_d = column4.default) == null ? void 0 : _d.type) === "deleted") {
22663
- statements.push({
22664
- type: "alter_table_alter_column_drop_default",
22665
- tableName,
22666
- columnName,
22667
- schema: schema4
22674
+ columnAutoIncrement,
22675
+ columnPk
22668
22676
  });
22669
22677
  }
22670
- if (((_e = column4.notNull) == null ? void 0 : _e.type) === "added") {
22678
+ if (((_b = column4.autoincrement) == null ? void 0 : _b.type) === "changed") {
22679
+ const type = column4.autoincrement.new ? "alter_table_alter_column_set_autoincrement" : "alter_table_alter_column_drop_autoincrement";
22671
22680
  statements.push({
22672
- type: "alter_table_alter_column_set_notnull",
22681
+ type,
22673
22682
  tableName,
22674
22683
  columnName,
22675
22684
  schema: schema4,
@@ -22677,13 +22686,13 @@ var _prepareAlterColumns = (tableName, schema4, columns, json2) => {
22677
22686
  columnDefault,
22678
22687
  columnOnUpdate,
22679
22688
  columnNotNull,
22680
- columnAutoIncrement
22689
+ columnAutoIncrement,
22690
+ columnPk
22681
22691
  });
22682
22692
  }
22683
- if (((_f = column4.notNull) == null ? void 0 : _f.type) === "changed") {
22684
- const type = column4.notNull.new ? "alter_table_alter_column_set_notnull" : "alter_table_alter_column_drop_notnull";
22693
+ if (((_c = column4.autoincrement) == null ? void 0 : _c.type) === "deleted") {
22685
22694
  statements.push({
22686
- type,
22695
+ type: "alter_table_alter_column_drop_autoincrement",
22687
22696
  tableName,
22688
22697
  columnName,
22689
22698
  schema: schema4,
@@ -22691,65 +22700,95 @@ var _prepareAlterColumns = (tableName, schema4, columns, json2) => {
22691
22700
  columnDefault,
22692
22701
  columnOnUpdate,
22693
22702
  columnNotNull,
22694
- columnAutoIncrement
22703
+ columnAutoIncrement,
22704
+ columnPk
22705
+ });
22706
+ }
22707
+ }
22708
+ for (const column4 of columns) {
22709
+ const columnName = typeof column4.name !== "string" ? column4.name.new : column4.name;
22710
+ const columnType = json2.tables[tableName].columns[columnName].type;
22711
+ const columnDefault = json2.tables[tableName].columns[columnName].default;
22712
+ const columnOnUpdate = json2.tables[tableName].columns[columnName].onUpdate;
22713
+ const columnNotNull = json2.tables[tableName].columns[columnName].notNull;
22714
+ const columnAutoIncrement = json2.tables[tableName].columns[columnName].autoincrement;
22715
+ const columnPk = json2.tables[tableName].columns[columnName].primaryKey;
22716
+ if (typeof column4.name !== "string") {
22717
+ statements.push({
22718
+ type: "alter_table_rename_column",
22719
+ tableName,
22720
+ oldColumnName: column4.name.old,
22721
+ newColumnName: column4.name.new,
22722
+ schema: schema4
22695
22723
  });
22696
22724
  }
22697
- if (((_g = column4.notNull) == null ? void 0 : _g.type) === "deleted") {
22725
+ if (((_d = column4.type) == null ? void 0 : _d.type) === "changed") {
22698
22726
  statements.push({
22699
- type: "alter_table_alter_column_drop_notnull",
22727
+ type: "alter_table_alter_column_set_type",
22700
22728
  tableName,
22701
22729
  columnName,
22730
+ newDataType: column4.type.new,
22731
+ oldDataType: column4.type.old,
22702
22732
  schema: schema4,
22703
- newDataType: columnType,
22704
22733
  columnDefault,
22705
22734
  columnOnUpdate,
22706
22735
  columnNotNull,
22707
- columnAutoIncrement
22736
+ columnAutoIncrement,
22737
+ columnPk
22738
+ });
22739
+ }
22740
+ if (((_e = column4.primaryKey) == null ? void 0 : _e.type) === "deleted" || ((_f = column4.primaryKey) == null ? void 0 : _f.type) === "changed" && !column4.primaryKey.new) {
22741
+ dropPkStatements.push({
22742
+ type: "alter_table_alter_column_drop_pk",
22743
+ tableName,
22744
+ columnName
22708
22745
  });
22709
22746
  }
22710
- if (((_h = column4.autoincrement) == null ? void 0 : _h.type) === "added") {
22747
+ if (((_g = column4.default) == null ? void 0 : _g.type) === "added") {
22711
22748
  statements.push({
22712
- type: "alter_table_alter_column_set_autoincrement",
22749
+ type: "alter_table_alter_column_set_default",
22713
22750
  tableName,
22714
22751
  columnName,
22752
+ newDefaultValue: column4.default.value,
22715
22753
  schema: schema4,
22716
- newDataType: columnType,
22717
- columnDefault,
22718
22754
  columnOnUpdate,
22719
22755
  columnNotNull,
22720
- columnAutoIncrement
22756
+ columnAutoIncrement,
22757
+ newDataType: columnType,
22758
+ columnPk
22721
22759
  });
22722
22760
  }
22723
- if (((_i = column4.autoincrement) == null ? void 0 : _i.type) === "changed") {
22724
- const type = column4.autoincrement.new ? "alter_table_alter_column_set_notnull" : "alter_table_alter_column_drop_notnull";
22761
+ if (((_h = column4.default) == null ? void 0 : _h.type) === "changed") {
22725
22762
  statements.push({
22726
- type,
22763
+ type: "alter_table_alter_column_set_default",
22727
22764
  tableName,
22728
22765
  columnName,
22766
+ newDefaultValue: column4.default.new,
22729
22767
  schema: schema4,
22730
- newDataType: columnType,
22731
- columnDefault,
22732
22768
  columnOnUpdate,
22733
22769
  columnNotNull,
22734
- columnAutoIncrement
22770
+ columnAutoIncrement,
22771
+ newDataType: columnType,
22772
+ columnPk
22735
22773
  });
22736
22774
  }
22737
- if (((_j = column4.autoincrement) == null ? void 0 : _j.type) === "deleted") {
22775
+ if (((_i = column4.default) == null ? void 0 : _i.type) === "deleted") {
22738
22776
  statements.push({
22739
- type: "alter_table_alter_column_drop_autoincrement",
22777
+ type: "alter_table_alter_column_drop_default",
22740
22778
  tableName,
22741
22779
  columnName,
22742
22780
  schema: schema4,
22743
- newDataType: columnType,
22744
22781
  columnDefault,
22745
22782
  columnOnUpdate,
22746
22783
  columnNotNull,
22747
- columnAutoIncrement
22784
+ columnAutoIncrement,
22785
+ newDataType: columnType,
22786
+ columnPk
22748
22787
  });
22749
22788
  }
22750
- if (((_k = column4.primaryKey) == null ? void 0 : _k.type) === "added") {
22789
+ if (((_j = column4.notNull) == null ? void 0 : _j.type) === "added") {
22751
22790
  statements.push({
22752
- type: "alter_table_alter_column_set_primarykey",
22791
+ type: "alter_table_alter_column_set_notnull",
22753
22792
  tableName,
22754
22793
  columnName,
22755
22794
  schema: schema4,
@@ -22757,11 +22796,12 @@ var _prepareAlterColumns = (tableName, schema4, columns, json2) => {
22757
22796
  columnDefault,
22758
22797
  columnOnUpdate,
22759
22798
  columnNotNull,
22760
- columnAutoIncrement
22799
+ columnAutoIncrement,
22800
+ columnPk
22761
22801
  });
22762
22802
  }
22763
- if (((_l = column4.primaryKey) == null ? void 0 : _l.type) === "changed") {
22764
- const type = column4.primaryKey.new ? "alter_table_alter_column_set_primarykey" : "alter_table_alter_column_drop_primarykey";
22803
+ if (((_k = column4.notNull) == null ? void 0 : _k.type) === "changed") {
22804
+ const type = column4.notNull.new ? "alter_table_alter_column_set_notnull" : "alter_table_alter_column_drop_notnull";
22765
22805
  statements.push({
22766
22806
  type,
22767
22807
  tableName,
@@ -22771,12 +22811,13 @@ var _prepareAlterColumns = (tableName, schema4, columns, json2) => {
22771
22811
  columnDefault,
22772
22812
  columnOnUpdate,
22773
22813
  columnNotNull,
22774
- columnAutoIncrement
22814
+ columnAutoIncrement,
22815
+ columnPk
22775
22816
  });
22776
22817
  }
22777
- if (((_m = column4.primaryKey) == null ? void 0 : _m.type) === "deleted") {
22818
+ if (((_l = column4.notNull) == null ? void 0 : _l.type) === "deleted") {
22778
22819
  statements.push({
22779
- type: "alter_table_alter_column_drop_primarykey",
22820
+ type: "alter_table_alter_column_drop_notnull",
22780
22821
  tableName,
22781
22822
  columnName,
22782
22823
  schema: schema4,
@@ -22784,10 +22825,23 @@ var _prepareAlterColumns = (tableName, schema4, columns, json2) => {
22784
22825
  columnDefault,
22785
22826
  columnOnUpdate,
22786
22827
  columnNotNull,
22787
- columnAutoIncrement
22828
+ columnAutoIncrement,
22829
+ columnPk
22788
22830
  });
22789
22831
  }
22790
- if (((_n = column4.onUpdate) == null ? void 0 : _n.type) === "added") {
22832
+ if (((_m = column4.primaryKey) == null ? void 0 : _m.type) === "added" || ((_n = column4.primaryKey) == null ? void 0 : _n.type) === "changed" && column4.primaryKey.new) {
22833
+ const wasAutoincrement = statements.filter(
22834
+ (it) => it.type === "alter_table_alter_column_set_autoincrement"
22835
+ );
22836
+ if (wasAutoincrement.length === 0) {
22837
+ setPkStatements.push({
22838
+ type: "alter_table_alter_column_set_pk",
22839
+ tableName,
22840
+ columnName
22841
+ });
22842
+ }
22843
+ }
22844
+ if (((_o = column4.onUpdate) == null ? void 0 : _o.type) === "added") {
22791
22845
  statements.push({
22792
22846
  type: "alter_table_alter_column_set_on_update",
22793
22847
  tableName,
@@ -22797,10 +22851,11 @@ var _prepareAlterColumns = (tableName, schema4, columns, json2) => {
22797
22851
  columnDefault,
22798
22852
  columnOnUpdate,
22799
22853
  columnNotNull,
22800
- columnAutoIncrement
22854
+ columnAutoIncrement,
22855
+ columnPk
22801
22856
  });
22802
22857
  }
22803
- if (((_o = column4.onUpdate) == null ? void 0 : _o.type) === "deleted") {
22858
+ if (((_p = column4.onUpdate) == null ? void 0 : _p.type) === "deleted") {
22804
22859
  statements.push({
22805
22860
  type: "alter_table_alter_column_drop_on_update",
22806
22861
  tableName,
@@ -22810,11 +22865,12 @@ var _prepareAlterColumns = (tableName, schema4, columns, json2) => {
22810
22865
  columnDefault,
22811
22866
  columnOnUpdate,
22812
22867
  columnNotNull,
22813
- columnAutoIncrement
22868
+ columnAutoIncrement,
22869
+ columnPk
22814
22870
  });
22815
22871
  }
22816
22872
  }
22817
- return statements;
22873
+ return [...dropPkStatements, ...setPkStatements, ...statements];
22818
22874
  };
22819
22875
  var prepareCreateIndexesJson = (tableName, schema4, indexes) => {
22820
22876
  return Object.values(indexes).map((indexData) => {
@@ -23042,9 +23098,9 @@ var alteredColumnSchema = objectType({
23042
23098
  name: makeSelfOrChanged(stringType()),
23043
23099
  type: makeChanged(stringType()).optional(),
23044
23100
  default: makePatched(anyType()).optional(),
23101
+ primaryKey: makePatched(booleanType()).optional(),
23045
23102
  notNull: makePatched(booleanType()).optional(),
23046
23103
  onUpdate: makePatched(booleanType()).optional(),
23047
- primaryKey: makePatched(booleanType()).optional(),
23048
23104
  autoincrement: makePatched(booleanType()).optional()
23049
23105
  }).strict();
23050
23106
  var enumSchema2 = objectType({
@@ -23072,6 +23128,13 @@ var alteredTableScheme = objectType({
23072
23128
  altered: alteredColumnSchema.array(),
23073
23129
  addedIndexes: recordType(stringType(), stringType()),
23074
23130
  deletedIndexes: recordType(stringType(), stringType()),
23131
+ alteredIndexes: recordType(
23132
+ stringType(),
23133
+ objectType({
23134
+ __new: stringType(),
23135
+ __old: stringType()
23136
+ }).strict()
23137
+ ),
23075
23138
  addedForeignKeys: recordType(stringType(), stringType()),
23076
23139
  deletedForeignKeys: recordType(stringType(), stringType()),
23077
23140
  alteredForeignKeys: recordType(
@@ -23172,6 +23235,7 @@ var applySnapshotsDiff = async (json1, json2, dialect3, schemasResolver, tablesR
23172
23235
  altered: allAltered2,
23173
23236
  addedIndexes: table4.addedIndexes,
23174
23237
  deletedIndexes: table4.deletedIndexes,
23238
+ alteredIndexes: table4.alteredIndexes,
23175
23239
  addedForeignKeys: table4.addedForeignKeys,
23176
23240
  deletedForeignKeys: table4.deletedForeignKeys,
23177
23241
  alteredForeignKeys: table4.alteredForeignKeys,
@@ -23309,6 +23373,25 @@ var applySnapshotsDiff = async (json1, json2, dialect3, schemasResolver, tablesR
23309
23373
  const schema4 = valueFromSelfOrPatchedNew(it.schema);
23310
23374
  return prepareDropIndexesJson(it.name, schema4, it.deletedIndexes || {});
23311
23375
  }).flat();
23376
+ allAltered.forEach((it) => {
23377
+ const schema4 = valueFromSelfOrPatchedNew(it.schema);
23378
+ const droppedIndexes = Object.keys(it.alteredIndexes).reduce(
23379
+ (current, item) => {
23380
+ current[item] = it.alteredIndexes[item].__old;
23381
+ return current;
23382
+ },
23383
+ {}
23384
+ );
23385
+ const createdIndexes = Object.keys(it.alteredIndexes).reduce(
23386
+ (current, item) => {
23387
+ current[item] = it.alteredIndexes[item].__new;
23388
+ return current;
23389
+ },
23390
+ {}
23391
+ );
23392
+ jsonCreateIndexesForAllAlteredTables.push(...prepareCreateIndexesJson(it.name, schema4, createdIndexes || {}));
23393
+ jsonDropIndexesForAllAlteredTables.push(...prepareDropIndexesJson(it.name, schema4, droppedIndexes || {}));
23394
+ });
23312
23395
  const jsonCreateReferencesForCreatedTables = created.map((it) => {
23313
23396
  return prepareCreateReferencesJson(it.name, it.schema, it.foreignKeys);
23314
23397
  }).flat();
@@ -23375,16 +23458,16 @@ var applySnapshotsDiff = async (json1, json2, dialect3, schemasResolver, tablesR
23375
23458
  jsonStatements.push(...jsonDropTables);
23376
23459
  jsonStatements.push(...jsonRenameTables);
23377
23460
  jsonStatements.push(...jsonRenameColumnsStatements);
23461
+ jsonStatements.push(...jsonDeletedCompositePKs);
23462
+ jsonStatements.push(...jsonDropIndexesForAllAlteredTables);
23378
23463
  jsonStatements.push(...jsonTableAlternations.alterColumns);
23379
23464
  jsonStatements.push(...jsonTableAlternations.createColumns);
23380
23465
  jsonStatements.push(...jsonAlterReferencesForAlteredTables);
23381
23466
  jsonStatements.push(...jsonTableAlternations.dropColumns);
23382
23467
  if (dialect3 !== "sqlite")
23383
23468
  jsonStatements.push(...jsonCreateReferences);
23384
- jsonStatements.push(...jsonDropIndexesForAllAlteredTables);
23385
23469
  jsonStatements.push(...jsonCreateIndexesForCreatedTables);
23386
23470
  jsonStatements.push(...jsonCreateIndexesForAllAlteredTables);
23387
- jsonStatements.push(...jsonDeletedCompositePKs);
23388
23471
  jsonStatements.push(...jsonAddedCompositePKs);
23389
23472
  jsonStatements.push(...jsonAlteredCompositePKs);
23390
23473
  jsonStatements.push(...jsonSetTableSchemas);
@@ -23406,6 +23489,12 @@ var applySnapshotsDiff = async (json1, json2, dialect3, schemasResolver, tablesR
23406
23489
  };
23407
23490
  };
23408
23491
 
23492
+ // src/cli/commands/pgUp.ts
23493
+ init_source();
23494
+
23495
+ // src/cli/commands/mysqlUp.ts
23496
+ init_source();
23497
+
23409
23498
  // src/cli/commands/upFolders.ts
23410
23499
  var resolveSchemas = (missingSchemas, newSchemas, predicate) => {
23411
23500
  try {