@prisma/get-platform 7.5.0-dev.5 → 7.5.0-dev.50

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.
@@ -16,13 +16,13 @@ var __copyProps = (to, from, except, desc) => {
16
16
  return to;
17
17
  };
18
18
  var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
- var magic_string_es_3WRPFX2A_exports = {};
20
- __export(magic_string_es_3WRPFX2A_exports, {
19
+ var magic_string_es_SDTMJBWP_exports = {};
20
+ __export(magic_string_es_SDTMJBWP_exports, {
21
21
  Bundle: () => Bundle,
22
22
  SourceMap: () => SourceMap,
23
23
  default: () => MagicString
24
24
  });
25
- module.exports = __toCommonJS(magic_string_es_3WRPFX2A_exports);
25
+ module.exports = __toCommonJS(magic_string_es_SDTMJBWP_exports);
26
26
  var import_chunk_2ESYSVXG = require("./chunk-2ESYSVXG.js");
27
27
  var comma = ",".charCodeAt(0);
28
28
  var semicolon = ";".charCodeAt(0);
@@ -40,8 +40,7 @@ function encodeInteger(builder, num, relative) {
40
40
  do {
41
41
  let clamped = delta & 31;
42
42
  delta >>>= 5;
43
- if (delta > 0)
44
- clamped |= 32;
43
+ if (delta > 0) clamped |= 32;
45
44
  builder.write(intToChar[clamped]);
46
45
  } while (delta > 0);
47
46
  return num;
@@ -88,23 +87,18 @@ function encode(decoded) {
88
87
  let namesIndex = 0;
89
88
  for (let i = 0; i < decoded.length; i++) {
90
89
  const line = decoded[i];
91
- if (i > 0)
92
- writer.write(semicolon);
93
- if (line.length === 0)
94
- continue;
90
+ if (i > 0) writer.write(semicolon);
91
+ if (line.length === 0) continue;
95
92
  let genColumn = 0;
96
93
  for (let j = 0; j < line.length; j++) {
97
94
  const segment = line[j];
98
- if (j > 0)
99
- writer.write(comma);
95
+ if (j > 0) writer.write(comma);
100
96
  genColumn = encodeInteger(writer, segment[0], genColumn);
101
- if (segment.length === 1)
102
- continue;
97
+ if (segment.length === 1) continue;
103
98
  sourcesIndex = encodeInteger(writer, segment[1], sourcesIndex);
104
99
  sourceLine = encodeInteger(writer, segment[2], sourceLine);
105
100
  sourceColumn = encodeInteger(writer, segment[3], sourceColumn);
106
- if (segment.length === 4)
107
- continue;
101
+ if (segment.length === 4) continue;
108
102
  namesIndex = encodeInteger(writer, segment[4], namesIndex);
109
103
  }
110
104
  }
@@ -546,6 +540,9 @@ var MagicString = class _MagicString {
546
540
  }
547
541
  if (chunk.outro.length) mappings.advance(chunk.outro);
548
542
  });
543
+ if (this.outro) {
544
+ mappings.advance(this.outro);
545
+ }
549
546
  return {
550
547
  file: options.file ? options.file.split(/[/\\]/).pop() : void 0,
551
548
  sources: [
@@ -903,10 +900,13 @@ var MagicString = class _MagicString {
903
900
  _split(index) {
904
901
  if (this.byStart[index] || this.byEnd[index]) return;
905
902
  let chunk = this.lastSearchedChunk;
903
+ let previousChunk = chunk;
906
904
  const searchForward = index > chunk.end;
907
905
  while (chunk) {
908
906
  if (chunk.contains(index)) return this._splitChunk(chunk, index);
909
907
  chunk = searchForward ? this.byStart[chunk.end] : this.byEnd[chunk.start];
908
+ if (chunk === previousChunk) return;
909
+ previousChunk = chunk;
910
910
  }
911
911
  }
912
912
  _splitChunk(chunk, index) {
@@ -1053,7 +1053,12 @@ var MagicString = class _MagicString {
1053
1053
  const { original } = this;
1054
1054
  const index = original.indexOf(string);
1055
1055
  if (index !== -1) {
1056
- this.overwrite(index, index + string.length, replacement);
1056
+ if (typeof replacement === "function") {
1057
+ replacement = replacement(string, index, original);
1058
+ }
1059
+ if (string !== replacement) {
1060
+ this.overwrite(index, index + string.length, replacement);
1061
+ }
1057
1062
  }
1058
1063
  return this;
1059
1064
  }
@@ -1068,7 +1073,11 @@ var MagicString = class _MagicString {
1068
1073
  const stringLength = string.length;
1069
1074
  for (let index = original.indexOf(string); index !== -1; index = original.indexOf(string, index + stringLength)) {
1070
1075
  const previous = original.slice(index, index + stringLength);
1071
- if (previous !== replacement) this.overwrite(index, index + stringLength, replacement);
1076
+ let _replacement = replacement;
1077
+ if (typeof replacement === "function") {
1078
+ _replacement = replacement(previous, index, original);
1079
+ }
1080
+ if (previous !== _replacement) this.overwrite(index, index + stringLength, _replacement);
1072
1081
  }
1073
1082
  return this;
1074
1083
  }
@@ -0,0 +1 @@
1
+ export declare function serialize(value: any): any;
@@ -0,0 +1,150 @@
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 vitest_snapshot_serializer_exports = {};
30
+ __export(vitest_snapshot_serializer_exports, {
31
+ serialize: () => serialize
32
+ });
33
+ module.exports = __toCommonJS(vitest_snapshot_serializer_exports);
34
+ var import_chunk_IPLRRT6O = require("../chunk-IPLRRT6O.js");
35
+ var import_chunk_7MLUNQIZ = require("../chunk-7MLUNQIZ.js");
36
+ var import_chunk_2ESYSVXG = require("../chunk-2ESYSVXG.js");
37
+ var import_node_path = __toESM(require("node:path"));
38
+ var import_node_util = require("node:util");
39
+ (0, import_chunk_IPLRRT6O.init_binaryTargetRegex)();
40
+ var pipe = (...fns) => (x) => fns.reduce((v, f) => f(v), x);
41
+ function normalizePrismaPaths(str) {
42
+ return str.replace(/prisma\\([\w-]+)\.prisma/g, "prisma/$1.prisma").replace(/prisma\\seed\.ts/g, "prisma/seed.ts").replace(/custom-folder\\seed\.js/g, "custom-folder/seed.js");
43
+ }
44
+ function normalizeLogs(str) {
45
+ return str.replace(
46
+ /Started query engine http server on http:\/\/127\.0\.0\.1:\d{1,5}/g,
47
+ "Started query engine http server on http://127.0.0.1:00000"
48
+ ).replace(/Starting a postgresql pool with \d+ connections./g, "Starting a postgresql pool with XX connections.");
49
+ }
50
+ function normalizeTmpDir(str) {
51
+ const tempDirRegexes = [
52
+ // Linux
53
+ /\/tmp\/([a-z0-9]+)/g,
54
+ // macOS
55
+ /\/private\/var\/folders\/[^/]+\/[^/]+\/T\/[a-z0-9]+/g
56
+ ];
57
+ if (process.env.TEMP) {
58
+ const escapedPath = process.env.TEMP.replaceAll("\\", "\\\\");
59
+ tempDirRegexes.push(new RegExp(`${escapedPath}\\\\[a-z0-9]+`, "g"));
60
+ }
61
+ for (const regex of tempDirRegexes) {
62
+ str = str.replace(regex, "/tmp/dir");
63
+ }
64
+ return str;
65
+ }
66
+ function trimErrorPaths(str) {
67
+ const parentDir = import_node_path.default.dirname(import_node_path.default.dirname(import_node_path.default.dirname(__dirname)));
68
+ return str.replaceAll(parentDir, "");
69
+ }
70
+ function normalizeToUnixPaths(str) {
71
+ return str.replaceAll(import_node_path.default.sep, "/");
72
+ }
73
+ function normalizeGitHubLinks(str) {
74
+ return str.replace(/https:\/\/github.com\/prisma\/prisma(-client-js)?\/issues\/new\S+/, "TEST_GITHUB_LINK");
75
+ }
76
+ function normalizeTsClientStackTrace(str) {
77
+ return str.replace(/([/\\]client[/\\]src[/\\]__tests__[/\\].*test\.ts)(:\d*:\d*)/, "$1:0:0").replace(/([/\\]client[/\\]tests[/\\]functional[/\\].*\.ts)(:\d*:\d*)/, "$1:0:0");
78
+ }
79
+ function removePlatforms(str) {
80
+ return str.replace(import_chunk_IPLRRT6O.binaryTargetRegex, "TEST_PLATFORM");
81
+ }
82
+ function normalizeBinaryFilePath(str) {
83
+ return str.replace(/\.exe(\s+)?(\W.*)/g, "$1$2").replace(/\.exe$/g, "");
84
+ }
85
+ function normalizeMigrateTimestamps(str) {
86
+ return str.replace(/(?<!\d)\d{14}(?!\d)/g, "20201231000000");
87
+ }
88
+ function normalizeDbUrl(str) {
89
+ return str.replace(/(localhost|postgres|mysql|mssql|mongodb_migrate|cockroachdb):(\d+)/g, "localhost:$2");
90
+ }
91
+ function normalizeRustError(str) {
92
+ return str.replace(/\/rustc\/(.+)\//g, "/rustc/hash/").replace(/(\[.*)(:\d*:\d*)(\])/g, "[/some/rust/path:0:0$3");
93
+ }
94
+ function normalizeRustCodeLocation(str) {
95
+ return str.replace(/(\w+\.rs):(\d+):(\d+)/g, "$1:0:0");
96
+ }
97
+ function normalizeArtificialPanic(str) {
98
+ return str.replace(/(Command failed with exit code 101:) (.+) /g, "$1 prisma-engines-path ");
99
+ }
100
+ function normalizeTime(str) {
101
+ return str.replace(/ \d+ms/g, " XXXms").replace(/ \d+(\.\d+)?s/g, " XXXms");
102
+ }
103
+ function prepareSchemaForSnapshot(str) {
104
+ if (!str.includes("tmp/prisma-tests/integration-test")) return str;
105
+ const urlRegex = /url\s*=\s*.+/;
106
+ const outputRegex = /output\s*=\s*.+/;
107
+ return str.split("\n").map((line) => {
108
+ const urlMatch = urlRegex.exec(line);
109
+ if (urlMatch) {
110
+ return `${line.slice(0, urlMatch.index)}url = "***"`;
111
+ }
112
+ const outputMatch = outputRegex.exec(line);
113
+ if (outputMatch) {
114
+ return `${line.slice(0, outputMatch.index)}output = "***"`;
115
+ }
116
+ return line;
117
+ }).join("\n");
118
+ }
119
+ function wrapWithQuotes(str) {
120
+ return `"${str}"`;
121
+ }
122
+ function serialize(value) {
123
+ const message = typeof value === "string" ? value : value instanceof Error ? value.message : "";
124
+ return pipe(
125
+ import_node_util.stripVTControlCharacters,
126
+ // integration-tests pkg
127
+ prepareSchemaForSnapshot,
128
+ // Generic
129
+ normalizeTmpDir,
130
+ normalizeTime,
131
+ // From Client package
132
+ normalizeGitHubLinks,
133
+ removePlatforms,
134
+ normalizeBinaryFilePath,
135
+ normalizeTsClientStackTrace,
136
+ trimErrorPaths,
137
+ normalizePrismaPaths,
138
+ normalizeLogs,
139
+ // remove windows \\
140
+ normalizeToUnixPaths,
141
+ // From Migrate/CLI package
142
+ normalizeDbUrl,
143
+ normalizeRustError,
144
+ normalizeRustCodeLocation,
145
+ normalizeMigrateTimestamps,
146
+ // artificial panic
147
+ normalizeArtificialPanic,
148
+ wrapWithQuotes
149
+ )(message);
150
+ }