@prisma/migrate 5.22.0-integration-remove-custom-yarn-logic.1 → 5.22.0-integration-engines-5-22-0-8-integration-itx-refactor-9bb49c906d23e0946061d551777bdac14ae4d17d.1

Sign up to get free protection for your applications and to get access to all the features.
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 import_chunk_75AMGQ4R = require("./chunk-75AMGQ4R.js");
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 import_chunk_E2XKFV2C = require("./chunk-E2XKFV2C.js");
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 import_chunk_O6RO4YUZ = require("./chunk-O6RO4YUZ.js");
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 import_chunk_YKUZUAXA = require("./chunk-YKUZUAXA.js");
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 import_chunk_4D5LNZLQ = require("./chunk-4D5LNZLQ.js");
63
+ var import_chunk_6CI434AY = require("./chunk-6CI434AY.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, import_chunk_E2XKFV2C.init_DbSeed)();
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, import_chunk_O6RO4YUZ.init_MigrateDev)();
96
- (0, import_chunk_4D5LNZLQ.init_MigrateDiff)();
97
- (0, import_chunk_75AMGQ4R.init_MigrateReset)();
96
+ (0, import_chunk_LLGEQ76N.init_MigrateDev)();
97
+ (0, import_chunk_6CI434AY.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: import_chunk_O6RO4YUZ.MigrateDev.new(),
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: import_chunk_75AMGQ4R.MigrateReset.new(),
119
+ reset: import_chunk_XVL5RF2T.MigrateReset.new(),
119
120
  deploy: import_chunk_UJWMQPUH.MigrateDeploy.new(),
120
- diff: import_chunk_4D5LNZLQ.MigrateDiff.new()
121
+ diff: import_chunk_6CI434AY.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: import_chunk_E2XKFV2C.DbSeed.new()
128
+ seed: import_chunk_ZLGLVUFD.DbSeed.new()
128
129
  })
129
130
  });
130
131
  const result = await cli.parse(commandArray);
@@ -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 chunk_4D5LNZLQ_exports = {};
30
- __export(chunk_4D5LNZLQ_exports, {
29
+ var chunk_6CI434AY_exports = {};
30
+ __export(chunk_6CI434AY_exports, {
31
31
  MigrateDiff: () => MigrateDiff,
32
32
  init_MigrateDiff: () => init_MigrateDiff
33
33
  });
34
- module.exports = __toCommonJS(chunk_4D5LNZLQ_exports);
34
+ module.exports = __toCommonJS(chunk_6CI434AY_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");
@@ -10753,7 +10754,7 @@ var require_package = (0, import_chunk_WWAWV7DQ.__commonJS)({
10753
10754
  "../internals/package.json"(exports, module2) {
10754
10755
  module2.exports = {
10755
10756
  name: "@prisma/internals",
10756
- version: "5.22.0-integration-remove-custom-yarn-logic.1",
10757
+ version: "5.22.0-integration-engines-5-22-0-8-integration-itx-refactor-9bb49c906d23e0946061d551777bdac14ae4d17d.1",
10757
10758
  description: "This package is intended for Prisma's internal use",
10758
10759
  main: "dist/index.js",
10759
10760
  types: "dist/index.d.ts",
@@ -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-7.155af6224b4a7a7fe47f2ce6202a785fbc5e1750",
10842
+ "@prisma/prisma-schema-wasm": "5.22.0-8.integration-itx-refactor-9bb49c906d23e0946061d551777bdac14ae4d17d",
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: defaultResult.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
- var import_schema_files_loader, readFile, stat, debug2;
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();
@@ -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 chunk_F5EZH7R5_exports = {};
30
- __export(chunk_F5EZH7R5_exports, {
29
+ var chunk_DPSX7IAE_exports = {};
30
+ __export(chunk_DPSX7IAE_exports, {
31
31
  MigrateDiff: () => MigrateDiff,
32
32
  init_MigrateDiff: () => init_MigrateDiff
33
33
  });
34
- module.exports = __toCommonJS(chunk_F5EZH7R5_exports);
34
+ module.exports = __toCommonJS(chunk_DPSX7IAE_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-7.155af6224b4a7a7fe47f2ce6202a785fbc5e1750",
10842
+ "@prisma/prisma-schema-wasm": "5.22.0-8.integration-itx-refactor-9bb49c906d23e0946061d551777bdac14ae4d17d",
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: defaultResult.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
- var import_schema_files_loader, readFile, stat, debug2;
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();