@prisma/migrate 5.23.0-dev.2 → 5.23.0-dev.21

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (48) hide show
  1. package/dist/Migrate.js +4 -4
  2. package/dist/SchemaEngine.js +4 -4
  3. package/dist/bin.js +39 -40
  4. package/dist/{chunk-EXUBPCXZ.js → chunk-3H4RLVCQ.js} +12 -12
  5. package/dist/{chunk-ZLGLVUFD.js → chunk-E2XKFV2C.js} +8 -8
  6. package/dist/{chunk-XVL5RF2T.js → chunk-GUBDW6S7.js} +11 -11
  7. package/dist/{chunk-BAVMZZAR.js → chunk-HODZFC64.js} +7 -7
  8. package/dist/{chunk-BAFPAACN.js → chunk-ILJRJJ3S.js} +4 -4
  9. package/dist/{chunk-LLGEQ76N.js → chunk-ILQWQHQO.js} +11 -11
  10. package/dist/{chunk-E3KHFUFQ.js → chunk-J77IRNPE.js} +9 -124
  11. package/dist/{chunk-76XWADEV.js → chunk-KEPR65SW.js} +6 -6
  12. package/dist/{chunk-NIFQA5SB.js → chunk-LAHPBQAT.js} +61 -143
  13. package/dist/{chunk-MWEO3VUS.js → chunk-LJOMIPJW.js} +7 -7
  14. package/dist/{chunk-GJN3CSXW.js → chunk-NKL64AIB.js} +6 -6
  15. package/dist/{chunk-VWV2NY26.js → chunk-NKQGJ3AE.js} +7 -3
  16. package/dist/{chunk-XLLUFIQK.js → chunk-PCJYN6LT.js} +6 -5
  17. package/dist/{chunk-SV5GANSI.js → chunk-PFEH6ILG.js} +6 -6
  18. package/dist/{chunk-ZBOJAYON.js → chunk-PNBMPQYH.js} +6 -6
  19. package/dist/{chunk-W3ROQKBN.js → chunk-V7DE6JTG.js} +4 -4
  20. package/dist/{chunk-WD642UYX.js → chunk-WDEGF6OA.js} +62 -144
  21. package/dist/{chunk-UJWMQPUH.js → chunk-X6GGREJW.js} +6 -6
  22. package/dist/{chunk-WIZM7TFT.js → chunk-YKUZUAXA.js} +443 -55
  23. package/dist/{chunk-YOW3VBYS.js → chunk-Z4OLB2H4.js} +6 -6
  24. package/dist/commands/DbExecute.js +5 -5
  25. package/dist/commands/DbPull.js +6 -6
  26. package/dist/commands/DbPush.js +5 -5
  27. package/dist/commands/DbSeed.js +4 -5
  28. package/dist/commands/MigrateDeploy.js +5 -5
  29. package/dist/commands/MigrateDev.js +6 -7
  30. package/dist/commands/MigrateDiff.js +6 -7
  31. package/dist/commands/MigrateReset.js +6 -7
  32. package/dist/commands/MigrateResolve.js +5 -5
  33. package/dist/commands/MigrateStatus.js +5 -5
  34. package/dist/index.js +45 -46
  35. package/dist/internals/src/utils/isCurrentBinInstalledGlobally.d.ts +1 -1
  36. package/dist/{multipart-parser-KKECAI5D.js → multipart-parser-73VM3J4A.js} +10 -7
  37. package/dist/{multipart-parser-47FFAP42-P3F6TPHJ.js → multipart-parser-ITART6UP-FFJAMHWE.js} +25 -22
  38. package/dist/utils/getDatabaseVersionSafe.js +4 -4
  39. package/dist/utils/introspectSql.js +3 -3
  40. package/dist/utils/removeSchemaFiles.js +3 -3
  41. package/dist/utils/saveSchemaFiles.js +3 -3
  42. package/dist/utils/seed.js +6 -7
  43. package/dist/utils/setupMSSQL.js +62 -59
  44. package/dist/utils/setupMongo.js +5 -4
  45. package/dist/utils/setupMysql.js +45 -0
  46. package/package.json +9 -10
  47. package/dist/chunk-EFPE3Q7J.js +0 -424
  48. package/dist/internals/src/get-generators/generatorResolvers/prisma-client-js/check-dependencies/checkYarnVersion.d.ts +0 -9
@@ -33,7 +33,7 @@ __export(setupMongo_exports, {
33
33
  tearDownMongo: () => tearDownMongo
34
34
  });
35
35
  module.exports = __toCommonJS(setupMongo_exports);
36
- var import_chunk_E3KHFUFQ = require("../chunk-E3KHFUFQ.js");
36
+ var import_chunk_J77IRNPE = require("../chunk-J77IRNPE.js");
37
37
  var import_chunk_RM5LJIEV = require("../chunk-RM5LJIEV.js");
38
38
  var import_chunk_WWAWV7DQ = require("../chunk-WWAWV7DQ.js");
39
39
  var import_path = __toESM(require("path"));
@@ -37022,6 +37022,7 @@ var require_methods2 = (0, import_chunk_WWAWV7DQ.__commonJS)({
37022
37022
  continue;
37023
37023
  }
37024
37024
  switch (event) {
37025
+ // only swap for save event for now, we may change this to all event types later
37025
37026
  case "save":
37026
37027
  val = _this[i];
37027
37028
  break;
@@ -39833,7 +39834,7 @@ var require_utils5 = (0, import_chunk_WWAWV7DQ.__commonJS)({
39833
39834
  "../../node_modules/.pnpm/mongoose@8.4.3/node_modules/mongoose/lib/utils.js"(exports) {
39834
39835
  "use strict";
39835
39836
  var UUID = require_bson().UUID;
39836
- var ms = (0, import_chunk_E3KHFUFQ.require_ms)();
39837
+ var ms = (0, import_chunk_J77IRNPE.require_ms)();
39837
39838
  var mpath = require_mpath();
39838
39839
  var ObjectId2 = require_objectid();
39839
39840
  var PopulateOptions = require_populateOptions();
@@ -51059,7 +51060,7 @@ var require_mquery = (0, import_chunk_WWAWV7DQ.__commonJS)({
51059
51060
  var assert = (0, import_chunk_WWAWV7DQ.__require)("assert");
51060
51061
  var util = (0, import_chunk_WWAWV7DQ.__require)("util");
51061
51062
  var utils = require_utils6();
51062
- var debug = (0, import_chunk_E3KHFUFQ.require_src)()("mquery");
51063
+ var debug = (0, import_chunk_J77IRNPE.require_src)()("mquery");
51063
51064
  function Query(criteria, options) {
51064
51065
  if (!(this instanceof Query))
51065
51066
  return new Query(criteria, options);
@@ -61047,7 +61048,7 @@ var require_mongoose = (0, import_chunk_WWAWV7DQ.__commonJS)({
61047
61048
  var defaultMongooseSymbol = Symbol.for("mongoose:default");
61048
61049
  require_printJestWarning();
61049
61050
  var objectIdHexRegexp = /^[0-9A-Fa-f]{24}$/;
61050
- var { AsyncLocalStorage } = (0, import_chunk_WWAWV7DQ.__require)("async_hooks");
61051
+ var { AsyncLocalStorage } = (0, import_chunk_WWAWV7DQ.__require)("node:async_hooks");
61051
61052
  function Mongoose(options) {
61052
61053
  this.connections = [];
61053
61054
  this.nextConnectionId = 0;
@@ -6089,6 +6089,9 @@ var require_clear_password_auth = (0, import_chunk_WWAWV7DQ.__commonJS)({
6089
6089
  response(packet, out, opts, info) {
6090
6090
  const marker = packet.peek();
6091
6091
  switch (marker) {
6092
+ //*********************************************************************************************************
6093
+ //* OK_Packet and Err_Packet ending packet
6094
+ //*********************************************************************************************************
6092
6095
  case 0:
6093
6096
  case 255:
6094
6097
  this.emit("send_end");
@@ -6877,6 +6880,9 @@ var require_pam_password_auth = (0, import_chunk_WWAWV7DQ.__commonJS)({
6877
6880
  response(packet, out, opts, info) {
6878
6881
  const marker = packet.peek();
6879
6882
  switch (marker) {
6883
+ //*********************************************************************************************************
6884
+ //* OK_Packet and Err_Packet ending packet
6885
+ //*********************************************************************************************************
6880
6886
  case 0:
6881
6887
  case 255:
6882
6888
  this.emit("send_end");
@@ -7002,6 +7008,9 @@ var require_sha256_password_auth = (0, import_chunk_WWAWV7DQ.__commonJS)({
7002
7008
  response(packet, out, opts, info) {
7003
7009
  const marker = packet.peek();
7004
7010
  switch (marker) {
7011
+ //*********************************************************************************************************
7012
+ //* OK_Packet and Err_Packet ending packet
7013
+ //*********************************************************************************************************
7005
7014
  case 0:
7006
7015
  case 255:
7007
7016
  this.emit("send_end");
@@ -7109,6 +7118,9 @@ var require_caching_sha2_password_auth = (0, import_chunk_WWAWV7DQ.__commonJS)({
7109
7118
  response(packet, out, opts, info) {
7110
7119
  const marker = packet.peek();
7111
7120
  switch (marker) {
7121
+ //*********************************************************************************************************
7122
+ //* OK_Packet and Err_Packet ending packet
7123
+ //*********************************************************************************************************
7112
7124
  case 0:
7113
7125
  case 255:
7114
7126
  this.emit("send_end");
@@ -7171,9 +7183,15 @@ var require_authentication = (0, import_chunk_WWAWV7DQ.__commonJS)({
7171
7183
  handshakeResult(packet, out, opts, info) {
7172
7184
  const marker = packet.peek();
7173
7185
  switch (marker) {
7186
+ //*********************************************************************************************************
7187
+ //* AuthSwitchRequest packet
7188
+ //*********************************************************************************************************
7174
7189
  case 254:
7175
7190
  this.dispatchAuthSwitchRequest(packet, out, opts, info);
7176
7191
  return;
7192
+ //*********************************************************************************************************
7193
+ //* OK_Packet - authentication succeeded
7194
+ //*********************************************************************************************************
7177
7195
  case 0:
7178
7196
  this.plugin.onPacketReceive = null;
7179
7197
  packet.skip(1);
@@ -7254,11 +7272,17 @@ var require_authentication = (0, import_chunk_WWAWV7DQ.__commonJS)({
7254
7272
  }
7255
7273
  if (!mustRedirect) this.successEnd();
7256
7274
  return;
7275
+ //*********************************************************************************************************
7276
+ //* ERR_Packet
7277
+ //*********************************************************************************************************
7257
7278
  case 255:
7258
7279
  this.plugin.onPacketReceive = null;
7259
7280
  const authErr = packet.readError(info, this.displaySql(), void 0);
7260
7281
  authErr.fatal = true;
7261
7282
  return this.plugin.throwError(authErr, info);
7283
+ //*********************************************************************************************************
7284
+ //* unexpected
7285
+ //*********************************************************************************************************
7262
7286
  default:
7263
7287
  this.throwNewError(
7264
7288
  `Unexpected type of packet during handshake phase : ${marker}`,
@@ -8581,16 +8605,28 @@ var require_parser = (0, import_chunk_WWAWV7DQ.__commonJS)({
8581
8605
  */
8582
8606
  readResponsePacket(packet, out, opts, info) {
8583
8607
  switch (packet.peek()) {
8608
+ //*********************************************************************************************************
8609
+ //* OK response
8610
+ //*********************************************************************************************************
8584
8611
  case 0:
8585
8612
  return this.readOKPacket(packet, out, opts, info);
8613
+ //*********************************************************************************************************
8614
+ //* ERROR response
8615
+ //*********************************************************************************************************
8586
8616
  case 255:
8587
8617
  this._columns = null;
8588
8618
  this._rows = [];
8589
8619
  const err = packet.readError(info, opts.logParam ? this.displaySql() : this.sql, this.cmdParam.stack);
8590
8620
  info.status |= ServerStatus.STATUS_IN_TRANS;
8591
8621
  return this.throwError(err, info);
8622
+ //*********************************************************************************************************
8623
+ //* LOCAL INFILE response
8624
+ //*********************************************************************************************************
8592
8625
  case 251:
8593
8626
  return this.readLocalInfile(packet, out, opts, info);
8627
+ //*********************************************************************************************************
8628
+ //* Parser
8629
+ //*********************************************************************************************************
8594
8630
  default:
8595
8631
  return this.readResultSet(packet, info);
8596
8632
  }
@@ -10314,6 +10350,9 @@ var require_prepare = (0, import_chunk_WWAWV7DQ.__commonJS)({
10314
10350
  */
10315
10351
  readPrepareResultPacket(packet, out, opts, info) {
10316
10352
  switch (packet.peek()) {
10353
+ //*********************************************************************************************************
10354
+ //* PREPARE response
10355
+ //*********************************************************************************************************
10317
10356
  case 0:
10318
10357
  packet.skip(1);
10319
10358
  this.statementId = packet.readInt32();
@@ -10324,11 +10363,17 @@ var require_prepare = (0, import_chunk_WWAWV7DQ.__commonJS)({
10324
10363
  if (this._parameterNo > 0) return this.onPacketReceive = this.skipPrepareParameterPacket;
10325
10364
  if (this.columnNo > 0) return this.onPacketReceive = this.readPrepareColumnsPacket;
10326
10365
  return this.successPrepare(info, opts);
10366
+ //*********************************************************************************************************
10367
+ //* ERROR response
10368
+ //*********************************************************************************************************
10327
10369
  case 255:
10328
10370
  const err = packet.readError(info, this.displaySql(), this.stack);
10329
10371
  info.status |= ServerStatus.STATUS_IN_TRANS;
10330
10372
  this.onPacketReceive = this.readResponsePacket;
10331
10373
  return this.throwError(err, info);
10374
+ //*********************************************************************************************************
10375
+ //* Unexpected response
10376
+ //*********************************************************************************************************
10332
10377
  default:
10333
10378
  info.status |= ServerStatus.STATUS_IN_TRANS;
10334
10379
  this.onPacketReceive = this.readResponsePacket;
package/package.json CHANGED
@@ -1,9 +1,9 @@
1
1
  {
2
2
  "name": "@prisma/migrate",
3
- "version": "5.23.0-dev.2",
3
+ "version": "5.23.0-dev.21",
4
4
  "description": "This package is intended for Prisma's internal use",
5
5
  "main": "dist/index.js",
6
- "types": "dist/index.d.ts",
6
+ "types": "dist/migrate/src/index.d.ts",
7
7
  "repository": {
8
8
  "type": "git",
9
9
  "url": "https://github.com/prisma/prisma.git",
@@ -26,12 +26,11 @@
26
26
  "@types/prompts": "2.4.9",
27
27
  "@types/sqlite3": "3.1.11",
28
28
  "arg": "5.0.2",
29
- "esbuild": "0.23.0",
29
+ "esbuild": "0.24.0",
30
30
  "execa": "5.1.1",
31
31
  "fp-ts": "2.16.9",
32
32
  "fs-jetpack": "5.1.0",
33
33
  "get-stdin": "8.0.0",
34
- "has-yarn": "2.1.0",
35
34
  "indent-string": "4.0.0",
36
35
  "jest": "29.7.0",
37
36
  "jest-junit": "16.0.0",
@@ -49,19 +48,19 @@
49
48
  "tempy": "1.0.1",
50
49
  "ts-pattern": "5.2.0",
51
50
  "typescript": "5.4.5",
52
- "wrangler": "3.62.0"
51
+ "wrangler": "3.91.0"
53
52
  },
54
53
  "peerDependencies": {
55
54
  "@prisma/generator-helper": "*",
56
55
  "@prisma/internals": "*"
57
56
  },
58
57
  "dependencies": {
59
- "@prisma/engines-version": "5.22.0-44.605197351a3c8bdd595af2d2a9bc3025bca48ea2",
58
+ "@prisma/engines-version": "5.23.0-13.06d4b2f30bf4fc71a1cb03bdc0f69f8c2a5c2b9c",
60
59
  "prompts": "2.4.2",
61
- "@prisma/debug": "5.23.0-dev.2",
62
- "@prisma/generator-helper": "5.23.0-dev.2",
63
- "@prisma/get-platform": "5.23.0-dev.2",
64
- "@prisma/internals": "5.23.0-dev.2"
60
+ "@prisma/generator-helper": "5.23.0-dev.21",
61
+ "@prisma/debug": "5.23.0-dev.21",
62
+ "@prisma/internals": "5.23.0-dev.21",
63
+ "@prisma/get-platform": "5.23.0-dev.21"
65
64
  },
66
65
  "files": [
67
66
  "README.md",
@@ -1,424 +0,0 @@
1
- "use strict";
2
- var __create = Object.create;
3
- var __defProp = Object.defineProperty;
4
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5
- var __getOwnPropNames = Object.getOwnPropertyNames;
6
- var __getProtoOf = Object.getPrototypeOf;
7
- var __hasOwnProp = Object.prototype.hasOwnProperty;
8
- var __export = (target, all) => {
9
- for (var name in all)
10
- __defProp(target, name, { get: all[name], enumerable: true });
11
- };
12
- var __copyProps = (to, from, except, desc) => {
13
- if (from && typeof from === "object" || typeof from === "function") {
14
- for (let key of __getOwnPropNames(from))
15
- if (!__hasOwnProp.call(to, key) && key !== except)
16
- __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
17
- }
18
- return to;
19
- };
20
- var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
21
- // If the importer is in node compatibility mode or this is not an ESM
22
- // file that has been converted to a CommonJS file using a Babel-
23
- // compatible transform (i.e. "__esModule" has not been set), then set
24
- // "default" to the CommonJS "module.exports" for node compatibility.
25
- isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
26
- mod
27
- ));
28
- var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
29
- var chunk_EFPE3Q7J_exports = {};
30
- __export(chunk_EFPE3Q7J_exports, {
31
- executeSeedCommand: () => executeSeedCommand,
32
- getSeedCommandFromPackageJson: () => getSeedCommandFromPackageJson,
33
- init_seed: () => init_seed,
34
- legacyTsNodeScriptWarning: () => legacyTsNodeScriptWarning,
35
- verifySeedConfigAndReturnMessage: () => verifySeedConfigAndReturnMessage
36
- });
37
- module.exports = __toCommonJS(chunk_EFPE3Q7J_exports);
38
- var import_chunk_WIZM7TFT = require("./chunk-WIZM7TFT.js");
39
- var import_chunk_6TE2RIPN = require("./chunk-6TE2RIPN.js");
40
- var import_chunk_WWAWV7DQ = require("./chunk-WWAWV7DQ.js");
41
- var import_debug = __toESM(require("@prisma/debug"));
42
- var import_internals = require("@prisma/internals");
43
- var import_fs = __toESM(require("fs"));
44
- var import_path = __toESM(require("path"));
45
- var require_has_yarn = (0, import_chunk_WWAWV7DQ.__commonJS)({
46
- "../../node_modules/.pnpm/has-yarn@2.1.0/node_modules/has-yarn/index.js"(exports, module2) {
47
- "use strict";
48
- var path2 = (0, import_chunk_WWAWV7DQ.__require)("path");
49
- var fs2 = (0, import_chunk_WWAWV7DQ.__require)("fs");
50
- var hasYarn2 = (cwd = process.cwd()) => fs2.existsSync(path2.resolve(cwd, "yarn.lock"));
51
- module2.exports = hasYarn2;
52
- module2.exports.default = hasYarn2;
53
- }
54
- });
55
- var require_path_exists = (0, import_chunk_WWAWV7DQ.__commonJS)({
56
- "../../node_modules/.pnpm/path-exists@3.0.0/node_modules/path-exists/index.js"(exports, module2) {
57
- "use strict";
58
- var fs2 = (0, import_chunk_WWAWV7DQ.__require)("fs");
59
- module2.exports = (fp) => new Promise((resolve) => {
60
- fs2.access(fp, (err) => {
61
- resolve(!err);
62
- });
63
- });
64
- module2.exports.sync = (fp) => {
65
- try {
66
- fs2.accessSync(fp);
67
- return true;
68
- } catch (err) {
69
- return false;
70
- }
71
- };
72
- }
73
- });
74
- var require_p_try = (0, import_chunk_WWAWV7DQ.__commonJS)({
75
- "../../node_modules/.pnpm/p-try@2.2.0/node_modules/p-try/index.js"(exports, module2) {
76
- "use strict";
77
- var pTry = (fn, ...arguments_) => new Promise((resolve) => {
78
- resolve(fn(...arguments_));
79
- });
80
- module2.exports = pTry;
81
- module2.exports.default = pTry;
82
- }
83
- });
84
- var require_p_limit = (0, import_chunk_WWAWV7DQ.__commonJS)({
85
- "../../node_modules/.pnpm/p-limit@2.3.0/node_modules/p-limit/index.js"(exports, module2) {
86
- "use strict";
87
- var pTry = require_p_try();
88
- var pLimit = (concurrency) => {
89
- if (!((Number.isInteger(concurrency) || concurrency === Infinity) && concurrency > 0)) {
90
- return Promise.reject(new TypeError("Expected `concurrency` to be a number from 1 and up"));
91
- }
92
- const queue = [];
93
- let activeCount = 0;
94
- const next = () => {
95
- activeCount--;
96
- if (queue.length > 0) {
97
- queue.shift()();
98
- }
99
- };
100
- const run = (fn, resolve, ...args) => {
101
- activeCount++;
102
- const result = pTry(fn, ...args);
103
- resolve(result);
104
- result.then(next, next);
105
- };
106
- const enqueue = (fn, resolve, ...args) => {
107
- if (activeCount < concurrency) {
108
- run(fn, resolve, ...args);
109
- } else {
110
- queue.push(run.bind(null, fn, resolve, ...args));
111
- }
112
- };
113
- const generator = (fn, ...args) => new Promise((resolve) => enqueue(fn, resolve, ...args));
114
- Object.defineProperties(generator, {
115
- activeCount: {
116
- get: () => activeCount
117
- },
118
- pendingCount: {
119
- get: () => queue.length
120
- },
121
- clearQueue: {
122
- value: () => {
123
- queue.length = 0;
124
- }
125
- }
126
- });
127
- return generator;
128
- };
129
- module2.exports = pLimit;
130
- module2.exports.default = pLimit;
131
- }
132
- });
133
- var require_p_locate = (0, import_chunk_WWAWV7DQ.__commonJS)({
134
- "../../node_modules/.pnpm/p-locate@3.0.0/node_modules/p-locate/index.js"(exports, module2) {
135
- "use strict";
136
- var pLimit = require_p_limit();
137
- var EndError = class extends Error {
138
- constructor(value) {
139
- super();
140
- this.value = value;
141
- }
142
- };
143
- var testElement = (el, tester) => Promise.resolve(el).then(tester);
144
- var finder = (el) => Promise.all(el).then((val) => val[1] === true && Promise.reject(new EndError(val[0])));
145
- module2.exports = (iterable, tester, opts) => {
146
- opts = Object.assign({
147
- concurrency: Infinity,
148
- preserveOrder: true
149
- }, opts);
150
- const limit = pLimit(opts.concurrency);
151
- const items = [...iterable].map((el) => [el, limit(testElement, el, tester)]);
152
- const checkLimit = pLimit(opts.preserveOrder ? 1 : Infinity);
153
- return Promise.all(items.map((el) => checkLimit(finder, el))).then(() => {
154
- }).catch((err) => err instanceof EndError ? err.value : Promise.reject(err));
155
- };
156
- }
157
- });
158
- var require_locate_path = (0, import_chunk_WWAWV7DQ.__commonJS)({
159
- "../../node_modules/.pnpm/locate-path@3.0.0/node_modules/locate-path/index.js"(exports, module2) {
160
- "use strict";
161
- var path2 = (0, import_chunk_WWAWV7DQ.__require)("path");
162
- var pathExists = require_path_exists();
163
- var pLocate = require_p_locate();
164
- module2.exports = (iterable, options) => {
165
- options = Object.assign({
166
- cwd: process.cwd()
167
- }, options);
168
- return pLocate(iterable, (el) => pathExists(path2.resolve(options.cwd, el)), options);
169
- };
170
- module2.exports.sync = (iterable, options) => {
171
- options = Object.assign({
172
- cwd: process.cwd()
173
- }, options);
174
- for (const el of iterable) {
175
- if (pathExists.sync(path2.resolve(options.cwd, el))) {
176
- return el;
177
- }
178
- }
179
- };
180
- }
181
- });
182
- var require_find_up = (0, import_chunk_WWAWV7DQ.__commonJS)({
183
- "../../node_modules/.pnpm/find-up@3.0.0/node_modules/find-up/index.js"(exports, module2) {
184
- "use strict";
185
- var path2 = (0, import_chunk_WWAWV7DQ.__require)("path");
186
- var locatePath = require_locate_path();
187
- module2.exports = (filename, opts = {}) => {
188
- const startDir = path2.resolve(opts.cwd || "");
189
- const { root } = path2.parse(startDir);
190
- const filenames = [].concat(filename);
191
- return new Promise((resolve) => {
192
- (function find(dir) {
193
- locatePath(filenames, { cwd: dir }).then((file) => {
194
- if (file) {
195
- resolve(path2.join(dir, file));
196
- } else if (dir === root) {
197
- resolve(null);
198
- } else {
199
- find(path2.dirname(dir));
200
- }
201
- });
202
- })(startDir);
203
- });
204
- };
205
- module2.exports.sync = (filename, opts = {}) => {
206
- let dir = path2.resolve(opts.cwd || "");
207
- const { root } = path2.parse(dir);
208
- const filenames = [].concat(filename);
209
- while (true) {
210
- const file = locatePath.sync(filenames, { cwd: dir });
211
- if (file) {
212
- return path2.join(dir, file);
213
- }
214
- if (dir === root) {
215
- return null;
216
- }
217
- dir = path2.dirname(dir);
218
- }
219
- };
220
- }
221
- });
222
- var require_pkg_up = (0, import_chunk_WWAWV7DQ.__commonJS)({
223
- "../../node_modules/.pnpm/pkg-up@3.1.0/node_modules/pkg-up/index.js"(exports, module2) {
224
- "use strict";
225
- var findUp = require_find_up();
226
- module2.exports = async ({ cwd } = {}) => findUp("package.json", { cwd });
227
- module2.exports.sync = ({ cwd } = {}) => findUp.sync("package.json", { cwd });
228
- }
229
- });
230
- async function verifySeedConfigAndReturnMessage(schemaPath) {
231
- const cwd = process.cwd();
232
- const detected = detectSeedFiles(cwd, schemaPath);
233
- const prismaConfig = await (0, import_internals.getPrismaConfigFromPackageJson)(cwd);
234
- if (prismaConfig && prismaConfig.data?.seed) {
235
- return void 0;
236
- }
237
- const packageManager = (0, import_has_yarn.default)() ? "yarn add -D" : "npm i -D";
238
- let message = `${(0, import_chunk_6TE2RIPN.red)(
239
- 'To configure seeding in your project you need to add a "prisma.seed" property in your package.json with the command to execute it:'
240
- )}
241
-
242
- 1. Open the package.json of your project
243
- `;
244
- if (detected.numberOfSeedFiles) {
245
- await legacyTsNodeScriptWarning();
246
- message += `2. Add the following example to it:`;
247
- if (detected.js) {
248
- message += `
249
- \`\`\`
250
- "prisma": {
251
- "seed": "node ${detected.js}"
252
- }
253
- \`\`\`
254
- `;
255
- } else if (detected.ts) {
256
- message += `
257
- \`\`\`
258
- "prisma": {
259
- "seed": "ts-node ${detected.ts}"
260
- }
261
- \`\`\`
262
- If you are using ESM (ECMAScript modules):
263
- \`\`\`
264
- "prisma": {
265
- "seed": "node --loader ts-node/esm ${detected.ts}"
266
- }
267
- \`\`\`
268
-
269
- 3. Install the required dependencies by running:
270
- ${(0, import_chunk_6TE2RIPN.green)(`${packageManager} ts-node typescript @types/node`)}
271
- `;
272
- } else if (detected.sh) {
273
- message += `
274
- \`\`\`
275
- "prisma": {
276
- "seed": "${detected.sh}"
277
- }
278
- \`\`\`
279
- And run \`chmod +x ${detected.sh}\` to make it executable.`;
280
- }
281
- } else {
282
- message += `2. Add one of the following examples to your package.json:
283
-
284
- ${(0, import_chunk_6TE2RIPN.bold)("TypeScript:")}
285
- \`\`\`
286
- "prisma": {
287
- "seed": "ts-node ./prisma/seed.ts"
288
- }
289
- \`\`\`
290
- If you are using ESM (ECMAScript modules):
291
- \`\`\`
292
- "prisma": {
293
- "seed": "node --loader ts-node/esm ./prisma/seed.ts"
294
- }
295
- \`\`\`
296
-
297
- And install the required dependencies by running:
298
- ${packageManager} ts-node typescript @types/node
299
-
300
- ${(0, import_chunk_6TE2RIPN.bold)("JavaScript:")}
301
- \`\`\`
302
- "prisma": {
303
- "seed": "node ./prisma/seed.js"
304
- }
305
- \`\`\`
306
-
307
- ${(0, import_chunk_6TE2RIPN.bold)("Bash:")}
308
- \`\`\`
309
- "prisma": {
310
- "seed": "./prisma/seed.sh"
311
- }
312
- \`\`\`
313
- And run \`chmod +x prisma/seed.sh\` to make it executable.`;
314
- }
315
- message += `
316
- More information in our documentation:
317
- ${(0, import_internals.link)("https://pris.ly/d/seeding")}`;
318
- return message;
319
- }
320
- async function getSeedCommandFromPackageJson(cwd) {
321
- const prismaConfig = await (0, import_internals.getPrismaConfigFromPackageJson)(cwd);
322
- debug({ prismaConfig });
323
- if (!prismaConfig || !prismaConfig.data?.seed) {
324
- return null;
325
- }
326
- const seedCommandFromPkgJson = prismaConfig.data.seed;
327
- if (typeof seedCommandFromPkgJson !== "string") {
328
- throw new Error(
329
- `Provided seed command \`${seedCommandFromPkgJson}\` from \`${import_path.default.relative(
330
- cwd,
331
- prismaConfig.packagePath
332
- )}\` must be of type string`
333
- );
334
- }
335
- if (!seedCommandFromPkgJson) {
336
- throw new Error(
337
- `Provided seed command \`${seedCommandFromPkgJson}\` from \`${import_path.default.relative(
338
- cwd,
339
- prismaConfig.packagePath
340
- )}\` cannot be empty`
341
- );
342
- }
343
- return seedCommandFromPkgJson;
344
- }
345
- async function executeSeedCommand({
346
- commandFromConfig,
347
- extraArgs
348
- }) {
349
- const command = extraArgs ? `${commandFromConfig} ${extraArgs}` : commandFromConfig;
350
- process.stdout.write(`Running seed command \`${(0, import_chunk_6TE2RIPN.italic)(command)}\` ...
351
- `);
352
- try {
353
- await import_execa.default.command(command, {
354
- stdout: "inherit",
355
- stderr: "inherit"
356
- });
357
- } catch (_e) {
358
- const e = _e;
359
- debug({ e });
360
- console.error((0, import_chunk_6TE2RIPN.bold)((0, import_chunk_6TE2RIPN.red)(`
361
- An error occurred while running the seed command:`)));
362
- console.error((0, import_chunk_6TE2RIPN.red)(e.stderr || String(e)));
363
- return false;
364
- }
365
- return true;
366
- }
367
- function detectSeedFiles(cwd, schemaPath) {
368
- let parentDirectory = import_path.default.relative(cwd, import_path.default.join(cwd, "prisma"));
369
- if (schemaPath) {
370
- parentDirectory = import_path.default.relative(cwd, import_path.default.dirname(schemaPath));
371
- }
372
- const seedPath = import_path.default.join(parentDirectory, "seed.");
373
- const detected = {
374
- seedPath,
375
- numberOfSeedFiles: 0,
376
- js: "",
377
- ts: "",
378
- sh: ""
379
- };
380
- const extensions = ["js", "ts", "sh"];
381
- for (const extension of extensions) {
382
- const fullPath = seedPath + extension;
383
- if (!import_fs.default.existsSync(fullPath)) {
384
- continue;
385
- }
386
- detected[extension] = fullPath;
387
- detected.numberOfSeedFiles++;
388
- }
389
- debug({ detected });
390
- return detected;
391
- }
392
- async function legacyTsNodeScriptWarning() {
393
- const scripts = await getScriptsFromPackageJson();
394
- if (scripts?.["ts-node"]) {
395
- import_internals.logger.warn(
396
- (0, import_chunk_6TE2RIPN.yellow)(`The "ts-node" script in the package.json is not used anymore since version 3.0 and can now be removed.`)
397
- );
398
- }
399
- return void 0;
400
- }
401
- async function getScriptsFromPackageJson(cwd = process.cwd()) {
402
- try {
403
- const pkgJsonPath = await (0, import_pkg_up.default)({ cwd });
404
- if (!pkgJsonPath) {
405
- return null;
406
- }
407
- const pkgJsonString = await import_fs.default.promises.readFile(pkgJsonPath, "utf-8");
408
- const pkgJson = JSON.parse(pkgJsonString);
409
- const { "ts-node": tsnode } = pkgJson.scripts;
410
- return { "ts-node": tsnode };
411
- } catch {
412
- return null;
413
- }
414
- }
415
- var import_execa, import_has_yarn, import_pkg_up, debug;
416
- var init_seed = (0, import_chunk_WWAWV7DQ.__esm)({
417
- "src/utils/seed.ts"() {
418
- import_execa = (0, import_chunk_WWAWV7DQ.__toESM)((0, import_chunk_WIZM7TFT.require_execa)());
419
- import_has_yarn = (0, import_chunk_WWAWV7DQ.__toESM)(require_has_yarn());
420
- (0, import_chunk_6TE2RIPN.init_colors)();
421
- import_pkg_up = (0, import_chunk_WWAWV7DQ.__toESM)(require_pkg_up());
422
- debug = (0, import_debug.default)("prisma:migrate:seed");
423
- }
424
- });
@@ -1,9 +0,0 @@
1
- /**
2
- * Warn, if yarn is older than 1.19.2 because Yarn used to remove all dot
3
- * folders inside node_modules before. We use node_modules/.prisma/client
4
- * directory as default location for generated Prisma Client. Changelog
5
- * https://github.com/yarnpkg/yarn/blob/HEAD/CHANGELOG.md#1192
6
- * https://www.prisma.io/docs/reference/system-requirements#software-requirements
7
- * // TODO Maybe we replace this with the "engines" field in package.json
8
- */
9
- export declare function checkYarnVersion(): void;