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