@prisma/migrate 5.22.0-integration-remove-custom-yarn-logic.5 → 5.22.0-integration-engines-5-22-0-27-metrics3-phantasmagoria-of-the-lost-recorder-47785ced2c48f59d114bb0f15b5495cf6c0a7b8e.1
Sign up to get free protection for your applications and to get access to all the features.
- package/dist/bin.js +14 -13
- package/dist/chunk-EFPE3Q7J.js +424 -0
- package/dist/{chunk-3XXJ4W6W.js → chunk-J3KBGWIZ.js} +92 -6
- package/dist/{chunk-O6RO4YUZ.js → chunk-LLGEQ76N.js} +8 -8
- package/dist/{chunk-B4GG72YU.js → chunk-UY4MANZT.js} +93 -7
- package/dist/{chunk-YKUZUAXA.js → chunk-WIZM7TFT.js} +55 -443
- package/dist/{chunk-75AMGQ4R.js → chunk-XVL5RF2T.js} +8 -8
- package/dist/{chunk-E2XKFV2C.js → chunk-ZLGLVUFD.js} +8 -8
- package/dist/commands/DbSeed.js +5 -4
- package/dist/commands/MigrateDev.js +5 -4
- package/dist/commands/MigrateDiff.js +4 -3
- package/dist/commands/MigrateReset.js +5 -4
- package/dist/index.js +14 -13
- package/dist/internals/src/get-generators/generatorResolvers/prisma-client-js/check-dependencies/checkYarnVersion.d.ts +9 -0
- package/dist/internals/src/utils/isCurrentBinInstalledGlobally.d.ts +1 -1
- package/dist/utils/seed.js +7 -6
- package/package.json +7 -6
package/dist/bin.js
CHANGED
@@ -34,7 +34,7 @@ __export(bin_exports, {
|
|
34
34
|
module.exports = __toCommonJS(bin_exports);
|
35
35
|
var import_chunk_JZ6FKTWG = require("./chunk-JZ6FKTWG.js");
|
36
36
|
var import_chunk_GJN3CSXW = require("./chunk-GJN3CSXW.js");
|
37
|
-
var
|
37
|
+
var import_chunk_XVL5RF2T = require("./chunk-XVL5RF2T.js");
|
38
38
|
var import_chunk_BAVMZZAR = require("./chunk-BAVMZZAR.js");
|
39
39
|
var import_chunk_SV5GANSI = require("./chunk-SV5GANSI.js");
|
40
40
|
var import_chunk_ZBOJAYON = require("./chunk-ZBOJAYON.js");
|
@@ -50,20 +50,21 @@ var import_chunk_QBK5XTJE = require("./chunk-QBK5XTJE.js");
|
|
50
50
|
var import_chunk_INC2OACE = require("./chunk-INC2OACE.js");
|
51
51
|
var import_chunk_GN5BY5N2 = require("./chunk-GN5BY5N2.js");
|
52
52
|
var import_chunk_76XWADEV = require("./chunk-76XWADEV.js");
|
53
|
-
var
|
53
|
+
var import_chunk_ZLGLVUFD = require("./chunk-ZLGLVUFD.js");
|
54
54
|
var import_chunk_CK5VLKFM = require("./chunk-CK5VLKFM.js");
|
55
55
|
var import_chunk_UJWMQPUH = require("./chunk-UJWMQPUH.js");
|
56
|
-
var
|
56
|
+
var import_chunk_LLGEQ76N = require("./chunk-LLGEQ76N.js");
|
57
57
|
var import_chunk_IFCV5MY4 = require("./chunk-IFCV5MY4.js");
|
58
58
|
var import_chunk_SGCF5OHF = require("./chunk-SGCF5OHF.js");
|
59
|
-
var
|
59
|
+
var import_chunk_EFPE3Q7J = require("./chunk-EFPE3Q7J.js");
|
60
60
|
var import_chunk_WOOPRG54 = require("./chunk-WOOPRG54.js");
|
61
61
|
var import_chunk_6QFE3AWR = require("./chunk-6QFE3AWR.js");
|
62
62
|
var import_chunk_LKTTJWFT = require("./chunk-LKTTJWFT.js");
|
63
|
-
var
|
63
|
+
var import_chunk_UY4MANZT = require("./chunk-UY4MANZT.js");
|
64
64
|
var import_chunk_VWV2NY26 = require("./chunk-VWV2NY26.js");
|
65
65
|
var import_chunk_XRTNIFND = require("./chunk-XRTNIFND.js");
|
66
66
|
var import_chunk_TKAGMA5K = require("./chunk-TKAGMA5K.js");
|
67
|
+
var import_chunk_WIZM7TFT = require("./chunk-WIZM7TFT.js");
|
67
68
|
var import_chunk_MWEO3VUS = require("./chunk-MWEO3VUS.js");
|
68
69
|
var import_chunk_6C7ESGWY = require("./chunk-6C7ESGWY.js");
|
69
70
|
var import_chunk_J46BJQHT = require("./chunk-J46BJQHT.js");
|
@@ -89,12 +90,12 @@ var require_bin = (0, import_chunk_WWAWV7DQ.__commonJS)({
|
|
89
90
|
(0, import_chunk_ZBOJAYON.init_DbExecute)();
|
90
91
|
(0, import_chunk_EXUBPCXZ.init_DbPull)();
|
91
92
|
(0, import_chunk_76XWADEV.init_DbPush)();
|
92
|
-
(0,
|
93
|
+
(0, import_chunk_ZLGLVUFD.init_DbSeed)();
|
93
94
|
(0, import_chunk_CK5VLKFM.init_MigrateCommand)();
|
94
95
|
(0, import_chunk_UJWMQPUH.init_MigrateDeploy)();
|
95
|
-
(0,
|
96
|
-
(0,
|
97
|
-
(0,
|
96
|
+
(0, import_chunk_LLGEQ76N.init_MigrateDev)();
|
97
|
+
(0, import_chunk_UY4MANZT.init_MigrateDiff)();
|
98
|
+
(0, import_chunk_XVL5RF2T.init_MigrateReset)();
|
98
99
|
(0, import_chunk_BAVMZZAR.init_MigrateResolve)();
|
99
100
|
(0, import_chunk_SV5GANSI.init_MigrateStatus)();
|
100
101
|
(0, import_chunk_GJN3CSXW.init_getDatabaseVersionSafe)();
|
@@ -112,19 +113,19 @@ var require_bin = (0, import_chunk_WWAWV7DQ.__commonJS)({
|
|
112
113
|
async function main() {
|
113
114
|
const cli = import_chunk_JZ6FKTWG.CLI.new({
|
114
115
|
migrate: import_chunk_CK5VLKFM.MigrateCommand.new({
|
115
|
-
dev:
|
116
|
+
dev: import_chunk_LLGEQ76N.MigrateDev.new(),
|
116
117
|
status: import_chunk_SV5GANSI.MigrateStatus.new(),
|
117
118
|
resolve: import_chunk_BAVMZZAR.MigrateResolve.new(),
|
118
|
-
reset:
|
119
|
+
reset: import_chunk_XVL5RF2T.MigrateReset.new(),
|
119
120
|
deploy: import_chunk_UJWMQPUH.MigrateDeploy.new(),
|
120
|
-
diff:
|
121
|
+
diff: import_chunk_UY4MANZT.MigrateDiff.new()
|
121
122
|
}),
|
122
123
|
db: import_chunk_NJUAN6V2.DbCommand.new({
|
123
124
|
execute: import_chunk_ZBOJAYON.DbExecute.new(),
|
124
125
|
pull: import_chunk_EXUBPCXZ.DbPull.new(),
|
125
126
|
push: import_chunk_76XWADEV.DbPush.new(),
|
126
127
|
// drop: DbDrop.new(),
|
127
|
-
seed:
|
128
|
+
seed: import_chunk_ZLGLVUFD.DbSeed.new()
|
128
129
|
})
|
129
130
|
});
|
130
131
|
const result = await cli.parse(commandArray);
|
@@ -0,0 +1,424 @@
|
|
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
|
+
});
|
@@ -26,15 +26,16 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
|
|
26
26
|
mod
|
27
27
|
));
|
28
28
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
29
|
-
var
|
30
|
-
__export(
|
29
|
+
var chunk_J3KBGWIZ_exports = {};
|
30
|
+
__export(chunk_J3KBGWIZ_exports, {
|
31
31
|
MigrateDiff: () => MigrateDiff,
|
32
32
|
init_MigrateDiff: () => init_MigrateDiff
|
33
33
|
});
|
34
|
-
module.exports = __toCommonJS(
|
34
|
+
module.exports = __toCommonJS(chunk_J3KBGWIZ_exports);
|
35
35
|
var import_chunk_VWV2NY26 = require("./chunk-VWV2NY26.js");
|
36
36
|
var import_chunk_XRTNIFND = require("./chunk-XRTNIFND.js");
|
37
37
|
var import_chunk_TKAGMA5K = require("./chunk-TKAGMA5K.js");
|
38
|
+
var import_chunk_WIZM7TFT = require("./chunk-WIZM7TFT.js");
|
38
39
|
var import_chunk_MWEO3VUS = require("./chunk-MWEO3VUS.js");
|
39
40
|
var import_chunk_LVFPGUOH = require("./chunk-LVFPGUOH.js");
|
40
41
|
var import_chunk_6TE2RIPN = require("./chunk-6TE2RIPN.js");
|
@@ -10838,7 +10839,7 @@ var require_package = (0, import_chunk_WWAWV7DQ.__commonJS)({
|
|
10838
10839
|
"@prisma/fetch-engine": "workspace:*",
|
10839
10840
|
"@prisma/generator-helper": "workspace:*",
|
10840
10841
|
"@prisma/get-platform": "workspace:*",
|
10841
|
-
"@prisma/prisma-schema-wasm": "5.22.0-
|
10842
|
+
"@prisma/prisma-schema-wasm": "5.22.0-27.metrics3-phantasmagoria-of-the-lost-recorder-47785ced2c48f59d114bb0f15b5495cf6c0a7b8e",
|
10842
10843
|
"@prisma/schema-files-loader": "workspace:*",
|
10843
10844
|
arg: "5.0.2",
|
10844
10845
|
prompts: "2.4.2"
|
@@ -11207,9 +11208,14 @@ async function getSchemaWithPathInternal(schemaPathFromArgs, { cwd, argumentName
|
|
11207
11208
|
if (defaultResult.ok) {
|
11208
11209
|
return defaultResult;
|
11209
11210
|
}
|
11211
|
+
const yarnResult = await getSchemaFromYarn1Workspace(cwd, defaultResult.error.failures);
|
11212
|
+
if (yarnResult.ok) {
|
11213
|
+
return yarnResult;
|
11214
|
+
}
|
11215
|
+
const finalError = yarnResult.error.kind === "Yarn1WorkspaceSchemaNotFound" ? defaultResult.error : yarnResult.error;
|
11210
11216
|
return {
|
11211
11217
|
ok: false,
|
11212
|
-
error:
|
11218
|
+
error: finalError
|
11213
11219
|
};
|
11214
11220
|
}
|
11215
11221
|
function renderLookupError(error) {
|
@@ -11284,6 +11290,47 @@ async function getSchemaFromPackageJson(cwd) {
|
|
11284
11290
|
}
|
11285
11291
|
return lookupResult;
|
11286
11292
|
}
|
11293
|
+
async function getSchemaFromYarn1Workspace(cwd, pastFailures) {
|
11294
|
+
if (!process.env.npm_config_user_agent?.includes("yarn")) {
|
11295
|
+
return { ok: false, error: { kind: "Yarn1WorkspaceSchemaNotFound" } };
|
11296
|
+
}
|
11297
|
+
let workspaces;
|
11298
|
+
try {
|
11299
|
+
const { stdout: version2 } = await import_execa.default.command("yarn --version", {
|
11300
|
+
cwd
|
11301
|
+
});
|
11302
|
+
if (version2.startsWith("2")) {
|
11303
|
+
return { ok: false, error: { kind: "Yarn1WorkspaceSchemaNotFound" } };
|
11304
|
+
}
|
11305
|
+
const { stdout } = await import_execa.default.command("yarn workspaces info --json", {
|
11306
|
+
cwd
|
11307
|
+
});
|
11308
|
+
const json = getJson(stdout);
|
11309
|
+
workspaces = Object.values(json);
|
11310
|
+
} catch {
|
11311
|
+
return { ok: false, error: { kind: "Yarn1WorkspaceSchemaNotFound" } };
|
11312
|
+
}
|
11313
|
+
const workspaceRootDir = await findWorkspaceRoot(cwd);
|
11314
|
+
if (!workspaceRootDir) {
|
11315
|
+
return { ok: false, error: { kind: "Yarn1WorkspaceSchemaNotFound" } };
|
11316
|
+
}
|
11317
|
+
for (const workspace of workspaces) {
|
11318
|
+
const workspacePath = import_path5.default.join(workspaceRootDir, workspace.location);
|
11319
|
+
const workspaceSchema = await tryWorkspacePath(workspacePath, pastFailures);
|
11320
|
+
if (workspaceSchema.ok) {
|
11321
|
+
return workspaceSchema;
|
11322
|
+
}
|
11323
|
+
}
|
11324
|
+
const rootPathSchema = await tryWorkspacePath(workspaceRootDir, pastFailures);
|
11325
|
+
return rootPathSchema;
|
11326
|
+
}
|
11327
|
+
async function tryWorkspacePath(cwd, pastFailures) {
|
11328
|
+
const pkgJson = await getSchemaFromPackageJson(cwd);
|
11329
|
+
if (pkgJson.ok) {
|
11330
|
+
return pkgJson;
|
11331
|
+
}
|
11332
|
+
return getDefaultSchema(cwd, pastFailures);
|
11333
|
+
}
|
11287
11334
|
async function getDefaultSchema(cwd, failures = []) {
|
11288
11335
|
const schemaPrisma = {
|
11289
11336
|
schemaPath: {
|
@@ -11348,11 +11395,50 @@ async function loadSchemaFromDefaultLocation(lookupPath) {
|
|
11348
11395
|
return readSchemaFromDirectory(lookupPath.path);
|
11349
11396
|
}
|
11350
11397
|
}
|
11351
|
-
|
11398
|
+
function getJson(stdout) {
|
11399
|
+
const firstCurly = stdout.indexOf("{");
|
11400
|
+
const lastCurly = stdout.lastIndexOf("}");
|
11401
|
+
const sliced = stdout.slice(firstCurly, lastCurly + 1);
|
11402
|
+
return JSON.parse(sliced);
|
11403
|
+
}
|
11404
|
+
function isPkgJsonWorkspaceRoot(pkgJson) {
|
11405
|
+
const workspaces = pkgJson.workspaces;
|
11406
|
+
if (!workspaces) {
|
11407
|
+
return false;
|
11408
|
+
}
|
11409
|
+
return Array.isArray(workspaces) || workspaces.packages !== void 0;
|
11410
|
+
}
|
11411
|
+
async function isNearestPkgJsonWorkspaceRoot(cwd) {
|
11412
|
+
const pkgJson = await readPackageUp({ cwd, normalize: false });
|
11413
|
+
if (!pkgJson) {
|
11414
|
+
return null;
|
11415
|
+
}
|
11416
|
+
return {
|
11417
|
+
isRoot: isPkgJsonWorkspaceRoot(pkgJson.packageJson),
|
11418
|
+
path: pkgJson.path
|
11419
|
+
};
|
11420
|
+
}
|
11421
|
+
async function findWorkspaceRoot(cwd) {
|
11422
|
+
let pkgJson = await isNearestPkgJsonWorkspaceRoot(cwd);
|
11423
|
+
if (!pkgJson) {
|
11424
|
+
return null;
|
11425
|
+
}
|
11426
|
+
if (pkgJson.isRoot === true) {
|
11427
|
+
return import_path5.default.dirname(pkgJson.path);
|
11428
|
+
}
|
11429
|
+
const pkgJsonParentDir = import_path5.default.dirname(import_path5.default.dirname(pkgJson.path));
|
11430
|
+
pkgJson = await isNearestPkgJsonWorkspaceRoot(pkgJsonParentDir);
|
11431
|
+
if (!pkgJson || pkgJson.isRoot === false) {
|
11432
|
+
return null;
|
11433
|
+
}
|
11434
|
+
return import_path5.default.dirname(pkgJson.path);
|
11435
|
+
}
|
11436
|
+
var import_schema_files_loader, import_execa, readFile, stat, debug2;
|
11352
11437
|
var init_getSchema = (0, import_chunk_WWAWV7DQ.__esm)({
|
11353
11438
|
"../internals/src/cli/getSchema.ts"() {
|
11354
11439
|
"use strict";
|
11355
11440
|
import_schema_files_loader = (0, import_chunk_WWAWV7DQ.__toESM)(require_dist());
|
11441
|
+
import_execa = (0, import_chunk_WWAWV7DQ.__toESM)((0, import_chunk_WIZM7TFT.require_execa)());
|
11356
11442
|
(0, import_chunk_6TE2RIPN.init_colors)();
|
11357
11443
|
init_read_package_up();
|
11358
11444
|
init_engine_commands();
|