@prisma/migrate 6.20.0-dev.7 → 6.20.0-dev.9
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/CLI.js +2 -2
- package/dist/Migrate.js +4 -8
- package/dist/SchemaEngineCLI.js +4 -4
- package/dist/SchemaEngineWasm.js +4 -4
- package/dist/bin.js +71 -74
- package/dist/chunk-3MCWUFUJ.js +169 -0
- package/dist/{chunk-O35BTK6Y.js → chunk-7BNYLV6P.js} +7 -14
- package/dist/{chunk-F2XCBEZ4.js → chunk-AIUUIREM.js} +27 -53
- package/dist/{chunk-74LUB4XX.js → chunk-BRPS327A.js} +23 -45
- package/dist/{chunk-7TVX3D4W.js → chunk-CQ6GMT2G.js} +23 -69
- package/dist/{chunk-EJG7GKM7.js → chunk-DCXZOUQV.js} +5 -5
- package/dist/{chunk-LLO7YF56.js → chunk-DYXUXG3K.js} +7 -7
- package/dist/{chunk-GSX25HRL.js → chunk-ENVEA7LT.js} +10 -13
- package/dist/{chunk-6ORQRJLP.js → chunk-FEUKQ7J3.js} +38 -132
- package/dist/{chunk-BHJMJSM4.js → chunk-IQWOR45L.js} +28 -24
- package/dist/{chunk-R4IWP35Z.js → chunk-IVL273O6.js} +20 -20
- package/dist/{chunk-PHXLQVPT.js → chunk-L7EZFBB4.js} +40 -68
- package/dist/{chunk-3AKRTEIK.js → chunk-N4SBKLAB.js} +24 -23
- package/dist/{chunk-NGQA5JTN.js → chunk-OAHBNV3B.js} +5 -5
- package/dist/{chunk-22YP3RXZ.js → chunk-OZ26HKM7.js} +7 -7
- package/dist/{chunk-AXR7LS2N.js → chunk-PEUHUCS4.js} +4 -5
- package/dist/{chunk-TW22Y3AA.js → chunk-QAOWTYGM.js} +31 -32
- package/dist/{chunk-2FXU5NZQ.js → chunk-QOPTDDIH.js} +5 -10
- package/dist/{chunk-J33EXHZB.js → chunk-S4LY555Z.js} +26 -46
- package/dist/{chunk-NB4FRYRQ.js → chunk-TLHUBVSH.js} +6 -6
- package/dist/{chunk-Z27SI4AV.js → chunk-TRUKHPCA.js} +20 -15
- package/dist/{chunk-D4TRX77Y.js → chunk-WF7UXKO5.js} +6 -9
- package/dist/{chunk-ZTIS675B.js → chunk-XFASRSQR.js} +81 -172
- package/dist/{chunk-3WC4XD74.js → chunk-XGTVKL4L.js} +11 -4
- package/dist/{chunk-VU5BLQUI.js → chunk-ZOT2HSX5.js} +218 -22
- package/dist/commands/DbCommand.js +2 -2
- package/dist/commands/DbDrop.js +5 -5
- package/dist/commands/DbExecute.js +5 -9
- package/dist/commands/DbPull.js +10 -16
- package/dist/commands/DbPush.js +8 -12
- package/dist/commands/DbSeed.js +3 -3
- package/dist/commands/MigrateCommand.js +2 -2
- package/dist/commands/MigrateDeploy.js +7 -11
- package/dist/commands/MigrateDev.js +8 -13
- package/dist/commands/MigrateDiff.js +6 -9
- package/dist/commands/MigrateReset.js +8 -13
- package/dist/commands/MigrateResolve.js +7 -11
- package/dist/commands/MigrateStatus.js +7 -11
- package/dist/index.js +44 -48
- package/dist/internals/src/cli/getSchema.d.ts +1 -15
- package/dist/migrate/src/CLI.d.ts +1 -1
- package/dist/migrate/src/Migrate.d.ts +2 -3
- package/dist/migrate/src/SchemaEngineCLI.d.ts +4 -3
- package/dist/migrate/src/commands/DbCommand.d.ts +1 -1
- package/dist/migrate/src/commands/DbDrop.d.ts +1 -1
- package/dist/migrate/src/commands/DbExecute.d.ts +1 -1
- package/dist/migrate/src/commands/DbPull.d.ts +1 -2
- package/dist/migrate/src/commands/DbPush.d.ts +1 -1
- package/dist/migrate/src/commands/MigrateCommand.d.ts +1 -1
- package/dist/migrate/src/commands/MigrateDeploy.d.ts +1 -1
- package/dist/migrate/src/commands/MigrateDev.d.ts +1 -1
- package/dist/migrate/src/commands/MigrateDiff.d.ts +2 -1
- package/dist/migrate/src/commands/MigrateReset.d.ts +1 -1
- package/dist/migrate/src/commands/MigrateResolve.d.ts +1 -1
- package/dist/migrate/src/commands/MigrateStatus.d.ts +1 -1
- package/dist/migrate/src/utils/ensureDatabaseExists.d.ts +9 -5
- package/dist/migrate/src/utils/errors.d.ts +3 -0
- package/dist/migrate/src/utils/getDatabaseVersionSafe.d.ts +2 -1
- package/dist/migrate/src/utils/introspectSql.d.ts +2 -2
- package/dist/migrate/src/utils/printDatasource.d.ts +1 -3
- package/dist/migrate/src/utils/seed.d.ts +0 -6
- package/dist/utils/ensureDatabaseExists.js +6 -6
- package/dist/utils/errors.js +8 -7
- package/dist/utils/getDatabaseVersionSafe.js +5 -9
- package/dist/utils/introspectSql.js +5 -9
- package/dist/utils/printDatasource.js +2 -2
- package/dist/utils/printDatasources.js +31 -3
- package/dist/utils/seed.js +2 -3
- package/dist/utils/setupMSSQL.js +18 -3
- package/dist/utils/spinner.js +2 -3
- package/dist/views/handleViewsIO.js +2 -2
- package/package.json +11 -11
- package/dist/chunk-AI6DH66U.js +0 -55
- package/dist/chunk-D6LYHB65.js +0 -905
- package/dist/chunk-RR6BKMNO.js +0 -80
- package/dist/chunk-T64SUJ5L.js +0 -46
- package/dist/chunk-VV4M6AN7.js +0 -233
- package/dist/migrate/src/utils/replaceOrAddDatasource.d.ts +0 -2
- package/dist/migrate/src/utils/replaceOrAddDatasource.test.d.ts +0 -1
- package/dist/migrate/src/utils/warnDatasourceDriverAdapter.d.ts +0 -2
- package/dist/utils/replaceOrAddDatasource.js +0 -25
- package/dist/utils/replaceOrAddDatasource.test.js +0 -207
- package/dist/utils/warnDatasourceDriverAdapter.js +0 -25
package/dist/chunk-D6LYHB65.js
DELETED
|
@@ -1,905 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __create = Object.create;
|
|
3
|
-
var __defProp = Object.defineProperty;
|
|
4
|
-
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
|
-
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
-
var __getProtoOf = Object.getPrototypeOf;
|
|
7
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
8
|
-
var __export = (target, all) => {
|
|
9
|
-
for (var name in all)
|
|
10
|
-
__defProp(target, name, { get: all[name], enumerable: true });
|
|
11
|
-
};
|
|
12
|
-
var __copyProps = (to, from, except, desc) => {
|
|
13
|
-
if (from && typeof from === "object" || typeof from === "function") {
|
|
14
|
-
for (let key of __getOwnPropNames(from))
|
|
15
|
-
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
16
|
-
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
17
|
-
}
|
|
18
|
-
return to;
|
|
19
|
-
};
|
|
20
|
-
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
21
|
-
// If the importer is in node compatibility mode or this is not an ESM
|
|
22
|
-
// file that has been converted to a CommonJS file using a Babel-
|
|
23
|
-
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
24
|
-
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
25
|
-
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
26
|
-
mod
|
|
27
|
-
));
|
|
28
|
-
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
29
|
-
var chunk_D6LYHB65_exports = {};
|
|
30
|
-
__export(chunk_D6LYHB65_exports, {
|
|
31
|
-
Migrate: () => Migrate
|
|
32
|
-
});
|
|
33
|
-
module.exports = __toCommonJS(chunk_D6LYHB65_exports);
|
|
34
|
-
var import_chunk_T64SUJ5L = require("./chunk-T64SUJ5L.js");
|
|
35
|
-
var import_chunk_VV4M6AN7 = require("./chunk-VV4M6AN7.js");
|
|
36
|
-
var import_chunk_GGA2F64G = require("./chunk-GGA2F64G.js");
|
|
37
|
-
var import_chunk_23DZXSTI = require("./chunk-23DZXSTI.js");
|
|
38
|
-
var import_chunk_22YP3RXZ = require("./chunk-22YP3RXZ.js");
|
|
39
|
-
var import_chunk_GSX25HRL = require("./chunk-GSX25HRL.js");
|
|
40
|
-
var import_chunk_SKRR5WT4 = require("./chunk-SKRR5WT4.js");
|
|
41
|
-
var import_chunk_2ESYSVXG = require("./chunk-2ESYSVXG.js");
|
|
42
|
-
var import_client_generator_registry = require("@prisma/client-generator-registry");
|
|
43
|
-
var import_engines_version = require("@prisma/engines-version");
|
|
44
|
-
var import_internals = require("@prisma/internals");
|
|
45
|
-
var import_node_process = __toESM(require("node:process"));
|
|
46
|
-
var import_node_process2 = __toESM(require("node:process"));
|
|
47
|
-
var base_exports = {};
|
|
48
|
-
(0, import_chunk_2ESYSVXG.__export)(base_exports, {
|
|
49
|
-
beep: () => beep,
|
|
50
|
-
clearScreen: () => clearScreen,
|
|
51
|
-
clearTerminal: () => clearTerminal,
|
|
52
|
-
cursorBackward: () => cursorBackward,
|
|
53
|
-
cursorDown: () => cursorDown,
|
|
54
|
-
cursorForward: () => cursorForward,
|
|
55
|
-
cursorGetPosition: () => cursorGetPosition,
|
|
56
|
-
cursorHide: () => cursorHide,
|
|
57
|
-
cursorLeft: () => cursorLeft,
|
|
58
|
-
cursorMove: () => cursorMove,
|
|
59
|
-
cursorNextLine: () => cursorNextLine,
|
|
60
|
-
cursorPrevLine: () => cursorPrevLine,
|
|
61
|
-
cursorRestorePosition: () => cursorRestorePosition,
|
|
62
|
-
cursorSavePosition: () => cursorSavePosition,
|
|
63
|
-
cursorShow: () => cursorShow,
|
|
64
|
-
cursorTo: () => cursorTo,
|
|
65
|
-
cursorUp: () => cursorUp,
|
|
66
|
-
enterAlternativeScreen: () => enterAlternativeScreen,
|
|
67
|
-
eraseDown: () => eraseDown,
|
|
68
|
-
eraseEndLine: () => eraseEndLine,
|
|
69
|
-
eraseLine: () => eraseLine,
|
|
70
|
-
eraseLines: () => eraseLines,
|
|
71
|
-
eraseScreen: () => eraseScreen,
|
|
72
|
-
eraseStartLine: () => eraseStartLine,
|
|
73
|
-
eraseUp: () => eraseUp,
|
|
74
|
-
exitAlternativeScreen: () => exitAlternativeScreen,
|
|
75
|
-
iTerm: () => iTerm,
|
|
76
|
-
image: () => image,
|
|
77
|
-
link: () => link,
|
|
78
|
-
scrollDown: () => scrollDown,
|
|
79
|
-
scrollUp: () => scrollUp
|
|
80
|
-
});
|
|
81
|
-
var isBrowser = globalThis.window?.document !== void 0;
|
|
82
|
-
var isNode = globalThis.process?.versions?.node !== void 0;
|
|
83
|
-
var isBun = globalThis.process?.versions?.bun !== void 0;
|
|
84
|
-
var isDeno = globalThis.Deno?.version?.deno !== void 0;
|
|
85
|
-
var isElectron = globalThis.process?.versions?.electron !== void 0;
|
|
86
|
-
var isJsDom = globalThis.navigator?.userAgent?.includes("jsdom") === true;
|
|
87
|
-
var isWebWorker = typeof WorkerGlobalScope !== "undefined" && globalThis instanceof WorkerGlobalScope;
|
|
88
|
-
var isDedicatedWorker = typeof DedicatedWorkerGlobalScope !== "undefined" && globalThis instanceof DedicatedWorkerGlobalScope;
|
|
89
|
-
var isSharedWorker = typeof SharedWorkerGlobalScope !== "undefined" && globalThis instanceof SharedWorkerGlobalScope;
|
|
90
|
-
var isServiceWorker = typeof ServiceWorkerGlobalScope !== "undefined" && globalThis instanceof ServiceWorkerGlobalScope;
|
|
91
|
-
var platform = globalThis.navigator?.userAgentData?.platform;
|
|
92
|
-
var isMacOs = platform === "macOS" || globalThis.navigator?.platform === "MacIntel" || globalThis.navigator?.userAgent?.includes(" Mac ") === true || globalThis.process?.platform === "darwin";
|
|
93
|
-
var isWindows = platform === "Windows" || globalThis.navigator?.platform === "Win32" || globalThis.process?.platform === "win32";
|
|
94
|
-
var isLinux = platform === "Linux" || globalThis.navigator?.platform?.startsWith("Linux") === true || globalThis.navigator?.userAgent?.includes(" Linux ") === true || globalThis.process?.platform === "linux";
|
|
95
|
-
var isIos = platform === "iOS" || globalThis.navigator?.platform === "MacIntel" && globalThis.navigator?.maxTouchPoints > 1 || /iPad|iPhone|iPod/.test(globalThis.navigator?.platform);
|
|
96
|
-
var isAndroid = platform === "Android" || globalThis.navigator?.platform === "Android" || globalThis.navigator?.userAgent?.includes(" Android ") === true || globalThis.process?.platform === "android";
|
|
97
|
-
var ESC = "\x1B[";
|
|
98
|
-
var OSC = "\x1B]";
|
|
99
|
-
var BEL = "\x07";
|
|
100
|
-
var SEP = ";";
|
|
101
|
-
var isTerminalApp = !isBrowser && import_node_process2.default.env.TERM_PROGRAM === "Apple_Terminal";
|
|
102
|
-
var isWindows2 = !isBrowser && import_node_process2.default.platform === "win32";
|
|
103
|
-
var cwdFunction = isBrowser ? () => {
|
|
104
|
-
throw new Error("`process.cwd()` only works in Node.js, not the browser.");
|
|
105
|
-
} : import_node_process2.default.cwd;
|
|
106
|
-
var cursorTo = (x, y) => {
|
|
107
|
-
if (typeof x !== "number") {
|
|
108
|
-
throw new TypeError("The `x` argument is required");
|
|
109
|
-
}
|
|
110
|
-
if (typeof y !== "number") {
|
|
111
|
-
return ESC + (x + 1) + "G";
|
|
112
|
-
}
|
|
113
|
-
return ESC + (y + 1) + SEP + (x + 1) + "H";
|
|
114
|
-
};
|
|
115
|
-
var cursorMove = (x, y) => {
|
|
116
|
-
if (typeof x !== "number") {
|
|
117
|
-
throw new TypeError("The `x` argument is required");
|
|
118
|
-
}
|
|
119
|
-
let returnValue = "";
|
|
120
|
-
if (x < 0) {
|
|
121
|
-
returnValue += ESC + -x + "D";
|
|
122
|
-
} else if (x > 0) {
|
|
123
|
-
returnValue += ESC + x + "C";
|
|
124
|
-
}
|
|
125
|
-
if (y < 0) {
|
|
126
|
-
returnValue += ESC + -y + "A";
|
|
127
|
-
} else if (y > 0) {
|
|
128
|
-
returnValue += ESC + y + "B";
|
|
129
|
-
}
|
|
130
|
-
return returnValue;
|
|
131
|
-
};
|
|
132
|
-
var cursorUp = (count = 1) => ESC + count + "A";
|
|
133
|
-
var cursorDown = (count = 1) => ESC + count + "B";
|
|
134
|
-
var cursorForward = (count = 1) => ESC + count + "C";
|
|
135
|
-
var cursorBackward = (count = 1) => ESC + count + "D";
|
|
136
|
-
var cursorLeft = ESC + "G";
|
|
137
|
-
var cursorSavePosition = isTerminalApp ? "\x1B7" : ESC + "s";
|
|
138
|
-
var cursorRestorePosition = isTerminalApp ? "\x1B8" : ESC + "u";
|
|
139
|
-
var cursorGetPosition = ESC + "6n";
|
|
140
|
-
var cursorNextLine = ESC + "E";
|
|
141
|
-
var cursorPrevLine = ESC + "F";
|
|
142
|
-
var cursorHide = ESC + "?25l";
|
|
143
|
-
var cursorShow = ESC + "?25h";
|
|
144
|
-
var eraseLines = (count) => {
|
|
145
|
-
let clear = "";
|
|
146
|
-
for (let i = 0; i < count; i++) {
|
|
147
|
-
clear += eraseLine + (i < count - 1 ? cursorUp() : "");
|
|
148
|
-
}
|
|
149
|
-
if (count) {
|
|
150
|
-
clear += cursorLeft;
|
|
151
|
-
}
|
|
152
|
-
return clear;
|
|
153
|
-
};
|
|
154
|
-
var eraseEndLine = ESC + "K";
|
|
155
|
-
var eraseStartLine = ESC + "1K";
|
|
156
|
-
var eraseLine = ESC + "2K";
|
|
157
|
-
var eraseDown = ESC + "J";
|
|
158
|
-
var eraseUp = ESC + "1J";
|
|
159
|
-
var eraseScreen = ESC + "2J";
|
|
160
|
-
var scrollUp = ESC + "S";
|
|
161
|
-
var scrollDown = ESC + "T";
|
|
162
|
-
var clearScreen = "\x1Bc";
|
|
163
|
-
var clearTerminal = isWindows2 ? `${eraseScreen}${ESC}0f` : `${eraseScreen}${ESC}3J${ESC}H`;
|
|
164
|
-
var enterAlternativeScreen = ESC + "?1049h";
|
|
165
|
-
var exitAlternativeScreen = ESC + "?1049l";
|
|
166
|
-
var beep = BEL;
|
|
167
|
-
var link = (text, url) => [
|
|
168
|
-
OSC,
|
|
169
|
-
"8",
|
|
170
|
-
SEP,
|
|
171
|
-
SEP,
|
|
172
|
-
url,
|
|
173
|
-
BEL,
|
|
174
|
-
text,
|
|
175
|
-
OSC,
|
|
176
|
-
"8",
|
|
177
|
-
SEP,
|
|
178
|
-
SEP,
|
|
179
|
-
BEL
|
|
180
|
-
].join("");
|
|
181
|
-
var image = (data, options = {}) => {
|
|
182
|
-
let returnValue = `${OSC}1337;File=inline=1`;
|
|
183
|
-
if (options.width) {
|
|
184
|
-
returnValue += `;width=${options.width}`;
|
|
185
|
-
}
|
|
186
|
-
if (options.height) {
|
|
187
|
-
returnValue += `;height=${options.height}`;
|
|
188
|
-
}
|
|
189
|
-
if (options.preserveAspectRatio === false) {
|
|
190
|
-
returnValue += ";preserveAspectRatio=0";
|
|
191
|
-
}
|
|
192
|
-
return returnValue + ":" + Buffer.from(data).toString("base64") + BEL;
|
|
193
|
-
};
|
|
194
|
-
var iTerm = {
|
|
195
|
-
setCwd: (cwd = cwdFunction()) => `${OSC}50;CurrentDir=${cwd}${BEL}`,
|
|
196
|
-
annotation(message, options = {}) {
|
|
197
|
-
let returnValue = `${OSC}1337;`;
|
|
198
|
-
const hasX = options.x !== void 0;
|
|
199
|
-
const hasY = options.y !== void 0;
|
|
200
|
-
if ((hasX || hasY) && !(hasX && hasY && options.length !== void 0)) {
|
|
201
|
-
throw new Error("`x`, `y` and `length` must be defined when `x` or `y` is defined");
|
|
202
|
-
}
|
|
203
|
-
message = message.replaceAll("|", "");
|
|
204
|
-
returnValue += options.isHidden ? "AddHiddenAnnotation=" : "AddAnnotation=";
|
|
205
|
-
if (options.length > 0) {
|
|
206
|
-
returnValue += (hasX ? [message, options.length, options.x, options.y] : [options.length, message]).join("|");
|
|
207
|
-
} else {
|
|
208
|
-
returnValue += message;
|
|
209
|
-
}
|
|
210
|
-
return returnValue + BEL;
|
|
211
|
-
}
|
|
212
|
-
};
|
|
213
|
-
var ANSI_BACKGROUND_OFFSET = 10;
|
|
214
|
-
var wrapAnsi16 = (offset = 0) => (code) => `\x1B[${code + offset}m`;
|
|
215
|
-
var wrapAnsi256 = (offset = 0) => (code) => `\x1B[${38 + offset};5;${code}m`;
|
|
216
|
-
var wrapAnsi16m = (offset = 0) => (red, green, blue) => `\x1B[${38 + offset};2;${red};${green};${blue}m`;
|
|
217
|
-
var styles = {
|
|
218
|
-
modifier: {
|
|
219
|
-
reset: [0, 0],
|
|
220
|
-
// 21 isn't widely supported and 22 does the same thing
|
|
221
|
-
bold: [1, 22],
|
|
222
|
-
dim: [2, 22],
|
|
223
|
-
italic: [3, 23],
|
|
224
|
-
underline: [4, 24],
|
|
225
|
-
overline: [53, 55],
|
|
226
|
-
inverse: [7, 27],
|
|
227
|
-
hidden: [8, 28],
|
|
228
|
-
strikethrough: [9, 29]
|
|
229
|
-
},
|
|
230
|
-
color: {
|
|
231
|
-
black: [30, 39],
|
|
232
|
-
red: [31, 39],
|
|
233
|
-
green: [32, 39],
|
|
234
|
-
yellow: [33, 39],
|
|
235
|
-
blue: [34, 39],
|
|
236
|
-
magenta: [35, 39],
|
|
237
|
-
cyan: [36, 39],
|
|
238
|
-
white: [37, 39],
|
|
239
|
-
// Bright color
|
|
240
|
-
blackBright: [90, 39],
|
|
241
|
-
gray: [90, 39],
|
|
242
|
-
// Alias of `blackBright`
|
|
243
|
-
grey: [90, 39],
|
|
244
|
-
// Alias of `blackBright`
|
|
245
|
-
redBright: [91, 39],
|
|
246
|
-
greenBright: [92, 39],
|
|
247
|
-
yellowBright: [93, 39],
|
|
248
|
-
blueBright: [94, 39],
|
|
249
|
-
magentaBright: [95, 39],
|
|
250
|
-
cyanBright: [96, 39],
|
|
251
|
-
whiteBright: [97, 39]
|
|
252
|
-
},
|
|
253
|
-
bgColor: {
|
|
254
|
-
bgBlack: [40, 49],
|
|
255
|
-
bgRed: [41, 49],
|
|
256
|
-
bgGreen: [42, 49],
|
|
257
|
-
bgYellow: [43, 49],
|
|
258
|
-
bgBlue: [44, 49],
|
|
259
|
-
bgMagenta: [45, 49],
|
|
260
|
-
bgCyan: [46, 49],
|
|
261
|
-
bgWhite: [47, 49],
|
|
262
|
-
// Bright color
|
|
263
|
-
bgBlackBright: [100, 49],
|
|
264
|
-
bgGray: [100, 49],
|
|
265
|
-
// Alias of `bgBlackBright`
|
|
266
|
-
bgGrey: [100, 49],
|
|
267
|
-
// Alias of `bgBlackBright`
|
|
268
|
-
bgRedBright: [101, 49],
|
|
269
|
-
bgGreenBright: [102, 49],
|
|
270
|
-
bgYellowBright: [103, 49],
|
|
271
|
-
bgBlueBright: [104, 49],
|
|
272
|
-
bgMagentaBright: [105, 49],
|
|
273
|
-
bgCyanBright: [106, 49],
|
|
274
|
-
bgWhiteBright: [107, 49]
|
|
275
|
-
}
|
|
276
|
-
};
|
|
277
|
-
var modifierNames = Object.keys(styles.modifier);
|
|
278
|
-
var foregroundColorNames = Object.keys(styles.color);
|
|
279
|
-
var backgroundColorNames = Object.keys(styles.bgColor);
|
|
280
|
-
var colorNames = [...foregroundColorNames, ...backgroundColorNames];
|
|
281
|
-
function assembleStyles() {
|
|
282
|
-
const codes = /* @__PURE__ */ new Map();
|
|
283
|
-
for (const [groupName, group] of Object.entries(styles)) {
|
|
284
|
-
for (const [styleName, style] of Object.entries(group)) {
|
|
285
|
-
styles[styleName] = {
|
|
286
|
-
open: `\x1B[${style[0]}m`,
|
|
287
|
-
close: `\x1B[${style[1]}m`
|
|
288
|
-
};
|
|
289
|
-
group[styleName] = styles[styleName];
|
|
290
|
-
codes.set(style[0], style[1]);
|
|
291
|
-
}
|
|
292
|
-
Object.defineProperty(styles, groupName, {
|
|
293
|
-
value: group,
|
|
294
|
-
enumerable: false
|
|
295
|
-
});
|
|
296
|
-
}
|
|
297
|
-
Object.defineProperty(styles, "codes", {
|
|
298
|
-
value: codes,
|
|
299
|
-
enumerable: false
|
|
300
|
-
});
|
|
301
|
-
styles.color.close = "\x1B[39m";
|
|
302
|
-
styles.bgColor.close = "\x1B[49m";
|
|
303
|
-
styles.color.ansi = wrapAnsi16();
|
|
304
|
-
styles.color.ansi256 = wrapAnsi256();
|
|
305
|
-
styles.color.ansi16m = wrapAnsi16m();
|
|
306
|
-
styles.bgColor.ansi = wrapAnsi16(ANSI_BACKGROUND_OFFSET);
|
|
307
|
-
styles.bgColor.ansi256 = wrapAnsi256(ANSI_BACKGROUND_OFFSET);
|
|
308
|
-
styles.bgColor.ansi16m = wrapAnsi16m(ANSI_BACKGROUND_OFFSET);
|
|
309
|
-
Object.defineProperties(styles, {
|
|
310
|
-
rgbToAnsi256: {
|
|
311
|
-
value: (red, green, blue) => {
|
|
312
|
-
if (red === green && green === blue) {
|
|
313
|
-
if (red < 8) {
|
|
314
|
-
return 16;
|
|
315
|
-
}
|
|
316
|
-
if (red > 248) {
|
|
317
|
-
return 231;
|
|
318
|
-
}
|
|
319
|
-
return Math.round((red - 8) / 247 * 24) + 232;
|
|
320
|
-
}
|
|
321
|
-
return 16 + 36 * Math.round(red / 255 * 5) + 6 * Math.round(green / 255 * 5) + Math.round(blue / 255 * 5);
|
|
322
|
-
},
|
|
323
|
-
enumerable: false
|
|
324
|
-
},
|
|
325
|
-
hexToRgb: {
|
|
326
|
-
value: (hex) => {
|
|
327
|
-
const matches = /[a-f\d]{6}|[a-f\d]{3}/i.exec(hex.toString(16));
|
|
328
|
-
if (!matches) {
|
|
329
|
-
return [0, 0, 0];
|
|
330
|
-
}
|
|
331
|
-
let [colorString] = matches;
|
|
332
|
-
if (colorString.length === 3) {
|
|
333
|
-
colorString = [...colorString].map((character) => character + character).join("");
|
|
334
|
-
}
|
|
335
|
-
const integer = Number.parseInt(colorString, 16);
|
|
336
|
-
return [
|
|
337
|
-
/* eslint-disable no-bitwise */
|
|
338
|
-
integer >> 16 & 255,
|
|
339
|
-
integer >> 8 & 255,
|
|
340
|
-
integer & 255
|
|
341
|
-
/* eslint-enable no-bitwise */
|
|
342
|
-
];
|
|
343
|
-
},
|
|
344
|
-
enumerable: false
|
|
345
|
-
},
|
|
346
|
-
hexToAnsi256: {
|
|
347
|
-
value: (hex) => styles.rgbToAnsi256(...styles.hexToRgb(hex)),
|
|
348
|
-
enumerable: false
|
|
349
|
-
},
|
|
350
|
-
ansi256ToAnsi: {
|
|
351
|
-
value: (code) => {
|
|
352
|
-
if (code < 8) {
|
|
353
|
-
return 30 + code;
|
|
354
|
-
}
|
|
355
|
-
if (code < 16) {
|
|
356
|
-
return 90 + (code - 8);
|
|
357
|
-
}
|
|
358
|
-
let red;
|
|
359
|
-
let green;
|
|
360
|
-
let blue;
|
|
361
|
-
if (code >= 232) {
|
|
362
|
-
red = ((code - 232) * 10 + 8) / 255;
|
|
363
|
-
green = red;
|
|
364
|
-
blue = red;
|
|
365
|
-
} else {
|
|
366
|
-
code -= 16;
|
|
367
|
-
const remainder = code % 36;
|
|
368
|
-
red = Math.floor(code / 36) / 5;
|
|
369
|
-
green = Math.floor(remainder / 6) / 5;
|
|
370
|
-
blue = remainder % 6 / 5;
|
|
371
|
-
}
|
|
372
|
-
const value = Math.max(red, green, blue) * 2;
|
|
373
|
-
if (value === 0) {
|
|
374
|
-
return 30;
|
|
375
|
-
}
|
|
376
|
-
let result = 30 + (Math.round(blue) << 2 | Math.round(green) << 1 | Math.round(red));
|
|
377
|
-
if (value === 2) {
|
|
378
|
-
result += 60;
|
|
379
|
-
}
|
|
380
|
-
return result;
|
|
381
|
-
},
|
|
382
|
-
enumerable: false
|
|
383
|
-
},
|
|
384
|
-
rgbToAnsi: {
|
|
385
|
-
value: (red, green, blue) => styles.ansi256ToAnsi(styles.rgbToAnsi256(red, green, blue)),
|
|
386
|
-
enumerable: false
|
|
387
|
-
},
|
|
388
|
-
hexToAnsi: {
|
|
389
|
-
value: (hex) => styles.ansi256ToAnsi(styles.hexToAnsi256(hex)),
|
|
390
|
-
enumerable: false
|
|
391
|
-
}
|
|
392
|
-
});
|
|
393
|
-
return styles;
|
|
394
|
-
}
|
|
395
|
-
var ansiStyles = assembleStyles();
|
|
396
|
-
var ansi_styles_default = ansiStyles;
|
|
397
|
-
var ESCAPES = /* @__PURE__ */ new Set([
|
|
398
|
-
"\x1B",
|
|
399
|
-
"\x9B"
|
|
400
|
-
]);
|
|
401
|
-
var END_CODE = 39;
|
|
402
|
-
var ANSI_ESCAPE_BELL = "\x07";
|
|
403
|
-
var ANSI_CSI = "[";
|
|
404
|
-
var ANSI_OSC = "]";
|
|
405
|
-
var ANSI_SGR_TERMINATOR = "m";
|
|
406
|
-
var ANSI_ESCAPE_LINK = `${ANSI_OSC}8;;`;
|
|
407
|
-
var wrapAnsiCode = (code) => `${ESCAPES.values().next().value}${ANSI_CSI}${code}${ANSI_SGR_TERMINATOR}`;
|
|
408
|
-
var wrapAnsiHyperlink = (url) => `${ESCAPES.values().next().value}${ANSI_ESCAPE_LINK}${url}${ANSI_ESCAPE_BELL}`;
|
|
409
|
-
var wordLengths = (string) => string.split(" ").map((character) => (0, import_chunk_VV4M6AN7.stringWidth)(character));
|
|
410
|
-
var wrapWord = (rows, word, columns) => {
|
|
411
|
-
const characters = [...word];
|
|
412
|
-
let isInsideEscape = false;
|
|
413
|
-
let isInsideLinkEscape = false;
|
|
414
|
-
let visible = (0, import_chunk_VV4M6AN7.stringWidth)((0, import_chunk_VV4M6AN7.stripAnsi)(rows.at(-1)));
|
|
415
|
-
for (const [index, character] of characters.entries()) {
|
|
416
|
-
const characterLength = (0, import_chunk_VV4M6AN7.stringWidth)(character);
|
|
417
|
-
if (visible + characterLength <= columns) {
|
|
418
|
-
rows[rows.length - 1] += character;
|
|
419
|
-
} else {
|
|
420
|
-
rows.push(character);
|
|
421
|
-
visible = 0;
|
|
422
|
-
}
|
|
423
|
-
if (ESCAPES.has(character)) {
|
|
424
|
-
isInsideEscape = true;
|
|
425
|
-
const ansiEscapeLinkCandidate = characters.slice(index + 1, index + 1 + ANSI_ESCAPE_LINK.length).join("");
|
|
426
|
-
isInsideLinkEscape = ansiEscapeLinkCandidate === ANSI_ESCAPE_LINK;
|
|
427
|
-
}
|
|
428
|
-
if (isInsideEscape) {
|
|
429
|
-
if (isInsideLinkEscape) {
|
|
430
|
-
if (character === ANSI_ESCAPE_BELL) {
|
|
431
|
-
isInsideEscape = false;
|
|
432
|
-
isInsideLinkEscape = false;
|
|
433
|
-
}
|
|
434
|
-
} else if (character === ANSI_SGR_TERMINATOR) {
|
|
435
|
-
isInsideEscape = false;
|
|
436
|
-
}
|
|
437
|
-
continue;
|
|
438
|
-
}
|
|
439
|
-
visible += characterLength;
|
|
440
|
-
if (visible === columns && index < characters.length - 1) {
|
|
441
|
-
rows.push("");
|
|
442
|
-
visible = 0;
|
|
443
|
-
}
|
|
444
|
-
}
|
|
445
|
-
if (!visible && rows.at(-1).length > 0 && rows.length > 1) {
|
|
446
|
-
rows[rows.length - 2] += rows.pop();
|
|
447
|
-
}
|
|
448
|
-
};
|
|
449
|
-
var stringVisibleTrimSpacesRight = (string) => {
|
|
450
|
-
const words = string.split(" ");
|
|
451
|
-
let last = words.length;
|
|
452
|
-
while (last > 0) {
|
|
453
|
-
if ((0, import_chunk_VV4M6AN7.stringWidth)(words[last - 1]) > 0) {
|
|
454
|
-
break;
|
|
455
|
-
}
|
|
456
|
-
last--;
|
|
457
|
-
}
|
|
458
|
-
if (last === words.length) {
|
|
459
|
-
return string;
|
|
460
|
-
}
|
|
461
|
-
return words.slice(0, last).join(" ") + words.slice(last).join("");
|
|
462
|
-
};
|
|
463
|
-
var exec = (string, columns, options = {}) => {
|
|
464
|
-
if (options.trim !== false && string.trim() === "") {
|
|
465
|
-
return "";
|
|
466
|
-
}
|
|
467
|
-
let returnValue = "";
|
|
468
|
-
let escapeCode;
|
|
469
|
-
let escapeUrl;
|
|
470
|
-
const lengths = wordLengths(string);
|
|
471
|
-
let rows = [""];
|
|
472
|
-
for (const [index, word] of string.split(" ").entries()) {
|
|
473
|
-
if (options.trim !== false) {
|
|
474
|
-
rows[rows.length - 1] = rows.at(-1).trimStart();
|
|
475
|
-
}
|
|
476
|
-
let rowLength = (0, import_chunk_VV4M6AN7.stringWidth)(rows.at(-1));
|
|
477
|
-
if (index !== 0) {
|
|
478
|
-
if (rowLength >= columns && (options.wordWrap === false || options.trim === false)) {
|
|
479
|
-
rows.push("");
|
|
480
|
-
rowLength = 0;
|
|
481
|
-
}
|
|
482
|
-
if (rowLength > 0 || options.trim === false) {
|
|
483
|
-
rows[rows.length - 1] += " ";
|
|
484
|
-
rowLength++;
|
|
485
|
-
}
|
|
486
|
-
}
|
|
487
|
-
if (options.hard && lengths[index] > columns) {
|
|
488
|
-
const remainingColumns = columns - rowLength;
|
|
489
|
-
const breaksStartingThisLine = 1 + Math.floor((lengths[index] - remainingColumns - 1) / columns);
|
|
490
|
-
const breaksStartingNextLine = Math.floor((lengths[index] - 1) / columns);
|
|
491
|
-
if (breaksStartingNextLine < breaksStartingThisLine) {
|
|
492
|
-
rows.push("");
|
|
493
|
-
}
|
|
494
|
-
wrapWord(rows, word, columns);
|
|
495
|
-
continue;
|
|
496
|
-
}
|
|
497
|
-
if (rowLength + lengths[index] > columns && rowLength > 0 && lengths[index] > 0) {
|
|
498
|
-
if (options.wordWrap === false && rowLength < columns) {
|
|
499
|
-
wrapWord(rows, word, columns);
|
|
500
|
-
continue;
|
|
501
|
-
}
|
|
502
|
-
rows.push("");
|
|
503
|
-
}
|
|
504
|
-
if (rowLength + lengths[index] > columns && options.wordWrap === false) {
|
|
505
|
-
wrapWord(rows, word, columns);
|
|
506
|
-
continue;
|
|
507
|
-
}
|
|
508
|
-
rows[rows.length - 1] += word;
|
|
509
|
-
}
|
|
510
|
-
if (options.trim !== false) {
|
|
511
|
-
rows = rows.map((row) => stringVisibleTrimSpacesRight(row));
|
|
512
|
-
}
|
|
513
|
-
const preString = rows.join("\n");
|
|
514
|
-
const pre = [...preString];
|
|
515
|
-
let preStringIndex = 0;
|
|
516
|
-
for (const [index, character] of pre.entries()) {
|
|
517
|
-
returnValue += character;
|
|
518
|
-
if (ESCAPES.has(character)) {
|
|
519
|
-
const { groups } = new RegExp(`(?:\\${ANSI_CSI}(?<code>\\d+)m|\\${ANSI_ESCAPE_LINK}(?<uri>.*)${ANSI_ESCAPE_BELL})`).exec(preString.slice(preStringIndex)) || { groups: {} };
|
|
520
|
-
if (groups.code !== void 0) {
|
|
521
|
-
const code2 = Number.parseFloat(groups.code);
|
|
522
|
-
escapeCode = code2 === END_CODE ? void 0 : code2;
|
|
523
|
-
} else if (groups.uri !== void 0) {
|
|
524
|
-
escapeUrl = groups.uri.length === 0 ? void 0 : groups.uri;
|
|
525
|
-
}
|
|
526
|
-
}
|
|
527
|
-
const code = ansi_styles_default.codes.get(Number(escapeCode));
|
|
528
|
-
if (pre[index + 1] === "\n") {
|
|
529
|
-
if (escapeUrl) {
|
|
530
|
-
returnValue += wrapAnsiHyperlink("");
|
|
531
|
-
}
|
|
532
|
-
if (escapeCode && code) {
|
|
533
|
-
returnValue += wrapAnsiCode(code);
|
|
534
|
-
}
|
|
535
|
-
} else if (character === "\n") {
|
|
536
|
-
if (escapeCode && code) {
|
|
537
|
-
returnValue += wrapAnsiCode(escapeCode);
|
|
538
|
-
}
|
|
539
|
-
if (escapeUrl) {
|
|
540
|
-
returnValue += wrapAnsiHyperlink(escapeUrl);
|
|
541
|
-
}
|
|
542
|
-
}
|
|
543
|
-
preStringIndex += character.length;
|
|
544
|
-
}
|
|
545
|
-
return returnValue;
|
|
546
|
-
};
|
|
547
|
-
function wrapAnsi(string, columns, options) {
|
|
548
|
-
return String(string).normalize().replaceAll("\r\n", "\n").split("\n").map((line) => exec(line, columns, options)).join("\n");
|
|
549
|
-
}
|
|
550
|
-
function isFullwidthCodePoint(codePoint) {
|
|
551
|
-
if (!Number.isInteger(codePoint)) {
|
|
552
|
-
return false;
|
|
553
|
-
}
|
|
554
|
-
return (0, import_chunk_VV4M6AN7.eastAsianWidth)(codePoint) === 2;
|
|
555
|
-
}
|
|
556
|
-
var ESCAPES2 = /* @__PURE__ */ new Set([27, 155]);
|
|
557
|
-
var CODE_POINT_0 = "0".codePointAt(0);
|
|
558
|
-
var CODE_POINT_9 = "9".codePointAt(0);
|
|
559
|
-
var endCodesSet = /* @__PURE__ */ new Set();
|
|
560
|
-
var endCodesMap = /* @__PURE__ */ new Map();
|
|
561
|
-
for (const [start, end] of ansi_styles_default.codes) {
|
|
562
|
-
endCodesSet.add(ansi_styles_default.color.ansi(end));
|
|
563
|
-
endCodesMap.set(ansi_styles_default.color.ansi(start), ansi_styles_default.color.ansi(end));
|
|
564
|
-
}
|
|
565
|
-
function getEndCode(code) {
|
|
566
|
-
if (endCodesSet.has(code)) {
|
|
567
|
-
return code;
|
|
568
|
-
}
|
|
569
|
-
if (endCodesMap.has(code)) {
|
|
570
|
-
return endCodesMap.get(code);
|
|
571
|
-
}
|
|
572
|
-
code = code.slice(2);
|
|
573
|
-
if (code.includes(";")) {
|
|
574
|
-
code = code[0] + "0";
|
|
575
|
-
}
|
|
576
|
-
const returnValue = ansi_styles_default.codes.get(Number.parseInt(code, 10));
|
|
577
|
-
if (returnValue) {
|
|
578
|
-
return ansi_styles_default.color.ansi(returnValue);
|
|
579
|
-
}
|
|
580
|
-
return ansi_styles_default.reset.open;
|
|
581
|
-
}
|
|
582
|
-
function findNumberIndex(string) {
|
|
583
|
-
for (let index = 0; index < string.length; index++) {
|
|
584
|
-
const codePoint = string.codePointAt(index);
|
|
585
|
-
if (codePoint >= CODE_POINT_0 && codePoint <= CODE_POINT_9) {
|
|
586
|
-
return index;
|
|
587
|
-
}
|
|
588
|
-
}
|
|
589
|
-
return -1;
|
|
590
|
-
}
|
|
591
|
-
function parseAnsiCode(string, offset) {
|
|
592
|
-
string = string.slice(offset, offset + 19);
|
|
593
|
-
const startIndex = findNumberIndex(string);
|
|
594
|
-
if (startIndex !== -1) {
|
|
595
|
-
let endIndex = string.indexOf("m", startIndex);
|
|
596
|
-
if (endIndex === -1) {
|
|
597
|
-
endIndex = string.length;
|
|
598
|
-
}
|
|
599
|
-
return string.slice(0, endIndex + 1);
|
|
600
|
-
}
|
|
601
|
-
}
|
|
602
|
-
function tokenize(string, endCharacter = Number.POSITIVE_INFINITY) {
|
|
603
|
-
const returnValue = [];
|
|
604
|
-
let index = 0;
|
|
605
|
-
let visibleCount = 0;
|
|
606
|
-
while (index < string.length) {
|
|
607
|
-
const codePoint = string.codePointAt(index);
|
|
608
|
-
if (ESCAPES2.has(codePoint)) {
|
|
609
|
-
const code = parseAnsiCode(string, index);
|
|
610
|
-
if (code) {
|
|
611
|
-
returnValue.push({
|
|
612
|
-
type: "ansi",
|
|
613
|
-
code,
|
|
614
|
-
endCode: getEndCode(code)
|
|
615
|
-
});
|
|
616
|
-
index += code.length;
|
|
617
|
-
continue;
|
|
618
|
-
}
|
|
619
|
-
}
|
|
620
|
-
const isFullWidth = isFullwidthCodePoint(codePoint);
|
|
621
|
-
const character = String.fromCodePoint(codePoint);
|
|
622
|
-
returnValue.push({
|
|
623
|
-
type: "character",
|
|
624
|
-
value: character,
|
|
625
|
-
isFullWidth
|
|
626
|
-
});
|
|
627
|
-
index += character.length;
|
|
628
|
-
visibleCount += isFullWidth ? 2 : character.length;
|
|
629
|
-
if (visibleCount >= endCharacter) {
|
|
630
|
-
break;
|
|
631
|
-
}
|
|
632
|
-
}
|
|
633
|
-
return returnValue;
|
|
634
|
-
}
|
|
635
|
-
function reduceAnsiCodes(codes) {
|
|
636
|
-
let returnValue = [];
|
|
637
|
-
for (const code of codes) {
|
|
638
|
-
if (code.code === ansi_styles_default.reset.open) {
|
|
639
|
-
returnValue = [];
|
|
640
|
-
} else if (endCodesSet.has(code.code)) {
|
|
641
|
-
returnValue = returnValue.filter((returnValueCode) => returnValueCode.endCode !== code.code);
|
|
642
|
-
} else {
|
|
643
|
-
returnValue = returnValue.filter((returnValueCode) => returnValueCode.endCode !== code.endCode);
|
|
644
|
-
returnValue.push(code);
|
|
645
|
-
}
|
|
646
|
-
}
|
|
647
|
-
return returnValue;
|
|
648
|
-
}
|
|
649
|
-
function undoAnsiCodes(codes) {
|
|
650
|
-
const reduced = reduceAnsiCodes(codes);
|
|
651
|
-
const endCodes = reduced.map(({ endCode }) => endCode);
|
|
652
|
-
return endCodes.reverse().join("");
|
|
653
|
-
}
|
|
654
|
-
function sliceAnsi(string, start, end) {
|
|
655
|
-
const tokens = tokenize(string, end);
|
|
656
|
-
let activeCodes = [];
|
|
657
|
-
let position = 0;
|
|
658
|
-
let returnValue = "";
|
|
659
|
-
let include = false;
|
|
660
|
-
for (const token of tokens) {
|
|
661
|
-
if (end !== void 0 && position >= end) {
|
|
662
|
-
break;
|
|
663
|
-
}
|
|
664
|
-
if (token.type === "ansi") {
|
|
665
|
-
activeCodes.push(token);
|
|
666
|
-
if (include) {
|
|
667
|
-
returnValue += token.code;
|
|
668
|
-
}
|
|
669
|
-
} else {
|
|
670
|
-
if (!include && position >= start) {
|
|
671
|
-
include = true;
|
|
672
|
-
activeCodes = reduceAnsiCodes(activeCodes);
|
|
673
|
-
returnValue = activeCodes.map(({ code }) => code).join("");
|
|
674
|
-
}
|
|
675
|
-
if (include) {
|
|
676
|
-
returnValue += token.value;
|
|
677
|
-
}
|
|
678
|
-
position += token.isFullWidth ? 2 : token.value.length;
|
|
679
|
-
}
|
|
680
|
-
}
|
|
681
|
-
returnValue += undoAnsiCodes(activeCodes);
|
|
682
|
-
return returnValue;
|
|
683
|
-
}
|
|
684
|
-
var defaultTerminalHeight = 24;
|
|
685
|
-
var getWidth = ({ columns = 80 }) => columns;
|
|
686
|
-
var fitToTerminalHeight = (stream, text) => {
|
|
687
|
-
const terminalHeight = stream.rows ?? defaultTerminalHeight;
|
|
688
|
-
const lines = text.split("\n");
|
|
689
|
-
const toRemove = Math.max(0, lines.length - terminalHeight);
|
|
690
|
-
return toRemove ? sliceAnsi(text, (0, import_chunk_VV4M6AN7.stripAnsi)(lines.slice(0, toRemove).join("\n")).length + 1) : text;
|
|
691
|
-
};
|
|
692
|
-
function createLogUpdate(stream, { showCursor = false } = {}) {
|
|
693
|
-
let previousLineCount = 0;
|
|
694
|
-
let previousWidth = getWidth(stream);
|
|
695
|
-
let previousOutput = "";
|
|
696
|
-
const reset = () => {
|
|
697
|
-
previousOutput = "";
|
|
698
|
-
previousWidth = getWidth(stream);
|
|
699
|
-
previousLineCount = 0;
|
|
700
|
-
};
|
|
701
|
-
const render = (...arguments_) => {
|
|
702
|
-
if (!showCursor) {
|
|
703
|
-
import_chunk_VV4M6AN7.cli_cursor_default.hide();
|
|
704
|
-
}
|
|
705
|
-
let output = fitToTerminalHeight(stream, arguments_.join(" ") + "\n");
|
|
706
|
-
const width = getWidth(stream);
|
|
707
|
-
if (output === previousOutput && previousWidth === width) {
|
|
708
|
-
return;
|
|
709
|
-
}
|
|
710
|
-
previousOutput = output;
|
|
711
|
-
previousWidth = width;
|
|
712
|
-
output = wrapAnsi(output, width, { trim: false, hard: true, wordWrap: false });
|
|
713
|
-
stream.write(base_exports.eraseLines(previousLineCount) + output);
|
|
714
|
-
previousLineCount = output.split("\n").length;
|
|
715
|
-
};
|
|
716
|
-
render.clear = () => {
|
|
717
|
-
stream.write(base_exports.eraseLines(previousLineCount));
|
|
718
|
-
reset();
|
|
719
|
-
};
|
|
720
|
-
render.done = () => {
|
|
721
|
-
reset();
|
|
722
|
-
if (!showCursor) {
|
|
723
|
-
import_chunk_VV4M6AN7.cli_cursor_default.show();
|
|
724
|
-
}
|
|
725
|
-
};
|
|
726
|
-
return render;
|
|
727
|
-
}
|
|
728
|
-
var logUpdate = createLogUpdate(import_node_process.default.stdout);
|
|
729
|
-
var log_update_default = logUpdate;
|
|
730
|
-
var logUpdateStderr = createLogUpdate(import_node_process.default.stderr);
|
|
731
|
-
var Migrate = class _Migrate {
|
|
732
|
-
engine;
|
|
733
|
-
schemaContext;
|
|
734
|
-
schemaFilter;
|
|
735
|
-
shadowDbInitScript;
|
|
736
|
-
migrationsDirectoryPath;
|
|
737
|
-
constructor({ schemaContext, migrationsDirPath, engine, schemaFilter, shadowDbInitScript }) {
|
|
738
|
-
this.engine = engine;
|
|
739
|
-
this.schemaContext = schemaContext;
|
|
740
|
-
this.migrationsDirectoryPath = migrationsDirPath;
|
|
741
|
-
this.schemaFilter = schemaFilter ?? { externalTables: [], externalEnums: [] };
|
|
742
|
-
this.shadowDbInitScript = shadowDbInitScript ?? "";
|
|
743
|
-
}
|
|
744
|
-
static async setup({ schemaContext, schemaEngineConfig, ...rest }) {
|
|
745
|
-
const schemaEngine = await (async () => {
|
|
746
|
-
if (schemaEngineConfig?.engine === "js") {
|
|
747
|
-
const adapter = await schemaEngineConfig.adapter();
|
|
748
|
-
(0, import_chunk_T64SUJ5L.warnDatasourceDriverAdapter)(schemaContext);
|
|
749
|
-
return await import_chunk_22YP3RXZ.SchemaEngineWasm.setup({ adapter, schemaContext, ...rest });
|
|
750
|
-
}
|
|
751
|
-
const datasource = schemaEngineConfig?.engine === "classic" ? schemaEngineConfig.datasource : void 0;
|
|
752
|
-
return await import_chunk_GSX25HRL.SchemaEngineCLI.setup({ datasource, schemaContext, ...rest });
|
|
753
|
-
})();
|
|
754
|
-
return new _Migrate({ engine: schemaEngine, schemaContext, ...rest });
|
|
755
|
-
}
|
|
756
|
-
async stop() {
|
|
757
|
-
await this.engine.stop();
|
|
758
|
-
}
|
|
759
|
-
getPrismaSchema() {
|
|
760
|
-
if (!this.schemaContext) throw new Error("this.schemaContext is undefined");
|
|
761
|
-
return (0, import_internals.toSchemasContainer)(this.schemaContext.schemaFiles);
|
|
762
|
-
}
|
|
763
|
-
reset() {
|
|
764
|
-
return this.engine.reset({
|
|
765
|
-
filter: this.schemaFilter
|
|
766
|
-
});
|
|
767
|
-
}
|
|
768
|
-
async createMigration(params) {
|
|
769
|
-
if (!this.migrationsDirectoryPath) throw new Error("this.migrationsDirectoryPath is undefined");
|
|
770
|
-
const migrationsList = await (0, import_chunk_GGA2F64G.listMigrations)(this.migrationsDirectoryPath, this.shadowDbInitScript);
|
|
771
|
-
const { connectorType, generatedMigrationName, extension, migrationScript } = await this.engine.createMigration({
|
|
772
|
-
...params,
|
|
773
|
-
migrationsList,
|
|
774
|
-
filters: this.schemaFilter
|
|
775
|
-
});
|
|
776
|
-
const { baseDir, lockfile } = migrationsList;
|
|
777
|
-
if (migrationScript === null) {
|
|
778
|
-
return {
|
|
779
|
-
generatedMigrationName: void 0
|
|
780
|
-
};
|
|
781
|
-
}
|
|
782
|
-
const directoryPath = await (0, import_chunk_23DZXSTI.createMigration)({
|
|
783
|
-
baseDir,
|
|
784
|
-
generatedMigrationName
|
|
785
|
-
}).catch((e) => {
|
|
786
|
-
throw new Error(`Failed to create a new migration directory: ${e.message}`);
|
|
787
|
-
});
|
|
788
|
-
await (0, import_chunk_23DZXSTI.writeMigrationScript)({
|
|
789
|
-
baseDir,
|
|
790
|
-
extension,
|
|
791
|
-
migrationName: generatedMigrationName,
|
|
792
|
-
script: migrationScript
|
|
793
|
-
}).catch((e) => {
|
|
794
|
-
throw new Error(`Failed to write migration script to ${directoryPath}: ${e.message}`);
|
|
795
|
-
});
|
|
796
|
-
await (0, import_chunk_23DZXSTI.writeMigrationLockfile)({
|
|
797
|
-
baseDir,
|
|
798
|
-
connectorType,
|
|
799
|
-
lockfile
|
|
800
|
-
}).catch((e) => {
|
|
801
|
-
throw new Error(`Failed to write the migration lock file to ${baseDir}: ${e.message}`);
|
|
802
|
-
});
|
|
803
|
-
return {
|
|
804
|
-
generatedMigrationName
|
|
805
|
-
};
|
|
806
|
-
}
|
|
807
|
-
async diagnoseMigrationHistory({
|
|
808
|
-
optInToShadowDatabase
|
|
809
|
-
}) {
|
|
810
|
-
if (!this.migrationsDirectoryPath) throw new Error("this.migrationsDirectoryPath is undefined");
|
|
811
|
-
const migrationsList = await (0, import_chunk_GGA2F64G.listMigrations)(this.migrationsDirectoryPath, this.shadowDbInitScript);
|
|
812
|
-
return this.engine.diagnoseMigrationHistory({
|
|
813
|
-
migrationsList,
|
|
814
|
-
optInToShadowDatabase,
|
|
815
|
-
filters: this.schemaFilter
|
|
816
|
-
});
|
|
817
|
-
}
|
|
818
|
-
async listMigrationDirectories() {
|
|
819
|
-
if (!this.migrationsDirectoryPath) throw new Error("this.migrationsDirectoryPath is undefined");
|
|
820
|
-
const migrationsList = await (0, import_chunk_GGA2F64G.listMigrations)(this.migrationsDirectoryPath, this.shadowDbInitScript);
|
|
821
|
-
return {
|
|
822
|
-
migrations: migrationsList.migrationDirectories.map((dir) => dir.path)
|
|
823
|
-
};
|
|
824
|
-
}
|
|
825
|
-
async devDiagnostic() {
|
|
826
|
-
if (!this.migrationsDirectoryPath) throw new Error("this.migrationsDirectoryPath is undefined");
|
|
827
|
-
const migrationsList = await (0, import_chunk_GGA2F64G.listMigrations)(this.migrationsDirectoryPath, this.shadowDbInitScript);
|
|
828
|
-
return this.engine.devDiagnostic({
|
|
829
|
-
migrationsList,
|
|
830
|
-
filters: this.schemaFilter
|
|
831
|
-
});
|
|
832
|
-
}
|
|
833
|
-
async markMigrationApplied({ migrationId }) {
|
|
834
|
-
if (!this.migrationsDirectoryPath) throw new Error("this.migrationsDirectoryPath is undefined");
|
|
835
|
-
const migrationsList = await (0, import_chunk_GGA2F64G.listMigrations)(this.migrationsDirectoryPath, this.shadowDbInitScript);
|
|
836
|
-
return await this.engine.markMigrationApplied({
|
|
837
|
-
migrationsList,
|
|
838
|
-
migrationName: migrationId
|
|
839
|
-
});
|
|
840
|
-
}
|
|
841
|
-
markMigrationRolledBack({ migrationId }) {
|
|
842
|
-
return this.engine.markMigrationRolledBack({
|
|
843
|
-
migrationName: migrationId
|
|
844
|
-
});
|
|
845
|
-
}
|
|
846
|
-
async applyMigrations() {
|
|
847
|
-
if (!this.migrationsDirectoryPath) throw new Error("this.migrationsDirectoryPath is undefined");
|
|
848
|
-
const migrationsList = await (0, import_chunk_GGA2F64G.listMigrations)(this.migrationsDirectoryPath, this.shadowDbInitScript);
|
|
849
|
-
return this.engine.applyMigrations({
|
|
850
|
-
migrationsList,
|
|
851
|
-
filters: this.schemaFilter
|
|
852
|
-
});
|
|
853
|
-
}
|
|
854
|
-
async evaluateDataLoss() {
|
|
855
|
-
if (!this.migrationsDirectoryPath) throw new Error("this.migrationsDirectoryPath is undefined");
|
|
856
|
-
const migrationsList = await (0, import_chunk_GGA2F64G.listMigrations)(this.migrationsDirectoryPath, this.shadowDbInitScript);
|
|
857
|
-
const schema = this.getPrismaSchema();
|
|
858
|
-
return this.engine.evaluateDataLoss({
|
|
859
|
-
migrationsList,
|
|
860
|
-
schema,
|
|
861
|
-
filters: this.schemaFilter
|
|
862
|
-
});
|
|
863
|
-
}
|
|
864
|
-
async push({ force = false }) {
|
|
865
|
-
const schema = this.getPrismaSchema();
|
|
866
|
-
const { warnings, unexecutable, executedSteps } = await this.engine.schemaPush({
|
|
867
|
-
force,
|
|
868
|
-
schema,
|
|
869
|
-
filters: this.schemaFilter
|
|
870
|
-
});
|
|
871
|
-
return {
|
|
872
|
-
executedSteps,
|
|
873
|
-
warnings,
|
|
874
|
-
unexecutable
|
|
875
|
-
};
|
|
876
|
-
}
|
|
877
|
-
async tryToRunGenerate(datasourceInfo) {
|
|
878
|
-
if (!this.schemaContext) throw new Error("this.schemaContext is undefined");
|
|
879
|
-
const skipEngines = (0, import_internals.isPrismaPostgres)(datasourceInfo.url);
|
|
880
|
-
const message = [];
|
|
881
|
-
process.stdout.write("\n");
|
|
882
|
-
log_update_default(`Running generate... ${(0, import_chunk_SKRR5WT4.dim)("(Use --skip-generate to skip the generators)")}`);
|
|
883
|
-
const generators = await (0, import_internals.getGenerators)({
|
|
884
|
-
schemaContext: this.schemaContext,
|
|
885
|
-
printDownloadProgress: true,
|
|
886
|
-
version: import_engines_version.enginesVersion,
|
|
887
|
-
noEngine: skipEngines,
|
|
888
|
-
registry: import_client_generator_registry.defaultRegistry.toInternal()
|
|
889
|
-
});
|
|
890
|
-
for (const generator of generators) {
|
|
891
|
-
log_update_default(`Running generate... - ${generator.getPrettyName()}`);
|
|
892
|
-
const before = Math.round(performance.now());
|
|
893
|
-
try {
|
|
894
|
-
await generator.generate();
|
|
895
|
-
const after = Math.round(performance.now());
|
|
896
|
-
message.push((0, import_internals.getGeneratorSuccessMessage)(generator, after - before));
|
|
897
|
-
generator.stop();
|
|
898
|
-
} catch (e) {
|
|
899
|
-
message.push(`${e.message}`);
|
|
900
|
-
generator.stop();
|
|
901
|
-
}
|
|
902
|
-
}
|
|
903
|
-
log_update_default(message.join("\n"));
|
|
904
|
-
}
|
|
905
|
-
};
|