@prisma/compute-sdk 0.25.0 → 0.27.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/artifact-stage.d.ts +24 -0
- package/dist/artifact-stage.d.ts.map +1 -0
- package/dist/artifact-stage.js +165 -0
- package/dist/artifact-stage.js.map +1 -0
- package/dist/astro-build.d.ts +2 -0
- package/dist/astro-build.d.ts.map +1 -1
- package/dist/astro-build.js +10 -1
- package/dist/astro-build.js.map +1 -1
- package/dist/auto-build.d.ts +7 -4
- package/dist/auto-build.d.ts.map +1 -1
- package/dist/auto-build.js +25 -33
- package/dist/auto-build.js.map +1 -1
- package/dist/build-settings.d.ts +55 -0
- package/dist/build-settings.d.ts.map +1 -0
- package/dist/build-settings.js +301 -0
- package/dist/build-settings.js.map +1 -0
- package/dist/build-strategy.d.ts +4 -0
- package/dist/build-strategy.d.ts.map +1 -1
- package/dist/build-strategy.js +13 -20
- package/dist/build-strategy.js.map +1 -1
- package/dist/build.d.ts +45 -0
- package/dist/build.d.ts.map +1 -0
- package/dist/build.js +86 -0
- package/dist/build.js.map +1 -0
- package/dist/bun-build.d.ts +8 -0
- package/dist/bun-build.d.ts.map +1 -1
- package/dist/bun-build.js +49 -23
- package/dist/bun-build.js.map +1 -1
- package/dist/config/frameworks.d.ts +8 -1
- package/dist/config/frameworks.d.ts.map +1 -1
- package/dist/config/frameworks.js +28 -0
- package/dist/config/frameworks.js.map +1 -1
- package/dist/config/index.d.ts +1 -1
- package/dist/config/index.d.ts.map +1 -1
- package/dist/config/index.js +1 -1
- package/dist/config/index.js.map +1 -1
- package/dist/index.d.ts +4 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +4 -0
- package/dist/index.js.map +1 -1
- package/dist/nextjs-build.d.ts +12 -2
- package/dist/nextjs-build.d.ts.map +1 -1
- package/dist/nextjs-build.js +158 -76
- package/dist/nextjs-build.js.map +1 -1
- package/dist/nuxt-build.d.ts +2 -0
- package/dist/nuxt-build.d.ts.map +1 -1
- package/dist/nuxt-build.js +10 -1
- package/dist/nuxt-build.js.map +1 -1
- package/dist/tanstack-start-build.d.ts +6 -1
- package/dist/tanstack-start-build.d.ts.map +1 -1
- package/dist/tanstack-start-build.js +39 -16
- package/dist/tanstack-start-build.js.map +1 -1
- package/dist/workspace.d.ts +90 -0
- package/dist/workspace.d.ts.map +1 -0
- package/dist/workspace.js +205 -0
- package/dist/workspace.js.map +1 -0
- package/package.json +4 -3
- package/src/artifact-stage.ts +280 -0
- package/src/astro-build.ts +13 -2
- package/src/auto-build.ts +28 -34
- package/src/build-settings.ts +430 -0
- package/src/build-strategy.ts +22 -29
- package/src/build.ts +124 -0
- package/src/bun-build.ts +62 -27
- package/src/config/frameworks.ts +38 -0
- package/src/config/index.ts +1 -0
- package/src/index.ts +28 -0
- package/src/nextjs-build.ts +208 -104
- package/src/nuxt-build.ts +13 -2
- package/src/tanstack-start-build.ts +48 -19
- package/src/workspace.ts +319 -0
package/dist/nextjs-build.js
CHANGED
|
@@ -1,8 +1,11 @@
|
|
|
1
|
-
import { cp, mkdtemp, readdir, rm, stat } from "node:fs/promises";
|
|
1
|
+
import { cp, mkdtemp, readdir, rm, stat, writeFile } from "node:fs/promises";
|
|
2
2
|
import os from "node:os";
|
|
3
3
|
import path from "node:path";
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
4
|
+
import { stageStandaloneArtifact } from "./artifact-stage.js";
|
|
5
|
+
import { nextOutputRootFromStandaloneDirectory, resolveBuildSettings, } from "./build-settings.js";
|
|
6
|
+
import { hasPackageDependency, hasRootFile } from "./build-strategy.js";
|
|
7
|
+
import { defaultHttpPortForBuildType } from "./config/frameworks.js";
|
|
8
|
+
import { runBuildCommand } from "./workspace.js";
|
|
6
9
|
const NEXT_CONFIG_FILENAMES = [
|
|
7
10
|
"next.config.js",
|
|
8
11
|
"next.config.mjs",
|
|
@@ -10,13 +13,23 @@ const NEXT_CONFIG_FILENAMES = [
|
|
|
10
13
|
"next.config.mts",
|
|
11
14
|
];
|
|
12
15
|
/**
|
|
13
|
-
* Build strategy for Next.js applications
|
|
14
|
-
*
|
|
16
|
+
* Build strategy for Next.js applications. Runs the resolved build command
|
|
17
|
+
* (the user's `package.json` build script, or `next build`), then stages the
|
|
18
|
+
* `output: "standalone"` tree — materializing workspace symlinks and hoisting
|
|
19
|
+
* isolated-store dependencies. Apps built without standalone output fall back
|
|
20
|
+
* to packaging the full tree and serving with `next start`, unless
|
|
21
|
+
* `requireStandalone` is set (a disk-limited deploy target opts out of that).
|
|
15
22
|
*/
|
|
16
23
|
export class NextjsBuild {
|
|
17
24
|
#appPath;
|
|
25
|
+
#buildSettings;
|
|
26
|
+
#io;
|
|
27
|
+
#requireStandalone;
|
|
18
28
|
constructor(options) {
|
|
19
29
|
this.#appPath = options.appPath;
|
|
30
|
+
this.#buildSettings = options.buildSettings;
|
|
31
|
+
this.#io = options.io;
|
|
32
|
+
this.#requireStandalone = options.requireStandalone ?? false;
|
|
20
33
|
}
|
|
21
34
|
async canBuild(signal) {
|
|
22
35
|
return ((await hasRootFile(this.#appPath, NEXT_CONFIG_FILENAMES, signal)) ||
|
|
@@ -24,57 +37,54 @@ export class NextjsBuild {
|
|
|
24
37
|
}
|
|
25
38
|
async execute(signal) {
|
|
26
39
|
signal?.throwIfAborted();
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
40
|
+
const settings = this.#buildSettings ??
|
|
41
|
+
(await resolveBuildSettings({
|
|
42
|
+
appPath: this.#appPath,
|
|
43
|
+
buildType: "nextjs",
|
|
44
|
+
signal,
|
|
45
|
+
}));
|
|
46
|
+
if (settings.buildCommand) {
|
|
47
|
+
await runBuildCommand({
|
|
48
|
+
appPath: this.#appPath,
|
|
49
|
+
command: settings.buildCommand,
|
|
50
|
+
failurePrefix: "Next.js",
|
|
51
|
+
env: this.#io?.env,
|
|
52
|
+
onOutput: this.#io?.onOutput,
|
|
53
|
+
signal,
|
|
54
|
+
});
|
|
55
|
+
}
|
|
56
|
+
const standaloneDir = path.join(this.#appPath, settings.outputDirectory);
|
|
57
|
+
if (!(await directoryExists(standaloneDir))) {
|
|
58
|
+
if (this.#requireStandalone) {
|
|
59
|
+
throw new Error(`Next.js build did not produce standalone output at ${settings.outputDirectory}. ` +
|
|
60
|
+
'Set output: "standalone" in your next.config; this deploy target requires it.');
|
|
61
|
+
}
|
|
62
|
+
// No `output: "standalone"` in next.config: the build succeeded, so
|
|
63
|
+
// package the full tree and serve with `next start`. Bigger artifact,
|
|
64
|
+
// same running app.
|
|
65
|
+
return stageFullTreeFallbackArtifact(this.#appPath, signal);
|
|
39
66
|
}
|
|
40
67
|
const outDir = await mkdtemp(path.join(os.tmpdir(), "compute-build-"));
|
|
41
68
|
try {
|
|
42
69
|
const artifactDir = path.join(outDir, "app");
|
|
43
|
-
await
|
|
44
|
-
|
|
45
|
-
|
|
70
|
+
await stageStandaloneArtifact({
|
|
71
|
+
standaloneDir,
|
|
72
|
+
artifactDir,
|
|
73
|
+
appPath: this.#appPath,
|
|
74
|
+
signal,
|
|
75
|
+
});
|
|
76
|
+
const entrypoint = await findStandaloneEntrypoint(artifactDir);
|
|
77
|
+
await copyStaticAssets({
|
|
78
|
+
appPath: this.#appPath,
|
|
79
|
+
artifactDir,
|
|
80
|
+
outputRoot: nextOutputRootFromStandaloneDirectory(settings.outputDirectory),
|
|
81
|
+
entrypoint,
|
|
82
|
+
signal,
|
|
46
83
|
});
|
|
47
|
-
// In monorepos, Next preserves the workspace-relative path from the
|
|
48
|
-
// workspace root down to the app, so server.js lands at e.g.
|
|
49
|
-
// .next/standalone/apps/web/server.js, not at the standalone root.
|
|
50
|
-
// The runtime needs the correct entrypoint, and Next expects public/
|
|
51
|
-
// and .next/static/ to be siblings of server.js.
|
|
52
|
-
const serverSubpath = await findServerSubpath(artifactDir);
|
|
53
|
-
const serverDir = serverSubpath === undefined
|
|
54
|
-
? artifactDir
|
|
55
|
-
: path.join(artifactDir, serverSubpath);
|
|
56
|
-
const publicDir = path.join(this.#appPath, "public");
|
|
57
|
-
if (await directoryExists(publicDir)) {
|
|
58
|
-
await cp(publicDir, path.join(serverDir, "public"), {
|
|
59
|
-
recursive: true,
|
|
60
|
-
verbatimSymlinks: true,
|
|
61
|
-
});
|
|
62
|
-
}
|
|
63
|
-
const staticDir = path.join(this.#appPath, ".next", "static");
|
|
64
|
-
if (await directoryExists(staticDir)) {
|
|
65
|
-
await cp(staticDir, path.join(serverDir, ".next", "static"), {
|
|
66
|
-
recursive: true,
|
|
67
|
-
verbatimSymlinks: true,
|
|
68
|
-
});
|
|
69
|
-
}
|
|
70
|
-
const entrypoint = serverSubpath === undefined
|
|
71
|
-
? "server.js"
|
|
72
|
-
: path.posix.join(serverSubpath, "server.js");
|
|
73
|
-
await normalizeArtifactSymlinks(artifactDir, this.#appPath, signal);
|
|
74
84
|
return {
|
|
75
85
|
directory: artifactDir,
|
|
76
86
|
entrypoint,
|
|
77
|
-
defaultPortMapping: { http:
|
|
87
|
+
defaultPortMapping: { http: defaultHttpPortForBuildType("nextjs") },
|
|
78
88
|
cleanup: () => rm(outDir, { recursive: true, force: true }),
|
|
79
89
|
};
|
|
80
90
|
}
|
|
@@ -84,44 +94,116 @@ export class NextjsBuild {
|
|
|
84
94
|
}
|
|
85
95
|
}
|
|
86
96
|
}
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
97
|
+
const FULL_TREE_ENTRYPOINT = "prisma-next-start.cjs";
|
|
98
|
+
// Bootstrap for apps built without `output: "standalone"`. Entering through
|
|
99
|
+
// the CLI bin (not `next/dist/server/lib/start-server`) keeps Next in charge
|
|
100
|
+
// of config loading, which is the part that drifts across Next majors.
|
|
101
|
+
const FULL_TREE_START_SOURCE = [
|
|
102
|
+
// The runtime unpacks us at the artifact root, but `next start` resolves
|
|
103
|
+
// `.next` from cwd.
|
|
104
|
+
"process.chdir(__dirname);",
|
|
105
|
+
'process.env.NODE_ENV = "production";',
|
|
106
|
+
'process.argv.push("start", "-p", process.env.PORT ?? "3000");',
|
|
107
|
+
'require("next/dist/bin/next");',
|
|
108
|
+
"",
|
|
109
|
+
].join("\n");
|
|
110
|
+
async function stageFullTreeFallbackArtifact(appPath, signal) {
|
|
111
|
+
const outDir = await mkdtemp(path.join(os.tmpdir(), "compute-build-"));
|
|
112
|
+
try {
|
|
113
|
+
const artifactDir = path.join(outDir, "app");
|
|
114
|
+
// node_modules ships on purpose: without standalone output the artifact
|
|
115
|
+
// must carry the full runtime dependency tree for `next start`.
|
|
116
|
+
signal?.throwIfAborted();
|
|
117
|
+
await cp(appPath, artifactDir, {
|
|
118
|
+
recursive: true,
|
|
119
|
+
// Keep relative symlinks relative (node_modules/.bin/*): the default
|
|
120
|
+
// rewrites them to absolute paths into the source tree, which the
|
|
121
|
+
// archiver rejects as escaping the artifact root.
|
|
122
|
+
verbatimSymlinks: true,
|
|
123
|
+
filter: (source) => !isExcludedFromFullTree(path.basename(source)),
|
|
124
|
+
});
|
|
125
|
+
signal?.throwIfAborted();
|
|
126
|
+
await writeFile(path.join(artifactDir, FULL_TREE_ENTRYPOINT), FULL_TREE_START_SOURCE);
|
|
127
|
+
return {
|
|
128
|
+
directory: artifactDir,
|
|
129
|
+
entrypoint: FULL_TREE_ENTRYPOINT,
|
|
130
|
+
defaultPortMapping: { http: defaultHttpPortForBuildType("nextjs") },
|
|
131
|
+
cleanup: () => rm(outDir, { recursive: true, force: true }),
|
|
132
|
+
};
|
|
133
|
+
}
|
|
134
|
+
catch (error) {
|
|
135
|
+
await rm(outDir, { recursive: true, force: true });
|
|
136
|
+
throw error;
|
|
137
|
+
}
|
|
138
|
+
}
|
|
139
|
+
/** Excludes VCS internals and dotenv files (local secrets, superseded by the deploy env). */
|
|
140
|
+
function isExcludedFromFullTree(basename) {
|
|
141
|
+
return (basename === ".git" || basename === ".env" || basename.startsWith(".env."));
|
|
142
|
+
}
|
|
143
|
+
async function copyStaticAssets(options) {
|
|
144
|
+
const serverSubpath = serverSubpathOf(options.entrypoint);
|
|
145
|
+
const serverDir = serverSubpath
|
|
146
|
+
? path.join(options.artifactDir, serverSubpath)
|
|
147
|
+
: options.artifactDir;
|
|
148
|
+
const publicDir = path.join(options.appPath, "public");
|
|
149
|
+
if (await directoryExists(publicDir)) {
|
|
150
|
+
options.signal?.throwIfAborted();
|
|
151
|
+
await cp(publicDir, path.join(serverDir, "public"), {
|
|
152
|
+
recursive: true,
|
|
153
|
+
verbatimSymlinks: true,
|
|
154
|
+
});
|
|
155
|
+
}
|
|
156
|
+
const staticDir = path.join(options.appPath, options.outputRoot, "static");
|
|
157
|
+
if (await directoryExists(staticDir)) {
|
|
158
|
+
options.signal?.throwIfAborted();
|
|
159
|
+
await cp(staticDir, path.join(serverDir, options.outputRoot, "static"), {
|
|
160
|
+
recursive: true,
|
|
161
|
+
verbatimSymlinks: true,
|
|
162
|
+
});
|
|
163
|
+
}
|
|
90
164
|
}
|
|
91
165
|
/**
|
|
92
|
-
*
|
|
93
|
-
*
|
|
94
|
-
*
|
|
95
|
-
*
|
|
96
|
-
* third-party packages may ship a file named server.js.
|
|
166
|
+
* Locates `server.js` in the staged standalone output. In monorepos Next
|
|
167
|
+
* preserves the workspace-relative path (e.g. `apps/web/server.js`), so the
|
|
168
|
+
* entrypoint is the shallowest match. `node_modules` is skipped because
|
|
169
|
+
* third-party packages may ship their own `server.js`.
|
|
97
170
|
*/
|
|
98
|
-
async function
|
|
99
|
-
const
|
|
100
|
-
|
|
101
|
-
|
|
171
|
+
async function findStandaloneEntrypoint(artifactDir) {
|
|
172
|
+
const rootStat = await stat(path.join(artifactDir, "server.js")).catch(() => null);
|
|
173
|
+
if (rootStat?.isFile()) {
|
|
174
|
+
return "server.js";
|
|
175
|
+
}
|
|
176
|
+
const candidates = [];
|
|
177
|
+
await walk(artifactDir);
|
|
178
|
+
candidates.sort((left, right) => left.split("/").length - right.split("/").length ||
|
|
179
|
+
left.localeCompare(right));
|
|
180
|
+
const selected = candidates[0];
|
|
181
|
+
if (!selected) {
|
|
182
|
+
throw new Error(`Next.js standalone output did not contain server.js in ${artifactDir}`);
|
|
183
|
+
}
|
|
184
|
+
return selected;
|
|
185
|
+
async function walk(directory) {
|
|
186
|
+
const entries = await readdir(directory, { withFileTypes: true });
|
|
102
187
|
for (const entry of entries) {
|
|
103
|
-
if (entry.name === "node_modules")
|
|
188
|
+
if (entry.name === "node_modules") {
|
|
104
189
|
continue;
|
|
105
|
-
|
|
190
|
+
}
|
|
191
|
+
const fullPath = path.join(directory, entry.name);
|
|
106
192
|
if (entry.isDirectory()) {
|
|
107
|
-
|
|
108
|
-
? entry.name
|
|
109
|
-
: path.posix.join(relative, entry.name);
|
|
110
|
-
await walk(fullPath, nextRelative);
|
|
193
|
+
await walk(fullPath);
|
|
111
194
|
}
|
|
112
195
|
else if (entry.isFile() && entry.name === "server.js") {
|
|
113
|
-
|
|
196
|
+
candidates.push(path.relative(artifactDir, fullPath).split(path.sep).join("/"));
|
|
114
197
|
}
|
|
115
198
|
}
|
|
116
199
|
}
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
return matches[0];
|
|
200
|
+
}
|
|
201
|
+
function serverSubpathOf(entrypoint) {
|
|
202
|
+
const dir = path.posix.dirname(entrypoint);
|
|
203
|
+
return dir === "." ? "" : dir;
|
|
204
|
+
}
|
|
205
|
+
async function directoryExists(dirPath) {
|
|
206
|
+
const s = await stat(dirPath).catch(() => null);
|
|
207
|
+
return s?.isDirectory() ?? false;
|
|
126
208
|
}
|
|
127
209
|
//# 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":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AK,CAAC,MAAM,EAAE,IAAI,KAAK,CAAC,IAAI,KAAK,WAAW,EAAE,CAAC;gBACxD,UAAU,CAAC,IAAI,CACb,IAAI,CAAC,QAAQ,CAAC,WAAW,EAAE,QAAQ,CAAC,CAAC,KAAK,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,CAC/D,CAAC;YACJ,CAAC;QACH,CAAC;IACH,CAAC;AACH,CAAC;AAED,SAAS,eAAe,CAAC,UAAkB;IACzC,MAAM,GAAG,GAAG,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,UAAU,CAAC,CAAC;IAC3C,OAAO,GAAG,KAAK,GAAG,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,GAAG,CAAC;AAChC,CAAC;AAED,KAAK,UAAU,eAAe,CAAC,OAAe;IAC5C,MAAM,CAAC,GAAG,MAAM,IAAI,CAAC,OAAO,CAAC,CAAC,KAAK,CAAC,GAAG,EAAE,CAAC,IAAI,CAAC,CAAC;IAChD,OAAO,CAAC,EAAE,WAAW,EAAE,IAAI,KAAK,CAAC;AACnC,CAAC"}
|
package/dist/nuxt-build.d.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import type { BuildArtifact, BuildStrategy } from "./build-strategy.ts";
|
|
2
|
+
import type { BuildCommandIo } from "./workspace.ts";
|
|
2
3
|
/**
|
|
3
4
|
* Build strategy for Nuxt applications using the Nitro `node-server` preset
|
|
4
5
|
* (the default). Runs `nuxt build` and produces an artifact from `.output/`.
|
|
@@ -7,6 +8,7 @@ export declare class NuxtBuild implements BuildStrategy {
|
|
|
7
8
|
#private;
|
|
8
9
|
constructor(options: {
|
|
9
10
|
appPath: string;
|
|
11
|
+
io?: BuildCommandIo;
|
|
10
12
|
});
|
|
11
13
|
canBuild(signal?: AbortSignal): Promise<boolean>;
|
|
12
14
|
execute(signal?: AbortSignal): Promise<BuildArtifact>;
|
package/dist/nuxt-build.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"nuxt-build.d.ts","sourceRoot":"","sources":["../src/nuxt-build.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"nuxt-build.d.ts","sourceRoot":"","sources":["../src/nuxt-build.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,EAAE,aAAa,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAC;AAOxE,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,gBAAgB,CAAC;AAUrD;;;GAGG;AACH,qBAAa,SAAU,YAAW,aAAa;;gBAIjC,OAAO,EAAE;QAAE,OAAO,EAAE,MAAM,CAAC;QAAC,EAAE,CAAC,EAAE,cAAc,CAAA;KAAE;IAKvD,QAAQ,CAAC,MAAM,CAAC,EAAE,WAAW,GAAG,OAAO,CAAC,OAAO,CAAC;IAOhD,OAAO,CAAC,MAAM,CAAC,EAAE,WAAW,GAAG,OAAO,CAAC,aAAa,CAAC;CA8C5D"}
|
package/dist/nuxt-build.js
CHANGED
|
@@ -1,7 +1,9 @@
|
|
|
1
1
|
import { cp, mkdtemp, rm, stat } from "node:fs/promises";
|
|
2
2
|
import os from "node:os";
|
|
3
3
|
import path from "node:path";
|
|
4
|
+
import { normalizeArtifactSymlinks } from "./artifact-postprocess.js";
|
|
4
5
|
import { hasPackageDependency, hasRootFile, runPackageCli, } from "./build-strategy.js";
|
|
6
|
+
import { defaultHttpPortForBuildType } from "./config/frameworks.js";
|
|
5
7
|
const NUXT_CONFIG_FILENAMES = [
|
|
6
8
|
"nuxt.config.js",
|
|
7
9
|
"nuxt.config.mjs",
|
|
@@ -15,8 +17,10 @@ const NUXT_CONFIG_FILENAMES = [
|
|
|
15
17
|
*/
|
|
16
18
|
export class NuxtBuild {
|
|
17
19
|
#appPath;
|
|
20
|
+
#io;
|
|
18
21
|
constructor(options) {
|
|
19
22
|
this.#appPath = options.appPath;
|
|
23
|
+
this.#io = options.io;
|
|
20
24
|
}
|
|
21
25
|
async canBuild(signal) {
|
|
22
26
|
return ((await hasRootFile(this.#appPath, NUXT_CONFIG_FILENAMES, signal)) ||
|
|
@@ -30,6 +34,8 @@ export class NuxtBuild {
|
|
|
30
34
|
args: ["build"],
|
|
31
35
|
failurePrefix: "Nuxt",
|
|
32
36
|
missingMessage: "Could not find the Nuxt CLI. Install it with `npm install nuxt` or ensure npx/bunx is available.",
|
|
37
|
+
env: this.#io?.env,
|
|
38
|
+
onOutput: this.#io?.onOutput,
|
|
33
39
|
signal,
|
|
34
40
|
});
|
|
35
41
|
const outputDir = path.join(this.#appPath, ".output");
|
|
@@ -45,10 +51,13 @@ export class NuxtBuild {
|
|
|
45
51
|
recursive: true,
|
|
46
52
|
verbatimSymlinks: true,
|
|
47
53
|
});
|
|
54
|
+
// Materialize any symlinks into the app/workspace node_modules so the
|
|
55
|
+
// artifact is self-contained once unpacked elsewhere.
|
|
56
|
+
await normalizeArtifactSymlinks(artifactDir, this.#appPath, signal);
|
|
48
57
|
return {
|
|
49
58
|
directory: artifactDir,
|
|
50
59
|
entrypoint: "server/index.mjs",
|
|
51
|
-
defaultPortMapping: { http:
|
|
60
|
+
defaultPortMapping: { http: defaultHttpPortForBuildType("nuxt") },
|
|
52
61
|
cleanup: () => rm(outDir, { recursive: true, force: true }),
|
|
53
62
|
};
|
|
54
63
|
}
|
package/dist/nuxt-build.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"nuxt-build.js","sourceRoot":"","sources":["../src/nuxt-build.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,EAAE,EAAE,OAAO,EAAE,EAAE,EAAE,IAAI,EAAE,MAAM,kBAAkB,CAAC;AACzD,OAAO,EAAE,MAAM,SAAS,CAAC;AACzB,OAAO,IAAI,MAAM,WAAW,CAAC;AAE7B,OAAO,EACL,oBAAoB,EACpB,WAAW,EACX,aAAa,GACd,MAAM,qBAAqB,CAAC;
|
|
1
|
+
{"version":3,"file":"nuxt-build.js","sourceRoot":"","sources":["../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ACJ,CAAC;QAAC,OAAO,KAAK,EAAE,CAAC;YACf,MAAM,EAAE,CAAC,MAAM,EAAE,EAAE,SAAS,EAAE,IAAI,EAAE,KAAK,EAAE,IAAI,EAAE,CAAC,CAAC;YACnD,MAAM,KAAK,CAAC;QACd,CAAC;IACH,CAAC;CACF"}
|
|
@@ -1,12 +1,17 @@
|
|
|
1
|
+
import { type BuildSettings } from "./build-settings.ts";
|
|
1
2
|
import type { BuildArtifact, BuildStrategy } from "./build-strategy.ts";
|
|
3
|
+
import { type BuildCommandIo } from "./workspace.ts";
|
|
2
4
|
/**
|
|
3
5
|
* Build strategy for TanStack Start applications targeting the Nitro node
|
|
4
|
-
* preset. Runs
|
|
6
|
+
* preset. Runs the resolved build command (the user's `package.json` build
|
|
7
|
+
* script, or `vite build`) and produces an artifact from its output directory.
|
|
5
8
|
*/
|
|
6
9
|
export declare class TanstackStartBuild implements BuildStrategy {
|
|
7
10
|
#private;
|
|
8
11
|
constructor(options: {
|
|
9
12
|
appPath: string;
|
|
13
|
+
buildSettings?: BuildSettings;
|
|
14
|
+
io?: BuildCommandIo;
|
|
10
15
|
});
|
|
11
16
|
canBuild(signal?: AbortSignal): Promise<boolean>;
|
|
12
17
|
execute(signal?: AbortSignal): Promise<BuildArtifact>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"tanstack-start-build.d.ts","sourceRoot":"","sources":["../src/tanstack-start-build.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"tanstack-start-build.d.ts","sourceRoot":"","sources":["../src/tanstack-start-build.ts"],"names":[],"mappings":"AAKA,OAAO,EAAE,KAAK,aAAa,EAAwB,MAAM,qBAAqB,CAAC;AAC/E,OAAO,KAAK,EAAE,aAAa,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAC;AAGxE,OAAO,EAAE,KAAK,cAAc,EAAmB,MAAM,gBAAgB,CAAC;AAOtE;;;;GAIG;AACH,qBAAa,kBAAmB,YAAW,aAAa;;gBAK1C,OAAO,EAAE;QACnB,OAAO,EAAE,MAAM,CAAC;QAChB,aAAa,CAAC,EAAE,aAAa,CAAC;QAC9B,EAAE,CAAC,EAAE,cAAc,CAAC;KACrB;IAMK,QAAQ,CAAC,MAAM,CAAC,EAAE,WAAW,GAAG,OAAO,CAAC,OAAO,CAAC;IAIhD,OAAO,CAAC,MAAM,CAAC,EAAE,WAAW,GAAG,OAAO,CAAC,aAAa,CAAC;CAwD5D"}
|
|
@@ -1,38 +1,56 @@
|
|
|
1
1
|
import { cp, mkdtemp, rm, stat } from "node:fs/promises";
|
|
2
2
|
import os from "node:os";
|
|
3
3
|
import path from "node:path";
|
|
4
|
-
import {
|
|
4
|
+
import { normalizeArtifactSymlinks } from "./artifact-postprocess.js";
|
|
5
|
+
import { resolveBuildSettings } from "./build-settings.js";
|
|
6
|
+
import { hasPackageDependency } from "./build-strategy.js";
|
|
7
|
+
import { defaultHttpPortForBuildType } from "./config/frameworks.js";
|
|
8
|
+
import { runBuildCommand } from "./workspace.js";
|
|
5
9
|
const TANSTACK_START_PACKAGES = [
|
|
6
10
|
"@tanstack/react-start",
|
|
7
11
|
"@tanstack/solid-start",
|
|
8
12
|
];
|
|
9
13
|
/**
|
|
10
14
|
* Build strategy for TanStack Start applications targeting the Nitro node
|
|
11
|
-
* preset. Runs
|
|
15
|
+
* preset. Runs the resolved build command (the user's `package.json` build
|
|
16
|
+
* script, or `vite build`) and produces an artifact from its output directory.
|
|
12
17
|
*/
|
|
13
18
|
export class TanstackStartBuild {
|
|
14
19
|
#appPath;
|
|
20
|
+
#buildSettings;
|
|
21
|
+
#io;
|
|
15
22
|
constructor(options) {
|
|
16
23
|
this.#appPath = options.appPath;
|
|
24
|
+
this.#buildSettings = options.buildSettings;
|
|
25
|
+
this.#io = options.io;
|
|
17
26
|
}
|
|
18
27
|
async canBuild(signal) {
|
|
19
28
|
return hasPackageDependency(this.#appPath, TANSTACK_START_PACKAGES, signal);
|
|
20
29
|
}
|
|
21
30
|
async execute(signal) {
|
|
22
31
|
signal?.throwIfAborted();
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
32
|
+
const settings = this.#buildSettings ??
|
|
33
|
+
(await resolveBuildSettings({
|
|
34
|
+
appPath: this.#appPath,
|
|
35
|
+
buildType: "tanstack-start",
|
|
36
|
+
signal,
|
|
37
|
+
}));
|
|
38
|
+
if (settings.buildCommand) {
|
|
39
|
+
await runBuildCommand({
|
|
40
|
+
appPath: this.#appPath,
|
|
41
|
+
command: settings.buildCommand,
|
|
42
|
+
failurePrefix: "TanStack Start",
|
|
43
|
+
env: this.#io?.env,
|
|
44
|
+
onOutput: this.#io?.onOutput,
|
|
45
|
+
signal,
|
|
46
|
+
});
|
|
47
|
+
}
|
|
48
|
+
const outputDir = path.join(this.#appPath, settings.outputDirectory);
|
|
49
|
+
const entrypoint = "server/index.mjs";
|
|
50
|
+
const entryStat = await stat(path.join(outputDir, entrypoint)).catch(() => null);
|
|
34
51
|
if (!entryStat?.isFile()) {
|
|
35
|
-
throw new Error(
|
|
52
|
+
throw new Error(`TanStack Start build did not produce a Nitro node server entrypoint at ${settings.outputDirectory}/${entrypoint}. ` +
|
|
53
|
+
"Ensure your vite.config includes the tanstackStart() and nitro() plugins with the default node preset.");
|
|
36
54
|
}
|
|
37
55
|
const outDir = await mkdtemp(path.join(os.tmpdir(), "compute-build-"));
|
|
38
56
|
try {
|
|
@@ -41,10 +59,15 @@ export class TanstackStartBuild {
|
|
|
41
59
|
recursive: true,
|
|
42
60
|
verbatimSymlinks: true,
|
|
43
61
|
});
|
|
62
|
+
// Materialize any symlinks into the app/workspace node_modules so the
|
|
63
|
+
// artifact is self-contained once unpacked elsewhere.
|
|
64
|
+
await normalizeArtifactSymlinks(artifactDir, this.#appPath, signal);
|
|
44
65
|
return {
|
|
45
66
|
directory: artifactDir,
|
|
46
|
-
entrypoint
|
|
47
|
-
defaultPortMapping: {
|
|
67
|
+
entrypoint,
|
|
68
|
+
defaultPortMapping: {
|
|
69
|
+
http: defaultHttpPortForBuildType("tanstack-start"),
|
|
70
|
+
},
|
|
48
71
|
cleanup: () => rm(outDir, { recursive: true, force: true }),
|
|
49
72
|
};
|
|
50
73
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"tanstack-start-build.js","sourceRoot":"","sources":["../src/tanstack-start-build.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,EAAE,EAAE,OAAO,EAAE,EAAE,EAAE,IAAI,EAAE,MAAM,kBAAkB,CAAC;AACzD,OAAO,EAAE,MAAM,SAAS,CAAC;AACzB,OAAO,IAAI,MAAM,WAAW,CAAC;AAE7B,OAAO,EAAE,oBAAoB,EAAE,
|
|
1
|
+
{"version":3,"file":"tanstack-start-build.js","sourceRoot":"","sources":["../src/tanstack-start-build.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,EAAE,EAAE,OAAO,EAAE,EAAE,EAAE,IAAI,EAAE,MAAM,kBAAkB,CAAC;AACzD,OAAO,EAAE,MAAM,SAAS,CAAC;AACzB,OAAO,IAAI,MAAM,WAAW,CAAC;AAE7B,OAAO,EAAE,yBAAyB,EAAE,MAAM,2BAA2B,CAAC;AACtE,OAAO,EAAsB,oBAAoB,EAAE,MAAM,qBAAqB,CAAC;AAE/E,OAAO,EAAE,oBAAoB,EAAE,MAAM,qBAAqB,CAAC;AAC3D,OAAO,EAAE,2BAA2B,EAAE,MAAM,wBAAwB,CAAC;AACrE,OAAO,EAAuB,eAAe,EAAE,MAAM,gBAAgB,CAAC;AAEtE,MAAM,uBAAuB,GAAG;IAC9B,uBAAuB;IACvB,uBAAuB;CACxB,CAAC;AAEF;;;;GAIG;AACH,MAAM,OAAO,kBAAkB;IACpB,QAAQ,CAAS;IACjB,cAAc,CAAiB;IAC/B,GAAG,CAAkB;IAE9B,YAAY,OAIX;QACC,IAAI,CAAC,Q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ACb,0EAA0E,QAAQ,CAAC,eAAe,IAAI,UAAU,IAAI;gBAClH,wGAAwG,CAC3G,CAAC;QACJ,CAAC;QAED,MAAM,MAAM,GAAG,MAAM,OAAO,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE,CAAC,MAAM,EAAE,EAAE,gBAAgB,CAAC,CAAC,CAAC;QACvE,IAAI,CAAC;YACH,MAAM,WAAW,GAAG,IAAI,CAAC,IAAI,CAAC,MAAM,EAAE,KAAK,CAAC,CAAC;YAC7C,MAAM,EAAE,CAAC,SAAS,EAAE,WAAW,EAAE;gBAC/B,SAAS,EAAE,IAAI;gBACf,gBAAgB,EAAE,IAAI;aACvB,CAAC,CAAC;YACH,sEAAsE;YACtE,sDAAsD;YACtD,MAAM,yBAAyB,CAAC,WAAW,EAAE,IAAI,CAAC,QAAQ,EAAE,MAAM,CAAC,CAAC;YAEpE,OAAO;gBACL,SAAS,EAAE,WAAW;gBACtB,UAAU;gBACV,kBAAkB,EAAE;oBAClB,IAAI,EAAE,2BAA2B,CAAC,gBAAgB,CAAC;iBACpD;gBACD,OAAO,EAAE,GAAG,EAAE,CAAC,EAAE,CAAC,MAAM,EAAE,EAAE,SAAS,EAAE,IAAI,EAAE,KAAK,EAAE,IAAI,EAAE,CAAC;aAC5D,CAAC;QACJ,CAAC;QAAC,OAAO,KAAK,EAAE,CAAC;YACf,MAAM,EAAE,CAAC,MAAM,EAAE,EAAE,SAAS,EAAE,IAAI,EAAE,KAAK,EAAE,IAAI,EAAE,CAAC,CAAC;YACnD,MAAM,KAAK,CAAC;QACd,CAAC;IACH,CAAC;CACF"}
|
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Workspace-aware build primitives shared by the framework strategies. These
|
|
3
|
+
* are location-agnostic: they take an explicit app directory and walk up to
|
|
4
|
+
* the source root (the repository or workspace boundary), so a build invoked
|
|
5
|
+
* from inside a monorepo package resolves the same package manager and
|
|
6
|
+
* binaries it would at the workspace root. Nothing here reads `process.cwd()`
|
|
7
|
+
* or prompts.
|
|
8
|
+
*/
|
|
9
|
+
export type PackageManager = "bun" | "pnpm" | "yarn" | "npm";
|
|
10
|
+
/**
|
|
11
|
+
* Build-environment hooks a consumer threads into a strategy: extra `env` for
|
|
12
|
+
* the build child and a per-line output tap. Both are optional, so the CLI
|
|
13
|
+
* keeps today's behavior while a headless consumer (the build-runner) injects
|
|
14
|
+
* deploy vars and streams a live build log.
|
|
15
|
+
*/
|
|
16
|
+
export interface BuildCommandIo {
|
|
17
|
+
env?: NodeJS.ProcessEnv;
|
|
18
|
+
onOutput?: (line: string, source: "stdout" | "stderr") => void;
|
|
19
|
+
}
|
|
20
|
+
/**
|
|
21
|
+
* Detects the package manager governing `appPath` by walking from the app up
|
|
22
|
+
* to the source root: the nearest `packageManager` field wins, then the
|
|
23
|
+
* nearest lockfile. Workspace repos keep both at the root, so a package
|
|
24
|
+
* deep in a monorepo still resolves correctly. Returns undefined when no
|
|
25
|
+
* signal is found.
|
|
26
|
+
*/
|
|
27
|
+
export declare function resolvePackageManager(appPath: string, signal?: AbortSignal): Promise<PackageManager | undefined>;
|
|
28
|
+
/**
|
|
29
|
+
* Build environment for `appPath`: every `node_modules/.bin` between the app
|
|
30
|
+
* and its source root, prepended to PATH. Workspace repos hoist binaries like
|
|
31
|
+
* `next` to the workspace root, so a build run from a package directory still
|
|
32
|
+
* finds them. The returned object is suitable as the `env` for a child build
|
|
33
|
+
* process.
|
|
34
|
+
*/
|
|
35
|
+
export declare function buildCommandEnv(appPath: string, baseEnv: NodeJS.ProcessEnv, signal?: AbortSignal): Promise<NodeJS.ProcessEnv>;
|
|
36
|
+
/**
|
|
37
|
+
* Runs a build command string inside `appPath`, with every ancestor
|
|
38
|
+
* `node_modules/.bin` on PATH so workspace-hoisted binaries resolve. Rejects
|
|
39
|
+
* with the framework prefix and captured output on a non-zero exit.
|
|
40
|
+
*/
|
|
41
|
+
export declare function runBuildCommand(options: {
|
|
42
|
+
appPath: string;
|
|
43
|
+
command: string;
|
|
44
|
+
failurePrefix: string;
|
|
45
|
+
/**
|
|
46
|
+
* Extra environment merged over `process.env` for the build child (after
|
|
47
|
+
* the ancestor-bin PATH). A headless consumer (e.g. the build-runner) uses
|
|
48
|
+
* this to inject per-branch deploy vars and build flags; the CLI passes none.
|
|
49
|
+
*/
|
|
50
|
+
env?: NodeJS.ProcessEnv;
|
|
51
|
+
/**
|
|
52
|
+
* Per-line tap for build output, called as each line arrives on stdout or
|
|
53
|
+
* stderr. Lets a consumer stream a live build log instead of waiting for the
|
|
54
|
+
* process to exit; the CLI passes none.
|
|
55
|
+
*/
|
|
56
|
+
onOutput?: (line: string, source: "stdout" | "stderr") => void;
|
|
57
|
+
signal?: AbortSignal;
|
|
58
|
+
}): Promise<void>;
|
|
59
|
+
/**
|
|
60
|
+
* Spawns a child build process, streaming each output line to `onOutput` and
|
|
61
|
+
* keeping a bounded tail for the failure message instead of buffering the whole
|
|
62
|
+
* build. Resolves on a zero exit; rejects on a non-zero exit (with the prefix,
|
|
63
|
+
* exit code, and tail) or a spawn error (whose `code`, e.g. ENOENT, is
|
|
64
|
+
* preserved on the rejection so a launcher ladder can branch on it).
|
|
65
|
+
*
|
|
66
|
+
* Shared by `runBuildCommand` (a shell command string) and `runPackageCli`
|
|
67
|
+
* (an explicit binary + args).
|
|
68
|
+
*/
|
|
69
|
+
export declare function runChildProcess(options: {
|
|
70
|
+
command: string;
|
|
71
|
+
args: readonly string[];
|
|
72
|
+
cwd: string;
|
|
73
|
+
env: NodeJS.ProcessEnv;
|
|
74
|
+
shell?: boolean;
|
|
75
|
+
failurePrefix: string;
|
|
76
|
+
onOutput?: (line: string, source: "stdout" | "stderr") => void;
|
|
77
|
+
signal?: AbortSignal;
|
|
78
|
+
}): Promise<void>;
|
|
79
|
+
/** A `package.json`'s build-relevant fields. */
|
|
80
|
+
export interface PackageManifest {
|
|
81
|
+
packageManager?: unknown;
|
|
82
|
+
scripts?: Record<string, unknown>;
|
|
83
|
+
main?: unknown;
|
|
84
|
+
module?: unknown;
|
|
85
|
+
}
|
|
86
|
+
/** Reads and parses `appPath/package.json`, returning null on any failure. */
|
|
87
|
+
export declare function readPackageManifest(appPath: string, signal?: AbortSignal): Promise<PackageManifest | null>;
|
|
88
|
+
/** The trimmed `scripts.build` string, or null when absent or empty. */
|
|
89
|
+
export declare function readBuildScript(manifest: PackageManifest | null): string | null;
|
|
90
|
+
//# sourceMappingURL=workspace.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"workspace.d.ts","sourceRoot":"","sources":["../src/workspace.ts"],"names":[],"mappings":"AAOA;;;;;;;GAOG;AAEH,MAAM,MAAM,cAAc,GAAG,KAAK,GAAG,MAAM,GAAG,MAAM,GAAG,KAAK,CAAC;AAE7D;;;;;GAKG;AACH,MAAM,WAAW,cAAc;IAC7B,GAAG,CAAC,EAAE,MAAM,CAAC,UAAU,CAAC;IACxB,QAAQ,CAAC,EAAE,CAAC,IAAI,EAAE,MAAM,EAAE,MAAM,EAAE,QAAQ,GAAG,QAAQ,KAAK,IAAI,CAAC;CAChE;AAED;;;;;;GAMG;AACH,wBAAsB,qBAAqB,CACzC,OAAO,EAAE,MAAM,EACf,MAAM,CAAC,EAAE,WAAW,GACnB,OAAO,CAAC,cAAc,GAAG,SAAS,CAAC,CA0BrC;AAED;;;;;;GAMG;AACH,wBAAsB,eAAe,CACnC,OAAO,EAAE,MAAM,EACf,OAAO,EAAE,MAAM,CAAC,UAAU,EAC1B,MAAM,CAAC,EAAE,WAAW,GACnB,OAAO,CAAC,MAAM,CAAC,UAAU,CAAC,CAS5B;AAED;;;;GAIG;AACH,wBAAsB,eAAe,CAAC,OAAO,EAAE;IAC7C,OAAO,EAAE,MAAM,CAAC;IAChB,OAAO,EAAE,MAAM,CAAC;IAChB,aAAa,EAAE,MAAM,CAAC;IACtB;;;;OAIG;IACH,GAAG,CAAC,EAAE,MAAM,CAAC,UAAU,CAAC;IACxB;;;;OAIG;IACH,QAAQ,CAA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