@prisma/cli-init 0.0.0-dev.202511240942 → 0.0.0-dev.202511250035
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/_-RC7NSKHC.js +36 -0
- package/dist/{accelerate-SOBMYP3B.js → accelerate-YEFEYVGD.js} +1 -1
- package/dist/chunk-6Q24WZUV.js +1486 -0
- package/dist/{chunk-NJX2BODH.js → chunk-YX4UTTNJ.js} +5 -0
- package/dist/index.js +459 -851
- package/dist/{utility-QJR3G2JJ.js → utility-W6LOZZIT.js} +1 -1
- package/package.json +2 -6
package/dist/index.js
CHANGED
|
@@ -22,11 +22,18 @@ import {
|
|
|
22
22
|
withResolvers,
|
|
23
23
|
y
|
|
24
24
|
} from "./chunk-7C5I22R2.js";
|
|
25
|
+
import {
|
|
26
|
+
credentialsFile,
|
|
27
|
+
poll,
|
|
28
|
+
printPpgInitOutput,
|
|
29
|
+
requestOrThrow,
|
|
30
|
+
successMessage
|
|
31
|
+
} from "./chunk-6Q24WZUV.js";
|
|
25
32
|
import {
|
|
26
33
|
__commonJS,
|
|
27
34
|
__require,
|
|
28
35
|
__toESM
|
|
29
|
-
} from "./chunk-
|
|
36
|
+
} from "./chunk-YX4UTTNJ.js";
|
|
30
37
|
|
|
31
38
|
// ../../node_modules/.pnpm/graceful-fs@4.2.11/node_modules/graceful-fs/polyfills.js
|
|
32
39
|
var require_polyfills = __commonJS({
|
|
@@ -56,56 +63,56 @@ var require_polyfills = __commonJS({
|
|
|
56
63
|
}
|
|
57
64
|
var chdir;
|
|
58
65
|
module.exports = patch;
|
|
59
|
-
function patch(
|
|
66
|
+
function patch(fs3) {
|
|
60
67
|
if (constants.hasOwnProperty("O_SYMLINK") && process.version.match(/^v0\.6\.[0-2]|^v0\.5\./)) {
|
|
61
|
-
patchLchmod(
|
|
62
|
-
}
|
|
63
|
-
if (!
|
|
64
|
-
patchLutimes(
|
|
65
|
-
}
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
if (
|
|
85
|
-
|
|
68
|
+
patchLchmod(fs3);
|
|
69
|
+
}
|
|
70
|
+
if (!fs3.lutimes) {
|
|
71
|
+
patchLutimes(fs3);
|
|
72
|
+
}
|
|
73
|
+
fs3.chown = chownFix(fs3.chown);
|
|
74
|
+
fs3.fchown = chownFix(fs3.fchown);
|
|
75
|
+
fs3.lchown = chownFix(fs3.lchown);
|
|
76
|
+
fs3.chmod = chmodFix(fs3.chmod);
|
|
77
|
+
fs3.fchmod = chmodFix(fs3.fchmod);
|
|
78
|
+
fs3.lchmod = chmodFix(fs3.lchmod);
|
|
79
|
+
fs3.chownSync = chownFixSync(fs3.chownSync);
|
|
80
|
+
fs3.fchownSync = chownFixSync(fs3.fchownSync);
|
|
81
|
+
fs3.lchownSync = chownFixSync(fs3.lchownSync);
|
|
82
|
+
fs3.chmodSync = chmodFixSync(fs3.chmodSync);
|
|
83
|
+
fs3.fchmodSync = chmodFixSync(fs3.fchmodSync);
|
|
84
|
+
fs3.lchmodSync = chmodFixSync(fs3.lchmodSync);
|
|
85
|
+
fs3.stat = statFix(fs3.stat);
|
|
86
|
+
fs3.fstat = statFix(fs3.fstat);
|
|
87
|
+
fs3.lstat = statFix(fs3.lstat);
|
|
88
|
+
fs3.statSync = statFixSync(fs3.statSync);
|
|
89
|
+
fs3.fstatSync = statFixSync(fs3.fstatSync);
|
|
90
|
+
fs3.lstatSync = statFixSync(fs3.lstatSync);
|
|
91
|
+
if (fs3.chmod && !fs3.lchmod) {
|
|
92
|
+
fs3.lchmod = function(path3, mode, cb) {
|
|
86
93
|
if (cb)
|
|
87
94
|
process.nextTick(cb);
|
|
88
95
|
};
|
|
89
|
-
|
|
96
|
+
fs3.lchmodSync = function() {
|
|
90
97
|
};
|
|
91
98
|
}
|
|
92
|
-
if (
|
|
93
|
-
|
|
99
|
+
if (fs3.chown && !fs3.lchown) {
|
|
100
|
+
fs3.lchown = function(path3, uid, gid, cb) {
|
|
94
101
|
if (cb)
|
|
95
102
|
process.nextTick(cb);
|
|
96
103
|
};
|
|
97
|
-
|
|
104
|
+
fs3.lchownSync = function() {
|
|
98
105
|
};
|
|
99
106
|
}
|
|
100
107
|
if (platform === "win32") {
|
|
101
|
-
|
|
108
|
+
fs3.rename = typeof fs3.rename !== "function" ? fs3.rename : function(fs$rename) {
|
|
102
109
|
function rename(from, to, cb) {
|
|
103
110
|
var start = Date.now();
|
|
104
111
|
var backoff = 0;
|
|
105
112
|
fs$rename(from, to, function CB(er) {
|
|
106
113
|
if (er && (er.code === "EACCES" || er.code === "EPERM" || er.code === "EBUSY") && Date.now() - start < 6e4) {
|
|
107
114
|
setTimeout(function() {
|
|
108
|
-
|
|
115
|
+
fs3.stat(to, function(stater, st) {
|
|
109
116
|
if (stater && stater.code === "ENOENT")
|
|
110
117
|
fs$rename(from, to, CB);
|
|
111
118
|
else
|
|
@@ -123,9 +130,9 @@ var require_polyfills = __commonJS({
|
|
|
123
130
|
if (Object.setPrototypeOf)
|
|
124
131
|
Object.setPrototypeOf(rename, fs$rename);
|
|
125
132
|
return rename;
|
|
126
|
-
}(
|
|
133
|
+
}(fs3.rename);
|
|
127
134
|
}
|
|
128
|
-
|
|
135
|
+
fs3.read = typeof fs3.read !== "function" ? fs3.read : function(fs$read) {
|
|
129
136
|
function read(fd, buffer, offset, length, position, callback_) {
|
|
130
137
|
var callback;
|
|
131
138
|
if (callback_ && typeof callback_ === "function") {
|
|
@@ -133,23 +140,23 @@ var require_polyfills = __commonJS({
|
|
|
133
140
|
callback = function(er, _, __) {
|
|
134
141
|
if (er && er.code === "EAGAIN" && eagCounter < 10) {
|
|
135
142
|
eagCounter++;
|
|
136
|
-
return fs$read.call(
|
|
143
|
+
return fs$read.call(fs3, fd, buffer, offset, length, position, callback);
|
|
137
144
|
}
|
|
138
145
|
callback_.apply(this, arguments);
|
|
139
146
|
};
|
|
140
147
|
}
|
|
141
|
-
return fs$read.call(
|
|
148
|
+
return fs$read.call(fs3, fd, buffer, offset, length, position, callback);
|
|
142
149
|
}
|
|
143
150
|
if (Object.setPrototypeOf)
|
|
144
151
|
Object.setPrototypeOf(read, fs$read);
|
|
145
152
|
return read;
|
|
146
|
-
}(
|
|
147
|
-
|
|
153
|
+
}(fs3.read);
|
|
154
|
+
fs3.readSync = typeof fs3.readSync !== "function" ? fs3.readSync : /* @__PURE__ */ function(fs$readSync) {
|
|
148
155
|
return function(fd, buffer, offset, length, position) {
|
|
149
156
|
var eagCounter = 0;
|
|
150
157
|
while (true) {
|
|
151
158
|
try {
|
|
152
|
-
return fs$readSync.call(
|
|
159
|
+
return fs$readSync.call(fs3, fd, buffer, offset, length, position);
|
|
153
160
|
} catch (er) {
|
|
154
161
|
if (er.code === "EAGAIN" && eagCounter < 10) {
|
|
155
162
|
eagCounter++;
|
|
@@ -159,11 +166,11 @@ var require_polyfills = __commonJS({
|
|
|
159
166
|
}
|
|
160
167
|
}
|
|
161
168
|
};
|
|
162
|
-
}(
|
|
163
|
-
function patchLchmod(
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
169
|
+
}(fs3.readSync);
|
|
170
|
+
function patchLchmod(fs4) {
|
|
171
|
+
fs4.lchmod = function(path3, mode, callback) {
|
|
172
|
+
fs4.open(
|
|
173
|
+
path3,
|
|
167
174
|
constants.O_WRONLY | constants.O_SYMLINK,
|
|
168
175
|
mode,
|
|
169
176
|
function(err, fd) {
|
|
@@ -172,8 +179,8 @@ var require_polyfills = __commonJS({
|
|
|
172
179
|
callback(err);
|
|
173
180
|
return;
|
|
174
181
|
}
|
|
175
|
-
|
|
176
|
-
|
|
182
|
+
fs4.fchmod(fd, mode, function(err2) {
|
|
183
|
+
fs4.close(fd, function(err22) {
|
|
177
184
|
if (callback)
|
|
178
185
|
callback(err2 || err22);
|
|
179
186
|
});
|
|
@@ -181,68 +188,68 @@ var require_polyfills = __commonJS({
|
|
|
181
188
|
}
|
|
182
189
|
);
|
|
183
190
|
};
|
|
184
|
-
|
|
185
|
-
var fd =
|
|
191
|
+
fs4.lchmodSync = function(path3, mode) {
|
|
192
|
+
var fd = fs4.openSync(path3, constants.O_WRONLY | constants.O_SYMLINK, mode);
|
|
186
193
|
var threw = true;
|
|
187
194
|
var ret;
|
|
188
195
|
try {
|
|
189
|
-
ret =
|
|
196
|
+
ret = fs4.fchmodSync(fd, mode);
|
|
190
197
|
threw = false;
|
|
191
198
|
} finally {
|
|
192
199
|
if (threw) {
|
|
193
200
|
try {
|
|
194
|
-
|
|
201
|
+
fs4.closeSync(fd);
|
|
195
202
|
} catch (er) {
|
|
196
203
|
}
|
|
197
204
|
} else {
|
|
198
|
-
|
|
205
|
+
fs4.closeSync(fd);
|
|
199
206
|
}
|
|
200
207
|
}
|
|
201
208
|
return ret;
|
|
202
209
|
};
|
|
203
210
|
}
|
|
204
|
-
function patchLutimes(
|
|
205
|
-
if (constants.hasOwnProperty("O_SYMLINK") &&
|
|
206
|
-
|
|
207
|
-
|
|
211
|
+
function patchLutimes(fs4) {
|
|
212
|
+
if (constants.hasOwnProperty("O_SYMLINK") && fs4.futimes) {
|
|
213
|
+
fs4.lutimes = function(path3, at, mt, cb) {
|
|
214
|
+
fs4.open(path3, constants.O_SYMLINK, function(er, fd) {
|
|
208
215
|
if (er) {
|
|
209
216
|
if (cb)
|
|
210
217
|
cb(er);
|
|
211
218
|
return;
|
|
212
219
|
}
|
|
213
|
-
|
|
214
|
-
|
|
220
|
+
fs4.futimes(fd, at, mt, function(er2) {
|
|
221
|
+
fs4.close(fd, function(er22) {
|
|
215
222
|
if (cb)
|
|
216
223
|
cb(er2 || er22);
|
|
217
224
|
});
|
|
218
225
|
});
|
|
219
226
|
});
|
|
220
227
|
};
|
|
221
|
-
|
|
222
|
-
var fd =
|
|
228
|
+
fs4.lutimesSync = function(path3, at, mt) {
|
|
229
|
+
var fd = fs4.openSync(path3, constants.O_SYMLINK);
|
|
223
230
|
var ret;
|
|
224
231
|
var threw = true;
|
|
225
232
|
try {
|
|
226
|
-
ret =
|
|
233
|
+
ret = fs4.futimesSync(fd, at, mt);
|
|
227
234
|
threw = false;
|
|
228
235
|
} finally {
|
|
229
236
|
if (threw) {
|
|
230
237
|
try {
|
|
231
|
-
|
|
238
|
+
fs4.closeSync(fd);
|
|
232
239
|
} catch (er) {
|
|
233
240
|
}
|
|
234
241
|
} else {
|
|
235
|
-
|
|
242
|
+
fs4.closeSync(fd);
|
|
236
243
|
}
|
|
237
244
|
}
|
|
238
245
|
return ret;
|
|
239
246
|
};
|
|
240
|
-
} else if (
|
|
241
|
-
|
|
247
|
+
} else if (fs4.futimes) {
|
|
248
|
+
fs4.lutimes = function(_a, _b, _c, cb) {
|
|
242
249
|
if (cb)
|
|
243
250
|
process.nextTick(cb);
|
|
244
251
|
};
|
|
245
|
-
|
|
252
|
+
fs4.lutimesSync = function() {
|
|
246
253
|
};
|
|
247
254
|
}
|
|
248
255
|
}
|
|
@@ -250,7 +257,7 @@ var require_polyfills = __commonJS({
|
|
|
250
257
|
if (!orig)
|
|
251
258
|
return orig;
|
|
252
259
|
return function(target, mode, cb) {
|
|
253
|
-
return orig.call(
|
|
260
|
+
return orig.call(fs3, target, mode, function(er) {
|
|
254
261
|
if (chownErOk(er))
|
|
255
262
|
er = null;
|
|
256
263
|
if (cb)
|
|
@@ -263,7 +270,7 @@ var require_polyfills = __commonJS({
|
|
|
263
270
|
return orig;
|
|
264
271
|
return function(target, mode) {
|
|
265
272
|
try {
|
|
266
|
-
return orig.call(
|
|
273
|
+
return orig.call(fs3, target, mode);
|
|
267
274
|
} catch (er) {
|
|
268
275
|
if (!chownErOk(er))
|
|
269
276
|
throw er;
|
|
@@ -274,7 +281,7 @@ var require_polyfills = __commonJS({
|
|
|
274
281
|
if (!orig)
|
|
275
282
|
return orig;
|
|
276
283
|
return function(target, uid, gid, cb) {
|
|
277
|
-
return orig.call(
|
|
284
|
+
return orig.call(fs3, target, uid, gid, function(er) {
|
|
278
285
|
if (chownErOk(er))
|
|
279
286
|
er = null;
|
|
280
287
|
if (cb)
|
|
@@ -287,7 +294,7 @@ var require_polyfills = __commonJS({
|
|
|
287
294
|
return orig;
|
|
288
295
|
return function(target, uid, gid) {
|
|
289
296
|
try {
|
|
290
|
-
return orig.call(
|
|
297
|
+
return orig.call(fs3, target, uid, gid);
|
|
291
298
|
} catch (er) {
|
|
292
299
|
if (!chownErOk(er))
|
|
293
300
|
throw er;
|
|
@@ -312,14 +319,14 @@ var require_polyfills = __commonJS({
|
|
|
312
319
|
if (cb)
|
|
313
320
|
cb.apply(this, arguments);
|
|
314
321
|
}
|
|
315
|
-
return options ? orig.call(
|
|
322
|
+
return options ? orig.call(fs3, target, options, callback) : orig.call(fs3, target, callback);
|
|
316
323
|
};
|
|
317
324
|
}
|
|
318
325
|
function statFixSync(orig) {
|
|
319
326
|
if (!orig)
|
|
320
327
|
return orig;
|
|
321
328
|
return function(target, options) {
|
|
322
|
-
var stats = options ? orig.call(
|
|
329
|
+
var stats = options ? orig.call(fs3, target, options) : orig.call(fs3, target);
|
|
323
330
|
if (stats) {
|
|
324
331
|
if (stats.uid < 0)
|
|
325
332
|
stats.uid += 4294967296;
|
|
@@ -351,17 +358,17 @@ var require_legacy_streams = __commonJS({
|
|
|
351
358
|
"use strict";
|
|
352
359
|
var Stream = __require("stream").Stream;
|
|
353
360
|
module.exports = legacy;
|
|
354
|
-
function legacy(
|
|
361
|
+
function legacy(fs3) {
|
|
355
362
|
return {
|
|
356
363
|
ReadStream,
|
|
357
364
|
WriteStream
|
|
358
365
|
};
|
|
359
|
-
function ReadStream(
|
|
366
|
+
function ReadStream(path3, options) {
|
|
360
367
|
if (!(this instanceof ReadStream))
|
|
361
|
-
return new ReadStream(
|
|
368
|
+
return new ReadStream(path3, options);
|
|
362
369
|
Stream.call(this);
|
|
363
370
|
var self = this;
|
|
364
|
-
this.path =
|
|
371
|
+
this.path = path3;
|
|
365
372
|
this.fd = null;
|
|
366
373
|
this.readable = true;
|
|
367
374
|
this.paused = false;
|
|
@@ -396,7 +403,7 @@ var require_legacy_streams = __commonJS({
|
|
|
396
403
|
});
|
|
397
404
|
return;
|
|
398
405
|
}
|
|
399
|
-
|
|
406
|
+
fs3.open(this.path, this.flags, this.mode, function(err, fd) {
|
|
400
407
|
if (err) {
|
|
401
408
|
self.emit("error", err);
|
|
402
409
|
self.readable = false;
|
|
@@ -407,11 +414,11 @@ var require_legacy_streams = __commonJS({
|
|
|
407
414
|
self._read();
|
|
408
415
|
});
|
|
409
416
|
}
|
|
410
|
-
function WriteStream(
|
|
417
|
+
function WriteStream(path3, options) {
|
|
411
418
|
if (!(this instanceof WriteStream))
|
|
412
|
-
return new WriteStream(
|
|
419
|
+
return new WriteStream(path3, options);
|
|
413
420
|
Stream.call(this);
|
|
414
|
-
this.path =
|
|
421
|
+
this.path = path3;
|
|
415
422
|
this.fd = null;
|
|
416
423
|
this.writable = true;
|
|
417
424
|
this.flags = "w";
|
|
@@ -436,7 +443,7 @@ var require_legacy_streams = __commonJS({
|
|
|
436
443
|
this.busy = false;
|
|
437
444
|
this._queue = [];
|
|
438
445
|
if (this.fd === null) {
|
|
439
|
-
this._open =
|
|
446
|
+
this._open = fs3.open;
|
|
440
447
|
this._queue.push([this._open, this.path, this.flags, this.mode, void 0]);
|
|
441
448
|
this.flush();
|
|
442
449
|
}
|
|
@@ -472,7 +479,7 @@ var require_clone = __commonJS({
|
|
|
472
479
|
var require_graceful_fs = __commonJS({
|
|
473
480
|
"../../node_modules/.pnpm/graceful-fs@4.2.11/node_modules/graceful-fs/graceful-fs.js"(exports, module) {
|
|
474
481
|
"use strict";
|
|
475
|
-
var
|
|
482
|
+
var fs3 = __require("fs");
|
|
476
483
|
var polyfills = require_polyfills();
|
|
477
484
|
var legacy = require_legacy_streams();
|
|
478
485
|
var clone = require_clone();
|
|
@@ -495,21 +502,21 @@ var require_graceful_fs = __commonJS({
|
|
|
495
502
|
}
|
|
496
503
|
});
|
|
497
504
|
}
|
|
498
|
-
var
|
|
505
|
+
var debug = noop;
|
|
499
506
|
if (util.debuglog)
|
|
500
|
-
|
|
507
|
+
debug = util.debuglog("gfs4");
|
|
501
508
|
else if (/\bgfs4\b/i.test(process.env.NODE_DEBUG || ""))
|
|
502
|
-
|
|
509
|
+
debug = function() {
|
|
503
510
|
var m = util.format.apply(util, arguments);
|
|
504
511
|
m = "GFS4: " + m.split(/\n/).join("\nGFS4: ");
|
|
505
512
|
console.error(m);
|
|
506
513
|
};
|
|
507
|
-
if (!
|
|
514
|
+
if (!fs3[gracefulQueue]) {
|
|
508
515
|
queue = global[gracefulQueue] || [];
|
|
509
|
-
publishQueue(
|
|
510
|
-
|
|
516
|
+
publishQueue(fs3, queue);
|
|
517
|
+
fs3.close = function(fs$close) {
|
|
511
518
|
function close(fd, cb) {
|
|
512
|
-
return fs$close.call(
|
|
519
|
+
return fs$close.call(fs3, fd, function(err) {
|
|
513
520
|
if (!err) {
|
|
514
521
|
resetQueue();
|
|
515
522
|
}
|
|
@@ -521,48 +528,48 @@ var require_graceful_fs = __commonJS({
|
|
|
521
528
|
value: fs$close
|
|
522
529
|
});
|
|
523
530
|
return close;
|
|
524
|
-
}(
|
|
525
|
-
|
|
531
|
+
}(fs3.close);
|
|
532
|
+
fs3.closeSync = function(fs$closeSync) {
|
|
526
533
|
function closeSync(fd) {
|
|
527
|
-
fs$closeSync.apply(
|
|
534
|
+
fs$closeSync.apply(fs3, arguments);
|
|
528
535
|
resetQueue();
|
|
529
536
|
}
|
|
530
537
|
Object.defineProperty(closeSync, previousSymbol, {
|
|
531
538
|
value: fs$closeSync
|
|
532
539
|
});
|
|
533
540
|
return closeSync;
|
|
534
|
-
}(
|
|
541
|
+
}(fs3.closeSync);
|
|
535
542
|
if (/\bgfs4\b/i.test(process.env.NODE_DEBUG || "")) {
|
|
536
543
|
process.on("exit", function() {
|
|
537
|
-
|
|
538
|
-
__require("assert").equal(
|
|
544
|
+
debug(fs3[gracefulQueue]);
|
|
545
|
+
__require("assert").equal(fs3[gracefulQueue].length, 0);
|
|
539
546
|
});
|
|
540
547
|
}
|
|
541
548
|
}
|
|
542
549
|
var queue;
|
|
543
550
|
if (!global[gracefulQueue]) {
|
|
544
|
-
publishQueue(global,
|
|
545
|
-
}
|
|
546
|
-
module.exports = patch(clone(
|
|
547
|
-
if (process.env.TEST_GRACEFUL_FS_GLOBAL_PATCH && !
|
|
548
|
-
module.exports = patch(
|
|
549
|
-
|
|
550
|
-
}
|
|
551
|
-
function patch(
|
|
552
|
-
polyfills(
|
|
553
|
-
|
|
554
|
-
|
|
555
|
-
|
|
556
|
-
var fs$readFile =
|
|
557
|
-
|
|
558
|
-
function readFile(
|
|
551
|
+
publishQueue(global, fs3[gracefulQueue]);
|
|
552
|
+
}
|
|
553
|
+
module.exports = patch(clone(fs3));
|
|
554
|
+
if (process.env.TEST_GRACEFUL_FS_GLOBAL_PATCH && !fs3.__patched) {
|
|
555
|
+
module.exports = patch(fs3);
|
|
556
|
+
fs3.__patched = true;
|
|
557
|
+
}
|
|
558
|
+
function patch(fs4) {
|
|
559
|
+
polyfills(fs4);
|
|
560
|
+
fs4.gracefulify = patch;
|
|
561
|
+
fs4.createReadStream = createReadStream;
|
|
562
|
+
fs4.createWriteStream = createWriteStream;
|
|
563
|
+
var fs$readFile = fs4.readFile;
|
|
564
|
+
fs4.readFile = readFile;
|
|
565
|
+
function readFile(path3, options, cb) {
|
|
559
566
|
if (typeof options === "function")
|
|
560
567
|
cb = options, options = null;
|
|
561
|
-
return go$readFile(
|
|
562
|
-
function go$readFile(
|
|
563
|
-
return fs$readFile(
|
|
568
|
+
return go$readFile(path3, options, cb);
|
|
569
|
+
function go$readFile(path4, options2, cb2, startTime) {
|
|
570
|
+
return fs$readFile(path4, options2, function(err) {
|
|
564
571
|
if (err && (err.code === "EMFILE" || err.code === "ENFILE"))
|
|
565
|
-
enqueue([go$readFile, [
|
|
572
|
+
enqueue([go$readFile, [path4, options2, cb2], err, startTime || Date.now(), Date.now()]);
|
|
566
573
|
else {
|
|
567
574
|
if (typeof cb2 === "function")
|
|
568
575
|
cb2.apply(this, arguments);
|
|
@@ -570,16 +577,16 @@ var require_graceful_fs = __commonJS({
|
|
|
570
577
|
});
|
|
571
578
|
}
|
|
572
579
|
}
|
|
573
|
-
var fs$writeFile =
|
|
574
|
-
|
|
575
|
-
function writeFile2(
|
|
580
|
+
var fs$writeFile = fs4.writeFile;
|
|
581
|
+
fs4.writeFile = writeFile2;
|
|
582
|
+
function writeFile2(path3, data, options, cb) {
|
|
576
583
|
if (typeof options === "function")
|
|
577
584
|
cb = options, options = null;
|
|
578
|
-
return go$writeFile(
|
|
579
|
-
function go$writeFile(
|
|
580
|
-
return fs$writeFile(
|
|
585
|
+
return go$writeFile(path3, data, options, cb);
|
|
586
|
+
function go$writeFile(path4, data2, options2, cb2, startTime) {
|
|
587
|
+
return fs$writeFile(path4, data2, options2, function(err) {
|
|
581
588
|
if (err && (err.code === "EMFILE" || err.code === "ENFILE"))
|
|
582
|
-
enqueue([go$writeFile, [
|
|
589
|
+
enqueue([go$writeFile, [path4, data2, options2, cb2], err, startTime || Date.now(), Date.now()]);
|
|
583
590
|
else {
|
|
584
591
|
if (typeof cb2 === "function")
|
|
585
592
|
cb2.apply(this, arguments);
|
|
@@ -587,17 +594,17 @@ var require_graceful_fs = __commonJS({
|
|
|
587
594
|
});
|
|
588
595
|
}
|
|
589
596
|
}
|
|
590
|
-
var fs$appendFile =
|
|
597
|
+
var fs$appendFile = fs4.appendFile;
|
|
591
598
|
if (fs$appendFile)
|
|
592
|
-
|
|
593
|
-
function appendFile(
|
|
599
|
+
fs4.appendFile = appendFile;
|
|
600
|
+
function appendFile(path3, data, options, cb) {
|
|
594
601
|
if (typeof options === "function")
|
|
595
602
|
cb = options, options = null;
|
|
596
|
-
return go$appendFile(
|
|
597
|
-
function go$appendFile(
|
|
598
|
-
return fs$appendFile(
|
|
603
|
+
return go$appendFile(path3, data, options, cb);
|
|
604
|
+
function go$appendFile(path4, data2, options2, cb2, startTime) {
|
|
605
|
+
return fs$appendFile(path4, data2, options2, function(err) {
|
|
599
606
|
if (err && (err.code === "EMFILE" || err.code === "ENFILE"))
|
|
600
|
-
enqueue([go$appendFile, [
|
|
607
|
+
enqueue([go$appendFile, [path4, data2, options2, cb2], err, startTime || Date.now(), Date.now()]);
|
|
601
608
|
else {
|
|
602
609
|
if (typeof cb2 === "function")
|
|
603
610
|
cb2.apply(this, arguments);
|
|
@@ -605,9 +612,9 @@ var require_graceful_fs = __commonJS({
|
|
|
605
612
|
});
|
|
606
613
|
}
|
|
607
614
|
}
|
|
608
|
-
var fs$copyFile =
|
|
615
|
+
var fs$copyFile = fs4.copyFile;
|
|
609
616
|
if (fs$copyFile)
|
|
610
|
-
|
|
617
|
+
fs4.copyFile = copyFile;
|
|
611
618
|
function copyFile(src, dest, flags, cb) {
|
|
612
619
|
if (typeof flags === "function") {
|
|
613
620
|
cb = flags;
|
|
@@ -625,34 +632,34 @@ var require_graceful_fs = __commonJS({
|
|
|
625
632
|
});
|
|
626
633
|
}
|
|
627
634
|
}
|
|
628
|
-
var fs$readdir =
|
|
629
|
-
|
|
635
|
+
var fs$readdir = fs4.readdir;
|
|
636
|
+
fs4.readdir = readdir;
|
|
630
637
|
var noReaddirOptionVersions = /^v[0-5]\./;
|
|
631
|
-
function readdir(
|
|
638
|
+
function readdir(path3, options, cb) {
|
|
632
639
|
if (typeof options === "function")
|
|
633
640
|
cb = options, options = null;
|
|
634
|
-
var go$readdir = noReaddirOptionVersions.test(process.version) ? function go$readdir2(
|
|
635
|
-
return fs$readdir(
|
|
636
|
-
|
|
641
|
+
var go$readdir = noReaddirOptionVersions.test(process.version) ? function go$readdir2(path4, options2, cb2, startTime) {
|
|
642
|
+
return fs$readdir(path4, fs$readdirCallback(
|
|
643
|
+
path4,
|
|
637
644
|
options2,
|
|
638
645
|
cb2,
|
|
639
646
|
startTime
|
|
640
647
|
));
|
|
641
|
-
} : function go$readdir2(
|
|
642
|
-
return fs$readdir(
|
|
643
|
-
|
|
648
|
+
} : function go$readdir2(path4, options2, cb2, startTime) {
|
|
649
|
+
return fs$readdir(path4, options2, fs$readdirCallback(
|
|
650
|
+
path4,
|
|
644
651
|
options2,
|
|
645
652
|
cb2,
|
|
646
653
|
startTime
|
|
647
654
|
));
|
|
648
655
|
};
|
|
649
|
-
return go$readdir(
|
|
650
|
-
function fs$readdirCallback(
|
|
656
|
+
return go$readdir(path3, options, cb);
|
|
657
|
+
function fs$readdirCallback(path4, options2, cb2, startTime) {
|
|
651
658
|
return function(err, files) {
|
|
652
659
|
if (err && (err.code === "EMFILE" || err.code === "ENFILE"))
|
|
653
660
|
enqueue([
|
|
654
661
|
go$readdir,
|
|
655
|
-
[
|
|
662
|
+
[path4, options2, cb2],
|
|
656
663
|
err,
|
|
657
664
|
startTime || Date.now(),
|
|
658
665
|
Date.now()
|
|
@@ -667,21 +674,21 @@ var require_graceful_fs = __commonJS({
|
|
|
667
674
|
}
|
|
668
675
|
}
|
|
669
676
|
if (process.version.substr(0, 4) === "v0.8") {
|
|
670
|
-
var legStreams = legacy(
|
|
677
|
+
var legStreams = legacy(fs4);
|
|
671
678
|
ReadStream = legStreams.ReadStream;
|
|
672
679
|
WriteStream = legStreams.WriteStream;
|
|
673
680
|
}
|
|
674
|
-
var fs$ReadStream =
|
|
681
|
+
var fs$ReadStream = fs4.ReadStream;
|
|
675
682
|
if (fs$ReadStream) {
|
|
676
683
|
ReadStream.prototype = Object.create(fs$ReadStream.prototype);
|
|
677
684
|
ReadStream.prototype.open = ReadStream$open;
|
|
678
685
|
}
|
|
679
|
-
var fs$WriteStream =
|
|
686
|
+
var fs$WriteStream = fs4.WriteStream;
|
|
680
687
|
if (fs$WriteStream) {
|
|
681
688
|
WriteStream.prototype = Object.create(fs$WriteStream.prototype);
|
|
682
689
|
WriteStream.prototype.open = WriteStream$open;
|
|
683
690
|
}
|
|
684
|
-
Object.defineProperty(
|
|
691
|
+
Object.defineProperty(fs4, "ReadStream", {
|
|
685
692
|
get: function() {
|
|
686
693
|
return ReadStream;
|
|
687
694
|
},
|
|
@@ -691,7 +698,7 @@ var require_graceful_fs = __commonJS({
|
|
|
691
698
|
enumerable: true,
|
|
692
699
|
configurable: true
|
|
693
700
|
});
|
|
694
|
-
Object.defineProperty(
|
|
701
|
+
Object.defineProperty(fs4, "WriteStream", {
|
|
695
702
|
get: function() {
|
|
696
703
|
return WriteStream;
|
|
697
704
|
},
|
|
@@ -702,7 +709,7 @@ var require_graceful_fs = __commonJS({
|
|
|
702
709
|
configurable: true
|
|
703
710
|
});
|
|
704
711
|
var FileReadStream = ReadStream;
|
|
705
|
-
Object.defineProperty(
|
|
712
|
+
Object.defineProperty(fs4, "FileReadStream", {
|
|
706
713
|
get: function() {
|
|
707
714
|
return FileReadStream;
|
|
708
715
|
},
|
|
@@ -713,7 +720,7 @@ var require_graceful_fs = __commonJS({
|
|
|
713
720
|
configurable: true
|
|
714
721
|
});
|
|
715
722
|
var FileWriteStream = WriteStream;
|
|
716
|
-
Object.defineProperty(
|
|
723
|
+
Object.defineProperty(fs4, "FileWriteStream", {
|
|
717
724
|
get: function() {
|
|
718
725
|
return FileWriteStream;
|
|
719
726
|
},
|
|
@@ -723,7 +730,7 @@ var require_graceful_fs = __commonJS({
|
|
|
723
730
|
enumerable: true,
|
|
724
731
|
configurable: true
|
|
725
732
|
});
|
|
726
|
-
function ReadStream(
|
|
733
|
+
function ReadStream(path3, options) {
|
|
727
734
|
if (this instanceof ReadStream)
|
|
728
735
|
return fs$ReadStream.apply(this, arguments), this;
|
|
729
736
|
else
|
|
@@ -731,7 +738,7 @@ var require_graceful_fs = __commonJS({
|
|
|
731
738
|
}
|
|
732
739
|
function ReadStream$open() {
|
|
733
740
|
var that = this;
|
|
734
|
-
|
|
741
|
+
open(that.path, that.flags, that.mode, function(err, fd) {
|
|
735
742
|
if (err) {
|
|
736
743
|
if (that.autoClose)
|
|
737
744
|
that.destroy();
|
|
@@ -743,7 +750,7 @@ var require_graceful_fs = __commonJS({
|
|
|
743
750
|
}
|
|
744
751
|
});
|
|
745
752
|
}
|
|
746
|
-
function WriteStream(
|
|
753
|
+
function WriteStream(path3, options) {
|
|
747
754
|
if (this instanceof WriteStream)
|
|
748
755
|
return fs$WriteStream.apply(this, arguments), this;
|
|
749
756
|
else
|
|
@@ -751,7 +758,7 @@ var require_graceful_fs = __commonJS({
|
|
|
751
758
|
}
|
|
752
759
|
function WriteStream$open() {
|
|
753
760
|
var that = this;
|
|
754
|
-
|
|
761
|
+
open(that.path, that.flags, that.mode, function(err, fd) {
|
|
755
762
|
if (err) {
|
|
756
763
|
that.destroy();
|
|
757
764
|
that.emit("error", err);
|
|
@@ -761,22 +768,22 @@ var require_graceful_fs = __commonJS({
|
|
|
761
768
|
}
|
|
762
769
|
});
|
|
763
770
|
}
|
|
764
|
-
function createReadStream(
|
|
765
|
-
return new
|
|
771
|
+
function createReadStream(path3, options) {
|
|
772
|
+
return new fs4.ReadStream(path3, options);
|
|
766
773
|
}
|
|
767
|
-
function createWriteStream(
|
|
768
|
-
return new
|
|
774
|
+
function createWriteStream(path3, options) {
|
|
775
|
+
return new fs4.WriteStream(path3, options);
|
|
769
776
|
}
|
|
770
|
-
var fs$open =
|
|
771
|
-
|
|
772
|
-
function
|
|
777
|
+
var fs$open = fs4.open;
|
|
778
|
+
fs4.open = open;
|
|
779
|
+
function open(path3, flags, mode, cb) {
|
|
773
780
|
if (typeof mode === "function")
|
|
774
781
|
cb = mode, mode = null;
|
|
775
|
-
return go$open(
|
|
776
|
-
function go$open(
|
|
777
|
-
return fs$open(
|
|
782
|
+
return go$open(path3, flags, mode, cb);
|
|
783
|
+
function go$open(path4, flags2, mode2, cb2, startTime) {
|
|
784
|
+
return fs$open(path4, flags2, mode2, function(err, fd) {
|
|
778
785
|
if (err && (err.code === "EMFILE" || err.code === "ENFILE"))
|
|
779
|
-
enqueue([go$open, [
|
|
786
|
+
enqueue([go$open, [path4, flags2, mode2, cb2], err, startTime || Date.now(), Date.now()]);
|
|
780
787
|
else {
|
|
781
788
|
if (typeof cb2 === "function")
|
|
782
789
|
cb2.apply(this, arguments);
|
|
@@ -784,20 +791,20 @@ var require_graceful_fs = __commonJS({
|
|
|
784
791
|
});
|
|
785
792
|
}
|
|
786
793
|
}
|
|
787
|
-
return
|
|
794
|
+
return fs4;
|
|
788
795
|
}
|
|
789
796
|
function enqueue(elem) {
|
|
790
|
-
|
|
791
|
-
|
|
797
|
+
debug("ENQUEUE", elem[0].name, elem[1]);
|
|
798
|
+
fs3[gracefulQueue].push(elem);
|
|
792
799
|
retry();
|
|
793
800
|
}
|
|
794
801
|
var retryTimer;
|
|
795
802
|
function resetQueue() {
|
|
796
803
|
var now = Date.now();
|
|
797
|
-
for (var i = 0; i <
|
|
798
|
-
if (
|
|
799
|
-
|
|
800
|
-
|
|
804
|
+
for (var i = 0; i < fs3[gracefulQueue].length; ++i) {
|
|
805
|
+
if (fs3[gracefulQueue][i].length > 2) {
|
|
806
|
+
fs3[gracefulQueue][i][3] = now;
|
|
807
|
+
fs3[gracefulQueue][i][4] = now;
|
|
801
808
|
}
|
|
802
809
|
}
|
|
803
810
|
retry();
|
|
@@ -805,19 +812,19 @@ var require_graceful_fs = __commonJS({
|
|
|
805
812
|
function retry() {
|
|
806
813
|
clearTimeout(retryTimer);
|
|
807
814
|
retryTimer = void 0;
|
|
808
|
-
if (
|
|
815
|
+
if (fs3[gracefulQueue].length === 0)
|
|
809
816
|
return;
|
|
810
|
-
var elem =
|
|
817
|
+
var elem = fs3[gracefulQueue].shift();
|
|
811
818
|
var fn = elem[0];
|
|
812
819
|
var args = elem[1];
|
|
813
820
|
var err = elem[2];
|
|
814
821
|
var startTime = elem[3];
|
|
815
822
|
var lastTime = elem[4];
|
|
816
823
|
if (startTime === void 0) {
|
|
817
|
-
|
|
824
|
+
debug("RETRY", fn.name, args);
|
|
818
825
|
fn.apply(null, args);
|
|
819
826
|
} else if (Date.now() - startTime >= 6e4) {
|
|
820
|
-
|
|
827
|
+
debug("TIMEOUT", fn.name, args);
|
|
821
828
|
var cb = args.pop();
|
|
822
829
|
if (typeof cb === "function")
|
|
823
830
|
cb.call(null, err);
|
|
@@ -826,10 +833,10 @@ var require_graceful_fs = __commonJS({
|
|
|
826
833
|
var sinceStart = Math.max(lastTime - startTime, 1);
|
|
827
834
|
var desiredDelay = Math.min(sinceStart * 1.2, 100);
|
|
828
835
|
if (sinceAttempt >= desiredDelay) {
|
|
829
|
-
|
|
836
|
+
debug("RETRY", fn.name, args);
|
|
830
837
|
fn.apply(null, args.concat([startTime]));
|
|
831
838
|
} else {
|
|
832
|
-
|
|
839
|
+
fs3[gracefulQueue].push(elem);
|
|
833
840
|
}
|
|
834
841
|
}
|
|
835
842
|
if (retryTimer === void 0) {
|
|
@@ -1269,10 +1276,10 @@ var require_mtime_precision = __commonJS({
|
|
|
1269
1276
|
"../../node_modules/.pnpm/proper-lockfile@4.1.2/node_modules/proper-lockfile/lib/mtime-precision.js"(exports, module) {
|
|
1270
1277
|
"use strict";
|
|
1271
1278
|
var cacheSymbol = Symbol();
|
|
1272
|
-
function probe(file,
|
|
1273
|
-
const cachedPrecision =
|
|
1279
|
+
function probe(file, fs3, callback) {
|
|
1280
|
+
const cachedPrecision = fs3[cacheSymbol];
|
|
1274
1281
|
if (cachedPrecision) {
|
|
1275
|
-
return
|
|
1282
|
+
return fs3.stat(file, (err, stat) => {
|
|
1276
1283
|
if (err) {
|
|
1277
1284
|
return callback(err);
|
|
1278
1285
|
}
|
|
@@ -1280,16 +1287,16 @@ var require_mtime_precision = __commonJS({
|
|
|
1280
1287
|
});
|
|
1281
1288
|
}
|
|
1282
1289
|
const mtime = new Date(Math.ceil(Date.now() / 1e3) * 1e3 + 5);
|
|
1283
|
-
|
|
1290
|
+
fs3.utimes(file, mtime, mtime, (err) => {
|
|
1284
1291
|
if (err) {
|
|
1285
1292
|
return callback(err);
|
|
1286
1293
|
}
|
|
1287
|
-
|
|
1294
|
+
fs3.stat(file, (err2, stat) => {
|
|
1288
1295
|
if (err2) {
|
|
1289
1296
|
return callback(err2);
|
|
1290
1297
|
}
|
|
1291
1298
|
const precision = stat.mtime.getTime() % 1e3 === 0 ? "s" : "ms";
|
|
1292
|
-
Object.defineProperty(
|
|
1299
|
+
Object.defineProperty(fs3, cacheSymbol, { value: precision });
|
|
1293
1300
|
callback(null, stat.mtime, precision);
|
|
1294
1301
|
});
|
|
1295
1302
|
});
|
|
@@ -1310,8 +1317,8 @@ var require_mtime_precision = __commonJS({
|
|
|
1310
1317
|
var require_lockfile = __commonJS({
|
|
1311
1318
|
"../../node_modules/.pnpm/proper-lockfile@4.1.2/node_modules/proper-lockfile/lib/lockfile.js"(exports, module) {
|
|
1312
1319
|
"use strict";
|
|
1313
|
-
var
|
|
1314
|
-
var
|
|
1320
|
+
var path3 = __require("path");
|
|
1321
|
+
var fs3 = require_graceful_fs();
|
|
1315
1322
|
var retry = require_retry2();
|
|
1316
1323
|
var onExit = require_signal_exit();
|
|
1317
1324
|
var mtimePrecision = require_mtime_precision();
|
|
@@ -1321,7 +1328,7 @@ var require_lockfile = __commonJS({
|
|
|
1321
1328
|
}
|
|
1322
1329
|
function resolveCanonicalPath(file, options, callback) {
|
|
1323
1330
|
if (!options.realpath) {
|
|
1324
|
-
return callback(null,
|
|
1331
|
+
return callback(null, path3.resolve(file));
|
|
1325
1332
|
}
|
|
1326
1333
|
options.fs.realpath(file, callback);
|
|
1327
1334
|
}
|
|
@@ -1442,7 +1449,7 @@ var require_lockfile = __commonJS({
|
|
|
1442
1449
|
update: null,
|
|
1443
1450
|
realpath: true,
|
|
1444
1451
|
retries: 0,
|
|
1445
|
-
fs:
|
|
1452
|
+
fs: fs3,
|
|
1446
1453
|
onCompromised: (err) => {
|
|
1447
1454
|
throw err;
|
|
1448
1455
|
},
|
|
@@ -1486,7 +1493,7 @@ var require_lockfile = __commonJS({
|
|
|
1486
1493
|
}
|
|
1487
1494
|
function unlock2(file, options, callback) {
|
|
1488
1495
|
options = {
|
|
1489
|
-
fs:
|
|
1496
|
+
fs: fs3,
|
|
1490
1497
|
realpath: true,
|
|
1491
1498
|
...options
|
|
1492
1499
|
};
|
|
@@ -1508,7 +1515,7 @@ var require_lockfile = __commonJS({
|
|
|
1508
1515
|
options = {
|
|
1509
1516
|
stale: 1e4,
|
|
1510
1517
|
realpath: true,
|
|
1511
|
-
fs:
|
|
1518
|
+
fs: fs3,
|
|
1512
1519
|
...options
|
|
1513
1520
|
};
|
|
1514
1521
|
options.stale = Math.max(options.stale || 0, 2e3);
|
|
@@ -1547,16 +1554,16 @@ var require_lockfile = __commonJS({
|
|
|
1547
1554
|
var require_adapter = __commonJS({
|
|
1548
1555
|
"../../node_modules/.pnpm/proper-lockfile@4.1.2/node_modules/proper-lockfile/lib/adapter.js"(exports, module) {
|
|
1549
1556
|
"use strict";
|
|
1550
|
-
var
|
|
1551
|
-
function createSyncFs(
|
|
1557
|
+
var fs3 = require_graceful_fs();
|
|
1558
|
+
function createSyncFs(fs4) {
|
|
1552
1559
|
const methods = ["mkdir", "realpath", "stat", "rmdir", "utimes"];
|
|
1553
|
-
const newFs = { ...
|
|
1560
|
+
const newFs = { ...fs4 };
|
|
1554
1561
|
methods.forEach((method) => {
|
|
1555
1562
|
newFs[method] = (...args) => {
|
|
1556
1563
|
const callback = args.pop();
|
|
1557
1564
|
let ret;
|
|
1558
1565
|
try {
|
|
1559
|
-
ret =
|
|
1566
|
+
ret = fs4[`${method}Sync`](...args);
|
|
1560
1567
|
} catch (err) {
|
|
1561
1568
|
return callback(err);
|
|
1562
1569
|
}
|
|
@@ -1594,7 +1601,7 @@ var require_adapter = __commonJS({
|
|
|
1594
1601
|
}
|
|
1595
1602
|
function toSyncOptions(options) {
|
|
1596
1603
|
options = { ...options };
|
|
1597
|
-
options.fs = createSyncFs(options.fs ||
|
|
1604
|
+
options.fs = createSyncFs(options.fs || fs3);
|
|
1598
1605
|
if (typeof options.retries === "number" && options.retries > 0 || options.retries && typeof options.retries.retries === "number" && options.retries.retries > 0) {
|
|
1599
1606
|
throw Object.assign(new Error("Cannot use retries with the sync api"), { code: "ESYNC" });
|
|
1600
1607
|
}
|
|
@@ -1658,65 +1665,65 @@ function normalizeWindowsPath(input2 = "") {
|
|
|
1658
1665
|
var _UNC_REGEX = /^[/\\]{2}/;
|
|
1659
1666
|
var _IS_ABSOLUTE_RE = /^[/\\](?![/\\])|^[/\\]{2}(?!\.)|^[A-Za-z]:[/\\]/;
|
|
1660
1667
|
var _DRIVE_LETTER_RE = /^[A-Za-z]:$/;
|
|
1661
|
-
var normalize = function(
|
|
1662
|
-
if (
|
|
1668
|
+
var normalize = function(path3) {
|
|
1669
|
+
if (path3.length === 0) {
|
|
1663
1670
|
return ".";
|
|
1664
1671
|
}
|
|
1665
|
-
|
|
1666
|
-
const isUNCPath =
|
|
1667
|
-
const isPathAbsolute = isAbsolute(
|
|
1668
|
-
const trailingSeparator =
|
|
1669
|
-
|
|
1670
|
-
if (
|
|
1672
|
+
path3 = normalizeWindowsPath(path3);
|
|
1673
|
+
const isUNCPath = path3.match(_UNC_REGEX);
|
|
1674
|
+
const isPathAbsolute = isAbsolute(path3);
|
|
1675
|
+
const trailingSeparator = path3[path3.length - 1] === "/";
|
|
1676
|
+
path3 = normalizeString(path3, !isPathAbsolute);
|
|
1677
|
+
if (path3.length === 0) {
|
|
1671
1678
|
if (isPathAbsolute) {
|
|
1672
1679
|
return "/";
|
|
1673
1680
|
}
|
|
1674
1681
|
return trailingSeparator ? "./" : ".";
|
|
1675
1682
|
}
|
|
1676
1683
|
if (trailingSeparator) {
|
|
1677
|
-
|
|
1684
|
+
path3 += "/";
|
|
1678
1685
|
}
|
|
1679
|
-
if (_DRIVE_LETTER_RE.test(
|
|
1680
|
-
|
|
1686
|
+
if (_DRIVE_LETTER_RE.test(path3)) {
|
|
1687
|
+
path3 += "/";
|
|
1681
1688
|
}
|
|
1682
1689
|
if (isUNCPath) {
|
|
1683
1690
|
if (!isPathAbsolute) {
|
|
1684
|
-
return `//./${
|
|
1691
|
+
return `//./${path3}`;
|
|
1685
1692
|
}
|
|
1686
|
-
return `//${
|
|
1693
|
+
return `//${path3}`;
|
|
1687
1694
|
}
|
|
1688
|
-
return isPathAbsolute && !isAbsolute(
|
|
1695
|
+
return isPathAbsolute && !isAbsolute(path3) ? `/${path3}` : path3;
|
|
1689
1696
|
};
|
|
1690
1697
|
var join = function(...segments) {
|
|
1691
|
-
let
|
|
1698
|
+
let path3 = "";
|
|
1692
1699
|
for (const seg of segments) {
|
|
1693
1700
|
if (!seg) {
|
|
1694
1701
|
continue;
|
|
1695
1702
|
}
|
|
1696
|
-
if (
|
|
1697
|
-
const pathTrailing =
|
|
1703
|
+
if (path3.length > 0) {
|
|
1704
|
+
const pathTrailing = path3[path3.length - 1] === "/";
|
|
1698
1705
|
const segLeading = seg[0] === "/";
|
|
1699
1706
|
const both = pathTrailing && segLeading;
|
|
1700
1707
|
if (both) {
|
|
1701
|
-
|
|
1708
|
+
path3 += seg.slice(1);
|
|
1702
1709
|
} else {
|
|
1703
|
-
|
|
1710
|
+
path3 += pathTrailing || segLeading ? seg : `/${seg}`;
|
|
1704
1711
|
}
|
|
1705
1712
|
} else {
|
|
1706
|
-
|
|
1713
|
+
path3 += seg;
|
|
1707
1714
|
}
|
|
1708
1715
|
}
|
|
1709
|
-
return normalize(
|
|
1716
|
+
return normalize(path3);
|
|
1710
1717
|
};
|
|
1711
|
-
function normalizeString(
|
|
1718
|
+
function normalizeString(path3, allowAboveRoot) {
|
|
1712
1719
|
let res = "";
|
|
1713
1720
|
let lastSegmentLength = 0;
|
|
1714
1721
|
let lastSlash = -1;
|
|
1715
1722
|
let dots = 0;
|
|
1716
1723
|
let char = null;
|
|
1717
|
-
for (let index = 0; index <=
|
|
1718
|
-
if (index <
|
|
1719
|
-
char =
|
|
1724
|
+
for (let index = 0; index <= path3.length; ++index) {
|
|
1725
|
+
if (index < path3.length) {
|
|
1726
|
+
char = path3[index];
|
|
1720
1727
|
} else if (char === "/") {
|
|
1721
1728
|
break;
|
|
1722
1729
|
} else {
|
|
@@ -1753,9 +1760,9 @@ function normalizeString(path6, allowAboveRoot) {
|
|
|
1753
1760
|
}
|
|
1754
1761
|
} else {
|
|
1755
1762
|
if (res.length > 0) {
|
|
1756
|
-
res += `/${
|
|
1763
|
+
res += `/${path3.slice(lastSlash + 1, index)}`;
|
|
1757
1764
|
} else {
|
|
1758
|
-
res =
|
|
1765
|
+
res = path3.slice(lastSlash + 1, index);
|
|
1759
1766
|
}
|
|
1760
1767
|
lastSegmentLength = index - lastSlash - 1;
|
|
1761
1768
|
}
|
|
@@ -1776,8 +1783,8 @@ var isAbsolute = function(p) {
|
|
|
1776
1783
|
// ../../node_modules/.pnpm/pathe@2.0.3/node_modules/pathe/dist/utils.mjs
|
|
1777
1784
|
var normalizedAliasSymbol = Symbol.for("pathe:normalizedAlias");
|
|
1778
1785
|
var SLASH_RE = /[/\\]/;
|
|
1779
|
-
function filename(
|
|
1780
|
-
const base =
|
|
1786
|
+
function filename(path3) {
|
|
1787
|
+
const base = path3.split(SLASH_RE).pop();
|
|
1781
1788
|
if (!base) {
|
|
1782
1789
|
return void 0;
|
|
1783
1790
|
}
|
|
@@ -2272,9 +2279,9 @@ var DEFAULT_SHADOW_DATABASE_PORT = 51215;
|
|
|
2272
2279
|
var MAX_PORT = 65535;
|
|
2273
2280
|
var NO_PORT = -Infinity;
|
|
2274
2281
|
async function pickPorts(options) {
|
|
2275
|
-
const { debug
|
|
2282
|
+
const { debug, name, requestedPorts, servers } = options;
|
|
2276
2283
|
const { portsUsedByOtherServers, portsUsedByThisServerLastTime } = extractUsedPorts(name, servers);
|
|
2277
|
-
if (
|
|
2284
|
+
if (debug) {
|
|
2278
2285
|
console.debug(`ports used by other servers: ${Object.keys(portsUsedByOtherServers).join(", ")}`);
|
|
2279
2286
|
console.debug(`ports used by "${name}" server last time: ${JSON.stringify(portsUsedByThisServerLastTime)}`);
|
|
2280
2287
|
}
|
|
@@ -2282,39 +2289,39 @@ async function pickPorts(options) {
|
|
|
2282
2289
|
const portKeys = ["port", "databasePort", "shadowDatabasePort"];
|
|
2283
2290
|
for (const portKey of portKeys) {
|
|
2284
2291
|
const port = await trySpecificPorts({
|
|
2285
|
-
debug
|
|
2292
|
+
debug,
|
|
2286
2293
|
portKey,
|
|
2287
2294
|
portsUsedByOtherServers,
|
|
2288
2295
|
portsUsedByThisServerLastTime,
|
|
2289
2296
|
requestedPorts
|
|
2290
|
-
}) ?? await tryAnyPort({ debug
|
|
2291
|
-
if (
|
|
2297
|
+
}) ?? await tryAnyPort({ debug, pickedPorts, portKey, portsUsedByOtherServers, portsUsedByThisServerLastTime });
|
|
2298
|
+
if (debug) {
|
|
2292
2299
|
console.debug(`Got port for "${portKey}": ${port}`);
|
|
2293
2300
|
}
|
|
2294
2301
|
pickedPorts[portKey] = port;
|
|
2295
2302
|
}
|
|
2296
|
-
if (
|
|
2303
|
+
if (debug) {
|
|
2297
2304
|
console.debug(`Picked ports: ${JSON.stringify(pickedPorts)}`);
|
|
2298
2305
|
}
|
|
2299
2306
|
return pickedPorts;
|
|
2300
2307
|
}
|
|
2301
2308
|
async function trySpecificPorts(options) {
|
|
2302
|
-
const { debug
|
|
2309
|
+
const { debug, portKey, portsUsedByOtherServers, portsUsedByThisServerLastTime, requestedPorts } = options;
|
|
2303
2310
|
const { [portKey]: requestedPort, ...otherRequestedPorts } = requestedPorts;
|
|
2304
2311
|
if (isPortSpecified(requestedPort)) {
|
|
2305
|
-
await assertPickablePort({ debug
|
|
2312
|
+
await assertPickablePort({ debug, otherRequestedPorts, portKey, portsUsedByOtherServers, requestedPort });
|
|
2306
2313
|
return requestedPort;
|
|
2307
2314
|
}
|
|
2308
2315
|
const portUsedLastTime = portsUsedByThisServerLastTime?.[portKey] ?? NO_PORT;
|
|
2309
2316
|
if (!isPortSpecified(portUsedLastTime)) {
|
|
2310
|
-
if (
|
|
2317
|
+
if (debug) {
|
|
2311
2318
|
console.debug(`No port specified for "${portKey}". Trying to pick a new port.`);
|
|
2312
2319
|
}
|
|
2313
2320
|
return null;
|
|
2314
2321
|
}
|
|
2315
2322
|
const isPortUsedByOtherServers = portUsedLastTime in portsUsedByOtherServers;
|
|
2316
2323
|
if (isPortUsedByOtherServers || Object.values(otherRequestedPorts).includes(portUsedLastTime)) {
|
|
2317
|
-
if (
|
|
2324
|
+
if (debug) {
|
|
2318
2325
|
console.debug(
|
|
2319
2326
|
`Port ${portUsedLastTime} that was used last time for this server, ${isPortUsedByOtherServers ? "is also used by another server" : "has been requested for another service"}. Trying to pick a new port.`
|
|
2320
2327
|
);
|
|
@@ -2322,20 +2329,20 @@ async function trySpecificPorts(options) {
|
|
|
2322
2329
|
return null;
|
|
2323
2330
|
}
|
|
2324
2331
|
if (await checkPort(portUsedLastTime) === false) {
|
|
2325
|
-
if (
|
|
2332
|
+
if (debug) {
|
|
2326
2333
|
console.debug(
|
|
2327
2334
|
`Port ${portUsedLastTime}, that was used last time for this server, is not available. Trying to pick a new port.`
|
|
2328
2335
|
);
|
|
2329
2336
|
}
|
|
2330
2337
|
return null;
|
|
2331
2338
|
}
|
|
2332
|
-
if (
|
|
2339
|
+
if (debug) {
|
|
2333
2340
|
console.debug(`Using port ${portUsedLastTime} for "${portKey}" as it was used last time and is available.`);
|
|
2334
2341
|
}
|
|
2335
2342
|
return portUsedLastTime;
|
|
2336
2343
|
}
|
|
2337
2344
|
async function tryAnyPort(options) {
|
|
2338
|
-
const { debug
|
|
2345
|
+
const { debug, pickedPorts, portKey, portsUsedByOtherServers, portsUsedByThisServerLastTime } = options;
|
|
2339
2346
|
const minimumPort = Math.max(DEFAULT_DATABASE_PORT, DEFAULT_SERVER_PORT, DEFAULT_SHADOW_DATABASE_PORT) + 1;
|
|
2340
2347
|
const excludedPorts = [
|
|
2341
2348
|
...Object.values(pickedPorts),
|
|
@@ -2356,7 +2363,7 @@ async function tryAnyPort(options) {
|
|
|
2356
2363
|
});
|
|
2357
2364
|
} catch (error) {
|
|
2358
2365
|
if (error instanceof Error && error.name === "GetPortError" && maximumSpecificPort + 1 <= MAX_PORT) {
|
|
2359
|
-
if (
|
|
2366
|
+
if (debug) {
|
|
2360
2367
|
console.debug(`Expanding port lookup to range [${maximumSpecificPort + 1}, ${MAX_PORT}].`);
|
|
2361
2368
|
}
|
|
2362
2369
|
return await getPort({ portRange: [maximumSpecificPort + 1, MAX_PORT] });
|
|
@@ -2383,27 +2390,27 @@ function extractUsedPorts(name, servers) {
|
|
|
2383
2390
|
return { portsUsedByOtherServers, portsUsedByThisServerLastTime };
|
|
2384
2391
|
}
|
|
2385
2392
|
async function assertPickablePort(options) {
|
|
2386
|
-
const { debug
|
|
2393
|
+
const { debug, otherRequestedPorts, portKey, portsUsedByOtherServers, requestedPort } = options;
|
|
2387
2394
|
if (requestedPort in portsUsedByOtherServers) {
|
|
2388
|
-
if (
|
|
2395
|
+
if (debug) {
|
|
2389
2396
|
console.error(`Port ${requestedPort} was requested for "${portKey}", but is already used by another server.`);
|
|
2390
2397
|
}
|
|
2391
2398
|
throw new PortBelongsToAnotherServerError(requestedPort);
|
|
2392
2399
|
}
|
|
2393
2400
|
if (Object.values(otherRequestedPorts).includes(requestedPort)) {
|
|
2394
|
-
if (
|
|
2401
|
+
if (debug) {
|
|
2395
2402
|
console.error(`Port ${requestedPort} was requested for "${portKey}", but also for another key.`);
|
|
2396
2403
|
}
|
|
2397
2404
|
throw new PortRequestedTwiceError(requestedPort);
|
|
2398
2405
|
}
|
|
2399
2406
|
if (isUnsafePort(requestedPort)) {
|
|
2400
|
-
if (
|
|
2407
|
+
if (debug) {
|
|
2401
2408
|
console.error(`Port ${requestedPort} was requested for "${portKey}", but is unsafe.`);
|
|
2402
2409
|
}
|
|
2403
2410
|
throw new PortNotAvailableError(requestedPort);
|
|
2404
2411
|
}
|
|
2405
2412
|
if (await checkPort(requestedPort) === false) {
|
|
2406
|
-
if (
|
|
2413
|
+
if (debug) {
|
|
2407
2414
|
console.error(`Port ${requestedPort} was requested for "${portKey}", but is not available.`);
|
|
2408
2415
|
}
|
|
2409
2416
|
throw new PortNotAvailableError(requestedPort);
|
|
@@ -2459,17 +2466,17 @@ async function startDBServer(purpose, serverState) {
|
|
|
2459
2466
|
if (serverState.dryRun) {
|
|
2460
2467
|
return getStartDBServerResult(purpose, serverState, { db: null, port, server: null });
|
|
2461
2468
|
}
|
|
2462
|
-
const { debug
|
|
2469
|
+
const { debug } = serverState;
|
|
2463
2470
|
const getDBFn = purpose === "shadow_database" ? getShadowDB : getDB;
|
|
2464
|
-
const db = await getDBFn(serverState.pgliteDataDirPath,
|
|
2465
|
-
if (
|
|
2471
|
+
const db = await getDBFn(serverState.pgliteDataDirPath, debug);
|
|
2472
|
+
if (debug) {
|
|
2466
2473
|
db.onNotification((channel, payload) => {
|
|
2467
2474
|
console.debug(`[${purpose}][${channel}] ${payload}`);
|
|
2468
2475
|
});
|
|
2469
2476
|
}
|
|
2470
2477
|
const { PGLiteSocketServer } = await import("@electric-sql/pglite-socket");
|
|
2471
|
-
const server = new PGLiteSocketServer({ db, debug
|
|
2472
|
-
if (
|
|
2478
|
+
const server = new PGLiteSocketServer({ db, debug, inspect: debug, port });
|
|
2479
|
+
if (debug) {
|
|
2473
2480
|
server.addEventListener("listening", (event) => {
|
|
2474
2481
|
const { detail } = event;
|
|
2475
2482
|
console.debug(`[${purpose}] server listening on ${JSON.stringify(detail)}`);
|
|
@@ -2494,9 +2501,9 @@ async function startDBServer(purpose, serverState) {
|
|
|
2494
2501
|
return getStartDBServerResult(purpose, serverState, { db, port, server });
|
|
2495
2502
|
}
|
|
2496
2503
|
function getStartDBServerResult(purpose, serverState, options) {
|
|
2497
|
-
const { debug
|
|
2504
|
+
const { debug } = serverState;
|
|
2498
2505
|
const { db, port, server } = options || {};
|
|
2499
|
-
if (
|
|
2506
|
+
if (debug) {
|
|
2500
2507
|
console.debug(`[${purpose}] server started on port ${port}`);
|
|
2501
2508
|
}
|
|
2502
2509
|
return {
|
|
@@ -2505,7 +2512,7 @@ function getStartDBServerResult(purpose, serverState, options) {
|
|
|
2505
2512
|
const errors = [];
|
|
2506
2513
|
try {
|
|
2507
2514
|
await server?.stop();
|
|
2508
|
-
if (
|
|
2515
|
+
if (debug) {
|
|
2509
2516
|
console.debug(`[${purpose}] server stopped on port ${port}`);
|
|
2510
2517
|
}
|
|
2511
2518
|
} catch (error) {
|
|
@@ -2515,7 +2522,7 @@ function getStartDBServerResult(purpose, serverState, options) {
|
|
|
2515
2522
|
if (purpose === "database") {
|
|
2516
2523
|
try {
|
|
2517
2524
|
await db?.syncToFs();
|
|
2518
|
-
if (
|
|
2525
|
+
if (debug) {
|
|
2519
2526
|
console.debug(`[${purpose}] synced to filesystem`);
|
|
2520
2527
|
}
|
|
2521
2528
|
} catch (error) {
|
|
@@ -2525,7 +2532,7 @@ function getStartDBServerResult(purpose, serverState, options) {
|
|
|
2525
2532
|
}
|
|
2526
2533
|
try {
|
|
2527
2534
|
await db?.close();
|
|
2528
|
-
if (
|
|
2535
|
+
if (debug) {
|
|
2529
2536
|
console.debug(`[${purpose}] closed`);
|
|
2530
2537
|
}
|
|
2531
2538
|
} catch (error) {
|
|
@@ -2541,7 +2548,7 @@ function getStartDBServerResult(purpose, serverState, options) {
|
|
|
2541
2548
|
if (purpose === "shadow_database" || !db) {
|
|
2542
2549
|
return;
|
|
2543
2550
|
}
|
|
2544
|
-
await dumpDB({ db, debug
|
|
2551
|
+
await dumpDB({ db, debug, destinationPath });
|
|
2545
2552
|
},
|
|
2546
2553
|
port,
|
|
2547
2554
|
prismaORMConnectionString: getConnectionString(port, PRISMA_ORM_CONNECTION_STRING_QUERY_PARAMS),
|
|
@@ -2551,29 +2558,29 @@ function getStartDBServerResult(purpose, serverState, options) {
|
|
|
2551
2558
|
function getConnectionString(port, queryParams) {
|
|
2552
2559
|
return `${BASE_DB_URL}:${port}/${BASE_PGLITE_OPTIONS.database}?${queryParams.toString()}`;
|
|
2553
2560
|
}
|
|
2554
|
-
async function getDB(dataDir,
|
|
2561
|
+
async function getDB(dataDir, debug) {
|
|
2555
2562
|
const { PGlite } = await import("@electric-sql/pglite");
|
|
2556
2563
|
return await PGlite.create({
|
|
2557
2564
|
database: BASE_PGLITE_OPTIONS.database,
|
|
2558
2565
|
dataDir,
|
|
2559
|
-
debug:
|
|
2566
|
+
debug: debug ? 5 : void 0,
|
|
2560
2567
|
relaxedDurability: false,
|
|
2561
2568
|
username: BASE_PGLITE_OPTIONS.username
|
|
2562
2569
|
});
|
|
2563
2570
|
}
|
|
2564
|
-
async function getShadowDB(_dataDir,
|
|
2571
|
+
async function getShadowDB(_dataDir, debug) {
|
|
2565
2572
|
const { PGlite } = await import("@electric-sql/pglite");
|
|
2566
2573
|
return await PGlite.create({
|
|
2567
2574
|
database: BASE_PGLITE_OPTIONS.database,
|
|
2568
2575
|
dataDir: "memory://",
|
|
2569
|
-
debug:
|
|
2576
|
+
debug: debug ? 5 : void 0,
|
|
2570
2577
|
relaxedDurability: false,
|
|
2571
2578
|
username: BASE_PGLITE_OPTIONS.username
|
|
2572
2579
|
});
|
|
2573
2580
|
}
|
|
2574
2581
|
async function dumpDB(options) {
|
|
2575
|
-
const { dataDir, db, debug
|
|
2576
|
-
const pg = db || await getDB(dataDir,
|
|
2582
|
+
const { dataDir, db, debug, destinationPath } = options;
|
|
2583
|
+
const pg = db || await getDB(dataDir, debug);
|
|
2577
2584
|
const { pgDump } = await import("@electric-sql/pglite-tools/pg_dump");
|
|
2578
2585
|
const dumpFile = await pgDump({
|
|
2579
2586
|
args: [
|
|
@@ -2589,12 +2596,12 @@ async function dumpDB(options) {
|
|
|
2589
2596
|
pg: await pg.clone()
|
|
2590
2597
|
});
|
|
2591
2598
|
if (destinationPath) {
|
|
2592
|
-
if (
|
|
2599
|
+
if (debug) {
|
|
2593
2600
|
console.debug(`[DB] Dumping database to ${destinationPath}`);
|
|
2594
2601
|
}
|
|
2595
2602
|
return await streamAsTextTo(dumpFile, destinationPath);
|
|
2596
2603
|
}
|
|
2597
|
-
if (
|
|
2604
|
+
if (debug) {
|
|
2598
2605
|
console.debug(`[DB] Dumping database to memory`);
|
|
2599
2606
|
}
|
|
2600
2607
|
return await dumpFile.text();
|
|
@@ -2635,18 +2642,18 @@ function getStartHTTPServerResult(port, server) {
|
|
|
2635
2642
|
};
|
|
2636
2643
|
}
|
|
2637
2644
|
async function getApp(port, dbServer, serverState) {
|
|
2638
|
-
const { debug
|
|
2645
|
+
const { debug } = serverState;
|
|
2639
2646
|
const [{ Hono }, { accelerateRoute }, { utilityRoute }] = await Promise.all([
|
|
2640
2647
|
import("hono/tiny"),
|
|
2641
|
-
import("./accelerate-
|
|
2642
|
-
import("./utility-
|
|
2648
|
+
import("./accelerate-YEFEYVGD.js"),
|
|
2649
|
+
import("./utility-W6LOZZIT.js")
|
|
2643
2650
|
]);
|
|
2644
2651
|
const app = new Hono();
|
|
2645
2652
|
const platform = await getPlatformModule.getPlatformInfo();
|
|
2646
|
-
if (
|
|
2653
|
+
if (debug) {
|
|
2647
2654
|
console.debug("[Accelerate] platform info: %s", JSON.stringify(platform));
|
|
2648
2655
|
}
|
|
2649
|
-
if (
|
|
2656
|
+
if (debug) {
|
|
2650
2657
|
const { logger } = await import("hono/logger");
|
|
2651
2658
|
app.use(
|
|
2652
2659
|
"*",
|
|
@@ -2655,7 +2662,7 @@ async function getApp(port, dbServer, serverState) {
|
|
|
2655
2662
|
}
|
|
2656
2663
|
app.use("*", async (ctx, next) => {
|
|
2657
2664
|
ctx.set("db", dbServer);
|
|
2658
|
-
ctx.set("debug", Boolean(
|
|
2665
|
+
ctx.set("debug", Boolean(debug));
|
|
2659
2666
|
ctx.set("platform", platform);
|
|
2660
2667
|
ctx.set("port", port);
|
|
2661
2668
|
ctx.set("protocol", "http");
|
|
@@ -2675,14 +2682,14 @@ import { writeFile } from "fs/promises";
|
|
|
2675
2682
|
var import_proper_lockfile = __toESM(require_proper_lockfile(), 1);
|
|
2676
2683
|
|
|
2677
2684
|
// ../../dev/server/src/kernel.ts
|
|
2678
|
-
function checkProcessExists(pid,
|
|
2685
|
+
function checkProcessExists(pid, debug) {
|
|
2679
2686
|
if (pid == null) {
|
|
2680
2687
|
return false;
|
|
2681
2688
|
}
|
|
2682
2689
|
try {
|
|
2683
2690
|
return y.kill?.(pid, 0) ?? true;
|
|
2684
2691
|
} catch (error) {
|
|
2685
|
-
if (
|
|
2692
|
+
if (debug) {
|
|
2686
2693
|
console.error(`Error checking if process with PID ${pid} exists:`, error);
|
|
2687
2694
|
}
|
|
2688
2695
|
return false;
|
|
@@ -2742,17 +2749,17 @@ var ServerState = class {
|
|
|
2742
2749
|
return serverState;
|
|
2743
2750
|
}
|
|
2744
2751
|
static async fromServerDump(options) {
|
|
2745
|
-
const { debug
|
|
2752
|
+
const { debug, name = DEFAULT_NAME } = options ?? {};
|
|
2746
2753
|
const dataDirPath = getDataDirPath(name);
|
|
2747
2754
|
const serverDumpPath = StatefulServerState.getServerDumpPath(dataDirPath);
|
|
2748
2755
|
const serverDumpFileContent = await readFileAsText(serverDumpPath);
|
|
2749
2756
|
if (serverDumpFileContent == null) {
|
|
2750
|
-
if (
|
|
2757
|
+
if (debug) {
|
|
2751
2758
|
console.debug(`[State] No server dump file found at: ${serverDumpPath}`);
|
|
2752
2759
|
}
|
|
2753
2760
|
return null;
|
|
2754
2761
|
}
|
|
2755
|
-
if (
|
|
2762
|
+
if (debug) {
|
|
2756
2763
|
console.debug(`[State] server dump file found at "${serverDumpPath}":`);
|
|
2757
2764
|
console.debug(serverDumpFileContent);
|
|
2758
2765
|
}
|
|
@@ -2762,7 +2769,7 @@ var ServerState = class {
|
|
|
2762
2769
|
success
|
|
2763
2770
|
} = safeParse(pipe(string(), parseJson(), serverDumpV1Schema), serverDumpFileContent);
|
|
2764
2771
|
if (!success) {
|
|
2765
|
-
if (
|
|
2772
|
+
if (debug) {
|
|
2766
2773
|
console.debug(`[State] Invalid server dump file at "${serverDumpPath}":
|
|
2767
2774
|
${JSON.stringify(issues, null, 2)}`);
|
|
2768
2775
|
}
|
|
@@ -2770,7 +2777,7 @@ ${JSON.stringify(issues, null, 2)}`);
|
|
|
2770
2777
|
}
|
|
2771
2778
|
return new StatefulServerState({
|
|
2772
2779
|
databasePort: serverDump.databasePort,
|
|
2773
|
-
debug
|
|
2780
|
+
debug,
|
|
2774
2781
|
dryRun: false,
|
|
2775
2782
|
name,
|
|
2776
2783
|
pid: serverDump.pid,
|
|
@@ -2780,13 +2787,13 @@ ${JSON.stringify(issues, null, 2)}`);
|
|
|
2780
2787
|
});
|
|
2781
2788
|
}
|
|
2782
2789
|
static async scan(options) {
|
|
2783
|
-
const { debug
|
|
2790
|
+
const { debug, globs } = options ?? {};
|
|
2784
2791
|
const dataDirsPath = join(getDataDirPath(DEFAULT_NAME), "..");
|
|
2785
|
-
if (
|
|
2792
|
+
if (debug) {
|
|
2786
2793
|
console.debug(`[State] scanning for server states in: ${dataDirsPath}`);
|
|
2787
2794
|
}
|
|
2788
2795
|
const names = await readDirectoryNames(dataDirsPath, globs);
|
|
2789
|
-
if (
|
|
2796
|
+
if (debug) {
|
|
2790
2797
|
console.debug(`[State] found server names: ${JSON.stringify(names)}`);
|
|
2791
2798
|
}
|
|
2792
2799
|
return await Promise.all(names.map((name) => getServerStatus(name, options)));
|
|
@@ -2918,7 +2925,7 @@ var StatefulServerState = class _StatefulServerState extends ServerState {
|
|
|
2918
2925
|
}
|
|
2919
2926
|
};
|
|
2920
2927
|
async function getServerStatus(nameOrState, options) {
|
|
2921
|
-
const { debug
|
|
2928
|
+
const { debug, onlyMetadata } = options || {};
|
|
2922
2929
|
const name = typeof nameOrState === "string" ? nameOrState : nameOrState.name;
|
|
2923
2930
|
const givenState = typeof nameOrState !== "string" ? nameOrState : void 0;
|
|
2924
2931
|
const baseResult = {
|
|
@@ -2931,9 +2938,9 @@ async function getServerStatus(nameOrState, options) {
|
|
|
2931
2938
|
version: "1"
|
|
2932
2939
|
};
|
|
2933
2940
|
try {
|
|
2934
|
-
const serverState = givenState || await ServerState.fromServerDump({ debug
|
|
2941
|
+
const serverState = givenState || await ServerState.fromServerDump({ debug, name });
|
|
2935
2942
|
if (!serverState) {
|
|
2936
|
-
if (
|
|
2943
|
+
if (debug) {
|
|
2937
2944
|
console.debug(`[State] no server state found for name: ${name}`);
|
|
2938
2945
|
}
|
|
2939
2946
|
return { ...baseResult, status: "no_such_server" };
|
|
@@ -2947,8 +2954,8 @@ async function getServerStatus(nameOrState, options) {
|
|
|
2947
2954
|
if (onlyMetadata) {
|
|
2948
2955
|
return { ...baseResult, status: "unknown" };
|
|
2949
2956
|
}
|
|
2950
|
-
if (!checkProcessExists(pid,
|
|
2951
|
-
if (
|
|
2957
|
+
if (!checkProcessExists(pid, debug)) {
|
|
2958
|
+
if (debug) {
|
|
2952
2959
|
console.debug(`[State] server state for "${name}" has no running process with PID: ${pid}`);
|
|
2953
2960
|
}
|
|
2954
2961
|
return { ...baseResult, status: "not_running" };
|
|
@@ -2956,41 +2963,41 @@ async function getServerStatus(nameOrState, options) {
|
|
|
2956
2963
|
const dataDirPath = getDataDirPath(name);
|
|
2957
2964
|
try {
|
|
2958
2965
|
if (!await (0, import_proper_lockfile.check)(dataDirPath, { lockfilePath: join(dataDirPath, ".lock") })) {
|
|
2959
|
-
if (
|
|
2966
|
+
if (debug) {
|
|
2960
2967
|
console.debug(`[State] server state for "${name}" is not locked, indicating it is not running.`);
|
|
2961
2968
|
}
|
|
2962
2969
|
return { ...baseResult, status: "starting_up" };
|
|
2963
2970
|
}
|
|
2964
2971
|
} catch (error) {
|
|
2965
|
-
if (
|
|
2972
|
+
if (debug) {
|
|
2966
2973
|
console.error(`[State] server state for "${name}" failed to check lock:`, error);
|
|
2967
2974
|
}
|
|
2968
2975
|
}
|
|
2969
2976
|
if (!exports) {
|
|
2970
2977
|
return { ...baseResult, status: "starting_up" };
|
|
2971
2978
|
}
|
|
2972
|
-
const { http
|
|
2979
|
+
const { http } = exports;
|
|
2973
2980
|
const { hc } = await import("hono/client");
|
|
2974
|
-
const healthResponse = await hc(
|
|
2981
|
+
const healthResponse = await hc(http.url).health.$get();
|
|
2975
2982
|
if (!healthResponse.ok) {
|
|
2976
|
-
if (
|
|
2983
|
+
if (debug) {
|
|
2977
2984
|
console.debug(`[State] server state for "${name}" is not live: ${JSON.stringify(healthResponse)}`);
|
|
2978
2985
|
}
|
|
2979
2986
|
return { ...baseResult, status: "not_running" };
|
|
2980
2987
|
}
|
|
2981
2988
|
const health = await healthResponse.json();
|
|
2982
2989
|
if (health.name !== nameOrState) {
|
|
2983
|
-
if (
|
|
2990
|
+
if (debug) {
|
|
2984
2991
|
console.debug(`[State] server state for "${name}" has mismatched health response: ${JSON.stringify(health)}`);
|
|
2985
2992
|
}
|
|
2986
2993
|
return { ...baseResult, status: "unknown" };
|
|
2987
2994
|
}
|
|
2988
|
-
if (
|
|
2995
|
+
if (debug) {
|
|
2989
2996
|
console.debug(`[State] server state for "${nameOrState}" is live: ${JSON.stringify(health)}`);
|
|
2990
2997
|
}
|
|
2991
2998
|
return { ...baseResult, status: "running" };
|
|
2992
2999
|
} catch (error) {
|
|
2993
|
-
if (
|
|
3000
|
+
if (debug) {
|
|
2994
3001
|
console.error(`[State] failed to get server status for "${name}":`, error);
|
|
2995
3002
|
}
|
|
2996
3003
|
return { ...baseResult, status: "error" };
|
|
@@ -3067,10 +3074,10 @@ async function unstable_startServer(options) {
|
|
|
3067
3074
|
import internals from "@prisma/internals";
|
|
3068
3075
|
import dotenv from "dotenv";
|
|
3069
3076
|
import { Schema as Shape } from "effect";
|
|
3070
|
-
import
|
|
3071
|
-
import { bold as bold2, dim, green
|
|
3077
|
+
import fs2 from "fs";
|
|
3078
|
+
import { bold as bold2, dim, green, red as red2, yellow } from "kleur/colors";
|
|
3072
3079
|
import ora from "ora";
|
|
3073
|
-
import
|
|
3080
|
+
import path2 from "path";
|
|
3074
3081
|
import { match, P } from "ts-pattern";
|
|
3075
3082
|
|
|
3076
3083
|
// src/utils/client-output-path.ts
|
|
@@ -3106,398 +3113,43 @@ function getSourceDirFromTypeScriptConfig() {
|
|
|
3106
3113
|
return config.compilerOptions?.rootDir ?? config.compilerOptions?.baseUrl ?? config.compilerOptions?.rootDirs?.[0];
|
|
3107
3114
|
}
|
|
3108
3115
|
|
|
3109
|
-
// src/
|
|
3110
|
-
|
|
3111
|
-
|
|
3112
|
-
|
|
3113
|
-
|
|
3114
|
-
|
|
3115
|
-
|
|
3116
|
-
|
|
3117
|
-
|
|
3118
|
-
|
|
3119
|
-
|
|
3120
|
-
|
|
3121
|
-
|
|
3122
|
-
|
|
3123
|
-
|
|
3124
|
-
|
|
3125
|
-
|
|
3126
|
-
|
|
3127
|
-
|
|
3128
|
-
|
|
3129
|
-
|
|
3130
|
-
|
|
3131
|
-
}
|
|
3132
|
-
};
|
|
3133
|
-
async function login() {
|
|
3134
|
-
const server = http.createServer();
|
|
3135
|
-
server.listen({ host: "localhost", port: 0 });
|
|
3136
|
-
const addressInfo = await events.once(server, "listening").then(() => server.address());
|
|
3137
|
-
const state = new LoginState("localhost", addressInfo.port);
|
|
3138
|
-
const authResult = new Promise((resolve2) => {
|
|
3139
|
-
server.on("request", async (req, res) => {
|
|
3140
|
-
const url2 = new URL(`http://${state.host}${req.url}`);
|
|
3141
|
-
const result = await state.handleCallback(url2);
|
|
3142
|
-
if (result === null) {
|
|
3143
|
-
res.statusCode = 404;
|
|
3144
|
-
res.end();
|
|
3145
|
-
return;
|
|
3146
|
-
}
|
|
3147
|
-
res.setHeader("Content-Type", "text/html");
|
|
3148
|
-
res.end(`
|
|
3149
|
-
<html>
|
|
3150
|
-
<head>
|
|
3151
|
-
<title>Login</title>
|
|
3152
|
-
</head>
|
|
3153
|
-
<body>
|
|
3154
|
-
<p>Success!</p>
|
|
3155
|
-
<p>You may now close this page.</p>
|
|
3156
|
-
</body>
|
|
3157
|
-
</html>
|
|
3158
|
-
`);
|
|
3159
|
-
setImmediate(() => {
|
|
3160
|
-
server.close();
|
|
3161
|
-
});
|
|
3162
|
-
resolve2(result);
|
|
3163
|
-
});
|
|
3164
|
-
});
|
|
3165
|
-
await state.login();
|
|
3166
|
-
return await authResult;
|
|
3167
|
-
}
|
|
3168
|
-
var LoginState = class {
|
|
3169
|
-
constructor(hostname, port) {
|
|
3170
|
-
this.hostname = hostname;
|
|
3171
|
-
this.port = port;
|
|
3172
|
-
}
|
|
3173
|
-
latestVerifier;
|
|
3174
|
-
latestState;
|
|
3175
|
-
async login() {
|
|
3176
|
-
this.latestState = this.generateState();
|
|
3177
|
-
this.latestVerifier = this.generateVerifier();
|
|
3178
|
-
const challenge = this.generateChallenge(this.latestVerifier);
|
|
3179
|
-
const authUrl = new URL(LOGIN_URL);
|
|
3180
|
-
authUrl.searchParams.set("response_type", "code");
|
|
3181
|
-
authUrl.searchParams.set("client_id", CLIENT_ID);
|
|
3182
|
-
authUrl.searchParams.set("redirect_uri", this.redirectUri);
|
|
3183
|
-
authUrl.searchParams.set("scope", "workspace:admin offline_access");
|
|
3184
|
-
authUrl.searchParams.set("state", this.latestState);
|
|
3185
|
-
authUrl.searchParams.set("code_challenge", challenge);
|
|
3186
|
-
authUrl.searchParams.set("code_challenge_method", "S256");
|
|
3187
|
-
authUrl.searchParams.set("utm_source", "orm");
|
|
3188
|
-
authUrl.searchParams.set("utm_medium", "cli");
|
|
3189
|
-
authUrl.searchParams.set("utm_campaign", "oauth");
|
|
3190
|
-
await open(authUrl.href);
|
|
3191
|
-
}
|
|
3192
|
-
async handleCallback(url2) {
|
|
3193
|
-
if (url2.pathname !== "/auth/callback")
|
|
3194
|
-
return null;
|
|
3195
|
-
const params = url2.searchParams;
|
|
3196
|
-
const error = params.get("error");
|
|
3197
|
-
if (error)
|
|
3198
|
-
throw new AuthError(error);
|
|
3199
|
-
const code = params.get("code");
|
|
3200
|
-
const state = params.get("state");
|
|
3201
|
-
if (!code)
|
|
3202
|
-
throw new AuthError("No code found in callback");
|
|
3203
|
-
if (!this.latestVerifier)
|
|
3204
|
-
throw new AuthError("No verifier found");
|
|
3205
|
-
if (state !== this.latestState)
|
|
3206
|
-
throw new AuthError("Invalid state");
|
|
3207
|
-
const body = new URLSearchParams({
|
|
3208
|
-
grant_type: "authorization_code",
|
|
3209
|
-
code,
|
|
3210
|
-
redirect_uri: this.redirectUri,
|
|
3211
|
-
client_id: CLIENT_ID,
|
|
3212
|
-
code_verifier: this.latestVerifier
|
|
3213
|
-
});
|
|
3214
|
-
const response = await fetch(TOKEN_URL, {
|
|
3215
|
-
method: "POST",
|
|
3216
|
-
headers: { "Content-Type": "application/x-www-form-urlencoded" },
|
|
3217
|
-
body
|
|
3218
|
-
});
|
|
3219
|
-
return parseTokenResponse(response);
|
|
3220
|
-
}
|
|
3221
|
-
get host() {
|
|
3222
|
-
return `${this.hostname}:${this.port}`;
|
|
3223
|
-
}
|
|
3224
|
-
get redirectUri() {
|
|
3225
|
-
return `http://${this.host}/auth/callback`;
|
|
3226
|
-
}
|
|
3227
|
-
base64urlEncode(buffer) {
|
|
3228
|
-
return buffer.toString("base64").replace(/\+/g, "-").replace(/\//g, "_").replace(/=+$/, "");
|
|
3229
|
-
}
|
|
3230
|
-
generateState() {
|
|
3231
|
-
return crypto.randomBytes(16).toString("hex");
|
|
3232
|
-
}
|
|
3233
|
-
generateVerifier() {
|
|
3234
|
-
return this.base64urlEncode(crypto.randomBytes(32));
|
|
3235
|
-
}
|
|
3236
|
-
generateChallenge(verifier) {
|
|
3237
|
-
const hash = crypto.createHash("sha256").update(verifier).digest();
|
|
3238
|
-
return this.base64urlEncode(hash);
|
|
3239
|
-
}
|
|
3240
|
-
};
|
|
3241
|
-
async function refreshToken(refreshToken2) {
|
|
3242
|
-
const body = new URLSearchParams({
|
|
3243
|
-
grant_type: "refresh_token",
|
|
3244
|
-
refresh_token: refreshToken2,
|
|
3245
|
-
client_id: CLIENT_ID
|
|
3246
|
-
});
|
|
3247
|
-
const response = await fetch(TOKEN_URL, {
|
|
3248
|
-
method: "POST",
|
|
3249
|
-
headers: { "Content-Type": "application/x-www-form-urlencoded" },
|
|
3250
|
-
body
|
|
3251
|
-
});
|
|
3252
|
-
const result = await parseTokenResponse(response);
|
|
3253
|
-
return result;
|
|
3254
|
-
}
|
|
3255
|
-
async function parseTokenResponse(response) {
|
|
3256
|
-
const data = await response.json();
|
|
3257
|
-
if (!response.ok) {
|
|
3258
|
-
throw new AuthError(`Failed to get token. Status code ${response.status}, response: ${JSON.stringify(data)}.`);
|
|
3259
|
-
}
|
|
3260
|
-
const parsed = z.object({
|
|
3261
|
-
access_token: z.string(),
|
|
3262
|
-
refresh_token: z.string()
|
|
3263
|
-
}).parse(data);
|
|
3264
|
-
return { token: parsed.access_token, refreshToken: parsed.refresh_token };
|
|
3265
|
-
}
|
|
3266
|
-
|
|
3267
|
-
// src/management-api/client.ts
|
|
3268
|
-
import { Debug } from "@prisma/debug";
|
|
3269
|
-
import createClient from "openapi-fetch";
|
|
3270
|
-
var debug = Debug("prisma:cli:management-api");
|
|
3271
|
-
var FetchError = class extends Error {
|
|
3272
|
-
constructor() {
|
|
3273
|
-
super("Connection to API failed.");
|
|
3274
|
-
}
|
|
3275
|
-
};
|
|
3276
|
-
function createTokenRefreshingFetch(initialToken, tokenRefreshHandler) {
|
|
3277
|
-
let currentToken = initialToken;
|
|
3278
|
-
let refreshPromise = null;
|
|
3279
|
-
let subscribers = [];
|
|
3280
|
-
const isRefreshing = () => refreshPromise !== null;
|
|
3281
|
-
const refreshAccessToken = async () => {
|
|
3282
|
-
if (isRefreshing()) {
|
|
3283
|
-
debug("token refresh already in progress, waiting for it to complete...");
|
|
3284
|
-
return new Promise((resolve2) => subscribers.push(resolve2));
|
|
3285
|
-
}
|
|
3286
|
-
refreshPromise = tokenRefreshHandler().finally(() => {
|
|
3287
|
-
refreshPromise = null;
|
|
3288
|
-
});
|
|
3289
|
-
const { token } = await refreshPromise;
|
|
3290
|
-
debug("refreshed token!");
|
|
3291
|
-
currentToken = token;
|
|
3292
|
-
subscribers.forEach((cb) => cb(token));
|
|
3293
|
-
subscribers = [];
|
|
3294
|
-
return token;
|
|
3295
|
-
};
|
|
3296
|
-
return async function tokenRefreshingFetch(request) {
|
|
3297
|
-
const requestCloneForRetry = request.clone();
|
|
3298
|
-
request.headers.set("Authorization", `Bearer ${currentToken}`);
|
|
3299
|
-
let response = await fetch(request);
|
|
3300
|
-
if (response.status === 401) {
|
|
3301
|
-
debug("detected expired token, refreshing...");
|
|
3302
|
-
await refreshAccessToken();
|
|
3303
|
-
requestCloneForRetry.headers.set("Authorization", `Bearer ${currentToken}`);
|
|
3304
|
-
response = await fetch(requestCloneForRetry);
|
|
3305
|
-
}
|
|
3306
|
-
return response;
|
|
3307
|
-
};
|
|
3308
|
-
}
|
|
3309
|
-
function createManagementApiClient(token, tokenRefreshHandler) {
|
|
3310
|
-
const client = createClient({
|
|
3311
|
-
baseUrl: "https://api.prisma.io",
|
|
3312
|
-
fetch: createTokenRefreshingFetch(token, tokenRefreshHandler)
|
|
3313
|
-
});
|
|
3314
|
-
client.use({
|
|
3315
|
-
onRequest({ request }) {
|
|
3316
|
-
debug("onRequest", {
|
|
3317
|
-
method: request.method,
|
|
3318
|
-
url: request.url,
|
|
3319
|
-
body: request.body
|
|
3320
|
-
});
|
|
3321
|
-
return request;
|
|
3322
|
-
},
|
|
3323
|
-
onResponse({ response }) {
|
|
3324
|
-
debug("onResponse", {
|
|
3325
|
-
status: response.status,
|
|
3326
|
-
statusText: response.statusText,
|
|
3327
|
-
url: response.url
|
|
3328
|
-
});
|
|
3329
|
-
return response;
|
|
3330
|
-
},
|
|
3331
|
-
onError({ error }) {
|
|
3332
|
-
debug("Fetch error", error);
|
|
3333
|
-
return new FetchError();
|
|
3116
|
+
// src/platform/accelerate/regions.ts
|
|
3117
|
+
var getRegionsOrThrow = async (input2) => {
|
|
3118
|
+
const { token } = input2;
|
|
3119
|
+
const { system } = await requestOrThrow({
|
|
3120
|
+
token,
|
|
3121
|
+
body: {
|
|
3122
|
+
query: (
|
|
3123
|
+
/* GraphQL */
|
|
3124
|
+
`
|
|
3125
|
+
query {
|
|
3126
|
+
system {
|
|
3127
|
+
accelerate {
|
|
3128
|
+
regions {
|
|
3129
|
+
id
|
|
3130
|
+
displayName
|
|
3131
|
+
ppgStatus
|
|
3132
|
+
}
|
|
3133
|
+
}
|
|
3134
|
+
}
|
|
3135
|
+
}
|
|
3136
|
+
`
|
|
3137
|
+
)
|
|
3334
3138
|
}
|
|
3335
3139
|
});
|
|
3336
|
-
return
|
|
3337
|
-
}
|
|
3338
|
-
|
|
3339
|
-
// src/management-api/credentials.ts
|
|
3340
|
-
import fs2 from "fs/promises";
|
|
3341
|
-
import path2 from "path";
|
|
3342
|
-
import { Debug as Debug2 } from "@prisma/debug";
|
|
3343
|
-
import XdgAppPaths from "xdg-app-paths";
|
|
3344
|
-
import { z as z2 } from "zod";
|
|
3345
|
-
var debug2 = Debug2("prisma:cli:management-api:credentials");
|
|
3346
|
-
var credentialsSchema = z2.object({
|
|
3347
|
-
token: z2.string(),
|
|
3348
|
-
refreshToken: z2.string()
|
|
3349
|
-
});
|
|
3350
|
-
var credentialsFileDirectoryPath = new XdgAppPaths("prisma-cli").config();
|
|
3351
|
-
var credentialsFilePath = path2.join(credentialsFileDirectoryPath, "auth.json");
|
|
3352
|
-
async function loadCredentials() {
|
|
3353
|
-
try {
|
|
3354
|
-
const fileContent = await fs2.readFile(credentialsFilePath, "utf8");
|
|
3355
|
-
return credentialsSchema.parse(JSON.parse(fileContent));
|
|
3356
|
-
} catch (error) {
|
|
3357
|
-
debug2(error);
|
|
3358
|
-
return void 0;
|
|
3359
|
-
}
|
|
3360
|
-
}
|
|
3361
|
-
async function saveCredentials(credentials) {
|
|
3362
|
-
await fs2.mkdir(credentialsFileDirectoryPath, { recursive: true });
|
|
3363
|
-
await fs2.writeFile(credentialsFilePath, JSON.stringify(credentials, null, 2));
|
|
3364
|
-
}
|
|
3365
|
-
|
|
3366
|
-
// src/management-api/auth-client.ts
|
|
3367
|
-
async function createAuthenticatedManagementApiClient() {
|
|
3368
|
-
let authResult = await loadCredentials() ?? await login();
|
|
3369
|
-
const tokenRefreshHandler = async () => {
|
|
3370
|
-
authResult = await refreshToken(authResult.refreshToken);
|
|
3371
|
-
await saveCredentials(authResult);
|
|
3372
|
-
return { token: authResult.token };
|
|
3373
|
-
};
|
|
3374
|
-
return createManagementApiClient(authResult.token, tokenRefreshHandler);
|
|
3375
|
-
}
|
|
3376
|
-
|
|
3377
|
-
// src/management-api/api.ts
|
|
3378
|
-
var ManagementApiError = class extends Error {
|
|
3379
|
-
code;
|
|
3380
|
-
constructor({ code, message }) {
|
|
3381
|
-
super(message);
|
|
3382
|
-
this.code = code;
|
|
3383
|
-
}
|
|
3140
|
+
return system.accelerate.regions;
|
|
3384
3141
|
};
|
|
3385
|
-
var
|
|
3386
|
-
|
|
3387
|
-
|
|
3388
|
-
|
|
3389
|
-
}
|
|
3390
|
-
async getRegions() {
|
|
3391
|
-
const { data, error } = await this.#client.GET("/v1/regions/postgres");
|
|
3392
|
-
if (error) {
|
|
3393
|
-
throw new ManagementApiError(error.error);
|
|
3394
|
-
}
|
|
3395
|
-
return data.data;
|
|
3396
|
-
}
|
|
3397
|
-
async createProjectWithDatabase(name, region) {
|
|
3398
|
-
const { data, error } = await this.#client.POST("/v1/projects", {
|
|
3399
|
-
body: {
|
|
3400
|
-
createDatabase: true,
|
|
3401
|
-
name,
|
|
3402
|
-
region
|
|
3403
|
-
}
|
|
3404
|
-
});
|
|
3405
|
-
if (error) {
|
|
3406
|
-
throw new ManagementApiError(error.error);
|
|
3407
|
-
}
|
|
3408
|
-
return data.data;
|
|
3409
|
-
}
|
|
3142
|
+
var getPrismaPostgresRegionsOrThrow = async (input2) => {
|
|
3143
|
+
const regions = await getRegionsOrThrow(input2);
|
|
3144
|
+
const ppgRegions = regions.filter((_) => _.ppgStatus !== "unsupported").sort((a2, b) => b.displayName.localeCompare(a2.displayName));
|
|
3145
|
+
return ppgRegions;
|
|
3410
3146
|
};
|
|
3411
3147
|
|
|
3412
|
-
// src/
|
|
3413
|
-
import
|
|
3414
|
-
|
|
3415
|
-
|
|
3416
|
-
|
|
3417
|
-
import path3 from "path";
|
|
3418
|
-
var GeneratedFiles = class _GeneratedFiles {
|
|
3419
|
-
#basePath;
|
|
3420
|
-
#children = /* @__PURE__ */ new Map();
|
|
3421
|
-
constructor(basePath) {
|
|
3422
|
-
this.#basePath = basePath;
|
|
3423
|
-
}
|
|
3424
|
-
add(file) {
|
|
3425
|
-
if (file === this.#basePath) {
|
|
3426
|
-
return;
|
|
3427
|
-
}
|
|
3428
|
-
const relPath = path3.relative(this.#basePath, file);
|
|
3429
|
-
const [firstSegment] = relPath.split(path3.sep, 1);
|
|
3430
|
-
this.#entry(firstSegment).add(file);
|
|
3431
|
-
}
|
|
3432
|
-
#entry(name) {
|
|
3433
|
-
let entry = this.#children.get(name);
|
|
3434
|
-
if (!entry) {
|
|
3435
|
-
entry = new _GeneratedFiles(path3.join(this.#basePath, name));
|
|
3436
|
-
this.#children.set(name, entry);
|
|
3437
|
-
}
|
|
3438
|
-
return entry;
|
|
3439
|
-
}
|
|
3440
|
-
header() {
|
|
3441
|
-
const header = path3.basename(this.#basePath);
|
|
3442
|
-
if (this.#children.size === 0) {
|
|
3443
|
-
return header;
|
|
3444
|
-
} else {
|
|
3445
|
-
return `${header}/`;
|
|
3446
|
-
}
|
|
3447
|
-
}
|
|
3448
|
-
*entries() {
|
|
3449
|
-
for (const entry of this.#children.values()) {
|
|
3450
|
-
yield entry;
|
|
3451
|
-
}
|
|
3452
|
-
}
|
|
3453
|
-
format(f3) {
|
|
3454
|
-
return new Formatter(this, f3).formatToString();
|
|
3455
|
-
}
|
|
3456
|
-
};
|
|
3457
|
-
var Formatter = class _Formatter {
|
|
3458
|
-
#files;
|
|
3459
|
-
#format;
|
|
3460
|
-
constructor(files, format2) {
|
|
3461
|
-
this.#files = files;
|
|
3462
|
-
this.#format = format2;
|
|
3463
|
-
}
|
|
3464
|
-
formatToString() {
|
|
3465
|
-
return this.formatLines().join("\n");
|
|
3466
|
-
}
|
|
3467
|
-
formatLines() {
|
|
3468
|
-
const lines = [];
|
|
3469
|
-
if (this.#format.level >= this.#format.printHeadersFromLevel) {
|
|
3470
|
-
lines.push(this.#indent(this.#files.header()));
|
|
3471
|
-
}
|
|
3472
|
-
for (const entry of this.#files.entries()) {
|
|
3473
|
-
const formatter = new _Formatter(entry, { ...this.#format, level: this.#format.level + 1 });
|
|
3474
|
-
lines.push(...formatter.formatLines());
|
|
3475
|
-
}
|
|
3476
|
-
return lines;
|
|
3477
|
-
}
|
|
3478
|
-
#indent(line) {
|
|
3479
|
-
const indent = " ".repeat(this.#format.indentSize * this.#format.level);
|
|
3480
|
-
return `${indent}${line}`;
|
|
3481
|
-
}
|
|
3482
|
-
};
|
|
3483
|
-
|
|
3484
|
-
// src/file-writer.ts
|
|
3485
|
-
var FileWriter = class {
|
|
3486
|
-
#basePath;
|
|
3487
|
-
#files;
|
|
3488
|
-
constructor(basePath) {
|
|
3489
|
-
this.#basePath = basePath;
|
|
3490
|
-
this.#files = new GeneratedFiles(basePath);
|
|
3491
|
-
}
|
|
3492
|
-
write(name, content, options) {
|
|
3493
|
-
const absPath = path4.resolve(this.#basePath, name);
|
|
3494
|
-
fs3.writeFileSync(absPath, content, options);
|
|
3495
|
-
this.#files.add(absPath);
|
|
3496
|
-
}
|
|
3497
|
-
format(f3) {
|
|
3498
|
-
return this.#files.format(f3);
|
|
3499
|
-
}
|
|
3500
|
-
};
|
|
3148
|
+
// src/utils/print.ts
|
|
3149
|
+
import { bgRed, bold, red } from "kleur/colors";
|
|
3150
|
+
function printError(text) {
|
|
3151
|
+
return bold(bgRed(" ERROR ")) + " " + red(text);
|
|
3152
|
+
}
|
|
3501
3153
|
|
|
3502
3154
|
// src/Init.ts
|
|
3503
3155
|
var isBun = (
|
|
@@ -3562,10 +3214,10 @@ model User {
|
|
|
3562
3214
|
}
|
|
3563
3215
|
return schema;
|
|
3564
3216
|
};
|
|
3565
|
-
var defaultEnv = async (url2,
|
|
3217
|
+
var defaultEnv = async (url2, debug = false, comments = true) => {
|
|
3566
3218
|
if (url2 === void 0) {
|
|
3567
3219
|
let created = false;
|
|
3568
|
-
const state = await ServerState.fromServerDump({ debug
|
|
3220
|
+
const state = await ServerState.fromServerDump({ debug }) || (created = true, await ServerState.createExclusively({ persistenceMode: "stateful", debug }));
|
|
3569
3221
|
if (created) {
|
|
3570
3222
|
await state.close();
|
|
3571
3223
|
}
|
|
@@ -3574,7 +3226,7 @@ var defaultEnv = async (url2, debug3 = false, comments = true) => {
|
|
|
3574
3226
|
dryRun: true,
|
|
3575
3227
|
port: state.port,
|
|
3576
3228
|
shadowDatabasePort: state.shadowDatabasePort,
|
|
3577
|
-
debug
|
|
3229
|
+
debug
|
|
3578
3230
|
});
|
|
3579
3231
|
url2 = server.ppg.url;
|
|
3580
3232
|
}
|
|
@@ -3637,17 +3289,13 @@ var defaultGitIgnore = () => {
|
|
|
3637
3289
|
var defaultGeneratorProvider = "prisma-client";
|
|
3638
3290
|
var defaultPreviewFeatures = [];
|
|
3639
3291
|
function normalizePath(configPath) {
|
|
3640
|
-
return JSON.stringify(configPath.replaceAll(
|
|
3292
|
+
return JSON.stringify(configPath.replaceAll(path2.sep, "/"));
|
|
3641
3293
|
}
|
|
3642
3294
|
var defaultConfig = (props) => {
|
|
3643
3295
|
const { prismaFolder } = props;
|
|
3644
|
-
const schemaPath =
|
|
3645
|
-
const migrationsPath =
|
|
3646
|
-
return `
|
|
3647
|
-
// This file was generated by Prisma and assumes you have installed the following:
|
|
3648
|
-
// npm install --save-dev prisma dotenv
|
|
3649
|
-
import "dotenv/config";
|
|
3650
|
-
import { defineConfig, env } from "prisma/config";
|
|
3296
|
+
const schemaPath = path2.relative(process.cwd(), path2.join(prismaFolder, "schema.prisma"));
|
|
3297
|
+
const migrationsPath = path2.relative(process.cwd(), path2.join(prismaFolder, "migrations"));
|
|
3298
|
+
return `import { defineConfig, env } from "prisma/config";
|
|
3651
3299
|
|
|
3652
3300
|
export default defineConfig({
|
|
3653
3301
|
schema: ${normalizePath(schemaPath)},
|
|
@@ -3661,85 +3309,6 @@ export default defineConfig({
|
|
|
3661
3309
|
});
|
|
3662
3310
|
`;
|
|
3663
3311
|
};
|
|
3664
|
-
var printPpgInitOutput = ({
|
|
3665
|
-
databaseUrl,
|
|
3666
|
-
workspaceId,
|
|
3667
|
-
projectId,
|
|
3668
|
-
environmentId,
|
|
3669
|
-
isExistingPrismaProject = false
|
|
3670
|
-
}) => {
|
|
3671
|
-
const newPrismaProjectOutput = `
|
|
3672
|
-
We created an initial ${green2("schema.prisma")} file and a ${green2(".env")} file with your ${green2(
|
|
3673
|
-
"DATABASE_URL"
|
|
3674
|
-
)} environment variable already set.
|
|
3675
|
-
|
|
3676
|
-
${bold2("--- Next steps ---")}
|
|
3677
|
-
|
|
3678
|
-
Go to ${internals.link("https://pris.ly/ppg-init")} for detailed instructions.
|
|
3679
|
-
|
|
3680
|
-
${bold2("1. Define your database schema")}
|
|
3681
|
-
Open the ${green2("schema.prisma")} file and define your first models. Check the docs if you need inspiration: ${internals.link(
|
|
3682
|
-
"https://pris.ly/ppg-init"
|
|
3683
|
-
)}.
|
|
3684
|
-
|
|
3685
|
-
${bold2("2. Apply migrations")}
|
|
3686
|
-
Run the following command to create and apply a migration:
|
|
3687
|
-
${green2("npx prisma migrate dev --name init")}
|
|
3688
|
-
|
|
3689
|
-
${bold2("3. Manage your data")}
|
|
3690
|
-
View and edit your data locally by running this command:
|
|
3691
|
-
${green2("npx prisma studio")}
|
|
3692
|
-
${environmentId !== void 0 ? `...or online in Console:
|
|
3693
|
-
${internals.link(`https://console.prisma.io/${workspaceId}/${projectId}/${environmentId}/studio`)}
|
|
3694
|
-
` : ""}
|
|
3695
|
-
${bold2(`4. Send queries from your app`)}
|
|
3696
|
-
To access your database from a JavaScript/TypeScript app, you need to use Prisma ORM. Go here for step-by-step instructions: ${internals.link(
|
|
3697
|
-
"https://pris.ly/ppg-init"
|
|
3698
|
-
)}
|
|
3699
|
-
`;
|
|
3700
|
-
const existingPrismaProjectOutput = `
|
|
3701
|
-
We found an existing ${green2("schema.prisma")} file in your current project directory.
|
|
3702
|
-
|
|
3703
|
-
${bold2("--- Database URL ---")}
|
|
3704
|
-
|
|
3705
|
-
Connect Prisma ORM to your Prisma Postgres database with this URL:
|
|
3706
|
-
|
|
3707
|
-
${green2(databaseUrl)}
|
|
3708
|
-
|
|
3709
|
-
${bold2("--- Next steps ---")}
|
|
3710
|
-
|
|
3711
|
-
Go to ${internals.link("https://pris.ly/ppg-init")} for detailed instructions.
|
|
3712
|
-
|
|
3713
|
-
${bold2("1. Install the Postgres adapter")}
|
|
3714
|
-
${green2("npm install @prisma/adapter-pg")}
|
|
3715
|
-
|
|
3716
|
-
...and add it to your Prisma Client instance:
|
|
3717
|
-
${green2('import { PrismaPg } from "@prisma/adapter-pg";')}
|
|
3718
|
-
${green2('import { PrismaClient } from "./generated/prisma/client";')}
|
|
3719
|
-
|
|
3720
|
-
${green2("const connectionString = `${process.env.DATABASE_URL}`;")}
|
|
3721
|
-
|
|
3722
|
-
${green2("const adapter = new PrismaPg({ connectionString });")}
|
|
3723
|
-
${green2("const prisma = new PrismaClient({ adapter });")}
|
|
3724
|
-
|
|
3725
|
-
${bold2("2. Apply migrations")}
|
|
3726
|
-
Run the following command to create and apply a migration:
|
|
3727
|
-
${green2("npx prisma migrate dev")}
|
|
3728
|
-
|
|
3729
|
-
${bold2(`3. Manage your data`)}
|
|
3730
|
-
View and edit your data locally by running this command:
|
|
3731
|
-
${green2("npx prisma studio")}
|
|
3732
|
-
${environmentId !== void 0 ? `...or online in Console:
|
|
3733
|
-
${internals.link(`https://console.prisma.io/${workspaceId}/${projectId}/${environmentId}/studio`)}
|
|
3734
|
-
` : ""}
|
|
3735
|
-
${bold2(`4. Send queries from your app`)}
|
|
3736
|
-
If you already have an existing app with Prisma ORM, you can now run it and it will send queries against your newly created Prisma Postgres instance.
|
|
3737
|
-
|
|
3738
|
-
${bold2(`5. Learn more`)}
|
|
3739
|
-
For more info, visit the Prisma Postgres docs: ${internals.link("https://pris.ly/ppg-docs")}
|
|
3740
|
-
`;
|
|
3741
|
-
return isExistingPrismaProject ? existingPrismaProjectOutput : newPrismaProjectOutput;
|
|
3742
|
-
};
|
|
3743
3312
|
var Init = class _Init {
|
|
3744
3313
|
static new() {
|
|
3745
3314
|
return new _Init();
|
|
@@ -3773,8 +3342,8 @@ var Init = class _Init {
|
|
|
3773
3342
|
Set up a new Prisma project and specify MySQL as the datasource provider to use
|
|
3774
3343
|
${dim("$")} prisma init --datasource-provider mysql
|
|
3775
3344
|
|
|
3776
|
-
Set up a new \`prisma dev\`-ready (local Prisma Postgres) Prisma project and specify \`prisma-client-
|
|
3777
|
-
${dim("$")} prisma init --generator-provider prisma-client-
|
|
3345
|
+
Set up a new \`prisma dev\`-ready (local Prisma Postgres) Prisma project and specify \`prisma-client-go\` as the generator provider to use
|
|
3346
|
+
${dim("$")} prisma init --generator-provider prisma-client-go
|
|
3778
3347
|
|
|
3779
3348
|
Set up a new \`prisma dev\`-ready (local Prisma Postgres) Prisma project and specify \`x\` and \`y\` as the preview features to use
|
|
3780
3349
|
${dim("$")} prisma init --preview-feature x --preview-feature y
|
|
@@ -3860,16 +3429,18 @@ var Init = class _Init {
|
|
|
3860
3429
|
console.log(`[isBun]`, isBun);
|
|
3861
3430
|
}
|
|
3862
3431
|
let prismaPostgresDatabaseUrl;
|
|
3863
|
-
let workspaceId
|
|
3864
|
-
let projectId
|
|
3865
|
-
let environmentId
|
|
3432
|
+
let workspaceId = ``;
|
|
3433
|
+
let projectId = ``;
|
|
3434
|
+
let environmentId = ``;
|
|
3866
3435
|
const outputDir = process.cwd();
|
|
3867
|
-
const prismaFolder =
|
|
3868
|
-
const writer = new FileWriter(outputDir);
|
|
3436
|
+
const prismaFolder = path2.join(outputDir, "prisma");
|
|
3869
3437
|
let generatedSchema;
|
|
3870
3438
|
let generatedName;
|
|
3871
3439
|
if (isPpgCommand) {
|
|
3872
|
-
const
|
|
3440
|
+
const PlatformCommands = await import("./_-RC7NSKHC.js");
|
|
3441
|
+
const credentials = await credentialsFile.load();
|
|
3442
|
+
if (internals.isError(credentials))
|
|
3443
|
+
throw credentials;
|
|
3873
3444
|
if (!credentials) {
|
|
3874
3445
|
if (args["--non-interactive"]) {
|
|
3875
3446
|
return "Please authenticate before creating a Prisma Postgres project.";
|
|
@@ -3881,7 +3452,8 @@ var Init = class _Init {
|
|
|
3881
3452
|
if (!authAnswer) {
|
|
3882
3453
|
return "Project creation aborted. You need to authenticate to use Prisma Postgres";
|
|
3883
3454
|
}
|
|
3884
|
-
|
|
3455
|
+
const authenticationResult = await PlatformCommands.loginOrSignup();
|
|
3456
|
+
console.log(`Successfully authenticated as ${bold2(authenticationResult.email)}.`);
|
|
3885
3457
|
}
|
|
3886
3458
|
if (args["--prompt"] || args["--vibe"]) {
|
|
3887
3459
|
const prompt = args["--prompt"] || args["--vibe"] || "";
|
|
@@ -3909,16 +3481,16 @@ var Init = class _Init {
|
|
|
3909
3481
|
spinner2.succeed("Schema is ready");
|
|
3910
3482
|
}
|
|
3911
3483
|
console.log("Let's set up your Prisma Postgres database!");
|
|
3912
|
-
const
|
|
3913
|
-
const
|
|
3914
|
-
const regions = await
|
|
3484
|
+
const platformToken = await PlatformCommands.getTokenOrThrow(args);
|
|
3485
|
+
const defaultWorkspace = await PlatformCommands.Workspace.getDefaultWorkspaceOrThrow({ token: platformToken });
|
|
3486
|
+
const regions = await getPrismaPostgresRegionsOrThrow({ token: platformToken });
|
|
3915
3487
|
const ppgRegionSelection = args["--region"] || await select({
|
|
3916
3488
|
message: "Select your region:",
|
|
3917
3489
|
default: "us-east-1",
|
|
3918
3490
|
choices: regions.map((region) => ({
|
|
3919
|
-
name: `${region.id} - ${region.
|
|
3491
|
+
name: `${region.id} - ${region.displayName}`,
|
|
3920
3492
|
value: region.id,
|
|
3921
|
-
disabled: region.
|
|
3493
|
+
disabled: region.ppgStatus === "unavailable"
|
|
3922
3494
|
})),
|
|
3923
3495
|
loop: true
|
|
3924
3496
|
});
|
|
@@ -3930,25 +3502,41 @@ var Init = class _Init {
|
|
|
3930
3502
|
`Creating project ${bold2(projectDisplayNameAnswer)} (this may take a few seconds)...`
|
|
3931
3503
|
).start();
|
|
3932
3504
|
try {
|
|
3933
|
-
const project = await
|
|
3934
|
-
|
|
3935
|
-
|
|
3936
|
-
|
|
3937
|
-
|
|
3938
|
-
|
|
3939
|
-
}
|
|
3940
|
-
|
|
3941
|
-
|
|
3942
|
-
|
|
3943
|
-
|
|
3944
|
-
|
|
3505
|
+
const project = await PlatformCommands.Project.createProjectOrThrow({
|
|
3506
|
+
token: platformToken,
|
|
3507
|
+
displayName: projectDisplayNameAnswer,
|
|
3508
|
+
workspaceId: defaultWorkspace.id,
|
|
3509
|
+
allowRemoteDatabases: false,
|
|
3510
|
+
ppgRegion: ppgRegionSelection
|
|
3511
|
+
});
|
|
3512
|
+
spinner.text = `Waiting for your Prisma Postgres database to be ready...`;
|
|
3513
|
+
workspaceId = defaultWorkspace.id;
|
|
3514
|
+
projectId = project.id;
|
|
3515
|
+
environmentId = project.defaultEnvironment.id;
|
|
3516
|
+
await poll(
|
|
3517
|
+
() => PlatformCommands.Environment.getEnvironmentOrThrow({
|
|
3518
|
+
environmentId: project.defaultEnvironment.id,
|
|
3519
|
+
token: platformToken
|
|
3520
|
+
}),
|
|
3521
|
+
(environment) => environment.ppg.status === "healthy" && environment.accelerate.status.enabled,
|
|
3522
|
+
5e3,
|
|
3523
|
+
// Poll every 5 seconds
|
|
3524
|
+
12e4
|
|
3525
|
+
// if it takes more than two minutes, bail with an error
|
|
3526
|
+
);
|
|
3527
|
+
const serviceToken = await PlatformCommands.ServiceToken.createOrThrow({
|
|
3528
|
+
token: platformToken,
|
|
3529
|
+
environmentId: project.defaultEnvironment.id,
|
|
3530
|
+
displayName: `database-setup-prismaPostgres-api-key`
|
|
3531
|
+
});
|
|
3532
|
+
prismaPostgresDatabaseUrl = `${internals.PRISMA_POSTGRES_PROTOCOL}//accelerate.prisma-data.net/?api_key=${serviceToken.value}`;
|
|
3945
3533
|
spinner.succeed(successMessage("Your Prisma Postgres database is ready \u2705"));
|
|
3946
3534
|
} catch (error) {
|
|
3947
3535
|
spinner.fail(error instanceof Error ? error.message : "Something went wrong");
|
|
3948
3536
|
throw error;
|
|
3949
3537
|
}
|
|
3950
3538
|
}
|
|
3951
|
-
if (
|
|
3539
|
+
if (fs2.existsSync(path2.join(outputDir, "schema.prisma")) || fs2.existsSync(prismaFolder) || fs2.existsSync(path2.join(prismaFolder, "schema.prisma"))) {
|
|
3952
3540
|
if (isPpgCommand) {
|
|
3953
3541
|
return printPpgInitOutput({
|
|
3954
3542
|
databaseUrl: prismaPostgresDatabaseUrl,
|
|
@@ -3959,7 +3547,7 @@ var Init = class _Init {
|
|
|
3959
3547
|
});
|
|
3960
3548
|
}
|
|
3961
3549
|
}
|
|
3962
|
-
if (
|
|
3550
|
+
if (fs2.existsSync(path2.join(outputDir, "schema.prisma"))) {
|
|
3963
3551
|
console.log(
|
|
3964
3552
|
printError(`File ${bold2("schema.prisma")} already exists in your project.
|
|
3965
3553
|
Please try again in a project that is not yet using Prisma.
|
|
@@ -3967,7 +3555,7 @@ var Init = class _Init {
|
|
|
3967
3555
|
);
|
|
3968
3556
|
process.exit(1);
|
|
3969
3557
|
}
|
|
3970
|
-
if (
|
|
3558
|
+
if (fs2.existsSync(prismaFolder)) {
|
|
3971
3559
|
console.log(
|
|
3972
3560
|
printError(`A folder called ${bold2("prisma")} already exists in your project.
|
|
3973
3561
|
Please try again in a project that is not yet using Prisma.
|
|
@@ -3975,7 +3563,7 @@ var Init = class _Init {
|
|
|
3975
3563
|
);
|
|
3976
3564
|
process.exit(1);
|
|
3977
3565
|
}
|
|
3978
|
-
if (
|
|
3566
|
+
if (fs2.existsSync(path2.join(prismaFolder, "schema.prisma"))) {
|
|
3979
3567
|
console.log(
|
|
3980
3568
|
printError(`File ${bold2("prisma/schema.prisma")} already exists in your project.
|
|
3981
3569
|
Please try again in a project that is not yet using Prisma.
|
|
@@ -3983,15 +3571,15 @@ var Init = class _Init {
|
|
|
3983
3571
|
);
|
|
3984
3572
|
process.exit(1);
|
|
3985
3573
|
}
|
|
3986
|
-
if (!
|
|
3987
|
-
|
|
3574
|
+
if (!fs2.existsSync(outputDir)) {
|
|
3575
|
+
fs2.mkdirSync(outputDir);
|
|
3988
3576
|
}
|
|
3989
|
-
if (!
|
|
3990
|
-
|
|
3577
|
+
if (!fs2.existsSync(prismaFolder)) {
|
|
3578
|
+
fs2.mkdirSync(prismaFolder);
|
|
3991
3579
|
}
|
|
3992
3580
|
const clientOutput = output ?? determineClientOutputPath(prismaFolder);
|
|
3993
|
-
|
|
3994
|
-
|
|
3581
|
+
fs2.writeFileSync(
|
|
3582
|
+
path2.join(prismaFolder, "schema.prisma"),
|
|
3995
3583
|
generatedSchema || defaultSchema({
|
|
3996
3584
|
datasourceProvider,
|
|
3997
3585
|
generatorProvider,
|
|
@@ -4002,26 +3590,26 @@ var Init = class _Init {
|
|
|
4002
3590
|
);
|
|
4003
3591
|
const databaseUrl = prismaPostgresDatabaseUrl || url2;
|
|
4004
3592
|
const warnings = [];
|
|
4005
|
-
|
|
4006
|
-
|
|
3593
|
+
fs2.writeFileSync(
|
|
3594
|
+
path2.join(outputDir, "prisma.config.ts"),
|
|
4007
3595
|
defaultConfig({
|
|
4008
3596
|
prismaFolder
|
|
4009
3597
|
})
|
|
4010
3598
|
);
|
|
4011
|
-
const envPath =
|
|
4012
|
-
if (!
|
|
4013
|
-
|
|
3599
|
+
const envPath = path2.join(outputDir, ".env");
|
|
3600
|
+
if (!fs2.existsSync(envPath)) {
|
|
3601
|
+
fs2.writeFileSync(envPath, await defaultEnv(databaseUrl, args["--debug"]));
|
|
4014
3602
|
} else {
|
|
4015
|
-
const envFile =
|
|
3603
|
+
const envFile = fs2.readFileSync(envPath, { encoding: "utf8" });
|
|
4016
3604
|
const config = dotenv.parse(envFile);
|
|
4017
3605
|
if (Object.keys(config).includes("DATABASE_URL")) {
|
|
4018
3606
|
warnings.push(
|
|
4019
3607
|
`${yellow("warn")} Prisma would have added DATABASE_URL but it already exists in ${bold2(
|
|
4020
|
-
|
|
3608
|
+
path2.relative(outputDir, envPath)
|
|
4021
3609
|
)}`
|
|
4022
3610
|
);
|
|
4023
3611
|
} else {
|
|
4024
|
-
|
|
3612
|
+
fs2.appendFileSync(
|
|
4025
3613
|
envPath,
|
|
4026
3614
|
`
|
|
4027
3615
|
|
|
@@ -4030,65 +3618,85 @@ var Init = class _Init {
|
|
|
4030
3618
|
);
|
|
4031
3619
|
}
|
|
4032
3620
|
}
|
|
4033
|
-
const gitignorePath =
|
|
3621
|
+
const gitignorePath = path2.join(outputDir, ".gitignore");
|
|
4034
3622
|
try {
|
|
4035
|
-
|
|
3623
|
+
fs2.writeFileSync(gitignorePath, defaultGitIgnore(), { flag: "wx" });
|
|
4036
3624
|
} catch (e) {
|
|
4037
3625
|
if (e.code === "EEXIST") {
|
|
4038
3626
|
warnings.push(
|
|
4039
3627
|
`${yellow(
|
|
4040
3628
|
"warn"
|
|
4041
|
-
)} You already have a
|
|
3629
|
+
)} You already have a .gitignore file. Don't forget to add \`.env\` in it to not commit any private information.`
|
|
4042
3630
|
);
|
|
4043
3631
|
} else {
|
|
4044
3632
|
console.error("Failed to write .gitignore file, reason: ", e);
|
|
4045
3633
|
}
|
|
4046
3634
|
}
|
|
4047
|
-
const clientPathRelativeToOutputDir =
|
|
3635
|
+
const clientPathRelativeToOutputDir = path2.relative(outputDir, path2.resolve(prismaFolder, clientOutput));
|
|
4048
3636
|
try {
|
|
4049
|
-
|
|
4050
|
-
/${clientPathRelativeToOutputDir.replaceAll(
|
|
3637
|
+
fs2.appendFileSync(gitignorePath, `
|
|
3638
|
+
/${clientPathRelativeToOutputDir.replaceAll(path2.sep, "/")}
|
|
4051
3639
|
`);
|
|
4052
3640
|
} catch (e) {
|
|
4053
3641
|
console.error("Failed to append client path to .gitignore file, reason: ", e);
|
|
4054
3642
|
}
|
|
4055
|
-
const
|
|
4056
|
-
|
|
4057
|
-
|
|
4058
|
-
|
|
4059
|
-
|
|
4060
|
-
|
|
4061
|
-
|
|
4062
|
-
${
|
|
4063
|
-
|
|
4064
|
-
|
|
4065
|
-
|
|
3643
|
+
const steps = [];
|
|
3644
|
+
if (!isBun) {
|
|
3645
|
+
steps.push(`Install \`dotenv\`, and add \`import "dotenv/config";\` to your \`prisma.config.ts\` file to load environment variables from \`.env\`.`);
|
|
3646
|
+
}
|
|
3647
|
+
const isPrismaDev = !args["--url"] && (datasourceProvider === "postgres" || datasourceProvider === "postgresql");
|
|
3648
|
+
if (isPrismaDev) {
|
|
3649
|
+
steps.push(
|
|
3650
|
+
`Run ${green(internals.getCommandWithExecutor("prisma dev"))} to start a local Prisma Postgres server.`
|
|
3651
|
+
);
|
|
3652
|
+
} else if (!args["--url"]) {
|
|
3653
|
+
steps.push(
|
|
3654
|
+
`Set the ${green("DATABASE_URL")} in the ${green(
|
|
3655
|
+
".env"
|
|
3656
|
+
)} file to point to your existing database. If your database has no ${datasourceProvider === "mongodb" ? "collections" : "tables"} yet, read https://pris.ly/d/getting-started`
|
|
3657
|
+
);
|
|
3658
|
+
}
|
|
3659
|
+
if (isPrismaDev || datasourceProvider === "mongodb") {
|
|
3660
|
+
steps.push(`Define models in the ${green("schema.prisma")} file.`);
|
|
4066
3661
|
} else {
|
|
4067
|
-
|
|
4068
|
-
${
|
|
3662
|
+
steps.push(
|
|
3663
|
+
`Run ${green(internals.getCommandWithExecutor("prisma db pull"))} to turn your database schema into a Prisma schema.`
|
|
3664
|
+
);
|
|
3665
|
+
}
|
|
3666
|
+
if (isPrismaDev) {
|
|
3667
|
+
steps.push(
|
|
3668
|
+
`Run ${green(internals.getCommandWithExecutor("prisma migrate dev"))} to migrate your local Prisma Postgres database.`
|
|
3669
|
+
);
|
|
3670
|
+
} else {
|
|
3671
|
+
steps.push(
|
|
3672
|
+
`Run ${green(
|
|
3673
|
+
internals.getCommandWithExecutor("prisma generate")
|
|
3674
|
+
)} to generate the Prisma Client. You can then start querying your database.`
|
|
3675
|
+
);
|
|
3676
|
+
}
|
|
3677
|
+
steps.push(
|
|
3678
|
+
`Tip: Explore how you can extend the ${green(
|
|
3679
|
+
"ORM"
|
|
3680
|
+
)} with scalable connection pooling, global caching, and a managed serverless Postgres database. Read: https://pris.ly/cli/beyond-orm`
|
|
3681
|
+
);
|
|
3682
|
+
if (!isBun) {
|
|
3683
|
+
warnings.push(`Environment variables declared in the \`.env\` file are NOT automatically loaded by Prisma.
|
|
3684
|
+
See: https://pris.ly/prisma-config-env-vars.`);
|
|
4069
3685
|
}
|
|
4070
3686
|
const defaultOutput = `
|
|
4071
|
-
|
|
4072
|
-
|
|
4073
|
-
|
|
4074
|
-
|
|
4075
|
-
printHeadersFromLevel: 1,
|
|
4076
|
-
indentSize: 2
|
|
4077
|
-
})}
|
|
4078
|
-
${warnings.length > 0 ? `
|
|
3687
|
+
\u2714 Your Prisma schema was created at ${green("prisma/schema.prisma")}
|
|
3688
|
+
\u2714 Your Prisma config was created at ${green("prisma.config.ts")}
|
|
3689
|
+
You can now open them in your favorite editor.
|
|
3690
|
+
${warnings.length > 0 && internals.logger.should.warn() ? `
|
|
4079
3691
|
${warnings.join("\n")}
|
|
4080
3692
|
` : ""}
|
|
4081
|
-
|
|
3693
|
+
Next steps:
|
|
3694
|
+
${steps.map((s2, i) => `${i + 1}. ${s2}`).join("\n")}
|
|
4082
3695
|
|
|
4083
|
-
|
|
4084
|
-
|
|
4085
|
-
|
|
4086
|
-
return isPpgCommand ? printPpgInitOutput({
|
|
4087
|
-
databaseUrl: prismaPostgresDatabaseUrl,
|
|
4088
|
-
workspaceId,
|
|
4089
|
-
projectId,
|
|
4090
|
-
environmentId
|
|
4091
|
-
}) : defaultOutput;
|
|
3696
|
+
More information in our documentation:
|
|
3697
|
+
${internals.link("https://pris.ly/d/getting-started")}
|
|
3698
|
+
`;
|
|
3699
|
+
return isPpgCommand ? printPpgInitOutput({ databaseUrl: prismaPostgresDatabaseUrl, workspaceId, projectId, environmentId }) : defaultOutput;
|
|
4092
3700
|
}
|
|
4093
3701
|
// help message
|
|
4094
3702
|
help(error) {
|