@prisma/compute-sdk 0.24.0 → 0.25.0
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.
- package/dist/apply-migrations.d.ts +61 -0
- package/dist/apply-migrations.d.ts.map +1 -0
- package/dist/apply-migrations.js +314 -0
- package/dist/apply-migrations.js.map +1 -0
- package/dist/detect-schema.d.ts +31 -0
- package/dist/detect-schema.d.ts.map +1 -0
- package/dist/detect-schema.js +212 -0
- package/dist/detect-schema.js.map +1 -0
- package/dist/index.d.ts +4 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +2 -0
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
- package/src/apply-migrations.ts +454 -0
- package/src/detect-schema.ts +384 -0
- package/src/index.ts +14 -0
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
import type { DetectedSchema, MigrationCommand } from "./detect-schema.ts";
|
|
2
|
+
export interface ApplyMigrationsOptions {
|
|
3
|
+
/** Application root the build runs in; also the CLI working directory. */
|
|
4
|
+
appPath: string;
|
|
5
|
+
/** Connection used for migrations: the direct/admin database URL. */
|
|
6
|
+
databaseUrl: string;
|
|
7
|
+
/** Auto-detected from `appPath` when omitted. */
|
|
8
|
+
schema?: DetectedSchema;
|
|
9
|
+
/** Extra environment for the CLI child, e.g. a user-set `DIRECT_URL`. */
|
|
10
|
+
env?: Record<string, string>;
|
|
11
|
+
signal?: AbortSignal;
|
|
12
|
+
onLog?: (line: string, stream: "stdout" | "stderr") => void;
|
|
13
|
+
}
|
|
14
|
+
export type ApplyMigrationsResult = {
|
|
15
|
+
applied: true;
|
|
16
|
+
via: MigrationCommand;
|
|
17
|
+
} | {
|
|
18
|
+
applied: false;
|
|
19
|
+
reason: "no-schema";
|
|
20
|
+
};
|
|
21
|
+
/**
|
|
22
|
+
* Last resort for repos that ship a schema with no prisma installed at all.
|
|
23
|
+
* Pinned to the 6.x line: Prisma 7 rejects the classic `url = env(...)`
|
|
24
|
+
* datasource form (P1012), which is exactly the schema shape such repos have.
|
|
25
|
+
* Bump deliberately, never to `latest`.
|
|
26
|
+
*/
|
|
27
|
+
export declare const FALLBACK_PRISMA_CLI_VERSION = "6.19.3";
|
|
28
|
+
export interface CliLauncher {
|
|
29
|
+
command: string;
|
|
30
|
+
argsPrefix: string[];
|
|
31
|
+
/** Human-readable command prefix used in failure messages. */
|
|
32
|
+
display: string;
|
|
33
|
+
}
|
|
34
|
+
/**
|
|
35
|
+
* Applies the app's schema and returns how it was applied, or `no-schema`
|
|
36
|
+
* when the app has none. Throws {@link BuildError} on failure: a non-zero
|
|
37
|
+
* CLI exit carries `exited with code N` (a user-fixable error), while an
|
|
38
|
+
* unrunnable launcher does not (an infrastructure error).
|
|
39
|
+
*/
|
|
40
|
+
export declare function applyMigrations(opts: ApplyMigrationsOptions): Promise<ApplyMigrationsResult>;
|
|
41
|
+
/**
|
|
42
|
+
* Resolves the launcher ladder for a schema's engine: the project's own
|
|
43
|
+
* binary first (run via `node`), then download fallbacks tried in order when
|
|
44
|
+
* the binary is not installed.
|
|
45
|
+
*/
|
|
46
|
+
export declare function resolveSchemaEngineCli(schema: DetectedSchema, appPath: string, signal?: AbortSignal): Promise<CliLauncher[]>;
|
|
47
|
+
/**
|
|
48
|
+
* Runs `subcommand` against the launcher ladder, falling through to the next
|
|
49
|
+
* launcher when one cannot run (spawn ENOENT or exit 127) and throwing on the
|
|
50
|
+
* first launcher that runs the tool to a real non-zero exit.
|
|
51
|
+
*/
|
|
52
|
+
export declare function runWithLaunchers(opts: {
|
|
53
|
+
launchers: CliLauncher[];
|
|
54
|
+
subcommand: string[];
|
|
55
|
+
subcommandDisplay: string;
|
|
56
|
+
cwd: string;
|
|
57
|
+
env: NodeJS.ProcessEnv;
|
|
58
|
+
signal?: AbortSignal;
|
|
59
|
+
onLog?: (line: string, stream: "stdout" | "stderr") => void;
|
|
60
|
+
}): Promise<void>;
|
|
61
|
+
//# sourceMappingURL=apply-migrations.d.ts.map
|
|
@@ -0,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AsB,gBAAgB,CAAC,IAAI,EAAE;IAC3C,SAAS,EAAE,WAAW,EAAE,CAAC;IACzB,UAAU,EAAE,MAAM,EAAE,CAAC;IACrB,iBAAiB,EAAE,MAAM,CAAC;IAC1B,GAAG,EAAE,MAAM,CAAC;IACZ,GAAG,EAAE,MAAM,CAAC,UAAU,CAAC;IACvB,MAAM,CAAC,EAAE,WAAW,CAAC;IACrB,KAAK,CAAC,EAAE,CAAC,IAAI,EAAE,MAAM,EAAE,MAAM,EAAE,QAAQ,GAAG,QAAQ,KAAK,IAAI,CAAC;CAC7D,GAAG,OAAO,CAAC,IAAI,CAAC,CAmBhB"}
|
|
@@ -0,0 +1,314 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Applies an application's database schema against a database, owning the
|
|
3
|
+
* prisma CLI resolution so every deploy front door (git-push build-runner,
|
|
4
|
+
* `prisma app deploy`) runs migrations the same way.
|
|
5
|
+
*
|
|
6
|
+
* The resolver locates the project's own prisma binary by walking
|
|
7
|
+
* `node_modules` from the schema directory up to the source root, the way
|
|
8
|
+
* Node resolves a dependency. That covers npm, pnpm, yarn, and monorepo
|
|
9
|
+
* layouts where prisma is installed but the flat `node_modules/.bin/prisma`
|
|
10
|
+
* symlink is absent at the app root.
|
|
11
|
+
*/
|
|
12
|
+
import { spawn } from "node:child_process";
|
|
13
|
+
import { readFile } from "node:fs/promises";
|
|
14
|
+
import path from "node:path";
|
|
15
|
+
import { sourceRootLineage } from "./config/source-root.js";
|
|
16
|
+
import { detectAppSchema } from "./detect-schema.js";
|
|
17
|
+
import { BuildError } from "./errors.js";
|
|
18
|
+
/**
|
|
19
|
+
* Last resort for repos that ship a schema with no prisma installed at all.
|
|
20
|
+
* Pinned to the 6.x line: Prisma 7 rejects the classic `url = env(...)`
|
|
21
|
+
* datasource form (P1012), which is exactly the schema shape such repos have.
|
|
22
|
+
* Bump deliberately, never to `latest`.
|
|
23
|
+
*/
|
|
24
|
+
export const FALLBACK_PRISMA_CLI_VERSION = "6.19.3";
|
|
25
|
+
/**
|
|
26
|
+
* Applies the app's schema and returns how it was applied, or `no-schema`
|
|
27
|
+
* when the app has none. Throws {@link BuildError} on failure: a non-zero
|
|
28
|
+
* CLI exit carries `exited with code N` (a user-fixable error), while an
|
|
29
|
+
* unrunnable launcher does not (an infrastructure error).
|
|
30
|
+
*/
|
|
31
|
+
export async function applyMigrations(opts) {
|
|
32
|
+
opts.signal?.throwIfAborted();
|
|
33
|
+
const schema = opts.schema ?? (await detectAppSchema(opts.appPath, opts.signal)).schema;
|
|
34
|
+
if (!schema) {
|
|
35
|
+
return { applied: false, reason: "no-schema" };
|
|
36
|
+
}
|
|
37
|
+
const launchers = await resolveSchemaEngineCli(schema, opts.appPath, opts.signal);
|
|
38
|
+
const relativeSchemaPath = path.relative(opts.appPath, schema.path) ||
|
|
39
|
+
defaultSchemaSourcePath(schema.engine);
|
|
40
|
+
const env = {
|
|
41
|
+
...process.env,
|
|
42
|
+
...opts.env,
|
|
43
|
+
DATABASE_URL: opts.databaseUrl,
|
|
44
|
+
// Update nags pollute the migration log and failure snippets.
|
|
45
|
+
PRISMA_HIDE_UPDATE_MESSAGE: "1",
|
|
46
|
+
};
|
|
47
|
+
for (const subcommand of subcommandsFor(schema, relativeSchemaPath, opts.databaseUrl)) {
|
|
48
|
+
await runWithLaunchers({
|
|
49
|
+
launchers,
|
|
50
|
+
subcommand: subcommand.args,
|
|
51
|
+
subcommandDisplay: subcommand.display,
|
|
52
|
+
cwd: opts.appPath,
|
|
53
|
+
env,
|
|
54
|
+
signal: opts.signal,
|
|
55
|
+
onLog: opts.onLog,
|
|
56
|
+
});
|
|
57
|
+
}
|
|
58
|
+
return { applied: true, via: schema.command };
|
|
59
|
+
}
|
|
60
|
+
/**
|
|
61
|
+
* Resolves the launcher ladder for a schema's engine: the project's own
|
|
62
|
+
* binary first (run via `node`), then download fallbacks tried in order when
|
|
63
|
+
* the binary is not installed.
|
|
64
|
+
*/
|
|
65
|
+
export async function resolveSchemaEngineCli(schema, appPath, signal) {
|
|
66
|
+
const startDir = path.dirname(schema.path) || appPath;
|
|
67
|
+
if (schema.engine === "prisma-next") {
|
|
68
|
+
const localBin = await resolveLocalCliBin(startDir, "@prisma-next/cli", "prisma-next", signal);
|
|
69
|
+
if (localBin) {
|
|
70
|
+
return [
|
|
71
|
+
{ command: "node", argsPrefix: [localBin], display: "prisma-next" },
|
|
72
|
+
];
|
|
73
|
+
}
|
|
74
|
+
// `@prisma-next/cli` is not published to npm, so there is no download
|
|
75
|
+
// fallback; `--no-install` keeps today's behaviour when it is missing.
|
|
76
|
+
return [
|
|
77
|
+
{
|
|
78
|
+
command: "npx",
|
|
79
|
+
argsPrefix: ["--no-install", "prisma-next"],
|
|
80
|
+
display: "npx --no-install prisma-next",
|
|
81
|
+
},
|
|
82
|
+
];
|
|
83
|
+
}
|
|
84
|
+
const localBin = await resolveLocalCliBin(startDir, "prisma", "prisma", signal);
|
|
85
|
+
if (localBin) {
|
|
86
|
+
return [{ command: "node", argsPrefix: [localBin], display: "prisma" }];
|
|
87
|
+
}
|
|
88
|
+
const pinned = (await readResolvedPrismaVersion(startDir, signal)) ??
|
|
89
|
+
FALLBACK_PRISMA_CLI_VERSION;
|
|
90
|
+
return [
|
|
91
|
+
{
|
|
92
|
+
command: "npx",
|
|
93
|
+
argsPrefix: ["--yes", "--package", `prisma@${pinned}`, "prisma"],
|
|
94
|
+
display: `npx prisma@${pinned}`,
|
|
95
|
+
},
|
|
96
|
+
{
|
|
97
|
+
command: "bunx",
|
|
98
|
+
argsPrefix: [`prisma@${pinned}`],
|
|
99
|
+
display: `bunx prisma@${pinned}`,
|
|
100
|
+
},
|
|
101
|
+
];
|
|
102
|
+
}
|
|
103
|
+
async function resolveLocalCliBin(startDir, packageName, binName, signal) {
|
|
104
|
+
for (const dir of await sourceRootLineage(startDir, signal)) {
|
|
105
|
+
const packageDir = path.join(dir, "node_modules", packageName);
|
|
106
|
+
const bin = await readBinFromPackageJson(path.join(packageDir, "package.json"), binName, signal);
|
|
107
|
+
if (bin) {
|
|
108
|
+
return path.resolve(packageDir, bin);
|
|
109
|
+
}
|
|
110
|
+
}
|
|
111
|
+
return null;
|
|
112
|
+
}
|
|
113
|
+
async function readBinFromPackageJson(packageJsonPath, binName, signal) {
|
|
114
|
+
let raw;
|
|
115
|
+
try {
|
|
116
|
+
raw = await readFile(packageJsonPath, { encoding: "utf8", signal });
|
|
117
|
+
}
|
|
118
|
+
catch (error) {
|
|
119
|
+
if (signal?.aborted)
|
|
120
|
+
throw error;
|
|
121
|
+
return null;
|
|
122
|
+
}
|
|
123
|
+
let parsed;
|
|
124
|
+
try {
|
|
125
|
+
parsed = JSON.parse(raw);
|
|
126
|
+
}
|
|
127
|
+
catch {
|
|
128
|
+
return null;
|
|
129
|
+
}
|
|
130
|
+
const bin = parsed.bin;
|
|
131
|
+
if (typeof bin === "string") {
|
|
132
|
+
return bin;
|
|
133
|
+
}
|
|
134
|
+
if (bin && typeof bin === "object") {
|
|
135
|
+
const entry = bin[binName];
|
|
136
|
+
return typeof entry === "string" ? entry : null;
|
|
137
|
+
}
|
|
138
|
+
return null;
|
|
139
|
+
}
|
|
140
|
+
async function readResolvedPrismaVersion(startDir, signal) {
|
|
141
|
+
for (const dir of await sourceRootLineage(startDir, signal)) {
|
|
142
|
+
const version = await readPackageVersion(path.join(dir, "node_modules", "@prisma", "client", "package.json"), signal);
|
|
143
|
+
if (version) {
|
|
144
|
+
return version;
|
|
145
|
+
}
|
|
146
|
+
}
|
|
147
|
+
return null;
|
|
148
|
+
}
|
|
149
|
+
async function readPackageVersion(packageJsonPath, signal) {
|
|
150
|
+
let raw;
|
|
151
|
+
try {
|
|
152
|
+
raw = await readFile(packageJsonPath, { encoding: "utf8", signal });
|
|
153
|
+
}
|
|
154
|
+
catch (error) {
|
|
155
|
+
if (signal?.aborted)
|
|
156
|
+
throw error;
|
|
157
|
+
return null;
|
|
158
|
+
}
|
|
159
|
+
try {
|
|
160
|
+
const parsed = JSON.parse(raw);
|
|
161
|
+
const version = parsed.version;
|
|
162
|
+
return typeof version === "string" && version.length > 0 ? version : null;
|
|
163
|
+
}
|
|
164
|
+
catch {
|
|
165
|
+
return null;
|
|
166
|
+
}
|
|
167
|
+
}
|
|
168
|
+
function subcommandsFor(schema, relativeSchemaPath, databaseUrl) {
|
|
169
|
+
switch (schema.command) {
|
|
170
|
+
case "migrate-deploy":
|
|
171
|
+
return [
|
|
172
|
+
{
|
|
173
|
+
args: ["migrate", "deploy", "--schema", relativeSchemaPath],
|
|
174
|
+
display: "migrate deploy",
|
|
175
|
+
},
|
|
176
|
+
];
|
|
177
|
+
case "db-push":
|
|
178
|
+
return [
|
|
179
|
+
{
|
|
180
|
+
args: ["db", "push", "--schema", relativeSchemaPath],
|
|
181
|
+
display: "db push",
|
|
182
|
+
},
|
|
183
|
+
];
|
|
184
|
+
case "prisma-next-init":
|
|
185
|
+
return [
|
|
186
|
+
{
|
|
187
|
+
args: ["contract", "emit", "--config", relativeSchemaPath],
|
|
188
|
+
display: "contract emit",
|
|
189
|
+
},
|
|
190
|
+
{
|
|
191
|
+
args: [
|
|
192
|
+
"db",
|
|
193
|
+
"init",
|
|
194
|
+
"--config",
|
|
195
|
+
relativeSchemaPath,
|
|
196
|
+
"--db",
|
|
197
|
+
databaseUrl,
|
|
198
|
+
],
|
|
199
|
+
display: "db init",
|
|
200
|
+
},
|
|
201
|
+
];
|
|
202
|
+
default: {
|
|
203
|
+
const exhaustive = schema.command;
|
|
204
|
+
throw new BuildError({
|
|
205
|
+
message: `Unknown migration command: ${String(exhaustive)}`,
|
|
206
|
+
});
|
|
207
|
+
}
|
|
208
|
+
}
|
|
209
|
+
}
|
|
210
|
+
function defaultSchemaSourcePath(engine) {
|
|
211
|
+
return engine === "prisma-next" ? "prisma-next.config.ts" : "schema.prisma";
|
|
212
|
+
}
|
|
213
|
+
/**
|
|
214
|
+
* Runs `subcommand` against the launcher ladder, falling through to the next
|
|
215
|
+
* launcher when one cannot run (spawn ENOENT or exit 127) and throwing on the
|
|
216
|
+
* first launcher that runs the tool to a real non-zero exit.
|
|
217
|
+
*/
|
|
218
|
+
export async function runWithLaunchers(opts) {
|
|
219
|
+
for (const launcher of opts.launchers) {
|
|
220
|
+
opts.signal?.throwIfAborted();
|
|
221
|
+
const outcome = await runOnce(launcher, opts);
|
|
222
|
+
if (outcome.kind === "ok") {
|
|
223
|
+
return;
|
|
224
|
+
}
|
|
225
|
+
if (outcome.kind === "failed") {
|
|
226
|
+
throw new BuildError({
|
|
227
|
+
message: `${launcher.display} ${opts.subcommandDisplay} exited with code ${outcome.code}`,
|
|
228
|
+
});
|
|
229
|
+
}
|
|
230
|
+
}
|
|
231
|
+
throw new BuildError({
|
|
232
|
+
message: `Could not run ${opts.subcommandDisplay}: no prisma launcher was runnable (tried ${opts.launchers
|
|
233
|
+
.map((launcher) => launcher.display)
|
|
234
|
+
.join(", ")})`,
|
|
235
|
+
});
|
|
236
|
+
}
|
|
237
|
+
function runOnce(launcher, opts) {
|
|
238
|
+
return new Promise((resolve, reject) => {
|
|
239
|
+
const child = spawn(launcher.command, [...launcher.argsPrefix, ...opts.subcommand], {
|
|
240
|
+
cwd: opts.cwd,
|
|
241
|
+
env: opts.env,
|
|
242
|
+
signal: opts.signal,
|
|
243
|
+
stdio: ["ignore", "pipe", "pipe"],
|
|
244
|
+
});
|
|
245
|
+
const flushStdout = streamLines(child.stdout, "stdout", opts.onLog);
|
|
246
|
+
const flushStderr = streamLines(child.stderr, "stderr", opts.onLog);
|
|
247
|
+
child.once("error", (error) => {
|
|
248
|
+
if (opts.signal?.aborted) {
|
|
249
|
+
reject(error);
|
|
250
|
+
return;
|
|
251
|
+
}
|
|
252
|
+
// A launcher that is not installed (e.g. `bunx` absent) should fall
|
|
253
|
+
// through to the next, not surface as a migration failure.
|
|
254
|
+
if (error.code === "ENOENT") {
|
|
255
|
+
resolve({ kind: "unavailable" });
|
|
256
|
+
return;
|
|
257
|
+
}
|
|
258
|
+
reject(new BuildError({
|
|
259
|
+
message: `Failed to start ${launcher.display}: ${error.message}`,
|
|
260
|
+
}));
|
|
261
|
+
});
|
|
262
|
+
child.once("close", (code, terminationSignal) => {
|
|
263
|
+
flushStdout();
|
|
264
|
+
flushStderr();
|
|
265
|
+
if (terminationSignal) {
|
|
266
|
+
if (opts.signal?.aborted) {
|
|
267
|
+
reject(opts.signal.reason ?? new Error("aborted"));
|
|
268
|
+
return;
|
|
269
|
+
}
|
|
270
|
+
reject(new BuildError({
|
|
271
|
+
message: `${launcher.display} was terminated by ${terminationSignal}`,
|
|
272
|
+
}));
|
|
273
|
+
return;
|
|
274
|
+
}
|
|
275
|
+
if (code === 0) {
|
|
276
|
+
resolve({ kind: "ok" });
|
|
277
|
+
return;
|
|
278
|
+
}
|
|
279
|
+
// Exit 127 is the shell's "command not found": the launcher could not
|
|
280
|
+
// exec the tool. Treat it like ENOENT and try the next launcher rather
|
|
281
|
+
// than blaming the user's schema.
|
|
282
|
+
if (code === 127) {
|
|
283
|
+
resolve({ kind: "unavailable" });
|
|
284
|
+
return;
|
|
285
|
+
}
|
|
286
|
+
resolve({ kind: "failed", code: code ?? 1 });
|
|
287
|
+
});
|
|
288
|
+
});
|
|
289
|
+
}
|
|
290
|
+
function streamLines(stream, channel, onLog) {
|
|
291
|
+
if (!stream) {
|
|
292
|
+
return () => { };
|
|
293
|
+
}
|
|
294
|
+
let buffer = "";
|
|
295
|
+
stream.on("data", (chunk) => {
|
|
296
|
+
buffer += chunk.toString("utf8");
|
|
297
|
+
let newline = buffer.indexOf("\n");
|
|
298
|
+
while (newline !== -1) {
|
|
299
|
+
const line = buffer.slice(0, newline);
|
|
300
|
+
if (line.length > 0) {
|
|
301
|
+
onLog?.(line, channel);
|
|
302
|
+
}
|
|
303
|
+
buffer = buffer.slice(newline + 1);
|
|
304
|
+
newline = buffer.indexOf("\n");
|
|
305
|
+
}
|
|
306
|
+
});
|
|
307
|
+
return () => {
|
|
308
|
+
if (buffer.length > 0) {
|
|
309
|
+
onLog?.(buffer, channel);
|
|
310
|
+
buffer = "";
|
|
311
|
+
}
|
|
312
|
+
};
|
|
313
|
+
}
|
|
314
|
+
//# sourceMappingURL=apply-migrations.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"apply-migrations.js","sourceRoot":"","sources":["../src/apply-migrations.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AACH,OAAO,EAAE,KAAK,EAAE,MAAM,oBAAoB,CAAC;AAC3C,OAAO,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAC;AAC5C,OAAO,IAAI,MAAM,WAAW,CAAC;AAE7B,OAAO,EAAE,iBAAiB,EAAE,MAAM,yBAAyB,CAAC;AAM5D,OAAO,EAAE,eAAe,EAAE,MAAM,oBAAoB,CAAC;AACrD,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AAmBzC;;;;;GAKG;AACH,MAAM,CAAC,MAAM,2BAA2B,GAAG,QAAQ,CAAC;AASpD;;;;;GAKG;AACH,MAAM,CAAC,KAAK,UAAU,eAAe,CACnC,IAA4B;IAE5B,IAAI,CAAC,MAAM,EAAE,cAAc,EAAE,CAAC;IAE9B,MAAM,MAAM,GACV,IAAI,CAAC,MAAM,IAAI,CAAC,MAAM,eAAe,CAAC,IAAI,CAAC,OAAO,EAAE,IAAI,CAAC,MAAM,CAAC,CAAC,CAAC,MAAM,CAAC;IAC3E,IAAI,CAAC,MAAM,EAAE,CAAC;QACZ,OAAO,EAAE,OAAO,EAAE,KAAK,EAAE,MAAM,EAAE,WAAW,EAAE,CAAC;IACjD,CAAC;IAED,MAAM,SAAS,GAAG,MAAM,sBAAsB,CAC5C,MAAM,EACN,IAAI,CAAC,OAAO,EACZ,IAAI,CAAC,MAAM,CACZ,CAAC;IACF,MAAM,kBAAkB,GACtB,IAAI,CAAC,QAAQ,CAAC,IAAI,CAAC,OAAO,EAAE,MAAM,CAAC,IAAI,CAAC;QACxC,uBAAuB,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC;I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AE,CAAC,MAAM,EAAE,CAAC,KAAa,EAAE,EAAE;QAClC,MAAM,IAAI,KAAK,CAAC,QAAQ,CAAC,MAAM,CAAC,CAAC;QACjC,IAAI,OAAO,GAAG,MAAM,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC;QACnC,OAAO,OAAO,KAAK,CAAC,CAAC,EAAE,CAAC;YACtB,MAAM,IAAI,GAAG,MAAM,CAAC,KAAK,CAAC,CAAC,EAAE,OAAO,CAAC,CAAC;YACtC,IAAI,IAAI,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;gBACpB,KAAK,EAAE,CAAC,IAAI,EAAE,OAAO,CAAC,CAAC;YACzB,CAAC;YACD,MAAM,GAAG,MAAM,CAAC,KAAK,CAAC,OAAO,GAAG,CAAC,CAAC,CAAC;YACnC,OAAO,GAAG,MAAM,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC;QACjC,CAAC;IACH,CAAC,CAAC,CAAC;IAEH,OAAO,GAAG,EAAE;QACV,IAAI,MAAM,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;YACtB,KAAK,EAAE,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;YACzB,MAAM,GAAG,EAAE,CAAC;QACd,CAAC;IACH,CAAC,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
export type SchemaEngine = "prisma-orm" | "prisma-next";
|
|
2
|
+
export type MigrationCommand = "migrate-deploy" | "db-push" | "prisma-next-init";
|
|
3
|
+
export type UnsupportedSchemaTarget = "mongodb" | "mysql" | "sqlite" | "sqlserver" | "cockroachdb";
|
|
4
|
+
export interface DetectedSchema {
|
|
5
|
+
engine: SchemaEngine;
|
|
6
|
+
/** Absolute path to `schema.prisma` (Prisma ORM) or the Prisma Next config. */
|
|
7
|
+
path: string;
|
|
8
|
+
command: MigrationCommand;
|
|
9
|
+
/** Prisma ORM only; always `false` for Prisma Next. */
|
|
10
|
+
hasMigrations: boolean;
|
|
11
|
+
target: "postgresql" | "unknown";
|
|
12
|
+
}
|
|
13
|
+
export interface UnsupportedSchema {
|
|
14
|
+
engine: SchemaEngine;
|
|
15
|
+
path: string;
|
|
16
|
+
target: UnsupportedSchemaTarget;
|
|
17
|
+
}
|
|
18
|
+
export interface SchemaDetection {
|
|
19
|
+
/** A schema whose migrations can be applied, or `null` if none was found. */
|
|
20
|
+
schema: DetectedSchema | null;
|
|
21
|
+
/** A schema targeting an engine the migration flow does not support. */
|
|
22
|
+
unsupported: UnsupportedSchema | null;
|
|
23
|
+
}
|
|
24
|
+
/**
|
|
25
|
+
* Walks `appPath` for a Prisma ORM schema or Prisma Next config and returns
|
|
26
|
+
* the migration command that should run against it. Returns a `null` schema
|
|
27
|
+
* when none is found, and reports a non-Postgres schema under `unsupported`
|
|
28
|
+
* so callers can decide how to surface it.
|
|
29
|
+
*/
|
|
30
|
+
export declare function detectAppSchema(appPath: string, signal?: AbortSignal): Promise<SchemaDetection>;
|
|
31
|
+
//# sourceMappingURL=detect-schema.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"detect-schema.d.ts","sourceRoot":"","sources":["../src/detect-schema.ts"],"names":[],"mappings":"AAaA,MAAM,MAAM,YAAY,GAAG,YAAY,GAAG,aAAa,CAAC;AAExD,MAAM,MAAM,gBAAgB,GACxB,gBAAgB,GAChB,SAAS,GACT,kBAAkB,CAAC;AAEvB,MAAM,MAAM,uBAAuB,GAC/B,SAAS,GACT,OAAO,GACP,QAAQ,GACR,WAAW,GACX,aAAa,CAAC;AAElB,MAAM,WAAW,cAAc;IAC7B,MAAM,EAAE,YAAY,CAAC;IACrB,+EAA+E;IAC/E,IAAI,EAAE,MAAM,CAAC;IACb,OAAO,EAAE,gBAAgB,CAAC;IAC1B,uDAAuD;IACvD,aAAa,EAAE,OAAO,CAAC;IACvB,MAAM,EAAE,YAAY,GAAG,SAAS,CAAC;CAClC;AAED,MAAM,WAAW,iBAAiB;IAChC,MAAM,EAAE,YAAY,CAAC;IACrB,IAAI,EAAE,MAAM,CAAC;IACb,MAAM,EAAE,uBAAuB,CAAC;CACjC;AAED,MAAM,WAAW,eAAe;IAC9B,6EAA6E;IAC7E,MAAM,EAAE,cAAc,GAAG,IAAI,CAAC;IAC9B,wEAAwE;IACxE,WAAW,EAAE,iBAAiB,GAAG,IAAI,CAAC;CACvC;AAqBD;;;;;GAKG;AACH,wBAAsB,eAAe,CACnC,OAAO,EAAE,MAAM,EACf,MAAM,CAAC,EAAE,WAAW,GACnB,OAAO,CAAC,eAAe,CAAC,CAkD1B"}
|
|
@@ -0,0 +1,212 @@
|
|
|
1
|
+
import { access, readdir, readFile, stat } from "node:fs/promises";
|
|
2
|
+
import path from "node:path";
|
|
3
|
+
const SKIPPED_DIRECTORIES = new Set([
|
|
4
|
+
".git",
|
|
5
|
+
".next",
|
|
6
|
+
".nuxt",
|
|
7
|
+
".output",
|
|
8
|
+
".prisma",
|
|
9
|
+
".turbo",
|
|
10
|
+
".vercel",
|
|
11
|
+
".wrangler",
|
|
12
|
+
"build",
|
|
13
|
+
"coverage",
|
|
14
|
+
"dist",
|
|
15
|
+
"node_modules",
|
|
16
|
+
"out",
|
|
17
|
+
]);
|
|
18
|
+
const MAX_SCAN_DEPTH = 6;
|
|
19
|
+
const MAX_SCAN_FILES = 1_000;
|
|
20
|
+
const MAX_TEXT_FILE_BYTES = 1024 * 1024;
|
|
21
|
+
/**
|
|
22
|
+
* Walks `appPath` for a Prisma ORM schema or Prisma Next config and returns
|
|
23
|
+
* the migration command that should run against it. Returns a `null` schema
|
|
24
|
+
* when none is found, and reports a non-Postgres schema under `unsupported`
|
|
25
|
+
* so callers can decide how to surface it.
|
|
26
|
+
*/
|
|
27
|
+
export async function detectAppSchema(appPath, signal) {
|
|
28
|
+
const state = {
|
|
29
|
+
filesVisited: 0,
|
|
30
|
+
schemaCandidates: [],
|
|
31
|
+
prismaNextConfigCandidates: [],
|
|
32
|
+
};
|
|
33
|
+
await scanDirectory(appPath, 0, state, signal);
|
|
34
|
+
const prismaNextConfigs = await Promise.all(state.prismaNextConfigCandidates.map((configPath) => classifyPrismaNextConfig(configPath, signal)));
|
|
35
|
+
const supportedPrismaNextConfig = selectPrismaNextConfig(appPath, prismaNextConfigs, "supported");
|
|
36
|
+
const unsupportedPrismaNextConfig = selectPrismaNextConfig(appPath, prismaNextConfigs, "unsupported");
|
|
37
|
+
const selectedPrismaOrmSchema = await selectPrismaOrmSchema(appPath, state.schemaCandidates, signal);
|
|
38
|
+
const schema = supportedPrismaNextConfig
|
|
39
|
+
? {
|
|
40
|
+
engine: "prisma-next",
|
|
41
|
+
path: supportedPrismaNextConfig.path,
|
|
42
|
+
hasMigrations: false,
|
|
43
|
+
command: "prisma-next-init",
|
|
44
|
+
target: supportedPrismaNextConfig.target,
|
|
45
|
+
}
|
|
46
|
+
: selectedPrismaOrmSchema.schema;
|
|
47
|
+
const unsupported = schema
|
|
48
|
+
? null
|
|
49
|
+
: unsupportedPrismaNextConfig
|
|
50
|
+
? {
|
|
51
|
+
engine: "prisma-next",
|
|
52
|
+
path: unsupportedPrismaNextConfig.path,
|
|
53
|
+
target: unsupportedPrismaNextConfig.target,
|
|
54
|
+
}
|
|
55
|
+
: selectedPrismaOrmSchema.unsupported;
|
|
56
|
+
return { schema, unsupported };
|
|
57
|
+
}
|
|
58
|
+
async function scanDirectory(directory, depth, state, signal) {
|
|
59
|
+
signal?.throwIfAborted();
|
|
60
|
+
if (depth > MAX_SCAN_DEPTH || state.filesVisited >= MAX_SCAN_FILES) {
|
|
61
|
+
return;
|
|
62
|
+
}
|
|
63
|
+
let entries;
|
|
64
|
+
try {
|
|
65
|
+
entries = await readdir(directory, { withFileTypes: true });
|
|
66
|
+
}
|
|
67
|
+
catch (error) {
|
|
68
|
+
if (error.code === "ENOENT") {
|
|
69
|
+
return;
|
|
70
|
+
}
|
|
71
|
+
throw error;
|
|
72
|
+
}
|
|
73
|
+
entries.sort((left, right) => left.name.localeCompare(right.name));
|
|
74
|
+
for (const entry of entries) {
|
|
75
|
+
signal?.throwIfAborted();
|
|
76
|
+
if (state.filesVisited >= MAX_SCAN_FILES) {
|
|
77
|
+
return;
|
|
78
|
+
}
|
|
79
|
+
const entryPath = path.join(directory, entry.name);
|
|
80
|
+
if (entry.isDirectory()) {
|
|
81
|
+
if (!SKIPPED_DIRECTORIES.has(entry.name)) {
|
|
82
|
+
await scanDirectory(entryPath, depth + 1, state, signal);
|
|
83
|
+
}
|
|
84
|
+
continue;
|
|
85
|
+
}
|
|
86
|
+
if (!entry.isFile()) {
|
|
87
|
+
continue;
|
|
88
|
+
}
|
|
89
|
+
state.filesVisited += 1;
|
|
90
|
+
if (entry.name === "schema.prisma") {
|
|
91
|
+
state.schemaCandidates.push(entryPath);
|
|
92
|
+
}
|
|
93
|
+
if (isPrismaNextConfigFile(entry.name)) {
|
|
94
|
+
state.prismaNextConfigCandidates.push(entryPath);
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
async function selectPrismaOrmSchema(appPath, candidates, signal) {
|
|
99
|
+
const sorted = sortByPreferredRelativePath(appPath, candidates, "schema.prisma");
|
|
100
|
+
for (const schemaPath of sorted) {
|
|
101
|
+
const target = await classifyPrismaOrmSchemaTarget(schemaPath, signal);
|
|
102
|
+
if (target === "postgresql" || target === "unknown") {
|
|
103
|
+
const hasMigrations = await hasMigrationsDirectory(path.dirname(schemaPath), signal);
|
|
104
|
+
return {
|
|
105
|
+
schema: {
|
|
106
|
+
engine: "prisma-orm",
|
|
107
|
+
path: schemaPath,
|
|
108
|
+
hasMigrations,
|
|
109
|
+
command: hasMigrations ? "migrate-deploy" : "db-push",
|
|
110
|
+
target,
|
|
111
|
+
},
|
|
112
|
+
unsupported: null,
|
|
113
|
+
};
|
|
114
|
+
}
|
|
115
|
+
return {
|
|
116
|
+
schema: null,
|
|
117
|
+
unsupported: { engine: "prisma-orm", path: schemaPath, target },
|
|
118
|
+
};
|
|
119
|
+
}
|
|
120
|
+
return { schema: null, unsupported: null };
|
|
121
|
+
}
|
|
122
|
+
function selectPrismaNextConfig(appPath, candidates, mode) {
|
|
123
|
+
const matches = candidates.filter((candidate) => {
|
|
124
|
+
const isSupported = candidate.target === "postgresql" || candidate.target === "unknown";
|
|
125
|
+
return mode === "supported" ? isSupported : !isSupported;
|
|
126
|
+
});
|
|
127
|
+
return (sortByPreferredRelativePath(appPath, matches.map((candidate) => candidate.path), "prisma-next.config.ts")
|
|
128
|
+
.map((candidatePath) => matches.find((candidate) => candidate.path === candidatePath))
|
|
129
|
+
.find((candidate) => Boolean(candidate)) ?? null);
|
|
130
|
+
}
|
|
131
|
+
function sortByPreferredRelativePath(appPath, candidates, preferredRootFile) {
|
|
132
|
+
return candidates
|
|
133
|
+
.map((candidate) => ({
|
|
134
|
+
absolute: candidate,
|
|
135
|
+
relative: path.relative(appPath, candidate) || preferredRootFile,
|
|
136
|
+
}))
|
|
137
|
+
.sort((left, right) => {
|
|
138
|
+
if (left.relative === preferredRootFile)
|
|
139
|
+
return -1;
|
|
140
|
+
if (right.relative === preferredRootFile)
|
|
141
|
+
return 1;
|
|
142
|
+
return (left.relative.length - right.relative.length ||
|
|
143
|
+
left.relative.localeCompare(right.relative));
|
|
144
|
+
})
|
|
145
|
+
.map((candidate) => candidate.absolute);
|
|
146
|
+
}
|
|
147
|
+
async function hasMigrationsDirectory(schemaDirectory, signal) {
|
|
148
|
+
signal?.throwIfAborted();
|
|
149
|
+
const migrationsPath = path.join(schemaDirectory, "migrations");
|
|
150
|
+
try {
|
|
151
|
+
await access(migrationsPath);
|
|
152
|
+
const entries = await readdir(migrationsPath);
|
|
153
|
+
return entries.length > 0;
|
|
154
|
+
}
|
|
155
|
+
catch (error) {
|
|
156
|
+
if (error.code === "ENOENT") {
|
|
157
|
+
return false;
|
|
158
|
+
}
|
|
159
|
+
throw error;
|
|
160
|
+
}
|
|
161
|
+
}
|
|
162
|
+
async function classifyPrismaNextConfig(configPath, signal) {
|
|
163
|
+
const content = await readTextFileIfSmall(configPath, signal);
|
|
164
|
+
if (!content) {
|
|
165
|
+
return { path: configPath, target: "unknown" };
|
|
166
|
+
}
|
|
167
|
+
if (content.includes("@prisma-next/postgres/config")) {
|
|
168
|
+
return { path: configPath, target: "postgresql" };
|
|
169
|
+
}
|
|
170
|
+
if (content.includes("@prisma-next/mongo/config")) {
|
|
171
|
+
return { path: configPath, target: "mongodb" };
|
|
172
|
+
}
|
|
173
|
+
if (content.includes("@prisma-next/sqlite/config")) {
|
|
174
|
+
return { path: configPath, target: "sqlite" };
|
|
175
|
+
}
|
|
176
|
+
return { path: configPath, target: "unknown" };
|
|
177
|
+
}
|
|
178
|
+
async function classifyPrismaOrmSchemaTarget(schemaPath, signal) {
|
|
179
|
+
const content = await readTextFileIfSmall(schemaPath, signal);
|
|
180
|
+
const provider = content?.match(/\bprovider\s*=\s*"([^"]+)"/)?.[1] ?? null;
|
|
181
|
+
switch (provider) {
|
|
182
|
+
case "postgresql":
|
|
183
|
+
return "postgresql";
|
|
184
|
+
case "mongodb":
|
|
185
|
+
return "mongodb";
|
|
186
|
+
case "mysql":
|
|
187
|
+
return "mysql";
|
|
188
|
+
case "sqlite":
|
|
189
|
+
return "sqlite";
|
|
190
|
+
case "sqlserver":
|
|
191
|
+
return "sqlserver";
|
|
192
|
+
case "cockroachdb":
|
|
193
|
+
return "cockroachdb";
|
|
194
|
+
default:
|
|
195
|
+
return "unknown";
|
|
196
|
+
}
|
|
197
|
+
}
|
|
198
|
+
function isPrismaNextConfigFile(fileName) {
|
|
199
|
+
if (!fileName.startsWith("prisma-next.config.")) {
|
|
200
|
+
return false;
|
|
201
|
+
}
|
|
202
|
+
return [".cjs", ".cts", ".js", ".mjs", ".mts", ".ts"].some((extension) => fileName.endsWith(extension));
|
|
203
|
+
}
|
|
204
|
+
async function readTextFileIfSmall(filePath, signal) {
|
|
205
|
+
signal?.throwIfAborted();
|
|
206
|
+
const info = await stat(filePath);
|
|
207
|
+
if (info.size > MAX_TEXT_FILE_BYTES) {
|
|
208
|
+
return null;
|
|
209
|
+
}
|
|
210
|
+
return readFile(filePath, { encoding: "utf8", signal });
|
|
211
|
+
}
|
|
212
|
+
//# sourceMappingURL=detect-schema.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"detect-schema.js","sourceRoot":"","sources":["../src/detect-schema.ts"],"names":[],"mappings":"AAUA,OAAO,EAAE,MAAM,EAAE,OAAO,EAAE,QAAQ,EAAE,IAAI,EAAE,MAAM,kBAAkB,CAAC;AACnE,OAAO,IAAI,MAAM,WAAW,CAAC;AAuC7B,MAAM,mBAAmB,GAAG,IAAI,GAAG,CAAC;IAClC,MAAM;IACN,OAAO;IACP,OAAO;IACP,SAAS;IACT,SAAS;IACT,QAAQ;IACR,SAAS;IACT,WAAW;IACX,OAAO;IACP,UAAU;IACV,MAAM;IACN,cAAc;IACd,KAAK;CACN,CAAC,CAAC;AACH,MAAM,cAAc,GAAG,CAAC,CAAC;AACzB,MAAM,cAAc,GAAG,KAAK,CAAC;AAC7B,MAAM,mBAAmB,GAAG,IAAI,GAAG,IAAI,CAAC;AAExC;;;;;GAKG;AACH,MAAM,CAAC,KAAK,UAAU,eAAe,CACnC,OAAe,EACf,MAAoB;IAEpB,MAAM,KAAK,GAAc;QACvB,YAAY,EAAE,CAAC;QACf,gBAAgB,EAAE,EAAE;QACpB,0BAA0B,EAAE,EAAE;KAC/B,CAAC;IAEF,MAAM,aAAa,CAAC,OAAO,EAAE,CAAC,EAAE,KAAK,EAAE,MAAM,CAAC,CAAC;IAE/C,MAAM,iBAAiB,GAAG,MAAM,OAAO,CAAC,GAAG,CACzC,KAAK,CAAC,0BAA0B,CAAC,GAAG,CAAC,CAAC,UAAU,EAAE,EAAE,CAClD,wBAAwB,CAAC,UAAU,EAAE,MAAM,CAAC,CAC7C,CACF,CAAC;IACF,MAAM,yBAAyB,GAAG,sBAAsB,CACtD,OAAO,EACP,iBAAiB,EACjB,WAAW,CACZ,CAAC;IACF,MAAM,2BAA2B,GAAG,sB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