@prisma/composer 0.23.0-dev.3 → 0.23.0-dev.4
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/dist-DiYPSVUE.mjs +177 -0
- package/dist/dist-DiYPSVUE.mjs.map +1 -0
- package/dist/nextjs-control.mjs +40 -2
- package/dist/nextjs-control.mjs.map +1 -1
- package/dist/node-control.mjs +6 -4
- package/dist/node-control.mjs.map +1 -1
- package/package.json +10 -10
- package/skills/prisma-composer-core-concepts/SKILL.md +1 -1
- package/dist/dist-D1TA1xGC.mjs +0 -70
- package/dist/dist-D1TA1xGC.mjs.map +0 -1
|
@@ -0,0 +1,177 @@
|
|
|
1
|
+
import fs from "node:fs";
|
|
2
|
+
import path from "node:path";
|
|
3
|
+
//#region ../../0-framework/2-authoring/bundle-paths/dist/index.mjs
|
|
4
|
+
/**
|
|
5
|
+
* The path-containment predicate and bundle-link validation shared by every
|
|
6
|
+
* assembly and packaging seam (node/nextjs adapters, the compute artifact
|
|
7
|
+
* writer, the local extractor). This predicate is the enforcement point of
|
|
8
|
+
* ADR-0047's boundary — a symlink may be preserved only while its target
|
|
9
|
+
* stays inside the assembled bundle — so it exists exactly once.
|
|
10
|
+
*
|
|
11
|
+
* Windows cannot create `dir`/`file` symlinks without Developer Mode or an
|
|
12
|
+
* elevated token (`EPERM`). Directory junctions need no such privilege, so
|
|
13
|
+
* assemble uses them on win32; file links fall back to a copy of the target.
|
|
14
|
+
*/
|
|
15
|
+
/** How a platform materializes a bundle link without needing symlink privilege. */
|
|
16
|
+
function bundleLinkStrategy(platform, type) {
|
|
17
|
+
if (platform !== "win32") return "symlink";
|
|
18
|
+
return type === "dir" ? "junction" : "symlink-with-copy-fallback";
|
|
19
|
+
}
|
|
20
|
+
function isNotPermitted(error) {
|
|
21
|
+
return error instanceof Error && Reflect.get(error, "code") === "EPERM";
|
|
22
|
+
}
|
|
23
|
+
/**
|
|
24
|
+
* Creates a link at `linkPath` whose stored target is `target`.
|
|
25
|
+
* `resolvedTarget` is the absolute path of that target in the destination
|
|
26
|
+
* tree — junctions require it. The win32 file-copy fallback reads
|
|
27
|
+
* `copySource` (source-tree path) when set, otherwise `resolvedTarget`, and
|
|
28
|
+
* only when the target exists and stays inside `copyWithinRoot` (ADR-0047:
|
|
29
|
+
* never dereference an escaping link into the artifact).
|
|
30
|
+
*
|
|
31
|
+
* Junction/symlink strategies may temporarily store an escaping
|
|
32
|
+
* `resolvedTarget` (pnpm absolute junctions into the tracing-root store);
|
|
33
|
+
* later staging rewrites them, and `assertBundleSymlinksStayInside` is the
|
|
34
|
+
* final gate. Only the file-copy fallback must refuse escapes — copying would
|
|
35
|
+
* materialize deploy-machine content as a regular file with no link left to
|
|
36
|
+
* validate.
|
|
37
|
+
*/
|
|
38
|
+
async function createBundleLink(linkPath, target, type, options) {
|
|
39
|
+
const strategy = bundleLinkStrategy(options.platform ?? process.platform, type);
|
|
40
|
+
if (strategy === "junction") {
|
|
41
|
+
await fs.promises.symlink(options.resolvedTarget, linkPath, "junction");
|
|
42
|
+
return;
|
|
43
|
+
}
|
|
44
|
+
if (strategy === "symlink") {
|
|
45
|
+
await fs.promises.symlink(target, linkPath, type);
|
|
46
|
+
return;
|
|
47
|
+
}
|
|
48
|
+
try {
|
|
49
|
+
await fs.promises.symlink(target, linkPath, "file");
|
|
50
|
+
} catch (error) {
|
|
51
|
+
if (!isNotPermitted(error)) throw error;
|
|
52
|
+
if (!isWithin(path.resolve(options.copyWithinRoot), path.resolve(options.resolvedTarget))) throw new Error(`refusing to materialize a file link whose target escapes the bundle: ${linkPath} -> ${options.resolvedTarget}`, { cause: error });
|
|
53
|
+
const copyFrom = options.copySource ?? options.resolvedTarget;
|
|
54
|
+
try {
|
|
55
|
+
await fs.promises.stat(copyFrom);
|
|
56
|
+
} catch {
|
|
57
|
+
throw new Error(`the assembled bundle contains a dangling symlink: ${linkPath}`);
|
|
58
|
+
}
|
|
59
|
+
await fs.promises.copyFile(copyFrom, linkPath);
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
/**
|
|
63
|
+
* Map a link's stored target from the source tree into the destination tree.
|
|
64
|
+
* pnpm on Windows often materializes directory links as junctions with absolute
|
|
65
|
+
* targets; copying those verbatim leaves them pointing at the source, which
|
|
66
|
+
* `assertBundleSymlinksStayInside` correctly rejects as an escape.
|
|
67
|
+
*/
|
|
68
|
+
function mapLinkIntoDestination(sourceRoot, destinationRoot, sourcePath, destinationPath, rawTarget) {
|
|
69
|
+
const resolvedSource = path.resolve(path.dirname(sourcePath), rawTarget);
|
|
70
|
+
if (isWithin(sourceRoot, resolvedSource)) {
|
|
71
|
+
const resolvedTarget = path.resolve(destinationRoot, path.relative(sourceRoot, resolvedSource));
|
|
72
|
+
return {
|
|
73
|
+
target: path.relative(path.dirname(destinationPath), resolvedTarget),
|
|
74
|
+
resolvedTarget
|
|
75
|
+
};
|
|
76
|
+
}
|
|
77
|
+
return {
|
|
78
|
+
target: rawTarget,
|
|
79
|
+
resolvedTarget: path.resolve(path.dirname(destinationPath), rawTarget)
|
|
80
|
+
};
|
|
81
|
+
}
|
|
82
|
+
/** Restores directory-link metadata lost by `fs.cp` on Windows. */
|
|
83
|
+
async function repairWindowsDirectorySymlinks(root) {
|
|
84
|
+
if (process.platform !== "win32") return;
|
|
85
|
+
const visit = async (directory) => {
|
|
86
|
+
for (const entry of await fs.promises.readdir(directory, { withFileTypes: true })) {
|
|
87
|
+
const full = path.join(directory, entry.name);
|
|
88
|
+
if (entry.isSymbolicLink()) {
|
|
89
|
+
const target = await fs.promises.readlink(full);
|
|
90
|
+
if (path.isAbsolute(target)) continue;
|
|
91
|
+
const resolvedTarget = path.resolve(path.dirname(full), target);
|
|
92
|
+
if (!isWithin(root, resolvedTarget)) continue;
|
|
93
|
+
try {
|
|
94
|
+
if (!(await fs.promises.stat(resolvedTarget)).isDirectory()) continue;
|
|
95
|
+
} catch {
|
|
96
|
+
continue;
|
|
97
|
+
}
|
|
98
|
+
await fs.promises.unlink(full);
|
|
99
|
+
await createBundleLink(full, target, "dir", {
|
|
100
|
+
resolvedTarget,
|
|
101
|
+
copyWithinRoot: root
|
|
102
|
+
});
|
|
103
|
+
} else if (entry.isDirectory()) await visit(full);
|
|
104
|
+
}
|
|
105
|
+
};
|
|
106
|
+
await visit(root);
|
|
107
|
+
}
|
|
108
|
+
/** Copy without `fs.cp`'s symlink privilege requirement: real files first, then links. */
|
|
109
|
+
async function copyTreeVerbatimWalk(source, destination) {
|
|
110
|
+
const sourceRoot = path.resolve(source);
|
|
111
|
+
const destinationRoot = path.resolve(destination);
|
|
112
|
+
const links = [];
|
|
113
|
+
const copyNonLinks = async (sourceDir, destinationDir) => {
|
|
114
|
+
await fs.promises.mkdir(destinationDir, { recursive: true });
|
|
115
|
+
for (const entry of await fs.promises.readdir(sourceDir, { withFileTypes: true })) {
|
|
116
|
+
const sourcePath = path.join(sourceDir, entry.name);
|
|
117
|
+
const destinationPath = path.join(destinationDir, entry.name);
|
|
118
|
+
if (entry.isSymbolicLink()) links.push({
|
|
119
|
+
sourcePath,
|
|
120
|
+
destinationPath
|
|
121
|
+
});
|
|
122
|
+
else if (entry.isDirectory()) await copyNonLinks(sourcePath, destinationPath);
|
|
123
|
+
else if (entry.isFile()) await fs.promises.copyFile(sourcePath, destinationPath);
|
|
124
|
+
}
|
|
125
|
+
};
|
|
126
|
+
await copyNonLinks(source, destination);
|
|
127
|
+
for (const { sourcePath, destinationPath } of links) {
|
|
128
|
+
const rawTarget = await fs.promises.readlink(sourcePath);
|
|
129
|
+
const resolvedSource = path.resolve(path.dirname(sourcePath), rawTarget);
|
|
130
|
+
let type = "file";
|
|
131
|
+
try {
|
|
132
|
+
type = (await fs.promises.stat(resolvedSource)).isDirectory() ? "dir" : "file";
|
|
133
|
+
} catch {}
|
|
134
|
+
const mapped = mapLinkIntoDestination(sourceRoot, destinationRoot, sourcePath, destinationPath, rawTarget);
|
|
135
|
+
await fs.promises.mkdir(path.dirname(destinationPath), { recursive: true });
|
|
136
|
+
await createBundleLink(destinationPath, mapped.target, type, {
|
|
137
|
+
resolvedTarget: mapped.resolvedTarget,
|
|
138
|
+
copySource: resolvedSource,
|
|
139
|
+
copyWithinRoot: destinationRoot
|
|
140
|
+
});
|
|
141
|
+
}
|
|
142
|
+
}
|
|
143
|
+
async function copyTreeVerbatim(source, destination) {
|
|
144
|
+
await copyTreeVerbatimWalk(source, destination);
|
|
145
|
+
}
|
|
146
|
+
/** Lexical containment: `candidate` is `root` itself or below it. Both paths
|
|
147
|
+
* must already be absolute or share a resolution base; no filesystem access. */
|
|
148
|
+
function isWithin(root, candidate) {
|
|
149
|
+
const relative = path.relative(root, candidate);
|
|
150
|
+
return relative === "" || !relative.startsWith(`..${path.sep}`) && relative !== ".." && !path.isAbsolute(relative);
|
|
151
|
+
}
|
|
152
|
+
/** Walks the assembled bundle and rejects a dangling symlink or one whose
|
|
153
|
+
* resolved target escapes the bundle root. Symlinked directories are not
|
|
154
|
+
* descended: their targets are validated, and their contents belong to the
|
|
155
|
+
* target's own location. */
|
|
156
|
+
async function assertBundleSymlinksStayInside(bundleDir) {
|
|
157
|
+
const realRoot = await fs.promises.realpath(bundleDir);
|
|
158
|
+
const walk = async (directory) => {
|
|
159
|
+
for (const entry of await fs.promises.readdir(directory, { withFileTypes: true })) {
|
|
160
|
+
const full = path.join(directory, entry.name);
|
|
161
|
+
if (entry.isSymbolicLink()) {
|
|
162
|
+
let realTarget;
|
|
163
|
+
try {
|
|
164
|
+
realTarget = await fs.promises.realpath(full);
|
|
165
|
+
} catch {
|
|
166
|
+
throw new Error(`the assembled bundle contains a dangling symlink: ${full}`);
|
|
167
|
+
}
|
|
168
|
+
if (!isWithin(realRoot, realTarget)) throw new Error(`the assembled bundle contains a symlink whose target escapes the bundle: ${full} -> ${await fs.promises.readlink(full)}`);
|
|
169
|
+
} else if (entry.isDirectory()) await walk(full);
|
|
170
|
+
}
|
|
171
|
+
};
|
|
172
|
+
await walk(bundleDir);
|
|
173
|
+
}
|
|
174
|
+
//#endregion
|
|
175
|
+
export { repairWindowsDirectorySymlinks as a, isWithin as i, copyTreeVerbatim as n, createBundleLink as r, assertBundleSymlinksStayInside as t };
|
|
176
|
+
|
|
177
|
+
//# sourceMappingURL=dist-DiYPSVUE.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"dist-DiYPSVUE.mjs","names":[],"sources":["../../../0-framework/2-authoring/bundle-paths/dist/index.mjs"],"sourcesContent":["import fs from \"node:fs\";\nimport path from \"node:path\";\n//#region src/bundle-paths.ts\n/**\n* The path-containment predicate and bundle-link validation shared by every\n* assembly and packaging seam (node/nextjs adapters, the compute artifact\n* writer, the local extractor). This predicate is the enforcement point of\n* ADR-0047's boundary — a symlink may be preserved only while its target\n* stays inside the assembled bundle — so it exists exactly once.\n*\n* Windows cannot create `dir`/`file` symlinks without Developer Mode or an\n* elevated token (`EPERM`). Directory junctions need no such privilege, so\n* assemble uses them on win32; file links fall back to a copy of the target.\n*/\n/** How a platform materializes a bundle link without needing symlink privilege. */\nfunction bundleLinkStrategy(platform, type) {\n\tif (platform !== \"win32\") return \"symlink\";\n\treturn type === \"dir\" ? \"junction\" : \"symlink-with-copy-fallback\";\n}\nfunction isNotPermitted(error) {\n\treturn error instanceof Error && Reflect.get(error, \"code\") === \"EPERM\";\n}\n/**\n* Creates a link at `linkPath` whose stored target is `target`.\n* `resolvedTarget` is the absolute path of that target in the destination\n* tree — junctions require it. The win32 file-copy fallback reads\n* `copySource` (source-tree path) when set, otherwise `resolvedTarget`, and\n* only when the target exists and stays inside `copyWithinRoot` (ADR-0047:\n* never dereference an escaping link into the artifact).\n*\n* Junction/symlink strategies may temporarily store an escaping\n* `resolvedTarget` (pnpm absolute junctions into the tracing-root store);\n* later staging rewrites them, and `assertBundleSymlinksStayInside` is the\n* final gate. Only the file-copy fallback must refuse escapes — copying would\n* materialize deploy-machine content as a regular file with no link left to\n* validate.\n*/\nasync function createBundleLink(linkPath, target, type, options) {\n\tconst strategy = bundleLinkStrategy(options.platform ?? process.platform, type);\n\tif (strategy === \"junction\") {\n\t\tawait fs.promises.symlink(options.resolvedTarget, linkPath, \"junction\");\n\t\treturn;\n\t}\n\tif (strategy === \"symlink\") {\n\t\tawait fs.promises.symlink(target, linkPath, type);\n\t\treturn;\n\t}\n\ttry {\n\t\tawait fs.promises.symlink(target, linkPath, \"file\");\n\t} catch (error) {\n\t\tif (!isNotPermitted(error)) throw error;\n\t\tif (!isWithin(path.resolve(options.copyWithinRoot), path.resolve(options.resolvedTarget))) throw new Error(`refusing to materialize a file link whose target escapes the bundle: ${linkPath} -> ${options.resolvedTarget}`, { cause: error });\n\t\tconst copyFrom = options.copySource ?? options.resolvedTarget;\n\t\ttry {\n\t\t\tawait fs.promises.stat(copyFrom);\n\t\t} catch {\n\t\t\tthrow new Error(`the assembled bundle contains a dangling symlink: ${linkPath}`);\n\t\t}\n\t\tawait fs.promises.copyFile(copyFrom, linkPath);\n\t}\n}\n/**\n* Map a link's stored target from the source tree into the destination tree.\n* pnpm on Windows often materializes directory links as junctions with absolute\n* targets; copying those verbatim leaves them pointing at the source, which\n* `assertBundleSymlinksStayInside` correctly rejects as an escape.\n*/\nfunction mapLinkIntoDestination(sourceRoot, destinationRoot, sourcePath, destinationPath, rawTarget) {\n\tconst resolvedSource = path.resolve(path.dirname(sourcePath), rawTarget);\n\tif (isWithin(sourceRoot, resolvedSource)) {\n\t\tconst resolvedTarget = path.resolve(destinationRoot, path.relative(sourceRoot, resolvedSource));\n\t\treturn {\n\t\t\ttarget: path.relative(path.dirname(destinationPath), resolvedTarget),\n\t\t\tresolvedTarget\n\t\t};\n\t}\n\treturn {\n\t\ttarget: rawTarget,\n\t\tresolvedTarget: path.resolve(path.dirname(destinationPath), rawTarget)\n\t};\n}\n/** Restores directory-link metadata lost by `fs.cp` on Windows. */\nasync function repairWindowsDirectorySymlinks(root) {\n\tif (process.platform !== \"win32\") return;\n\tconst visit = async (directory) => {\n\t\tfor (const entry of await fs.promises.readdir(directory, { withFileTypes: true })) {\n\t\t\tconst full = path.join(directory, entry.name);\n\t\t\tif (entry.isSymbolicLink()) {\n\t\t\t\tconst target = await fs.promises.readlink(full);\n\t\t\t\tif (path.isAbsolute(target)) continue;\n\t\t\t\tconst resolvedTarget = path.resolve(path.dirname(full), target);\n\t\t\t\tif (!isWithin(root, resolvedTarget)) continue;\n\t\t\t\ttry {\n\t\t\t\t\tif (!(await fs.promises.stat(resolvedTarget)).isDirectory()) continue;\n\t\t\t\t} catch {\n\t\t\t\t\tcontinue;\n\t\t\t\t}\n\t\t\t\tawait fs.promises.unlink(full);\n\t\t\t\tawait createBundleLink(full, target, \"dir\", {\n\t\t\t\t\tresolvedTarget,\n\t\t\t\t\tcopyWithinRoot: root\n\t\t\t\t});\n\t\t\t} else if (entry.isDirectory()) await visit(full);\n\t\t}\n\t};\n\tawait visit(root);\n}\n/** Copy without `fs.cp`'s symlink privilege requirement: real files first, then links. */\nasync function copyTreeVerbatimWalk(source, destination) {\n\tconst sourceRoot = path.resolve(source);\n\tconst destinationRoot = path.resolve(destination);\n\tconst links = [];\n\tconst copyNonLinks = async (sourceDir, destinationDir) => {\n\t\tawait fs.promises.mkdir(destinationDir, { recursive: true });\n\t\tfor (const entry of await fs.promises.readdir(sourceDir, { withFileTypes: true })) {\n\t\t\tconst sourcePath = path.join(sourceDir, entry.name);\n\t\t\tconst destinationPath = path.join(destinationDir, entry.name);\n\t\t\tif (entry.isSymbolicLink()) links.push({\n\t\t\t\tsourcePath,\n\t\t\t\tdestinationPath\n\t\t\t});\n\t\t\telse if (entry.isDirectory()) await copyNonLinks(sourcePath, destinationPath);\n\t\t\telse if (entry.isFile()) await fs.promises.copyFile(sourcePath, destinationPath);\n\t\t}\n\t};\n\tawait copyNonLinks(source, destination);\n\tfor (const { sourcePath, destinationPath } of links) {\n\t\tconst rawTarget = await fs.promises.readlink(sourcePath);\n\t\tconst resolvedSource = path.resolve(path.dirname(sourcePath), rawTarget);\n\t\tlet type = \"file\";\n\t\ttry {\n\t\t\ttype = (await fs.promises.stat(resolvedSource)).isDirectory() ? \"dir\" : \"file\";\n\t\t} catch {}\n\t\tconst mapped = mapLinkIntoDestination(sourceRoot, destinationRoot, sourcePath, destinationPath, rawTarget);\n\t\tawait fs.promises.mkdir(path.dirname(destinationPath), { recursive: true });\n\t\tawait createBundleLink(destinationPath, mapped.target, type, {\n\t\t\tresolvedTarget: mapped.resolvedTarget,\n\t\t\tcopySource: resolvedSource,\n\t\t\tcopyWithinRoot: destinationRoot\n\t\t});\n\t}\n}\nasync function copyTreeVerbatim(source, destination) {\n\tawait copyTreeVerbatimWalk(source, destination);\n}\n/** Lexical containment: `candidate` is `root` itself or below it. Both paths\n* must already be absolute or share a resolution base; no filesystem access. */\nfunction isWithin(root, candidate) {\n\tconst relative = path.relative(root, candidate);\n\treturn relative === \"\" || !relative.startsWith(`..${path.sep}`) && relative !== \"..\" && !path.isAbsolute(relative);\n}\n/** Walks the assembled bundle and rejects a dangling symlink or one whose\n* resolved target escapes the bundle root. Symlinked directories are not\n* descended: their targets are validated, and their contents belong to the\n* target's own location. */\nasync function assertBundleSymlinksStayInside(bundleDir) {\n\tconst realRoot = await fs.promises.realpath(bundleDir);\n\tconst walk = async (directory) => {\n\t\tfor (const entry of await fs.promises.readdir(directory, { withFileTypes: true })) {\n\t\t\tconst full = path.join(directory, entry.name);\n\t\t\tif (entry.isSymbolicLink()) {\n\t\t\t\tlet realTarget;\n\t\t\t\ttry {\n\t\t\t\t\trealTarget = await fs.promises.realpath(full);\n\t\t\t\t} catch {\n\t\t\t\t\tthrow new Error(`the assembled bundle contains a dangling symlink: ${full}`);\n\t\t\t\t}\n\t\t\t\tif (!isWithin(realRoot, realTarget)) throw new Error(`the assembled bundle contains a symlink whose target escapes the bundle: ${full} -> ${await fs.promises.readlink(full)}`);\n\t\t\t} else if (entry.isDirectory()) await walk(full);\n\t\t}\n\t};\n\tawait walk(bundleDir);\n}\n//#endregion\nexport { assertBundleSymlinksStayInside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AK,WAAW,QAAQ;AAClH;;;;;AAKA,eAAe,+BAA+B,WAAW;CACxD,MAAM,WAAW,MAAM,GAAG,SAAS,SAAS,SAAS;CACrD,MAAM,OAAO,OAAO,cAAc;EACjC,KAAK,MAAM,SAAS,MAAM,GAAG,SAAS,QAAQ,WAAW,EAAE,eAAe,KAAK,CAAC,GAAG;GAClF,MAAM,OAAO,KAAK,KAAK,WAAW,MAAM,IAAI;GAC5C,IAAI,MAAM,eAAe,GAAG;IAC3B,IAAI;IACJ,IAAI;KACH,aAAa,MAAM,GAAG,SAAS,SAAS,IAAI;IAC7C,QAAQ;KACP,MAAM,IAAI,MAAM,qDAAqD,MAAM;IAC5E;IACA,IAAI,CAAC,SAAS,UAAU,UAAU,GAAG,MAAM,IAAI,MAAM,4EAA4E,KAAK,MAAM,MAAM,GAAG,SAAS,SAAS,IAAI,GAAG;GAC/K,OAAO,IAAI,MAAM,YAAY,GAAG,MAAM,KAAK,IAAI;EAChD;CACD;CACA,MAAM,KAAK,SAAS;AACrB"}
|
package/dist/nextjs-control.mjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { a as repairWindowsDirectorySymlinks, i as isWithin, n as copyTreeVerbatim, r as createBundleLink, t as assertBundleSymlinksStayInside } from "./dist-DiYPSVUE.mjs";
|
|
2
2
|
import * as fs$1 from "node:fs";
|
|
3
3
|
import * as path$1 from "node:path";
|
|
4
4
|
import { fileURLToPath } from "node:url";
|
|
@@ -100,7 +100,6 @@ async function missingLinkTargets(bundleDir) {
|
|
|
100
100
|
const missing = [];
|
|
101
101
|
for (const linkPath of await collectSymlinks(bundleDir)) {
|
|
102
102
|
const rawTarget = await fs$1.promises.readlink(linkPath);
|
|
103
|
-
if (path$1.isAbsolute(rawTarget)) continue;
|
|
104
103
|
const target = path$1.resolve(path$1.dirname(linkPath), rawTarget);
|
|
105
104
|
if (!isWithin(bundleDir, target) || await lstatIfPresent(target) !== void 0) continue;
|
|
106
105
|
if (await hasSymlinkAncestor(bundleDir, target)) continue;
|
|
@@ -109,6 +108,44 @@ async function missingLinkTargets(bundleDir) {
|
|
|
109
108
|
return missing;
|
|
110
109
|
}
|
|
111
110
|
/**
|
|
111
|
+
* Absolute junctions (pnpm on Windows) often point from `.next/standalone`
|
|
112
|
+
* straight into the app's `node_modules/.pnpm/...` under the tracing root —
|
|
113
|
+
* outside the standalone copy root. After `copyTreeVerbatim` those links still
|
|
114
|
+
* escape the assembled bundle; stage the real target under the bundle at the
|
|
115
|
+
* same tracing-root-relative path and repoint the link.
|
|
116
|
+
*/
|
|
117
|
+
async function stageEscapingTracingRootLinks(bundleDir, tracedRootReal) {
|
|
118
|
+
const nodeModulesRoot = path$1.join(tracedRootReal, "node_modules");
|
|
119
|
+
const stagedSources = /* @__PURE__ */ new Set();
|
|
120
|
+
for (const linkPath of await collectSymlinks(bundleDir)) {
|
|
121
|
+
const rawTarget = await fs$1.promises.readlink(linkPath);
|
|
122
|
+
let resolved = path$1.resolve(path$1.dirname(linkPath), rawTarget);
|
|
123
|
+
if (await lstatIfPresent(resolved) === void 0) continue;
|
|
124
|
+
try {
|
|
125
|
+
resolved = await fs$1.promises.realpath(resolved);
|
|
126
|
+
} catch {
|
|
127
|
+
continue;
|
|
128
|
+
}
|
|
129
|
+
if (isWithin(bundleDir, resolved)) continue;
|
|
130
|
+
if (!isWithin(nodeModulesRoot, resolved) && resolved !== nodeModulesRoot) continue;
|
|
131
|
+
const stagedAt = path$1.join(bundleDir, path$1.relative(tracedRootReal, resolved));
|
|
132
|
+
if (await lstatIfPresent(stagedAt) === void 0) {
|
|
133
|
+
await fs$1.promises.mkdir(path$1.dirname(stagedAt), { recursive: true });
|
|
134
|
+
if ((await fs$1.promises.stat(resolved)).isDirectory()) await copyTreeVerbatim(resolved, stagedAt);
|
|
135
|
+
else await fs$1.promises.copyFile(resolved, stagedAt);
|
|
136
|
+
stagedSources.add(resolved);
|
|
137
|
+
}
|
|
138
|
+
const type = (await fs$1.promises.stat(stagedAt)).isDirectory() ? "dir" : "file";
|
|
139
|
+
await fs$1.promises.unlink(linkPath);
|
|
140
|
+
await createBundleLink(linkPath, path$1.relative(path$1.dirname(linkPath), stagedAt), type, {
|
|
141
|
+
resolvedTarget: stagedAt,
|
|
142
|
+
copySource: stagedAt,
|
|
143
|
+
copyWithinRoot: bundleDir
|
|
144
|
+
});
|
|
145
|
+
}
|
|
146
|
+
return [...stagedSources];
|
|
147
|
+
}
|
|
148
|
+
/**
|
|
112
149
|
* pnpm can leave a traced hoist link in standalone while omitting the virtual-
|
|
113
150
|
* store directory it targets. The same target still exists at the corresponding
|
|
114
151
|
* path under outputFileTracingRoot. Stage only that exact, real in-root target;
|
|
@@ -137,6 +174,7 @@ async function stageMissingStandaloneLinkTargets(bundleDir, manifest) {
|
|
|
137
174
|
staged = true;
|
|
138
175
|
}
|
|
139
176
|
}
|
|
177
|
+
for (const source of await stageEscapingTracingRootLinks(bundleDir, tracedRootReal)) stagedSources.add(source);
|
|
140
178
|
return [...stagedSources];
|
|
141
179
|
}
|
|
142
180
|
/** The built standalone server.js for a nextjs build — `appDir`'s standalone root plus the app subpath Next recorded. Single-sourced so `assemble()` (deploy) and the integration-test seam can't drift. */
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"nextjs-control.mjs","names":["path","fs"],"sources":["../../../0-framework/2-authoring/nextjs/dist/control.mjs"],"sourcesContent":["import * as fs from \"node:fs\";\nimport * as path from \"node:path\";\nimport { fileURLToPath } from \"node:url\";\nimport { assertBundleSymlinksStayInside, copyTreeVerbatim, isWithin, repairWindowsDirectorySymlinks } from \"@internal/bundle-paths\";\nimport { build } from \"esbuild\";\n//#region src/control/build.ts\n/**\n* The extension's control entry (ADR-0017): `nextjsBuild()` returns the build\n* descriptor `prisma-composer.config.ts` lists. Deploy-only (ADR-0005): the user\n* runs `next build` (`output: \"standalone\"`); `assemble` then performs the\n* *documented* Next standalone deploy — it ships the standalone tree and copies\n* in the client assets Next deliberately omits (`.next/static`, `public/`) — and\n* adds the framework's boot wrapper. This is the canonical `cp` step from the\n* Next docs, run at deploy so no app needs a build-script for it.\n*\n* It does not guess: the app's location inside the standalone tree (deep, when\n* `outputFileTracingRoot` is the monorepo root) is *read from Next's own build\n* manifest* (`.next/required-server-files.json`'s `relativeAppDir`), never walked\n* for or computed from a hardcoded depth. It does not launder: node_modules is\n* shipped exactly as `next build` produced it. The packager preserves a link\n* only after resolving its target inside the assembled bundle, and rejects\n* escaping links. When Next records an in-root package link but omits its target\n* from standalone (seen with pnpm's virtual store), assembly stages that exact\n* target from `outputFileTracingRoot` so the artifact remains self-contained.\n*\n* Artifact layout: `<workDir>/main.mjs` (our wrapper) + `<workDir>/bundle/`\n* (the standalone tree, with static/public copied in). The packager adds\n* `bootstrap.js` + the manifest at the root; bootstrap imports main.mjs, whose\n* run() dynamically imports `./bundle/<relativeAppDir>/server.js`.\n*\n* Paths are file-relative (ADR-0004): `appDir` resolves against\n* `dirname(build.module)`.\n*/\n/** Narrows the shared BuildAdapter to this extension's own descriptor — the value-level mirror of the registry routing on (extension, type). */\nfunction isNextjsBuild(descriptor) {\n\treturn descriptor.type === \"nextjs\" && \"appDir\" in descriptor && typeof descriptor.appDir === \"string\";\n}\nfunction readServerFilesManifest(appDir) {\n\tconst manifestPath = path.join(appDir, \".next\", \"required-server-files.json\");\n\tif (!fs.existsSync(manifestPath)) throw new Error(`no ${path.join(\".next\", \"required-server-files.json\")} under ${appDir} — run \\`next build\\` with output: \"standalone\" first.`);\n\tconst manifest = JSON.parse(fs.readFileSync(manifestPath, \"utf8\"));\n\tconst relativeAppDir = manifest?.relativeAppDir;\n\tconst tracingRoot = manifest?.config?.outputFileTracingRoot;\n\treturn {\n\t\tpath: manifestPath,\n\t\trelativeAppDir: typeof relativeAppDir === \"string\" ? relativeAppDir : void 0,\n\t\ttracingRoot: typeof tracingRoot === \"string\" ? path.resolve(appDir, tracingRoot) : void 0\n\t};\n}\n/**\n* The app's own subpath within `.next/standalone`, as an OS-relative path. Next\n* mirrors the app's location under `outputFileTracingRoot` (deep, when that's the\n* monorepo root); rather than walk the tree for `server.js`, we read where Next\n* put it from `.next/required-server-files.json` — `relativeAppDir` is exactly\n* that subpath. Older Next lacks the field; fall back to computing it from the\n* same manifest's `config.outputFileTracingRoot`.\n*/\nfunction appRelFrom(manifest, appDir) {\n\tconst posixRel = manifest.relativeAppDir ?? (manifest.tracingRoot === void 0 ? void 0 : path.relative(manifest.tracingRoot, appDir).split(path.sep).join(\"/\"));\n\tif (posixRel === void 0) throw new Error(`${manifest.path} records neither relativeAppDir nor config.outputFileTracingRoot — cannot locate the standalone server`);\n\tconst rel = posixRel.split(\"/\").join(path.sep);\n\tif (path.isAbsolute(rel) || !isWithin(appDir, path.join(appDir, rel))) throw new Error(`${manifest.path} records an app location that escapes its tracing root (${posixRel}) — refusing to stage outside the bundle`);\n\treturn rel;\n}\nasync function lstatIfPresent(candidate) {\n\ttry {\n\t\treturn await fs.promises.lstat(candidate);\n\t} catch (error) {\n\t\tif (error instanceof Error && Reflect.get(error, \"code\") === \"ENOENT\") return void 0;\n\t\tthrow error;\n\t}\n}\n/** Do not write through an existing link while repairing a missing target. */\nasync function hasSymlinkAncestor(root, candidate) {\n\tconst relative = path.relative(root, path.dirname(candidate));\n\tlet cursor = root;\n\tfor (const segment of relative.split(path.sep).filter(Boolean)) {\n\t\tcursor = path.join(cursor, segment);\n\t\tconst stat = await lstatIfPresent(cursor);\n\t\tif (stat === void 0) return false;\n\t\tif (stat.isSymbolicLink()) return true;\n\t}\n\treturn false;\n}\nasync function collectSymlinks(root) {\n\tconst links = [];\n\tasync function visit(directory) {\n\t\tfor (const entry of await fs.promises.readdir(directory, { withFileTypes: true })) {\n\t\t\tconst entryPath = path.join(directory, entry.name);\n\t\t\tif (entry.isSymbolicLink()) links.push(entryPath);\n\t\t\telse if (entry.isDirectory()) await visit(entryPath);\n\t\t}\n\t}\n\tawait visit(root);\n\treturn links;\n}\n/** In-bundle link targets that the standalone tree does not contain — the\n* repairs staging has to make. */\nasync function missingLinkTargets(bundleDir) {\n\tconst missing = [];\n\tfor (const linkPath of await collectSymlinks(bundleDir)) {\n\t\tconst rawTarget = await fs.promises.readlink(linkPath);\n\t\tif (path.isAbsolute(rawTarget)) continue;\n\t\tconst target = path.resolve(path.dirname(linkPath), rawTarget);\n\t\tif (!isWithin(bundleDir, target) || await lstatIfPresent(target) !== void 0) continue;\n\t\tif (await hasSymlinkAncestor(bundleDir, target)) continue;\n\t\tmissing.push(target);\n\t}\n\treturn missing;\n}\n/**\n* pnpm can leave a traced hoist link in standalone while omitting the virtual-\n* store directory it targets. The same target still exists at the corresponding\n* path under outputFileTracingRoot. Stage only that exact, real in-root target;\n* unsafe or genuinely unavailable links remain for the packager to reject.\n*/\nasync function stageMissingStandaloneLinkTargets(bundleDir, manifest) {\n\tconst tracingRoot = manifest.tracingRoot;\n\tif (tracingRoot === void 0) {\n\t\tif ((await missingLinkTargets(bundleDir)).length === 0) return [];\n\t\tthrow new Error(`${manifest.path} records no config.outputFileTracingRoot, but the standalone tree contains symlinks whose targets Next omitted — the source root those targets must be staged from is unknown. Rebuild with a Next version that records config.outputFileTracingRoot, or set outputFileTracingRoot in next.config.`);\n\t}\n\tif (await lstatIfPresent(tracingRoot) === void 0) return [];\n\tconst tracedRootReal = await fs.promises.realpath(tracingRoot);\n\tconst stagedSources = /* @__PURE__ */ new Set();\n\tlet staged = true;\n\twhile (staged) {\n\t\tstaged = false;\n\t\tfor (const target of await missingLinkTargets(bundleDir)) {\n\t\t\tconst standaloneRelative = path.relative(bundleDir, target);\n\t\t\tconst source = path.resolve(tracingRoot, standaloneRelative);\n\t\t\tif (await lstatIfPresent(source) === void 0) continue;\n\t\t\tif (!isWithin(tracedRootReal, await fs.promises.realpath(source))) continue;\n\t\t\tawait fs.promises.mkdir(path.dirname(target), { recursive: true });\n\t\t\tawait copyTreeVerbatim(source, target);\n\t\t\tstagedSources.add(source);\n\t\t\tstaged = true;\n\t\t}\n\t}\n\treturn [...stagedSources];\n}\n/** The built standalone server.js for a nextjs build — `appDir`'s standalone root plus the app subpath Next recorded. Single-sourced so `assemble()` (deploy) and the integration-test seam can't drift. */\nfunction standaloneServerPath(build) {\n\tconst appDir = path.resolve(path.dirname(fileURLToPath(build.module)), build.appDir);\n\tconst manifest = readServerFilesManifest(appDir);\n\treturn path.join(appDir, \".next\", \"standalone\", appRelFrom(manifest, appDir), \"server.js\");\n}\nasync function assemble(input) {\n\tif (!isNextjsBuild(input.build)) throw new Error(`@prisma/composer/nextjs/control: expected a \"nextjs\" build adapter (with appDir), got \"${input.build.type}\".`);\n\tconst buildDescriptor = input.build;\n\tconst appDir = path.resolve(path.dirname(fileURLToPath(buildDescriptor.module)), buildDescriptor.appDir);\n\tconst standaloneRoot = path.join(appDir, \".next\", \"standalone\");\n\tif (!fs.existsSync(standaloneRoot)) throw new Error(`no ${path.join(\".next\", \"standalone\")} under ${appDir} — run \\`next build\\` with output: \"standalone\" first.`);\n\tconst manifest = readServerFilesManifest(appDir);\n\tconst appRel = appRelFrom(manifest, appDir);\n\tconst workDir = path.join(input.cwd, \".prisma-composer\", \"artifacts\", input.address);\n\tawait fs.promises.rm(workDir, {\n\t\trecursive: true,\n\t\tforce: true\n\t});\n\tawait fs.promises.mkdir(workDir, { recursive: true });\n\tconst bundleDir = path.join(workDir, \"bundle\");\n\tawait copyTreeVerbatim(standaloneRoot, bundleDir);\n\tconst stagedLinkTargets = await stageMissingStandaloneLinkTargets(bundleDir, manifest);\n\tawait repairWindowsDirectorySymlinks(bundleDir);\n\tconst appOut = path.join(bundleDir, appRel);\n\tconst staticSrc = path.join(appDir, \".next\", \"static\");\n\tif (fs.existsSync(staticSrc)) await copyTreeVerbatim(staticSrc, path.join(appOut, \".next\", \"static\"));\n\tconst publicSrc = path.join(appDir, \"public\");\n\tif (fs.existsSync(publicSrc)) await copyTreeVerbatim(publicSrc, path.join(appOut, \"public\"));\n\tawait assertBundleSymlinksStayInside(bundleDir);\n\tawait build({\n\t\tentryPoints: { main: fileURLToPath(buildDescriptor.module) },\n\t\toutdir: workDir,\n\t\tbundle: true,\n\t\tformat: \"esm\",\n\t\tplatform: \"node\",\n\t\texternal: [\"bun\", \"bun:*\"],\n\t\toutExtension: { \".js\": \".mjs\" }\n\t});\n\tif (!fs.existsSync(path.join(workDir, \"main.mjs\"))) throw new Error(`esbuild produced no main.mjs in ${workDir}`);\n\treturn {\n\t\tdir: workDir,\n\t\tentry: path.posix.join(\"bundle\", appRel.split(path.sep).join(\"/\"), \"server.js\"),\n\t\twatch: [standaloneRoot, ...stagedLinkTargets]\n\t};\n}\n/** The nextjs build extension descriptor — `prisma-composer.config.ts` lists it under `extensions`. */\nconst nextjsBuild = () => ({\n\tid: \"@prisma/composer/nextjs\",\n\tnodes: { nextjs: {\n\t\tkind: \"build\",\n\t\tassemble\n\t} }\n});\n//#endregion\nexport { assemble, nextjsBuild, standaloneServerPath };\n\n//# sourceMappingURL=control.mjs.map"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAkCA,SAAS,cAAc,YAAY;CAClC,OAAO,WAAW,SAAS,YAAY,YAAY,cAAc,OAAO,WAAW,WAAW;AAC/F;AACA,SAAS,wBAAwB,QAAQ;CACxC,MAAM,eAAeA,OAAK,KAAK,QAAQ,SAAS,4BAA4B;CAC5E,IAAI,CAACC,KAAG,WAAW,YAAY,GAAG,MAAM,IAAI,MAAM,MAAMD,OAAK,KAAK,SAAS,4BAA4B,EAAE,SAAS,OAAO,uDAAuD;CAChL,MAAM,WAAW,KAAK,MAAMC,KAAG,aAAa,cAAc,MAAM,CAAC;CACjE,MAAM,iBAAiB,UAAU;CACjC,MAAM,cAAc,UAAU,QAAQ;CACtC,OAAO;EACN,MAAM;EACN,gBAAgB,OAAO,mBAAmB,WAAW,iBAAiB,KAAK;EAC3E,aAAa,OAAO,gBAAgB,WAAWD,OAAK,QAAQ,QAAQ,WAAW,IAAI,KAAK;CACzF;AACD;;;;;;;;;AASA,SAAS,WAA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,SAAS;CAChD,MAAM,oBAAoB,MAAM,kCAAkC,WAAW,QAAQ;CACrF,MAAM,+BAA+B,SAAS;CAC9C,MAAM,SAASA,OAAK,KAAK,WAAW,MAAM;CAC1C,MAAM,YAAYA,OAAK,KAAK,QAAQ,SAAS,QAAQ;CACrD,IAAIC,KAAG,WAAW,SAAS,GAAG,MAAM,iBAAiB,WAAWD,OAAK,KAAK,QAAQ,SAAS,QAAQ,CAAC;CACpG,MAAM,YAAYA,OAAK,KAAK,QAAQ,QAAQ;CAC5C,IAAIC,KAAG,WAAW,SAAS,GAAG,MAAM,iBAAiB,WAAWD,OAAK,KAAK,QAAQ,QAAQ,CAAC;CAC3F,MAAM,+BAA+B,SAAS;CAC9C,MAAM,MAAM;EACX,aAAa,EAAE,MAAM,cAAc,gBAAgB,MAAM,EAAE;EAC3D,QAAQ;EACR,QAAQ;EACR,QAAQ;EACR,UAAU;EACV,UAAU,CAAC,OAAO,OAAO;EACzB,cAAc,EAAE,OAAO,OAAO;CAC/B,CAAC;CACD,IAAI,CAACC,KAAG,WAAWD,OAAK,KAAK,SAAS,UAAU,CAAC,GAAG,MAAM,IAAI,MAAM,mCAAmC,SAAS;CAChH,OAAO;EACN,KAAK;EACL,OAAOA,OAAK,MAAM,KAAK,UAAU,OAAO,MAAMA,OAAK,GAAG,CAAC,CAAC,KAAK,GAAG,GAAG,WAAW;EAC9E,OAAO,CAAC,gBAAgB,GAAG,iBAAiB;CAC7C;AACD;;AAEA,MAAM,qBAAqB;CAC1B,IAAI;CACJ,OAAO,EAAE,QAAQ;EAChB,MAAM;EACN;CACD,EAAE;AACH"}
|
|
1
|
+
{"version":3,"file":"nextjs-control.mjs","names":["path","fs"],"sources":["../../../0-framework/2-authoring/nextjs/dist/control.mjs"],"sourcesContent":["import * as fs from \"node:fs\";\nimport * as path from \"node:path\";\nimport { fileURLToPath } from \"node:url\";\nimport { assertBundleSymlinksStayInside, copyTreeVerbatim, createBundleLink, isWithin, repairWindowsDirectorySymlinks } from \"@internal/bundle-paths\";\nimport { build } from \"esbuild\";\n//#region src/control/build.ts\n/**\n* The extension's control entry (ADR-0017): `nextjsBuild()` returns the build\n* descriptor `prisma-composer.config.ts` lists. Deploy-only (ADR-0005): the user\n* runs `next build` (`output: \"standalone\"`); `assemble` then performs the\n* *documented* Next standalone deploy — it ships the standalone tree and copies\n* in the client assets Next deliberately omits (`.next/static`, `public/`) — and\n* adds the framework's boot wrapper. This is the canonical `cp` step from the\n* Next docs, run at deploy so no app needs a build-script for it.\n*\n* It does not guess: the app's location inside the standalone tree (deep, when\n* `outputFileTracingRoot` is the monorepo root) is *read from Next's own build\n* manifest* (`.next/required-server-files.json`'s `relativeAppDir`), never walked\n* for or computed from a hardcoded depth. It does not launder: node_modules is\n* shipped exactly as `next build` produced it. The packager preserves a link\n* only after resolving its target inside the assembled bundle, and rejects\n* escaping links. When Next records an in-root package link but omits its target\n* from standalone (seen with pnpm's virtual store), assembly stages that exact\n* target from `outputFileTracingRoot` so the artifact remains self-contained.\n*\n* Artifact layout: `<workDir>/main.mjs` (our wrapper) + `<workDir>/bundle/`\n* (the standalone tree, with static/public copied in). The packager adds\n* `bootstrap.js` + the manifest at the root; bootstrap imports main.mjs, whose\n* run() dynamically imports `./bundle/<relativeAppDir>/server.js`.\n*\n* Paths are file-relative (ADR-0004): `appDir` resolves against\n* `dirname(build.module)`.\n*/\n/** Narrows the shared BuildAdapter to this extension's own descriptor — the value-level mirror of the registry routing on (extension, type). */\nfunction isNextjsBuild(descriptor) {\n\treturn descriptor.type === \"nextjs\" && \"appDir\" in descriptor && typeof descriptor.appDir === \"string\";\n}\nfunction readServerFilesManifest(appDir) {\n\tconst manifestPath = path.join(appDir, \".next\", \"required-server-files.json\");\n\tif (!fs.existsSync(manifestPath)) throw new Error(`no ${path.join(\".next\", \"required-server-files.json\")} under ${appDir} — run \\`next build\\` with output: \"standalone\" first.`);\n\tconst manifest = JSON.parse(fs.readFileSync(manifestPath, \"utf8\"));\n\tconst relativeAppDir = manifest?.relativeAppDir;\n\tconst tracingRoot = manifest?.config?.outputFileTracingRoot;\n\treturn {\n\t\tpath: manifestPath,\n\t\trelativeAppDir: typeof relativeAppDir === \"string\" ? relativeAppDir : void 0,\n\t\ttracingRoot: typeof tracingRoot === \"string\" ? path.resolve(appDir, tracingRoot) : void 0\n\t};\n}\n/**\n* The app's own subpath within `.next/standalone`, as an OS-relative path. Next\n* mirrors the app's location under `outputFileTracingRoot` (deep, when that's the\n* monorepo root); rather than walk the tree for `server.js`, we read where Next\n* put it from `.next/required-server-files.json` — `relativeAppDir` is exactly\n* that subpath. Older Next lacks the field; fall back to computing it from the\n* same manifest's `config.outputFileTracingRoot`.\n*/\nfunction appRelFrom(manifest, appDir) {\n\tconst posixRel = manifest.relativeAppDir ?? (manifest.tracingRoot === void 0 ? void 0 : path.relative(manifest.tracingRoot, appDir).split(path.sep).join(\"/\"));\n\tif (posixRel === void 0) throw new Error(`${manifest.path} records neither relativeAppDir nor config.outputFileTracingRoot — cannot locate the standalone server`);\n\tconst rel = posixRel.split(\"/\").join(path.sep);\n\tif (path.isAbsolute(rel) || !isWithin(appDir, path.join(appDir, rel))) throw new Error(`${manifest.path} records an app location that escapes its tracing root (${posixRel}) — refusing to stage outside the bundle`);\n\treturn rel;\n}\nasync function lstatIfPresent(candidate) {\n\ttry {\n\t\treturn await fs.promises.lstat(candidate);\n\t} catch (error) {\n\t\tif (error instanceof Error && Reflect.get(error, \"code\") === \"ENOENT\") return void 0;\n\t\tthrow error;\n\t}\n}\n/** Do not write through an existing link while repairing a missing target. */\nasync function hasSymlinkAncestor(root, candidate) {\n\tconst relative = path.relative(root, path.dirname(candidate));\n\tlet cursor = root;\n\tfor (const segment of relative.split(path.sep).filter(Boolean)) {\n\t\tcursor = path.join(cursor, segment);\n\t\tconst stat = await lstatIfPresent(cursor);\n\t\tif (stat === void 0) return false;\n\t\tif (stat.isSymbolicLink()) return true;\n\t}\n\treturn false;\n}\nasync function collectSymlinks(root) {\n\tconst links = [];\n\tasync function visit(directory) {\n\t\tfor (const entry of await fs.promises.readdir(directory, { withFileTypes: true })) {\n\t\t\tconst entryPath = path.join(directory, entry.name);\n\t\t\tif (entry.isSymbolicLink()) links.push(entryPath);\n\t\t\telse if (entry.isDirectory()) await visit(entryPath);\n\t\t}\n\t}\n\tawait visit(root);\n\treturn links;\n}\n/** In-bundle link targets that the standalone tree does not contain — the\n* repairs staging has to make. */\nasync function missingLinkTargets(bundleDir) {\n\tconst missing = [];\n\tfor (const linkPath of await collectSymlinks(bundleDir)) {\n\t\tconst rawTarget = await fs.promises.readlink(linkPath);\n\t\tconst target = path.resolve(path.dirname(linkPath), rawTarget);\n\t\tif (!isWithin(bundleDir, target) || await lstatIfPresent(target) !== void 0) continue;\n\t\tif (await hasSymlinkAncestor(bundleDir, target)) continue;\n\t\tmissing.push(target);\n\t}\n\treturn missing;\n}\n/**\n* Absolute junctions (pnpm on Windows) often point from `.next/standalone`\n* straight into the app's `node_modules/.pnpm/...` under the tracing root —\n* outside the standalone copy root. After `copyTreeVerbatim` those links still\n* escape the assembled bundle; stage the real target under the bundle at the\n* same tracing-root-relative path and repoint the link.\n*/\nasync function stageEscapingTracingRootLinks(bundleDir, tracedRootReal) {\n\tconst nodeModulesRoot = path.join(tracedRootReal, \"node_modules\");\n\tconst stagedSources = /* @__PURE__ */ new Set();\n\tfor (const linkPath of await collectSymlinks(bundleDir)) {\n\t\tconst rawTarget = await fs.promises.readlink(linkPath);\n\t\tlet resolved = path.resolve(path.dirname(linkPath), rawTarget);\n\t\tif (await lstatIfPresent(resolved) === void 0) continue;\n\t\ttry {\n\t\t\tresolved = await fs.promises.realpath(resolved);\n\t\t} catch {\n\t\t\tcontinue;\n\t\t}\n\t\tif (isWithin(bundleDir, resolved)) continue;\n\t\tif (!isWithin(nodeModulesRoot, resolved) && resolved !== nodeModulesRoot) continue;\n\t\tconst stagedAt = path.join(bundleDir, path.relative(tracedRootReal, resolved));\n\t\tif (await lstatIfPresent(stagedAt) === void 0) {\n\t\t\tawait fs.promises.mkdir(path.dirname(stagedAt), { recursive: true });\n\t\t\tif ((await fs.promises.stat(resolved)).isDirectory()) await copyTreeVerbatim(resolved, stagedAt);\n\t\t\telse await fs.promises.copyFile(resolved, stagedAt);\n\t\t\tstagedSources.add(resolved);\n\t\t}\n\t\tconst type = (await fs.promises.stat(stagedAt)).isDirectory() ? \"dir\" : \"file\";\n\t\tawait fs.promises.unlink(linkPath);\n\t\tawait createBundleLink(linkPath, path.relative(path.dirname(linkPath), stagedAt), type, {\n\t\t\tresolvedTarget: stagedAt,\n\t\t\tcopySource: stagedAt,\n\t\t\tcopyWithinRoot: bundleDir\n\t\t});\n\t}\n\treturn [...stagedSources];\n}\n/**\n* pnpm can leave a traced hoist link in standalone while omitting the virtual-\n* store directory it targets. The same target still exists at the corresponding\n* path under outputFileTracingRoot. Stage only that exact, real in-root target;\n* unsafe or genuinely unavailable links remain for the packager to reject.\n*/\nasync function stageMissingStandaloneLinkTargets(bundleDir, manifest) {\n\tconst tracingRoot = manifest.tracingRoot;\n\tif (tracingRoot === void 0) {\n\t\tif ((await missingLinkTargets(bundleDir)).length === 0) return [];\n\t\tthrow new Error(`${manifest.path} records no config.outputFileTracingRoot, but the standalone tree contains symlinks whose targets Next omitted — the source root those targets must be staged from is unknown. Rebuild with a Next version that records config.outputFileTracingRoot, or set outputFileTracingRoot in next.config.`);\n\t}\n\tif (await lstatIfPresent(tracingRoot) === void 0) return [];\n\tconst tracedRootReal = await fs.promises.realpath(tracingRoot);\n\tconst stagedSources = /* @__PURE__ */ new Set();\n\tlet staged = true;\n\twhile (staged) {\n\t\tstaged = false;\n\t\tfor (const target of await missingLinkTargets(bundleDir)) {\n\t\t\tconst standaloneRelative = path.relative(bundleDir, target);\n\t\t\tconst source = path.resolve(tracingRoot, standaloneRelative);\n\t\t\tif (await lstatIfPresent(source) === void 0) continue;\n\t\t\tif (!isWithin(tracedRootReal, await fs.promises.realpath(source))) continue;\n\t\t\tawait fs.promises.mkdir(path.dirname(target), { recursive: true });\n\t\t\tawait copyTreeVerbatim(source, target);\n\t\t\tstagedSources.add(source);\n\t\t\tstaged = true;\n\t\t}\n\t}\n\tfor (const source of await stageEscapingTracingRootLinks(bundleDir, tracedRootReal)) stagedSources.add(source);\n\treturn [...stagedSources];\n}\n/** The built standalone server.js for a nextjs build — `appDir`'s standalone root plus the app subpath Next recorded. Single-sourced so `assemble()` (deploy) and the integration-test seam can't drift. */\nfunction standaloneServerPath(build) {\n\tconst appDir = path.resolve(path.dirname(fileURLToPath(build.module)), build.appDir);\n\tconst manifest = readServerFilesManifest(appDir);\n\treturn path.join(appDir, \".next\", \"standalone\", appRelFrom(manifest, appDir), \"server.js\");\n}\nasync function assemble(input) {\n\tif (!isNextjsBuild(input.build)) throw new Error(`@prisma/composer/nextjs/control: expected a \"nextjs\" build adapter (with appDir), got \"${input.build.type}\".`);\n\tconst buildDescriptor = input.build;\n\tconst appDir = path.resolve(path.dirname(fileURLToPath(buildDescriptor.module)), buildDescriptor.appDir);\n\tconst standaloneRoot = path.join(appDir, \".next\", \"standalone\");\n\tif (!fs.existsSync(standaloneRoot)) throw new Error(`no ${path.join(\".next\", \"standalone\")} under ${appDir} — run \\`next build\\` with output: \"standalone\" first.`);\n\tconst manifest = readServerFilesManifest(appDir);\n\tconst appRel = appRelFrom(manifest, appDir);\n\tconst workDir = path.join(input.cwd, \".prisma-composer\", \"artifacts\", input.address);\n\tawait fs.promises.rm(workDir, {\n\t\trecursive: true,\n\t\tforce: true\n\t});\n\tawait fs.promises.mkdir(workDir, { recursive: true });\n\tconst bundleDir = path.join(workDir, \"bundle\");\n\tawait copyTreeVerbatim(standaloneRoot, bundleDir);\n\tconst stagedLinkTargets = await stageMissingStandaloneLinkTargets(bundleDir, manifest);\n\tawait repairWindowsDirectorySymlinks(bundleDir);\n\tconst appOut = path.join(bundleDir, appRel);\n\tconst staticSrc = path.join(appDir, \".next\", \"static\");\n\tif (fs.existsSync(staticSrc)) await copyTreeVerbatim(staticSrc, path.join(appOut, \".next\", \"static\"));\n\tconst publicSrc = path.join(appDir, \"public\");\n\tif (fs.existsSync(publicSrc)) await copyTreeVerbatim(publicSrc, path.join(appOut, \"public\"));\n\tawait assertBundleSymlinksStayInside(bundleDir);\n\tawait build({\n\t\tentryPoints: { main: fileURLToPath(buildDescriptor.module) },\n\t\toutdir: workDir,\n\t\tbundle: true,\n\t\tformat: \"esm\",\n\t\tplatform: \"node\",\n\t\texternal: [\"bun\", \"bun:*\"],\n\t\toutExtension: { \".js\": \".mjs\" }\n\t});\n\tif (!fs.existsSync(path.join(workDir, \"main.mjs\"))) throw new Error(`esbuild produced no main.mjs in ${workDir}`);\n\treturn {\n\t\tdir: workDir,\n\t\tentry: path.posix.join(\"bundle\", appRel.split(path.sep).join(\"/\"), \"server.js\"),\n\t\twatch: [standaloneRoot, ...stagedLinkTargets]\n\t};\n}\n/** The nextjs build extension descriptor — `prisma-composer.config.ts` lists it under `extensions`. */\nconst nextjsBuild = () => ({\n\tid: \"@prisma/composer/nextjs\",\n\tnodes: { nextjs: {\n\t\tkind: \"build\",\n\t\tassemble\n\t} }\n});\n//#endregion\nexport { assemble, nextjsBuild, standaloneServerPath };\n\n//# sourceMappingURL=control.mjs.map"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAkCA,SAAS,cAAc,YAAY;CAClC,OAAO,WAAW,SAAS,YAAY,YAAY,cAAc,OAAO,WAAW,WAAW;AAC/F;AACA,SAAS,wBAAwB,QAAQ;CACxC,MAAM,eAAeA,OAAK,KAAK,QAAQ,SAAS,4BAA4B;CAC5E,IAAI,CAACC,KAAG,WAAW,YAAY,GAAG,MAAM,IAAI,MAAM,MAAMD,OAAK,KAAK,SAAS,4BAA4B,EAAE,SAAS,OAAO,uDAAuD;CAChL,MAAM,WAAW,KAAK,MAAMC,KAAG,aAAa,cAAc,MAAM,CAAC;CACjE,MAAM,iBAAiB,UAAU;CACjC,MAAM,cAAc,UAAU,QAAQ;CACtC,OAAO;EACN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import { n as copyTreeVerbatim, r as
|
|
1
|
+
import { i as isWithin, n as copyTreeVerbatim, r as createBundleLink, t as assertBundleSymlinksStayInside } from "./dist-DiYPSVUE.mjs";
|
|
2
2
|
import { createRequire } from "node:module";
|
|
3
3
|
import * as fs$1 from "node:fs";
|
|
4
4
|
import * as path$1 from "node:path";
|
|
@@ -21783,9 +21783,11 @@ async function copyTracedEntry(source, destination, stagingRoot, bundleDir, dirP
|
|
|
21783
21783
|
const realTarget = await fs$1.promises.realpath(source);
|
|
21784
21784
|
if (!isWithin(stagingRoot, realTarget)) throw new Error(`the runtime dependency trace found a symlink outside its staging root: ${source} -> ${realTarget}`);
|
|
21785
21785
|
const stagedTarget = isWithin(dirPath, realTarget) ? path$1.join(bundleDir, path$1.relative(dirPath, realTarget)) : stagedRuntimePath(realTarget, stagingRoot, bundleDir);
|
|
21786
|
-
|
|
21787
|
-
|
|
21788
|
-
|
|
21786
|
+
await createBundleLink(destination, path$1.relative(path$1.dirname(destination), stagedTarget), (await fs$1.promises.stat(realTarget)).isDirectory() ? "dir" : "file", {
|
|
21787
|
+
resolvedTarget: stagedTarget,
|
|
21788
|
+
copySource: realTarget,
|
|
21789
|
+
copyWithinRoot: bundleDir
|
|
21790
|
+
});
|
|
21789
21791
|
return;
|
|
21790
21792
|
}
|
|
21791
21793
|
if (stat.isDirectory()) {
|