drizzle-kit 0.16.0 → 0.16.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/index.js +2078 -1287
- package/package.json +4 -4
- package/readme.md +43 -22
package/index.js
CHANGED
|
@@ -29,9 +29,9 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
|
|
|
29
29
|
));
|
|
30
30
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
31
31
|
|
|
32
|
-
// node_modules/.pnpm/commander@9.
|
|
32
|
+
// node_modules/.pnpm/commander@9.5.0/node_modules/commander/lib/error.js
|
|
33
33
|
var require_error = __commonJS({
|
|
34
|
-
"node_modules/.pnpm/commander@9.
|
|
34
|
+
"node_modules/.pnpm/commander@9.5.0/node_modules/commander/lib/error.js"(exports) {
|
|
35
35
|
var CommanderError2 = class extends Error {
|
|
36
36
|
constructor(exitCode, code, message) {
|
|
37
37
|
super(message);
|
|
@@ -54,9 +54,9 @@ var require_error = __commonJS({
|
|
|
54
54
|
}
|
|
55
55
|
});
|
|
56
56
|
|
|
57
|
-
// node_modules/.pnpm/commander@9.
|
|
57
|
+
// node_modules/.pnpm/commander@9.5.0/node_modules/commander/lib/argument.js
|
|
58
58
|
var require_argument = __commonJS({
|
|
59
|
-
"node_modules/.pnpm/commander@9.
|
|
59
|
+
"node_modules/.pnpm/commander@9.5.0/node_modules/commander/lib/argument.js"(exports) {
|
|
60
60
|
var { InvalidArgumentError: InvalidArgumentError2 } = require_error();
|
|
61
61
|
var Argument2 = class {
|
|
62
62
|
constructor(name, description) {
|
|
@@ -134,15 +134,16 @@ var require_argument = __commonJS({
|
|
|
134
134
|
}
|
|
135
135
|
});
|
|
136
136
|
|
|
137
|
-
// node_modules/.pnpm/commander@9.
|
|
137
|
+
// node_modules/.pnpm/commander@9.5.0/node_modules/commander/lib/help.js
|
|
138
138
|
var require_help = __commonJS({
|
|
139
|
-
"node_modules/.pnpm/commander@9.
|
|
139
|
+
"node_modules/.pnpm/commander@9.5.0/node_modules/commander/lib/help.js"(exports) {
|
|
140
140
|
var { humanReadableArgName } = require_argument();
|
|
141
141
|
var Help2 = class {
|
|
142
142
|
constructor() {
|
|
143
143
|
this.helpWidth = void 0;
|
|
144
144
|
this.sortSubcommands = false;
|
|
145
145
|
this.sortOptions = false;
|
|
146
|
+
this.showGlobalOptions = false;
|
|
146
147
|
}
|
|
147
148
|
visibleCommands(cmd) {
|
|
148
149
|
const visibleCommands = cmd.commands.filter((cmd2) => !cmd2._hidden);
|
|
@@ -161,6 +162,12 @@ var require_help = __commonJS({
|
|
|
161
162
|
}
|
|
162
163
|
return visibleCommands;
|
|
163
164
|
}
|
|
165
|
+
compareOptions(a, b) {
|
|
166
|
+
const getSortKey = (option) => {
|
|
167
|
+
return option.short ? option.short.replace(/^-/, "") : option.long.replace(/^--/, "");
|
|
168
|
+
};
|
|
169
|
+
return getSortKey(a).localeCompare(getSortKey(b));
|
|
170
|
+
}
|
|
164
171
|
visibleOptions(cmd) {
|
|
165
172
|
const visibleOptions = cmd.options.filter((option) => !option.hidden);
|
|
166
173
|
const showShortHelpFlag = cmd._hasHelpOption && cmd._helpShortFlag && !cmd._findOption(cmd._helpShortFlag);
|
|
@@ -177,15 +184,23 @@ var require_help = __commonJS({
|
|
|
177
184
|
visibleOptions.push(helpOption);
|
|
178
185
|
}
|
|
179
186
|
if (this.sortOptions) {
|
|
180
|
-
|
|
181
|
-
return option.short ? option.short.replace(/^-/, "") : option.long.replace(/^--/, "");
|
|
182
|
-
};
|
|
183
|
-
visibleOptions.sort((a, b) => {
|
|
184
|
-
return getSortKey(a).localeCompare(getSortKey(b));
|
|
185
|
-
});
|
|
187
|
+
visibleOptions.sort(this.compareOptions);
|
|
186
188
|
}
|
|
187
189
|
return visibleOptions;
|
|
188
190
|
}
|
|
191
|
+
visibleGlobalOptions(cmd) {
|
|
192
|
+
if (!this.showGlobalOptions)
|
|
193
|
+
return [];
|
|
194
|
+
const globalOptions = [];
|
|
195
|
+
for (let parentCmd = cmd.parent; parentCmd; parentCmd = parentCmd.parent) {
|
|
196
|
+
const visibleOptions = parentCmd.options.filter((option) => !option.hidden);
|
|
197
|
+
globalOptions.push(...visibleOptions);
|
|
198
|
+
}
|
|
199
|
+
if (this.sortOptions) {
|
|
200
|
+
globalOptions.sort(this.compareOptions);
|
|
201
|
+
}
|
|
202
|
+
return globalOptions;
|
|
203
|
+
}
|
|
189
204
|
visibleArguments(cmd) {
|
|
190
205
|
if (cmd._argsDescription) {
|
|
191
206
|
cmd._args.forEach((argument) => {
|
|
@@ -217,6 +232,11 @@ var require_help = __commonJS({
|
|
|
217
232
|
return Math.max(max, helper.optionTerm(option).length);
|
|
218
233
|
}, 0);
|
|
219
234
|
}
|
|
235
|
+
longestGlobalOptionTermLength(cmd, helper) {
|
|
236
|
+
return helper.visibleGlobalOptions(cmd).reduce((max, option) => {
|
|
237
|
+
return Math.max(max, helper.optionTerm(option).length);
|
|
238
|
+
}, 0);
|
|
239
|
+
}
|
|
220
240
|
longestArgumentTermLength(cmd, helper) {
|
|
221
241
|
return helper.visibleArguments(cmd).reduce((max, argument) => {
|
|
222
242
|
return Math.max(max, helper.argumentTerm(argument).length);
|
|
@@ -314,6 +334,14 @@ var require_help = __commonJS({
|
|
|
314
334
|
if (optionList.length > 0) {
|
|
315
335
|
output = output.concat(["Options:", formatList(optionList), ""]);
|
|
316
336
|
}
|
|
337
|
+
if (this.showGlobalOptions) {
|
|
338
|
+
const globalOptionList = helper.visibleGlobalOptions(cmd).map((option) => {
|
|
339
|
+
return formatItem(helper.optionTerm(option), helper.optionDescription(option));
|
|
340
|
+
});
|
|
341
|
+
if (globalOptionList.length > 0) {
|
|
342
|
+
output = output.concat(["Global Options:", formatList(globalOptionList), ""]);
|
|
343
|
+
}
|
|
344
|
+
}
|
|
317
345
|
const commandList = helper.visibleCommands(cmd).map((cmd2) => {
|
|
318
346
|
return formatItem(helper.subcommandTerm(cmd2), helper.subcommandDescription(cmd2));
|
|
319
347
|
});
|
|
@@ -325,6 +353,7 @@ var require_help = __commonJS({
|
|
|
325
353
|
padWidth(cmd, helper) {
|
|
326
354
|
return Math.max(
|
|
327
355
|
helper.longestOptionTermLength(cmd, helper),
|
|
356
|
+
helper.longestGlobalOptionTermLength(cmd, helper),
|
|
328
357
|
helper.longestSubcommandTermLength(cmd, helper),
|
|
329
358
|
helper.longestArgumentTermLength(cmd, helper)
|
|
330
359
|
);
|
|
@@ -352,9 +381,9 @@ var require_help = __commonJS({
|
|
|
352
381
|
}
|
|
353
382
|
});
|
|
354
383
|
|
|
355
|
-
// node_modules/.pnpm/commander@9.
|
|
384
|
+
// node_modules/.pnpm/commander@9.5.0/node_modules/commander/lib/option.js
|
|
356
385
|
var require_option = __commonJS({
|
|
357
|
-
"node_modules/.pnpm/commander@9.
|
|
386
|
+
"node_modules/.pnpm/commander@9.5.0/node_modules/commander/lib/option.js"(exports) {
|
|
358
387
|
var { InvalidArgumentError: InvalidArgumentError2 } = require_error();
|
|
359
388
|
var Option2 = class {
|
|
360
389
|
constructor(flags, description) {
|
|
@@ -500,9 +529,9 @@ var require_option = __commonJS({
|
|
|
500
529
|
}
|
|
501
530
|
});
|
|
502
531
|
|
|
503
|
-
// node_modules/.pnpm/commander@9.
|
|
532
|
+
// node_modules/.pnpm/commander@9.5.0/node_modules/commander/lib/suggestSimilar.js
|
|
504
533
|
var require_suggestSimilar = __commonJS({
|
|
505
|
-
"node_modules/.pnpm/commander@9.
|
|
534
|
+
"node_modules/.pnpm/commander@9.5.0/node_modules/commander/lib/suggestSimilar.js"(exports) {
|
|
506
535
|
var maxDistance = 3;
|
|
507
536
|
function editDistance(a, b) {
|
|
508
537
|
if (Math.abs(a.length - b.length) > maxDistance)
|
|
@@ -579,13 +608,13 @@ var require_suggestSimilar = __commonJS({
|
|
|
579
608
|
}
|
|
580
609
|
});
|
|
581
610
|
|
|
582
|
-
// node_modules/.pnpm/commander@9.
|
|
611
|
+
// node_modules/.pnpm/commander@9.5.0/node_modules/commander/lib/command.js
|
|
583
612
|
var require_command = __commonJS({
|
|
584
|
-
"node_modules/.pnpm/commander@9.
|
|
613
|
+
"node_modules/.pnpm/commander@9.5.0/node_modules/commander/lib/command.js"(exports) {
|
|
585
614
|
var EventEmitter = require("events").EventEmitter;
|
|
586
615
|
var childProcess = require("child_process");
|
|
587
|
-
var
|
|
588
|
-
var
|
|
616
|
+
var path5 = require("path");
|
|
617
|
+
var fs7 = require("fs");
|
|
589
618
|
var process3 = require("process");
|
|
590
619
|
var { Argument: Argument2, humanReadableArgName } = require_argument();
|
|
591
620
|
var { CommanderError: CommanderError2 } = require_error();
|
|
@@ -962,6 +991,15 @@ Expecting one of '${allowedValues.join("', '")}'`);
|
|
|
962
991
|
getOptionValueSource(key) {
|
|
963
992
|
return this._optionValueSources[key];
|
|
964
993
|
}
|
|
994
|
+
getOptionValueSourceWithGlobals(key) {
|
|
995
|
+
let source;
|
|
996
|
+
getCommandAndParents(this).forEach((cmd) => {
|
|
997
|
+
if (cmd.getOptionValueSource(key) !== void 0) {
|
|
998
|
+
source = cmd.getOptionValueSource(key);
|
|
999
|
+
}
|
|
1000
|
+
});
|
|
1001
|
+
return source;
|
|
1002
|
+
}
|
|
965
1003
|
_prepareUserArgs(argv, parseOptions) {
|
|
966
1004
|
if (argv !== void 0 && !Array.isArray(argv)) {
|
|
967
1005
|
throw new Error("first parameter to parse must be array or undefined");
|
|
@@ -1015,12 +1053,12 @@ Expecting one of '${allowedValues.join("', '")}'`);
|
|
|
1015
1053
|
let launchWithNode = false;
|
|
1016
1054
|
const sourceExt = [".js", ".ts", ".tsx", ".mjs", ".cjs"];
|
|
1017
1055
|
function findFile(baseDir, baseName) {
|
|
1018
|
-
const localBin =
|
|
1019
|
-
if (
|
|
1056
|
+
const localBin = path5.resolve(baseDir, baseName);
|
|
1057
|
+
if (fs7.existsSync(localBin))
|
|
1020
1058
|
return localBin;
|
|
1021
|
-
if (sourceExt.includes(
|
|
1059
|
+
if (sourceExt.includes(path5.extname(baseName)))
|
|
1022
1060
|
return void 0;
|
|
1023
|
-
const foundExt = sourceExt.find((ext) =>
|
|
1061
|
+
const foundExt = sourceExt.find((ext) => fs7.existsSync(`${localBin}${ext}`));
|
|
1024
1062
|
if (foundExt)
|
|
1025
1063
|
return `${localBin}${foundExt}`;
|
|
1026
1064
|
return void 0;
|
|
@@ -1032,23 +1070,23 @@ Expecting one of '${allowedValues.join("', '")}'`);
|
|
|
1032
1070
|
if (this._scriptPath) {
|
|
1033
1071
|
let resolvedScriptPath;
|
|
1034
1072
|
try {
|
|
1035
|
-
resolvedScriptPath =
|
|
1073
|
+
resolvedScriptPath = fs7.realpathSync(this._scriptPath);
|
|
1036
1074
|
} catch (err2) {
|
|
1037
1075
|
resolvedScriptPath = this._scriptPath;
|
|
1038
1076
|
}
|
|
1039
|
-
executableDir =
|
|
1077
|
+
executableDir = path5.resolve(path5.dirname(resolvedScriptPath), executableDir);
|
|
1040
1078
|
}
|
|
1041
1079
|
if (executableDir) {
|
|
1042
1080
|
let localFile = findFile(executableDir, executableFile);
|
|
1043
1081
|
if (!localFile && !subcommand._executableFile && this._scriptPath) {
|
|
1044
|
-
const legacyName =
|
|
1082
|
+
const legacyName = path5.basename(this._scriptPath, path5.extname(this._scriptPath));
|
|
1045
1083
|
if (legacyName !== this._name) {
|
|
1046
1084
|
localFile = findFile(executableDir, `${legacyName}-${subcommand._name}`);
|
|
1047
1085
|
}
|
|
1048
1086
|
}
|
|
1049
1087
|
executableFile = localFile || executableFile;
|
|
1050
1088
|
}
|
|
1051
|
-
launchWithNode = sourceExt.includes(
|
|
1089
|
+
launchWithNode = sourceExt.includes(path5.extname(executableFile));
|
|
1052
1090
|
let proc;
|
|
1053
1091
|
if (process3.platform !== "win32") {
|
|
1054
1092
|
if (launchWithNode) {
|
|
@@ -1620,13 +1658,13 @@ Expecting one of '${allowedValues.join("', '")}'`);
|
|
|
1620
1658
|
return this;
|
|
1621
1659
|
}
|
|
1622
1660
|
nameFromFilename(filename) {
|
|
1623
|
-
this._name =
|
|
1661
|
+
this._name = path5.basename(filename, path5.extname(filename));
|
|
1624
1662
|
return this;
|
|
1625
1663
|
}
|
|
1626
|
-
executableDir(
|
|
1627
|
-
if (
|
|
1664
|
+
executableDir(path6) {
|
|
1665
|
+
if (path6 === void 0)
|
|
1628
1666
|
return this._executableDir;
|
|
1629
|
-
this._executableDir =
|
|
1667
|
+
this._executableDir = path6;
|
|
1630
1668
|
return this;
|
|
1631
1669
|
}
|
|
1632
1670
|
helpInformation(contextOptions) {
|
|
@@ -1759,9 +1797,9 @@ Expecting one of '${allowedValues.join("', '")}'`);
|
|
|
1759
1797
|
}
|
|
1760
1798
|
});
|
|
1761
1799
|
|
|
1762
|
-
// node_modules/.pnpm/commander@9.
|
|
1800
|
+
// node_modules/.pnpm/commander@9.5.0/node_modules/commander/index.js
|
|
1763
1801
|
var require_commander = __commonJS({
|
|
1764
|
-
"node_modules/.pnpm/commander@9.
|
|
1802
|
+
"node_modules/.pnpm/commander@9.5.0/node_modules/commander/index.js"(exports, module2) {
|
|
1765
1803
|
var { Argument: Argument2 } = require_argument();
|
|
1766
1804
|
var { Command: Command2 } = require_command();
|
|
1767
1805
|
var { CommanderError: CommanderError2, InvalidArgumentError: InvalidArgumentError2 } = require_error();
|
|
@@ -2214,8 +2252,8 @@ var init_lib = __esm({
|
|
|
2214
2252
|
};
|
|
2215
2253
|
overrideErrorMap = errorMap;
|
|
2216
2254
|
makeIssue = (params) => {
|
|
2217
|
-
const { data, path:
|
|
2218
|
-
const fullPath = [...
|
|
2255
|
+
const { data, path: path5, errorMaps, issueData } = params;
|
|
2256
|
+
const fullPath = [...path5, ...issueData.path || []];
|
|
2219
2257
|
const fullIssue = {
|
|
2220
2258
|
...issueData,
|
|
2221
2259
|
path: fullPath
|
|
@@ -2297,10 +2335,10 @@ var init_lib = __esm({
|
|
|
2297
2335
|
errorUtil2.toString = (message) => typeof message === "string" ? message : message === null || message === void 0 ? void 0 : message.message;
|
|
2298
2336
|
})(errorUtil || (errorUtil = {}));
|
|
2299
2337
|
ParseInputLazyPath = class {
|
|
2300
|
-
constructor(parent, value,
|
|
2338
|
+
constructor(parent, value, path5, key) {
|
|
2301
2339
|
this.parent = parent;
|
|
2302
2340
|
this.data = value;
|
|
2303
|
-
this._path =
|
|
2341
|
+
this._path = path5;
|
|
2304
2342
|
this._key = key;
|
|
2305
2343
|
}
|
|
2306
2344
|
get path() {
|
|
@@ -4908,1040 +4946,1040 @@ var init_lib = __esm({
|
|
|
4908
4946
|
}
|
|
4909
4947
|
});
|
|
4910
4948
|
|
|
4911
|
-
// node_modules/.pnpm/
|
|
4912
|
-
|
|
4913
|
-
|
|
4914
|
-
|
|
4915
|
-
|
|
4916
|
-
|
|
4917
|
-
|
|
4918
|
-
|
|
4919
|
-
const stdout = process.stdout;
|
|
4920
|
-
const readline = require("readline");
|
|
4921
|
-
const rl = readline.createInterface({
|
|
4922
|
-
input: stdin,
|
|
4923
|
-
escapeCodeTimeout: 50
|
|
4924
|
-
});
|
|
4925
|
-
readline.emitKeypressEvents(stdin, rl);
|
|
4926
|
-
return {
|
|
4927
|
-
stdin,
|
|
4928
|
-
stdout,
|
|
4929
|
-
closable: rl
|
|
4949
|
+
// node_modules/.pnpm/chalk@5.2.0/node_modules/chalk/source/vendor/ansi-styles/index.js
|
|
4950
|
+
function assembleStyles() {
|
|
4951
|
+
const codes = /* @__PURE__ */ new Map();
|
|
4952
|
+
for (const [groupName, group] of Object.entries(styles)) {
|
|
4953
|
+
for (const [styleName, style] of Object.entries(group)) {
|
|
4954
|
+
styles[styleName] = {
|
|
4955
|
+
open: `\x1B[${style[0]}m`,
|
|
4956
|
+
close: `\x1B[${style[1]}m`
|
|
4930
4957
|
};
|
|
4931
|
-
|
|
4932
|
-
|
|
4933
|
-
|
|
4934
|
-
|
|
4935
|
-
|
|
4936
|
-
|
|
4937
|
-
|
|
4938
|
-
"node_modules/.pnpm/sisteransi@1.0.5/node_modules/sisteransi/src/index.js"(exports, module2) {
|
|
4939
|
-
"use strict";
|
|
4940
|
-
var ESC = "\x1B";
|
|
4941
|
-
var CSI = `${ESC}[`;
|
|
4942
|
-
var beep = "\x07";
|
|
4943
|
-
var cursor = {
|
|
4944
|
-
to(x, y) {
|
|
4945
|
-
if (!y)
|
|
4946
|
-
return `${CSI}${x + 1}G`;
|
|
4947
|
-
return `${CSI}${y + 1};${x + 1}H`;
|
|
4948
|
-
},
|
|
4949
|
-
move(x, y) {
|
|
4950
|
-
let ret = "";
|
|
4951
|
-
if (x < 0)
|
|
4952
|
-
ret += `${CSI}${-x}D`;
|
|
4953
|
-
else if (x > 0)
|
|
4954
|
-
ret += `${CSI}${x}C`;
|
|
4955
|
-
if (y < 0)
|
|
4956
|
-
ret += `${CSI}${-y}A`;
|
|
4957
|
-
else if (y > 0)
|
|
4958
|
-
ret += `${CSI}${y}B`;
|
|
4959
|
-
return ret;
|
|
4960
|
-
},
|
|
4961
|
-
up: (count = 1) => `${CSI}${count}A`,
|
|
4962
|
-
down: (count = 1) => `${CSI}${count}B`,
|
|
4963
|
-
forward: (count = 1) => `${CSI}${count}C`,
|
|
4964
|
-
backward: (count = 1) => `${CSI}${count}D`,
|
|
4965
|
-
nextLine: (count = 1) => `${CSI}E`.repeat(count),
|
|
4966
|
-
prevLine: (count = 1) => `${CSI}F`.repeat(count),
|
|
4967
|
-
left: `${CSI}G`,
|
|
4968
|
-
hide: `${CSI}?25l`,
|
|
4969
|
-
show: `${CSI}?25h`,
|
|
4970
|
-
save: `${ESC}7`,
|
|
4971
|
-
restore: `${ESC}8`
|
|
4972
|
-
};
|
|
4973
|
-
var scroll = {
|
|
4974
|
-
up: (count = 1) => `${CSI}S`.repeat(count),
|
|
4975
|
-
down: (count = 1) => `${CSI}T`.repeat(count)
|
|
4976
|
-
};
|
|
4977
|
-
var erase = {
|
|
4978
|
-
screen: `${CSI}2J`,
|
|
4979
|
-
up: (count = 1) => `${CSI}1J`.repeat(count),
|
|
4980
|
-
down: (count = 1) => `${CSI}J`.repeat(count),
|
|
4981
|
-
line: `${CSI}2K`,
|
|
4982
|
-
lineEnd: `${CSI}K`,
|
|
4983
|
-
lineStart: `${CSI}1K`,
|
|
4984
|
-
lines(count) {
|
|
4985
|
-
let clear = "";
|
|
4986
|
-
for (let i = 0; i < count; i++)
|
|
4987
|
-
clear += this.line + (i < count - 1 ? cursor.up() : "");
|
|
4988
|
-
if (count)
|
|
4989
|
-
clear += cursor.left;
|
|
4990
|
-
return clear;
|
|
4991
|
-
}
|
|
4992
|
-
};
|
|
4993
|
-
module2.exports = { cursor, scroll, erase, beep };
|
|
4994
|
-
}
|
|
4995
|
-
});
|
|
4996
|
-
|
|
4997
|
-
// node_modules/.pnpm/hanji@0.0.5/node_modules/hanji/utils.js
|
|
4998
|
-
var require_utils = __commonJS({
|
|
4999
|
-
"node_modules/.pnpm/hanji@0.0.5/node_modules/hanji/utils.js"(exports) {
|
|
5000
|
-
"use strict";
|
|
5001
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
5002
|
-
exports.clear = void 0;
|
|
5003
|
-
var sisteransi_1 = require_src();
|
|
5004
|
-
var strip = (str) => {
|
|
5005
|
-
const pattern = [
|
|
5006
|
-
"[\\u001B\\u009B][[\\]()#;?]*(?:(?:(?:(?:;[-a-zA-Z\\d\\/#&.:=?%@~_]+)*|[a-zA-Z\\d]+(?:;[-a-zA-Z\\d\\/#&.:=?%@~_]*)*)?\\u0007)",
|
|
5007
|
-
"(?:(?:\\d{1,4}(?:;\\d{0,4})*)?[\\dA-PRZcf-ntqry=><~]))"
|
|
5008
|
-
].join("|");
|
|
5009
|
-
const RGX = new RegExp(pattern, "g");
|
|
5010
|
-
return typeof str === "string" ? str.replace(RGX, "") : str;
|
|
5011
|
-
};
|
|
5012
|
-
var stringWidth = (str) => [...strip(str)].length;
|
|
5013
|
-
var clear = function(prompt, perLine) {
|
|
5014
|
-
if (!perLine)
|
|
5015
|
-
return sisteransi_1.erase.line + sisteransi_1.cursor.to(0);
|
|
5016
|
-
let rows = 0;
|
|
5017
|
-
const lines = prompt.split(/\r?\n/);
|
|
5018
|
-
for (let line of lines) {
|
|
5019
|
-
rows += 1 + Math.floor(Math.max(stringWidth(line) - 1, 0) / perLine);
|
|
5020
|
-
}
|
|
5021
|
-
return sisteransi_1.erase.lines(rows);
|
|
5022
|
-
};
|
|
5023
|
-
exports.clear = clear;
|
|
4958
|
+
group[styleName] = styles[styleName];
|
|
4959
|
+
codes.set(style[0], style[1]);
|
|
4960
|
+
}
|
|
4961
|
+
Object.defineProperty(styles, groupName, {
|
|
4962
|
+
value: group,
|
|
4963
|
+
enumerable: false
|
|
4964
|
+
});
|
|
5024
4965
|
}
|
|
5025
|
-
|
|
5026
|
-
|
|
5027
|
-
|
|
5028
|
-
|
|
5029
|
-
|
|
5030
|
-
|
|
5031
|
-
|
|
5032
|
-
|
|
5033
|
-
|
|
5034
|
-
|
|
5035
|
-
|
|
5036
|
-
|
|
5037
|
-
|
|
5038
|
-
|
|
5039
|
-
|
|
5040
|
-
|
|
5041
|
-
|
|
5042
|
-
|
|
5043
|
-
|
|
5044
|
-
|
|
5045
|
-
|
|
5046
|
-
|
|
5047
|
-
|
|
5048
|
-
function debounce(func, wait, options) {
|
|
5049
|
-
var lastArgs, lastThis, maxWait, result, timerId, lastCallTime, lastInvokeTime = 0, leading = false, maxing = false, trailing = true;
|
|
5050
|
-
if (typeof func != "function") {
|
|
5051
|
-
throw new TypeError(FUNC_ERROR_TEXT);
|
|
5052
|
-
}
|
|
5053
|
-
wait = toNumber(wait) || 0;
|
|
5054
|
-
if (isObject(options)) {
|
|
5055
|
-
leading = !!options.leading;
|
|
5056
|
-
maxing = "maxWait" in options;
|
|
5057
|
-
maxWait = maxing ? nativeMax(toNumber(options.maxWait) || 0, wait) : maxWait;
|
|
5058
|
-
trailing = "trailing" in options ? !!options.trailing : trailing;
|
|
5059
|
-
}
|
|
5060
|
-
function invokeFunc(time) {
|
|
5061
|
-
var args = lastArgs, thisArg = lastThis;
|
|
5062
|
-
lastArgs = lastThis = void 0;
|
|
5063
|
-
lastInvokeTime = time;
|
|
5064
|
-
result = func.apply(thisArg, args);
|
|
5065
|
-
return result;
|
|
5066
|
-
}
|
|
5067
|
-
function leadingEdge(time) {
|
|
5068
|
-
lastInvokeTime = time;
|
|
5069
|
-
timerId = setTimeout(timerExpired, wait);
|
|
5070
|
-
return leading ? invokeFunc(time) : result;
|
|
5071
|
-
}
|
|
5072
|
-
function remainingWait(time) {
|
|
5073
|
-
var timeSinceLastCall = time - lastCallTime, timeSinceLastInvoke = time - lastInvokeTime, result2 = wait - timeSinceLastCall;
|
|
5074
|
-
return maxing ? nativeMin(result2, maxWait - timeSinceLastInvoke) : result2;
|
|
5075
|
-
}
|
|
5076
|
-
function shouldInvoke(time) {
|
|
5077
|
-
var timeSinceLastCall = time - lastCallTime, timeSinceLastInvoke = time - lastInvokeTime;
|
|
5078
|
-
return lastCallTime === void 0 || timeSinceLastCall >= wait || timeSinceLastCall < 0 || maxing && timeSinceLastInvoke >= maxWait;
|
|
5079
|
-
}
|
|
5080
|
-
function timerExpired() {
|
|
5081
|
-
var time = now();
|
|
5082
|
-
if (shouldInvoke(time)) {
|
|
5083
|
-
return trailingEdge(time);
|
|
4966
|
+
Object.defineProperty(styles, "codes", {
|
|
4967
|
+
value: codes,
|
|
4968
|
+
enumerable: false
|
|
4969
|
+
});
|
|
4970
|
+
styles.color.close = "\x1B[39m";
|
|
4971
|
+
styles.bgColor.close = "\x1B[49m";
|
|
4972
|
+
styles.color.ansi = wrapAnsi16();
|
|
4973
|
+
styles.color.ansi256 = wrapAnsi256();
|
|
4974
|
+
styles.color.ansi16m = wrapAnsi16m();
|
|
4975
|
+
styles.bgColor.ansi = wrapAnsi16(ANSI_BACKGROUND_OFFSET);
|
|
4976
|
+
styles.bgColor.ansi256 = wrapAnsi256(ANSI_BACKGROUND_OFFSET);
|
|
4977
|
+
styles.bgColor.ansi16m = wrapAnsi16m(ANSI_BACKGROUND_OFFSET);
|
|
4978
|
+
Object.defineProperties(styles, {
|
|
4979
|
+
rgbToAnsi256: {
|
|
4980
|
+
value(red, green, blue) {
|
|
4981
|
+
if (red === green && green === blue) {
|
|
4982
|
+
if (red < 8) {
|
|
4983
|
+
return 16;
|
|
4984
|
+
}
|
|
4985
|
+
if (red > 248) {
|
|
4986
|
+
return 231;
|
|
4987
|
+
}
|
|
4988
|
+
return Math.round((red - 8) / 247 * 24) + 232;
|
|
5084
4989
|
}
|
|
5085
|
-
|
|
5086
|
-
}
|
|
5087
|
-
|
|
5088
|
-
|
|
5089
|
-
|
|
5090
|
-
|
|
4990
|
+
return 16 + 36 * Math.round(red / 255 * 5) + 6 * Math.round(green / 255 * 5) + Math.round(blue / 255 * 5);
|
|
4991
|
+
},
|
|
4992
|
+
enumerable: false
|
|
4993
|
+
},
|
|
4994
|
+
hexToRgb: {
|
|
4995
|
+
value(hex) {
|
|
4996
|
+
const matches = /[a-f\d]{6}|[a-f\d]{3}/i.exec(hex.toString(16));
|
|
4997
|
+
if (!matches) {
|
|
4998
|
+
return [0, 0, 0];
|
|
5091
4999
|
}
|
|
5092
|
-
|
|
5093
|
-
|
|
5094
|
-
|
|
5095
|
-
function cancel() {
|
|
5096
|
-
if (timerId !== void 0) {
|
|
5097
|
-
clearTimeout(timerId);
|
|
5000
|
+
let [colorString] = matches;
|
|
5001
|
+
if (colorString.length === 3) {
|
|
5002
|
+
colorString = [...colorString].map((character) => character + character).join("");
|
|
5098
5003
|
}
|
|
5099
|
-
|
|
5100
|
-
|
|
5101
|
-
|
|
5102
|
-
|
|
5103
|
-
|
|
5104
|
-
|
|
5105
|
-
|
|
5106
|
-
|
|
5107
|
-
|
|
5108
|
-
|
|
5109
|
-
|
|
5110
|
-
|
|
5111
|
-
|
|
5112
|
-
|
|
5113
|
-
|
|
5114
|
-
|
|
5115
|
-
|
|
5116
|
-
return invokeFunc(lastCallTime);
|
|
5117
|
-
}
|
|
5004
|
+
const integer = Number.parseInt(colorString, 16);
|
|
5005
|
+
return [
|
|
5006
|
+
integer >> 16 & 255,
|
|
5007
|
+
integer >> 8 & 255,
|
|
5008
|
+
integer & 255
|
|
5009
|
+
];
|
|
5010
|
+
},
|
|
5011
|
+
enumerable: false
|
|
5012
|
+
},
|
|
5013
|
+
hexToAnsi256: {
|
|
5014
|
+
value: (hex) => styles.rgbToAnsi256(...styles.hexToRgb(hex)),
|
|
5015
|
+
enumerable: false
|
|
5016
|
+
},
|
|
5017
|
+
ansi256ToAnsi: {
|
|
5018
|
+
value(code) {
|
|
5019
|
+
if (code < 8) {
|
|
5020
|
+
return 30 + code;
|
|
5118
5021
|
}
|
|
5119
|
-
if (
|
|
5120
|
-
|
|
5022
|
+
if (code < 16) {
|
|
5023
|
+
return 90 + (code - 8);
|
|
5024
|
+
}
|
|
5025
|
+
let red;
|
|
5026
|
+
let green;
|
|
5027
|
+
let blue;
|
|
5028
|
+
if (code >= 232) {
|
|
5029
|
+
red = ((code - 232) * 10 + 8) / 255;
|
|
5030
|
+
green = red;
|
|
5031
|
+
blue = red;
|
|
5032
|
+
} else {
|
|
5033
|
+
code -= 16;
|
|
5034
|
+
const remainder = code % 36;
|
|
5035
|
+
red = Math.floor(code / 36) / 5;
|
|
5036
|
+
green = Math.floor(remainder / 6) / 5;
|
|
5037
|
+
blue = remainder % 6 / 5;
|
|
5038
|
+
}
|
|
5039
|
+
const value = Math.max(red, green, blue) * 2;
|
|
5040
|
+
if (value === 0) {
|
|
5041
|
+
return 30;
|
|
5042
|
+
}
|
|
5043
|
+
let result = 30 + (Math.round(blue) << 2 | Math.round(green) << 1 | Math.round(red));
|
|
5044
|
+
if (value === 2) {
|
|
5045
|
+
result += 60;
|
|
5121
5046
|
}
|
|
5122
5047
|
return result;
|
|
5123
|
-
}
|
|
5124
|
-
|
|
5125
|
-
|
|
5126
|
-
|
|
5048
|
+
},
|
|
5049
|
+
enumerable: false
|
|
5050
|
+
},
|
|
5051
|
+
rgbToAnsi: {
|
|
5052
|
+
value: (red, green, blue) => styles.ansi256ToAnsi(styles.rgbToAnsi256(red, green, blue)),
|
|
5053
|
+
enumerable: false
|
|
5054
|
+
},
|
|
5055
|
+
hexToAnsi: {
|
|
5056
|
+
value: (hex) => styles.ansi256ToAnsi(styles.hexToAnsi256(hex)),
|
|
5057
|
+
enumerable: false
|
|
5127
5058
|
}
|
|
5128
|
-
|
|
5129
|
-
|
|
5130
|
-
|
|
5131
|
-
|
|
5132
|
-
|
|
5133
|
-
|
|
5134
|
-
|
|
5135
|
-
|
|
5059
|
+
});
|
|
5060
|
+
return styles;
|
|
5061
|
+
}
|
|
5062
|
+
var ANSI_BACKGROUND_OFFSET, wrapAnsi16, wrapAnsi256, wrapAnsi16m, styles, modifierNames, foregroundColorNames, backgroundColorNames, colorNames, ansiStyles, ansi_styles_default;
|
|
5063
|
+
var init_ansi_styles = __esm({
|
|
5064
|
+
"node_modules/.pnpm/chalk@5.2.0/node_modules/chalk/source/vendor/ansi-styles/index.js"() {
|
|
5065
|
+
ANSI_BACKGROUND_OFFSET = 10;
|
|
5066
|
+
wrapAnsi16 = (offset = 0) => (code) => `\x1B[${code + offset}m`;
|
|
5067
|
+
wrapAnsi256 = (offset = 0) => (code) => `\x1B[${38 + offset};5;${code}m`;
|
|
5068
|
+
wrapAnsi16m = (offset = 0) => (red, green, blue) => `\x1B[${38 + offset};2;${red};${green};${blue}m`;
|
|
5069
|
+
styles = {
|
|
5070
|
+
modifier: {
|
|
5071
|
+
reset: [0, 0],
|
|
5072
|
+
bold: [1, 22],
|
|
5073
|
+
dim: [2, 22],
|
|
5074
|
+
italic: [3, 23],
|
|
5075
|
+
underline: [4, 24],
|
|
5076
|
+
overline: [53, 55],
|
|
5077
|
+
inverse: [7, 27],
|
|
5078
|
+
hidden: [8, 28],
|
|
5079
|
+
strikethrough: [9, 29]
|
|
5080
|
+
},
|
|
5081
|
+
color: {
|
|
5082
|
+
black: [30, 39],
|
|
5083
|
+
red: [31, 39],
|
|
5084
|
+
green: [32, 39],
|
|
5085
|
+
yellow: [33, 39],
|
|
5086
|
+
blue: [34, 39],
|
|
5087
|
+
magenta: [35, 39],
|
|
5088
|
+
cyan: [36, 39],
|
|
5089
|
+
white: [37, 39],
|
|
5090
|
+
blackBright: [90, 39],
|
|
5091
|
+
gray: [90, 39],
|
|
5092
|
+
grey: [90, 39],
|
|
5093
|
+
redBright: [91, 39],
|
|
5094
|
+
greenBright: [92, 39],
|
|
5095
|
+
yellowBright: [93, 39],
|
|
5096
|
+
blueBright: [94, 39],
|
|
5097
|
+
magentaBright: [95, 39],
|
|
5098
|
+
cyanBright: [96, 39],
|
|
5099
|
+
whiteBright: [97, 39]
|
|
5100
|
+
},
|
|
5101
|
+
bgColor: {
|
|
5102
|
+
bgBlack: [40, 49],
|
|
5103
|
+
bgRed: [41, 49],
|
|
5104
|
+
bgGreen: [42, 49],
|
|
5105
|
+
bgYellow: [43, 49],
|
|
5106
|
+
bgBlue: [44, 49],
|
|
5107
|
+
bgMagenta: [45, 49],
|
|
5108
|
+
bgCyan: [46, 49],
|
|
5109
|
+
bgWhite: [47, 49],
|
|
5110
|
+
bgBlackBright: [100, 49],
|
|
5111
|
+
bgGray: [100, 49],
|
|
5112
|
+
bgGrey: [100, 49],
|
|
5113
|
+
bgRedBright: [101, 49],
|
|
5114
|
+
bgGreenBright: [102, 49],
|
|
5115
|
+
bgYellowBright: [103, 49],
|
|
5116
|
+
bgBlueBright: [104, 49],
|
|
5117
|
+
bgMagentaBright: [105, 49],
|
|
5118
|
+
bgCyanBright: [106, 49],
|
|
5119
|
+
bgWhiteBright: [107, 49]
|
|
5136
5120
|
}
|
|
5137
|
-
|
|
5138
|
-
|
|
5139
|
-
|
|
5140
|
-
|
|
5141
|
-
|
|
5121
|
+
};
|
|
5122
|
+
modifierNames = Object.keys(styles.modifier);
|
|
5123
|
+
foregroundColorNames = Object.keys(styles.color);
|
|
5124
|
+
backgroundColorNames = Object.keys(styles.bgColor);
|
|
5125
|
+
colorNames = [...foregroundColorNames, ...backgroundColorNames];
|
|
5126
|
+
ansiStyles = assembleStyles();
|
|
5127
|
+
ansi_styles_default = ansiStyles;
|
|
5128
|
+
}
|
|
5129
|
+
});
|
|
5130
|
+
|
|
5131
|
+
// node_modules/.pnpm/chalk@5.2.0/node_modules/chalk/source/vendor/supports-color/index.js
|
|
5132
|
+
function hasFlag(flag, argv = globalThis.Deno ? globalThis.Deno.args : import_node_process.default.argv) {
|
|
5133
|
+
const prefix = flag.startsWith("-") ? "" : flag.length === 1 ? "-" : "--";
|
|
5134
|
+
const position = argv.indexOf(prefix + flag);
|
|
5135
|
+
const terminatorPosition = argv.indexOf("--");
|
|
5136
|
+
return position !== -1 && (terminatorPosition === -1 || position < terminatorPosition);
|
|
5137
|
+
}
|
|
5138
|
+
function envForceColor() {
|
|
5139
|
+
if ("FORCE_COLOR" in env) {
|
|
5140
|
+
if (env.FORCE_COLOR === "true") {
|
|
5141
|
+
return 1;
|
|
5142
5142
|
}
|
|
5143
|
-
|
|
5144
|
-
|
|
5145
|
-
return !!value && (type == "object" || type == "function");
|
|
5143
|
+
if (env.FORCE_COLOR === "false") {
|
|
5144
|
+
return 0;
|
|
5146
5145
|
}
|
|
5147
|
-
|
|
5148
|
-
|
|
5146
|
+
return env.FORCE_COLOR.length === 0 ? 1 : Math.min(Number.parseInt(env.FORCE_COLOR, 10), 3);
|
|
5147
|
+
}
|
|
5148
|
+
}
|
|
5149
|
+
function translateLevel(level) {
|
|
5150
|
+
if (level === 0) {
|
|
5151
|
+
return false;
|
|
5152
|
+
}
|
|
5153
|
+
return {
|
|
5154
|
+
level,
|
|
5155
|
+
hasBasic: true,
|
|
5156
|
+
has256: level >= 2,
|
|
5157
|
+
has16m: level >= 3
|
|
5158
|
+
};
|
|
5159
|
+
}
|
|
5160
|
+
function _supportsColor(haveStream, { streamIsTTY, sniffFlags = true } = {}) {
|
|
5161
|
+
const noFlagForceColor = envForceColor();
|
|
5162
|
+
if (noFlagForceColor !== void 0) {
|
|
5163
|
+
flagForceColor = noFlagForceColor;
|
|
5164
|
+
}
|
|
5165
|
+
const forceColor = sniffFlags ? flagForceColor : noFlagForceColor;
|
|
5166
|
+
if (forceColor === 0) {
|
|
5167
|
+
return 0;
|
|
5168
|
+
}
|
|
5169
|
+
if (sniffFlags) {
|
|
5170
|
+
if (hasFlag("color=16m") || hasFlag("color=full") || hasFlag("color=truecolor")) {
|
|
5171
|
+
return 3;
|
|
5149
5172
|
}
|
|
5150
|
-
|
|
5151
|
-
return
|
|
5173
|
+
if (hasFlag("color=256")) {
|
|
5174
|
+
return 2;
|
|
5152
5175
|
}
|
|
5153
|
-
|
|
5154
|
-
|
|
5155
|
-
|
|
5156
|
-
|
|
5157
|
-
|
|
5158
|
-
|
|
5159
|
-
|
|
5160
|
-
|
|
5161
|
-
|
|
5162
|
-
|
|
5163
|
-
|
|
5164
|
-
|
|
5165
|
-
|
|
5166
|
-
|
|
5167
|
-
|
|
5168
|
-
var isBinary = reIsBinary.test(value);
|
|
5169
|
-
return isBinary || reIsOctal.test(value) ? freeParseInt(value.slice(2), isBinary ? 2 : 8) : reIsBadHex.test(value) ? NAN : +value;
|
|
5176
|
+
}
|
|
5177
|
+
if ("TF_BUILD" in env && "AGENT_NAME" in env) {
|
|
5178
|
+
return 1;
|
|
5179
|
+
}
|
|
5180
|
+
if (haveStream && !streamIsTTY && forceColor === void 0) {
|
|
5181
|
+
return 0;
|
|
5182
|
+
}
|
|
5183
|
+
const min = forceColor || 0;
|
|
5184
|
+
if (env.TERM === "dumb") {
|
|
5185
|
+
return min;
|
|
5186
|
+
}
|
|
5187
|
+
if (import_node_process.default.platform === "win32") {
|
|
5188
|
+
const osRelease = import_node_os.default.release().split(".");
|
|
5189
|
+
if (Number(osRelease[0]) >= 10 && Number(osRelease[2]) >= 10586) {
|
|
5190
|
+
return Number(osRelease[2]) >= 14931 ? 3 : 2;
|
|
5170
5191
|
}
|
|
5171
|
-
|
|
5192
|
+
return 1;
|
|
5172
5193
|
}
|
|
5173
|
-
|
|
5174
|
-
|
|
5175
|
-
|
|
5176
|
-
|
|
5177
|
-
|
|
5178
|
-
|
|
5179
|
-
|
|
5180
|
-
|
|
5181
|
-
|
|
5182
|
-
|
|
5183
|
-
|
|
5184
|
-
|
|
5185
|
-
|
|
5186
|
-
|
|
5187
|
-
|
|
5188
|
-
|
|
5189
|
-
|
|
5190
|
-
|
|
5191
|
-
|
|
5192
|
-
|
|
5193
|
-
|
|
5194
|
-
|
|
5195
|
-
|
|
5196
|
-
} catch (e) {
|
|
5197
|
-
reject(e);
|
|
5198
|
-
}
|
|
5199
|
-
}
|
|
5200
|
-
function step(result) {
|
|
5201
|
-
result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected);
|
|
5202
|
-
}
|
|
5203
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
5204
|
-
});
|
|
5205
|
-
};
|
|
5206
|
-
var __importDefault = exports && exports.__importDefault || function(mod) {
|
|
5207
|
-
return mod && mod.__esModule ? mod : { "default": mod };
|
|
5208
|
-
};
|
|
5209
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
5210
|
-
exports.onTerminate = exports.renderWithTask = exports.render = exports.TaskTerminal = exports.TaskView = exports.Terminal = exports.deferred = exports.SelectState = exports.Prompt = void 0;
|
|
5211
|
-
var readline_1 = require_readline();
|
|
5212
|
-
var sisteransi_1 = require_src();
|
|
5213
|
-
var utils_1 = require_utils();
|
|
5214
|
-
var lodash_throttle_1 = __importDefault(require_lodash());
|
|
5215
|
-
var Prompt2 = class {
|
|
5216
|
-
constructor() {
|
|
5217
|
-
this.attachCallbacks = [];
|
|
5218
|
-
this.detachCallbacks = [];
|
|
5219
|
-
this.inputCallbacks = [];
|
|
5220
|
-
}
|
|
5221
|
-
requestLayout() {
|
|
5222
|
-
this.terminal.requestLayout();
|
|
5223
|
-
}
|
|
5224
|
-
on(type, callback) {
|
|
5225
|
-
if (type === "attach") {
|
|
5226
|
-
this.attachCallbacks.push(callback);
|
|
5227
|
-
} else if (type === "detach") {
|
|
5228
|
-
this.detachCallbacks.push(callback);
|
|
5229
|
-
} else if (type === "input") {
|
|
5230
|
-
this.inputCallbacks.push(callback);
|
|
5231
|
-
}
|
|
5232
|
-
}
|
|
5233
|
-
attach(terminal) {
|
|
5234
|
-
this.terminal = terminal;
|
|
5235
|
-
this.attachCallbacks.forEach((it) => it(terminal));
|
|
5236
|
-
}
|
|
5237
|
-
detach(terminal) {
|
|
5238
|
-
this.detachCallbacks.forEach((it) => it(terminal));
|
|
5239
|
-
this.terminal = void 0;
|
|
5194
|
+
if ("CI" in env) {
|
|
5195
|
+
if ("GITHUB_ACTIONS" in env) {
|
|
5196
|
+
return 3;
|
|
5197
|
+
}
|
|
5198
|
+
if (["TRAVIS", "CIRCLECI", "APPVEYOR", "GITLAB_CI", "BUILDKITE", "DRONE"].some((sign) => sign in env) || env.CI_NAME === "codeship") {
|
|
5199
|
+
return 1;
|
|
5200
|
+
}
|
|
5201
|
+
return min;
|
|
5202
|
+
}
|
|
5203
|
+
if ("TEAMCITY_VERSION" in env) {
|
|
5204
|
+
return /^(9\.(0*[1-9]\d*)\.|\d{2,}\.)/.test(env.TEAMCITY_VERSION) ? 1 : 0;
|
|
5205
|
+
}
|
|
5206
|
+
if (env.COLORTERM === "truecolor") {
|
|
5207
|
+
return 3;
|
|
5208
|
+
}
|
|
5209
|
+
if (env.TERM === "xterm-kitty") {
|
|
5210
|
+
return 3;
|
|
5211
|
+
}
|
|
5212
|
+
if ("TERM_PROGRAM" in env) {
|
|
5213
|
+
const version = Number.parseInt((env.TERM_PROGRAM_VERSION || "").split(".")[0], 10);
|
|
5214
|
+
switch (env.TERM_PROGRAM) {
|
|
5215
|
+
case "iTerm.app": {
|
|
5216
|
+
return version >= 3 ? 3 : 2;
|
|
5240
5217
|
}
|
|
5241
|
-
|
|
5242
|
-
|
|
5218
|
+
case "Apple_Terminal": {
|
|
5219
|
+
return 2;
|
|
5243
5220
|
}
|
|
5221
|
+
}
|
|
5222
|
+
}
|
|
5223
|
+
if (/-256(color)?$/i.test(env.TERM)) {
|
|
5224
|
+
return 2;
|
|
5225
|
+
}
|
|
5226
|
+
if (/^screen|^xterm|^vt100|^vt220|^rxvt|color|ansi|cygwin|linux/i.test(env.TERM)) {
|
|
5227
|
+
return 1;
|
|
5228
|
+
}
|
|
5229
|
+
if ("COLORTERM" in env) {
|
|
5230
|
+
return 1;
|
|
5231
|
+
}
|
|
5232
|
+
return min;
|
|
5233
|
+
}
|
|
5234
|
+
function createSupportsColor(stream, options = {}) {
|
|
5235
|
+
const level = _supportsColor(stream, {
|
|
5236
|
+
streamIsTTY: stream && stream.isTTY,
|
|
5237
|
+
...options
|
|
5238
|
+
});
|
|
5239
|
+
return translateLevel(level);
|
|
5240
|
+
}
|
|
5241
|
+
var import_node_process, import_node_os, import_node_tty, env, flagForceColor, supportsColor, supports_color_default;
|
|
5242
|
+
var init_supports_color = __esm({
|
|
5243
|
+
"node_modules/.pnpm/chalk@5.2.0/node_modules/chalk/source/vendor/supports-color/index.js"() {
|
|
5244
|
+
import_node_process = __toESM(require("process"), 1);
|
|
5245
|
+
import_node_os = __toESM(require("os"), 1);
|
|
5246
|
+
import_node_tty = __toESM(require("tty"), 1);
|
|
5247
|
+
({ env } = import_node_process.default);
|
|
5248
|
+
if (hasFlag("no-color") || hasFlag("no-colors") || hasFlag("color=false") || hasFlag("color=never")) {
|
|
5249
|
+
flagForceColor = 0;
|
|
5250
|
+
} else if (hasFlag("color") || hasFlag("colors") || hasFlag("color=true") || hasFlag("color=always")) {
|
|
5251
|
+
flagForceColor = 1;
|
|
5252
|
+
}
|
|
5253
|
+
supportsColor = {
|
|
5254
|
+
stdout: createSupportsColor({ isTTY: import_node_tty.default.isatty(1) }),
|
|
5255
|
+
stderr: createSupportsColor({ isTTY: import_node_tty.default.isatty(2) })
|
|
5244
5256
|
};
|
|
5245
|
-
|
|
5246
|
-
|
|
5247
|
-
|
|
5248
|
-
|
|
5249
|
-
|
|
5257
|
+
supports_color_default = supportsColor;
|
|
5258
|
+
}
|
|
5259
|
+
});
|
|
5260
|
+
|
|
5261
|
+
// node_modules/.pnpm/chalk@5.2.0/node_modules/chalk/source/utilities.js
|
|
5262
|
+
function stringReplaceAll(string, substring, replacer) {
|
|
5263
|
+
let index4 = string.indexOf(substring);
|
|
5264
|
+
if (index4 === -1) {
|
|
5265
|
+
return string;
|
|
5266
|
+
}
|
|
5267
|
+
const substringLength = substring.length;
|
|
5268
|
+
let endIndex = 0;
|
|
5269
|
+
let returnValue = "";
|
|
5270
|
+
do {
|
|
5271
|
+
returnValue += string.slice(endIndex, index4) + substring + replacer;
|
|
5272
|
+
endIndex = index4 + substringLength;
|
|
5273
|
+
index4 = string.indexOf(substring, endIndex);
|
|
5274
|
+
} while (index4 !== -1);
|
|
5275
|
+
returnValue += string.slice(endIndex);
|
|
5276
|
+
return returnValue;
|
|
5277
|
+
}
|
|
5278
|
+
function stringEncaseCRLFWithFirstIndex(string, prefix, postfix, index4) {
|
|
5279
|
+
let endIndex = 0;
|
|
5280
|
+
let returnValue = "";
|
|
5281
|
+
do {
|
|
5282
|
+
const gotCR = string[index4 - 1] === "\r";
|
|
5283
|
+
returnValue += string.slice(endIndex, gotCR ? index4 - 1 : index4) + prefix + (gotCR ? "\r\n" : "\n") + postfix;
|
|
5284
|
+
endIndex = index4 + 1;
|
|
5285
|
+
index4 = string.indexOf("\n", endIndex);
|
|
5286
|
+
} while (index4 !== -1);
|
|
5287
|
+
returnValue += string.slice(endIndex);
|
|
5288
|
+
return returnValue;
|
|
5289
|
+
}
|
|
5290
|
+
var init_utilities = __esm({
|
|
5291
|
+
"node_modules/.pnpm/chalk@5.2.0/node_modules/chalk/source/utilities.js"() {
|
|
5292
|
+
}
|
|
5293
|
+
});
|
|
5294
|
+
|
|
5295
|
+
// node_modules/.pnpm/chalk@5.2.0/node_modules/chalk/source/index.js
|
|
5296
|
+
function createChalk(options) {
|
|
5297
|
+
return chalkFactory(options);
|
|
5298
|
+
}
|
|
5299
|
+
var stdoutColor, stderrColor, GENERATOR, STYLER, IS_EMPTY, levelMapping, styles2, applyOptions, chalkFactory, getModelAnsi, usedModels, proto, createStyler, createBuilder, applyStyle, chalk, chalkStderr, source_default;
|
|
5300
|
+
var init_source = __esm({
|
|
5301
|
+
"node_modules/.pnpm/chalk@5.2.0/node_modules/chalk/source/index.js"() {
|
|
5302
|
+
init_ansi_styles();
|
|
5303
|
+
init_supports_color();
|
|
5304
|
+
init_utilities();
|
|
5305
|
+
init_ansi_styles();
|
|
5306
|
+
({ stdout: stdoutColor, stderr: stderrColor } = supports_color_default);
|
|
5307
|
+
GENERATOR = Symbol("GENERATOR");
|
|
5308
|
+
STYLER = Symbol("STYLER");
|
|
5309
|
+
IS_EMPTY = Symbol("IS_EMPTY");
|
|
5310
|
+
levelMapping = [
|
|
5311
|
+
"ansi",
|
|
5312
|
+
"ansi",
|
|
5313
|
+
"ansi256",
|
|
5314
|
+
"ansi16m"
|
|
5315
|
+
];
|
|
5316
|
+
styles2 = /* @__PURE__ */ Object.create(null);
|
|
5317
|
+
applyOptions = (object, options = {}) => {
|
|
5318
|
+
if (options.level && !(Number.isInteger(options.level) && options.level >= 0 && options.level <= 3)) {
|
|
5319
|
+
throw new Error("The `level` option should be an integer from 0 to 3");
|
|
5250
5320
|
}
|
|
5251
|
-
|
|
5252
|
-
|
|
5253
|
-
|
|
5254
|
-
|
|
5255
|
-
|
|
5256
|
-
|
|
5321
|
+
const colorLevel = stdoutColor ? stdoutColor.level : 0;
|
|
5322
|
+
object.level = options.level === void 0 ? colorLevel : options.level;
|
|
5323
|
+
};
|
|
5324
|
+
chalkFactory = (options) => {
|
|
5325
|
+
const chalk2 = (...strings) => strings.join(" ");
|
|
5326
|
+
applyOptions(chalk2, options);
|
|
5327
|
+
Object.setPrototypeOf(chalk2, createChalk.prototype);
|
|
5328
|
+
return chalk2;
|
|
5329
|
+
};
|
|
5330
|
+
Object.setPrototypeOf(createChalk.prototype, Function.prototype);
|
|
5331
|
+
for (const [styleName, style] of Object.entries(ansi_styles_default)) {
|
|
5332
|
+
styles2[styleName] = {
|
|
5333
|
+
get() {
|
|
5334
|
+
const builder = createBuilder(this, createStyler(style.open, style.close, this[STYLER]), this[IS_EMPTY]);
|
|
5335
|
+
Object.defineProperty(this, styleName, { value: builder });
|
|
5336
|
+
return builder;
|
|
5337
|
+
}
|
|
5338
|
+
};
|
|
5339
|
+
}
|
|
5340
|
+
styles2.visible = {
|
|
5341
|
+
get() {
|
|
5342
|
+
const builder = createBuilder(this, this[STYLER], true);
|
|
5343
|
+
Object.defineProperty(this, "visible", { value: builder });
|
|
5344
|
+
return builder;
|
|
5257
5345
|
}
|
|
5258
|
-
|
|
5259
|
-
|
|
5260
|
-
|
|
5261
|
-
if (
|
|
5262
|
-
|
|
5263
|
-
return true;
|
|
5346
|
+
};
|
|
5347
|
+
getModelAnsi = (model, level, type, ...arguments_) => {
|
|
5348
|
+
if (model === "rgb") {
|
|
5349
|
+
if (level === "ansi16m") {
|
|
5350
|
+
return ansi_styles_default[type].ansi16m(...arguments_);
|
|
5264
5351
|
}
|
|
5265
|
-
if (
|
|
5266
|
-
|
|
5267
|
-
this.selectedIdx = this.selectedIdx < 0 ? this.items.length - 1 : this.selectedIdx;
|
|
5268
|
-
return true;
|
|
5352
|
+
if (level === "ansi256") {
|
|
5353
|
+
return ansi_styles_default[type].ansi256(ansi_styles_default.rgbToAnsi256(...arguments_));
|
|
5269
5354
|
}
|
|
5270
|
-
return
|
|
5355
|
+
return ansi_styles_default[type].ansi(ansi_styles_default.rgbToAnsi(...arguments_));
|
|
5271
5356
|
}
|
|
5357
|
+
if (model === "hex") {
|
|
5358
|
+
return getModelAnsi("rgb", level, type, ...ansi_styles_default.hexToRgb(...arguments_));
|
|
5359
|
+
}
|
|
5360
|
+
return ansi_styles_default[type][model](...arguments_);
|
|
5272
5361
|
};
|
|
5273
|
-
|
|
5274
|
-
|
|
5275
|
-
|
|
5276
|
-
|
|
5277
|
-
|
|
5278
|
-
|
|
5279
|
-
|
|
5280
|
-
|
|
5281
|
-
|
|
5282
|
-
|
|
5283
|
-
reject,
|
|
5284
|
-
promise
|
|
5362
|
+
usedModels = ["rgb", "hex", "ansi256"];
|
|
5363
|
+
for (const model of usedModels) {
|
|
5364
|
+
styles2[model] = {
|
|
5365
|
+
get() {
|
|
5366
|
+
const { level } = this;
|
|
5367
|
+
return function(...arguments_) {
|
|
5368
|
+
const styler = createStyler(getModelAnsi(model, levelMapping[level], "color", ...arguments_), ansi_styles_default.color.close, this[STYLER]);
|
|
5369
|
+
return createBuilder(this, styler, this[IS_EMPTY]);
|
|
5370
|
+
};
|
|
5371
|
+
}
|
|
5285
5372
|
};
|
|
5286
|
-
|
|
5287
|
-
|
|
5288
|
-
|
|
5289
|
-
|
|
5290
|
-
|
|
5291
|
-
|
|
5292
|
-
|
|
5293
|
-
|
|
5294
|
-
|
|
5295
|
-
|
|
5296
|
-
|
|
5297
|
-
|
|
5298
|
-
|
|
5299
|
-
|
|
5300
|
-
|
|
5301
|
-
|
|
5302
|
-
|
|
5303
|
-
|
|
5304
|
-
|
|
5305
|
-
|
|
5306
|
-
|
|
5307
|
-
this.stdout.write(`
|
|
5308
|
-
^C
|
|
5309
|
-
`);
|
|
5310
|
-
process.exit(1);
|
|
5311
|
-
}
|
|
5312
|
-
if (key.name === "escape") {
|
|
5313
|
-
this.status = "aborted";
|
|
5314
|
-
this.requestLayout();
|
|
5315
|
-
this.view.detach(this);
|
|
5316
|
-
this.tearDown(keypress);
|
|
5317
|
-
this.resolve({ status: "aborted", data: void 0 });
|
|
5318
|
-
return;
|
|
5319
|
-
}
|
|
5320
|
-
if (key.name === "return") {
|
|
5321
|
-
this.status = "submitted";
|
|
5322
|
-
this.requestLayout();
|
|
5323
|
-
this.view.detach(this);
|
|
5324
|
-
this.tearDown(keypress);
|
|
5325
|
-
this.resolve({ status: "submitted", data: this.view.result() });
|
|
5326
|
-
return;
|
|
5327
|
-
}
|
|
5328
|
-
view.input(str, key);
|
|
5329
|
-
};
|
|
5330
|
-
this.stdin.on("keypress", keypress);
|
|
5331
|
-
this.view.attach(this);
|
|
5332
|
-
const { resolve, promise } = (0, exports.deferred)();
|
|
5333
|
-
this.resolve = resolve;
|
|
5334
|
-
this.promise = promise;
|
|
5335
|
-
this.renderFunc = (0, lodash_throttle_1.default)((str) => {
|
|
5336
|
-
this.stdout.write(str);
|
|
5337
|
-
});
|
|
5338
|
-
}
|
|
5339
|
-
tearDown(keypress) {
|
|
5340
|
-
this.stdout.write(sisteransi_1.cursor.show);
|
|
5341
|
-
this.stdin.removeListener("keypress", keypress);
|
|
5342
|
-
if (this.stdin.isTTY)
|
|
5343
|
-
this.stdin.setRawMode(false);
|
|
5344
|
-
this.closable.close();
|
|
5345
|
-
}
|
|
5346
|
-
result() {
|
|
5347
|
-
return this.promise;
|
|
5348
|
-
}
|
|
5349
|
-
toggleCursor(state) {
|
|
5350
|
-
if (state === "hide") {
|
|
5351
|
-
this.stdout.write(sisteransi_1.cursor.hide);
|
|
5352
|
-
} else {
|
|
5353
|
-
this.stdout.write(sisteransi_1.cursor.show);
|
|
5373
|
+
const bgModel = "bg" + model[0].toUpperCase() + model.slice(1);
|
|
5374
|
+
styles2[bgModel] = {
|
|
5375
|
+
get() {
|
|
5376
|
+
const { level } = this;
|
|
5377
|
+
return function(...arguments_) {
|
|
5378
|
+
const styler = createStyler(getModelAnsi(model, levelMapping[level], "bgColor", ...arguments_), ansi_styles_default.bgColor.close, this[STYLER]);
|
|
5379
|
+
return createBuilder(this, styler, this[IS_EMPTY]);
|
|
5380
|
+
};
|
|
5381
|
+
}
|
|
5382
|
+
};
|
|
5383
|
+
}
|
|
5384
|
+
proto = Object.defineProperties(() => {
|
|
5385
|
+
}, {
|
|
5386
|
+
...styles2,
|
|
5387
|
+
level: {
|
|
5388
|
+
enumerable: true,
|
|
5389
|
+
get() {
|
|
5390
|
+
return this[GENERATOR].level;
|
|
5391
|
+
},
|
|
5392
|
+
set(level) {
|
|
5393
|
+
this[GENERATOR].level = level;
|
|
5354
5394
|
}
|
|
5355
5395
|
}
|
|
5356
|
-
|
|
5357
|
-
|
|
5358
|
-
|
|
5359
|
-
|
|
5360
|
-
|
|
5396
|
+
});
|
|
5397
|
+
createStyler = (open, close, parent) => {
|
|
5398
|
+
let openAll;
|
|
5399
|
+
let closeAll;
|
|
5400
|
+
if (parent === void 0) {
|
|
5401
|
+
openAll = open;
|
|
5402
|
+
closeAll = close;
|
|
5403
|
+
} else {
|
|
5404
|
+
openAll = parent.openAll + open;
|
|
5405
|
+
closeAll = close + parent.closeAll;
|
|
5361
5406
|
}
|
|
5407
|
+
return {
|
|
5408
|
+
open,
|
|
5409
|
+
close,
|
|
5410
|
+
openAll,
|
|
5411
|
+
closeAll,
|
|
5412
|
+
parent
|
|
5413
|
+
};
|
|
5362
5414
|
};
|
|
5363
|
-
|
|
5364
|
-
|
|
5365
|
-
|
|
5366
|
-
|
|
5367
|
-
|
|
5368
|
-
|
|
5369
|
-
|
|
5370
|
-
|
|
5371
|
-
|
|
5372
|
-
|
|
5373
|
-
|
|
5374
|
-
this.attachCallbacks.forEach((it) => it(terminal));
|
|
5415
|
+
createBuilder = (self2, _styler, _isEmpty) => {
|
|
5416
|
+
const builder = (...arguments_) => applyStyle(builder, arguments_.length === 1 ? "" + arguments_[0] : arguments_.join(" "));
|
|
5417
|
+
Object.setPrototypeOf(builder, proto);
|
|
5418
|
+
builder[GENERATOR] = self2;
|
|
5419
|
+
builder[STYLER] = _styler;
|
|
5420
|
+
builder[IS_EMPTY] = _isEmpty;
|
|
5421
|
+
return builder;
|
|
5422
|
+
};
|
|
5423
|
+
applyStyle = (self2, string) => {
|
|
5424
|
+
if (self2.level <= 0 || !string) {
|
|
5425
|
+
return self2[IS_EMPTY] ? "" : string;
|
|
5375
5426
|
}
|
|
5376
|
-
|
|
5377
|
-
|
|
5378
|
-
|
|
5427
|
+
let styler = self2[STYLER];
|
|
5428
|
+
if (styler === void 0) {
|
|
5429
|
+
return string;
|
|
5379
5430
|
}
|
|
5380
|
-
|
|
5381
|
-
|
|
5382
|
-
|
|
5383
|
-
|
|
5384
|
-
|
|
5431
|
+
const { openAll, closeAll } = styler;
|
|
5432
|
+
if (string.includes("\x1B")) {
|
|
5433
|
+
while (styler !== void 0) {
|
|
5434
|
+
string = stringReplaceAll(string, styler.close, styler.open);
|
|
5435
|
+
styler = styler.parent;
|
|
5385
5436
|
}
|
|
5386
5437
|
}
|
|
5387
|
-
|
|
5388
|
-
|
|
5389
|
-
|
|
5390
|
-
constructor(view, stdout) {
|
|
5391
|
-
this.view = view;
|
|
5392
|
-
this.stdout = stdout;
|
|
5393
|
-
this.text = "";
|
|
5394
|
-
this.view.attach(this);
|
|
5395
|
-
}
|
|
5396
|
-
requestLayout() {
|
|
5397
|
-
const string = this.view.render("pending");
|
|
5398
|
-
const clearPrefix = this.text ? (0, utils_1.clear)(this.text, this.stdout.columns) : "";
|
|
5399
|
-
this.text = string;
|
|
5400
|
-
this.stdout.write(`${clearPrefix}${string}`);
|
|
5401
|
-
}
|
|
5402
|
-
clear() {
|
|
5403
|
-
const string = this.view.render("done");
|
|
5404
|
-
this.view.detach(this);
|
|
5405
|
-
const clearPrefix = this.text ? (0, utils_1.clear)(this.text, this.stdout.columns) : "";
|
|
5406
|
-
this.stdout.write(`${clearPrefix}${string}`);
|
|
5438
|
+
const lfIndex = string.indexOf("\n");
|
|
5439
|
+
if (lfIndex !== -1) {
|
|
5440
|
+
string = stringEncaseCRLFWithFirstIndex(string, closeAll, openAll, lfIndex);
|
|
5407
5441
|
}
|
|
5442
|
+
return openAll + string + closeAll;
|
|
5408
5443
|
};
|
|
5409
|
-
|
|
5410
|
-
|
|
5411
|
-
|
|
5412
|
-
|
|
5413
|
-
const terminal = new Terminal(view, stdin, stdout, closable);
|
|
5414
|
-
terminal.requestLayout();
|
|
5415
|
-
return terminal.result();
|
|
5416
|
-
}
|
|
5417
|
-
stdout.write(`${view}
|
|
5418
|
-
`);
|
|
5419
|
-
closable.close();
|
|
5420
|
-
return;
|
|
5421
|
-
}
|
|
5422
|
-
exports.render = render5;
|
|
5423
|
-
function renderWithTask2(view, task) {
|
|
5424
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
5425
|
-
const terminal = new TaskTerminal(view, process.stdout);
|
|
5426
|
-
terminal.requestLayout();
|
|
5427
|
-
const result = yield task;
|
|
5428
|
-
terminal.clear();
|
|
5429
|
-
return result;
|
|
5430
|
-
});
|
|
5431
|
-
}
|
|
5432
|
-
exports.renderWithTask = renderWithTask2;
|
|
5433
|
-
var terminateHandler;
|
|
5434
|
-
function onTerminate(callback) {
|
|
5435
|
-
terminateHandler = callback;
|
|
5436
|
-
}
|
|
5437
|
-
exports.onTerminate = onTerminate;
|
|
5444
|
+
Object.defineProperties(createChalk.prototype, styles2);
|
|
5445
|
+
chalk = createChalk();
|
|
5446
|
+
chalkStderr = createChalk({ level: stderrColor ? stderrColor.level : 0 });
|
|
5447
|
+
source_default = chalk;
|
|
5438
5448
|
}
|
|
5439
5449
|
});
|
|
5440
5450
|
|
|
5441
|
-
// node_modules/.pnpm/
|
|
5442
|
-
|
|
5443
|
-
|
|
5444
|
-
|
|
5445
|
-
|
|
5446
|
-
|
|
5447
|
-
|
|
5448
|
-
|
|
5451
|
+
// node_modules/.pnpm/hanji@0.0.5/node_modules/hanji/readline.js
|
|
5452
|
+
var require_readline = __commonJS({
|
|
5453
|
+
"node_modules/.pnpm/hanji@0.0.5/node_modules/hanji/readline.js"(exports) {
|
|
5454
|
+
"use strict";
|
|
5455
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
5456
|
+
exports.prepareReadLine = void 0;
|
|
5457
|
+
var prepareReadLine = () => {
|
|
5458
|
+
const stdin = process.stdin;
|
|
5459
|
+
const stdout = process.stdout;
|
|
5460
|
+
const readline = require("readline");
|
|
5461
|
+
const rl = readline.createInterface({
|
|
5462
|
+
input: stdin,
|
|
5463
|
+
escapeCodeTimeout: 50
|
|
5464
|
+
});
|
|
5465
|
+
readline.emitKeypressEvents(stdin, rl);
|
|
5466
|
+
return {
|
|
5467
|
+
stdin,
|
|
5468
|
+
stdout,
|
|
5469
|
+
closable: rl
|
|
5449
5470
|
};
|
|
5450
|
-
|
|
5451
|
-
|
|
5452
|
-
}
|
|
5453
|
-
Object.defineProperty(styles, groupName, {
|
|
5454
|
-
value: group,
|
|
5455
|
-
enumerable: false
|
|
5456
|
-
});
|
|
5471
|
+
};
|
|
5472
|
+
exports.prepareReadLine = prepareReadLine;
|
|
5457
5473
|
}
|
|
5458
|
-
|
|
5459
|
-
|
|
5460
|
-
|
|
5461
|
-
|
|
5462
|
-
|
|
5463
|
-
|
|
5464
|
-
|
|
5465
|
-
|
|
5466
|
-
|
|
5467
|
-
|
|
5468
|
-
|
|
5469
|
-
|
|
5470
|
-
|
|
5471
|
-
|
|
5472
|
-
value(red, green, blue) {
|
|
5473
|
-
if (red === green && green === blue) {
|
|
5474
|
-
if (red < 8) {
|
|
5475
|
-
return 16;
|
|
5476
|
-
}
|
|
5477
|
-
if (red > 248) {
|
|
5478
|
-
return 231;
|
|
5479
|
-
}
|
|
5480
|
-
return Math.round((red - 8) / 247 * 24) + 232;
|
|
5481
|
-
}
|
|
5482
|
-
return 16 + 36 * Math.round(red / 255 * 5) + 6 * Math.round(green / 255 * 5) + Math.round(blue / 255 * 5);
|
|
5483
|
-
},
|
|
5484
|
-
enumerable: false
|
|
5485
|
-
},
|
|
5486
|
-
hexToRgb: {
|
|
5487
|
-
value(hex) {
|
|
5488
|
-
const matches = /[a-f\d]{6}|[a-f\d]{3}/i.exec(hex.toString(16));
|
|
5489
|
-
if (!matches) {
|
|
5490
|
-
return [0, 0, 0];
|
|
5491
|
-
}
|
|
5492
|
-
let [colorString] = matches;
|
|
5493
|
-
if (colorString.length === 3) {
|
|
5494
|
-
colorString = [...colorString].map((character) => character + character).join("");
|
|
5495
|
-
}
|
|
5496
|
-
const integer = Number.parseInt(colorString, 16);
|
|
5497
|
-
return [
|
|
5498
|
-
integer >> 16 & 255,
|
|
5499
|
-
integer >> 8 & 255,
|
|
5500
|
-
integer & 255
|
|
5501
|
-
];
|
|
5502
|
-
},
|
|
5503
|
-
enumerable: false
|
|
5504
|
-
},
|
|
5505
|
-
hexToAnsi256: {
|
|
5506
|
-
value: (hex) => styles.rgbToAnsi256(...styles.hexToRgb(hex)),
|
|
5507
|
-
enumerable: false
|
|
5508
|
-
},
|
|
5509
|
-
ansi256ToAnsi: {
|
|
5510
|
-
value(code) {
|
|
5511
|
-
if (code < 8) {
|
|
5512
|
-
return 30 + code;
|
|
5513
|
-
}
|
|
5514
|
-
if (code < 16) {
|
|
5515
|
-
return 90 + (code - 8);
|
|
5516
|
-
}
|
|
5517
|
-
let red;
|
|
5518
|
-
let green;
|
|
5519
|
-
let blue;
|
|
5520
|
-
if (code >= 232) {
|
|
5521
|
-
red = ((code - 232) * 10 + 8) / 255;
|
|
5522
|
-
green = red;
|
|
5523
|
-
blue = red;
|
|
5524
|
-
} else {
|
|
5525
|
-
code -= 16;
|
|
5526
|
-
const remainder = code % 36;
|
|
5527
|
-
red = Math.floor(code / 36) / 5;
|
|
5528
|
-
green = Math.floor(remainder / 6) / 5;
|
|
5529
|
-
blue = remainder % 6 / 5;
|
|
5530
|
-
}
|
|
5531
|
-
const value = Math.max(red, green, blue) * 2;
|
|
5532
|
-
if (value === 0) {
|
|
5533
|
-
return 30;
|
|
5534
|
-
}
|
|
5535
|
-
let result = 30 + (Math.round(blue) << 2 | Math.round(green) << 1 | Math.round(red));
|
|
5536
|
-
if (value === 2) {
|
|
5537
|
-
result += 60;
|
|
5538
|
-
}
|
|
5539
|
-
return result;
|
|
5540
|
-
},
|
|
5541
|
-
enumerable: false
|
|
5542
|
-
},
|
|
5543
|
-
rgbToAnsi: {
|
|
5544
|
-
value: (red, green, blue) => styles.ansi256ToAnsi(styles.rgbToAnsi256(red, green, blue)),
|
|
5545
|
-
enumerable: false
|
|
5546
|
-
},
|
|
5547
|
-
hexToAnsi: {
|
|
5548
|
-
value: (hex) => styles.ansi256ToAnsi(styles.hexToAnsi256(hex)),
|
|
5549
|
-
enumerable: false
|
|
5550
|
-
}
|
|
5551
|
-
});
|
|
5552
|
-
return styles;
|
|
5553
|
-
}
|
|
5554
|
-
var ANSI_BACKGROUND_OFFSET, wrapAnsi16, wrapAnsi256, wrapAnsi16m, styles, modifierNames, foregroundColorNames, backgroundColorNames, colorNames, ansiStyles, ansi_styles_default;
|
|
5555
|
-
var init_ansi_styles = __esm({
|
|
5556
|
-
"node_modules/.pnpm/chalk@5.2.0/node_modules/chalk/source/vendor/ansi-styles/index.js"() {
|
|
5557
|
-
ANSI_BACKGROUND_OFFSET = 10;
|
|
5558
|
-
wrapAnsi16 = (offset = 0) => (code) => `\x1B[${code + offset}m`;
|
|
5559
|
-
wrapAnsi256 = (offset = 0) => (code) => `\x1B[${38 + offset};5;${code}m`;
|
|
5560
|
-
wrapAnsi16m = (offset = 0) => (red, green, blue) => `\x1B[${38 + offset};2;${red};${green};${blue}m`;
|
|
5561
|
-
styles = {
|
|
5562
|
-
modifier: {
|
|
5563
|
-
reset: [0, 0],
|
|
5564
|
-
bold: [1, 22],
|
|
5565
|
-
dim: [2, 22],
|
|
5566
|
-
italic: [3, 23],
|
|
5567
|
-
underline: [4, 24],
|
|
5568
|
-
overline: [53, 55],
|
|
5569
|
-
inverse: [7, 27],
|
|
5570
|
-
hidden: [8, 28],
|
|
5571
|
-
strikethrough: [9, 29]
|
|
5474
|
+
});
|
|
5475
|
+
|
|
5476
|
+
// node_modules/.pnpm/sisteransi@1.0.5/node_modules/sisteransi/src/index.js
|
|
5477
|
+
var require_src = __commonJS({
|
|
5478
|
+
"node_modules/.pnpm/sisteransi@1.0.5/node_modules/sisteransi/src/index.js"(exports, module2) {
|
|
5479
|
+
"use strict";
|
|
5480
|
+
var ESC = "\x1B";
|
|
5481
|
+
var CSI = `${ESC}[`;
|
|
5482
|
+
var beep = "\x07";
|
|
5483
|
+
var cursor = {
|
|
5484
|
+
to(x, y) {
|
|
5485
|
+
if (!y)
|
|
5486
|
+
return `${CSI}${x + 1}G`;
|
|
5487
|
+
return `${CSI}${y + 1};${x + 1}H`;
|
|
5572
5488
|
},
|
|
5573
|
-
|
|
5574
|
-
|
|
5575
|
-
|
|
5576
|
-
|
|
5577
|
-
|
|
5578
|
-
|
|
5579
|
-
|
|
5580
|
-
|
|
5581
|
-
|
|
5582
|
-
|
|
5583
|
-
|
|
5584
|
-
grey: [90, 39],
|
|
5585
|
-
redBright: [91, 39],
|
|
5586
|
-
greenBright: [92, 39],
|
|
5587
|
-
yellowBright: [93, 39],
|
|
5588
|
-
blueBright: [94, 39],
|
|
5589
|
-
magentaBright: [95, 39],
|
|
5590
|
-
cyanBright: [96, 39],
|
|
5591
|
-
whiteBright: [97, 39]
|
|
5489
|
+
move(x, y) {
|
|
5490
|
+
let ret = "";
|
|
5491
|
+
if (x < 0)
|
|
5492
|
+
ret += `${CSI}${-x}D`;
|
|
5493
|
+
else if (x > 0)
|
|
5494
|
+
ret += `${CSI}${x}C`;
|
|
5495
|
+
if (y < 0)
|
|
5496
|
+
ret += `${CSI}${-y}A`;
|
|
5497
|
+
else if (y > 0)
|
|
5498
|
+
ret += `${CSI}${y}B`;
|
|
5499
|
+
return ret;
|
|
5592
5500
|
},
|
|
5593
|
-
|
|
5594
|
-
|
|
5595
|
-
|
|
5596
|
-
|
|
5597
|
-
|
|
5598
|
-
|
|
5599
|
-
|
|
5600
|
-
|
|
5601
|
-
|
|
5602
|
-
|
|
5603
|
-
|
|
5604
|
-
|
|
5605
|
-
|
|
5606
|
-
|
|
5607
|
-
|
|
5608
|
-
|
|
5609
|
-
|
|
5610
|
-
|
|
5611
|
-
|
|
5501
|
+
up: (count = 1) => `${CSI}${count}A`,
|
|
5502
|
+
down: (count = 1) => `${CSI}${count}B`,
|
|
5503
|
+
forward: (count = 1) => `${CSI}${count}C`,
|
|
5504
|
+
backward: (count = 1) => `${CSI}${count}D`,
|
|
5505
|
+
nextLine: (count = 1) => `${CSI}E`.repeat(count),
|
|
5506
|
+
prevLine: (count = 1) => `${CSI}F`.repeat(count),
|
|
5507
|
+
left: `${CSI}G`,
|
|
5508
|
+
hide: `${CSI}?25l`,
|
|
5509
|
+
show: `${CSI}?25h`,
|
|
5510
|
+
save: `${ESC}7`,
|
|
5511
|
+
restore: `${ESC}8`
|
|
5512
|
+
};
|
|
5513
|
+
var scroll = {
|
|
5514
|
+
up: (count = 1) => `${CSI}S`.repeat(count),
|
|
5515
|
+
down: (count = 1) => `${CSI}T`.repeat(count)
|
|
5516
|
+
};
|
|
5517
|
+
var erase = {
|
|
5518
|
+
screen: `${CSI}2J`,
|
|
5519
|
+
up: (count = 1) => `${CSI}1J`.repeat(count),
|
|
5520
|
+
down: (count = 1) => `${CSI}J`.repeat(count),
|
|
5521
|
+
line: `${CSI}2K`,
|
|
5522
|
+
lineEnd: `${CSI}K`,
|
|
5523
|
+
lineStart: `${CSI}1K`,
|
|
5524
|
+
lines(count) {
|
|
5525
|
+
let clear = "";
|
|
5526
|
+
for (let i = 0; i < count; i++)
|
|
5527
|
+
clear += this.line + (i < count - 1 ? cursor.up() : "");
|
|
5528
|
+
if (count)
|
|
5529
|
+
clear += cursor.left;
|
|
5530
|
+
return clear;
|
|
5612
5531
|
}
|
|
5613
5532
|
};
|
|
5614
|
-
|
|
5615
|
-
foregroundColorNames = Object.keys(styles.color);
|
|
5616
|
-
backgroundColorNames = Object.keys(styles.bgColor);
|
|
5617
|
-
colorNames = [...foregroundColorNames, ...backgroundColorNames];
|
|
5618
|
-
ansiStyles = assembleStyles();
|
|
5619
|
-
ansi_styles_default = ansiStyles;
|
|
5533
|
+
module2.exports = { cursor, scroll, erase, beep };
|
|
5620
5534
|
}
|
|
5621
5535
|
});
|
|
5622
5536
|
|
|
5623
|
-
// node_modules/.pnpm/
|
|
5624
|
-
|
|
5625
|
-
|
|
5626
|
-
|
|
5627
|
-
|
|
5628
|
-
|
|
5629
|
-
|
|
5630
|
-
|
|
5631
|
-
|
|
5632
|
-
|
|
5633
|
-
|
|
5634
|
-
|
|
5635
|
-
|
|
5636
|
-
return
|
|
5637
|
-
}
|
|
5638
|
-
|
|
5639
|
-
|
|
5640
|
-
|
|
5641
|
-
|
|
5642
|
-
|
|
5643
|
-
|
|
5644
|
-
|
|
5645
|
-
|
|
5646
|
-
|
|
5647
|
-
|
|
5648
|
-
|
|
5649
|
-
|
|
5650
|
-
};
|
|
5651
|
-
}
|
|
5652
|
-
function _supportsColor(haveStream, { streamIsTTY, sniffFlags = true } = {}) {
|
|
5653
|
-
const noFlagForceColor = envForceColor();
|
|
5654
|
-
if (noFlagForceColor !== void 0) {
|
|
5655
|
-
flagForceColor = noFlagForceColor;
|
|
5656
|
-
}
|
|
5657
|
-
const forceColor = sniffFlags ? flagForceColor : noFlagForceColor;
|
|
5658
|
-
if (forceColor === 0) {
|
|
5659
|
-
return 0;
|
|
5537
|
+
// node_modules/.pnpm/hanji@0.0.5/node_modules/hanji/utils.js
|
|
5538
|
+
var require_utils = __commonJS({
|
|
5539
|
+
"node_modules/.pnpm/hanji@0.0.5/node_modules/hanji/utils.js"(exports) {
|
|
5540
|
+
"use strict";
|
|
5541
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
5542
|
+
exports.clear = void 0;
|
|
5543
|
+
var sisteransi_1 = require_src();
|
|
5544
|
+
var strip = (str) => {
|
|
5545
|
+
const pattern = [
|
|
5546
|
+
"[\\u001B\\u009B][[\\]()#;?]*(?:(?:(?:(?:;[-a-zA-Z\\d\\/#&.:=?%@~_]+)*|[a-zA-Z\\d]+(?:;[-a-zA-Z\\d\\/#&.:=?%@~_]*)*)?\\u0007)",
|
|
5547
|
+
"(?:(?:\\d{1,4}(?:;\\d{0,4})*)?[\\dA-PRZcf-ntqry=><~]))"
|
|
5548
|
+
].join("|");
|
|
5549
|
+
const RGX = new RegExp(pattern, "g");
|
|
5550
|
+
return typeof str === "string" ? str.replace(RGX, "") : str;
|
|
5551
|
+
};
|
|
5552
|
+
var stringWidth = (str) => [...strip(str)].length;
|
|
5553
|
+
var clear = function(prompt, perLine) {
|
|
5554
|
+
if (!perLine)
|
|
5555
|
+
return sisteransi_1.erase.line + sisteransi_1.cursor.to(0);
|
|
5556
|
+
let rows = 0;
|
|
5557
|
+
const lines = prompt.split(/\r?\n/);
|
|
5558
|
+
for (let line of lines) {
|
|
5559
|
+
rows += 1 + Math.floor(Math.max(stringWidth(line) - 1, 0) / perLine);
|
|
5560
|
+
}
|
|
5561
|
+
return sisteransi_1.erase.lines(rows);
|
|
5562
|
+
};
|
|
5563
|
+
exports.clear = clear;
|
|
5660
5564
|
}
|
|
5661
|
-
|
|
5662
|
-
|
|
5663
|
-
|
|
5565
|
+
});
|
|
5566
|
+
|
|
5567
|
+
// node_modules/.pnpm/lodash.throttle@4.1.1/node_modules/lodash.throttle/index.js
|
|
5568
|
+
var require_lodash = __commonJS({
|
|
5569
|
+
"node_modules/.pnpm/lodash.throttle@4.1.1/node_modules/lodash.throttle/index.js"(exports, module2) {
|
|
5570
|
+
var FUNC_ERROR_TEXT = "Expected a function";
|
|
5571
|
+
var NAN = 0 / 0;
|
|
5572
|
+
var symbolTag = "[object Symbol]";
|
|
5573
|
+
var reTrim = /^\s+|\s+$/g;
|
|
5574
|
+
var reIsBadHex = /^[-+]0x[0-9a-f]+$/i;
|
|
5575
|
+
var reIsBinary = /^0b[01]+$/i;
|
|
5576
|
+
var reIsOctal = /^0o[0-7]+$/i;
|
|
5577
|
+
var freeParseInt = parseInt;
|
|
5578
|
+
var freeGlobal = typeof global == "object" && global && global.Object === Object && global;
|
|
5579
|
+
var freeSelf = typeof self == "object" && self && self.Object === Object && self;
|
|
5580
|
+
var root = freeGlobal || freeSelf || Function("return this")();
|
|
5581
|
+
var objectProto = Object.prototype;
|
|
5582
|
+
var objectToString = objectProto.toString;
|
|
5583
|
+
var nativeMax = Math.max;
|
|
5584
|
+
var nativeMin = Math.min;
|
|
5585
|
+
var now = function() {
|
|
5586
|
+
return root.Date.now();
|
|
5587
|
+
};
|
|
5588
|
+
function debounce(func, wait, options) {
|
|
5589
|
+
var lastArgs, lastThis, maxWait, result, timerId, lastCallTime, lastInvokeTime = 0, leading = false, maxing = false, trailing = true;
|
|
5590
|
+
if (typeof func != "function") {
|
|
5591
|
+
throw new TypeError(FUNC_ERROR_TEXT);
|
|
5592
|
+
}
|
|
5593
|
+
wait = toNumber(wait) || 0;
|
|
5594
|
+
if (isObject(options)) {
|
|
5595
|
+
leading = !!options.leading;
|
|
5596
|
+
maxing = "maxWait" in options;
|
|
5597
|
+
maxWait = maxing ? nativeMax(toNumber(options.maxWait) || 0, wait) : maxWait;
|
|
5598
|
+
trailing = "trailing" in options ? !!options.trailing : trailing;
|
|
5599
|
+
}
|
|
5600
|
+
function invokeFunc(time) {
|
|
5601
|
+
var args = lastArgs, thisArg = lastThis;
|
|
5602
|
+
lastArgs = lastThis = void 0;
|
|
5603
|
+
lastInvokeTime = time;
|
|
5604
|
+
result = func.apply(thisArg, args);
|
|
5605
|
+
return result;
|
|
5606
|
+
}
|
|
5607
|
+
function leadingEdge(time) {
|
|
5608
|
+
lastInvokeTime = time;
|
|
5609
|
+
timerId = setTimeout(timerExpired, wait);
|
|
5610
|
+
return leading ? invokeFunc(time) : result;
|
|
5611
|
+
}
|
|
5612
|
+
function remainingWait(time) {
|
|
5613
|
+
var timeSinceLastCall = time - lastCallTime, timeSinceLastInvoke = time - lastInvokeTime, result2 = wait - timeSinceLastCall;
|
|
5614
|
+
return maxing ? nativeMin(result2, maxWait - timeSinceLastInvoke) : result2;
|
|
5615
|
+
}
|
|
5616
|
+
function shouldInvoke(time) {
|
|
5617
|
+
var timeSinceLastCall = time - lastCallTime, timeSinceLastInvoke = time - lastInvokeTime;
|
|
5618
|
+
return lastCallTime === void 0 || timeSinceLastCall >= wait || timeSinceLastCall < 0 || maxing && timeSinceLastInvoke >= maxWait;
|
|
5619
|
+
}
|
|
5620
|
+
function timerExpired() {
|
|
5621
|
+
var time = now();
|
|
5622
|
+
if (shouldInvoke(time)) {
|
|
5623
|
+
return trailingEdge(time);
|
|
5624
|
+
}
|
|
5625
|
+
timerId = setTimeout(timerExpired, remainingWait(time));
|
|
5626
|
+
}
|
|
5627
|
+
function trailingEdge(time) {
|
|
5628
|
+
timerId = void 0;
|
|
5629
|
+
if (trailing && lastArgs) {
|
|
5630
|
+
return invokeFunc(time);
|
|
5631
|
+
}
|
|
5632
|
+
lastArgs = lastThis = void 0;
|
|
5633
|
+
return result;
|
|
5634
|
+
}
|
|
5635
|
+
function cancel() {
|
|
5636
|
+
if (timerId !== void 0) {
|
|
5637
|
+
clearTimeout(timerId);
|
|
5638
|
+
}
|
|
5639
|
+
lastInvokeTime = 0;
|
|
5640
|
+
lastArgs = lastCallTime = lastThis = timerId = void 0;
|
|
5641
|
+
}
|
|
5642
|
+
function flush() {
|
|
5643
|
+
return timerId === void 0 ? result : trailingEdge(now());
|
|
5644
|
+
}
|
|
5645
|
+
function debounced() {
|
|
5646
|
+
var time = now(), isInvoking = shouldInvoke(time);
|
|
5647
|
+
lastArgs = arguments;
|
|
5648
|
+
lastThis = this;
|
|
5649
|
+
lastCallTime = time;
|
|
5650
|
+
if (isInvoking) {
|
|
5651
|
+
if (timerId === void 0) {
|
|
5652
|
+
return leadingEdge(lastCallTime);
|
|
5653
|
+
}
|
|
5654
|
+
if (maxing) {
|
|
5655
|
+
timerId = setTimeout(timerExpired, wait);
|
|
5656
|
+
return invokeFunc(lastCallTime);
|
|
5657
|
+
}
|
|
5658
|
+
}
|
|
5659
|
+
if (timerId === void 0) {
|
|
5660
|
+
timerId = setTimeout(timerExpired, wait);
|
|
5661
|
+
}
|
|
5662
|
+
return result;
|
|
5663
|
+
}
|
|
5664
|
+
debounced.cancel = cancel;
|
|
5665
|
+
debounced.flush = flush;
|
|
5666
|
+
return debounced;
|
|
5664
5667
|
}
|
|
5665
|
-
|
|
5666
|
-
|
|
5668
|
+
function throttle(func, wait, options) {
|
|
5669
|
+
var leading = true, trailing = true;
|
|
5670
|
+
if (typeof func != "function") {
|
|
5671
|
+
throw new TypeError(FUNC_ERROR_TEXT);
|
|
5672
|
+
}
|
|
5673
|
+
if (isObject(options)) {
|
|
5674
|
+
leading = "leading" in options ? !!options.leading : leading;
|
|
5675
|
+
trailing = "trailing" in options ? !!options.trailing : trailing;
|
|
5676
|
+
}
|
|
5677
|
+
return debounce(func, wait, {
|
|
5678
|
+
"leading": leading,
|
|
5679
|
+
"maxWait": wait,
|
|
5680
|
+
"trailing": trailing
|
|
5681
|
+
});
|
|
5667
5682
|
}
|
|
5668
|
-
|
|
5669
|
-
|
|
5670
|
-
|
|
5671
|
-
}
|
|
5672
|
-
if (haveStream && !streamIsTTY && forceColor === void 0) {
|
|
5673
|
-
return 0;
|
|
5674
|
-
}
|
|
5675
|
-
const min = forceColor || 0;
|
|
5676
|
-
if (env.TERM === "dumb") {
|
|
5677
|
-
return min;
|
|
5678
|
-
}
|
|
5679
|
-
if (import_node_process.default.platform === "win32") {
|
|
5680
|
-
const osRelease = import_node_os.default.release().split(".");
|
|
5681
|
-
if (Number(osRelease[0]) >= 10 && Number(osRelease[2]) >= 10586) {
|
|
5682
|
-
return Number(osRelease[2]) >= 14931 ? 3 : 2;
|
|
5683
|
+
function isObject(value) {
|
|
5684
|
+
var type = typeof value;
|
|
5685
|
+
return !!value && (type == "object" || type == "function");
|
|
5683
5686
|
}
|
|
5684
|
-
|
|
5685
|
-
|
|
5686
|
-
if ("CI" in env) {
|
|
5687
|
-
if ("GITHUB_ACTIONS" in env) {
|
|
5688
|
-
return 3;
|
|
5687
|
+
function isObjectLike(value) {
|
|
5688
|
+
return !!value && typeof value == "object";
|
|
5689
5689
|
}
|
|
5690
|
-
|
|
5691
|
-
return
|
|
5690
|
+
function isSymbol(value) {
|
|
5691
|
+
return typeof value == "symbol" || isObjectLike(value) && objectToString.call(value) == symbolTag;
|
|
5692
5692
|
}
|
|
5693
|
-
|
|
5694
|
-
|
|
5695
|
-
|
|
5696
|
-
return /^(9\.(0*[1-9]\d*)\.|\d{2,}\.)/.test(env.TEAMCITY_VERSION) ? 1 : 0;
|
|
5697
|
-
}
|
|
5698
|
-
if (env.COLORTERM === "truecolor") {
|
|
5699
|
-
return 3;
|
|
5700
|
-
}
|
|
5701
|
-
if (env.TERM === "xterm-kitty") {
|
|
5702
|
-
return 3;
|
|
5703
|
-
}
|
|
5704
|
-
if ("TERM_PROGRAM" in env) {
|
|
5705
|
-
const version = Number.parseInt((env.TERM_PROGRAM_VERSION || "").split(".")[0], 10);
|
|
5706
|
-
switch (env.TERM_PROGRAM) {
|
|
5707
|
-
case "iTerm.app": {
|
|
5708
|
-
return version >= 3 ? 3 : 2;
|
|
5693
|
+
function toNumber(value) {
|
|
5694
|
+
if (typeof value == "number") {
|
|
5695
|
+
return value;
|
|
5709
5696
|
}
|
|
5710
|
-
|
|
5711
|
-
return
|
|
5697
|
+
if (isSymbol(value)) {
|
|
5698
|
+
return NAN;
|
|
5712
5699
|
}
|
|
5700
|
+
if (isObject(value)) {
|
|
5701
|
+
var other = typeof value.valueOf == "function" ? value.valueOf() : value;
|
|
5702
|
+
value = isObject(other) ? other + "" : other;
|
|
5703
|
+
}
|
|
5704
|
+
if (typeof value != "string") {
|
|
5705
|
+
return value === 0 ? value : +value;
|
|
5706
|
+
}
|
|
5707
|
+
value = value.replace(reTrim, "");
|
|
5708
|
+
var isBinary = reIsBinary.test(value);
|
|
5709
|
+
return isBinary || reIsOctal.test(value) ? freeParseInt(value.slice(2), isBinary ? 2 : 8) : reIsBadHex.test(value) ? NAN : +value;
|
|
5713
5710
|
}
|
|
5714
|
-
|
|
5715
|
-
if (/-256(color)?$/i.test(env.TERM)) {
|
|
5716
|
-
return 2;
|
|
5717
|
-
}
|
|
5718
|
-
if (/^screen|^xterm|^vt100|^vt220|^rxvt|color|ansi|cygwin|linux/i.test(env.TERM)) {
|
|
5719
|
-
return 1;
|
|
5720
|
-
}
|
|
5721
|
-
if ("COLORTERM" in env) {
|
|
5722
|
-
return 1;
|
|
5723
|
-
}
|
|
5724
|
-
return min;
|
|
5725
|
-
}
|
|
5726
|
-
function createSupportsColor(stream, options = {}) {
|
|
5727
|
-
const level = _supportsColor(stream, {
|
|
5728
|
-
streamIsTTY: stream && stream.isTTY,
|
|
5729
|
-
...options
|
|
5730
|
-
});
|
|
5731
|
-
return translateLevel(level);
|
|
5732
|
-
}
|
|
5733
|
-
var import_node_process, import_node_os, import_node_tty, env, flagForceColor, supportsColor, supports_color_default;
|
|
5734
|
-
var init_supports_color = __esm({
|
|
5735
|
-
"node_modules/.pnpm/chalk@5.2.0/node_modules/chalk/source/vendor/supports-color/index.js"() {
|
|
5736
|
-
import_node_process = __toESM(require("process"), 1);
|
|
5737
|
-
import_node_os = __toESM(require("os"), 1);
|
|
5738
|
-
import_node_tty = __toESM(require("tty"), 1);
|
|
5739
|
-
({ env } = import_node_process.default);
|
|
5740
|
-
if (hasFlag("no-color") || hasFlag("no-colors") || hasFlag("color=false") || hasFlag("color=never")) {
|
|
5741
|
-
flagForceColor = 0;
|
|
5742
|
-
} else if (hasFlag("color") || hasFlag("colors") || hasFlag("color=true") || hasFlag("color=always")) {
|
|
5743
|
-
flagForceColor = 1;
|
|
5744
|
-
}
|
|
5745
|
-
supportsColor = {
|
|
5746
|
-
stdout: createSupportsColor({ isTTY: import_node_tty.default.isatty(1) }),
|
|
5747
|
-
stderr: createSupportsColor({ isTTY: import_node_tty.default.isatty(2) })
|
|
5748
|
-
};
|
|
5749
|
-
supports_color_default = supportsColor;
|
|
5750
|
-
}
|
|
5751
|
-
});
|
|
5752
|
-
|
|
5753
|
-
// node_modules/.pnpm/chalk@5.2.0/node_modules/chalk/source/utilities.js
|
|
5754
|
-
function stringReplaceAll(string, substring, replacer) {
|
|
5755
|
-
let index4 = string.indexOf(substring);
|
|
5756
|
-
if (index4 === -1) {
|
|
5757
|
-
return string;
|
|
5758
|
-
}
|
|
5759
|
-
const substringLength = substring.length;
|
|
5760
|
-
let endIndex = 0;
|
|
5761
|
-
let returnValue = "";
|
|
5762
|
-
do {
|
|
5763
|
-
returnValue += string.slice(endIndex, index4) + substring + replacer;
|
|
5764
|
-
endIndex = index4 + substringLength;
|
|
5765
|
-
index4 = string.indexOf(substring, endIndex);
|
|
5766
|
-
} while (index4 !== -1);
|
|
5767
|
-
returnValue += string.slice(endIndex);
|
|
5768
|
-
return returnValue;
|
|
5769
|
-
}
|
|
5770
|
-
function stringEncaseCRLFWithFirstIndex(string, prefix, postfix, index4) {
|
|
5771
|
-
let endIndex = 0;
|
|
5772
|
-
let returnValue = "";
|
|
5773
|
-
do {
|
|
5774
|
-
const gotCR = string[index4 - 1] === "\r";
|
|
5775
|
-
returnValue += string.slice(endIndex, gotCR ? index4 - 1 : index4) + prefix + (gotCR ? "\r\n" : "\n") + postfix;
|
|
5776
|
-
endIndex = index4 + 1;
|
|
5777
|
-
index4 = string.indexOf("\n", endIndex);
|
|
5778
|
-
} while (index4 !== -1);
|
|
5779
|
-
returnValue += string.slice(endIndex);
|
|
5780
|
-
return returnValue;
|
|
5781
|
-
}
|
|
5782
|
-
var init_utilities = __esm({
|
|
5783
|
-
"node_modules/.pnpm/chalk@5.2.0/node_modules/chalk/source/utilities.js"() {
|
|
5711
|
+
module2.exports = throttle;
|
|
5784
5712
|
}
|
|
5785
5713
|
});
|
|
5786
5714
|
|
|
5787
|
-
// node_modules/.pnpm/
|
|
5788
|
-
|
|
5789
|
-
|
|
5790
|
-
|
|
5791
|
-
var
|
|
5792
|
-
|
|
5793
|
-
|
|
5794
|
-
|
|
5795
|
-
|
|
5796
|
-
init_utilities();
|
|
5797
|
-
init_ansi_styles();
|
|
5798
|
-
({ stdout: stdoutColor, stderr: stderrColor } = supports_color_default);
|
|
5799
|
-
GENERATOR = Symbol("GENERATOR");
|
|
5800
|
-
STYLER = Symbol("STYLER");
|
|
5801
|
-
IS_EMPTY = Symbol("IS_EMPTY");
|
|
5802
|
-
levelMapping = [
|
|
5803
|
-
"ansi",
|
|
5804
|
-
"ansi",
|
|
5805
|
-
"ansi256",
|
|
5806
|
-
"ansi16m"
|
|
5807
|
-
];
|
|
5808
|
-
styles2 = /* @__PURE__ */ Object.create(null);
|
|
5809
|
-
applyOptions = (object, options = {}) => {
|
|
5810
|
-
if (options.level && !(Number.isInteger(options.level) && options.level >= 0 && options.level <= 3)) {
|
|
5811
|
-
throw new Error("The `level` option should be an integer from 0 to 3");
|
|
5715
|
+
// node_modules/.pnpm/hanji@0.0.5/node_modules/hanji/index.js
|
|
5716
|
+
var require_hanji = __commonJS({
|
|
5717
|
+
"node_modules/.pnpm/hanji@0.0.5/node_modules/hanji/index.js"(exports) {
|
|
5718
|
+
"use strict";
|
|
5719
|
+
var __awaiter = exports && exports.__awaiter || function(thisArg, _arguments, P, generator) {
|
|
5720
|
+
function adopt(value) {
|
|
5721
|
+
return value instanceof P ? value : new P(function(resolve) {
|
|
5722
|
+
resolve(value);
|
|
5723
|
+
});
|
|
5812
5724
|
}
|
|
5813
|
-
|
|
5814
|
-
|
|
5815
|
-
|
|
5816
|
-
|
|
5817
|
-
|
|
5818
|
-
|
|
5819
|
-
|
|
5820
|
-
return chalk2;
|
|
5821
|
-
};
|
|
5822
|
-
Object.setPrototypeOf(createChalk.prototype, Function.prototype);
|
|
5823
|
-
for (const [styleName, style] of Object.entries(ansi_styles_default)) {
|
|
5824
|
-
styles2[styleName] = {
|
|
5825
|
-
get() {
|
|
5826
|
-
const builder = createBuilder(this, createStyler(style.open, style.close, this[STYLER]), this[IS_EMPTY]);
|
|
5827
|
-
Object.defineProperty(this, styleName, { value: builder });
|
|
5828
|
-
return builder;
|
|
5725
|
+
return new (P || (P = Promise))(function(resolve, reject) {
|
|
5726
|
+
function fulfilled(value) {
|
|
5727
|
+
try {
|
|
5728
|
+
step(generator.next(value));
|
|
5729
|
+
} catch (e) {
|
|
5730
|
+
reject(e);
|
|
5731
|
+
}
|
|
5829
5732
|
}
|
|
5830
|
-
|
|
5831
|
-
|
|
5832
|
-
|
|
5833
|
-
|
|
5834
|
-
|
|
5835
|
-
|
|
5836
|
-
|
|
5837
|
-
|
|
5733
|
+
function rejected(value) {
|
|
5734
|
+
try {
|
|
5735
|
+
step(generator["throw"](value));
|
|
5736
|
+
} catch (e) {
|
|
5737
|
+
reject(e);
|
|
5738
|
+
}
|
|
5739
|
+
}
|
|
5740
|
+
function step(result) {
|
|
5741
|
+
result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected);
|
|
5742
|
+
}
|
|
5743
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
5744
|
+
});
|
|
5745
|
+
};
|
|
5746
|
+
var __importDefault = exports && exports.__importDefault || function(mod) {
|
|
5747
|
+
return mod && mod.__esModule ? mod : { "default": mod };
|
|
5838
5748
|
};
|
|
5839
|
-
|
|
5840
|
-
|
|
5841
|
-
|
|
5842
|
-
|
|
5843
|
-
|
|
5844
|
-
|
|
5845
|
-
|
|
5749
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
5750
|
+
exports.onTerminate = exports.renderWithTask = exports.render = exports.TaskTerminal = exports.TaskView = exports.Terminal = exports.deferred = exports.SelectState = exports.Prompt = void 0;
|
|
5751
|
+
var readline_1 = require_readline();
|
|
5752
|
+
var sisteransi_1 = require_src();
|
|
5753
|
+
var utils_1 = require_utils();
|
|
5754
|
+
var lodash_throttle_1 = __importDefault(require_lodash());
|
|
5755
|
+
var Prompt2 = class {
|
|
5756
|
+
constructor() {
|
|
5757
|
+
this.attachCallbacks = [];
|
|
5758
|
+
this.detachCallbacks = [];
|
|
5759
|
+
this.inputCallbacks = [];
|
|
5760
|
+
}
|
|
5761
|
+
requestLayout() {
|
|
5762
|
+
this.terminal.requestLayout();
|
|
5763
|
+
}
|
|
5764
|
+
on(type, callback) {
|
|
5765
|
+
if (type === "attach") {
|
|
5766
|
+
this.attachCallbacks.push(callback);
|
|
5767
|
+
} else if (type === "detach") {
|
|
5768
|
+
this.detachCallbacks.push(callback);
|
|
5769
|
+
} else if (type === "input") {
|
|
5770
|
+
this.inputCallbacks.push(callback);
|
|
5846
5771
|
}
|
|
5847
|
-
return ansi_styles_default[type].ansi(ansi_styles_default.rgbToAnsi(...arguments_));
|
|
5848
5772
|
}
|
|
5849
|
-
|
|
5850
|
-
|
|
5773
|
+
attach(terminal) {
|
|
5774
|
+
this.terminal = terminal;
|
|
5775
|
+
this.attachCallbacks.forEach((it) => it(terminal));
|
|
5776
|
+
}
|
|
5777
|
+
detach(terminal) {
|
|
5778
|
+
this.detachCallbacks.forEach((it) => it(terminal));
|
|
5779
|
+
this.terminal = void 0;
|
|
5780
|
+
}
|
|
5781
|
+
input(str, key) {
|
|
5782
|
+
this.inputCallbacks.forEach((it) => it(str, key));
|
|
5851
5783
|
}
|
|
5852
|
-
return ansi_styles_default[type][model](...arguments_);
|
|
5853
5784
|
};
|
|
5854
|
-
|
|
5855
|
-
|
|
5856
|
-
|
|
5857
|
-
|
|
5858
|
-
|
|
5859
|
-
|
|
5860
|
-
|
|
5861
|
-
|
|
5862
|
-
|
|
5863
|
-
|
|
5864
|
-
|
|
5865
|
-
|
|
5866
|
-
|
|
5867
|
-
|
|
5868
|
-
|
|
5869
|
-
return
|
|
5870
|
-
|
|
5871
|
-
|
|
5872
|
-
|
|
5785
|
+
exports.Prompt = Prompt2;
|
|
5786
|
+
var SelectState2 = class {
|
|
5787
|
+
constructor(items) {
|
|
5788
|
+
this.items = items;
|
|
5789
|
+
this.selectedIdx = 0;
|
|
5790
|
+
}
|
|
5791
|
+
bind(prompt) {
|
|
5792
|
+
prompt.on("input", (str, key) => {
|
|
5793
|
+
const invalidate = this.consume(str, key);
|
|
5794
|
+
if (invalidate)
|
|
5795
|
+
prompt.requestLayout();
|
|
5796
|
+
});
|
|
5797
|
+
}
|
|
5798
|
+
consume(str, key) {
|
|
5799
|
+
if (!key)
|
|
5800
|
+
return false;
|
|
5801
|
+
if (key.name === "down") {
|
|
5802
|
+
this.selectedIdx = (this.selectedIdx + 1) % this.items.length;
|
|
5803
|
+
return true;
|
|
5873
5804
|
}
|
|
5874
|
-
|
|
5875
|
-
|
|
5876
|
-
|
|
5877
|
-
|
|
5878
|
-
...styles2,
|
|
5879
|
-
level: {
|
|
5880
|
-
enumerable: true,
|
|
5881
|
-
get() {
|
|
5882
|
-
return this[GENERATOR].level;
|
|
5883
|
-
},
|
|
5884
|
-
set(level) {
|
|
5885
|
-
this[GENERATOR].level = level;
|
|
5805
|
+
if (key.name === "up") {
|
|
5806
|
+
this.selectedIdx -= 1;
|
|
5807
|
+
this.selectedIdx = this.selectedIdx < 0 ? this.items.length - 1 : this.selectedIdx;
|
|
5808
|
+
return true;
|
|
5886
5809
|
}
|
|
5810
|
+
return false;
|
|
5887
5811
|
}
|
|
5888
|
-
}
|
|
5889
|
-
|
|
5890
|
-
|
|
5891
|
-
let
|
|
5892
|
-
|
|
5893
|
-
|
|
5894
|
-
|
|
5895
|
-
|
|
5896
|
-
|
|
5897
|
-
closeAll = close + parent.closeAll;
|
|
5898
|
-
}
|
|
5812
|
+
};
|
|
5813
|
+
exports.SelectState = SelectState2;
|
|
5814
|
+
var deferred = () => {
|
|
5815
|
+
let resolve;
|
|
5816
|
+
let reject;
|
|
5817
|
+
const promise = new Promise((res, rej) => {
|
|
5818
|
+
resolve = res;
|
|
5819
|
+
reject = rej;
|
|
5820
|
+
});
|
|
5899
5821
|
return {
|
|
5900
|
-
|
|
5901
|
-
|
|
5902
|
-
|
|
5903
|
-
closeAll,
|
|
5904
|
-
parent
|
|
5822
|
+
resolve,
|
|
5823
|
+
reject,
|
|
5824
|
+
promise
|
|
5905
5825
|
};
|
|
5906
5826
|
};
|
|
5907
|
-
|
|
5908
|
-
|
|
5909
|
-
|
|
5910
|
-
|
|
5911
|
-
|
|
5912
|
-
|
|
5913
|
-
|
|
5827
|
+
exports.deferred = deferred;
|
|
5828
|
+
var Terminal = class {
|
|
5829
|
+
constructor(view, stdin, stdout, closable) {
|
|
5830
|
+
this.view = view;
|
|
5831
|
+
this.stdin = stdin;
|
|
5832
|
+
this.stdout = stdout;
|
|
5833
|
+
this.closable = closable;
|
|
5834
|
+
this.text = "";
|
|
5835
|
+
this.status = "idle";
|
|
5836
|
+
if (this.stdin.isTTY)
|
|
5837
|
+
this.stdin.setRawMode(true);
|
|
5838
|
+
const keypress = (str, key) => {
|
|
5839
|
+
if (key.name === "c" && key.ctrl === true) {
|
|
5840
|
+
this.requestLayout();
|
|
5841
|
+
this.view.detach(this);
|
|
5842
|
+
this.tearDown(keypress);
|
|
5843
|
+
if (terminateHandler) {
|
|
5844
|
+
terminateHandler(this.stdin, this.stdout);
|
|
5845
|
+
return;
|
|
5846
|
+
}
|
|
5847
|
+
this.stdout.write(`
|
|
5848
|
+
^C
|
|
5849
|
+
`);
|
|
5850
|
+
process.exit(1);
|
|
5851
|
+
}
|
|
5852
|
+
if (key.name === "escape") {
|
|
5853
|
+
this.status = "aborted";
|
|
5854
|
+
this.requestLayout();
|
|
5855
|
+
this.view.detach(this);
|
|
5856
|
+
this.tearDown(keypress);
|
|
5857
|
+
this.resolve({ status: "aborted", data: void 0 });
|
|
5858
|
+
return;
|
|
5859
|
+
}
|
|
5860
|
+
if (key.name === "return") {
|
|
5861
|
+
this.status = "submitted";
|
|
5862
|
+
this.requestLayout();
|
|
5863
|
+
this.view.detach(this);
|
|
5864
|
+
this.tearDown(keypress);
|
|
5865
|
+
this.resolve({ status: "submitted", data: this.view.result() });
|
|
5866
|
+
return;
|
|
5867
|
+
}
|
|
5868
|
+
view.input(str, key);
|
|
5869
|
+
};
|
|
5870
|
+
this.stdin.on("keypress", keypress);
|
|
5871
|
+
this.view.attach(this);
|
|
5872
|
+
const { resolve, promise } = (0, exports.deferred)();
|
|
5873
|
+
this.resolve = resolve;
|
|
5874
|
+
this.promise = promise;
|
|
5875
|
+
this.renderFunc = (0, lodash_throttle_1.default)((str) => {
|
|
5876
|
+
this.stdout.write(str);
|
|
5877
|
+
});
|
|
5878
|
+
}
|
|
5879
|
+
tearDown(keypress) {
|
|
5880
|
+
this.stdout.write(sisteransi_1.cursor.show);
|
|
5881
|
+
this.stdin.removeListener("keypress", keypress);
|
|
5882
|
+
if (this.stdin.isTTY)
|
|
5883
|
+
this.stdin.setRawMode(false);
|
|
5884
|
+
this.closable.close();
|
|
5885
|
+
}
|
|
5886
|
+
result() {
|
|
5887
|
+
return this.promise;
|
|
5888
|
+
}
|
|
5889
|
+
toggleCursor(state) {
|
|
5890
|
+
if (state === "hide") {
|
|
5891
|
+
this.stdout.write(sisteransi_1.cursor.hide);
|
|
5892
|
+
} else {
|
|
5893
|
+
this.stdout.write(sisteransi_1.cursor.show);
|
|
5894
|
+
}
|
|
5895
|
+
}
|
|
5896
|
+
requestLayout() {
|
|
5897
|
+
const string = this.view.render(this.status);
|
|
5898
|
+
const clearPrefix = this.text ? (0, utils_1.clear)(this.text, this.stdout.columns) : "";
|
|
5899
|
+
this.text = string;
|
|
5900
|
+
this.renderFunc(`${clearPrefix}${string}`);
|
|
5901
|
+
}
|
|
5914
5902
|
};
|
|
5915
|
-
|
|
5916
|
-
|
|
5917
|
-
|
|
5903
|
+
exports.Terminal = Terminal;
|
|
5904
|
+
var TaskView2 = class {
|
|
5905
|
+
constructor() {
|
|
5906
|
+
this.attachCallbacks = [];
|
|
5907
|
+
this.detachCallbacks = [];
|
|
5918
5908
|
}
|
|
5919
|
-
|
|
5920
|
-
|
|
5921
|
-
return string;
|
|
5909
|
+
requestLayout() {
|
|
5910
|
+
this.terminal.requestLayout();
|
|
5922
5911
|
}
|
|
5923
|
-
|
|
5924
|
-
|
|
5925
|
-
|
|
5926
|
-
|
|
5927
|
-
|
|
5912
|
+
attach(terminal) {
|
|
5913
|
+
this.terminal = terminal;
|
|
5914
|
+
this.attachCallbacks.forEach((it) => it(terminal));
|
|
5915
|
+
}
|
|
5916
|
+
detach(terminal) {
|
|
5917
|
+
this.detachCallbacks.forEach((it) => it(terminal));
|
|
5918
|
+
this.terminal = void 0;
|
|
5919
|
+
}
|
|
5920
|
+
on(type, callback) {
|
|
5921
|
+
if (type === "attach") {
|
|
5922
|
+
this.attachCallbacks.push(callback);
|
|
5923
|
+
} else if (type === "detach") {
|
|
5924
|
+
this.detachCallbacks.push(callback);
|
|
5928
5925
|
}
|
|
5929
5926
|
}
|
|
5930
|
-
|
|
5931
|
-
|
|
5932
|
-
|
|
5927
|
+
};
|
|
5928
|
+
exports.TaskView = TaskView2;
|
|
5929
|
+
var TaskTerminal = class {
|
|
5930
|
+
constructor(view, stdout) {
|
|
5931
|
+
this.view = view;
|
|
5932
|
+
this.stdout = stdout;
|
|
5933
|
+
this.text = "";
|
|
5934
|
+
this.view.attach(this);
|
|
5935
|
+
}
|
|
5936
|
+
requestLayout() {
|
|
5937
|
+
const string = this.view.render("pending");
|
|
5938
|
+
const clearPrefix = this.text ? (0, utils_1.clear)(this.text, this.stdout.columns) : "";
|
|
5939
|
+
this.text = string;
|
|
5940
|
+
this.stdout.write(`${clearPrefix}${string}`);
|
|
5941
|
+
}
|
|
5942
|
+
clear() {
|
|
5943
|
+
const string = this.view.render("done");
|
|
5944
|
+
this.view.detach(this);
|
|
5945
|
+
const clearPrefix = this.text ? (0, utils_1.clear)(this.text, this.stdout.columns) : "";
|
|
5946
|
+
this.stdout.write(`${clearPrefix}${string}`);
|
|
5933
5947
|
}
|
|
5934
|
-
return openAll + string + closeAll;
|
|
5935
5948
|
};
|
|
5936
|
-
|
|
5937
|
-
|
|
5938
|
-
|
|
5939
|
-
|
|
5949
|
+
exports.TaskTerminal = TaskTerminal;
|
|
5950
|
+
function render4(view) {
|
|
5951
|
+
const { stdin, stdout, closable } = (0, readline_1.prepareReadLine)();
|
|
5952
|
+
if (view instanceof Prompt2) {
|
|
5953
|
+
const terminal = new Terminal(view, stdin, stdout, closable);
|
|
5954
|
+
terminal.requestLayout();
|
|
5955
|
+
return terminal.result();
|
|
5956
|
+
}
|
|
5957
|
+
stdout.write(`${view}
|
|
5958
|
+
`);
|
|
5959
|
+
closable.close();
|
|
5960
|
+
return;
|
|
5961
|
+
}
|
|
5962
|
+
exports.render = render4;
|
|
5963
|
+
function renderWithTask2(view, task) {
|
|
5964
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
5965
|
+
const terminal = new TaskTerminal(view, process.stdout);
|
|
5966
|
+
terminal.requestLayout();
|
|
5967
|
+
const result = yield task;
|
|
5968
|
+
terminal.clear();
|
|
5969
|
+
return result;
|
|
5970
|
+
});
|
|
5971
|
+
}
|
|
5972
|
+
exports.renderWithTask = renderWithTask2;
|
|
5973
|
+
var terminateHandler;
|
|
5974
|
+
function onTerminate(callback) {
|
|
5975
|
+
terminateHandler = callback;
|
|
5976
|
+
}
|
|
5977
|
+
exports.onTerminate = onTerminate;
|
|
5940
5978
|
}
|
|
5941
5979
|
});
|
|
5942
5980
|
|
|
5943
5981
|
// src/cli/views.ts
|
|
5944
|
-
var import_hanji, err, info, error, schema, isRenamePromptItem, ResolveColumnSelect, ResolveTableSelect, Spinner, IntrospectProgress;
|
|
5982
|
+
var import_hanji, err, info, error, schema, isRenamePromptItem, ResolveColumnSelect, ResolveTableSelect, ResolveSchemasSelect, Spinner, IntrospectProgress;
|
|
5945
5983
|
var init_views = __esm({
|
|
5946
5984
|
"src/cli/views.ts"() {
|
|
5947
5985
|
init_source();
|
|
@@ -5950,10 +5988,10 @@ var init_views = __esm({
|
|
|
5950
5988
|
(0, import_hanji.render)(`${source_default.bold.red("error")} ${msg}`);
|
|
5951
5989
|
};
|
|
5952
5990
|
info = (msg, greyMsg = "") => {
|
|
5953
|
-
return `${source_default.blue.bold("Info:")} ${
|
|
5991
|
+
return `${source_default.blue.bold("Info:")} ${msg} ${greyMsg ? source_default.grey(greyMsg) : ""}`.trim();
|
|
5954
5992
|
};
|
|
5955
5993
|
error = (error2, greyMsg = "") => {
|
|
5956
|
-
return `${source_default.red.bold("
|
|
5994
|
+
return `${source_default.red.bold("Err:")} ${error2} ${greyMsg ? source_default.grey(greyMsg) : ""}`.trim();
|
|
5957
5995
|
};
|
|
5958
5996
|
schema = (schema4) => {
|
|
5959
5997
|
const tables = Object.values(schema4.tables);
|
|
@@ -5968,7 +6006,7 @@ var init_views = __esm({
|
|
|
5968
6006
|
)}`;
|
|
5969
6007
|
}).join("\n");
|
|
5970
6008
|
msg += "\n";
|
|
5971
|
-
const enums = Object.values(schema4
|
|
6009
|
+
const enums = Object.values(schema4["enums"] || {});
|
|
5972
6010
|
if (enums.length > 0) {
|
|
5973
6011
|
msg += "\n";
|
|
5974
6012
|
msg += source_default.bold(`${enums.length} enums
|
|
@@ -6075,6 +6113,50 @@ Is ${source_default.bold.blue(
|
|
|
6075
6113
|
return this.state.items[this.state.selectedIdx];
|
|
6076
6114
|
}
|
|
6077
6115
|
};
|
|
6116
|
+
ResolveSchemasSelect = class extends import_hanji.Prompt {
|
|
6117
|
+
constructor(base, data) {
|
|
6118
|
+
super();
|
|
6119
|
+
this.base = base;
|
|
6120
|
+
this.on("attach", (terminal) => terminal.toggleCursor("hide"));
|
|
6121
|
+
this.state = new import_hanji.SelectState(data);
|
|
6122
|
+
this.state.bind(this);
|
|
6123
|
+
this.base = base;
|
|
6124
|
+
}
|
|
6125
|
+
render(status) {
|
|
6126
|
+
if (status === "submitted" || status === "aborted") {
|
|
6127
|
+
return "";
|
|
6128
|
+
}
|
|
6129
|
+
let text = `
|
|
6130
|
+
Is ${source_default.bold.blue(
|
|
6131
|
+
this.base.name
|
|
6132
|
+
)} schema created or renamed from another schema?
|
|
6133
|
+
`;
|
|
6134
|
+
const isSelectedRenamed = isRenamePromptItem(
|
|
6135
|
+
this.state.items[this.state.selectedIdx]
|
|
6136
|
+
);
|
|
6137
|
+
const selectedPrefix = isSelectedRenamed ? source_default.yellow("\u276F ") : source_default.green("\u276F ");
|
|
6138
|
+
const labelLength = this.state.items.filter((it) => isRenamePromptItem(it)).map((it) => {
|
|
6139
|
+
return this.base.name.length + 3 + it["from"].name.length;
|
|
6140
|
+
}).reduce((a, b) => {
|
|
6141
|
+
if (a > b) {
|
|
6142
|
+
return a;
|
|
6143
|
+
}
|
|
6144
|
+
return b;
|
|
6145
|
+
}, 0);
|
|
6146
|
+
this.state.items.forEach((it, idx) => {
|
|
6147
|
+
const isSelected = idx === this.state.selectedIdx;
|
|
6148
|
+
const isRenamed = isRenamePromptItem(it);
|
|
6149
|
+
const title = isRenamed ? `${it.from.name} \u203A ${it.to.name}`.padEnd(labelLength, " ") : it.name.padEnd(labelLength, " ");
|
|
6150
|
+
const label = isRenamed ? `${source_default.yellow("~")} ${title} ${source_default.gray("rename schema")}` : `${source_default.green("+")} ${title} ${source_default.gray("create schema")}`;
|
|
6151
|
+
text += isSelected ? `${selectedPrefix}${label}` : ` ${label}`;
|
|
6152
|
+
text += idx != this.state.items.length - 1 ? "\n" : "";
|
|
6153
|
+
});
|
|
6154
|
+
return text;
|
|
6155
|
+
}
|
|
6156
|
+
result() {
|
|
6157
|
+
return this.state.items[this.state.selectedIdx];
|
|
6158
|
+
}
|
|
6159
|
+
};
|
|
6078
6160
|
Spinner = class {
|
|
6079
6161
|
constructor(frames) {
|
|
6080
6162
|
this.frames = frames;
|
|
@@ -6150,14 +6232,14 @@ Is ${source_default.bold.blue(
|
|
|
6150
6232
|
this.requestLayout();
|
|
6151
6233
|
}
|
|
6152
6234
|
render() {
|
|
6153
|
-
let
|
|
6235
|
+
let info3 = "";
|
|
6154
6236
|
const spin = this.spinner.value();
|
|
6155
|
-
|
|
6156
|
-
|
|
6157
|
-
|
|
6158
|
-
|
|
6159
|
-
|
|
6160
|
-
return
|
|
6237
|
+
info3 += this.statusText(spin, this.state.tables);
|
|
6238
|
+
info3 += this.statusText(spin, this.state.columns);
|
|
6239
|
+
info3 += this.statusText(spin, this.state.enums);
|
|
6240
|
+
info3 += this.statusText(spin, this.state.indexes);
|
|
6241
|
+
info3 += this.statusText(spin, this.state.fks);
|
|
6242
|
+
return info3;
|
|
6161
6243
|
}
|
|
6162
6244
|
};
|
|
6163
6245
|
}
|
|
@@ -6172,7 +6254,7 @@ var init_global = __esm({
|
|
|
6172
6254
|
});
|
|
6173
6255
|
|
|
6174
6256
|
// src/serializer/mysqlSchema.ts
|
|
6175
|
-
var index, fk, column, table, dialect, schemaHash, schemaInternal, schema2, tableSquashed, schemaSquashed, MySqlSquasher, squashMysqlScheme,
|
|
6257
|
+
var index, fk, column, tableV3, table, dialect, schemaHash, schemaInternalV3, schemaInternal, schemaV3, schema2, tableSquashed, schemaSquashed, MySqlSquasher, squashMysqlScheme, mysqlSchema, mysqlSchemaV3, backwardCompatibleMysqlSchema, dryMySql;
|
|
6176
6258
|
var init_mysqlSchema = __esm({
|
|
6177
6259
|
"src/serializer/mysqlSchema.ts"() {
|
|
6178
6260
|
init_global();
|
|
@@ -6203,8 +6285,15 @@ var init_mysqlSchema = __esm({
|
|
|
6203
6285
|
autoincrement: booleanType().optional(),
|
|
6204
6286
|
default: anyType().optional()
|
|
6205
6287
|
}).strict();
|
|
6288
|
+
tableV3 = objectType({
|
|
6289
|
+
name: stringType(),
|
|
6290
|
+
columns: recordType(stringType(), column),
|
|
6291
|
+
indexes: recordType(stringType(), index),
|
|
6292
|
+
foreignKeys: recordType(stringType(), fk)
|
|
6293
|
+
}).strict();
|
|
6206
6294
|
table = objectType({
|
|
6207
6295
|
name: stringType(),
|
|
6296
|
+
schema: stringType().optional(),
|
|
6208
6297
|
columns: recordType(stringType(), column),
|
|
6209
6298
|
indexes: recordType(stringType(), index),
|
|
6210
6299
|
foreignKeys: recordType(stringType(), fk)
|
|
@@ -6214,24 +6303,31 @@ var init_mysqlSchema = __esm({
|
|
|
6214
6303
|
id: stringType(),
|
|
6215
6304
|
prevId: stringType()
|
|
6216
6305
|
});
|
|
6217
|
-
|
|
6306
|
+
schemaInternalV3 = objectType({
|
|
6218
6307
|
version: literalType("3"),
|
|
6219
6308
|
dialect,
|
|
6309
|
+
tables: recordType(stringType(), tableV3)
|
|
6310
|
+
}).strict();
|
|
6311
|
+
schemaInternal = objectType({
|
|
6312
|
+
version: literalType("4"),
|
|
6313
|
+
dialect,
|
|
6220
6314
|
tables: recordType(stringType(), table),
|
|
6221
|
-
|
|
6315
|
+
schemas: recordType(stringType(), stringType())
|
|
6222
6316
|
}).strict();
|
|
6317
|
+
schemaV3 = schemaInternalV3.merge(schemaHash);
|
|
6223
6318
|
schema2 = schemaInternal.merge(schemaHash);
|
|
6224
6319
|
tableSquashed = objectType({
|
|
6225
6320
|
name: stringType(),
|
|
6321
|
+
schema: stringType().optional(),
|
|
6226
6322
|
columns: recordType(stringType(), column),
|
|
6227
6323
|
indexes: recordType(stringType(), stringType()),
|
|
6228
6324
|
foreignKeys: recordType(stringType(), stringType())
|
|
6229
6325
|
}).strict();
|
|
6230
6326
|
schemaSquashed = objectType({
|
|
6231
|
-
version: literalType("
|
|
6327
|
+
version: literalType("4"),
|
|
6232
6328
|
dialect,
|
|
6233
6329
|
tables: recordType(stringType(), tableSquashed),
|
|
6234
|
-
|
|
6330
|
+
schemas: recordType(stringType(), stringType())
|
|
6235
6331
|
}).strict();
|
|
6236
6332
|
MySqlSquasher = {
|
|
6237
6333
|
squashIdx: (idx) => {
|
|
@@ -6241,15 +6337,15 @@ var init_mysqlSchema = __esm({
|
|
|
6241
6337
|
},
|
|
6242
6338
|
unsquashIdx: (input) => {
|
|
6243
6339
|
const [name, columnsString, isUnique, using, algorithm, lock] = input.split(";");
|
|
6244
|
-
const
|
|
6340
|
+
const destructed = {
|
|
6245
6341
|
name,
|
|
6246
6342
|
columns: columnsString.split(","),
|
|
6247
6343
|
isUnique: isUnique === "true",
|
|
6248
|
-
using,
|
|
6249
|
-
algorithm,
|
|
6250
|
-
lock
|
|
6251
|
-
}
|
|
6252
|
-
return
|
|
6344
|
+
using: using ? using : void 0,
|
|
6345
|
+
algorithm: algorithm ? algorithm : void 0,
|
|
6346
|
+
lock: lock ? lock : void 0
|
|
6347
|
+
};
|
|
6348
|
+
return index.parse(destructed);
|
|
6253
6349
|
},
|
|
6254
6350
|
squashFK: (fk4) => {
|
|
6255
6351
|
var _a, _b;
|
|
@@ -6290,6 +6386,7 @@ var init_mysqlSchema = __esm({
|
|
|
6290
6386
|
it[0],
|
|
6291
6387
|
{
|
|
6292
6388
|
name: it[1].name,
|
|
6389
|
+
schema: it[1].schema,
|
|
6293
6390
|
columns: it[1].columns,
|
|
6294
6391
|
indexes: squashedIndexes,
|
|
6295
6392
|
foreignKeys: squashedFKs
|
|
@@ -6301,24 +6398,25 @@ var init_mysqlSchema = __esm({
|
|
|
6301
6398
|
version: json.version,
|
|
6302
6399
|
dialect: json.dialect,
|
|
6303
6400
|
tables: mappedTables,
|
|
6304
|
-
|
|
6401
|
+
schemas: json.schemas
|
|
6305
6402
|
};
|
|
6306
6403
|
};
|
|
6307
|
-
|
|
6308
|
-
|
|
6309
|
-
|
|
6310
|
-
|
|
6404
|
+
mysqlSchema = schema2;
|
|
6405
|
+
mysqlSchemaV3 = schemaV3;
|
|
6406
|
+
backwardCompatibleMysqlSchema = unionType([schemaV3, schema2]);
|
|
6407
|
+
dryMySql = mysqlSchema.parse({
|
|
6408
|
+
version: "4",
|
|
6311
6409
|
dialect: "mysql",
|
|
6312
6410
|
id: originUUID,
|
|
6313
6411
|
prevId: "",
|
|
6314
6412
|
tables: {},
|
|
6315
|
-
|
|
6413
|
+
schemas: {}
|
|
6316
6414
|
});
|
|
6317
6415
|
}
|
|
6318
6416
|
});
|
|
6319
6417
|
|
|
6320
6418
|
// src/serializer/pgSchema.ts
|
|
6321
|
-
var indexV2, columnV2, tableV2, enumSchema, pgSchemaV2, references, columnV1, tableV1, pgSchemaV1, index2, fk2, column2, table2, schemaHash2, pgSchemaInternal, tableSquashed2, pgSchemaSquashed, pgSchema, backwardCompatiblePgSchema, PgSquasher, squashPgScheme, dryPg;
|
|
6419
|
+
var indexV2, columnV2, tableV2, enumSchema, pgSchemaV2, references, columnV1, tableV1, pgSchemaV1, index2, fk2, column2, tableV32, table2, schemaHash2, pgSchemaInternalV3, pgSchemaInternal, tableSquashed2, pgSchemaSquashed, pgSchemaV3, pgSchema, backwardCompatiblePgSchema, PgSquasher, squashPgScheme, dryPg;
|
|
6322
6420
|
var init_pgSchema = __esm({
|
|
6323
6421
|
"src/serializer/pgSchema.ts"() {
|
|
6324
6422
|
init_global();
|
|
@@ -6402,8 +6500,15 @@ var init_pgSchema = __esm({
|
|
|
6402
6500
|
notNull: booleanType(),
|
|
6403
6501
|
default: anyType().optional()
|
|
6404
6502
|
}).strict();
|
|
6503
|
+
tableV32 = objectType({
|
|
6504
|
+
name: stringType(),
|
|
6505
|
+
columns: recordType(stringType(), column2),
|
|
6506
|
+
indexes: recordType(stringType(), index2),
|
|
6507
|
+
foreignKeys: recordType(stringType(), fk2)
|
|
6508
|
+
}).strict();
|
|
6405
6509
|
table2 = objectType({
|
|
6406
6510
|
name: stringType(),
|
|
6511
|
+
schema: stringType(),
|
|
6407
6512
|
columns: recordType(stringType(), column2),
|
|
6408
6513
|
indexes: recordType(stringType(), index2),
|
|
6409
6514
|
foreignKeys: recordType(stringType(), fk2)
|
|
@@ -6412,26 +6517,41 @@ var init_pgSchema = __esm({
|
|
|
6412
6517
|
id: stringType(),
|
|
6413
6518
|
prevId: stringType()
|
|
6414
6519
|
});
|
|
6415
|
-
|
|
6520
|
+
pgSchemaInternalV3 = objectType({
|
|
6416
6521
|
version: literalType("3"),
|
|
6417
6522
|
dialect: enumType(["pg"]),
|
|
6418
|
-
tables: recordType(stringType(),
|
|
6523
|
+
tables: recordType(stringType(), tableV32),
|
|
6419
6524
|
enums: recordType(stringType(), enumSchema)
|
|
6420
6525
|
}).strict();
|
|
6526
|
+
pgSchemaInternal = objectType({
|
|
6527
|
+
version: literalType("4"),
|
|
6528
|
+
dialect: enumType(["pg"]),
|
|
6529
|
+
tables: recordType(stringType(), table2),
|
|
6530
|
+
enums: recordType(stringType(), enumSchema),
|
|
6531
|
+
schemas: recordType(stringType(), stringType())
|
|
6532
|
+
}).strict();
|
|
6421
6533
|
tableSquashed2 = objectType({
|
|
6422
6534
|
name: stringType(),
|
|
6535
|
+
schema: stringType(),
|
|
6423
6536
|
columns: recordType(stringType(), column2),
|
|
6424
6537
|
indexes: recordType(stringType(), stringType()),
|
|
6425
6538
|
foreignKeys: recordType(stringType(), stringType())
|
|
6426
6539
|
}).strict();
|
|
6427
6540
|
pgSchemaSquashed = objectType({
|
|
6428
|
-
version: literalType("
|
|
6541
|
+
version: literalType("4"),
|
|
6429
6542
|
dialect: enumType(["pg"]),
|
|
6430
6543
|
tables: recordType(stringType(), tableSquashed2),
|
|
6431
|
-
enums: recordType(stringType(), enumSchema)
|
|
6544
|
+
enums: recordType(stringType(), enumSchema),
|
|
6545
|
+
schemas: recordType(stringType(), stringType())
|
|
6432
6546
|
}).strict();
|
|
6547
|
+
pgSchemaV3 = pgSchemaInternalV3.merge(schemaHash2);
|
|
6433
6548
|
pgSchema = pgSchemaInternal.merge(schemaHash2);
|
|
6434
|
-
backwardCompatiblePgSchema = unionType([
|
|
6549
|
+
backwardCompatiblePgSchema = unionType([
|
|
6550
|
+
pgSchemaV1,
|
|
6551
|
+
pgSchemaV2,
|
|
6552
|
+
pgSchemaV3,
|
|
6553
|
+
pgSchema
|
|
6554
|
+
]);
|
|
6435
6555
|
PgSquasher = {
|
|
6436
6556
|
squashIdx: (idx) => {
|
|
6437
6557
|
index2.parse(idx);
|
|
@@ -6485,6 +6605,7 @@ var init_pgSchema = __esm({
|
|
|
6485
6605
|
it[0],
|
|
6486
6606
|
{
|
|
6487
6607
|
name: it[1].name,
|
|
6608
|
+
schema: it[1].schema,
|
|
6488
6609
|
columns: it[1].columns,
|
|
6489
6610
|
indexes: squashedIndexes,
|
|
6490
6611
|
foreignKeys: squashedFKs
|
|
@@ -6496,22 +6617,24 @@ var init_pgSchema = __esm({
|
|
|
6496
6617
|
version: json.version,
|
|
6497
6618
|
dialect: json.dialect,
|
|
6498
6619
|
tables: mappedTables,
|
|
6499
|
-
enums: json.enums
|
|
6620
|
+
enums: json.enums,
|
|
6621
|
+
schemas: json.schemas
|
|
6500
6622
|
};
|
|
6501
6623
|
};
|
|
6502
6624
|
dryPg = pgSchema.parse({
|
|
6503
|
-
version: "
|
|
6625
|
+
version: "4",
|
|
6504
6626
|
dialect: "pg",
|
|
6505
6627
|
id: originUUID,
|
|
6506
6628
|
prevId: "",
|
|
6507
6629
|
tables: {},
|
|
6508
|
-
enums: {}
|
|
6630
|
+
enums: {},
|
|
6631
|
+
schemas: {}
|
|
6509
6632
|
});
|
|
6510
6633
|
}
|
|
6511
6634
|
});
|
|
6512
6635
|
|
|
6513
6636
|
// src/serializer/sqliteSchema.ts
|
|
6514
|
-
var index3, fk3, compositePK, column3,
|
|
6637
|
+
var index3, fk3, compositePK, column3, tableV33, table3, dialect2, schemaHash3, schemaInternalV32, latestVersion, schemaInternal2, schemaV32, schema3, tableSquashed3, schemaSquashed2, SQLiteSquasher, squashSqliteScheme, drySQLite, sqliteSchemaV3, sqliteSchema, backwardCompatibleSqliteSchema;
|
|
6515
6638
|
var init_sqliteSchema = __esm({
|
|
6516
6639
|
"src/serializer/sqliteSchema.ts"() {
|
|
6517
6640
|
init_global();
|
|
@@ -6543,7 +6666,7 @@ var init_sqliteSchema = __esm({
|
|
|
6543
6666
|
autoincrement: booleanType().optional(),
|
|
6544
6667
|
default: anyType().optional()
|
|
6545
6668
|
}).strict();
|
|
6546
|
-
|
|
6669
|
+
tableV33 = objectType({
|
|
6547
6670
|
name: stringType(),
|
|
6548
6671
|
columns: recordType(stringType(), column3),
|
|
6549
6672
|
indexes: recordType(stringType(), index3),
|
|
@@ -6561,10 +6684,10 @@ var init_sqliteSchema = __esm({
|
|
|
6561
6684
|
id: stringType(),
|
|
6562
6685
|
prevId: stringType()
|
|
6563
6686
|
}).strict();
|
|
6564
|
-
|
|
6687
|
+
schemaInternalV32 = objectType({
|
|
6565
6688
|
version: literalType("3"),
|
|
6566
6689
|
dialect: dialect2,
|
|
6567
|
-
tables: recordType(stringType(),
|
|
6690
|
+
tables: recordType(stringType(), tableV33),
|
|
6568
6691
|
enums: objectType({})
|
|
6569
6692
|
}).strict();
|
|
6570
6693
|
latestVersion = literalType("4");
|
|
@@ -6574,7 +6697,7 @@ var init_sqliteSchema = __esm({
|
|
|
6574
6697
|
tables: recordType(stringType(), table3),
|
|
6575
6698
|
enums: objectType({})
|
|
6576
6699
|
}).strict();
|
|
6577
|
-
|
|
6700
|
+
schemaV32 = schemaInternalV32.merge(schemaHash3).strict();
|
|
6578
6701
|
schema3 = schemaInternal2.merge(schemaHash3).strict();
|
|
6579
6702
|
tableSquashed3 = objectType({
|
|
6580
6703
|
name: stringType(),
|
|
@@ -6676,18 +6799,17 @@ var init_sqliteSchema = __esm({
|
|
|
6676
6799
|
tables: {},
|
|
6677
6800
|
enums: {}
|
|
6678
6801
|
});
|
|
6679
|
-
sqliteSchemaV3 =
|
|
6802
|
+
sqliteSchemaV3 = schemaV32;
|
|
6680
6803
|
sqliteSchema = schema3;
|
|
6681
|
-
backwardCompatibleSqliteSchema = unionType([
|
|
6804
|
+
backwardCompatibleSqliteSchema = unionType([schemaV32, schema3]);
|
|
6682
6805
|
}
|
|
6683
6806
|
});
|
|
6684
6807
|
|
|
6685
6808
|
// src/utils.ts
|
|
6686
|
-
var import_fs,
|
|
6809
|
+
var import_fs, prepareOutFolders, mapValues, validatorForDialect, validateWithReport, prepareMigrationFolder;
|
|
6687
6810
|
var init_utils = __esm({
|
|
6688
6811
|
"src/utils.ts"() {
|
|
6689
6812
|
import_fs = require("fs");
|
|
6690
|
-
import_hanji2 = __toESM(require_hanji());
|
|
6691
6813
|
init_views();
|
|
6692
6814
|
init_mysqlSchema();
|
|
6693
6815
|
init_pgSchema();
|
|
@@ -6714,11 +6836,11 @@ var init_utils = __esm({
|
|
|
6714
6836
|
validatorForDialect = (dialect6) => {
|
|
6715
6837
|
switch (dialect6) {
|
|
6716
6838
|
case "pg":
|
|
6717
|
-
return { validator: backwardCompatiblePgSchema, version:
|
|
6839
|
+
return { validator: backwardCompatiblePgSchema, version: 4 };
|
|
6718
6840
|
case "sqlite":
|
|
6719
6841
|
return { validator: backwardCompatibleSqliteSchema, version: 4 };
|
|
6720
6842
|
case "mysql":
|
|
6721
|
-
return { validator: backwardCompatibleMysqlSchema, version:
|
|
6843
|
+
return { validator: backwardCompatibleMysqlSchema, version: 4 };
|
|
6722
6844
|
}
|
|
6723
6845
|
};
|
|
6724
6846
|
validateWithReport = (root, migrationFolders, dialect6) => {
|
|
@@ -6732,7 +6854,7 @@ var init_utils = __esm({
|
|
|
6732
6854
|
);
|
|
6733
6855
|
accum.rawMap[folder] = raw;
|
|
6734
6856
|
if (raw["version"] && Number(raw["version"]) > version) {
|
|
6735
|
-
|
|
6857
|
+
console.log(
|
|
6736
6858
|
info(
|
|
6737
6859
|
`${folder}/snapshot.json is of unsupported version, please update drizzle-kit`
|
|
6738
6860
|
)
|
|
@@ -6775,7 +6897,7 @@ var init_utils = __esm({
|
|
|
6775
6897
|
console.log(
|
|
6776
6898
|
report.nonLatest.map((it) => {
|
|
6777
6899
|
return `${it}/snapshot.json is not of the latest version`;
|
|
6778
|
-
}).concat(`Run ${source_default.green.bold(
|
|
6900
|
+
}).concat(`Run ${source_default.green.bold(`drizzle-kit up:${dialect6}`)}`).join("\n")
|
|
6779
6901
|
);
|
|
6780
6902
|
process.exit(0);
|
|
6781
6903
|
}
|
|
@@ -7719,16 +7841,16 @@ var require_node2 = __commonJS({
|
|
|
7719
7841
|
}
|
|
7720
7842
|
exports2.urlGenerate = urlGenerate;
|
|
7721
7843
|
function normalize(aPath) {
|
|
7722
|
-
var
|
|
7844
|
+
var path5 = aPath;
|
|
7723
7845
|
var url = urlParse(aPath);
|
|
7724
7846
|
if (url) {
|
|
7725
7847
|
if (!url.path) {
|
|
7726
7848
|
return aPath;
|
|
7727
7849
|
}
|
|
7728
|
-
|
|
7850
|
+
path5 = url.path;
|
|
7729
7851
|
}
|
|
7730
|
-
var isAbsolute = exports2.isAbsolute(
|
|
7731
|
-
var parts =
|
|
7852
|
+
var isAbsolute = exports2.isAbsolute(path5);
|
|
7853
|
+
var parts = path5.split(/\/+/);
|
|
7732
7854
|
for (var part, up = 0, i = parts.length - 1; i >= 0; i--) {
|
|
7733
7855
|
part = parts[i];
|
|
7734
7856
|
if (part === ".") {
|
|
@@ -7745,15 +7867,15 @@ var require_node2 = __commonJS({
|
|
|
7745
7867
|
}
|
|
7746
7868
|
}
|
|
7747
7869
|
}
|
|
7748
|
-
|
|
7749
|
-
if (
|
|
7750
|
-
|
|
7870
|
+
path5 = parts.join("/");
|
|
7871
|
+
if (path5 === "") {
|
|
7872
|
+
path5 = isAbsolute ? "/" : ".";
|
|
7751
7873
|
}
|
|
7752
7874
|
if (url) {
|
|
7753
|
-
url.path =
|
|
7875
|
+
url.path = path5;
|
|
7754
7876
|
return urlGenerate(url);
|
|
7755
7877
|
}
|
|
7756
|
-
return
|
|
7878
|
+
return path5;
|
|
7757
7879
|
}
|
|
7758
7880
|
exports2.normalize = normalize;
|
|
7759
7881
|
function join2(aRoot, aPath) {
|
|
@@ -9283,7 +9405,7 @@ var require_node2 = __commonJS({
|
|
|
9283
9405
|
});
|
|
9284
9406
|
var require_source_map_support = __commonJS2((exports2, module22) => {
|
|
9285
9407
|
var SourceMapConsumer = require_source_map().SourceMapConsumer;
|
|
9286
|
-
var
|
|
9408
|
+
var path5 = require("path");
|
|
9287
9409
|
var fs32;
|
|
9288
9410
|
try {
|
|
9289
9411
|
fs32 = require("fs");
|
|
@@ -9356,15 +9478,15 @@ var require_node2 = __commonJS({
|
|
|
9356
9478
|
function supportRelativeURL(file, url) {
|
|
9357
9479
|
if (!file)
|
|
9358
9480
|
return url;
|
|
9359
|
-
var dir =
|
|
9481
|
+
var dir = path5.dirname(file);
|
|
9360
9482
|
var match = /^\w+:\/\/[^\/]*/.exec(dir);
|
|
9361
9483
|
var protocol = match ? match[0] : "";
|
|
9362
9484
|
var startPath = dir.slice(protocol.length);
|
|
9363
9485
|
if (protocol && /^\/\w\:/.test(startPath)) {
|
|
9364
9486
|
protocol += "/";
|
|
9365
|
-
return protocol +
|
|
9487
|
+
return protocol + path5.resolve(dir.slice(protocol.length), url).replace(/\\/g, "/");
|
|
9366
9488
|
}
|
|
9367
|
-
return protocol +
|
|
9489
|
+
return protocol + path5.resolve(dir.slice(protocol.length), url);
|
|
9368
9490
|
}
|
|
9369
9491
|
function retrieveSourceMapURL(source) {
|
|
9370
9492
|
var fileData;
|
|
@@ -9817,13 +9939,13 @@ var require_node2 = __commonJS({
|
|
|
9817
9939
|
}
|
|
9818
9940
|
function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) {
|
|
9819
9941
|
try {
|
|
9820
|
-
var
|
|
9821
|
-
var value =
|
|
9942
|
+
var info3 = gen[key](arg);
|
|
9943
|
+
var value = info3.value;
|
|
9822
9944
|
} catch (error2) {
|
|
9823
9945
|
reject(error2);
|
|
9824
9946
|
return;
|
|
9825
9947
|
}
|
|
9826
|
-
if (
|
|
9948
|
+
if (info3.done) {
|
|
9827
9949
|
resolve(value);
|
|
9828
9950
|
} else {
|
|
9829
9951
|
Promise.resolve(value).then(_next, _throw);
|
|
@@ -10159,9 +10281,9 @@ var require_node2 = __commonJS({
|
|
|
10159
10281
|
"use strict";
|
|
10160
10282
|
Object.defineProperty(exports2, "__esModule", { value: true });
|
|
10161
10283
|
var fs32 = require("fs");
|
|
10162
|
-
function fileExistsSync(
|
|
10284
|
+
function fileExistsSync(path5) {
|
|
10163
10285
|
try {
|
|
10164
|
-
var stats = fs32.statSync(
|
|
10286
|
+
var stats = fs32.statSync(path5);
|
|
10165
10287
|
return stats.isFile();
|
|
10166
10288
|
} catch (err2) {
|
|
10167
10289
|
return false;
|
|
@@ -10175,8 +10297,8 @@ var require_node2 = __commonJS({
|
|
|
10175
10297
|
return require(packageJsonPath);
|
|
10176
10298
|
}
|
|
10177
10299
|
exports2.readJsonFromDiskSync = readJsonFromDiskSync;
|
|
10178
|
-
function readJsonFromDiskAsync(
|
|
10179
|
-
fs32.readFile(
|
|
10300
|
+
function readJsonFromDiskAsync(path5, callback) {
|
|
10301
|
+
fs32.readFile(path5, "utf8", function(err2, result) {
|
|
10180
10302
|
if (err2 || !result) {
|
|
10181
10303
|
return callback();
|
|
10182
10304
|
}
|
|
@@ -10194,15 +10316,15 @@ var require_node2 = __commonJS({
|
|
|
10194
10316
|
});
|
|
10195
10317
|
}
|
|
10196
10318
|
exports2.fileExistsAsync = fileExistsAsync;
|
|
10197
|
-
function removeExtension(
|
|
10198
|
-
return
|
|
10319
|
+
function removeExtension(path5) {
|
|
10320
|
+
return path5.substring(0, path5.lastIndexOf(".")) || path5;
|
|
10199
10321
|
}
|
|
10200
10322
|
exports2.removeExtension = removeExtension;
|
|
10201
10323
|
});
|
|
10202
10324
|
var require_mapping_entry = __commonJS2((exports2) => {
|
|
10203
10325
|
"use strict";
|
|
10204
10326
|
Object.defineProperty(exports2, "__esModule", { value: true });
|
|
10205
|
-
var
|
|
10327
|
+
var path5 = require("path");
|
|
10206
10328
|
function getAbsoluteMappingEntries(absoluteBaseUrl, paths, addMatchAll) {
|
|
10207
10329
|
var sortedKeys = sortByLongestPrefix(Object.keys(paths));
|
|
10208
10330
|
var absolutePaths = [];
|
|
@@ -10211,7 +10333,7 @@ var require_node2 = __commonJS({
|
|
|
10211
10333
|
absolutePaths.push({
|
|
10212
10334
|
pattern: key,
|
|
10213
10335
|
paths: paths[key].map(function(pathToResolve) {
|
|
10214
|
-
return
|
|
10336
|
+
return path5.join(absoluteBaseUrl, pathToResolve);
|
|
10215
10337
|
})
|
|
10216
10338
|
});
|
|
10217
10339
|
}
|
|
@@ -10237,11 +10359,11 @@ var require_node2 = __commonJS({
|
|
|
10237
10359
|
var require_try_path = __commonJS2((exports2) => {
|
|
10238
10360
|
"use strict";
|
|
10239
10361
|
Object.defineProperty(exports2, "__esModule", { value: true });
|
|
10240
|
-
var
|
|
10362
|
+
var path5 = require("path");
|
|
10241
10363
|
var path_1 = require("path");
|
|
10242
10364
|
var filesystem_1 = require_filesystem();
|
|
10243
10365
|
function getPathsToTry(extensions, absolutePathMappings, requestedModule) {
|
|
10244
|
-
if (!absolutePathMappings || !requestedModule || requestedModule[0] === "." || requestedModule[0] ===
|
|
10366
|
+
if (!absolutePathMappings || !requestedModule || requestedModule[0] === "." || requestedModule[0] === path5.sep) {
|
|
10245
10367
|
return void 0;
|
|
10246
10368
|
}
|
|
10247
10369
|
var pathsToTry = [];
|
|
@@ -10257,9 +10379,9 @@ var require_node2 = __commonJS({
|
|
|
10257
10379
|
}));
|
|
10258
10380
|
pathsToTry.push({
|
|
10259
10381
|
type: "package",
|
|
10260
|
-
path:
|
|
10382
|
+
path: path5.join(physicalPath, "/package.json")
|
|
10261
10383
|
});
|
|
10262
|
-
var indexPath =
|
|
10384
|
+
var indexPath = path5.join(physicalPath, "/index");
|
|
10263
10385
|
pathsToTry.push.apply(pathsToTry, extensions.map(function(e) {
|
|
10264
10386
|
return { type: "index", path: indexPath + e };
|
|
10265
10387
|
}));
|
|
@@ -10306,7 +10428,7 @@ var require_node2 = __commonJS({
|
|
|
10306
10428
|
var require_match_path_sync = __commonJS2((exports2) => {
|
|
10307
10429
|
"use strict";
|
|
10308
10430
|
Object.defineProperty(exports2, "__esModule", { value: true });
|
|
10309
|
-
var
|
|
10431
|
+
var path5 = require("path");
|
|
10310
10432
|
var Filesystem = require_filesystem();
|
|
10311
10433
|
var MappingEntry = require_mapping_entry();
|
|
10312
10434
|
var TryPath = require_try_path();
|
|
@@ -10348,7 +10470,7 @@ var require_node2 = __commonJS({
|
|
|
10348
10470
|
var mainFieldName = mainFields[index4];
|
|
10349
10471
|
var candidateMapping = packageJson[mainFieldName];
|
|
10350
10472
|
if (candidateMapping && typeof candidateMapping === "string") {
|
|
10351
|
-
var candidateFilePath =
|
|
10473
|
+
var candidateFilePath = path5.join(path5.dirname(packageJsonPath), candidateMapping);
|
|
10352
10474
|
if (fileExists(candidateFilePath)) {
|
|
10353
10475
|
return candidateFilePath;
|
|
10354
10476
|
}
|
|
@@ -10387,7 +10509,7 @@ var require_node2 = __commonJS({
|
|
|
10387
10509
|
var require_match_path_async = __commonJS2((exports2) => {
|
|
10388
10510
|
"use strict";
|
|
10389
10511
|
Object.defineProperty(exports2, "__esModule", { value: true });
|
|
10390
|
-
var
|
|
10512
|
+
var path5 = require("path");
|
|
10391
10513
|
var TryPath = require_try_path();
|
|
10392
10514
|
var MappingEntry = require_mapping_entry();
|
|
10393
10515
|
var Filesystem = require_filesystem();
|
|
@@ -10438,7 +10560,7 @@ var require_node2 = __commonJS({
|
|
|
10438
10560
|
if (typeof mainFieldMapping !== "string") {
|
|
10439
10561
|
return tryNext();
|
|
10440
10562
|
}
|
|
10441
|
-
var mappedFilePath =
|
|
10563
|
+
var mappedFilePath = path5.join(path5.dirname(packageJsonPath), mainFieldMapping);
|
|
10442
10564
|
fileExistsAsync(mappedFilePath, function(err2, exists) {
|
|
10443
10565
|
if (err2) {
|
|
10444
10566
|
return doneCallback(err2);
|
|
@@ -11658,7 +11780,7 @@ var require_node2 = __commonJS({
|
|
|
11658
11780
|
return t;
|
|
11659
11781
|
};
|
|
11660
11782
|
Object.defineProperty(exports2, "__esModule", { value: true });
|
|
11661
|
-
var
|
|
11783
|
+
var path5 = require("path");
|
|
11662
11784
|
var fs32 = require("fs");
|
|
11663
11785
|
var JSON5 = require_lib32();
|
|
11664
11786
|
var StripBom = require_strip_bom();
|
|
@@ -11688,40 +11810,40 @@ var require_node2 = __commonJS({
|
|
|
11688
11810
|
}
|
|
11689
11811
|
function resolveConfigPath(cwd, filename) {
|
|
11690
11812
|
if (filename) {
|
|
11691
|
-
var absolutePath = fs32.lstatSync(filename).isDirectory() ?
|
|
11813
|
+
var absolutePath = fs32.lstatSync(filename).isDirectory() ? path5.resolve(filename, "./tsconfig.json") : path5.resolve(cwd, filename);
|
|
11692
11814
|
return absolutePath;
|
|
11693
11815
|
}
|
|
11694
11816
|
if (fs32.statSync(cwd).isFile()) {
|
|
11695
|
-
return
|
|
11817
|
+
return path5.resolve(cwd);
|
|
11696
11818
|
}
|
|
11697
11819
|
var configAbsolutePath = walkForTsConfig(cwd);
|
|
11698
|
-
return configAbsolutePath ?
|
|
11820
|
+
return configAbsolutePath ? path5.resolve(configAbsolutePath) : void 0;
|
|
11699
11821
|
}
|
|
11700
|
-
function walkForTsConfig(directory,
|
|
11701
|
-
if (
|
|
11702
|
-
|
|
11822
|
+
function walkForTsConfig(directory, existsSync3) {
|
|
11823
|
+
if (existsSync3 === void 0) {
|
|
11824
|
+
existsSync3 = fs32.existsSync;
|
|
11703
11825
|
}
|
|
11704
|
-
var configPath =
|
|
11705
|
-
if (
|
|
11826
|
+
var configPath = path5.join(directory, "./tsconfig.json");
|
|
11827
|
+
if (existsSync3(configPath)) {
|
|
11706
11828
|
return configPath;
|
|
11707
11829
|
}
|
|
11708
|
-
var parentDirectory =
|
|
11830
|
+
var parentDirectory = path5.join(directory, "../");
|
|
11709
11831
|
if (directory === parentDirectory) {
|
|
11710
11832
|
return void 0;
|
|
11711
11833
|
}
|
|
11712
|
-
return walkForTsConfig(parentDirectory,
|
|
11834
|
+
return walkForTsConfig(parentDirectory, existsSync3);
|
|
11713
11835
|
}
|
|
11714
11836
|
exports2.walkForTsConfig = walkForTsConfig;
|
|
11715
|
-
function loadTsconfig(configFilePath,
|
|
11716
|
-
if (
|
|
11717
|
-
|
|
11837
|
+
function loadTsconfig(configFilePath, existsSync3, readFileSync2) {
|
|
11838
|
+
if (existsSync3 === void 0) {
|
|
11839
|
+
existsSync3 = fs32.existsSync;
|
|
11718
11840
|
}
|
|
11719
11841
|
if (readFileSync2 === void 0) {
|
|
11720
11842
|
readFileSync2 = function(filename) {
|
|
11721
11843
|
return fs32.readFileSync(filename, "utf8");
|
|
11722
11844
|
};
|
|
11723
11845
|
}
|
|
11724
|
-
if (!
|
|
11846
|
+
if (!existsSync3(configFilePath)) {
|
|
11725
11847
|
return void 0;
|
|
11726
11848
|
}
|
|
11727
11849
|
var configString = readFileSync2(configFilePath);
|
|
@@ -11732,15 +11854,15 @@ var require_node2 = __commonJS({
|
|
|
11732
11854
|
if (typeof extendedConfig === "string" && extendedConfig.indexOf(".json") === -1) {
|
|
11733
11855
|
extendedConfig += ".json";
|
|
11734
11856
|
}
|
|
11735
|
-
var currentDir =
|
|
11736
|
-
var extendedConfigPath =
|
|
11737
|
-
if (extendedConfig.indexOf("/") !== -1 && extendedConfig.indexOf(".") !== -1 && !
|
|
11738
|
-
extendedConfigPath =
|
|
11857
|
+
var currentDir = path5.dirname(configFilePath);
|
|
11858
|
+
var extendedConfigPath = path5.join(currentDir, extendedConfig);
|
|
11859
|
+
if (extendedConfig.indexOf("/") !== -1 && extendedConfig.indexOf(".") !== -1 && !existsSync3(extendedConfigPath)) {
|
|
11860
|
+
extendedConfigPath = path5.join(currentDir, "node_modules", extendedConfig);
|
|
11739
11861
|
}
|
|
11740
|
-
var base = loadTsconfig(extendedConfigPath,
|
|
11862
|
+
var base = loadTsconfig(extendedConfigPath, existsSync3, readFileSync2) || {};
|
|
11741
11863
|
if (base.compilerOptions && base.compilerOptions.baseUrl) {
|
|
11742
|
-
var extendsDir =
|
|
11743
|
-
base.compilerOptions.baseUrl =
|
|
11864
|
+
var extendsDir = path5.dirname(extendedConfig);
|
|
11865
|
+
base.compilerOptions.baseUrl = path5.join(extendsDir, base.compilerOptions.baseUrl);
|
|
11744
11866
|
}
|
|
11745
11867
|
return __assign({}, base, config, { compilerOptions: __assign({}, base.compilerOptions, config.compilerOptions) });
|
|
11746
11868
|
}
|
|
@@ -11965,7 +12087,7 @@ var require_node2 = __commonJS({
|
|
|
11965
12087
|
"use strict";
|
|
11966
12088
|
Object.defineProperty(exports2, "__esModule", { value: true });
|
|
11967
12089
|
var TsConfigLoader = require_tsconfig_loader();
|
|
11968
|
-
var
|
|
12090
|
+
var path5 = require("path");
|
|
11969
12091
|
var options_1 = require_options();
|
|
11970
12092
|
function loadConfig2(cwd) {
|
|
11971
12093
|
if (cwd === void 0) {
|
|
@@ -11977,7 +12099,7 @@ var require_node2 = __commonJS({
|
|
|
11977
12099
|
function configLoader(_a) {
|
|
11978
12100
|
var cwd = _a.cwd, explicitParams = _a.explicitParams, _b = _a.tsConfigLoader, tsConfigLoader = _b === void 0 ? TsConfigLoader.tsConfigLoader : _b;
|
|
11979
12101
|
if (explicitParams) {
|
|
11980
|
-
var absoluteBaseUrl_1 =
|
|
12102
|
+
var absoluteBaseUrl_1 = path5.isAbsolute(explicitParams.baseUrl) ? explicitParams.baseUrl : path5.join(cwd, explicitParams.baseUrl);
|
|
11981
12103
|
return {
|
|
11982
12104
|
resultType: "success",
|
|
11983
12105
|
configFileAbsolutePath: "",
|
|
@@ -12006,8 +12128,8 @@ var require_node2 = __commonJS({
|
|
|
12006
12128
|
message: "Missing baseUrl in compilerOptions"
|
|
12007
12129
|
};
|
|
12008
12130
|
}
|
|
12009
|
-
var tsConfigDir =
|
|
12010
|
-
var absoluteBaseUrl =
|
|
12131
|
+
var tsConfigDir = path5.dirname(loadResult.tsConfigPath);
|
|
12132
|
+
var absoluteBaseUrl = path5.join(tsConfigDir, loadResult.baseUrl);
|
|
12011
12133
|
return {
|
|
12012
12134
|
resultType: "success",
|
|
12013
12135
|
configFileAbsolutePath: loadResult.tsConfigPath,
|
|
@@ -12208,8 +12330,8 @@ var require_node2 = __commonJS({
|
|
|
12208
12330
|
});
|
|
12209
12331
|
var getOptions = (cwd) => {
|
|
12210
12332
|
var _a, _b, _c, _d;
|
|
12211
|
-
const { data, path:
|
|
12212
|
-
if (
|
|
12333
|
+
const { data, path: path5 } = joycon.loadSync(["tsconfig.json", "jsconfig.json"], cwd);
|
|
12334
|
+
if (path5 && data) {
|
|
12213
12335
|
return {
|
|
12214
12336
|
jsxFactory: (_a = data.compilerOptions) == null ? void 0 : _a.jsxFactory,
|
|
12215
12337
|
jsxFragment: (_b = data.compilerOptions) == null ? void 0 : _b.jsxFragmentFactory,
|
|
@@ -12386,6 +12508,7 @@ var init_mysqlImports = __esm({
|
|
|
12386
12508
|
prepareFromMySqlImports = (imports) => {
|
|
12387
12509
|
const tables = [];
|
|
12388
12510
|
const enums = [];
|
|
12511
|
+
const schemas = [];
|
|
12389
12512
|
imports.forEach((it) => {
|
|
12390
12513
|
const i0 = require(it);
|
|
12391
12514
|
const i0values = Object.values(i0);
|
|
@@ -12395,9 +12518,12 @@ var init_mysqlImports = __esm({
|
|
|
12395
12518
|
t
|
|
12396
12519
|
);
|
|
12397
12520
|
}
|
|
12521
|
+
if ((0, import_drizzle_orm_mysql.isMySqlSchema)(t)) {
|
|
12522
|
+
schemas.push(t);
|
|
12523
|
+
}
|
|
12398
12524
|
});
|
|
12399
12525
|
});
|
|
12400
|
-
return { tables, enums };
|
|
12526
|
+
return { tables, enums, schemas };
|
|
12401
12527
|
};
|
|
12402
12528
|
}
|
|
12403
12529
|
});
|
|
@@ -12416,14 +12542,20 @@ var init_mysqlSerializer = __esm({
|
|
|
12416
12542
|
import_sql = require("drizzle-orm/sql");
|
|
12417
12543
|
import_common = require("drizzle-orm-mysql/columns/common");
|
|
12418
12544
|
dialect3 = new import_drizzle_orm_mysql2.MySqlDialect();
|
|
12419
|
-
generateMySqlSnapshot = (tables, enums) => {
|
|
12545
|
+
generateMySqlSnapshot = (tables, enums, mysqlSchemas) => {
|
|
12420
12546
|
const result = {};
|
|
12421
12547
|
for (const table4 of tables) {
|
|
12422
|
-
const
|
|
12548
|
+
const {
|
|
12549
|
+
name: tableName,
|
|
12550
|
+
columns,
|
|
12551
|
+
indexes,
|
|
12552
|
+
foreignKeys,
|
|
12553
|
+
schema: schema4
|
|
12554
|
+
} = (0, import_utils5.getTableConfig)(table4);
|
|
12423
12555
|
const columnsObject = {};
|
|
12424
12556
|
const indexesObject = {};
|
|
12425
12557
|
const foreignKeysObject = {};
|
|
12426
|
-
|
|
12558
|
+
columns.forEach((column5) => {
|
|
12427
12559
|
const notNull = column5.notNull;
|
|
12428
12560
|
const primaryKey = column5.primary;
|
|
12429
12561
|
const columnToSet = {
|
|
@@ -12450,7 +12582,7 @@ var init_mysqlSerializer = __esm({
|
|
|
12450
12582
|
}
|
|
12451
12583
|
columnsObject[column5.name] = columnToSet;
|
|
12452
12584
|
});
|
|
12453
|
-
const
|
|
12585
|
+
const fks = foreignKeys.map((fk4) => {
|
|
12454
12586
|
const name = fk4.getName();
|
|
12455
12587
|
const tableFrom = tableName;
|
|
12456
12588
|
const onDelete = fk4.onDelete;
|
|
@@ -12470,14 +12602,14 @@ var init_mysqlSerializer = __esm({
|
|
|
12470
12602
|
onUpdate
|
|
12471
12603
|
};
|
|
12472
12604
|
});
|
|
12473
|
-
|
|
12605
|
+
fks.forEach((it) => {
|
|
12474
12606
|
foreignKeysObject[it.name] = it;
|
|
12475
12607
|
});
|
|
12476
|
-
|
|
12608
|
+
indexes.forEach((value) => {
|
|
12477
12609
|
var _a;
|
|
12478
|
-
const
|
|
12610
|
+
const columns2 = value.config.columns;
|
|
12479
12611
|
const name = value.config.name;
|
|
12480
|
-
let indexColumns =
|
|
12612
|
+
let indexColumns = columns2.map((it) => {
|
|
12481
12613
|
if (it instanceof import_sql.SQL) {
|
|
12482
12614
|
return dialect3.sqlToQuery(it).sql;
|
|
12483
12615
|
} else {
|
|
@@ -12495,12 +12627,14 @@ var init_mysqlSerializer = __esm({
|
|
|
12495
12627
|
});
|
|
12496
12628
|
result[tableName] = {
|
|
12497
12629
|
name: tableName,
|
|
12630
|
+
schema: schema4,
|
|
12498
12631
|
columns: columnsObject,
|
|
12499
12632
|
indexes: indexesObject,
|
|
12500
12633
|
foreignKeys: foreignKeysObject
|
|
12501
12634
|
};
|
|
12502
12635
|
}
|
|
12503
|
-
|
|
12636
|
+
const schemas = Object.fromEntries(mysqlSchemas.map((it) => [it.schemaName, it.schemaName]));
|
|
12637
|
+
return { version: "4", dialect: "mysql", tables: result, schemas };
|
|
12504
12638
|
};
|
|
12505
12639
|
}
|
|
12506
12640
|
});
|
|
@@ -12517,6 +12651,7 @@ var init_pgImports = __esm({
|
|
|
12517
12651
|
prepareFromPgImports = (imports) => {
|
|
12518
12652
|
const tables = [];
|
|
12519
12653
|
const enums = [];
|
|
12654
|
+
const schemas = [];
|
|
12520
12655
|
imports.forEach((it) => {
|
|
12521
12656
|
const i0 = require(it);
|
|
12522
12657
|
const i0values = Object.values(i0);
|
|
@@ -12530,9 +12665,12 @@ var init_pgImports = __esm({
|
|
|
12530
12665
|
t
|
|
12531
12666
|
);
|
|
12532
12667
|
}
|
|
12668
|
+
if ((0, import_drizzle_orm_pg.isPgSchema)(t)) {
|
|
12669
|
+
schemas.push(t);
|
|
12670
|
+
}
|
|
12533
12671
|
});
|
|
12534
12672
|
});
|
|
12535
|
-
return { tables, enums };
|
|
12673
|
+
return { tables, enums, schemas };
|
|
12536
12674
|
};
|
|
12537
12675
|
}
|
|
12538
12676
|
});
|
|
@@ -12555,11 +12693,17 @@ var init_pgSerializer = __esm({
|
|
|
12555
12693
|
indexName = (tableName, columns) => {
|
|
12556
12694
|
return `${tableName}_${columns.join("_")}_index`;
|
|
12557
12695
|
};
|
|
12558
|
-
generatePgSnapshot = (tables, enums) => {
|
|
12696
|
+
generatePgSnapshot = (tables, enums, schemas) => {
|
|
12559
12697
|
const result = {};
|
|
12560
12698
|
for (const table4 of tables) {
|
|
12561
|
-
const
|
|
12562
|
-
|
|
12699
|
+
const {
|
|
12700
|
+
name: tableName,
|
|
12701
|
+
columns,
|
|
12702
|
+
indexes,
|
|
12703
|
+
foreignKeys,
|
|
12704
|
+
checks,
|
|
12705
|
+
schema: schema4
|
|
12706
|
+
} = (0, import_utils6.getTableConfig)(table4);
|
|
12563
12707
|
const columnsObject = {};
|
|
12564
12708
|
const indexesObject = {};
|
|
12565
12709
|
const foreignKeysObject = {};
|
|
@@ -12644,6 +12788,7 @@ var init_pgSerializer = __esm({
|
|
|
12644
12788
|
});
|
|
12645
12789
|
result[tableName] = {
|
|
12646
12790
|
name: tableName,
|
|
12791
|
+
schema: schema4 != null ? schema4 : "",
|
|
12647
12792
|
columns: columnsObject,
|
|
12648
12793
|
indexes: indexesObject,
|
|
12649
12794
|
foreignKeys: foreignKeysObject
|
|
@@ -12658,13 +12803,23 @@ var init_pgSerializer = __esm({
|
|
|
12658
12803
|
map[key] = { name: obj.enumName, values: newValues };
|
|
12659
12804
|
return map;
|
|
12660
12805
|
}, {});
|
|
12661
|
-
|
|
12806
|
+
const schemasObject = Object.fromEntries(
|
|
12807
|
+
schemas.map((it) => [it.schemaName, it.schemaName])
|
|
12808
|
+
);
|
|
12809
|
+
return {
|
|
12810
|
+
version: "4",
|
|
12811
|
+
dialect: "pg",
|
|
12812
|
+
tables: result,
|
|
12813
|
+
enums: enumsToReturn,
|
|
12814
|
+
schemas: schemasObject
|
|
12815
|
+
};
|
|
12662
12816
|
};
|
|
12663
12817
|
fromDatabase = async (db, progressCallback) => {
|
|
12664
12818
|
const result = {};
|
|
12665
12819
|
const allTables = await db.query(
|
|
12666
12820
|
`SELECT table_schema, table_name FROM information_schema.tables WHERE table_schema != 'pg_catalog' and table_schema != 'information_schema';`
|
|
12667
12821
|
);
|
|
12822
|
+
const schemas = new Set(allTables.rows.map((it) => it.table_schema));
|
|
12668
12823
|
progressCallback("tables", allTables.rows.length, "done");
|
|
12669
12824
|
let columnsCount = 0;
|
|
12670
12825
|
let indexesCount = 0;
|
|
@@ -12672,6 +12827,7 @@ var init_pgSerializer = __esm({
|
|
|
12672
12827
|
const all = allTables.rows.map((row) => {
|
|
12673
12828
|
return new Promise(async (res, rej) => {
|
|
12674
12829
|
const tableName = row.table_name;
|
|
12830
|
+
const tableSchema = row.table_schema;
|
|
12675
12831
|
try {
|
|
12676
12832
|
const columnToReturn = {};
|
|
12677
12833
|
const indexToReturn = {};
|
|
@@ -12827,6 +12983,7 @@ var init_pgSerializer = __esm({
|
|
|
12827
12983
|
progressCallback("indexes", indexesCount, "fetching");
|
|
12828
12984
|
result[tableName] = {
|
|
12829
12985
|
name: tableName,
|
|
12986
|
+
schema: tableSchema,
|
|
12830
12987
|
columns: columnToReturn,
|
|
12831
12988
|
indexes: indexToReturn,
|
|
12832
12989
|
foreignKeys: foreignKeysToReturn
|
|
@@ -12865,7 +13022,14 @@ var init_pgSerializer = __esm({
|
|
|
12865
13022
|
}
|
|
12866
13023
|
}
|
|
12867
13024
|
progressCallback("enums", Object.keys(enumsToReturn).length, "done");
|
|
12868
|
-
|
|
13025
|
+
const schemasObject = Object.fromEntries([...schemas].map((it) => [it, it]));
|
|
13026
|
+
return {
|
|
13027
|
+
version: "4",
|
|
13028
|
+
dialect: "pg",
|
|
13029
|
+
tables: result,
|
|
13030
|
+
enums: enumsToReturn,
|
|
13031
|
+
schemas: schemasObject
|
|
13032
|
+
};
|
|
12869
13033
|
};
|
|
12870
13034
|
}
|
|
12871
13035
|
});
|
|
@@ -13008,51 +13172,54 @@ var init_sqliteSerializer = __esm({
|
|
|
13008
13172
|
});
|
|
13009
13173
|
|
|
13010
13174
|
// src/serializer/index.ts
|
|
13011
|
-
var import_fs2, import_node, import_path, serializeMySql, serializePg, serializeSQLite, prepareFilenames;
|
|
13175
|
+
var import_fs2, import_node, import_path, safeRegister, serializeMySql, serializePg, serializeSQLite, prepareFilenames;
|
|
13012
13176
|
var init_serializer = __esm({
|
|
13013
13177
|
"src/serializer/index.ts"() {
|
|
13014
13178
|
import_fs2 = __toESM(require("fs"));
|
|
13015
13179
|
import_node = __toESM(require_node2());
|
|
13016
13180
|
import_path = __toESM(require("path"));
|
|
13017
|
-
|
|
13018
|
-
|
|
13019
|
-
|
|
13020
|
-
|
|
13021
|
-
|
|
13022
|
-
|
|
13181
|
+
safeRegister = () => {
|
|
13182
|
+
try {
|
|
13183
|
+
const { unregister } = (0, import_node.register)({
|
|
13184
|
+
target: "node14",
|
|
13185
|
+
loader: "ts"
|
|
13186
|
+
});
|
|
13187
|
+
return { unregister };
|
|
13188
|
+
} catch (e) {
|
|
13189
|
+
return { unregister: () => {
|
|
13190
|
+
} };
|
|
13191
|
+
}
|
|
13192
|
+
};
|
|
13193
|
+
serializeMySql = (path5) => {
|
|
13194
|
+
const filenames = prepareFilenames(path5);
|
|
13195
|
+
const { unregister } = safeRegister();
|
|
13023
13196
|
const { prepareFromMySqlImports: prepareFromMySqlImports2 } = (init_mysqlImports(), __toCommonJS(mysqlImports_exports));
|
|
13024
13197
|
const { generateMySqlSnapshot: generateMySqlSnapshot2 } = (init_mysqlSerializer(), __toCommonJS(mysqlSerializer_exports));
|
|
13025
|
-
const { tables, enums } = prepareFromMySqlImports2(filenames);
|
|
13198
|
+
const { tables, enums, schemas } = prepareFromMySqlImports2(filenames);
|
|
13026
13199
|
unregister();
|
|
13027
|
-
return generateMySqlSnapshot2(tables, enums);
|
|
13200
|
+
return generateMySqlSnapshot2(tables, enums, schemas);
|
|
13028
13201
|
};
|
|
13029
|
-
serializePg = (
|
|
13030
|
-
const filenames = prepareFilenames(
|
|
13031
|
-
const { unregister } = (
|
|
13032
|
-
target: "node14",
|
|
13033
|
-
loader: "ts"
|
|
13034
|
-
});
|
|
13202
|
+
serializePg = (path5) => {
|
|
13203
|
+
const filenames = prepareFilenames(path5);
|
|
13204
|
+
const { unregister } = safeRegister();
|
|
13035
13205
|
const { prepareFromPgImports: prepareFromPgImports2 } = (init_pgImports(), __toCommonJS(pgImports_exports));
|
|
13036
13206
|
const { generatePgSnapshot: generatePgSnapshot2 } = (init_pgSerializer(), __toCommonJS(pgSerializer_exports));
|
|
13037
|
-
const { tables, enums } = prepareFromPgImports2(filenames);
|
|
13207
|
+
const { tables, enums, schemas } = prepareFromPgImports2(filenames);
|
|
13038
13208
|
unregister();
|
|
13039
|
-
return generatePgSnapshot2(tables, enums);
|
|
13209
|
+
return generatePgSnapshot2(tables, enums, schemas);
|
|
13040
13210
|
};
|
|
13041
|
-
serializeSQLite = (
|
|
13042
|
-
const filenames = prepareFilenames(
|
|
13043
|
-
const { unregister } = (
|
|
13044
|
-
target: "node14",
|
|
13045
|
-
loader: "ts"
|
|
13046
|
-
});
|
|
13211
|
+
serializeSQLite = (path5) => {
|
|
13212
|
+
const filenames = prepareFilenames(path5);
|
|
13213
|
+
const { unregister } = safeRegister();
|
|
13047
13214
|
const { prepareFromSqliteImports: prepareFromSqliteImports2 } = (init_sqliteImports(), __toCommonJS(sqliteImports_exports));
|
|
13048
13215
|
const { generateSqliteSnapshot: generateSqliteSnapshot2 } = (init_sqliteSerializer(), __toCommonJS(sqliteSerializer_exports));
|
|
13049
13216
|
const { tables, enums } = prepareFromSqliteImports2(filenames);
|
|
13050
13217
|
unregister();
|
|
13051
13218
|
return generateSqliteSnapshot2(tables, enums);
|
|
13052
13219
|
};
|
|
13053
|
-
prepareFilenames = (
|
|
13054
|
-
const fileName = import_fs2.default.lstatSync(
|
|
13055
|
-
const filenames = fileName ? [fileName] : import_fs2.default.readdirSync(
|
|
13220
|
+
prepareFilenames = (path5) => {
|
|
13221
|
+
const fileName = import_fs2.default.lstatSync(path5).isDirectory() ? null : import_path.default.resolve(path5);
|
|
13222
|
+
const filenames = fileName ? [fileName] : import_fs2.default.readdirSync(path5).map((it) => import_path.default.join(import_path.default.resolve(path5), it));
|
|
13056
13223
|
return filenames;
|
|
13057
13224
|
};
|
|
13058
13225
|
}
|
|
@@ -13069,7 +13236,7 @@ var init_migrationPreparator = __esm({
|
|
|
13069
13236
|
init_sqliteSchema();
|
|
13070
13237
|
init_mysqlSchema();
|
|
13071
13238
|
prepareMySqlMigrationSnapshot = (migrationFolders, outFolder = "drizzle", schemaPath) => {
|
|
13072
|
-
const prevSnapshot =
|
|
13239
|
+
const prevSnapshot = mysqlSchema.parse(
|
|
13073
13240
|
preparePrevSnapshot(outFolder, migrationFolders, dryMySql)
|
|
13074
13241
|
);
|
|
13075
13242
|
const serialized = serializeMySql(schemaPath);
|
|
@@ -13124,7 +13291,7 @@ var init_migrationPreparator = __esm({
|
|
|
13124
13291
|
});
|
|
13125
13292
|
|
|
13126
13293
|
// src/sqlgenerator.ts
|
|
13127
|
-
var pgNativeTypes, Convertor, PgCreateTableConvertor, MySqlCreateTableConvertor, SQLiteCreateTableConvertor, CreateTypeEnumConvertor, AlterTypeAddValueConvertor, DropTableConvertor, PgRenameTableConvertor, SqliteRenameTableConvertor, MySqlRenameTableConvertor, PgAlterTableRenameColumnConvertor, MySqlAlterTableRenameColumnConvertor, SQLiteAlterTableRenameColumnConvertor, PgAlterTableDropColumnConvertor, MySqlAlterTableDropColumnConvertor, SQLiteAlterTableDropColumnConvertor, PgAlterTableAddColumnConvertor, MySqlAlterTableAddColumnConvertor, SQLiteAlterTableAddColumnConvertor, PgAlterTableAlterColumnSetTypeConvertor, SQLiteAlterTableAlterColumnSetTypeConvertor, PgAlterTableAlterColumnSetDefaultConvertor, SqliteAlterTableAlterColumnSetDefaultConvertor, PgAlterTableAlterColumnDropDefaultConvertor, SqliteAlterTableAlterColumnDropDefaultConvertor, PgAlterTableAlterColumnSetNotNullConvertor, SqliteAlterTableAlterColumnSetNotNullConvertor, PgAlterTableAlterColumnDropNotNullConvertor, SqliteAlterTableAlterColumnDropNotNullConvertor, PgCreateForeignKeyConvertor, SqliteCreateForeignKeyConvertor, MySqlCreateForeignKeyConvertor, PgAlterForeignKeyConvertor, SqliteAlterForeignKeyConvertor, PgDeleteForeignKeyConvertor, SqliteDeleteForeignKeyConvertor, MySqlDeleteForeignKeyConvertor, CreatePgIndexConvertor, CreateMySqlIndexConvertor, CreateSqliteIndexConvertor, PgDropIndexConvertor, SqliteDropIndexConvertor, convertors, fromJson;
|
|
13294
|
+
var pgNativeTypes, Convertor, PgCreateTableConvertor, MySqlCreateTableConvertor, SQLiteCreateTableConvertor, CreateTypeEnumConvertor, AlterTypeAddValueConvertor, DropTableConvertor, PgRenameTableConvertor, SqliteRenameTableConvertor, MySqlRenameTableConvertor, PgAlterTableRenameColumnConvertor, MySqlAlterTableRenameColumnConvertor, SQLiteAlterTableRenameColumnConvertor, PgAlterTableDropColumnConvertor, MySqlAlterTableDropColumnConvertor, SQLiteAlterTableDropColumnConvertor, PgAlterTableAddColumnConvertor, MySqlAlterTableAddColumnConvertor, SQLiteAlterTableAddColumnConvertor, PgAlterTableAlterColumnSetTypeConvertor, SQLiteAlterTableAlterColumnSetTypeConvertor, PgAlterTableAlterColumnSetDefaultConvertor, SqliteAlterTableAlterColumnSetDefaultConvertor, PgAlterTableAlterColumnDropDefaultConvertor, SqliteAlterTableAlterColumnDropDefaultConvertor, SqliteAlterTableCreateCompositePrimaryKeyConvertor, SqliteAlterTableDeleteCompositePrimaryKeyConvertor, SqliteAlterTableAlterCompositePrimaryKeyConvertor, PgAlterTableAlterColumnSetNotNullConvertor, SqliteAlterTableAlterColumnSetNotNullConvertor, PgAlterTableAlterColumnDropNotNullConvertor, SqliteAlterTableAlterColumnDropNotNullConvertor, PgCreateForeignKeyConvertor, SqliteCreateForeignKeyConvertor, MySqlCreateForeignKeyConvertor, PgAlterForeignKeyConvertor, SqliteAlterForeignKeyConvertor, PgDeleteForeignKeyConvertor, SqliteDeleteForeignKeyConvertor, MySqlDeleteForeignKeyConvertor, CreatePgIndexConvertor, CreateMySqlIndexConvertor, CreateSqliteIndexConvertor, PgDropIndexConvertor, PgCreateSchemaConvertor, PgRenameSchemaConvertor, PgDropSchemaConvertor, PgAlterTableSetSchemaConvertor, PgAlterTableSetNewSchemaConvertor, PgAlterTableRemoveFromSchemaConvertor, SqliteDropIndexConvertor, MysqlCreateSchemaConvertor, MysqlDropSchemaConvertor, MysqlAlterTableSetSchemaConvertor, MysqlAlterTableSetNewSchemaConvertor, MysqlAlterTableRemoveFromSchemaConvertor, convertors, fromJson;
|
|
13128
13295
|
var init_sqlgenerator = __esm({
|
|
13129
13296
|
"src/sqlgenerator.ts"() {
|
|
13130
13297
|
init_mysqlSchema();
|
|
@@ -13165,9 +13332,10 @@ var init_sqlgenerator = __esm({
|
|
|
13165
13332
|
return statement.type === "create_table" && dialect6 === "pg";
|
|
13166
13333
|
}
|
|
13167
13334
|
convert(st) {
|
|
13168
|
-
const { tableName, columns } = st;
|
|
13335
|
+
const { tableName, schema: schema4, columns } = st;
|
|
13169
13336
|
let statement = "";
|
|
13170
|
-
|
|
13337
|
+
const name = schema4 ? `"${schema4}"."${tableName}"` : `"${tableName}"`;
|
|
13338
|
+
statement += `CREATE TABLE IF NOT EXISTS ${name} (
|
|
13171
13339
|
`;
|
|
13172
13340
|
for (let i = 0; i < columns.length; i++) {
|
|
13173
13341
|
const column5 = columns[i];
|
|
@@ -13189,9 +13357,10 @@ var init_sqlgenerator = __esm({
|
|
|
13189
13357
|
return statement.type === "create_table" && dialect6 === "mysql";
|
|
13190
13358
|
}
|
|
13191
13359
|
convert(st) {
|
|
13192
|
-
const { tableName, columns } = st;
|
|
13360
|
+
const { tableName, columns, schema: schema4 } = st;
|
|
13193
13361
|
let statement = "";
|
|
13194
|
-
|
|
13362
|
+
const tName = schema4 ? `\`${schema4}\`.\`${tableName}\`` : `\`${tableName}\``;
|
|
13363
|
+
statement += `CREATE TABLE ${tName} (
|
|
13195
13364
|
`;
|
|
13196
13365
|
for (let i = 0; i < columns.length; i++) {
|
|
13197
13366
|
const column5 = columns[i];
|
|
@@ -13303,8 +13472,10 @@ var init_sqlgenerator = __esm({
|
|
|
13303
13472
|
return statement.type === "rename_table" && dialect6 === "pg";
|
|
13304
13473
|
}
|
|
13305
13474
|
convert(statement) {
|
|
13306
|
-
const { tableNameFrom, tableNameTo } = statement;
|
|
13307
|
-
|
|
13475
|
+
const { tableNameFrom, tableNameTo, fromSchema: schema4 } = statement;
|
|
13476
|
+
const from = schema4 ? `"${schema4}"."${tableNameFrom}"` : `"${tableNameFrom}"`;
|
|
13477
|
+
const to = schema4 ? `"${schema4}"."${tableNameTo}"` : `"${tableNameTo}"`;
|
|
13478
|
+
return `ALTER TABLE ${from} RENAME TO ${to};`;
|
|
13308
13479
|
}
|
|
13309
13480
|
};
|
|
13310
13481
|
SqliteRenameTableConvertor = class extends Convertor {
|
|
@@ -13321,8 +13492,11 @@ var init_sqlgenerator = __esm({
|
|
|
13321
13492
|
return statement.type === "rename_table" && dialect6 === "mysql";
|
|
13322
13493
|
}
|
|
13323
13494
|
convert(statement) {
|
|
13324
|
-
const { tableNameFrom, tableNameTo } = statement;
|
|
13325
|
-
|
|
13495
|
+
const { tableNameFrom, tableNameTo, fromSchema, toSchema } = statement;
|
|
13496
|
+
const from = fromSchema ? `\`${fromSchema}\`.\`${tableNameFrom}\`` : `\`${tableNameFrom}\``;
|
|
13497
|
+
const to = fromSchema ? `\`${fromSchema}\`.\`${tableNameTo}\`` : `\`${tableNameTo}\``;
|
|
13498
|
+
console.log("MySqlRenameTableConvertor");
|
|
13499
|
+
return `RENAME TABLE ${from} TO ${to};`;
|
|
13326
13500
|
}
|
|
13327
13501
|
};
|
|
13328
13502
|
PgAlterTableRenameColumnConvertor = class extends Convertor {
|
|
@@ -13493,6 +13667,85 @@ var init_sqlgenerator = __esm({
|
|
|
13493
13667
|
*/`;
|
|
13494
13668
|
}
|
|
13495
13669
|
};
|
|
13670
|
+
SqliteAlterTableCreateCompositePrimaryKeyConvertor = class extends Convertor {
|
|
13671
|
+
can(statement, dialect6) {
|
|
13672
|
+
return statement.type === "create_composite_pk" && dialect6 === "sqlite";
|
|
13673
|
+
}
|
|
13674
|
+
convert(statement) {
|
|
13675
|
+
let msg = "/*\n";
|
|
13676
|
+
msg += `You're trying to add PRIMARY KEY(${statement.data}) to '${statement.tableName}' table
|
|
13677
|
+
`;
|
|
13678
|
+
msg += "SQLite does not support adding primary key to an already created table\n";
|
|
13679
|
+
msg += "You can do it in 3 steps with drizzle orm:\n";
|
|
13680
|
+
msg += " - create new mirror table with needed pk, rename current table to old_table, generate SQL\n";
|
|
13681
|
+
msg += " - migrate old data from one table to another\n";
|
|
13682
|
+
msg += " - delete old_table in schema, generate sql\n\n";
|
|
13683
|
+
msg += "or create manual migration like below:\n\n";
|
|
13684
|
+
msg += "ALTER TABLE table_name RENAME TO old_table;\n";
|
|
13685
|
+
msg += "CREATE TABLE table_name (\n";
|
|
13686
|
+
msg += " column1 datatype [ NULL | NOT NULL ],\n";
|
|
13687
|
+
msg += " column2 datatype [ NULL | NOT NULL ],\n";
|
|
13688
|
+
msg += " ...\n";
|
|
13689
|
+
msg += " PRIMARY KEY (pk_col1, pk_col2, ... pk_col_n)\n";
|
|
13690
|
+
msg += " );\n";
|
|
13691
|
+
msg += "INSERT INTO table_name SELECT * FROM old_table;\n\n";
|
|
13692
|
+
msg += "Due to that we don't generate migration automatically and it has to be done manually\n";
|
|
13693
|
+
msg += "*/\n";
|
|
13694
|
+
return msg;
|
|
13695
|
+
}
|
|
13696
|
+
};
|
|
13697
|
+
SqliteAlterTableDeleteCompositePrimaryKeyConvertor = class extends Convertor {
|
|
13698
|
+
can(statement, dialect6) {
|
|
13699
|
+
return statement.type === "delete_composite_pk" && dialect6 === "sqlite";
|
|
13700
|
+
}
|
|
13701
|
+
convert(statement) {
|
|
13702
|
+
let msg = "/*\n";
|
|
13703
|
+
msg += `You're trying to delete PRIMARY KEY(${statement.data}) from '${statement.tableName}' table
|
|
13704
|
+
`;
|
|
13705
|
+
msg += "SQLite does not supportprimary key deletion from existing table\n";
|
|
13706
|
+
msg += "You can do it in 3 steps with drizzle orm:\n";
|
|
13707
|
+
msg += " - create new mirror table table without pk, rename current table to old_table, generate SQL\n";
|
|
13708
|
+
msg += " - migrate old data from one table to another\n";
|
|
13709
|
+
msg += " - delete old_table in schema, generate sql\n\n";
|
|
13710
|
+
msg += "or create manual migration like below:\n\n";
|
|
13711
|
+
msg += "ALTER TABLE table_name RENAME TO old_table;\n";
|
|
13712
|
+
msg += "CREATE TABLE table_name (\n";
|
|
13713
|
+
msg += " column1 datatype [ NULL | NOT NULL ],\n";
|
|
13714
|
+
msg += " column2 datatype [ NULL | NOT NULL ],\n";
|
|
13715
|
+
msg += " ...\n";
|
|
13716
|
+
msg += " PRIMARY KEY (pk_col1, pk_col2, ... pk_col_n)\n";
|
|
13717
|
+
msg += " );\n";
|
|
13718
|
+
msg += "INSERT INTO table_name SELECT * FROM old_table;\n\n";
|
|
13719
|
+
msg += "Due to that we don't generate migration automatically and it has to be done manually\n";
|
|
13720
|
+
msg += "*/\n";
|
|
13721
|
+
return msg;
|
|
13722
|
+
}
|
|
13723
|
+
};
|
|
13724
|
+
SqliteAlterTableAlterCompositePrimaryKeyConvertor = class extends Convertor {
|
|
13725
|
+
can(statement, dialect6) {
|
|
13726
|
+
return statement.type === "alter_composite_pk" && dialect6 === "sqlite";
|
|
13727
|
+
}
|
|
13728
|
+
convert(statement) {
|
|
13729
|
+
let msg = "/*\n";
|
|
13730
|
+
msg += "SQLite does not support altering primary key\n";
|
|
13731
|
+
msg += "You can do it in 3 steps with drizzle orm:\n";
|
|
13732
|
+
msg += " - create new mirror table with needed pk, rename current table to old_table, generate SQL\n";
|
|
13733
|
+
msg += " - migrate old data from one table to another\n";
|
|
13734
|
+
msg += " - delete old_table in schema, generate sql\n\n";
|
|
13735
|
+
msg += "or create manual migration like below:\n\n";
|
|
13736
|
+
msg += "ALTER TABLE table_name RENAME TO old_table;\n";
|
|
13737
|
+
msg += "CREATE TABLE table_name (\n";
|
|
13738
|
+
msg += " column1 datatype [ NULL | NOT NULL ],\n";
|
|
13739
|
+
msg += " column2 datatype [ NULL | NOT NULL ],\n";
|
|
13740
|
+
msg += " ...\n";
|
|
13741
|
+
msg += " PRIMARY KEY (pk_col1, pk_col2, ... pk_col_n)\n";
|
|
13742
|
+
msg += " );\n";
|
|
13743
|
+
msg += "INSERT INTO table_name SELECT * FROM old_table;\n\n";
|
|
13744
|
+
msg += "Due to that we don't generate migration automatically and it has to be done manually\n";
|
|
13745
|
+
msg += "*/\n";
|
|
13746
|
+
return msg;
|
|
13747
|
+
}
|
|
13748
|
+
};
|
|
13496
13749
|
PgAlterTableAlterColumnSetNotNullConvertor = class extends Convertor {
|
|
13497
13750
|
can(statement, dialect6) {
|
|
13498
13751
|
return statement.type === "alter_table_alter_column_set_notnull" && dialect6 === "pg";
|
|
@@ -13610,10 +13863,10 @@ var init_sqlgenerator = __esm({
|
|
|
13610
13863
|
convert(statement) {
|
|
13611
13864
|
const newFk = PgSquasher.unsquashFK(statement.data);
|
|
13612
13865
|
const oldFk = PgSquasher.unsquashFK(statement.oldFkey);
|
|
13613
|
-
let sql = `ALTER TABLE ${oldFk.tableFrom} DROP
|
|
13866
|
+
let sql = `ALTER TABLE ${oldFk.tableFrom} DROP CONSTRAINT ${oldFk.name};
|
|
13614
13867
|
`;
|
|
13615
|
-
const onDeleteStatement = newFk.onDelete
|
|
13616
|
-
const onUpdateStatement = newFk.onUpdate
|
|
13868
|
+
const onDeleteStatement = newFk.onDelete ? `ON DELETE ${newFk.onDelete}` : "";
|
|
13869
|
+
const onUpdateStatement = newFk.onUpdate ? `ON UPDATE ${newFk.onDelete}` : "";
|
|
13617
13870
|
const fromColumnsString = newFk.columnsFrom.map((it) => `"${it}"`).join(",");
|
|
13618
13871
|
const toColumnsString = newFk.columnsTo.map((it) => `"${it}"`).join(",");
|
|
13619
13872
|
const alterStatement = `ALTER TABLE ${newFk.tableFrom} ADD CONSTRAINT ${newFk.name} FOREIGN KEY (${fromColumnsString}) REFERENCES ${newFk.tableTo}(${toColumnsString}) ${onDeleteStatement} ${onUpdateStatement}`.replace(/ +/g, " ").trim();
|
|
@@ -13681,55 +13934,173 @@ var init_sqlgenerator = __esm({
|
|
|
13681
13934
|
return statement.type === "create_index" && dialect6 === "pg";
|
|
13682
13935
|
}
|
|
13683
13936
|
convert(statement) {
|
|
13684
|
-
const { name, columns, isUnique } = PgSquasher.unsquashIdx(statement.data);
|
|
13685
|
-
const indexPart = isUnique ? "UNIQUE INDEX" : "INDEX";
|
|
13686
|
-
const value = columns.map((it) => `"${it}"`).join(",");
|
|
13687
|
-
return `CREATE ${indexPart} IF NOT EXISTS ${name} ON ${statement.tableName} (${value});`;
|
|
13937
|
+
const { name, columns, isUnique } = PgSquasher.unsquashIdx(statement.data);
|
|
13938
|
+
const indexPart = isUnique ? "UNIQUE INDEX" : "INDEX";
|
|
13939
|
+
const value = columns.map((it) => `"${it}"`).join(",");
|
|
13940
|
+
return `CREATE ${indexPart} IF NOT EXISTS ${name} ON ${statement.tableName} (${value});`;
|
|
13941
|
+
}
|
|
13942
|
+
};
|
|
13943
|
+
CreateMySqlIndexConvertor = class extends Convertor {
|
|
13944
|
+
can(statement, dialect6) {
|
|
13945
|
+
return statement.type === "create_index" && dialect6 === "mysql";
|
|
13946
|
+
}
|
|
13947
|
+
convert(statement) {
|
|
13948
|
+
const { name, columns, isUnique } = MySqlSquasher.unsquashIdx(
|
|
13949
|
+
statement.data
|
|
13950
|
+
);
|
|
13951
|
+
const indexPart = isUnique ? "UNIQUE INDEX" : "INDEX";
|
|
13952
|
+
const value = columns.map((it) => `\`${it}\``).join(",");
|
|
13953
|
+
return `CREATE ${indexPart} ${name} ON ${statement.tableName} (${value});`;
|
|
13954
|
+
}
|
|
13955
|
+
};
|
|
13956
|
+
CreateSqliteIndexConvertor = class extends Convertor {
|
|
13957
|
+
can(statement, dialect6) {
|
|
13958
|
+
return statement.type === "create_index" && dialect6 === "sqlite";
|
|
13959
|
+
}
|
|
13960
|
+
convert(statement) {
|
|
13961
|
+
const { name, columns, isUnique, where } = SQLiteSquasher.unsquashIdx(
|
|
13962
|
+
statement.data
|
|
13963
|
+
);
|
|
13964
|
+
const indexPart = isUnique ? "UNIQUE INDEX" : "INDEX";
|
|
13965
|
+
const whereStatement = where ? ` WHERE ${where}` : "";
|
|
13966
|
+
const value = columns.map((it) => `\`${it}\``).join(",");
|
|
13967
|
+
return `CREATE ${indexPart} ${name} ON ${statement.tableName} (${value})${whereStatement};`;
|
|
13968
|
+
}
|
|
13969
|
+
};
|
|
13970
|
+
PgDropIndexConvertor = class extends Convertor {
|
|
13971
|
+
can(statement, dialect6) {
|
|
13972
|
+
return statement.type === "drop_index" && dialect6 === "pg";
|
|
13973
|
+
}
|
|
13974
|
+
convert(statement) {
|
|
13975
|
+
const { name } = PgSquasher.unsquashIdx(statement.data);
|
|
13976
|
+
return `DROP INDEX IF EXISTS ${name};`;
|
|
13977
|
+
}
|
|
13978
|
+
};
|
|
13979
|
+
PgCreateSchemaConvertor = class extends Convertor {
|
|
13980
|
+
can(statement, dialect6) {
|
|
13981
|
+
return statement.type === "create_schema" && dialect6 === "pg";
|
|
13982
|
+
}
|
|
13983
|
+
convert(statement) {
|
|
13984
|
+
const { name } = statement;
|
|
13985
|
+
return `CREATE SCHEMA "${name}";
|
|
13986
|
+
`;
|
|
13987
|
+
}
|
|
13988
|
+
};
|
|
13989
|
+
PgRenameSchemaConvertor = class extends Convertor {
|
|
13990
|
+
can(statement, dialect6) {
|
|
13991
|
+
return statement.type === "rename_schema" && dialect6 === "pg";
|
|
13992
|
+
}
|
|
13993
|
+
convert(statement) {
|
|
13994
|
+
const { from, to } = statement;
|
|
13995
|
+
return `ALTER SCHEMA "${from}" RENAME TO "${to}";
|
|
13996
|
+
`;
|
|
13997
|
+
}
|
|
13998
|
+
};
|
|
13999
|
+
PgDropSchemaConvertor = class extends Convertor {
|
|
14000
|
+
can(statement, dialect6) {
|
|
14001
|
+
return statement.type === "drop_schema" && dialect6 === "pg";
|
|
14002
|
+
}
|
|
14003
|
+
convert(statement) {
|
|
14004
|
+
const { name } = statement;
|
|
14005
|
+
return `DROP SCHEMA "${name}";
|
|
14006
|
+
`;
|
|
14007
|
+
}
|
|
14008
|
+
};
|
|
14009
|
+
PgAlterTableSetSchemaConvertor = class extends Convertor {
|
|
14010
|
+
can(statement, dialect6) {
|
|
14011
|
+
return statement.type === "alter_table_set_schema" && dialect6 === "pg";
|
|
14012
|
+
}
|
|
14013
|
+
convert(statement) {
|
|
14014
|
+
const { tableName, schema: schema4 } = statement;
|
|
14015
|
+
return `ALTER TABLE "${tableName}" SET SCHEMA "${schema4}";
|
|
14016
|
+
`;
|
|
14017
|
+
}
|
|
14018
|
+
};
|
|
14019
|
+
PgAlterTableSetNewSchemaConvertor = class extends Convertor {
|
|
14020
|
+
can(statement, dialect6) {
|
|
14021
|
+
return statement.type === "alter_table_set_new_schema" && dialect6 === "pg";
|
|
14022
|
+
}
|
|
14023
|
+
convert(statement) {
|
|
14024
|
+
const { tableName, to } = statement;
|
|
14025
|
+
return `ALTER TABLE "${tableName}" SET SCHEMA "${to}";
|
|
14026
|
+
`;
|
|
14027
|
+
}
|
|
14028
|
+
};
|
|
14029
|
+
PgAlterTableRemoveFromSchemaConvertor = class extends Convertor {
|
|
14030
|
+
can(statement, dialect6) {
|
|
14031
|
+
return statement.type === "alter_table_remove_from_schema" && dialect6 === "pg";
|
|
14032
|
+
}
|
|
14033
|
+
convert(statement) {
|
|
14034
|
+
const { tableName } = statement;
|
|
14035
|
+
return `ALTER TABLE "${tableName}" SET SCHEMA public;
|
|
14036
|
+
`;
|
|
14037
|
+
}
|
|
14038
|
+
};
|
|
14039
|
+
SqliteDropIndexConvertor = class extends Convertor {
|
|
14040
|
+
can(statement, dialect6) {
|
|
14041
|
+
return statement.type === "drop_index" && dialect6 === "sqlite";
|
|
14042
|
+
}
|
|
14043
|
+
convert(statement) {
|
|
14044
|
+
const { name } = PgSquasher.unsquashIdx(statement.data);
|
|
14045
|
+
return `DROP INDEX IF EXISTS ${name};`;
|
|
14046
|
+
}
|
|
14047
|
+
};
|
|
14048
|
+
MysqlCreateSchemaConvertor = class extends Convertor {
|
|
14049
|
+
can(statement, dialect6) {
|
|
14050
|
+
return statement.type === "create_schema" && dialect6 === "mysql";
|
|
14051
|
+
}
|
|
14052
|
+
convert(statement) {
|
|
14053
|
+
const { name } = statement;
|
|
14054
|
+
return `CREATE DATABASE \`${name}\`;
|
|
14055
|
+
`;
|
|
13688
14056
|
}
|
|
13689
14057
|
};
|
|
13690
|
-
|
|
14058
|
+
MysqlDropSchemaConvertor = class extends Convertor {
|
|
13691
14059
|
can(statement, dialect6) {
|
|
13692
|
-
return statement.type === "
|
|
14060
|
+
return statement.type === "drop_schema" && dialect6 === "mysql";
|
|
13693
14061
|
}
|
|
13694
14062
|
convert(statement) {
|
|
13695
|
-
const { name
|
|
13696
|
-
|
|
13697
|
-
|
|
13698
|
-
const indexPart = isUnique ? "UNIQUE INDEX" : "INDEX";
|
|
13699
|
-
const value = columns.map((it) => `\`${it}\``).join(",");
|
|
13700
|
-
return `CREATE ${indexPart} ${name} ON ${statement.tableName} (${value});`;
|
|
14063
|
+
const { name } = statement;
|
|
14064
|
+
return `DROP DATABASE \`${name}\`;
|
|
14065
|
+
`;
|
|
13701
14066
|
}
|
|
13702
14067
|
};
|
|
13703
|
-
|
|
14068
|
+
MysqlAlterTableSetSchemaConvertor = class extends Convertor {
|
|
13704
14069
|
can(statement, dialect6) {
|
|
13705
|
-
return statement.type === "
|
|
14070
|
+
return statement.type === "alter_table_set_schema" && dialect6 === "mysql";
|
|
13706
14071
|
}
|
|
13707
14072
|
convert(statement) {
|
|
13708
|
-
const {
|
|
13709
|
-
|
|
13710
|
-
|
|
13711
|
-
|
|
13712
|
-
|
|
13713
|
-
|
|
13714
|
-
return `CREATE ${indexPart} ${name} ON ${statement.tableName} (${value})${whereStatement};`;
|
|
14073
|
+
const { tableName, schema: schema4 } = statement;
|
|
14074
|
+
const nameFrom = `\`${tableName}\``;
|
|
14075
|
+
const nameTo = `\`${schema4}\`.\`${tableName}\``;
|
|
14076
|
+
console.log("MysqlAlterTableSetSchemaConvertor");
|
|
14077
|
+
return `RENAME TABLE ${nameFrom} TO ${nameTo};
|
|
14078
|
+
`;
|
|
13715
14079
|
}
|
|
13716
14080
|
};
|
|
13717
|
-
|
|
14081
|
+
MysqlAlterTableSetNewSchemaConvertor = class extends Convertor {
|
|
13718
14082
|
can(statement, dialect6) {
|
|
13719
|
-
return statement.type === "
|
|
14083
|
+
return statement.type === "alter_table_set_new_schema" && dialect6 === "mysql";
|
|
13720
14084
|
}
|
|
13721
14085
|
convert(statement) {
|
|
13722
|
-
const {
|
|
13723
|
-
|
|
14086
|
+
const { tableName, to, from } = statement;
|
|
14087
|
+
const nameFrom = from ? `\`${from}\`.\`${tableName}\`` : `\`${tableName}\``;
|
|
14088
|
+
const nameTo = to ? `\`${to}\`.\`${tableName}\`` : `\`${tableName}\``;
|
|
14089
|
+
console.log("MysqlAlterTableSetNewSchemaConvertor");
|
|
14090
|
+
return `RENAME TABLE ${nameFrom} TO ${nameTo};
|
|
14091
|
+
`;
|
|
13724
14092
|
}
|
|
13725
14093
|
};
|
|
13726
|
-
|
|
14094
|
+
MysqlAlterTableRemoveFromSchemaConvertor = class extends Convertor {
|
|
13727
14095
|
can(statement, dialect6) {
|
|
13728
|
-
return statement.type === "
|
|
14096
|
+
return statement.type === "alter_table_remove_from_schema" && dialect6 === "mysql";
|
|
13729
14097
|
}
|
|
13730
14098
|
convert(statement) {
|
|
13731
|
-
const {
|
|
13732
|
-
|
|
14099
|
+
const { tableName, schema: schema4 } = statement;
|
|
14100
|
+
const nameFrom = `\`${schema4}\`.\`${tableName}\``;
|
|
14101
|
+
const nameTo = `\`${tableName}\``;
|
|
14102
|
+
return `RENAME TABLE ${nameFrom} TO ${nameTo};
|
|
14103
|
+
`;
|
|
13733
14104
|
}
|
|
13734
14105
|
};
|
|
13735
14106
|
convertors = [];
|
|
@@ -13766,6 +14137,17 @@ var init_sqlgenerator = __esm({
|
|
|
13766
14137
|
convertors.push(new PgAlterForeignKeyConvertor());
|
|
13767
14138
|
convertors.push(new PgDeleteForeignKeyConvertor());
|
|
13768
14139
|
convertors.push(new MySqlDeleteForeignKeyConvertor());
|
|
14140
|
+
convertors.push(new PgCreateSchemaConvertor());
|
|
14141
|
+
convertors.push(new PgRenameSchemaConvertor());
|
|
14142
|
+
convertors.push(new PgDropSchemaConvertor());
|
|
14143
|
+
convertors.push(new PgAlterTableSetSchemaConvertor());
|
|
14144
|
+
convertors.push(new PgAlterTableSetNewSchemaConvertor());
|
|
14145
|
+
convertors.push(new PgAlterTableRemoveFromSchemaConvertor());
|
|
14146
|
+
convertors.push(new MysqlCreateSchemaConvertor());
|
|
14147
|
+
convertors.push(new MysqlDropSchemaConvertor());
|
|
14148
|
+
convertors.push(new MysqlAlterTableSetSchemaConvertor());
|
|
14149
|
+
convertors.push(new MysqlAlterTableSetNewSchemaConvertor());
|
|
14150
|
+
convertors.push(new MysqlAlterTableRemoveFromSchemaConvertor());
|
|
13769
14151
|
convertors.push(new SQLiteAlterTableAlterColumnSetTypeConvertor());
|
|
13770
14152
|
convertors.push(new SqliteAlterForeignKeyConvertor());
|
|
13771
14153
|
convertors.push(new SqliteDeleteForeignKeyConvertor());
|
|
@@ -13774,6 +14156,9 @@ var init_sqlgenerator = __esm({
|
|
|
13774
14156
|
convertors.push(new SqliteAlterTableAlterColumnDropNotNullConvertor());
|
|
13775
14157
|
convertors.push(new SqliteAlterTableAlterColumnSetDefaultConvertor());
|
|
13776
14158
|
convertors.push(new SqliteAlterTableAlterColumnDropDefaultConvertor());
|
|
14159
|
+
convertors.push(new SqliteAlterTableCreateCompositePrimaryKeyConvertor());
|
|
14160
|
+
convertors.push(new SqliteAlterTableDeleteCompositePrimaryKeyConvertor());
|
|
14161
|
+
convertors.push(new SqliteAlterTableAlterCompositePrimaryKeyConvertor());
|
|
13777
14162
|
fromJson = (statements, dialect6) => {
|
|
13778
14163
|
const result = statements.map((statement) => {
|
|
13779
14164
|
const filtered = convertors.filter((it) => {
|
|
@@ -16753,7 +17138,7 @@ var require_get = __commonJS({
|
|
|
16753
17138
|
return lastId;
|
|
16754
17139
|
},
|
|
16755
17140
|
delete: function(id) {
|
|
16756
|
-
var index4 = 0, set = map, i, args = cache[id], length = args.length,
|
|
17141
|
+
var index4 = 0, set = map, i, args = cache[id], length = args.length, path5 = [];
|
|
16757
17142
|
if (length === 0) {
|
|
16758
17143
|
delete set[length];
|
|
16759
17144
|
} else if (set = set[length]) {
|
|
@@ -16762,7 +17147,7 @@ var require_get = __commonJS({
|
|
|
16762
17147
|
if (i === -1) {
|
|
16763
17148
|
return;
|
|
16764
17149
|
}
|
|
16765
|
-
|
|
17150
|
+
path5.push(set, i);
|
|
16766
17151
|
set = set[1][i];
|
|
16767
17152
|
++index4;
|
|
16768
17153
|
}
|
|
@@ -16773,9 +17158,9 @@ var require_get = __commonJS({
|
|
|
16773
17158
|
id = set[1][i];
|
|
16774
17159
|
set[0].splice(i, 1);
|
|
16775
17160
|
set[1].splice(i, 1);
|
|
16776
|
-
while (!set[0].length &&
|
|
16777
|
-
i =
|
|
16778
|
-
set =
|
|
17161
|
+
while (!set[0].length && path5.length) {
|
|
17162
|
+
i = path5.pop();
|
|
17163
|
+
set = path5.pop();
|
|
16779
17164
|
set[0].splice(i, 1);
|
|
16780
17165
|
set[1].splice(i, 1);
|
|
16781
17166
|
}
|
|
@@ -16867,13 +17252,13 @@ var require_get_fixed = __commonJS({
|
|
|
16867
17252
|
return lastId;
|
|
16868
17253
|
},
|
|
16869
17254
|
delete: function(id) {
|
|
16870
|
-
var index4 = 0, set = map, i,
|
|
17255
|
+
var index4 = 0, set = map, i, path5 = [], args = cache[id];
|
|
16871
17256
|
while (index4 < length - 1) {
|
|
16872
17257
|
i = indexOf.call(set[0], args[index4]);
|
|
16873
17258
|
if (i === -1) {
|
|
16874
17259
|
return;
|
|
16875
17260
|
}
|
|
16876
|
-
|
|
17261
|
+
path5.push(set, i);
|
|
16877
17262
|
set = set[1][i];
|
|
16878
17263
|
++index4;
|
|
16879
17264
|
}
|
|
@@ -16884,9 +17269,9 @@ var require_get_fixed = __commonJS({
|
|
|
16884
17269
|
id = set[1][i];
|
|
16885
17270
|
set[0].splice(i, 1);
|
|
16886
17271
|
set[1].splice(i, 1);
|
|
16887
|
-
while (!set[0].length &&
|
|
16888
|
-
i =
|
|
16889
|
-
set =
|
|
17272
|
+
while (!set[0].length && path5.length) {
|
|
17273
|
+
i = path5.pop();
|
|
17274
|
+
set = path5.pop();
|
|
16890
17275
|
set[0].splice(i, 1);
|
|
16891
17276
|
set[1].splice(i, 1);
|
|
16892
17277
|
}
|
|
@@ -19933,11 +20318,10 @@ function diffForRenamedTables(pairs) {
|
|
|
19933
20318
|
return altered;
|
|
19934
20319
|
}
|
|
19935
20320
|
function diffForRenamedTable(t1, t2) {
|
|
19936
|
-
const oldName = t1.name;
|
|
19937
20321
|
t1.name = t2.name;
|
|
19938
20322
|
const diffed = (0, import_json_diff.diff)(t1, t2) || {};
|
|
19939
20323
|
diffed.name = t2.name;
|
|
19940
|
-
return findAlternationsInTable(diffed
|
|
20324
|
+
return findAlternationsInTable(diffed);
|
|
19941
20325
|
}
|
|
19942
20326
|
function diffForRenamedColumn(t1, t2) {
|
|
19943
20327
|
const renamed = { ...t1, name: t2.name };
|
|
@@ -19946,14 +20330,16 @@ function diffForRenamedColumn(t1, t2) {
|
|
|
19946
20330
|
return alternationsInColumn(diffed);
|
|
19947
20331
|
}
|
|
19948
20332
|
function applyJsonDiff(json1, json2) {
|
|
20333
|
+
var _a, _b, _c;
|
|
19949
20334
|
json1 = JSON.parse(JSON.stringify(json1));
|
|
19950
20335
|
json2 = JSON.parse(JSON.stringify(json2));
|
|
19951
20336
|
const rawDiff = (0, import_json_diff.diff)(json1, json2);
|
|
19952
20337
|
const difference = rawDiff;
|
|
19953
20338
|
if (!difference)
|
|
19954
20339
|
return {};
|
|
19955
|
-
difference.tables = difference.tables ?
|
|
19956
|
-
difference.enums = difference.enums ?
|
|
20340
|
+
difference.tables = (_a = difference.tables) != null ? _a : {};
|
|
20341
|
+
difference.enums = (_b = difference.enums) != null ? _b : {};
|
|
20342
|
+
difference.schemas = (_c = difference.schemas) != null ? _c : {};
|
|
19957
20343
|
const tableEntries = Object.entries(difference.tables);
|
|
19958
20344
|
const addedTables = tableEntries.filter((it) => it[0].includes("__added")).map((it) => it[1]);
|
|
19959
20345
|
const deletedTables = tableEntries.filter((it) => it[0].includes("__deleted")).map((it) => it[1]);
|
|
@@ -19975,6 +20361,9 @@ function applyJsonDiff(json1, json2) {
|
|
|
19975
20361
|
const alteredTables = Object.keys(difference.tables).filter((it) => !(it.includes("__added") || it.includes("__deleted"))).map((it) => {
|
|
19976
20362
|
return { name: it, ...difference.tables[it] };
|
|
19977
20363
|
});
|
|
20364
|
+
const schemasEntries = Object.entries(difference.schemas);
|
|
20365
|
+
const addedSchemas = schemasEntries.filter((it) => it[0].endsWith("__added")).map((it) => it[1]);
|
|
20366
|
+
const deletedSchemas = schemasEntries.filter((it) => it[0].endsWith("__deleted")).map((it) => it[1]);
|
|
19978
20367
|
const alteredTablesWithColumns = alteredTables.map((table4) => findAlternationsInTable(table4));
|
|
19979
20368
|
return {
|
|
19980
20369
|
addedTables,
|
|
@@ -19982,7 +20371,9 @@ function applyJsonDiff(json1, json2) {
|
|
|
19982
20371
|
alteredTablesWithColumns,
|
|
19983
20372
|
addedEnums,
|
|
19984
20373
|
deletedEnums,
|
|
19985
|
-
alteredEnums
|
|
20374
|
+
alteredEnums,
|
|
20375
|
+
addedSchemas,
|
|
20376
|
+
deletedSchemas
|
|
19986
20377
|
};
|
|
19987
20378
|
}
|
|
19988
20379
|
var import_json_diff, findAlternationsInTable, alternationsInColumn;
|
|
@@ -19990,9 +20381,23 @@ var init_jsonDiffer = __esm({
|
|
|
19990
20381
|
"src/jsonDiffer.js"() {
|
|
19991
20382
|
import_json_diff = __toESM(require_lib());
|
|
19992
20383
|
"use-strict";
|
|
19993
|
-
findAlternationsInTable = (table4
|
|
20384
|
+
findAlternationsInTable = (table4) => {
|
|
19994
20385
|
var _a;
|
|
19995
20386
|
const columns = (_a = table4.columns) != null ? _a : {};
|
|
20387
|
+
let schema4;
|
|
20388
|
+
if ("schema" in table4) {
|
|
20389
|
+
if (table4.schema.__new) {
|
|
20390
|
+
schema4 = { type: "changed", old: table4.schema.__old, new: table4.schema.__new };
|
|
20391
|
+
} else {
|
|
20392
|
+
schema4 = { type: "deleted", value: table4.schema.__old };
|
|
20393
|
+
}
|
|
20394
|
+
}
|
|
20395
|
+
if ("schema__added" in table4) {
|
|
20396
|
+
schema4 = { type: "added", value: table4.schema__added };
|
|
20397
|
+
}
|
|
20398
|
+
if ("schema__deleted" in table4) {
|
|
20399
|
+
schema4 = { type: "deleted", value: table4.schema__deleted };
|
|
20400
|
+
}
|
|
19996
20401
|
const added = Object.keys(columns).filter((it) => it.includes("__added")).map((it) => {
|
|
19997
20402
|
return { ...columns[it] };
|
|
19998
20403
|
});
|
|
@@ -20015,9 +20420,19 @@ var init_jsonDiffer = __esm({
|
|
|
20015
20420
|
Object.entries(table4.foreignKeys__added || {}).concat(Object.entries(table4.foreignKeys || {}).filter((it) => it[0].includes("__added"))).map((entry) => [entry[0].replace("__added", ""), entry[1]])
|
|
20016
20421
|
);
|
|
20017
20422
|
const alteredForeignKeys = Object.fromEntries(Object.entries(table4.foreignKeys || {}).filter((it) => !it[0].endsWith("__added") && !it[0].endsWith("__deleted")).map((entry) => [entry[0], entry[1]]));
|
|
20423
|
+
const addedCompositePKs = Object.fromEntries(Object.entries(table4.compositePrimaryKeys || {}).filter((it) => {
|
|
20424
|
+
return it[0].endsWith("__added");
|
|
20425
|
+
}));
|
|
20426
|
+
const deletedCompositePKs = Object.fromEntries(Object.entries(table4.compositePrimaryKeys || {}).filter((it) => {
|
|
20427
|
+
return it[0].endsWith("__deleted");
|
|
20428
|
+
}));
|
|
20429
|
+
const alteredCompositePKs = Object.fromEntries(Object.entries(table4.compositePrimaryKeys || {}).filter((it) => {
|
|
20430
|
+
return !it[0].endsWith("__deleted") && !it[0].endsWith("__added");
|
|
20431
|
+
}));
|
|
20018
20432
|
const mappedAltered = altered.map((it) => alternationsInColumn(it));
|
|
20019
20433
|
return {
|
|
20020
20434
|
name: table4.name,
|
|
20435
|
+
schema: schema4,
|
|
20021
20436
|
deleted,
|
|
20022
20437
|
added,
|
|
20023
20438
|
altered: mappedAltered,
|
|
@@ -20025,7 +20440,10 @@ var init_jsonDiffer = __esm({
|
|
|
20025
20440
|
deletedIndexes,
|
|
20026
20441
|
addedForeignKeys,
|
|
20027
20442
|
deletedForeignKeys,
|
|
20028
|
-
alteredForeignKeys
|
|
20443
|
+
alteredForeignKeys,
|
|
20444
|
+
addedCompositePKs,
|
|
20445
|
+
deletedCompositePKs,
|
|
20446
|
+
alteredCompositePKs
|
|
20029
20447
|
};
|
|
20030
20448
|
};
|
|
20031
20449
|
alternationsInColumn = (column5) => {
|
|
@@ -20073,15 +20491,16 @@ var init_jsonDiffer = __esm({
|
|
|
20073
20491
|
});
|
|
20074
20492
|
|
|
20075
20493
|
// src/jsonStatements.ts
|
|
20076
|
-
var prepareCreateTableJson, prepareSQLiteCreateTable, prepareDropTableJson, prepareRenameTableJson, prepareCreateEnumJson, prepareAddValuesToEnumJson, prepareRenameColumns, prepareAlterTableColumnsJson, _prepareDropColumns, _prepareAddColumns, _prepareSQLiteAddColumns, _prepareAlterColumns, prepareCreateIndexesJson, prepareCreateReferencesJson, prepareDropReferencesJson, prepareAlterReferencesJson, prepareDropIndexesJson;
|
|
20494
|
+
var prepareCreateTableJson, prepareSQLiteCreateTable, prepareDropTableJson, prepareRenameTableJson, prepareCreateEnumJson, prepareAddValuesToEnumJson, prepareCreateSchemasJson, prepareRenameSchemasJson, prepareDeleteSchemasJson, prepareRenameColumns, prepareAlterTableColumnsJson, _prepareDropColumns, _prepareAddColumns, _prepareSQLiteAddColumns, _prepareAlterColumns, prepareCreateIndexesJson, prepareCreateReferencesJson, prepareDropReferencesJson, prepareAlterReferencesJson, prepareDropIndexesJson, prepareAddCompositePrimaryKeySqlite, prepareDeleteCompositePrimaryKeySqlite, prepareAlterCompositePrimaryKeySqlite;
|
|
20077
20495
|
var init_jsonStatements = __esm({
|
|
20078
20496
|
"src/jsonStatements.ts"() {
|
|
20079
20497
|
init_sqliteSchema();
|
|
20080
20498
|
prepareCreateTableJson = (table4) => {
|
|
20081
|
-
const { name, columns } = table4;
|
|
20499
|
+
const { name, schema: schema4, columns } = table4;
|
|
20082
20500
|
return {
|
|
20083
20501
|
type: "create_table",
|
|
20084
20502
|
tableName: name,
|
|
20503
|
+
schema: schema4,
|
|
20085
20504
|
columns: Object.values(columns)
|
|
20086
20505
|
};
|
|
20087
20506
|
};
|
|
@@ -20108,6 +20527,8 @@ var init_jsonStatements = __esm({
|
|
|
20108
20527
|
prepareRenameTableJson = (tableFrom, tableTo) => {
|
|
20109
20528
|
return {
|
|
20110
20529
|
type: "rename_table",
|
|
20530
|
+
fromSchema: tableFrom.schema,
|
|
20531
|
+
toSchema: tableTo.schema,
|
|
20111
20532
|
tableNameFrom: tableFrom.name,
|
|
20112
20533
|
tableNameTo: tableTo.name
|
|
20113
20534
|
};
|
|
@@ -20128,6 +20549,31 @@ var init_jsonStatements = __esm({
|
|
|
20128
20549
|
};
|
|
20129
20550
|
});
|
|
20130
20551
|
};
|
|
20552
|
+
prepareCreateSchemasJson = (values) => {
|
|
20553
|
+
return values.map((it) => {
|
|
20554
|
+
return {
|
|
20555
|
+
type: "create_schema",
|
|
20556
|
+
name: it
|
|
20557
|
+
};
|
|
20558
|
+
});
|
|
20559
|
+
};
|
|
20560
|
+
prepareRenameSchemasJson = (values) => {
|
|
20561
|
+
return values.map((it) => {
|
|
20562
|
+
return {
|
|
20563
|
+
type: "rename_schema",
|
|
20564
|
+
from: it.from,
|
|
20565
|
+
to: it.to
|
|
20566
|
+
};
|
|
20567
|
+
});
|
|
20568
|
+
};
|
|
20569
|
+
prepareDeleteSchemasJson = (values) => {
|
|
20570
|
+
return values.map((it) => {
|
|
20571
|
+
return {
|
|
20572
|
+
type: "drop_schema",
|
|
20573
|
+
name: it
|
|
20574
|
+
};
|
|
20575
|
+
});
|
|
20576
|
+
};
|
|
20131
20577
|
prepareRenameColumns = (tableName, pairs) => {
|
|
20132
20578
|
return pairs.map((it) => {
|
|
20133
20579
|
return {
|
|
@@ -20139,7 +20585,7 @@ var init_jsonStatements = __esm({
|
|
|
20139
20585
|
});
|
|
20140
20586
|
};
|
|
20141
20587
|
prepareAlterTableColumnsJson = (tableName, deleted, added, altered, addedFk, dialect6) => {
|
|
20142
|
-
const
|
|
20588
|
+
const addColumns = [];
|
|
20143
20589
|
const dropColumns = _prepareDropColumns(tableName, deleted);
|
|
20144
20590
|
const alterColumns = _prepareAlterColumns(tableName, altered);
|
|
20145
20591
|
if (dialect6 === "sqlite") {
|
|
@@ -20149,14 +20595,12 @@ var init_jsonStatements = __esm({
|
|
|
20149
20595
|
added,
|
|
20150
20596
|
jsonCreateFKStatements
|
|
20151
20597
|
);
|
|
20152
|
-
|
|
20598
|
+
addColumns.push(...sqliteAddColumns);
|
|
20153
20599
|
} else {
|
|
20154
|
-
const
|
|
20155
|
-
|
|
20600
|
+
const addColumns2 = _prepareAddColumns(tableName, added);
|
|
20601
|
+
addColumns2.push(...addColumns2);
|
|
20156
20602
|
}
|
|
20157
|
-
|
|
20158
|
-
statements.push(...alterColumns);
|
|
20159
|
-
return statements;
|
|
20603
|
+
return { addColumns, dropColumns, alterColumns };
|
|
20160
20604
|
};
|
|
20161
20605
|
_prepareDropColumns = (taleName, columns) => {
|
|
20162
20606
|
return columns.map((it) => {
|
|
@@ -20307,6 +20751,34 @@ var init_jsonStatements = __esm({
|
|
|
20307
20751
|
};
|
|
20308
20752
|
});
|
|
20309
20753
|
};
|
|
20754
|
+
prepareAddCompositePrimaryKeySqlite = (tableName, pks) => {
|
|
20755
|
+
return Object.values(pks).map((it) => {
|
|
20756
|
+
return {
|
|
20757
|
+
type: "create_composite_pk",
|
|
20758
|
+
tableName,
|
|
20759
|
+
data: it
|
|
20760
|
+
};
|
|
20761
|
+
});
|
|
20762
|
+
};
|
|
20763
|
+
prepareDeleteCompositePrimaryKeySqlite = (tableName, pks) => {
|
|
20764
|
+
return Object.values(pks).map((it) => {
|
|
20765
|
+
return {
|
|
20766
|
+
type: "delete_composite_pk",
|
|
20767
|
+
tableName,
|
|
20768
|
+
data: it
|
|
20769
|
+
};
|
|
20770
|
+
});
|
|
20771
|
+
};
|
|
20772
|
+
prepareAlterCompositePrimaryKeySqlite = (tableName, pks) => {
|
|
20773
|
+
return Object.values(pks).map((it) => {
|
|
20774
|
+
return {
|
|
20775
|
+
type: "alter_composite_pk",
|
|
20776
|
+
tableName,
|
|
20777
|
+
old: it.__old,
|
|
20778
|
+
new: it.__new
|
|
20779
|
+
};
|
|
20780
|
+
});
|
|
20781
|
+
};
|
|
20310
20782
|
}
|
|
20311
20783
|
});
|
|
20312
20784
|
|
|
@@ -20378,6 +20850,7 @@ var init_snapshotsDiffer = __esm({
|
|
|
20378
20850
|
}).strict();
|
|
20379
20851
|
tableScheme = objectType({
|
|
20380
20852
|
name: stringType(),
|
|
20853
|
+
schema: stringType().default(""),
|
|
20381
20854
|
columns: recordType(stringType(), columnSchema),
|
|
20382
20855
|
indexes: recordType(stringType(), stringType()),
|
|
20383
20856
|
foreignKeys: recordType(stringType(), stringType()),
|
|
@@ -20385,6 +20858,7 @@ var init_snapshotsDiffer = __esm({
|
|
|
20385
20858
|
}).strict();
|
|
20386
20859
|
alteredTableScheme = objectType({
|
|
20387
20860
|
name: stringType(),
|
|
20861
|
+
schema: makePatched(stringType()).optional(),
|
|
20388
20862
|
deleted: columnSchema.array(),
|
|
20389
20863
|
added: columnSchema.array(),
|
|
20390
20864
|
altered: alteredColumnSchema.array(),
|
|
@@ -20398,6 +20872,15 @@ var init_snapshotsDiffer = __esm({
|
|
|
20398
20872
|
__new: stringType(),
|
|
20399
20873
|
__old: stringType()
|
|
20400
20874
|
}).strict()
|
|
20875
|
+
),
|
|
20876
|
+
addedCompositePKs: recordType(stringType(), stringType()),
|
|
20877
|
+
deletedCompositePKs: recordType(stringType(), stringType()),
|
|
20878
|
+
alteredCompositePKs: recordType(
|
|
20879
|
+
stringType(),
|
|
20880
|
+
objectType({
|
|
20881
|
+
__new: stringType(),
|
|
20882
|
+
__old: stringType()
|
|
20883
|
+
})
|
|
20401
20884
|
)
|
|
20402
20885
|
}).strict();
|
|
20403
20886
|
diffResultScheme = objectType({
|
|
@@ -20406,15 +20889,25 @@ var init_snapshotsDiffer = __esm({
|
|
|
20406
20889
|
alteredTablesWithColumns: alteredTableScheme.array(),
|
|
20407
20890
|
addedEnums: enumSchema2.array(),
|
|
20408
20891
|
deletedEnums: enumSchema2.array(),
|
|
20409
|
-
alteredEnums: changedEnumSchema.array()
|
|
20892
|
+
alteredEnums: changedEnumSchema.array(),
|
|
20893
|
+
addedSchemas: stringType().array(),
|
|
20894
|
+
deletedSchemas: stringType().array()
|
|
20410
20895
|
}).strict();
|
|
20411
|
-
applySnapshotsDiff = async (json1, json2, dialect6, tablesResolver, columnsResolver) => {
|
|
20896
|
+
applySnapshotsDiff = async (json1, json2, dialect6, schemasResolver, tablesResolver, columnsResolver) => {
|
|
20412
20897
|
var _a, _b, _c, _d;
|
|
20413
20898
|
const diffResult = applyJsonDiff(json1, json2);
|
|
20414
20899
|
if (Object.keys(diffResult).length === 0) {
|
|
20415
20900
|
return "";
|
|
20416
20901
|
}
|
|
20417
20902
|
const typedResult = diffResultScheme.parse(diffResult);
|
|
20903
|
+
const {
|
|
20904
|
+
created: createdSchemas,
|
|
20905
|
+
deleted: deletedSchemas,
|
|
20906
|
+
renamed: renamedSchemas
|
|
20907
|
+
} = await schemasResolver({
|
|
20908
|
+
created: typedResult.addedSchemas.map((it) => ({ name: it })),
|
|
20909
|
+
deleted: typedResult.deletedSchemas.map((it) => ({ name: it }))
|
|
20910
|
+
});
|
|
20418
20911
|
const { created, deleted, renamed } = await tablesResolver({
|
|
20419
20912
|
created: typedResult.addedTables,
|
|
20420
20913
|
deleted: typedResult.deletedTables
|
|
@@ -20458,6 +20951,7 @@ var init_snapshotsDiffer = __esm({
|
|
|
20458
20951
|
const allAltered2 = table4.altered.concat(renamedColumnsAltered);
|
|
20459
20952
|
const resolved = {
|
|
20460
20953
|
name: table4.name,
|
|
20954
|
+
schema: table4.schema,
|
|
20461
20955
|
deleted: result.deleted,
|
|
20462
20956
|
added: result.created,
|
|
20463
20957
|
altered: allAltered2,
|
|
@@ -20465,11 +20959,66 @@ var init_snapshotsDiffer = __esm({
|
|
|
20465
20959
|
deletedIndexes: table4.deletedIndexes,
|
|
20466
20960
|
addedForeignKeys: table4.addedForeignKeys,
|
|
20467
20961
|
deletedForeignKeys: table4.deletedForeignKeys,
|
|
20468
|
-
alteredForeignKeys: table4.alteredForeignKeys
|
|
20962
|
+
alteredForeignKeys: table4.alteredForeignKeys,
|
|
20963
|
+
addedCompositePKs: table4.addedCompositePKs,
|
|
20964
|
+
deletedCompositePKs: table4.deletedCompositePKs,
|
|
20965
|
+
alteredCompositePKs: table4.alteredCompositePKs
|
|
20469
20966
|
};
|
|
20470
20967
|
allAlteredResolved.push(resolved);
|
|
20471
20968
|
}
|
|
20472
|
-
const
|
|
20969
|
+
const jsonAddedCompositePKs = [];
|
|
20970
|
+
const jsonDeletedCompositePKs = [];
|
|
20971
|
+
const jsonAlteredCompositePKs = [];
|
|
20972
|
+
const jsonSetTableSchemas = [];
|
|
20973
|
+
const jsonRemoveTableFromSchemas = [];
|
|
20974
|
+
const jsonSetNewTableSchemas = [];
|
|
20975
|
+
allAlteredResolved.forEach((it) => {
|
|
20976
|
+
const addedCompositePKs = prepareAddCompositePrimaryKeySqlite(
|
|
20977
|
+
it.name,
|
|
20978
|
+
it.addedCompositePKs
|
|
20979
|
+
);
|
|
20980
|
+
const deletedCompositePKs = prepareDeleteCompositePrimaryKeySqlite(
|
|
20981
|
+
it.name,
|
|
20982
|
+
it.deletedCompositePKs
|
|
20983
|
+
);
|
|
20984
|
+
const alteredCompositePKs = prepareAlterCompositePrimaryKeySqlite(
|
|
20985
|
+
it.name,
|
|
20986
|
+
it.alteredCompositePKs
|
|
20987
|
+
);
|
|
20988
|
+
if (it.schema) {
|
|
20989
|
+
switch (it.schema.type) {
|
|
20990
|
+
case "added": {
|
|
20991
|
+
jsonSetTableSchemas.push({
|
|
20992
|
+
schema: it.schema.value,
|
|
20993
|
+
tableName: it.name,
|
|
20994
|
+
type: "alter_table_set_schema"
|
|
20995
|
+
});
|
|
20996
|
+
break;
|
|
20997
|
+
}
|
|
20998
|
+
case "changed": {
|
|
20999
|
+
jsonSetNewTableSchemas.push({
|
|
21000
|
+
type: "alter_table_set_new_schema",
|
|
21001
|
+
tableName: it.name,
|
|
21002
|
+
from: it.schema.old,
|
|
21003
|
+
to: it.schema.new
|
|
21004
|
+
});
|
|
21005
|
+
break;
|
|
21006
|
+
}
|
|
21007
|
+
case "deleted": {
|
|
21008
|
+
jsonRemoveTableFromSchemas.push({
|
|
21009
|
+
type: "alter_table_remove_from_schema",
|
|
21010
|
+
tableName: it.name,
|
|
21011
|
+
schema: it.schema.value
|
|
21012
|
+
});
|
|
21013
|
+
break;
|
|
21014
|
+
}
|
|
21015
|
+
}
|
|
21016
|
+
}
|
|
21017
|
+
jsonAddedCompositePKs.push(...addedCompositePKs);
|
|
21018
|
+
jsonDeletedCompositePKs.push(...deletedCompositePKs);
|
|
21019
|
+
jsonAlteredCompositePKs.push(...alteredCompositePKs);
|
|
21020
|
+
});
|
|
21021
|
+
const jsonTableAlternations = allAlteredResolved.map((it) => {
|
|
20473
21022
|
return prepareAlterTableColumnsJson(
|
|
20474
21023
|
it.name,
|
|
20475
21024
|
it.deleted,
|
|
@@ -20478,7 +21027,12 @@ var init_snapshotsDiffer = __esm({
|
|
|
20478
21027
|
it.addedForeignKeys,
|
|
20479
21028
|
dialect6
|
|
20480
21029
|
);
|
|
20481
|
-
}).flat()
|
|
21030
|
+
}).flat().reduce((res, it) => {
|
|
21031
|
+
res.createColumns.push(...it.addColumns);
|
|
21032
|
+
res.dropColumns.push(...it.dropColumns);
|
|
21033
|
+
res.alterColumns.push(...it.alterColumns);
|
|
21034
|
+
return res;
|
|
21035
|
+
}, { createColumns: [], dropColumns: [], alterColumns: [] });
|
|
20482
21036
|
const jsonCreateIndexesForAllAlteredTables = allAltered.map((it) => {
|
|
20483
21037
|
return prepareCreateIndexesJson(it.name, it.addedIndexes || {});
|
|
20484
21038
|
}).flat();
|
|
@@ -20508,6 +21062,28 @@ var init_snapshotsDiffer = __esm({
|
|
|
20508
21062
|
const jsonAlterEnumsWithAddedValues = (_d = (_c = typedResult.alteredEnums) == null ? void 0 : _c.map((it) => {
|
|
20509
21063
|
return prepareAddValuesToEnumJson(it.name, it.addedValues);
|
|
20510
21064
|
}).flat()) != null ? _d : [];
|
|
21065
|
+
if (dialect6 === "mysql") {
|
|
21066
|
+
createdSchemas.push(...renamedSchemas.map((it) => it.to));
|
|
21067
|
+
deletedSchemas.push(...renamedSchemas.map((it) => it.from));
|
|
21068
|
+
renamedSchemas.splice(0, renamedSchemas.length);
|
|
21069
|
+
}
|
|
21070
|
+
const createSchemas = prepareCreateSchemasJson(
|
|
21071
|
+
createdSchemas.map((it) => it.name)
|
|
21072
|
+
);
|
|
21073
|
+
const renameSchemas = prepareRenameSchemasJson(
|
|
21074
|
+
renamedSchemas.map((it) => ({ from: it.from.name, to: it.to.name }))
|
|
21075
|
+
);
|
|
21076
|
+
const dropSchemas = prepareDeleteSchemasJson(
|
|
21077
|
+
deletedSchemas.map((it) => it.name)
|
|
21078
|
+
);
|
|
21079
|
+
const renamedSchemasSet = new Set(
|
|
21080
|
+
renameSchemas.map((it) => `${it.from}-${it.to}`)
|
|
21081
|
+
);
|
|
21082
|
+
const filteredJsonSetNewTableSchemas = jsonSetNewTableSchemas.filter((it) => {
|
|
21083
|
+
return !renamedSchemasSet.has(`${it.from}-${it.to}`);
|
|
21084
|
+
});
|
|
21085
|
+
jsonStatements.push(...createSchemas);
|
|
21086
|
+
jsonStatements.push(...renameSchemas);
|
|
20511
21087
|
jsonStatements.push(...createEnums);
|
|
20512
21088
|
jsonStatements.push(...jsonAlterEnumsWithAddedValues);
|
|
20513
21089
|
if (dialect6 === "sqlite") {
|
|
@@ -20518,13 +21094,22 @@ var init_snapshotsDiffer = __esm({
|
|
|
20518
21094
|
jsonStatements.push(...jsonDropTables);
|
|
20519
21095
|
jsonStatements.push(...jsonRenameTables);
|
|
20520
21096
|
jsonStatements.push(...jsonRenameColumnsStatements);
|
|
20521
|
-
jsonStatements.push(...
|
|
21097
|
+
jsonStatements.push(...jsonTableAlternations.alterColumns);
|
|
21098
|
+
jsonStatements.push(...jsonAlterReferencesForAlteredTables);
|
|
21099
|
+
jsonStatements.push(...jsonTableAlternations.dropColumns);
|
|
21100
|
+
jsonStatements.push(...jsonTableAlternations.createColumns);
|
|
20522
21101
|
if (dialect6 !== "sqlite")
|
|
20523
21102
|
jsonStatements.push(...jsonCreateReferences);
|
|
20524
|
-
jsonStatements.push(...
|
|
21103
|
+
jsonStatements.push(...jsonDropIndexesForAllAlteredTables);
|
|
20525
21104
|
jsonStatements.push(...jsonCreateIndexesForCreatedTables);
|
|
20526
21105
|
jsonStatements.push(...jsonCreateIndexesForAllAlteredTables);
|
|
20527
|
-
jsonStatements.push(...
|
|
21106
|
+
jsonStatements.push(...jsonDeletedCompositePKs);
|
|
21107
|
+
jsonStatements.push(...jsonAddedCompositePKs);
|
|
21108
|
+
jsonStatements.push(...jsonAlteredCompositePKs);
|
|
21109
|
+
jsonStatements.push(...jsonSetTableSchemas);
|
|
21110
|
+
jsonStatements.push(...filteredJsonSetNewTableSchemas);
|
|
21111
|
+
jsonStatements.push(...jsonRemoveTableFromSchemas);
|
|
21112
|
+
jsonStatements.push(...dropSchemas);
|
|
20528
21113
|
const sqlStatements = fromJson(jsonStatements, dialect6);
|
|
20529
21114
|
return sqlStatements.join("\n");
|
|
20530
21115
|
};
|
|
@@ -20540,14 +21125,14 @@ __export(migrate_exports, {
|
|
|
20540
21125
|
prepareSQL: () => prepareSQL,
|
|
20541
21126
|
prepareSnapshotFolderName: () => prepareSnapshotFolderName
|
|
20542
21127
|
});
|
|
20543
|
-
var import_fs4, import_path2,
|
|
21128
|
+
var import_fs4, import_path2, import_hanji2, prepareAndMigratePg, prepareAndMigrateSqlite, prepareAndMigrateMySql, prepareSQL, promptColumnsConflicts, promptTablesConflict, promptSchemasConflict, writeResult, prepareSnapshotFolderName, two;
|
|
20544
21129
|
var init_migrate = __esm({
|
|
20545
21130
|
"src/cli/commands/migrate.ts"() {
|
|
20546
21131
|
import_fs4 = __toESM(require("fs"));
|
|
20547
21132
|
init_migrationPreparator();
|
|
20548
21133
|
init_snapshotsDiffer();
|
|
20549
21134
|
import_path2 = __toESM(require("path"));
|
|
20550
|
-
|
|
21135
|
+
import_hanji2 = __toESM(require_hanji());
|
|
20551
21136
|
init_views();
|
|
20552
21137
|
init_source();
|
|
20553
21138
|
init_pgSchema();
|
|
@@ -20604,8 +21189,8 @@ var init_migrate = __esm({
|
|
|
20604
21189
|
outFolder,
|
|
20605
21190
|
schemaPath
|
|
20606
21191
|
);
|
|
20607
|
-
const validatedPrev =
|
|
20608
|
-
const validatedCur =
|
|
21192
|
+
const validatedPrev = mysqlSchema.parse(prev);
|
|
21193
|
+
const validatedCur = mysqlSchema.parse(cur);
|
|
20609
21194
|
const squashedPrev = squashMysqlScheme(validatedPrev);
|
|
20610
21195
|
const squashedCur = squashMysqlScheme(validatedCur);
|
|
20611
21196
|
const sql = await prepareSQL(squashedPrev, squashedCur, "mysql");
|
|
@@ -20615,6 +21200,18 @@ var init_migrate = __esm({
|
|
|
20615
21200
|
}
|
|
20616
21201
|
};
|
|
20617
21202
|
prepareSQL = async (prev, cur, dialect6) => {
|
|
21203
|
+
const schemasResolver = async (input) => {
|
|
21204
|
+
try {
|
|
21205
|
+
const { created, deleted, renamed } = await promptSchemasConflict(
|
|
21206
|
+
input.created,
|
|
21207
|
+
input.deleted
|
|
21208
|
+
);
|
|
21209
|
+
return { created, deleted, renamed };
|
|
21210
|
+
} catch (e) {
|
|
21211
|
+
console.error(e);
|
|
21212
|
+
throw e;
|
|
21213
|
+
}
|
|
21214
|
+
};
|
|
20618
21215
|
const tablesResolver = async (input) => {
|
|
20619
21216
|
try {
|
|
20620
21217
|
const { created, deleted, renamed } = await promptTablesConflict(
|
|
@@ -20644,6 +21241,7 @@ var init_migrate = __esm({
|
|
|
20644
21241
|
prev,
|
|
20645
21242
|
cur,
|
|
20646
21243
|
dialect6,
|
|
21244
|
+
schemasResolver,
|
|
20647
21245
|
tablesResolver,
|
|
20648
21246
|
columnsResolver
|
|
20649
21247
|
);
|
|
@@ -20661,7 +21259,7 @@ var init_migrate = __esm({
|
|
|
20661
21259
|
return { from: it, to: created };
|
|
20662
21260
|
});
|
|
20663
21261
|
const promptData = [created, ...renames];
|
|
20664
|
-
const { status, data } = await (0,
|
|
21262
|
+
const { status, data } = await (0, import_hanji2.render)(
|
|
20665
21263
|
new ResolveColumnSelect(tableName, created, promptData)
|
|
20666
21264
|
);
|
|
20667
21265
|
if (status === "aborted") {
|
|
@@ -20707,7 +21305,7 @@ var init_migrate = __esm({
|
|
|
20707
21305
|
return { from: it, to: created };
|
|
20708
21306
|
});
|
|
20709
21307
|
const promptData = [created, ...renames];
|
|
20710
|
-
const { status, data } = await (0,
|
|
21308
|
+
const { status, data } = await (0, import_hanji2.render)(
|
|
20711
21309
|
new ResolveTableSelect(created, promptData)
|
|
20712
21310
|
);
|
|
20713
21311
|
if (status === "aborted") {
|
|
@@ -20733,7 +21331,50 @@ var init_migrate = __esm({
|
|
|
20733
21331
|
}
|
|
20734
21332
|
index4 += 1;
|
|
20735
21333
|
} while (index4 < newTables.length);
|
|
20736
|
-
console.log(source_default.gray("--- all table conflicts resolved
|
|
21334
|
+
console.log(source_default.gray("--- all table conflicts resolved ---\n"));
|
|
21335
|
+
result.deleted.push(...leftMissing);
|
|
21336
|
+
return result;
|
|
21337
|
+
};
|
|
21338
|
+
promptSchemasConflict = async (newSchemas, missingSchemas) => {
|
|
21339
|
+
if (missingSchemas.length === 0 || newSchemas.length === 0) {
|
|
21340
|
+
return { created: newSchemas, renamed: [], deleted: missingSchemas };
|
|
21341
|
+
}
|
|
21342
|
+
const result = { created: [], renamed: [], deleted: [] };
|
|
21343
|
+
let index4 = 0;
|
|
21344
|
+
let leftMissing = [...missingSchemas];
|
|
21345
|
+
do {
|
|
21346
|
+
const created = newSchemas[index4];
|
|
21347
|
+
const renames = leftMissing.map((it) => {
|
|
21348
|
+
return { from: it, to: created };
|
|
21349
|
+
});
|
|
21350
|
+
const promptData = [created, ...renames];
|
|
21351
|
+
const { status, data } = await (0, import_hanji2.render)(
|
|
21352
|
+
new ResolveSchemasSelect(created, promptData)
|
|
21353
|
+
);
|
|
21354
|
+
if (status === "aborted") {
|
|
21355
|
+
console.error("ERROR");
|
|
21356
|
+
process.exit(1);
|
|
21357
|
+
}
|
|
21358
|
+
if (isRenamePromptItem(data)) {
|
|
21359
|
+
console.log(
|
|
21360
|
+
`${source_default.yellow("~")} ${data.from.name} \u203A ${data.to.name} ${source_default.gray(
|
|
21361
|
+
"schema will be renamed"
|
|
21362
|
+
)}`
|
|
21363
|
+
);
|
|
21364
|
+
result.renamed.push(data);
|
|
21365
|
+
delete leftMissing[leftMissing.indexOf(data.from)];
|
|
21366
|
+
leftMissing = leftMissing.filter(Boolean);
|
|
21367
|
+
} else {
|
|
21368
|
+
console.log(
|
|
21369
|
+
`${source_default.green("+")} ${data.name} ${source_default.gray(
|
|
21370
|
+
"schema will be created"
|
|
21371
|
+
)}`
|
|
21372
|
+
);
|
|
21373
|
+
result.created.push(created);
|
|
21374
|
+
}
|
|
21375
|
+
index4 += 1;
|
|
21376
|
+
} while (index4 < newSchemas.length);
|
|
21377
|
+
console.log(source_default.gray("--- all schemas conflicts resolved ---\n"));
|
|
20737
21378
|
result.deleted.push(...leftMissing);
|
|
20738
21379
|
return result;
|
|
20739
21380
|
};
|
|
@@ -22186,7 +22827,7 @@ var require_split2 = __commonJS({
|
|
|
22186
22827
|
var require_helper = __commonJS({
|
|
22187
22828
|
"node_modules/.pnpm/pgpass@1.0.5/node_modules/pgpass/lib/helper.js"(exports, module2) {
|
|
22188
22829
|
"use strict";
|
|
22189
|
-
var
|
|
22830
|
+
var path5 = require("path");
|
|
22190
22831
|
var Stream = require("stream").Stream;
|
|
22191
22832
|
var split = require_split2();
|
|
22192
22833
|
var util2 = require("util");
|
|
@@ -22225,7 +22866,7 @@ var require_helper = __commonJS({
|
|
|
22225
22866
|
};
|
|
22226
22867
|
module2.exports.getFileName = function(rawEnv) {
|
|
22227
22868
|
var env2 = rawEnv || process.env;
|
|
22228
|
-
var file = env2.PGPASSFILE || (isWin ?
|
|
22869
|
+
var file = env2.PGPASSFILE || (isWin ? path5.join(env2.APPDATA || "./", "postgresql", "pgpass.conf") : path5.join(env2.HOME || "./", ".pgpass"));
|
|
22229
22870
|
return file;
|
|
22230
22871
|
};
|
|
22231
22872
|
module2.exports.usePgPass = function(stats, fname) {
|
|
@@ -22352,16 +22993,16 @@ var require_helper = __commonJS({
|
|
|
22352
22993
|
var require_lib2 = __commonJS({
|
|
22353
22994
|
"node_modules/.pnpm/pgpass@1.0.5/node_modules/pgpass/lib/index.js"(exports, module2) {
|
|
22354
22995
|
"use strict";
|
|
22355
|
-
var
|
|
22356
|
-
var
|
|
22996
|
+
var path5 = require("path");
|
|
22997
|
+
var fs7 = require("fs");
|
|
22357
22998
|
var helper = require_helper();
|
|
22358
22999
|
module2.exports = function(connInfo, cb) {
|
|
22359
23000
|
var file = helper.getFileName();
|
|
22360
|
-
|
|
23001
|
+
fs7.stat(file, function(err2, stat) {
|
|
22361
23002
|
if (err2 || !helper.usePgPass(stat, file)) {
|
|
22362
23003
|
return cb(void 0);
|
|
22363
23004
|
}
|
|
22364
|
-
var st =
|
|
23005
|
+
var st = fs7.createReadStream(file);
|
|
22365
23006
|
helper.getPassword(connInfo, st, cb);
|
|
22366
23007
|
});
|
|
22367
23008
|
};
|
|
@@ -22409,7 +23050,7 @@ var require_pg_connection_string = __commonJS({
|
|
|
22409
23050
|
"node_modules/.pnpm/pg-connection-string@2.5.0/node_modules/pg-connection-string/index.js"(exports, module2) {
|
|
22410
23051
|
"use strict";
|
|
22411
23052
|
var url = require("url");
|
|
22412
|
-
var
|
|
23053
|
+
var fs7 = require("fs");
|
|
22413
23054
|
function parse(str) {
|
|
22414
23055
|
if (str.charAt(0) === "/") {
|
|
22415
23056
|
var config = str.split(" ");
|
|
@@ -22458,13 +23099,13 @@ var require_pg_connection_string = __commonJS({
|
|
|
22458
23099
|
config.ssl = {};
|
|
22459
23100
|
}
|
|
22460
23101
|
if (config.sslcert) {
|
|
22461
|
-
config.ssl.cert =
|
|
23102
|
+
config.ssl.cert = fs7.readFileSync(config.sslcert).toString();
|
|
22462
23103
|
}
|
|
22463
23104
|
if (config.sslkey) {
|
|
22464
|
-
config.ssl.key =
|
|
23105
|
+
config.ssl.key = fs7.readFileSync(config.sslkey).toString();
|
|
22465
23106
|
}
|
|
22466
23107
|
if (config.sslrootcert) {
|
|
22467
|
-
config.ssl.ca =
|
|
23108
|
+
config.ssl.ca = fs7.readFileSync(config.sslrootcert).toString();
|
|
22468
23109
|
}
|
|
22469
23110
|
switch (config.sslmode) {
|
|
22470
23111
|
case "disable": {
|
|
@@ -25297,6 +25938,9 @@ var init_introspect = __esm({
|
|
|
25297
25938
|
relations.add(relation);
|
|
25298
25939
|
});
|
|
25299
25940
|
});
|
|
25941
|
+
const schemas = Object.fromEntries(Object.entries(schema4.schemas).map((it) => {
|
|
25942
|
+
return [it[0], it[1].camelCase()];
|
|
25943
|
+
}));
|
|
25300
25944
|
const enumTypes = new Set(Object.values(schema4.enums).map((it) => it.name));
|
|
25301
25945
|
const imports = Object.values(schema4.tables).reduce(
|
|
25302
25946
|
(res, it) => {
|
|
@@ -25324,9 +25968,15 @@ var init_introspect = __esm({
|
|
|
25324
25968
|
const values = Object.values(it.values).map((it2) => `'${it2}'`).join(", ");
|
|
25325
25969
|
return `export const ${it.name.camelCase()} = pgEnum("${it.name}", [${values}])
|
|
25326
25970
|
`;
|
|
25327
|
-
}).join("");
|
|
25971
|
+
}).join("").concat("\n");
|
|
25972
|
+
const schemaStatements = Object.entries(schemas).map((it) => {
|
|
25973
|
+
return `export const ${it[1]} = pgSchema("${it[0]}");
|
|
25974
|
+
`;
|
|
25975
|
+
}).join();
|
|
25328
25976
|
const tableStatements = Object.values(schema4.tables).map((table4) => {
|
|
25329
|
-
|
|
25977
|
+
var _a;
|
|
25978
|
+
const func = (_a = schemas[table4.schema]) != null ? _a : "pgTable";
|
|
25979
|
+
let statement = `export const ${table4.name.camelCase()} = ${func}("${table4.name}", {
|
|
25330
25980
|
`;
|
|
25331
25981
|
statement += createTableColumns(
|
|
25332
25982
|
Object.values(table4.columns),
|
|
@@ -25352,6 +26002,7 @@ var init_introspect = __esm({
|
|
|
25352
26002
|
const uniquePgImports = [
|
|
25353
26003
|
"pgTable",
|
|
25354
26004
|
"pgEnum",
|
|
26005
|
+
"pgSchema",
|
|
25355
26006
|
"AnyPgColumn",
|
|
25356
26007
|
...new Set(imports.pg)
|
|
25357
26008
|
];
|
|
@@ -25361,6 +26012,7 @@ var init_introspect = __esm({
|
|
|
25361
26012
|
|
|
25362
26013
|
`;
|
|
25363
26014
|
result += enumStatements;
|
|
26015
|
+
result += schemaStatements;
|
|
25364
26016
|
result += "\n";
|
|
25365
26017
|
result += tableStatements.join("\n\n");
|
|
25366
26018
|
return result;
|
|
@@ -25577,10 +26229,10 @@ __export(pgIntrospect_exports, {
|
|
|
25577
26229
|
PgConfig2: () => PgConfig2,
|
|
25578
26230
|
pgIntrospect: () => pgIntrospect
|
|
25579
26231
|
});
|
|
25580
|
-
var
|
|
26232
|
+
var import_hanji3, import_pg, PgConfig1, PgConfig2, Conf, pgIntrospect;
|
|
25581
26233
|
var init_pgIntrospect = __esm({
|
|
25582
26234
|
"src/cli/commands/pgIntrospect.ts"() {
|
|
25583
|
-
|
|
26235
|
+
import_hanji3 = __toESM(require_hanji());
|
|
25584
26236
|
init_lib();
|
|
25585
26237
|
init_views();
|
|
25586
26238
|
import_pg = __toESM(require_lib3());
|
|
@@ -25602,7 +26254,7 @@ var init_pgIntrospect = __esm({
|
|
|
25602
26254
|
pgIntrospect = async (config) => {
|
|
25603
26255
|
const pool = new import_pg.Pool(config);
|
|
25604
26256
|
const progress = new IntrospectProgress();
|
|
25605
|
-
const res = await (0,
|
|
26257
|
+
const res = await (0, import_hanji3.renderWithTask)(
|
|
25606
26258
|
progress,
|
|
25607
26259
|
fromDatabase(pool, (stage, count, status) => {
|
|
25608
26260
|
progress.update(stage, count, status);
|
|
@@ -25623,7 +26275,7 @@ __export(cli_exports, {
|
|
|
25623
26275
|
});
|
|
25624
26276
|
module.exports = __toCommonJS(cli_exports);
|
|
25625
26277
|
|
|
25626
|
-
// node_modules/.pnpm/commander@9.
|
|
26278
|
+
// node_modules/.pnpm/commander@9.5.0/node_modules/commander/esm.mjs
|
|
25627
26279
|
var import_index = __toESM(require_commander(), 1);
|
|
25628
26280
|
var {
|
|
25629
26281
|
program,
|
|
@@ -25640,7 +26292,7 @@ var {
|
|
|
25640
26292
|
} = import_index.default;
|
|
25641
26293
|
|
|
25642
26294
|
// src/cli/index.ts
|
|
25643
|
-
var
|
|
26295
|
+
var import_fs8 = __toESM(require("fs"));
|
|
25644
26296
|
init_lib();
|
|
25645
26297
|
|
|
25646
26298
|
// src/cli/commands/check.ts
|
|
@@ -25681,9 +26333,9 @@ var checkHandler = (out, dialect6) => {
|
|
|
25681
26333
|
};
|
|
25682
26334
|
|
|
25683
26335
|
// src/cli/index.ts
|
|
25684
|
-
var
|
|
26336
|
+
var import_hanji4 = __toESM(require_hanji());
|
|
25685
26337
|
init_views();
|
|
25686
|
-
var
|
|
26338
|
+
var import_path6 = __toESM(require("path"));
|
|
25687
26339
|
|
|
25688
26340
|
// src/cli/utils.ts
|
|
25689
26341
|
init_views();
|
|
@@ -25730,7 +26382,7 @@ init_source();
|
|
|
25730
26382
|
// package.json
|
|
25731
26383
|
var package_default = {
|
|
25732
26384
|
name: "drizzle-kit",
|
|
25733
|
-
version: "0.16.
|
|
26385
|
+
version: "0.16.2",
|
|
25734
26386
|
repository: "https://github.com/drizzle-team/drizzle-kit-mirror",
|
|
25735
26387
|
author: "Alex Blokh <aleksandrblokh@gmail.com>",
|
|
25736
26388
|
license: "MIT",
|
|
@@ -25783,9 +26435,9 @@ var package_default = {
|
|
|
25783
26435
|
"@typescript-eslint/parser": "^5.46.1",
|
|
25784
26436
|
ava: "^5.1.0",
|
|
25785
26437
|
dockerode: "^3.3.4",
|
|
25786
|
-
"drizzle-orm": "0.15.
|
|
25787
|
-
"drizzle-orm-mysql": "0.15.
|
|
25788
|
-
"drizzle-orm-pg": "0.15.
|
|
26438
|
+
"drizzle-orm": "0.15.1-a1b76f5",
|
|
26439
|
+
"drizzle-orm-mysql": "0.15.1-a1b76f5",
|
|
26440
|
+
"drizzle-orm-pg": "0.15.1-a1b76f5",
|
|
25789
26441
|
"drizzle-orm-sqlite": "0.15.0-60954a3",
|
|
25790
26442
|
esbuild: "^0.15.7",
|
|
25791
26443
|
"esbuild-register": "^3.3.3",
|
|
@@ -25842,11 +26494,17 @@ var updateToLatest = (json, prevId) => {
|
|
|
25842
26494
|
const v1 = pgSchemaV1.parse(json);
|
|
25843
26495
|
const v2 = update1to2(v1);
|
|
25844
26496
|
const v3 = update2to3(v2, prevId);
|
|
25845
|
-
|
|
26497
|
+
const v4 = update3to4(v3);
|
|
26498
|
+
return v4;
|
|
25846
26499
|
}
|
|
25847
26500
|
if (version === 2) {
|
|
25848
26501
|
const v2 = pgSchemaV2.parse(json);
|
|
25849
|
-
|
|
26502
|
+
const v3 = update2to3(v2, prevId);
|
|
26503
|
+
const v4 = update3to4(v3);
|
|
26504
|
+
return v4;
|
|
26505
|
+
}
|
|
26506
|
+
if (version === 3) {
|
|
26507
|
+
return update3to4(pgSchemaV3.parse(json));
|
|
25850
26508
|
}
|
|
25851
26509
|
return pgSchema.parse(json);
|
|
25852
26510
|
};
|
|
@@ -25873,11 +26531,11 @@ var update1to2 = (json) => {
|
|
|
25873
26531
|
};
|
|
25874
26532
|
var update2to3 = (json, prevId) => {
|
|
25875
26533
|
const tables = Object.fromEntries(
|
|
25876
|
-
Object.entries(json.tables).map((
|
|
25877
|
-
const { name, columns, indexes } =
|
|
26534
|
+
Object.entries(json.tables).map((table4) => {
|
|
26535
|
+
const { name, columns, indexes } = table4[1];
|
|
25878
26536
|
let refs = [];
|
|
25879
26537
|
const newColumns = Object.fromEntries(
|
|
25880
|
-
Object.entries(columns).map((
|
|
26538
|
+
Object.entries(columns).map((it) => {
|
|
25881
26539
|
const {
|
|
25882
26540
|
name: name2,
|
|
25883
26541
|
type,
|
|
@@ -25885,7 +26543,7 @@ var update2to3 = (json, prevId) => {
|
|
|
25885
26543
|
notNull,
|
|
25886
26544
|
default: defaultValue,
|
|
25887
26545
|
references: references2
|
|
25888
|
-
} =
|
|
26546
|
+
} = it[1];
|
|
25889
26547
|
const newColumn = {
|
|
25890
26548
|
name: name2,
|
|
25891
26549
|
type,
|
|
@@ -25896,18 +26554,18 @@ var update2to3 = (json, prevId) => {
|
|
|
25896
26554
|
if (references2) {
|
|
25897
26555
|
refs.push({ column: name2, value: references2 });
|
|
25898
26556
|
}
|
|
25899
|
-
return [
|
|
26557
|
+
return [it[0], newColumn];
|
|
25900
26558
|
})
|
|
25901
26559
|
);
|
|
25902
26560
|
const tableName = name;
|
|
25903
26561
|
const fks = Object.fromEntries(
|
|
25904
|
-
refs.map((
|
|
25905
|
-
const [name2,
|
|
26562
|
+
refs.map((it) => {
|
|
26563
|
+
const [name2, table5, column5, onDelete, onUpdate] = it.value.split(";");
|
|
25906
26564
|
const fk4 = {
|
|
25907
26565
|
name: name2,
|
|
25908
26566
|
tableFrom: tableName,
|
|
25909
|
-
columnsFrom: [
|
|
25910
|
-
tableTo:
|
|
26567
|
+
columnsFrom: [it.column],
|
|
26568
|
+
tableTo: table5,
|
|
25911
26569
|
columnsTo: [column5],
|
|
25912
26570
|
onUpdate,
|
|
25913
26571
|
onDelete
|
|
@@ -25916,17 +26574,17 @@ var update2to3 = (json, prevId) => {
|
|
|
25916
26574
|
})
|
|
25917
26575
|
);
|
|
25918
26576
|
const idxs = Object.fromEntries(
|
|
25919
|
-
Object.entries(indexes).map((
|
|
25920
|
-
const { columns: columns2, isUnique, name: name2 } =
|
|
25921
|
-
const mappedColumns = Object.entries(columns2).map((
|
|
25922
|
-
return
|
|
26577
|
+
Object.entries(indexes).map((it) => {
|
|
26578
|
+
const { columns: columns2, isUnique, name: name2 } = it[1];
|
|
26579
|
+
const mappedColumns = Object.entries(columns2).map((it2) => {
|
|
26580
|
+
return it2[1].name;
|
|
25923
26581
|
});
|
|
25924
26582
|
const index4 = {
|
|
25925
26583
|
name: name2,
|
|
25926
26584
|
isUnique,
|
|
25927
26585
|
columns: mappedColumns
|
|
25928
26586
|
};
|
|
25929
|
-
return [
|
|
26587
|
+
return [it[0], index4];
|
|
25930
26588
|
})
|
|
25931
26589
|
);
|
|
25932
26590
|
const newTable = {
|
|
@@ -25935,7 +26593,7 @@ var update2to3 = (json, prevId) => {
|
|
|
25935
26593
|
indexes: idxs,
|
|
25936
26594
|
foreignKeys: fks
|
|
25937
26595
|
};
|
|
25938
|
-
return [
|
|
26596
|
+
return [table4[0], newTable];
|
|
25939
26597
|
})
|
|
25940
26598
|
);
|
|
25941
26599
|
return {
|
|
@@ -25947,6 +26605,49 @@ var update2to3 = (json, prevId) => {
|
|
|
25947
26605
|
enums: json.enums
|
|
25948
26606
|
};
|
|
25949
26607
|
};
|
|
26608
|
+
var update3to4 = (json) => {
|
|
26609
|
+
const tables = Object.fromEntries(
|
|
26610
|
+
Object.entries(json.tables).map((table4) => {
|
|
26611
|
+
const { name, columns, foreignKeys, indexes } = table4[1];
|
|
26612
|
+
const newColumns = Object.fromEntries(
|
|
26613
|
+
Object.entries(columns).map((it) => {
|
|
26614
|
+
const {
|
|
26615
|
+
name: name2,
|
|
26616
|
+
type,
|
|
26617
|
+
primaryKey,
|
|
26618
|
+
notNull,
|
|
26619
|
+
default: defaultValue
|
|
26620
|
+
} = it[1];
|
|
26621
|
+
const newColumn = {
|
|
26622
|
+
name: name2,
|
|
26623
|
+
type,
|
|
26624
|
+
primaryKey,
|
|
26625
|
+
notNull,
|
|
26626
|
+
default: defaultValue
|
|
26627
|
+
};
|
|
26628
|
+
return [it[0], newColumn];
|
|
26629
|
+
})
|
|
26630
|
+
);
|
|
26631
|
+
const newTable = {
|
|
26632
|
+
name,
|
|
26633
|
+
schema: "",
|
|
26634
|
+
columns: newColumns,
|
|
26635
|
+
indexes,
|
|
26636
|
+
foreignKeys
|
|
26637
|
+
};
|
|
26638
|
+
return [table4[0], newTable];
|
|
26639
|
+
})
|
|
26640
|
+
);
|
|
26641
|
+
return {
|
|
26642
|
+
version: "4",
|
|
26643
|
+
dialect: "pg",
|
|
26644
|
+
id: (0, import_crypto2.randomUUID)(),
|
|
26645
|
+
prevId: json.prevId,
|
|
26646
|
+
tables,
|
|
26647
|
+
enums: json.enums,
|
|
26648
|
+
schemas: {}
|
|
26649
|
+
};
|
|
26650
|
+
};
|
|
25950
26651
|
|
|
25951
26652
|
// src/cli/commands/sqliteUp.ts
|
|
25952
26653
|
init_source();
|
|
@@ -25996,11 +26697,66 @@ var updateV3toV4 = (old) => {
|
|
|
25996
26697
|
};
|
|
25997
26698
|
};
|
|
25998
26699
|
|
|
26700
|
+
// src/cli/commands/mysqlUp.ts
|
|
26701
|
+
init_source();
|
|
26702
|
+
var import_fs7 = __toESM(require("fs"));
|
|
26703
|
+
var import_path5 = __toESM(require("path"));
|
|
26704
|
+
init_mysqlSchema();
|
|
26705
|
+
init_utils();
|
|
26706
|
+
var upMysqlHandler = (out) => {
|
|
26707
|
+
const migrationFolders = prepareOutFolders(out);
|
|
26708
|
+
const report = validateWithReport(out, migrationFolders, "mysql");
|
|
26709
|
+
report.nonLatest.map((it) => ({
|
|
26710
|
+
folder: it,
|
|
26711
|
+
raw: report.rawMap[it]
|
|
26712
|
+
})).forEach((it) => {
|
|
26713
|
+
const folder = it.folder;
|
|
26714
|
+
const result = updateToLatest3(it.raw);
|
|
26715
|
+
console.log(
|
|
26716
|
+
`[${source_default.green("\u2713")}] ${import_path5.default.join(out, folder, "snapshot.json")}`
|
|
26717
|
+
);
|
|
26718
|
+
import_fs7.default.writeFileSync(
|
|
26719
|
+
import_path5.default.join(out, folder, "snapshot.json"),
|
|
26720
|
+
JSON.stringify(result, null, 2)
|
|
26721
|
+
);
|
|
26722
|
+
});
|
|
26723
|
+
console.log("Everything's fine \u{1F436}\u{1F525}");
|
|
26724
|
+
};
|
|
26725
|
+
var updateToLatest3 = (json) => {
|
|
26726
|
+
const version = Number(json["version"]);
|
|
26727
|
+
if (version === 3) {
|
|
26728
|
+
const v3 = mysqlSchemaV3.parse(json);
|
|
26729
|
+
const v4 = updateV3toV42(v3);
|
|
26730
|
+
return v4;
|
|
26731
|
+
}
|
|
26732
|
+
return mysqlSchema.parse(json);
|
|
26733
|
+
};
|
|
26734
|
+
var updateV3toV42 = (old) => {
|
|
26735
|
+
return {
|
|
26736
|
+
...old,
|
|
26737
|
+
version: "4",
|
|
26738
|
+
schemas: {}
|
|
26739
|
+
};
|
|
26740
|
+
};
|
|
26741
|
+
|
|
25999
26742
|
// src/cli/index.ts
|
|
26000
26743
|
var printVersions = () => {
|
|
26001
26744
|
console.log(`${source_default.gray(versions())}
|
|
26002
26745
|
`);
|
|
26003
26746
|
};
|
|
26747
|
+
var assertEitherConfigOrOut = (config, out) => {
|
|
26748
|
+
if (out)
|
|
26749
|
+
return out;
|
|
26750
|
+
if (!(0, import_fs8.existsSync)(import_path6.default.join(import_path6.default.resolve(config)))) {
|
|
26751
|
+
console.log(`${config} file does not exist`);
|
|
26752
|
+
process.exit(1);
|
|
26753
|
+
}
|
|
26754
|
+
console.log(`Reading ${config}`);
|
|
26755
|
+
const drizzleConfig = JSON.parse(
|
|
26756
|
+
import_fs8.default.readFileSync(import_path6.default.join(import_path6.default.resolve(config))).toString()
|
|
26757
|
+
);
|
|
26758
|
+
return drizzleConfig.out;
|
|
26759
|
+
};
|
|
26004
26760
|
var versions = () => {
|
|
26005
26761
|
const { npmVersion } = pgVersions();
|
|
26006
26762
|
const ormVersion = npmVersion ? `
|
|
@@ -26021,6 +26777,7 @@ var generatePgCommand = new Command("generate:pg").option("--schema <schema>", "
|
|
|
26021
26777
|
"--config <config>",
|
|
26022
26778
|
"Path to a config.json file, drizzle.config.json by default"
|
|
26023
26779
|
).action(async (options) => {
|
|
26780
|
+
printVersions();
|
|
26024
26781
|
const oprtionsParsed = optionsSchema.parse(options);
|
|
26025
26782
|
const result = prepareGenerateConfig(oprtionsParsed);
|
|
26026
26783
|
if (result instanceof Error) {
|
|
@@ -26035,6 +26792,7 @@ var generateMysqlCommand = new Command("generate:mysql").option("--schema <schem
|
|
|
26035
26792
|
"--config <config>",
|
|
26036
26793
|
"Path to a config.json file, drizzle.config.json by default"
|
|
26037
26794
|
).action(async (options) => {
|
|
26795
|
+
printVersions();
|
|
26038
26796
|
const oprtionsParsed = optionsSchema.parse(options);
|
|
26039
26797
|
const result = prepareGenerateConfig(oprtionsParsed);
|
|
26040
26798
|
if (result instanceof Error) {
|
|
@@ -26049,6 +26807,7 @@ var generateSqliteCommand = new Command("generate:sqlite").option("--schema <sch
|
|
|
26049
26807
|
"--config <config>",
|
|
26050
26808
|
"Path to a config.json file, drizzle.config.json by default"
|
|
26051
26809
|
).action(async (options) => {
|
|
26810
|
+
printVersions();
|
|
26052
26811
|
const oprtionsParsed = optionsSchema.parse(options);
|
|
26053
26812
|
const result = prepareGenerateConfig(oprtionsParsed);
|
|
26054
26813
|
if (result instanceof Error) {
|
|
@@ -26062,9 +26821,9 @@ var generateSqliteCommand = new Command("generate:sqlite").option("--schema <sch
|
|
|
26062
26821
|
var prepareGenerateConfig = (options) => {
|
|
26063
26822
|
const { schema: schema4, out, config } = options;
|
|
26064
26823
|
if (!(schema4 || out)) {
|
|
26065
|
-
const
|
|
26824
|
+
const path5 = config != null ? config : "drizzle.config.json";
|
|
26066
26825
|
const drizzleConfig = JSON.parse(
|
|
26067
|
-
|
|
26826
|
+
import_fs8.default.readFileSync(import_path6.default.join(import_path6.default.resolve(path5))).toString()
|
|
26068
26827
|
);
|
|
26069
26828
|
return drizzleConfig;
|
|
26070
26829
|
}
|
|
@@ -26074,39 +26833,70 @@ var prepareGenerateConfig = (options) => {
|
|
|
26074
26833
|
return configSchema.parse({ schema: schema4, out });
|
|
26075
26834
|
};
|
|
26076
26835
|
var checkSchema = objectType({
|
|
26077
|
-
out: stringType().
|
|
26836
|
+
out: stringType().optional(),
|
|
26837
|
+
config: stringType().default("drizzle.config.json")
|
|
26078
26838
|
}).strict();
|
|
26079
|
-
var checkPgCommand = new Command("check:pg").option("--out <out>", `Output folder,
|
|
26080
|
-
|
|
26839
|
+
var checkPgCommand = new Command("check:pg").option("--out <out>", `Output folder`).option("--config <config>", `Config path [default=drizzle.config.json]`).action((options) => {
|
|
26840
|
+
printVersions();
|
|
26841
|
+
const params = checkSchema.parse(options);
|
|
26842
|
+
const out = assertEitherConfigOrOut(params.config, params.out);
|
|
26081
26843
|
if (!out) {
|
|
26082
|
-
|
|
26844
|
+
console.log(error(`'out' folder param must be set`));
|
|
26083
26845
|
process.exit(0);
|
|
26084
26846
|
}
|
|
26085
26847
|
checkHandler(out, "pg");
|
|
26086
26848
|
console.log("Everything's fine \u{1F436}\u{1F525}");
|
|
26087
26849
|
});
|
|
26088
|
-
var checkSqliteCommand = new Command("check:sqlite").option("--out <out>", `Output folder,
|
|
26089
|
-
|
|
26850
|
+
var checkSqliteCommand = new Command("check:sqlite").option("--out <out>", `Output folder`).option("--config <config>", `Config path [default=drizzle.config.json]`).action((options) => {
|
|
26851
|
+
printVersions();
|
|
26852
|
+
const params = checkSchema.parse(options);
|
|
26853
|
+
const out = assertEitherConfigOrOut(params.config, params.out);
|
|
26090
26854
|
if (!out) {
|
|
26091
|
-
|
|
26855
|
+
console.log(error(`'out' folder param must be set`));
|
|
26092
26856
|
process.exit(0);
|
|
26093
26857
|
}
|
|
26094
26858
|
checkHandler(out, "sqlite");
|
|
26095
26859
|
console.log("Everything's fine \u{1F436}\u{1F525}");
|
|
26096
26860
|
});
|
|
26097
|
-
var upPgCommand = new Command("up:pg").option("--out <out>", `Output folder,
|
|
26098
|
-
|
|
26861
|
+
var upPgCommand = new Command("up:pg").option("--out <out>", `Output folder`).option("--config <config>", `Config path [default=drizzle.config.json]`).action((options) => {
|
|
26862
|
+
printVersions();
|
|
26863
|
+
const params = checkSchema.parse(options);
|
|
26864
|
+
const out = assertEitherConfigOrOut(params.config, params.out);
|
|
26099
26865
|
if (!out) {
|
|
26100
|
-
|
|
26866
|
+
console.log(
|
|
26867
|
+
error(
|
|
26868
|
+
`'out' folder param must be set through '--out' param or in config file`
|
|
26869
|
+
)
|
|
26870
|
+
);
|
|
26101
26871
|
process.exit(0);
|
|
26102
26872
|
}
|
|
26103
26873
|
assertPackages("drizzle-orm", "drizzle-orm-pg");
|
|
26104
26874
|
upPgHandler(out);
|
|
26105
26875
|
});
|
|
26106
|
-
var
|
|
26107
|
-
|
|
26876
|
+
var upMysqlCommand = new Command("up:mysql").option("--out <out>", `Output folder`).option("--config <config>", `Config path [default=drizzle.config.json]`).action((options) => {
|
|
26877
|
+
printVersions();
|
|
26878
|
+
const params = checkSchema.parse(options);
|
|
26879
|
+
const out = assertEitherConfigOrOut(params.config, params.out);
|
|
26880
|
+
if (!out) {
|
|
26881
|
+
console.log(
|
|
26882
|
+
error(
|
|
26883
|
+
`'out' folder param must be set through '--out' param or in config file`
|
|
26884
|
+
)
|
|
26885
|
+
);
|
|
26886
|
+
process.exit(0);
|
|
26887
|
+
}
|
|
26888
|
+
if (!out) {
|
|
26889
|
+
console.log(error(`'out' folder param must be set`));
|
|
26890
|
+
process.exit(0);
|
|
26891
|
+
}
|
|
26892
|
+
upMysqlHandler(out);
|
|
26893
|
+
});
|
|
26894
|
+
var upSqliteCommand = new Command("up:sqlite").option("--out <out>", `Output folder`).option("--config <config>", `Config path [default=drizzle.config.json]`).action((options) => {
|
|
26895
|
+
printVersions();
|
|
26896
|
+
const params = checkSchema.parse(options);
|
|
26897
|
+
const out = assertEitherConfigOrOut(params.config, params.out);
|
|
26108
26898
|
if (!out) {
|
|
26109
|
-
|
|
26899
|
+
console.log(error(`'out' folder param must be set`));
|
|
26110
26900
|
process.exit(0);
|
|
26111
26901
|
}
|
|
26112
26902
|
upSqliteHandler(out);
|
|
@@ -26132,33 +26922,33 @@ var introspectPgCommand = new Command("introspect:pg").option("--out <out>", `Mi
|
|
|
26132
26922
|
const folderName = prepareSnapshotFolderName();
|
|
26133
26923
|
const migrationFolderPath = `./${res.data.out}/${folderName}`;
|
|
26134
26924
|
const { schema: schema4, ts } = await pgIntrospect2(res.data);
|
|
26135
|
-
const schemaFile =
|
|
26136
|
-
(0,
|
|
26925
|
+
const schemaFile = import_path6.default.join(res.data.out, "schema.ts");
|
|
26926
|
+
(0, import_fs8.writeFileSync)(schemaFile, ts);
|
|
26137
26927
|
console.log();
|
|
26138
26928
|
if (migrationFolders.length === 0) {
|
|
26139
|
-
|
|
26140
|
-
const snapshotFile =
|
|
26141
|
-
(0,
|
|
26929
|
+
import_fs8.default.mkdirSync(migrationFolderPath);
|
|
26930
|
+
const snapshotFile = import_path6.default.join(migrationFolderPath, "snapshot.json");
|
|
26931
|
+
(0, import_fs8.writeFileSync)(snapshotFile, JSON.stringify(schema4));
|
|
26142
26932
|
const sql = await prepareSQL(
|
|
26143
26933
|
squashPgScheme(dryPg),
|
|
26144
26934
|
squashPgScheme(schema4),
|
|
26145
26935
|
"pg"
|
|
26146
26936
|
);
|
|
26147
|
-
const sqlFile =
|
|
26148
|
-
(0,
|
|
26149
|
-
(0,
|
|
26937
|
+
const sqlFile = import_path6.default.join(migrationFolderPath, "migration.sql");
|
|
26938
|
+
(0, import_fs8.writeFileSync)(sqlFile, sql);
|
|
26939
|
+
(0, import_hanji4.render)(
|
|
26150
26940
|
`[${source_default.green(
|
|
26151
26941
|
"\u2713"
|
|
26152
26942
|
)}] Your SQL migration file \u279C ${source_default.bold.underline.blue(sqlFile)} \u{1F680}`
|
|
26153
26943
|
);
|
|
26154
26944
|
} else {
|
|
26155
|
-
(0,
|
|
26945
|
+
(0, import_hanji4.render)(
|
|
26156
26946
|
`[${source_default.blue(
|
|
26157
26947
|
"i"
|
|
26158
26948
|
)}] No SQL generated, you already have migrations in project`
|
|
26159
26949
|
);
|
|
26160
26950
|
}
|
|
26161
|
-
(0,
|
|
26951
|
+
(0, import_hanji4.render)(
|
|
26162
26952
|
`[${source_default.green(
|
|
26163
26953
|
"\u2713"
|
|
26164
26954
|
)}] You schema file is ready \u279C ${source_default.bold.underline.blue(
|
|
@@ -26174,6 +26964,7 @@ program.addCommand(generateSqliteCommand);
|
|
|
26174
26964
|
program.addCommand(checkPgCommand);
|
|
26175
26965
|
program.addCommand(checkSqliteCommand);
|
|
26176
26966
|
program.addCommand(upPgCommand);
|
|
26967
|
+
program.addCommand(upMysqlCommand);
|
|
26177
26968
|
program.addCommand(upSqliteCommand);
|
|
26178
26969
|
program.addCommand(introspectPgCommand);
|
|
26179
26970
|
program.parse();
|