@prisma/compute-sdk 0.18.0 → 0.19.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/nextjs-build.d.ts.map +1 -1
- package/dist/nextjs-build.js +52 -4
- package/dist/nextjs-build.js.map +1 -1
- package/package.json +1 -1
- package/src/nextjs-build.ts +68 -4
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"nextjs-build.d.ts","sourceRoot":"","sources":["../src/nextjs-build.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,aAAa,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAC;AAcxE;;;GAGG;AACH,qBAAa,WAAY,YAAW,aAAa;;gBAGnC,OAAO,EAAE;QAAE,OAAO,EAAE,MAAM,CAAA;KAAE;IAIlC,QAAQ,IAAI,OAAO,CAAC,OAAO,CAAC;IAO5B,OAAO,IAAI,OAAO,CAAC,aAAa,CAAC;
|
|
1
|
+
{"version":3,"file":"nextjs-build.d.ts","sourceRoot":"","sources":["../src/nextjs-build.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,aAAa,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAC;AAcxE;;;GAGG;AACH,qBAAa,WAAY,YAAW,aAAa;;gBAGnC,OAAO,EAAE;QAAE,OAAO,EAAE,MAAM,CAAA;KAAE;IAIlC,QAAQ,IAAI,OAAO,CAAC,OAAO,CAAC;IAO5B,OAAO,IAAI,OAAO,CAAC,aAAa,CAAC;CAuExC"}
|
package/dist/nextjs-build.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { cp, mkdtemp, rm, stat } from "node:fs/promises";
|
|
1
|
+
import { cp, mkdtemp, readdir, rm, stat } from "node:fs/promises";
|
|
2
2
|
import os from "node:os";
|
|
3
3
|
import path from "node:path";
|
|
4
4
|
import { hasPackageDependency, hasRootFile, runPackageCli, } from "./build-strategy.js";
|
|
@@ -41,23 +41,35 @@ export class NextjsBuild {
|
|
|
41
41
|
recursive: true,
|
|
42
42
|
verbatimSymlinks: true,
|
|
43
43
|
});
|
|
44
|
+
// In monorepos, Next preserves the workspace-relative path from the
|
|
45
|
+
// workspace root down to the app, so server.js lands at e.g.
|
|
46
|
+
// .next/standalone/apps/web/server.js, not at the standalone root.
|
|
47
|
+
// The runtime needs the correct entrypoint, and Next expects public/
|
|
48
|
+
// and .next/static/ to be siblings of server.js.
|
|
49
|
+
const serverSubpath = await findServerSubpath(artifactDir);
|
|
50
|
+
const serverDir = serverSubpath === undefined
|
|
51
|
+
? artifactDir
|
|
52
|
+
: path.join(artifactDir, serverSubpath);
|
|
44
53
|
const publicDir = path.join(this.#appPath, "public");
|
|
45
54
|
if (await directoryExists(publicDir)) {
|
|
46
|
-
await cp(publicDir, path.join(
|
|
55
|
+
await cp(publicDir, path.join(serverDir, "public"), {
|
|
47
56
|
recursive: true,
|
|
48
57
|
verbatimSymlinks: true,
|
|
49
58
|
});
|
|
50
59
|
}
|
|
51
60
|
const staticDir = path.join(this.#appPath, ".next", "static");
|
|
52
61
|
if (await directoryExists(staticDir)) {
|
|
53
|
-
await cp(staticDir, path.join(
|
|
62
|
+
await cp(staticDir, path.join(serverDir, ".next", "static"), {
|
|
54
63
|
recursive: true,
|
|
55
64
|
verbatimSymlinks: true,
|
|
56
65
|
});
|
|
57
66
|
}
|
|
67
|
+
const entrypoint = serverSubpath === undefined
|
|
68
|
+
? "server.js"
|
|
69
|
+
: path.posix.join(serverSubpath, "server.js");
|
|
58
70
|
return {
|
|
59
71
|
directory: artifactDir,
|
|
60
|
-
entrypoint
|
|
72
|
+
entrypoint,
|
|
61
73
|
defaultPortMapping: { http: 3000 },
|
|
62
74
|
cleanup: () => rm(outDir, { recursive: true, force: true }),
|
|
63
75
|
};
|
|
@@ -72,4 +84,40 @@ async function directoryExists(dirPath) {
|
|
|
72
84
|
const s = await stat(dirPath).catch(() => null);
|
|
73
85
|
return s?.isDirectory() ?? false;
|
|
74
86
|
}
|
|
87
|
+
/**
|
|
88
|
+
* Scan the Next.js standalone output to find the directory that contains
|
|
89
|
+
* server.js, relative to the standalone root. Returns undefined when
|
|
90
|
+
* server.js is at the root (single-app repos) and a posix-joined subpath
|
|
91
|
+
* like "apps/web" for monorepos. node_modules is skipped because
|
|
92
|
+
* third-party packages may ship a file named server.js.
|
|
93
|
+
*/
|
|
94
|
+
async function findServerSubpath(standaloneDir) {
|
|
95
|
+
const matches = [];
|
|
96
|
+
async function walk(currentDir, relative) {
|
|
97
|
+
const entries = await readdir(currentDir, { withFileTypes: true });
|
|
98
|
+
for (const entry of entries) {
|
|
99
|
+
if (entry.name === "node_modules")
|
|
100
|
+
continue;
|
|
101
|
+
const fullPath = path.join(currentDir, entry.name);
|
|
102
|
+
if (entry.isDirectory()) {
|
|
103
|
+
const nextRelative = relative === undefined
|
|
104
|
+
? entry.name
|
|
105
|
+
: path.posix.join(relative, entry.name);
|
|
106
|
+
await walk(fullPath, nextRelative);
|
|
107
|
+
}
|
|
108
|
+
else if (entry.isFile() && entry.name === "server.js") {
|
|
109
|
+
matches.push(relative);
|
|
110
|
+
}
|
|
111
|
+
}
|
|
112
|
+
}
|
|
113
|
+
await walk(standaloneDir, undefined);
|
|
114
|
+
if (matches.length > 1) {
|
|
115
|
+
const locations = matches.map((m) => m ?? "<root>").join(", ");
|
|
116
|
+
throw new Error(`Next.js standalone output has multiple server.js files (${locations}). Cannot determine the application entrypoint.`);
|
|
117
|
+
}
|
|
118
|
+
if (matches.length === 0) {
|
|
119
|
+
throw new Error("Next.js standalone output is missing server.js. The build may not have completed successfully.");
|
|
120
|
+
}
|
|
121
|
+
return matches[0];
|
|
122
|
+
}
|
|
75
123
|
//# sourceMappingURL=nextjs-build.js.map
|
package/dist/nextjs-build.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"nextjs-build.js","sourceRoot":"","sources":["../src/nextjs-build.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,EAAE,EAAE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
|
-
import { cp, mkdtemp, rm, stat } from "node:fs/promises";
|
|
1
|
+
import { cp, mkdtemp, readdir, rm, stat } from "node:fs/promises";
|
|
2
2
|
import os from "node:os";
|
|
3
3
|
import path from "node:path";
|
|
4
4
|
import type { BuildArtifact, BuildStrategy } from "./build-strategy.ts";
|
|
@@ -61,9 +61,20 @@ export class NextjsBuild implements BuildStrategy {
|
|
|
61
61
|
verbatimSymlinks: true,
|
|
62
62
|
});
|
|
63
63
|
|
|
64
|
+
// In monorepos, Next preserves the workspace-relative path from the
|
|
65
|
+
// workspace root down to the app, so server.js lands at e.g.
|
|
66
|
+
// .next/standalone/apps/web/server.js, not at the standalone root.
|
|
67
|
+
// The runtime needs the correct entrypoint, and Next expects public/
|
|
68
|
+
// and .next/static/ to be siblings of server.js.
|
|
69
|
+
const serverSubpath = await findServerSubpath(artifactDir);
|
|
70
|
+
const serverDir =
|
|
71
|
+
serverSubpath === undefined
|
|
72
|
+
? artifactDir
|
|
73
|
+
: path.join(artifactDir, serverSubpath);
|
|
74
|
+
|
|
64
75
|
const publicDir = path.join(this.#appPath, "public");
|
|
65
76
|
if (await directoryExists(publicDir)) {
|
|
66
|
-
await cp(publicDir, path.join(
|
|
77
|
+
await cp(publicDir, path.join(serverDir, "public"), {
|
|
67
78
|
recursive: true,
|
|
68
79
|
verbatimSymlinks: true,
|
|
69
80
|
});
|
|
@@ -71,15 +82,20 @@ export class NextjsBuild implements BuildStrategy {
|
|
|
71
82
|
|
|
72
83
|
const staticDir = path.join(this.#appPath, ".next", "static");
|
|
73
84
|
if (await directoryExists(staticDir)) {
|
|
74
|
-
await cp(staticDir, path.join(
|
|
85
|
+
await cp(staticDir, path.join(serverDir, ".next", "static"), {
|
|
75
86
|
recursive: true,
|
|
76
87
|
verbatimSymlinks: true,
|
|
77
88
|
});
|
|
78
89
|
}
|
|
79
90
|
|
|
91
|
+
const entrypoint =
|
|
92
|
+
serverSubpath === undefined
|
|
93
|
+
? "server.js"
|
|
94
|
+
: path.posix.join(serverSubpath, "server.js");
|
|
95
|
+
|
|
80
96
|
return {
|
|
81
97
|
directory: artifactDir,
|
|
82
|
-
entrypoint
|
|
98
|
+
entrypoint,
|
|
83
99
|
defaultPortMapping: { http: 3000 },
|
|
84
100
|
cleanup: () => rm(outDir, { recursive: true, force: true }),
|
|
85
101
|
};
|
|
@@ -94,3 +110,51 @@ async function directoryExists(dirPath: string): Promise<boolean> {
|
|
|
94
110
|
const s = await stat(dirPath).catch(() => null);
|
|
95
111
|
return s?.isDirectory() ?? false;
|
|
96
112
|
}
|
|
113
|
+
|
|
114
|
+
/**
|
|
115
|
+
* Scan the Next.js standalone output to find the directory that contains
|
|
116
|
+
* server.js, relative to the standalone root. Returns undefined when
|
|
117
|
+
* server.js is at the root (single-app repos) and a posix-joined subpath
|
|
118
|
+
* like "apps/web" for monorepos. node_modules is skipped because
|
|
119
|
+
* third-party packages may ship a file named server.js.
|
|
120
|
+
*/
|
|
121
|
+
async function findServerSubpath(
|
|
122
|
+
standaloneDir: string,
|
|
123
|
+
): Promise<string | undefined> {
|
|
124
|
+
const matches: (string | undefined)[] = [];
|
|
125
|
+
|
|
126
|
+
async function walk(
|
|
127
|
+
currentDir: string,
|
|
128
|
+
relative: string | undefined,
|
|
129
|
+
): Promise<void> {
|
|
130
|
+
const entries = await readdir(currentDir, { withFileTypes: true });
|
|
131
|
+
for (const entry of entries) {
|
|
132
|
+
if (entry.name === "node_modules") continue;
|
|
133
|
+
const fullPath = path.join(currentDir, entry.name);
|
|
134
|
+
if (entry.isDirectory()) {
|
|
135
|
+
const nextRelative =
|
|
136
|
+
relative === undefined
|
|
137
|
+
? entry.name
|
|
138
|
+
: path.posix.join(relative, entry.name);
|
|
139
|
+
await walk(fullPath, nextRelative);
|
|
140
|
+
} else if (entry.isFile() && entry.name === "server.js") {
|
|
141
|
+
matches.push(relative);
|
|
142
|
+
}
|
|
143
|
+
}
|
|
144
|
+
}
|
|
145
|
+
|
|
146
|
+
await walk(standaloneDir, undefined);
|
|
147
|
+
|
|
148
|
+
if (matches.length > 1) {
|
|
149
|
+
const locations = matches.map((m) => m ?? "<root>").join(", ");
|
|
150
|
+
throw new Error(
|
|
151
|
+
`Next.js standalone output has multiple server.js files (${locations}). Cannot determine the application entrypoint.`,
|
|
152
|
+
);
|
|
153
|
+
}
|
|
154
|
+
if (matches.length === 0) {
|
|
155
|
+
throw new Error(
|
|
156
|
+
"Next.js standalone output is missing server.js. The build may not have completed successfully.",
|
|
157
|
+
);
|
|
158
|
+
}
|
|
159
|
+
return matches[0];
|
|
160
|
+
}
|