@prisma/compute-sdk 0.47.0 → 0.49.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/README.md +38 -18
- package/dist/errors.d.ts +2 -2
- package/dist/errors.d.ts.map +1 -1
- package/dist/errors.js +1 -1
- package/dist/errors.js.map +1 -1
- package/dist/service/build/build-service.d.ts +3 -3
- package/dist/service/build/build-service.d.ts.map +1 -1
- package/dist/service/build/build-service.js +32 -15
- package/dist/service/build/build-service.js.map +1 -1
- package/dist/service/build/{build-output.d.ts → output-directories.d.ts} +3 -3
- package/dist/service/build/output-directories.d.ts.map +1 -0
- package/dist/service/build/{build-output.js → output-directories.js} +2 -2
- package/dist/service/build/output-directories.js.map +1 -0
- package/dist/service/index.d.ts +3 -3
- package/dist/service/index.d.ts.map +1 -1
- package/dist/service/index.js +3 -3
- package/dist/service/index.js.map +1 -1
- package/dist/service/launcher-contract/start-plan.d.ts +3 -3
- package/dist/service/launcher-contract/start-plan.d.ts.map +1 -1
- package/dist/service/launcher-contract/start-plan.js +3 -3
- package/dist/service/launcher-contract/start-plan.js.map +1 -1
- package/dist/service/output/build-output.d.ts +47 -0
- package/dist/service/output/build-output.d.ts.map +1 -0
- package/dist/service/output/build-output.js +97 -0
- package/dist/service/output/build-output.js.map +1 -0
- package/dist/service/output/copy.d.ts +15 -0
- package/dist/service/output/copy.d.ts.map +1 -0
- package/dist/service/output/copy.js +59 -0
- package/dist/service/output/copy.js.map +1 -0
- package/dist/service/output/entrypoint.d.ts +20 -0
- package/dist/service/output/entrypoint.d.ts.map +1 -0
- package/dist/service/output/entrypoint.js +183 -0
- package/dist/service/output/entrypoint.js.map +1 -0
- package/dist/service/output/exclude.d.ts +6 -0
- package/dist/service/output/exclude.d.ts.map +1 -0
- package/dist/service/{artifact → output}/exclude.js +2 -2
- package/dist/service/output/exclude.js.map +1 -0
- package/dist/service/output/launcher-file.d.ts +3 -0
- package/dist/service/output/launcher-file.d.ts.map +1 -0
- package/dist/service/{artifact → output}/launcher-file.js +1 -1
- package/dist/service/output/launcher-file.js.map +1 -0
- package/dist/service/output/source-files.d.ts +12 -0
- package/dist/service/output/source-files.d.ts.map +1 -0
- package/dist/service/output/source-files.js +46 -0
- package/dist/service/output/source-files.js.map +1 -0
- package/dist/service/output/trace/bins.d.ts +9 -0
- package/dist/service/output/trace/bins.d.ts.map +1 -0
- package/dist/service/output/trace/bins.js +26 -0
- package/dist/service/output/trace/bins.js.map +1 -0
- package/dist/service/output/trace/imports.d.ts +8 -0
- package/dist/service/output/trace/imports.d.ts.map +1 -0
- package/dist/service/output/trace/imports.js +24 -0
- package/dist/service/output/trace/imports.js.map +1 -0
- package/dist/service/output/trace/optional-peer-dependencies.d.ts +13 -0
- package/dist/service/output/trace/optional-peer-dependencies.d.ts.map +1 -0
- package/dist/service/output/trace/optional-peer-dependencies.js +34 -0
- package/dist/service/output/trace/optional-peer-dependencies.js.map +1 -0
- package/dist/service/output/trace/packages.d.ts +22 -0
- package/dist/service/output/trace/packages.d.ts.map +1 -0
- package/dist/service/output/trace/packages.js +50 -0
- package/dist/service/output/trace/packages.js.map +1 -0
- package/dist/service/output/trace/trace.d.ts +32 -0
- package/dist/service/output/trace/trace.d.ts.map +1 -0
- package/dist/service/output/trace/trace.js +53 -0
- package/dist/service/output/trace/trace.js.map +1 -0
- package/dist/service/settings/index.d.ts +1 -1
- package/dist/service/settings/index.d.ts.map +1 -1
- package/dist/service/settings/resolve.d.ts +2 -2
- package/dist/service/settings/resolve.d.ts.map +1 -1
- package/dist/service/settings/resolve.js.map +1 -1
- package/dist/service/settings/start-order.d.ts +2 -2
- package/dist/service/settings/start-order.d.ts.map +1 -1
- package/dist/service/settings/types.d.ts +1 -1
- package/dist/service/settings/types.d.ts.map +1 -1
- package/package.json +1 -1
- package/src/errors.ts +2 -2
- package/src/service/build/build-service.ts +44 -22
- package/src/service/build/{build-output.ts → output-directories.ts} +3 -3
- package/src/service/index.ts +5 -5
- package/src/service/launcher/main.ts +2 -2
- package/src/service/launcher-contract/start-plan.ts +4 -4
- package/src/service/output/build-output.ts +174 -0
- package/src/service/output/copy.ts +69 -0
- package/src/service/output/entrypoint.ts +250 -0
- package/src/service/{artifact → output}/exclude.ts +2 -2
- package/src/service/{artifact → output}/launcher-file.ts +1 -1
- package/src/service/output/source-files.ts +64 -0
- package/src/service/output/trace/bins.ts +39 -0
- package/src/service/output/trace/imports.ts +37 -0
- package/src/service/output/trace/optional-peer-dependencies.ts +50 -0
- package/src/service/output/trace/packages.ts +81 -0
- package/src/service/output/trace/trace.ts +99 -0
- package/src/service/settings/index.ts +1 -1
- package/src/service/settings/resolve.ts +2 -2
- package/src/service/settings/start-order.ts +2 -2
- package/src/service/settings/types.ts +1 -1
- package/dist/service/artifact/exclude.d.ts +0 -6
- package/dist/service/artifact/exclude.d.ts.map +0 -1
- package/dist/service/artifact/exclude.js.map +0 -1
- package/dist/service/artifact/launcher-file.d.ts +0 -3
- package/dist/service/artifact/launcher-file.d.ts.map +0 -1
- package/dist/service/artifact/launcher-file.js.map +0 -1
- package/dist/service/artifact/write-artifact.d.ts +0 -16
- package/dist/service/artifact/write-artifact.d.ts.map +0 -1
- package/dist/service/artifact/write-artifact.js +0 -24
- package/dist/service/artifact/write-artifact.js.map +0 -1
- package/dist/service/build/build-output.d.ts.map +0 -1
- package/dist/service/build/build-output.js.map +0 -1
- package/src/service/artifact/write-artifact.ts +0 -50
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
// Finds packages in `node_modules`, for the parts of a trace that take whole packages.
|
|
2
|
+
import { existsSync, readFileSync, realpathSync } from "node:fs";
|
|
3
|
+
import path from "node:path";
|
|
4
|
+
export function readManifest(packageDir) {
|
|
5
|
+
try {
|
|
6
|
+
return JSON.parse(readFileSync(path.join(packageDir, "package.json"), "utf8"));
|
|
7
|
+
}
|
|
8
|
+
catch {
|
|
9
|
+
return {};
|
|
10
|
+
}
|
|
11
|
+
}
|
|
12
|
+
/** Finds a package the way Node.js does: in the `node_modules` of `from` and of each folder above it. */
|
|
13
|
+
export function findPackage(from, name) {
|
|
14
|
+
for (let dir = from; dir !== path.dirname(dir); dir = path.dirname(dir)) {
|
|
15
|
+
const link = path.join(dir, "node_modules", name);
|
|
16
|
+
if (existsSync(path.join(link, "package.json"))) {
|
|
17
|
+
return { link, dir: realpathSync(link) };
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
return null;
|
|
21
|
+
}
|
|
22
|
+
/** The folder of the package that holds `file`: the nearest folder with a `package.json` that sits in a `node_modules`. */
|
|
23
|
+
export function packageDirOf(file) {
|
|
24
|
+
for (let dir = path.dirname(file); dir !== path.dirname(dir); dir = path.dirname(dir)) {
|
|
25
|
+
const parent = path.basename(path.dirname(dir));
|
|
26
|
+
const inNodeModules = parent === "node_modules" || parent.startsWith("@");
|
|
27
|
+
if (inNodeModules && existsSync(path.join(dir, "package.json"))) {
|
|
28
|
+
return dir;
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
return null;
|
|
32
|
+
}
|
|
33
|
+
/** Adds a package and, in turn, every package it depends on. */
|
|
34
|
+
export function addWithDependencies(installed, found) {
|
|
35
|
+
if (found.has(installed.link)) {
|
|
36
|
+
return;
|
|
37
|
+
}
|
|
38
|
+
found.set(installed.link, installed);
|
|
39
|
+
const manifest = readManifest(installed.dir);
|
|
40
|
+
for (const name of Object.keys({
|
|
41
|
+
...manifest.dependencies,
|
|
42
|
+
...manifest.optionalDependencies,
|
|
43
|
+
})) {
|
|
44
|
+
const dependency = findPackage(installed.dir, name);
|
|
45
|
+
if (dependency !== null) {
|
|
46
|
+
addWithDependencies(dependency, found);
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
//# sourceMappingURL=packages.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"packages.js","sourceRoot":"","sources":["../../../../src/service/output/trace/packages.ts"],"names":[],"mappings":"AAAA,uFAAuF;AACvF,OAAO,EAAE,UA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a,GAAG,MAAM,KAAK,cAAc,IAAI,MAAM,CAAC,UAAU,CAAC,GAAG,CAAC,CAAC;QAC1E,IAAI,aAAa,IAAI,UAAU,CAAC,IAAI,CAAC,IAAI,CAAC,GAAG,EAAE,cAAc,CAAC,CAAC,EAAE,CAAC;YAChE,OAAO,GAAG,CAAC;QACb,CAAC;IACH,CAAC;IAED,OAAO,IAAI,CAAC;AACd,CAAC;AAED,gEAAgE;AAChE,MAAM,UAAU,mBAAmB,CACjC,SAA2B,EAC3B,KAAoC;IAEpC,IAAI,KAAK,CAAC,GAAG,CAAC,SAAS,CAAC,IAAI,CAAC,EAAE,CAAC;QAC9B,OAAO;IACT,CAAC;IAED,KAAK,CAAC,GAAG,CAAC,SAAS,CAAC,IAAI,EAAE,SAAS,CAAC,CAAC;IACrC,MAAM,QAAQ,GAAG,YAAY,CAAC,SAAS,CAAC,GAAG,CAAC,CAAC;IAC7C,KAAK,MAAM,IAAI,IAAI,MAAM,CAAC,IAAI,CAAC;QAC7B,GAAG,QAAQ,CAAC,YAAY;QACxB,GAAG,QAAQ,CAAC,oBAAoB;KACjC,CAAC,EAAE,CAAC;QACH,MAAM,UAAU,GAAG,WAAW,CAAC,SAAS,CAAC,GAAG,EAAE,IAAI,CAAC,CAAC;QACpD,IAAI,UAAU,KAAK,IAAI,EAAE,CAAC;YACxB,mBAAmB,CAAC,UAAU,EAAE,KAAK,CAAC,CAAC;QACzC,CAAC;IACH,CAAC;AACH,CAAC"}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import type { PackageJson } from "../../settings/types.ts";
|
|
2
|
+
import { type InstalledPackage } from "./packages.ts";
|
|
3
|
+
/** What a server loads, found from its start command. */
|
|
4
|
+
export interface ServerTrace {
|
|
5
|
+
/** The files the server starts from. */
|
|
6
|
+
entrypoints: string[];
|
|
7
|
+
/** The bins the start command runs. */
|
|
8
|
+
bins: string[];
|
|
9
|
+
/** Every file the entrypoints and the built scripts import. */
|
|
10
|
+
files: string[];
|
|
11
|
+
/** Packages that go in whole: those of the bins, those the start command preloads, and the optional peer dependencies. */
|
|
12
|
+
packages: InstalledPackage[];
|
|
13
|
+
/** The names of the optional peer dependencies among `packages`. */
|
|
14
|
+
optionalPeerDependencies: string[];
|
|
15
|
+
}
|
|
16
|
+
/** Why a server could not be traced. */
|
|
17
|
+
export type Untraceable = "the start command runs no file and no bin that can be followed" | "the server imports files from outside the Service folder";
|
|
18
|
+
/**
|
|
19
|
+
* Traces the server that `command` starts:
|
|
20
|
+
* 1. the imports of its entrypoints, and of the scripts the build wrote;
|
|
21
|
+
* 2. the packages of the bins it runs, and the packages it preloads;
|
|
22
|
+
* 3. the optional peer dependencies of what was traced.
|
|
23
|
+
*/
|
|
24
|
+
export declare function traceServer(options: {
|
|
25
|
+
serviceDir: string;
|
|
26
|
+
command: string;
|
|
27
|
+
packageJson: PackageJson;
|
|
28
|
+
/** Scripts in the output directories. A framework's server loads them by path, and they import packages. */
|
|
29
|
+
builtScripts: string[];
|
|
30
|
+
signal?: AbortSignal;
|
|
31
|
+
}): Promise<ServerTrace | Untraceable>;
|
|
32
|
+
//# sourceMappingURL=trace.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"trace.d.ts","sourceRoot":"","sources":["../../../../src/service/output/trace/trace.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,yBAAyB,CAAC;AAK3D,OAAO,EAGL,KAAK,gBAAgB,EACtB,MAAM,eAAe,CAAC;AAEvB,yDAAyD;AACzD,MAAM,WAAW,WAAW;IAC1B,wCAAwC;IACxC,WAAW,EAAE,MAAM,EAAE,CAAC;IACtB,uCAAuC;IACvC,IAAI,EAAE,MAAM,EAAE,CAAC;IACf,+DAA+D;IAC/D,KAAK,EAAE,MAAM,EAAE,CAAC;IAChB,0HAA0H;IAC1H,QAAQ,EAAE,gBAAgB,EAAE,CAAC;IAC7B,oEAAoE;IACpE,wBAAwB,EAAE,MAAM,EAAE,CAAC;CACpC;AAED,wCAAwC;AACxC,MAAM,MAAM,WAAW,GACnB,gEAAgE,GAChE,0DAA0D,CAAC;AAE/D;;;;;GAKG;AACH,wBAAsB,WAAW,CAAC,OAAO,EAAE;IACzC,UAAU,EAAE,MAAM,CAAC;IACnB,OAAO,EAAE,MAAM,CAAC;IAChB,WAAW,EAAE,WAAW,CAAC;IACzB,4GAA4G;IAC5G,YAAY,EAAE,MAAM,EAAE,CAAC;IACvB,MAAM,CAAC,EAAE,WAAW,CAAC;CACtB,GAAG,OAAO,CAAC,WAAW,GAAG,WAAW,CAAC,CAoDrC"}
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
// The trace of a server: every file it loads from `node_modules`.
|
|
2
|
+
import { realpathSync } from "node:fs";
|
|
3
|
+
import path from "node:path";
|
|
4
|
+
import { readStartCommand } from "../entrypoint.js";
|
|
5
|
+
import { binPackages } from "./bins.js";
|
|
6
|
+
import { traceImports } from "./imports.js";
|
|
7
|
+
import { optionalPeerDependencies } from "./optional-peer-dependencies.js";
|
|
8
|
+
import { addWithDependencies, findPackage, } from "./packages.js";
|
|
9
|
+
/**
|
|
10
|
+
* Traces the server that `command` starts:
|
|
11
|
+
* 1. the imports of its entrypoints, and of the scripts the build wrote;
|
|
12
|
+
* 2. the packages of the bins it runs, and the packages it preloads;
|
|
13
|
+
* 3. the optional peer dependencies of what was traced.
|
|
14
|
+
*/
|
|
15
|
+
export async function traceServer(options) {
|
|
16
|
+
const { packageJson } = options;
|
|
17
|
+
// Traced files are real paths, so the Service folder they are compared with must be its real path too.
|
|
18
|
+
const serviceDir = realpathSync(options.serviceDir);
|
|
19
|
+
const { entrypoints, bins, preloadedPackages } = readStartCommand(serviceDir, options.command, packageJson);
|
|
20
|
+
if (entrypoints.length === 0 && bins.length === 0) {
|
|
21
|
+
return "the start command runs no file and no bin that can be followed";
|
|
22
|
+
}
|
|
23
|
+
options.signal?.throwIfAborted();
|
|
24
|
+
const files = await traceImports([...entrypoints, ...options.builtScripts], serviceDir);
|
|
25
|
+
const packages = binPackages(serviceDir, bins);
|
|
26
|
+
// A preloaded package goes in whole, as a bin's package does: `tsx` loads its own files by path.
|
|
27
|
+
for (const name of preloadedPackages) {
|
|
28
|
+
const preloaded = findPackage(serviceDir, name);
|
|
29
|
+
if (preloaded !== null) {
|
|
30
|
+
addWithDependencies(preloaded, packages);
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
const peers = optionalPeerDependencies(serviceDir, packageJson, files);
|
|
34
|
+
for (const peer of peers) {
|
|
35
|
+
addWithDependencies(peer, packages);
|
|
36
|
+
}
|
|
37
|
+
const inside = (file) => {
|
|
38
|
+
const relative = path.relative(serviceDir, file);
|
|
39
|
+
return !relative.startsWith("..") && !path.isAbsolute(relative);
|
|
40
|
+
};
|
|
41
|
+
if (!files.every(inside) ||
|
|
42
|
+
![...packages.values()].every((found) => inside(found.dir))) {
|
|
43
|
+
return "the server imports files from outside the Service folder";
|
|
44
|
+
}
|
|
45
|
+
return {
|
|
46
|
+
entrypoints,
|
|
47
|
+
bins,
|
|
48
|
+
files,
|
|
49
|
+
packages: [...packages.values()],
|
|
50
|
+
optionalPeerDependencies: peers.map((peer) => peer.name),
|
|
51
|
+
};
|
|
52
|
+
}
|
|
53
|
+
//# sourceMappingURL=trace.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"trace.js","sourceRoot":"","sources":["../../../../src/service/output/trace/trace.ts"],"names":[],"mappings":"AAAA,kEAAkE;AAClE,OAAO,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AACvC,OAAO,IAAI,MAAM,WAAW,CAAC;AAE7B,OAAO,EAAE,gBAAgB,EAAE,MAAM,kBAAkB,CAAC;AACpD,OAAO,EAAE,WAAW,EAAE,MAAM,WAAW,CAAC;AACxC,OAAO,EAAE,YAAY,EAAE,MAAM,cAAc,CAAC;AAC5C,OAAO,EAAE,wBAAwB,EAAE,MAAM,iCAAiC,CAAC;AAC3E,OAAO,EACL,m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M,QAAQ,GAAG,IAAI,CAAC,QAAQ,CAAC,UAAU,EAAE,IAAI,CAAC,CAAC;QAEjD,OAAO,CAAC,QAAQ,CAAC,UAAU,CAAC,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,UAAU,CAAC,QAAQ,CAAC,CAAC;IAClE,CAAC,CAAC;IACF,IACE,CAAC,KAAK,CAAC,KAAK,CAAC,MAAM,CAAC;QACpB,CAAC,CAAC,GAAG,QAAQ,CAAC,MAAM,EAAE,CAAC,CAAC,KAAK,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,MAAM,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,EAC3D,CAAC;QACD,OAAO,0DAA0D,CAAC;IACpE,CAAC;IAED,OAAO;QACL,WAAW;QACX,IAAI;QACJ,KAAK;QACL,QAAQ,EAAE,CAAC,GAAG,QAAQ,CAAC,MAAM,EAAE,CAAC;QAChC,wBAAwB,EAAE,KAAK,CAAC,GAAG,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,IAAI,CAAC,IAAI,CAAC;KACzD,CAAC;AACJ,CAAC"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
export type { PackageManager } from "../../package-manager.ts";
|
|
2
2
|
export { isDevCommand } from "./dev-command.ts";
|
|
3
3
|
export { resolveServiceBuildSettings, resolveStartAfterBuild, } from "./resolve.ts";
|
|
4
|
-
export type {
|
|
4
|
+
export type { OutputDirectories, ReadFile, Resolved, ServiceBuildSettings, ServiceConfig, Source, Start, } from "./types.ts";
|
|
5
5
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/service/settings/index.ts"],"names":[],"mappings":"AAEA,YAAY,EAAE,cAAc,EAAE,MAAM,0BAA0B,CAAC;AAC/D,OAAO,EAAE,YAAY,EAAE,MAAM,kBAAkB,CAAC;AAChD,OAAO,EACL,2BAA2B,EAC3B,sBAAsB,GACvB,MAAM,cAAc,CAAC;AACtB,YAAY,EACV,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/service/settings/index.ts"],"names":[],"mappings":"AAEA,YAAY,EAAE,cAAc,EAAE,MAAM,0BAA0B,CAAC;AAC/D,OAAO,EAAE,YAAY,EAAE,MAAM,kBAAkB,CAAC;AAChD,OAAO,EACL,2BAA2B,EAC3B,sBAAsB,GACvB,MAAM,cAAc,CAAC;AACtB,YAAY,EACV,iBAAiB,EACjB,QAAQ,EACR,QAAQ,EACR,oBAAoB,EACpB,aAAa,EACb,MAAM,EACN,KAAK,GACN,MAAM,YAAY,CAAC"}
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { OutputDirectories, ReadFile, Resolved, ServiceBuildSettings, ServiceConfig, Start } from "./types.ts";
|
|
2
2
|
/**
|
|
3
3
|
* Resolves the Build settings that can be known before the build runs.
|
|
4
4
|
* `start` is `"after build"` when only the build output can decide it.
|
|
5
5
|
*/
|
|
6
6
|
export declare function resolveServiceBuildSettings(read: ReadFile, config?: ServiceConfig, signal?: AbortSignal): Promise<ServiceBuildSettings>;
|
|
7
7
|
/** Decides the start from the build output and the source. Null means no rule matched. */
|
|
8
|
-
export declare function resolveStartAfterBuild(read: ReadFile, output:
|
|
8
|
+
export declare function resolveStartAfterBuild(read: ReadFile, output: OutputDirectories, signal?: AbortSignal): Promise<Resolved<Start> | null>;
|
|
9
9
|
//# sourceMappingURL=resolve.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"resolve.d.ts","sourceRoot":"","sources":["../../../src/service/settings/resolve.ts"],"names":[],"mappings":"AAMA,OAAO,KAAK,EACV,
|
|
1
|
+
{"version":3,"file":"resolve.d.ts","sourceRoot":"","sources":["../../../src/service/settings/resolve.ts"],"names":[],"mappings":"AAMA,OAAO,KAAK,EACV,iBAAiB,EACjB,QAAQ,EACR,QAAQ,EACR,oBAAoB,EACpB,aAAa,EACb,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AAE,CAAC;IACxE,CAAC;IAED,OAAO,EAAE,KAAK,EAAE,IAAI,EAAE,IAAI,EAAE,SAAS,EAAE,CAAC;AAC1C,CAAC;AAED,0EAA0E;AAC1E,SAAS,WAAW,CAAC,MAAqB;IACxC,OAAO,MAAM,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,KAAK,EAAE,MAAM,CAAC,IAAI,EAAE,IAAI,EAAE,QAAQ,EAAE,CAAC,CAAC,CAAC,IAAI,CAAC;AACrE,CAAC"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { PackageManager } from "../../package-manager.ts";
|
|
2
|
-
import type {
|
|
2
|
+
import type { OutputDirectories, PackageJson, ReadFile, Resolved, ServiceConfig, Start } from "./types.ts";
|
|
3
3
|
/** What a rule may look at before the build runs. */
|
|
4
4
|
interface ServiceBeforeBuild {
|
|
5
5
|
config: ServiceConfig;
|
|
@@ -10,7 +10,7 @@ interface ServiceBeforeBuild {
|
|
|
10
10
|
interface ServiceAfterBuild {
|
|
11
11
|
read: ReadFile;
|
|
12
12
|
packageJson: PackageJson;
|
|
13
|
-
output:
|
|
13
|
+
output: OutputDirectories;
|
|
14
14
|
}
|
|
15
15
|
/** The start, when a rule that needs no build output decides it, and the notes for the user. */
|
|
16
16
|
export declare function startBeforeBuild(service: ServiceBeforeBuild): {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"start-order.d.ts","sourceRoot":"","sources":["../../../src/service/settings/start-order.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,0BAA0B,CAAC;AAE/D,OAAO,KAAK,EACV,
|
|
1
|
+
{"version":3,"file":"start-order.d.ts","sourceRoot":"","sources":["../../../src/service/settings/start-order.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,0BAA0B,CAAC;AAE/D,OAAO,KAAK,EACV,iBAAiB,EACjB,WAAW,EACX,QAAQ,EACR,QAAQ,EACR,aAAa,EAEb,KAAK,EACN,MAAM,YAAY,CAAC;AAEpB,qDAAqD;AACrD,UAAU,kBAAkB;IAC1B,MAAM,EAAE,aAAa,CAAC;IACtB,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IAChC,cAAc,EAAE,cAAc,CAAC;CAChC;AAED,sDAAsD;AACtD,UAAU,iBAAiB;IACzB,IAAI,EAAE,QAAQ,CAAC;IACf,WAAW,EAAE,WAAW,CAAC;IACzB,MAAM,EAAE,iBAAiB,CAAC;CAC3B;AA6CD,gGAAgG;AAChG,wBAAgB,gBAAgB,CAAC,OAAO,EAAE,kBAAkB,GAAG;IAC7D,KAAK,EAAE,QAAQ,CAAC,KAAK,CAAC,GAAG,aAAa,CAAC;IACvC,KAAK,EAAE,MAAM,EAAE,CAAC;CACjB,CASA;AAED,2FAA2F;AAC3F,wBAAsB,eAAe,CACnC,OAAO,EAAE,iBAAiB,GACzB,OAAO,CAAC,QAAQ,CAAC,KAAK,CAAC,GAAG,IAAI,CAAC,CASjC"}
|
|
@@ -45,7 +45,7 @@ export interface ServiceBuildSettings {
|
|
|
45
45
|
notes: string[];
|
|
46
46
|
}
|
|
47
47
|
/** What the build step wrote, as far as the start order needs it. */
|
|
48
|
-
export interface
|
|
48
|
+
export interface OutputDirectories {
|
|
49
49
|
/** Top-level folders the build created or wrote to, such as `dist` or `.output`. */
|
|
50
50
|
newDirs: string[];
|
|
51
51
|
/** Folders that hold a self-contained `index.html` the build wrote, shallowest first. */
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../src/service/settings/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,0BAA0B,CAAC;AAE/D;;;GAGG;AACH,MAAM,MAAM,QAAQ,GAAG,CAAC,IAAI,EAAE,MAAM,KAAK,OAAO,CAAC,MAAM,GAAG,IAAI,CAAC,GAAG,MAAM,GAAG,IAAI,CAAC;A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,CAAC,KAAK,CAAC,GAAG,aAAa,CAAC;IACvC,wGAAwG;IACxG,IAAI,EAAE,QAAQ,CAAC,MAAM,CAAC,GAAG,IAAI,CAAC;IAC9B,0FAA0F;IAC1F,KAAK,EAAE,MAAM,EAAE,CAAC;CACjB;AAED,qEAAqE;AACrE,MAAM,WAAW,iBAAiB;IAChC,oFAAoF;IACpF,OAAO,EAAE,MAAM,EAAE,CAAC;IAClB,yFAAyF;IACzF,aAAa,EAAE,MAAM,EAAE,CAAC;CACzB;AAED,8DAA8D;AAC9D,MAAM,WAAW,WAAW;IAC1B,cAAc,CAAC,EAAE,MAAM,CAAC;IACxB,OAAO,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IACjC,YAAY,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IACtC,eAAe,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IACzC,OAAO,CAAC,EAAE;QAAE,IAAI,CAAC,EAAE,MAAM,CAAA;KAAE,CAAC;IAC5B,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,MAAM,CAAC,EAAE,MAAM,CAAC;CACjB"}
|
package/package.json
CHANGED
package/src/errors.ts
CHANGED
|
@@ -190,7 +190,7 @@ export type DeploymentOperationError =
|
|
|
190
190
|
| TimeoutError
|
|
191
191
|
| DeploymentFailedError;
|
|
192
192
|
|
|
193
|
-
/** A build of one Service that produced no
|
|
193
|
+
/** A build of one Service that produced no build output. `code` is stable across releases. */
|
|
194
194
|
export class ServiceBuildError extends TaggedError("ServiceBuildError")<{
|
|
195
195
|
code: "install_failed" | "build_failed" | "no_start";
|
|
196
196
|
/** For the user. */
|
|
@@ -198,5 +198,5 @@ export class ServiceBuildError extends TaggedError("ServiceBuildError")<{
|
|
|
198
198
|
settings: ServiceBuildSettings;
|
|
199
199
|
steps: BuildStep[];
|
|
200
200
|
/** The end of the failed command's output, under a line that gives its exit code. */
|
|
201
|
-
|
|
201
|
+
commandOutput?: string;
|
|
202
202
|
}>() {}
|
|
@@ -1,26 +1,27 @@
|
|
|
1
|
-
// Builds one Service folder
|
|
1
|
+
// Builds one Service folder and writes its build output. Runs on the Build runner: it needs a shell,
|
|
2
2
|
// the repository's package manager, and the checkout. It never starts the Service.
|
|
3
3
|
import { existsSync, readFileSync } from "node:fs";
|
|
4
4
|
import { join } from "node:path";
|
|
5
5
|
import { Result } from "better-result";
|
|
6
6
|
import { ServiceBuildError } from "../../errors.ts";
|
|
7
|
-
import {
|
|
8
|
-
|
|
9
|
-
writeArtifact,
|
|
10
|
-
} from "../artifact/write-artifact.ts";
|
|
7
|
+
import { type BuildOutput, writeBuildOutput } from "../output/build-output.ts";
|
|
8
|
+
import { readPackageJson } from "../settings/package-json.ts";
|
|
11
9
|
import {
|
|
12
10
|
resolveServiceBuildSettings,
|
|
13
11
|
resolveStartAfterBuild,
|
|
14
12
|
} from "../settings/resolve.ts";
|
|
15
13
|
import type {
|
|
16
|
-
|
|
14
|
+
OutputDirectories,
|
|
17
15
|
ReadFile,
|
|
18
16
|
Resolved,
|
|
19
17
|
ServiceBuildSettings,
|
|
20
18
|
ServiceConfig,
|
|
21
19
|
Start,
|
|
22
20
|
} from "../settings/types.ts";
|
|
23
|
-
import {
|
|
21
|
+
import {
|
|
22
|
+
outputDirectoriesSince,
|
|
23
|
+
snapshotFolders,
|
|
24
|
+
} from "./output-directories.ts";
|
|
24
25
|
import {
|
|
25
26
|
type BuildStep,
|
|
26
27
|
runStep,
|
|
@@ -44,11 +45,11 @@ export interface BuiltService {
|
|
|
44
45
|
settings: ServiceBuildSettings;
|
|
45
46
|
start: Resolved<Start>;
|
|
46
47
|
steps: BuildStep[];
|
|
47
|
-
|
|
48
|
+
output: BuildOutput;
|
|
48
49
|
}
|
|
49
50
|
|
|
50
51
|
/** What makes a `ServiceBuildError`, beside the Build settings and the steps. */
|
|
51
|
-
type Failure = Pick<ServiceBuildError, "code" | "message" | "
|
|
52
|
+
type Failure = Pick<ServiceBuildError, "code" | "message" | "commandOutput">;
|
|
52
53
|
|
|
53
54
|
/** The build failures have stable codes: the CLI, Console and the fix task key on them. */
|
|
54
55
|
const STEP_FAILURES = {
|
|
@@ -63,7 +64,7 @@ const NO_START: Failure = {
|
|
|
63
64
|
};
|
|
64
65
|
|
|
65
66
|
/**
|
|
66
|
-
* Runs the Service's install and build commands, decides how the Service starts, and writes the
|
|
67
|
+
* Runs the Service's install and build commands, decides how the Service starts, and writes the build output.
|
|
67
68
|
*
|
|
68
69
|
* A failed install, a failed build and a missing start are expected outcomes:
|
|
69
70
|
* they come back as a `ServiceBuildError`, not as a thrown error.
|
|
@@ -82,27 +83,44 @@ export async function buildService(
|
|
|
82
83
|
const fail = (failure: Failure) =>
|
|
83
84
|
Result.err(new ServiceBuildError({ ...failure, settings, steps }));
|
|
84
85
|
|
|
85
|
-
const
|
|
86
|
-
if (
|
|
87
|
-
return fail(
|
|
86
|
+
const outputDirectories = await installAndBuild(settings, options, steps);
|
|
87
|
+
if (outputDirectories.isErr()) {
|
|
88
|
+
return fail(outputDirectories.error);
|
|
88
89
|
}
|
|
89
90
|
|
|
90
91
|
const start =
|
|
91
92
|
settings.start === "after build"
|
|
92
|
-
? await resolveStartAfterBuild(
|
|
93
|
+
? await resolveStartAfterBuild(
|
|
94
|
+
read,
|
|
95
|
+
outputDirectories.value,
|
|
96
|
+
options.signal,
|
|
97
|
+
)
|
|
93
98
|
: settings.start;
|
|
94
99
|
if (start === null) {
|
|
95
100
|
return fail(NO_START);
|
|
96
101
|
}
|
|
97
102
|
|
|
98
|
-
const
|
|
99
|
-
|
|
103
|
+
const output = await writeBuildOutput({
|
|
104
|
+
serviceDir: dir,
|
|
105
|
+
start: start.value,
|
|
106
|
+
port: settings.port?.value ?? null,
|
|
107
|
+
packageJson: (await readPackageJson(read)).packageJson,
|
|
108
|
+
outputDirectories: outputDirectories.value,
|
|
109
|
+
signal: options.signal,
|
|
110
|
+
});
|
|
111
|
+
const notes =
|
|
112
|
+
output.kind === "whole folder"
|
|
113
|
+
? [
|
|
114
|
+
...settings.notes,
|
|
115
|
+
`The build output is the whole folder, with all of node_modules: ${output.reason}.`,
|
|
116
|
+
]
|
|
117
|
+
: settings.notes;
|
|
100
118
|
|
|
101
119
|
return Result.ok({
|
|
102
|
-
settings: { ...settings, start },
|
|
120
|
+
settings: { ...settings, start, notes },
|
|
103
121
|
start,
|
|
104
122
|
steps,
|
|
105
|
-
|
|
123
|
+
output,
|
|
106
124
|
});
|
|
107
125
|
}
|
|
108
126
|
|
|
@@ -111,7 +129,7 @@ async function installAndBuild(
|
|
|
111
129
|
settings: ServiceBuildSettings,
|
|
112
130
|
options: BuildServiceOptions,
|
|
113
131
|
steps: BuildStep[],
|
|
114
|
-
): Promise<Result<
|
|
132
|
+
): Promise<Result<OutputDirectories, Failure>> {
|
|
115
133
|
const { dir, env, signal } = options;
|
|
116
134
|
const run: StepRun = { dir, steps, log: options.log ?? (() => {}), signal };
|
|
117
135
|
|
|
@@ -128,7 +146,7 @@ async function installAndBuild(
|
|
|
128
146
|
return Result.err(stepFailed(build, built.output));
|
|
129
147
|
}
|
|
130
148
|
|
|
131
|
-
return Result.ok(
|
|
149
|
+
return Result.ok(outputDirectoriesSince(dir, beforeBuild));
|
|
132
150
|
}
|
|
133
151
|
|
|
134
152
|
/** The build runs in production mode. The caller's variables win over these. */
|
|
@@ -158,10 +176,14 @@ function installStep(
|
|
|
158
176
|
};
|
|
159
177
|
}
|
|
160
178
|
|
|
161
|
-
function stepFailed(step: StepToRun,
|
|
179
|
+
function stepFailed(step: StepToRun, commandOutput: string): Failure {
|
|
162
180
|
const { code, label } = STEP_FAILURES[step.name];
|
|
163
181
|
|
|
164
|
-
return {
|
|
182
|
+
return {
|
|
183
|
+
code,
|
|
184
|
+
message: `${label} failed: ${step.command}`,
|
|
185
|
+
commandOutput,
|
|
186
|
+
};
|
|
165
187
|
}
|
|
166
188
|
|
|
167
189
|
/** Reads the files of the Service folder for the Build rules. */
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
// The Build rules must not guess output folders by framework.
|
|
3
3
|
import { existsSync, readdirSync, readFileSync, statSync } from "node:fs";
|
|
4
4
|
import { join } from "node:path";
|
|
5
|
-
import type {
|
|
5
|
+
import type { OutputDirectories } from "../settings/types.ts";
|
|
6
6
|
|
|
7
7
|
/** The folders of the Service folder at one moment. Taken before the build, it tells what the build wrote. */
|
|
8
8
|
export interface FolderSnapshot {
|
|
@@ -46,10 +46,10 @@ export function snapshotFolders(serviceDir: string): FolderSnapshot {
|
|
|
46
46
|
* What the build wrote: the folders that were not in the snapshot, and the folders that the build wrote to again.
|
|
47
47
|
* The second kind is the output of an earlier build in the same folder. Without it a second build would find no output.
|
|
48
48
|
*/
|
|
49
|
-
export function
|
|
49
|
+
export function outputDirectoriesSince(
|
|
50
50
|
serviceDir: string,
|
|
51
51
|
before: FolderSnapshot,
|
|
52
|
-
):
|
|
52
|
+
): OutputDirectories {
|
|
53
53
|
return {
|
|
54
54
|
newDirs: topLevelDirs(serviceDir).filter(
|
|
55
55
|
(dir) =>
|
package/src/service/index.ts
CHANGED
|
@@ -1,17 +1,17 @@
|
|
|
1
|
-
// The public API of `@prisma/compute-sdk/service`: resolve the Build settings of one Service
|
|
2
|
-
// Nothing here deploys the
|
|
1
|
+
// The public API of `@prisma/compute-sdk/service`: resolve the Build settings of one Service, build it, and write its build output.
|
|
2
|
+
// Nothing here deploys the build output. The caller does that.
|
|
3
3
|
export { ServiceBuildError } from "../errors.ts";
|
|
4
|
-
export { excludedFromArtifact } from "./artifact/exclude.ts";
|
|
5
|
-
export type { ServiceArtifact } from "./artifact/write-artifact.ts";
|
|
6
4
|
export {
|
|
7
5
|
type BuildServiceOptions,
|
|
8
6
|
type BuiltService,
|
|
9
7
|
buildService,
|
|
10
8
|
} from "./build/build-service.ts";
|
|
11
9
|
export type { BuildStep } from "./build/run-step.ts";
|
|
10
|
+
export type { BuildOutput, TraceSummary } from "./output/build-output.ts";
|
|
11
|
+
export { excludedFromBuildOutput } from "./output/exclude.ts";
|
|
12
12
|
export {
|
|
13
|
-
type BuildOutput,
|
|
14
13
|
isDevCommand,
|
|
14
|
+
type OutputDirectories,
|
|
15
15
|
type PackageManager,
|
|
16
16
|
type ReadFile,
|
|
17
17
|
type Resolved,
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
// The Launcher: the file Compute starts from
|
|
1
|
+
// The Launcher: the file Compute starts from a build output. It starts the Service.
|
|
2
2
|
// It exists because the Runtime has no /bin/sh and no /usr/bin/env, so `bun run start` cannot work there.
|
|
3
3
|
import { readFileSync } from "node:fs";
|
|
4
4
|
import { dirname, join, resolve } from "node:path";
|
|
@@ -33,7 +33,7 @@ if (shim === null) {
|
|
|
33
33
|
* A stop signal goes on to the Service. In static mode it stops the server.
|
|
34
34
|
*/
|
|
35
35
|
async function startService(): Promise<void> {
|
|
36
|
-
// The Launcher is at .prisma/launcher.mjs in the
|
|
36
|
+
// The Launcher is at .prisma/launcher.mjs in the build output, so the Service's folder is one level up.
|
|
37
37
|
const serviceDir = resolve(dirname(launcherFile), "..");
|
|
38
38
|
const plan = readStartPlan(serviceDir);
|
|
39
39
|
const port = routedPort(plan);
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
// The Start plan: what the Build runner tells the Launcher to do on the Runtime.
|
|
2
|
-
// The build writes it into the
|
|
2
|
+
// The build writes it into the build output beside the Launcher, and the Launcher reads it at every start.
|
|
3
3
|
// Both files come from the same SDK version, so the format needs no version field.
|
|
4
4
|
|
|
5
|
-
/** The Launcher, relative to the
|
|
5
|
+
/** The Launcher, relative to the build output folder. Compute starts this file. */
|
|
6
6
|
export const LAUNCHER_FILE = ".prisma/launcher.mjs";
|
|
7
7
|
|
|
8
|
-
/** The Start plan, relative to the
|
|
8
|
+
/** The Start plan, relative to the build output folder. */
|
|
9
9
|
export const START_PLAN_FILE = ".prisma/plan.json";
|
|
10
10
|
|
|
11
11
|
/** The port the Service gets as `PORT` when Compute sets none and the user stated none. */
|
|
@@ -14,5 +14,5 @@ export const DEFAULT_PORT = 8080;
|
|
|
14
14
|
export type StartPlan =
|
|
15
15
|
/** Run the Service's own start command. `port` is the port the user stated, or null. */
|
|
16
16
|
| { kind: "command"; command: string; port: number | null }
|
|
17
|
-
/** Serve a folder of static files. `dir` is relative to the
|
|
17
|
+
/** Serve a folder of static files. `dir` is relative to the build output folder. */
|
|
18
18
|
| { kind: "static"; dir: string; port: number | null };
|