Erster Docker-Stand

This commit is contained in:
Ali
2026-02-20 16:06:40 +09:00
commit f31e2e8ed3
8818 changed files with 1605323 additions and 0 deletions

View File

@@ -0,0 +1,8 @@
/**
* This regex matches all supported binary target names in a given string.
*
* Platform names are sorted by their lengths in descending order to ensure that
* the longest substring is always matched (e.g., "darwin-arm64" is matched as a
* whole instead of "darwin" and "arm" separately)
*/
export declare const binaryTargetRegex: RegExp;

View File

@@ -0,0 +1,27 @@
"use strict";
var __defProp = Object.defineProperty;
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
var __getOwnPropNames = Object.getOwnPropertyNames;
var __hasOwnProp = Object.prototype.hasOwnProperty;
var __export = (target, all) => {
for (var name in all)
__defProp(target, name, { get: all[name], enumerable: true });
};
var __copyProps = (to, from, except, desc) => {
if (from && typeof from === "object" || typeof from === "function") {
for (let key of __getOwnPropNames(from))
if (!__hasOwnProp.call(to, key) && key !== except)
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
}
return to;
};
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
var binaryTargetRegex_exports = {};
__export(binaryTargetRegex_exports, {
binaryTargetRegex: () => import_chunk_IPLRRT6O.binaryTargetRegex
});
module.exports = __toCommonJS(binaryTargetRegex_exports);
var import_chunk_IPLRRT6O = require("../chunk-IPLRRT6O.js");
var import_chunk_7MLUNQIZ = require("../chunk-7MLUNQIZ.js");
var import_chunk_2ESYSVXG = require("../chunk-2ESYSVXG.js");
(0, import_chunk_IPLRRT6O.init_binaryTargetRegex)();

View File

@@ -0,0 +1 @@
export { type BaseContext, jestConsoleContext, jestContext, jestStdoutContext, type ProcessContextSettings, processExitContext, } from './jestContext';

View File

@@ -0,0 +1,30 @@
"use strict";
var __defProp = Object.defineProperty;
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
var __getOwnPropNames = Object.getOwnPropertyNames;
var __hasOwnProp = Object.prototype.hasOwnProperty;
var __export = (target, all) => {
for (var name in all)
__defProp(target, name, { get: all[name], enumerable: true });
};
var __copyProps = (to, from, except, desc) => {
if (from && typeof from === "object" || typeof from === "function") {
for (let key of __getOwnPropNames(from))
if (!__hasOwnProp.call(to, key) && key !== except)
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
}
return to;
};
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
var test_utils_exports = {};
__export(test_utils_exports, {
jestConsoleContext: () => import_chunk_GGL63BNP.jestConsoleContext,
jestContext: () => import_chunk_GGL63BNP.jestContext,
jestStdoutContext: () => import_chunk_GGL63BNP.jestStdoutContext,
processExitContext: () => import_chunk_GGL63BNP.processExitContext
});
module.exports = __toCommonJS(test_utils_exports);
var import_chunk_6HZWON4S = require("../chunk-6HZWON4S.js");
var import_chunk_GGL63BNP = require("../chunk-GGL63BNP.js");
var import_chunk_3UEKS5W6 = require("../chunk-3UEKS5W6.js");
var import_chunk_2ESYSVXG = require("../chunk-2ESYSVXG.js");

View File

@@ -0,0 +1,122 @@
/// <reference types="jest" />
import { type ExecaChildProcess } from 'execa';
import type { FSJetpack } from 'fs-jetpack/types';
/**
* Base test context.
*/
export type BaseContext = {
tmpDir: string;
fs: FSJetpack;
mocked: {
cwd: string;
};
/**
* Set up the temporary directory based on the contents of some fixture.
*/
fixture: (name: string) => void;
/**
* Spawn the Prisma cli using the temporary directory as the CWD.
*
* @remarks
*
* For this to work the source must be built
*/
cli: (...input: string[]) => ExecaChildProcess<string>;
printDir(dir: string, extensions: string[]): void;
/**
* JavaScript-friendly implementation of the `tree` command. It skips the `node_modules` directory.
* @param itemPath The path to start the tree from, defaults to the root of the temporary directory
* @param indent How much to indent each level of the tree, defaults to ''
* @returns String representation of the directory tree
*/
tree: (itemPath?: string, indent?: string) => void;
};
/**
* Create test context to use in tests. Provides the following:
*
* - A temporary directory
* - an fs-jetpack instance bound to the temporary directory
* - Mocked process.cwd via Node process.chdir
* - Fixture loader for bootstrapping the temporary directory with content
*/
export declare const jestContext: {
new: (ctx?: BaseContext) => {
add<NewContext>(contextContributor: ContextContributor<BaseContext, NewContext>): {
add<NewContext_1>(contextContributor: ContextContributor<BaseContext & NewContext, NewContext_1>): {
add<NewContext_2>(contextContributor: ContextContributor<BaseContext & NewContext & NewContext_1, NewContext_2>): {
add<NewContext_3>(contextContributor: ContextContributor<BaseContext & NewContext & NewContext_1 & NewContext_2, NewContext_3>): {
add<NewContext_4>(contextContributor: ContextContributor<BaseContext & NewContext & NewContext_1 & NewContext_2 & NewContext_3, NewContext_4>): {
add<NewContext_5>(contextContributor: ContextContributor<BaseContext & NewContext & NewContext_1 & NewContext_2 & NewContext_3 & NewContext_4, NewContext_5>): {
add<NewContext_6>(contextContributor: ContextContributor<BaseContext & NewContext & NewContext_1 & NewContext_2 & NewContext_3 & NewContext_4 & NewContext_5, NewContext_6>): {
add<NewContext_7>(contextContributor: ContextContributor<BaseContext & NewContext & NewContext_1 & NewContext_2 & NewContext_3 & NewContext_4 & NewContext_5 & NewContext_6, NewContext_7>): {
add<NewContext_8>(contextContributor: ContextContributor<BaseContext & NewContext & NewContext_1 & NewContext_2 & NewContext_3 & NewContext_4 & NewContext_5 & NewContext_6 & NewContext_7, NewContext_8>): {
add<NewContext_9>(contextContributor: ContextContributor<BaseContext & NewContext & NewContext_1 & NewContext_2 & NewContext_3 & NewContext_4 & NewContext_5 & NewContext_6 & NewContext_7 & NewContext_8, NewContext_9>): {
add<NewContext_10>(contextContributor: ContextContributor<BaseContext & NewContext & NewContext_1 & NewContext_2 & NewContext_3 & NewContext_4 & NewContext_5 & NewContext_6 & NewContext_7 & NewContext_8 & NewContext_9, NewContext_10>): any;
assemble(): BaseContext & NewContext & NewContext_1 & NewContext_2 & NewContext_3 & NewContext_4 & NewContext_5 & NewContext_6 & NewContext_7 & NewContext_8 & NewContext_9;
};
assemble(): BaseContext & NewContext & NewContext_1 & NewContext_2 & NewContext_3 & NewContext_4 & NewContext_5 & NewContext_6 & NewContext_7 & NewContext_8;
};
assemble(): BaseContext & NewContext & NewContext_1 & NewContext_2 & NewContext_3 & NewContext_4 & NewContext_5 & NewContext_6 & NewContext_7;
};
assemble(): BaseContext & NewContext & NewContext_1 & NewContext_2 & NewContext_3 & NewContext_4 & NewContext_5 & NewContext_6;
};
assemble(): BaseContext & NewContext & NewContext_1 & NewContext_2 & NewContext_3 & NewContext_4 & NewContext_5;
};
assemble(): BaseContext & NewContext & NewContext_1 & NewContext_2 & NewContext_3 & NewContext_4;
};
assemble(): BaseContext & NewContext & NewContext_1 & NewContext_2 & NewContext_3;
};
assemble(): BaseContext & NewContext & NewContext_1 & NewContext_2;
};
assemble(): BaseContext & NewContext & NewContext_1;
};
assemble(): BaseContext & NewContext;
};
assemble(): BaseContext;
};
};
/**
* A function that provides additional test context.
*/
type ContextContributor<Context, NewContext> = (ctx: Context) => Context & NewContext;
/**
* Test context contributor. Mocks console.error with a Jest spy before each test.
*/
type ConsoleContext = {
mocked: {
'console.error': jest.SpyInstance;
'console.log': jest.SpyInstance;
'console.info': jest.SpyInstance;
'console.warn': jest.SpyInstance;
};
};
export declare const jestConsoleContext: <Ctx extends BaseContext>() => (c: Ctx) => Ctx & ConsoleContext;
/**
* Test context contributor. Mocks process.std(out|err).write with a Jest spy before each test.
*/
type ProcessContext = {
mocked: {
'process.stderr.write': jest.SpyInstance;
'process.stdout.write': jest.SpyInstance;
};
normalizedCapturedStdout: () => string;
normalizedCapturedStderr: () => string;
clearCapturedStdout: () => void;
clearCapturedStderr: () => void;
};
type NormalizationRule = [RegExp | string, string];
export type ProcessContextSettings = {
normalizationRules: NormalizationRule[];
};
export declare const jestStdoutContext: <Ctx extends BaseContext>({ normalizationRules }?: ProcessContextSettings) => (c: Ctx) => Ctx & ProcessContext;
/**
* Test context contributor. Mocks process.exit with a spay and records the exit code.
*/
type ProcessExitContext = {
mocked: {
'process.exit': jest.SpyInstance;
};
recordedExitCode: () => number;
};
export declare const processExitContext: <C extends BaseContext>() => (c: C) => C & ProcessExitContext;
export {};

View File

@@ -0,0 +1,29 @@
"use strict";
var __defProp = Object.defineProperty;
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
var __getOwnPropNames = Object.getOwnPropertyNames;
var __hasOwnProp = Object.prototype.hasOwnProperty;
var __export = (target, all) => {
for (var name in all)
__defProp(target, name, { get: all[name], enumerable: true });
};
var __copyProps = (to, from, except, desc) => {
if (from && typeof from === "object" || typeof from === "function") {
for (let key of __getOwnPropNames(from))
if (!__hasOwnProp.call(to, key) && key !== except)
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
}
return to;
};
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
var jestContext_exports = {};
__export(jestContext_exports, {
jestConsoleContext: () => import_chunk_GGL63BNP.jestConsoleContext,
jestContext: () => import_chunk_GGL63BNP.jestContext,
jestStdoutContext: () => import_chunk_GGL63BNP.jestStdoutContext,
processExitContext: () => import_chunk_GGL63BNP.processExitContext
});
module.exports = __toCommonJS(jestContext_exports);
var import_chunk_GGL63BNP = require("../chunk-GGL63BNP.js");
var import_chunk_3UEKS5W6 = require("../chunk-3UEKS5W6.js");
var import_chunk_2ESYSVXG = require("../chunk-2ESYSVXG.js");

View File

@@ -0,0 +1,151 @@
"use strict";
var __defProp = Object.defineProperty;
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
var __getOwnPropNames = Object.getOwnPropertyNames;
var __hasOwnProp = Object.prototype.hasOwnProperty;
var __export = (target, all) => {
for (var name in all)
__defProp(target, name, { get: all[name], enumerable: true });
};
var __copyProps = (to, from, except, desc) => {
if (from && typeof from === "object" || typeof from === "function") {
for (let key of __getOwnPropNames(from))
if (!__hasOwnProp.call(to, key) && key !== except)
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
}
return to;
};
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
var jestSnapshotSerializer_exports = {};
__export(jestSnapshotSerializer_exports, {
default: () => jestSnapshotSerializer_default
});
module.exports = __toCommonJS(jestSnapshotSerializer_exports);
var import_chunk_IPLRRT6O = require("../chunk-IPLRRT6O.js");
var import_chunk_7MLUNQIZ = require("../chunk-7MLUNQIZ.js");
var import_chunk_2ESYSVXG = require("../chunk-2ESYSVXG.js");
var require_jestSnapshotSerializer = (0, import_chunk_2ESYSVXG.__commonJS)({
"src/test-utils/jestSnapshotSerializer.js"(exports, module2) {
var path = (0, import_chunk_2ESYSVXG.__require)("node:path");
var { stripVTControlCharacters } = (0, import_chunk_2ESYSVXG.__require)("node:util");
var { binaryTargetRegex } = ((0, import_chunk_IPLRRT6O.init_binaryTargetRegex)(), (0, import_chunk_2ESYSVXG.__toCommonJS)(import_chunk_IPLRRT6O.binaryTargetRegex_exports));
var pipe = (...fns) => (x) => fns.reduce((v, f) => f(v), x);
function normalizePrismaPaths(str) {
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");
}
function normalizeLogs(str) {
return str.replace(
/Started query engine http server on http:\/\/127\.0\.0\.1:\d{1,5}/g,
"Started query engine http server on http://127.0.0.1:00000"
).replace(/Starting a postgresql pool with \d+ connections./g, "Starting a postgresql pool with XX connections.");
}
function normalizeTmpDir(str) {
const tempDirRegexes = [
// Linux
/\/tmp\/([a-z0-9]+)/g,
// macOS
/\/private\/var\/folders\/[^/]+\/[^/]+\/T\/[a-z0-9]+/g
];
if (process.env.TEMP) {
const escapedPath = process.env.TEMP.replaceAll("\\", "\\\\");
tempDirRegexes.push(new RegExp(`${escapedPath}\\\\[a-z0-9]+`, "g"));
}
for (const regex of tempDirRegexes) {
str = str.replace(regex, "/tmp/dir");
}
return str;
}
function trimErrorPaths(str) {
const parentDir = path.dirname(path.dirname(path.dirname(__dirname)));
return str.replaceAll(parentDir, "");
}
function normalizeToUnixPaths(str) {
return str.replaceAll(path.sep, "/");
}
function normalizeGitHubLinks(str) {
return str.replace(/https:\/\/github.com\/prisma\/prisma(-client-js)?\/issues\/new\S+/, "TEST_GITHUB_LINK");
}
function normalizeTsClientStackTrace(str) {
return str.replace(/([/\\]client[/\\]src[/\\]__tests__[/\\].*test\.ts)(:\d*:\d*)/, "$1:0:0").replace(/([/\\]client[/\\]tests[/\\]functional[/\\].*\.ts)(:\d*:\d*)/, "$1:0:0");
}
function removePlatforms(str) {
return str.replace(binaryTargetRegex, "TEST_PLATFORM");
}
function normalizeBinaryFilePath(str) {
return str.replace(/\.exe(\s+)?(\W.*)/g, "$1$2").replace(/\.exe$/g, "");
}
function normalizeMigrateTimestamps(str) {
return str.replace(/(?<!\d)\d{14}(?!\d)/g, "20201231000000");
}
function normalizeDbUrl(str) {
return str.replace(/(localhost|postgres|mysql|mssql|mongodb_migrate|cockroachdb):(\d+)/g, "localhost:$2");
}
function normalizeRustError(str) {
return str.replace(/\/rustc\/(.+)\//g, "/rustc/hash/").replace(/(\[.*)(:\d*:\d*)(\])/g, "[/some/rust/path:0:0$3");
}
function normalizeRustCodeLocation(str) {
return str.replace(/(\w+\.rs):(\d+):(\d+)/g, "$1:0:0");
}
function normalizeArtificialPanic(str) {
return str.replace(/(Command failed with exit code 101:) (.+) /g, "$1 prisma-engines-path ");
}
function normalizeTime(str) {
return str.replace(/ \d+ms/g, " XXXms").replace(/ \d+(\.\d+)?s/g, " XXXms");
}
function prepareSchemaForSnapshot(str) {
if (!str.includes("tmp/prisma-tests/integration-test")) return str;
const urlRegex = /url\s*=\s*.+/;
const outputRegex = /output\s*=\s*.+/;
return str.split("\n").map((line) => {
const urlMatch = urlRegex.exec(line);
if (urlMatch) {
return `${line.slice(0, urlMatch.index)}url = "***"`;
}
const outputMatch = outputRegex.exec(line);
if (outputMatch) {
return `${line.slice(0, outputMatch.index)}output = "***"`;
}
return line;
}).join("\n");
}
function wrapWithQuotes(str) {
return `"${str}"`;
}
module2.exports = {
// Expected by Jest
test(value) {
return typeof value === "string" || value instanceof Error;
},
serialize(value) {
const message = typeof value === "string" ? value : value instanceof Error ? value.message : "";
return pipe(
stripVTControlCharacters,
// integration-tests pkg
prepareSchemaForSnapshot,
// Generic
normalizeTmpDir,
normalizeTime,
// From Client package
normalizeGitHubLinks,
removePlatforms,
normalizeBinaryFilePath,
normalizeTsClientStackTrace,
trimErrorPaths,
normalizePrismaPaths,
normalizeLogs,
// remove windows \\
normalizeToUnixPaths,
// From Migrate/CLI package
normalizeDbUrl,
normalizeRustError,
normalizeRustCodeLocation,
normalizeMigrateTimestamps,
// artificial panic
normalizeArtificialPanic,
wrapWithQuotes
)(message);
}
};
}
});
var jestSnapshotSerializer_default = require_jestSnapshotSerializer();

View File

@@ -0,0 +1,123 @@
import { type ExecaChildProcess } from 'execa';
import type { FSJetpack } from 'fs-jetpack/types';
import { type MockInstance } from 'vitest';
/**
* Base test context.
*/
export type BaseContext = {
tmpDir: string;
fs: FSJetpack;
mocked: {
cwd: string;
};
/**
* Set up the temporary directory based on the contents of some fixture.
*/
fixture: (name: string) => void;
/**
* Spawn the Prisma cli using the temporary directory as the CWD.
*
* @remarks
*
* For this to work the source must be built
*/
cli: (...input: string[]) => ExecaChildProcess<string>;
printDir(dir: string, extensions: string[]): void;
/**
* JavaScript-friendly implementation of the `tree` command. It skips the `node_modules` directory.
* @param itemPath The path to start the tree from, defaults to the root of the temporary directory
* @param indent How much to indent each level of the tree, defaults to ''
* @returns String representation of the directory tree
*/
tree: (itemPath?: string, indent?: string) => void;
};
/**
* Create test context to use in tests. Provides the following:
*
* - A temporary directory
* - an fs-jetpack instance bound to the temporary directory
* - Mocked process.cwd via Node process.chdir
* - Fixture loader for bootstrapping the temporary directory with content
*/
export declare const vitestContext: {
new: (ctx?: BaseContext) => {
add<NewContext>(contextContributor: ContextContributor<BaseContext, NewContext>): {
add<NewContext_1>(contextContributor: ContextContributor<BaseContext & NewContext, NewContext_1>): {
add<NewContext_2>(contextContributor: ContextContributor<BaseContext & NewContext & NewContext_1, NewContext_2>): {
add<NewContext_3>(contextContributor: ContextContributor<BaseContext & NewContext & NewContext_1 & NewContext_2, NewContext_3>): {
add<NewContext_4>(contextContributor: ContextContributor<BaseContext & NewContext & NewContext_1 & NewContext_2 & NewContext_3, NewContext_4>): {
add<NewContext_5>(contextContributor: ContextContributor<BaseContext & NewContext & NewContext_1 & NewContext_2 & NewContext_3 & NewContext_4, NewContext_5>): {
add<NewContext_6>(contextContributor: ContextContributor<BaseContext & NewContext & NewContext_1 & NewContext_2 & NewContext_3 & NewContext_4 & NewContext_5, NewContext_6>): {
add<NewContext_7>(contextContributor: ContextContributor<BaseContext & NewContext & NewContext_1 & NewContext_2 & NewContext_3 & NewContext_4 & NewContext_5 & NewContext_6, NewContext_7>): {
add<NewContext_8>(contextContributor: ContextContributor<BaseContext & NewContext & NewContext_1 & NewContext_2 & NewContext_3 & NewContext_4 & NewContext_5 & NewContext_6 & NewContext_7, NewContext_8>): {
add<NewContext_9>(contextContributor: ContextContributor<BaseContext & NewContext & NewContext_1 & NewContext_2 & NewContext_3 & NewContext_4 & NewContext_5 & NewContext_6 & NewContext_7 & NewContext_8, NewContext_9>): {
add<NewContext_10>(contextContributor: ContextContributor<BaseContext & NewContext & NewContext_1 & NewContext_2 & NewContext_3 & NewContext_4 & NewContext_5 & NewContext_6 & NewContext_7 & NewContext_8 & NewContext_9, NewContext_10>): any;
assemble(): BaseContext & NewContext & NewContext_1 & NewContext_2 & NewContext_3 & NewContext_4 & NewContext_5 & NewContext_6 & NewContext_7 & NewContext_8 & NewContext_9;
};
assemble(): BaseContext & NewContext & NewContext_1 & NewContext_2 & NewContext_3 & NewContext_4 & NewContext_5 & NewContext_6 & NewContext_7 & NewContext_8;
};
assemble(): BaseContext & NewContext & NewContext_1 & NewContext_2 & NewContext_3 & NewContext_4 & NewContext_5 & NewContext_6 & NewContext_7;
};
assemble(): BaseContext & NewContext & NewContext_1 & NewContext_2 & NewContext_3 & NewContext_4 & NewContext_5 & NewContext_6;
};
assemble(): BaseContext & NewContext & NewContext_1 & NewContext_2 & NewContext_3 & NewContext_4 & NewContext_5;
};
assemble(): BaseContext & NewContext & NewContext_1 & NewContext_2 & NewContext_3 & NewContext_4;
};
assemble(): BaseContext & NewContext & NewContext_1 & NewContext_2 & NewContext_3;
};
assemble(): BaseContext & NewContext & NewContext_1 & NewContext_2;
};
assemble(): BaseContext & NewContext & NewContext_1;
};
assemble(): BaseContext & NewContext;
};
assemble(): BaseContext;
};
};
/**
* A function that provides additional test context.
*/
type ContextContributor<Context, NewContext> = (ctx: Context) => Context & NewContext;
/**
* Test context contributor. Mocks console.error with a Vitest spy before each test.
*/
type ConsoleContext = {
mocked: {
'console.error': MockInstance<typeof console.error>;
'console.log': MockInstance<typeof console.log>;
'console.info': MockInstance<typeof console.info>;
'console.warn': MockInstance<typeof console.warn>;
};
};
export declare const vitestConsoleContext: <Ctx extends BaseContext>() => (c: Ctx) => Ctx & ConsoleContext;
/**
* Test context contributor. Mocks process.std(out|err).write with a Vitest spy before each test.
*/
type ProcessContext = {
mocked: {
'process.stderr.write': MockInstance<typeof process.stderr.write>;
'process.stdout.write': MockInstance<typeof process.stdout.write>;
};
normalizedCapturedStdout: () => string;
normalizedCapturedStderr: () => string;
clearCapturedStdout: () => void;
clearCapturedStderr: () => void;
};
type NormalizationRule = [RegExp | string, string];
export type ProcessContextSettings = {
normalizationRules: NormalizationRule[];
};
export declare const vitestStdoutContext: <Ctx extends BaseContext>({ normalizationRules }?: ProcessContextSettings) => (c: Ctx) => Ctx & ProcessContext;
/**
* Test context contributor. Mocks process.exit with a spy and records the exit code.
*/
type ProcessExitContext = {
mocked: {
'process.exit': MockInstance<typeof process.exit>;
};
recordedExitCode: () => number;
};
export declare const vitestProcessExitContext: <C extends BaseContext>() => (c: C) => C & ProcessExitContext;
export declare const processExitContext: <C extends BaseContext>() => (c: C) => C & ProcessExitContext;
export {};

File diff suppressed because it is too large Load Diff