@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
package/README.md
CHANGED
|
@@ -455,9 +455,9 @@ class MyCustomBuild implements BuildStrategy {
|
|
|
455
455
|
|
|
456
456
|
## Build one Service from its own commands
|
|
457
457
|
|
|
458
|
-
`@prisma/compute-sdk/service` builds one Service from its own `install`, `build` and `start` commands. The result is
|
|
458
|
+
`@prisma/compute-sdk/service` builds one Service from its own `install`, `build` and `start` commands. The result is a build output: a folder and the file Compute starts in it. The package holds no framework rules.
|
|
459
459
|
|
|
460
|
-
This package does not deploy. It calls no Compute API. The caller takes the
|
|
460
|
+
This package does not deploy. It calls no Compute API. The caller takes the build output and deploys it: see [What the caller does next](#what-the-caller-does-next).
|
|
461
461
|
|
|
462
462
|
```ts
|
|
463
463
|
import { buildService } from "@prisma/compute-sdk/service";
|
|
@@ -467,10 +467,10 @@ if (built.isErr()) {
|
|
|
467
467
|
throw built.error;
|
|
468
468
|
}
|
|
469
469
|
|
|
470
|
-
built.value.
|
|
470
|
+
built.value.output; // { dir: "/repo", entrypoint: ".prisma/launcher.mjs" }
|
|
471
471
|
```
|
|
472
472
|
|
|
473
|
-
`buildService` returns a `Result`. Success means
|
|
473
|
+
`buildService` returns a `Result`. Success means a build output exists.
|
|
474
474
|
|
|
475
475
|
### Build settings
|
|
476
476
|
|
|
@@ -563,7 +563,7 @@ await buildService({
|
|
|
563
563
|
|
|
564
564
|
### `buildService(options)`
|
|
565
565
|
|
|
566
|
-
Runs install and build, decides the start, and writes two files into the
|
|
566
|
+
Runs install and build, decides the start, and writes two files into the build output folder: the Launcher (`.prisma/launcher.mjs`) and the Start plan (`.prisma/plan.json`). It runs on the Build runner, and needs a shell and the repository's package manager there. It never starts the Service.
|
|
567
567
|
|
|
568
568
|
```ts
|
|
569
569
|
const built = await buildService({
|
|
@@ -574,54 +574,74 @@ const built = await buildService({
|
|
|
574
574
|
if (built.isOk()) {
|
|
575
575
|
built.value.start; // { value: { kind: "command", command: "npm run start" }, from: "package.json" }
|
|
576
576
|
built.value.steps; // [{ name: "install", command: "npm ci", seconds: 12, ok: true }, { name: "build", ... }]
|
|
577
|
-
built.value.
|
|
577
|
+
built.value.output; // { dir: "/repo", entrypoint: ".prisma/launcher.mjs" }
|
|
578
578
|
}
|
|
579
579
|
```
|
|
580
580
|
|
|
581
|
-
A build that produces no
|
|
581
|
+
A build that produces no build output returns a `ServiceBuildError`. It is not thrown.
|
|
582
582
|
|
|
583
583
|
```ts
|
|
584
584
|
if (built.isErr()) {
|
|
585
585
|
built.error.code; // "build_failed"
|
|
586
586
|
built.error.message; // "Build failed: npm run build"
|
|
587
|
-
built.error.
|
|
587
|
+
built.error.commandOutput; // "Service build failed (exit code 2):\nsrc/index.ts(3,1): error TS2304: ..."
|
|
588
588
|
built.error.steps; // [{ name: "install", ok: true, ... }, { name: "build", ok: false, ... }]
|
|
589
589
|
}
|
|
590
590
|
```
|
|
591
591
|
|
|
592
592
|
| `code` | Meaning |
|
|
593
593
|
| --- | --- |
|
|
594
|
-
| `install_failed` | The install command exited with an error. `
|
|
595
|
-
| `build_failed` | The build command exited with an error. `
|
|
594
|
+
| `install_failed` | The install command exited with an error. `commandOutput` holds the end of its output. |
|
|
595
|
+
| `build_failed` | The build command exited with an error. `commandOutput` holds the end of its output. |
|
|
596
596
|
| `no_start` | No start rule matched. |
|
|
597
597
|
|
|
598
598
|
The install command runs with `NODE_ENV=development`, because dev dependencies hold the build tools. A `NODE_ENV` in `env` does not change that. The build command runs with `NODE_ENV=production` unless `env` sets another value.
|
|
599
599
|
|
|
600
|
-
|
|
600
|
+
### What the build output holds
|
|
601
|
+
|
|
602
|
+
Compute unpacks the build output on every start, so it holds only what the Service needs to run. `output.kind` says which of three it is:
|
|
603
|
+
|
|
604
|
+
| `kind` | The folder | When |
|
|
605
|
+
| --- | --- | --- |
|
|
606
|
+
| `"static site"` | The folder of static files the build wrote | The start is a folder of static files |
|
|
607
|
+
| `"traced server"` | `.prisma/output`: the source files and the trace of the server | The start is a command |
|
|
608
|
+
| `"whole folder"` | The Service folder, with all of `node_modules` | The server cannot be traced. `output.reason` says why, and the Build settings get a note. |
|
|
609
|
+
|
|
610
|
+
The **source files** are the repository's files and the output directories of the build. The installed `node_modules` is not among them. A `node_modules` folder inside an output directory is kept, because Nuxt and Next.js put their server's packages there.
|
|
611
|
+
|
|
612
|
+
The **trace** is every file of `node_modules` that the server loads. It starts from the entrypoints that the start command runs, such as `dist/main.js` in `node dist/main.js`. A file that a runtime option preloads is an entrypoint too, such as `./setup.js` in `node --require ./setup.js server.js`:
|
|
613
|
+
|
|
614
|
+
1. The imports of the entrypoints and of the scripts in the output directories, followed with `@vercel/nft`.
|
|
615
|
+
2. Whole, the package of a bin the start command runs, such as `tsx`, with its dependencies. A bin loads its own files by path, which imports do not show. A package that a runtime option preloads goes in the same way, such as `dotenv` in `node -r dotenv/config server.js`.
|
|
616
|
+
3. An optional peer dependency of a traced package, when the Service lists it in `dependencies`. sequelize loads `pg` by a name held in a variable.
|
|
617
|
+
|
|
618
|
+
The start command is not changed. The Launcher runs it as written.
|
|
619
|
+
|
|
620
|
+
A server cannot be traced when the start command runs no file and no bin (`./run.sh`), or when it imports files from outside the Service folder, as in a workspace.
|
|
601
621
|
|
|
602
622
|
### What the caller does next
|
|
603
623
|
|
|
604
|
-
The
|
|
624
|
+
The build output is a folder (`output.dir`, a real path) and an entry file (`output.entrypoint`, relative to the folder). The caller copies or uploads the folder and tells Compute to start the entry file with Bun.
|
|
605
625
|
|
|
606
|
-
The caller leaves out every file and folder that `
|
|
626
|
+
The caller leaves out every file and folder that `excludedFromBuildOutput` names, at every depth: `.git` and dotenv files (`.env`, `.env.*`). A CI checkout keeps a token in `.git`, and a dotenv file holds local secrets. Set the values the Service needs as variables on the project.
|
|
607
627
|
|
|
608
628
|
```ts
|
|
609
629
|
import { cp } from "node:fs/promises";
|
|
610
630
|
import path from "node:path";
|
|
611
|
-
import {
|
|
631
|
+
import { excludedFromBuildOutput } from "@prisma/compute-sdk/service";
|
|
612
632
|
|
|
613
|
-
const { dir, entrypoint } = built.value.
|
|
633
|
+
const { dir, entrypoint } = built.value.output;
|
|
614
634
|
|
|
615
|
-
await cp(dir, "/tmp/
|
|
635
|
+
await cp(dir, "/tmp/build-output", {
|
|
616
636
|
recursive: true,
|
|
617
|
-
filter: (source) => !
|
|
637
|
+
filter: (source) => !excludedFromBuildOutput(path.basename(source)),
|
|
618
638
|
});
|
|
619
639
|
```
|
|
620
640
|
|
|
621
641
|
`PreBuilt` takes the same function as its `exclude` option.
|
|
622
642
|
|
|
623
643
|
```ts
|
|
624
|
-
new PreBuilt({ appPath: dir, entrypoint, exclude:
|
|
644
|
+
new PreBuilt({ appPath: dir, entrypoint, exclude: excludedFromBuildOutput });
|
|
625
645
|
```
|
|
626
646
|
|
|
627
647
|
### Port
|
package/dist/errors.d.ts
CHANGED
|
@@ -129,9 +129,9 @@ declare const ServiceBuildError_base: import("better-result").TaggedErrorClass<"
|
|
|
129
129
|
settings: ServiceBuildSettings;
|
|
130
130
|
steps: BuildStep[];
|
|
131
131
|
/** The end of the failed command's output, under a line that gives its exit code. */
|
|
132
|
-
|
|
132
|
+
commandOutput?: string;
|
|
133
133
|
}>;
|
|
134
|
-
/** A build of one Service that produced no
|
|
134
|
+
/** A build of one Service that produced no build output. `code` is stable across releases. */
|
|
135
135
|
export declare class ServiceBuildError extends ServiceBuildError_base {
|
|
136
136
|
}
|
|
137
137
|
export {};
|
package/dist/errors.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"errors.d.ts","sourceRoot":"","sources":["../src/errors.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,6BAA6B,CAAC;AAC7D,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,6BAA6B,CAAC;;gBAG1D,GAAG;aACN,MAAM;;AAFjB,qBAAa,mBAAoB,SAAQ,wBAGrC;CAAG;;gBAGO,MAAM;gBACN,MAAM;WACX,MAAM;aACJ,MAAM;WACR,MAAM;kBACC,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC;;AANtC,qBAAa,QAAS,SAAQ,aAO1B;CAAG;;WAGE,MAAM;aACJ,MAAM;;AAFjB,qBAAa,oBAAqB,SAAQ,yBAGtC;gBACU,IAAI,EAAE;QAAE,KAAK,EAAE,MAAM,CAAA;KAAE;CAMpC;;aAGU,MAAM;WACR,MAAM,EAAE;;AAFjB,qBAAa,UAAW,SAAQ,eAG5B;CAAG;;aAGI,MAAM;YACP,OAAO;;AAFjB,qBAAa,aAAc,SAAQ,kBAG/B;CAAG;;kBAGS,MAAM;eACT,MAA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AAC9F,qBAAa,iBAAkB,SAAQ,sBAQnC;CAAG"}
|
package/dist/errors.js
CHANGED
|
@@ -65,7 +65,7 @@ export class InvalidOptionsError extends TaggedError("InvalidOptionsError")() {
|
|
|
65
65
|
}
|
|
66
66
|
export class LogStreamError extends TaggedError("LogStreamError")() {
|
|
67
67
|
}
|
|
68
|
-
/** A build of one Service that produced no
|
|
68
|
+
/** A build of one Service that produced no build output. `code` is stable across releases. */
|
|
69
69
|
export class ServiceBuildError extends TaggedError("ServiceBuildError")() {
|
|
70
70
|
}
|
|
71
71
|
//# sourceMappingURL=errors.js.map
|
package/dist/errors.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"errors.js","sourceRoot":"","sources":["../src/errors.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC;AAI5C,MAAM,OAAO,mBAAoB,SAAQ,WAAW,CAAC,qBAAqB,CAAC,EAGvE;CAAG;AAEP,MAAM,OAAO,QAAS,SAAQ,WAAW,CAAC,UAAU,CAAC,EAOjD;CAAG;AAEP,MAAM,OAAO,oBAAqB,SAAQ,WAAW,CAAC,sBAAsB,CAAC,EAGzE;IACF,YAAY,IAAuB;QACjC,KAAK,CAAC;YACJ,KAAK,EAAE,IAAI,CAAC,KAAK;YACjB,OAAO,EAAE,8BAA8B,IAAI,CAAC,KAAK,EAAE;SACpD,CAAC,CAAC;IACL,CAAC;CACF;AAED,MAAM,OAAO,UAAW,SAAQ,WAAW,CAAC,YAAY,CAAC,EAGrD;CAAG;AAEP,MAAM,OAAO,aAAc,SAAQ,WAAW,CAAC,eAAe,CAAC,EAG3D;CAAG;AAEP,MAAM,OAAO,YAAa,SAAQ,WAAW,CAAC,cAAc,CAAC,EAKzD;IACF,YAAY,IAIX;QACC,KAAK,CAAC;YACJ,GAAG,IAAI;YACP,OAAO,EAAE,oCAAoC,IAAI,CAAC,YAAY,wCAAwC,IAAI,CAAC,UAAU,cAAc,IAAI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AG;AAEP,MAAM,OAAO,cAAe,SAAQ,WAAW,CAAC,gBAAgB,CAAC,EAG7D;CAAG;AAwDP,8FAA8F;AAC9F,MAAM,OAAO,iBAAkB,SAAQ,WAAW,CAAC,mBAAmB,CAAC,EAQnE;CAAG"}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { Result } from "better-result";
|
|
2
2
|
import { ServiceBuildError } from "../../errors.ts";
|
|
3
|
-
import { type
|
|
3
|
+
import { type BuildOutput } from "../output/build-output.ts";
|
|
4
4
|
import type { Resolved, ServiceBuildSettings, ServiceConfig, Start } from "../settings/types.ts";
|
|
5
5
|
import { type BuildStep } from "./run-step.ts";
|
|
6
6
|
export interface BuildServiceOptions {
|
|
@@ -18,10 +18,10 @@ export interface BuiltService {
|
|
|
18
18
|
settings: ServiceBuildSettings;
|
|
19
19
|
start: Resolved<Start>;
|
|
20
20
|
steps: BuildStep[];
|
|
21
|
-
|
|
21
|
+
output: BuildOutput;
|
|
22
22
|
}
|
|
23
23
|
/**
|
|
24
|
-
* Runs the Service's install and build commands, decides how the Service starts, and writes the
|
|
24
|
+
* Runs the Service's install and build commands, decides how the Service starts, and writes the build output.
|
|
25
25
|
*
|
|
26
26
|
* A failed install, a failed build and a missing start are expected outcomes:
|
|
27
27
|
* they come back as a `ServiceBuildError`, not as a thrown error.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"build-service.d.ts","sourceRoot":"","sources":["../../../src/service/build/build-service.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,MAAM,EAAE,MAAM,eAAe,CAAC;AACvC,OAAO,EAAE,iBAAiB,EAAE,MAAM,iBAAiB,CAAC;AACpD,OAAO,
|
|
1
|
+
{"version":3,"file":"build-service.d.ts","sourceRoot":"","sources":["../../../src/service/build/build-service.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,MAAM,EAAE,MAAM,eAAe,CAAC;AACvC,OAAO,EAAE,iBAAiB,EAAE,MAAM,iBAAiB,CAAC;AACpD,OAAO,EAAE,KAAK,WAAW,EAAoB,MAAM,2BAA2B,CAAC;AAM/E,OAAO,KAAK,EAGV,QAAQ,EACR,oBAAoB,EACpB,aAAa,EACb,KAAK,EACN,MAAM,sBAAsB,CAAC;AAK9B,OAAO,EACL,KAAK,SAAS,EAIf,MAAM,eAAe,CAAC;AAEvB,MAAM,WAAW,mBAAmB;IAClC,0BAA0B;IAC1B,GAAG,EAAE,MAAM,CAAC;IACZ,MAAM,CAAC,EAAE,aAAa,CAAC;IACvB,0DAA0D;IAC1D,GAAG,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IAC7B,0DAA0D;IAC1D,GAAG,CAAC,EAAE,CAAC,IAAI,EAAE,MAAM,KAAK,IAAI,CAAC;IAC7B,MAAM,CAAC,EAAE,WAAW,CAAC;CACtB;AAED,MAAM,WAAW,YAAY;IAC3B,mDAAmD;IACnD,QAAQ,EAAE,oBAAoB,CAAC;IAC/B,KAAK,EAAE,QAAQ,CAAC,KAAK,CAAC,CAAC;IACvB,KAAK,EAAE,SAAS,EAAE,CAAC;IACnB,MAAM,EAAE,WAAW,CAAC;CACrB;AAiBD;;;;;GAKG;AACH,wBAAsB,YAAY,CAChC,OAAO,EAAE,mBAAmB,GAC3B,OAAO,CAAC,MAAM,CAAC,YAAY,EAAE,iBAAiB,CAAC,CAAC,CAmDlD"}
|
|
@@ -1,12 +1,13 @@
|
|
|
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.js";
|
|
7
|
-
import {
|
|
7
|
+
import { writeBuildOutput } from "../output/build-output.js";
|
|
8
|
+
import { readPackageJson } from "../settings/package-json.js";
|
|
8
9
|
import { resolveServiceBuildSettings, resolveStartAfterBuild, } from "../settings/resolve.js";
|
|
9
|
-
import {
|
|
10
|
+
import { outputDirectoriesSince, snapshotFolders, } from "./output-directories.js";
|
|
10
11
|
import { runStep, } from "./run-step.js";
|
|
11
12
|
/** The build failures have stable codes: the CLI, Console and the fix task key on them. */
|
|
12
13
|
const STEP_FAILURES = {
|
|
@@ -18,7 +19,7 @@ const NO_START = {
|
|
|
18
19
|
message: "No start command. Add a start script to package.json, or set start or static in prisma.config.ts.",
|
|
19
20
|
};
|
|
20
21
|
/**
|
|
21
|
-
* Runs the Service's install and build commands, decides how the Service starts, and writes the
|
|
22
|
+
* Runs the Service's install and build commands, decides how the Service starts, and writes the build output.
|
|
22
23
|
*
|
|
23
24
|
* A failed install, a failed build and a missing start are expected outcomes:
|
|
24
25
|
* they come back as a `ServiceBuildError`, not as a thrown error.
|
|
@@ -29,23 +30,35 @@ export async function buildService(options) {
|
|
|
29
30
|
const settings = await resolveServiceBuildSettings(read, options.config, options.signal);
|
|
30
31
|
const steps = [];
|
|
31
32
|
const fail = (failure) => Result.err(new ServiceBuildError({ ...failure, settings, steps }));
|
|
32
|
-
const
|
|
33
|
-
if (
|
|
34
|
-
return fail(
|
|
33
|
+
const outputDirectories = await installAndBuild(settings, options, steps);
|
|
34
|
+
if (outputDirectories.isErr()) {
|
|
35
|
+
return fail(outputDirectories.error);
|
|
35
36
|
}
|
|
36
37
|
const start = settings.start === "after build"
|
|
37
|
-
? await resolveStartAfterBuild(read,
|
|
38
|
+
? await resolveStartAfterBuild(read, outputDirectories.value, options.signal)
|
|
38
39
|
: settings.start;
|
|
39
40
|
if (start === null) {
|
|
40
41
|
return fail(NO_START);
|
|
41
42
|
}
|
|
42
|
-
const
|
|
43
|
-
|
|
43
|
+
const output = await writeBuildOutput({
|
|
44
|
+
serviceDir: dir,
|
|
45
|
+
start: start.value,
|
|
46
|
+
port: settings.port?.value ?? null,
|
|
47
|
+
packageJson: (await readPackageJson(read)).packageJson,
|
|
48
|
+
outputDirectories: outputDirectories.value,
|
|
49
|
+
signal: options.signal,
|
|
50
|
+
});
|
|
51
|
+
const notes = output.kind === "whole folder"
|
|
52
|
+
? [
|
|
53
|
+
...settings.notes,
|
|
54
|
+
`The build output is the whole folder, with all of node_modules: ${output.reason}.`,
|
|
55
|
+
]
|
|
56
|
+
: settings.notes;
|
|
44
57
|
return Result.ok({
|
|
45
|
-
settings: { ...settings, start },
|
|
58
|
+
settings: { ...settings, start, notes },
|
|
46
59
|
start,
|
|
47
60
|
steps,
|
|
48
|
-
|
|
61
|
+
output,
|
|
49
62
|
});
|
|
50
63
|
}
|
|
51
64
|
/** Runs the install, then the build. Returns what the build created, or the step that failed. */
|
|
@@ -63,7 +76,7 @@ async function installAndBuild(settings, options, steps) {
|
|
|
63
76
|
if (!built.ok) {
|
|
64
77
|
return Result.err(stepFailed(build, built.output));
|
|
65
78
|
}
|
|
66
|
-
return Result.ok(
|
|
79
|
+
return Result.ok(outputDirectoriesSince(dir, beforeBuild));
|
|
67
80
|
}
|
|
68
81
|
/** The build runs in production mode. The caller's variables win over these. */
|
|
69
82
|
function buildStep(settings, extraEnv = {}) {
|
|
@@ -84,9 +97,13 @@ function installStep(settings, extraEnv = {}) {
|
|
|
84
97
|
env: { ...process.env, CI: "true", ...extraEnv, NODE_ENV: "development" },
|
|
85
98
|
};
|
|
86
99
|
}
|
|
87
|
-
function stepFailed(step,
|
|
100
|
+
function stepFailed(step, commandOutput) {
|
|
88
101
|
const { code, label } = STEP_FAILURES[step.name];
|
|
89
|
-
return {
|
|
102
|
+
return {
|
|
103
|
+
code,
|
|
104
|
+
message: `${label} failed: ${step.command}`,
|
|
105
|
+
commandOutput,
|
|
106
|
+
};
|
|
90
107
|
}
|
|
91
108
|
/** Reads the files of the Service folder for the Build rules. */
|
|
92
109
|
function readFrom(dir) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"build-service.js","sourceRoot":"","sources":["../../../src/service/build/build-service.ts"],"names":[],"mappings":"AAAA,
|
|
1
|
+
{"version":3,"file":"build-service.js","sourceRoot":"","sources":["../../../src/service/build/build-service.ts"],"names":[],"mappings":"AAAA,qGAAqG;AACrG,mFAAmF;AACnF,OAAO,EAAE,UAAU,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AACnD,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AACjC,OAAO,EAAE,MAAM,EAAE,MAAM,eAAe,CAAC;AACvC,OAAO,EAAE,iBAAiB,EAAE,MAAM,iBAAiB,CAAC;AACpD,OAAO,EAAoB,gBAAgB,EAAE,MAAM,2BAA2B,CAAC;AAC/E,OAAO,EAAE,eAAe,EAAE,MAAM,6BAA6B,CAAC;AAC9D,OAAO,EACL,2BAA2B,EAC3B,sBAAsB,GACvB,MAAM,wBAAwB,CAAC;AAShC,OAAO,EACL,sBAAsB,EACtB,eAAe,GAChB,MAAM,yBAAyB,CAAC;AACjC,OAAO,EAEL,OAAO,GAGR,MAAM,eAAe,CAAC;AAwBvB,2FAA2F;AAC3F,MAAM,aAAa,GAAG;IACpB,OAAO,EAAE,EAAE,IAAI,EAAE,gBAAgB,EAAE,KAAK,EAAE,SAAS,EAAE;IACrD,KAAK,EAAE,EAAE,IAAI,EAAE,cAAc,EAAE,KAAK,EAAE,OAAO,EAAE;CACvC,CAAC;AAEX,MAAM,QAAQ,GAAY;IACxB,IAAI,EAAE,UAAU;IAChB,OAAO,EACL,mGAAmG;CACtG,CAAC;AAEF;;;;;GAKG;AACH,MAAM,CAAC,KAAK,UAAU,YAAY,CAChC,OAA4B;IAE5B,MAAM,EAAE,GAAG,EAAE,GAAG,OAAO,CAAC;IACxB,MAAM,IAAI,GAAG,QAAQ,CAAC,GAAG,CAAC,CAAC;IAC3B,MAAM,QAAQ,GAAG,MAAM,2BAA2B,CAChD,IAAI,EACJ,OAAO,CAAC,MAAM,EACd,OAAO,CAAC,MAAM,CACf,CAAC;IACF,MAAM,KAAK,GAAgB,EAAE,CAAC;IAC9B,MAA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ErC,OAAO;QACL,IAAI,EAAE,OAAO;QACb,OAAO,EAAE,QAAQ,CAAC,KAAK,CAAC,KAAK;QAC7B,GAAG,EAAE,EAAE,GAAG,OAAO,CAAC,GAAG,EAAE,EAAE,EAAE,MAAM,EAAE,QAAQ,EAAE,YAAY,EAAE,GAAG,QAAQ,EAAE;KACzE,CAAC;AACJ,CAAC;AAED;;;GAGG;AACH,SAAS,WAAW,CAClB,QAA8B,EAC9B,WAAmC,EAAE;IAErC,OAAO;QACL,IAAI,EAAE,SAAS;QACf,OAAO,EAAE,QAAQ,CAAC,OAAO,CAAC,KAAK;QAC/B,GAAG,EAAE,EAAE,GAAG,OAAO,CAAC,GAAG,EAAE,EAAE,EAAE,MAAM,EAAE,GAAG,QAAQ,EAAE,QAAQ,EAAE,aAAa,EAAE;KAC1E,CAAC;AACJ,CAAC;AAED,SAAS,UAAU,CAAC,IAAe,EAAE,aAAqB;IACxD,MAAM,EAAE,IAAI,EAAE,KAAK,EAAE,GAAG,aAAa,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;IAEjD,OAAO;QACL,IAAI;QACJ,OAAO,EAAE,GAAG,KAAK,YAAY,IAAI,CAAC,OAAO,EAAE;QAC3C,aAAa;KACd,CAAC;AACJ,CAAC;AAED,iEAAiE;AACjE,SAAS,QAAQ,CAAC,GAAW;IAC3B,OAAO,CAAC,IAAI,EAAE,EAAE,CACd,UAAU,CAAC,IAAI,CAAC,GAAG,EAAE,IAAI,CAAC,CAAC,CAAC,CAAC,CAAC,YAAY,CAAC,IAAI,CAAC,GAAG,EAAE,IAAI,CAAC,EAAE,MAAM,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC;AAC/E,CAAC"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { OutputDirectories } from "../settings/types.ts";
|
|
2
2
|
/** The folders of the Service folder at one moment. Taken before the build, it tells what the build wrote. */
|
|
3
3
|
export interface FolderSnapshot {
|
|
4
4
|
/** Each top-level folder, with the time of the newest change to a file in it. */
|
|
@@ -11,10 +11,10 @@ export declare function snapshotFolders(serviceDir: string): FolderSnapshot;
|
|
|
11
11
|
* What the build wrote: the folders that were not in the snapshot, and the folders that the build wrote to again.
|
|
12
12
|
* The second kind is the output of an earlier build in the same folder. Without it a second build would find no output.
|
|
13
13
|
*/
|
|
14
|
-
export declare function
|
|
14
|
+
export declare function outputDirectoriesSince(serviceDir: string, before: FolderSnapshot): OutputDirectories;
|
|
15
15
|
/**
|
|
16
16
|
* True when the site in `dir` holds the first scripts and styles its `index.html` links to.
|
|
17
17
|
* A page copied out of a server build does not, and cannot be served alone.
|
|
18
18
|
*/
|
|
19
19
|
export declare function isSelfContained(dir: string): boolean;
|
|
20
|
-
//# sourceMappingURL=
|
|
20
|
+
//# sourceMappingURL=output-directories.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"output-directories.d.ts","sourceRoot":"","sources":["../../../src/service/build/output-directories.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,sBAAsB,CAAC;AAE9D,8GAA8G;AAC9G,MAAM,WAAW,cAAc;IAC7B,iFAAiF;IACjF,YAAY,EAAE,GAAG,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IAClC,oFAAoF;IACpF,UAAU,EAAE,GAAG,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;CACjC;AAeD,wBAAgB,eAAe,CAAC,UAAU,EAAE,MAAM,GAAG,cAAc,CAelE;AAED;;;GAGG;AACH,wBAAgB,sBAAsB,CACpC,UAAU,EAAE,MAAM,EAClB,MAAM,EAAE,cAAc,GACrB,iBAAiB,CAgBnB;AAED;;;GAGG;AACH,wBAAgB,eAAe,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAOpD"}
|
|
@@ -26,7 +26,7 @@ export function snapshotFolders(serviceDir) {
|
|
|
26
26
|
* What the build wrote: the folders that were not in the snapshot, and the folders that the build wrote to again.
|
|
27
27
|
* The second kind is the output of an earlier build in the same folder. Without it a second build would find no output.
|
|
28
28
|
*/
|
|
29
|
-
export function
|
|
29
|
+
export function outputDirectoriesSince(serviceDir, before) {
|
|
30
30
|
return {
|
|
31
31
|
newDirs: topLevelDirs(serviceDir).filter((dir) => newestFileChange(join(serviceDir, dir)) >
|
|
32
32
|
(before.topLevelDirs.get(dir) ?? Number.NEGATIVE_INFINITY)),
|
|
@@ -96,4 +96,4 @@ function dirsWithIndexHtml(serviceDir, depth, dir = ".") {
|
|
|
96
96
|
function shallowestFirst(a, b) {
|
|
97
97
|
return a.split("/").length - b.split("/").length || a.localeCompare(b);
|
|
98
98
|
}
|
|
99
|
-
//# sourceMappingURL=
|
|
99
|
+
//# sourceMappingURL=output-directories.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"output-directories.js","sourceRoot":"","sources":["../../../src/service/build/output-directories.ts"],"names":[],"mappings":"AAAA,yFAAyF;AACzF,8DAA8D;AAC9D,OAAO,EAAE,UAAU,EAAE,WAAW,EAAE,YAAY,EAAE,QAAQ,EAAE,MAAM,SAAS,CAAC;AAC1E,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AAWjC,4CAA4C;AAC5C,MAAM,YAAY,GAAG,IAAI,GAAG,CAAC,CAAC,cAAc,EAAE,MAAM,CAAC,CAAC,CAAC;AAEvD,4EAA4E;AAC5E,MAAM,iBAAiB,GAAG,CAAC,CAAC;AAE5B,sEAAsE;AACtE,MAAM,aAAa,GAAG,CAAC,CAAC;AAExB,iHAAiH;AACjH,MAAM,qBAAqB,GACzB,sDAAsD,CAAC;AAEzD,MAAM,UAAU,eAAe,CAAC,UAAkB;IAChD,OAAO;QACL,YAAY,EAAE,IAAI,GAAG,CACnB,YAAY,CAAC,UAAU,CAAC,CAAC,GAAG,CAAC,CAAC,GAAG,EAAE,EAAE,CAAC;YACpC,GAAG;YACH,gBAAgB,CAAC,IAAI,CAAC,UAAU,EAAE,GAAG,CAA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,CAAC,CAAC,MAAM,IAAI,CAAC,CAAC,aAAa,CAAC,CAAC,CAAC,CAAC;AACzE,CAAC"}
|
package/dist/service/index.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
export { ServiceBuildError } from "../errors.ts";
|
|
2
|
-
export { excludedFromArtifact } from "./artifact/exclude.ts";
|
|
3
|
-
export type { ServiceArtifact } from "./artifact/write-artifact.ts";
|
|
4
2
|
export { type BuildServiceOptions, type BuiltService, buildService, } from "./build/build-service.ts";
|
|
5
3
|
export type { BuildStep } from "./build/run-step.ts";
|
|
6
|
-
export {
|
|
4
|
+
export type { BuildOutput, TraceSummary } from "./output/build-output.ts";
|
|
5
|
+
export { excludedFromBuildOutput } from "./output/exclude.ts";
|
|
6
|
+
export { isDevCommand, type OutputDirectories, type PackageManager, type ReadFile, type Resolved, resolveServiceBuildSettings, resolveStartAfterBuild, type ServiceBuildSettings, type ServiceConfig, type Source, type Start, } from "./settings/index.ts";
|
|
7
7
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/service/index.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,iBAAiB,EAAE,MAAM,cAAc,CAAC;AACjD,OAAO,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/service/index.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,iBAAiB,EAAE,MAAM,cAAc,CAAC;AACjD,OAAO,EACL,KAAK,mBAAmB,EACxB,KAAK,YAAY,EACjB,YAAY,GACb,MAAM,0BAA0B,CAAC;AAClC,YAAY,EAAE,SAAS,EAAE,MAAM,qBAAqB,CAAC;AACrD,YAAY,EAAE,WAAW,EAAE,YAAY,EAAE,MAAM,0BAA0B,CAAC;AAC1E,OAAO,EAAE,uBAAuB,EAAE,MAAM,qBAAqB,CAAC;AAC9D,OAAO,EACL,YAAY,EACZ,KAAK,iBAAiB,EACtB,KAAK,cAAc,EACnB,KAAK,QAAQ,EACb,KAAK,QAAQ,EACb,2BAA2B,EAC3B,sBAAsB,EACtB,KAAK,oBAAoB,EACzB,KAAK,aAAa,EAClB,KAAK,MAAM,EACX,KAAK,KAAK,GACX,MAAM,qBAAqB,CAAC"}
|
package/dist/service/index.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
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.js";
|
|
4
|
-
export { excludedFromArtifact } from "./artifact/exclude.js";
|
|
5
4
|
export { buildService, } from "./build/build-service.js";
|
|
5
|
+
export { excludedFromBuildOutput } from "./output/exclude.js";
|
|
6
6
|
export { isDevCommand, resolveServiceBuildSettings, resolveStartAfterBuild, } from "./settings/index.js";
|
|
7
7
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/service/index.ts"],"names":[],"mappings":"AAAA,
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/service/index.ts"],"names":[],"mappings":"AAAA,oIAAoI;AACpI,+DAA+D;AAC/D,OAAO,EAAE,iBAAiB,EAAE,MAAM,cAAc,CAAC;AACjD,OAAO,EAGL,YAAY,GACb,MAAM,0BAA0B,CAAC;AAGlC,OAAO,EAAE,uBAAuB,EAAE,MAAM,qBAAqB,CAAC;AAC9D,OAAO,EACL,YAAY,EAKZ,2BAA2B,EAC3B,sBAAsB,GAKvB,MAAM,qBAAqB,CAAC"}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
/** The Launcher, relative to the
|
|
1
|
+
/** The Launcher, relative to the build output folder. Compute starts this file. */
|
|
2
2
|
export declare const LAUNCHER_FILE = ".prisma/launcher.mjs";
|
|
3
|
-
/** The Start plan, relative to the
|
|
3
|
+
/** The Start plan, relative to the build output folder. */
|
|
4
4
|
export declare const START_PLAN_FILE = ".prisma/plan.json";
|
|
5
5
|
/** The port the Service gets as `PORT` when Compute sets none and the user stated none. */
|
|
6
6
|
export declare const DEFAULT_PORT = 8080;
|
|
@@ -11,7 +11,7 @@ export type StartPlan =
|
|
|
11
11
|
command: string;
|
|
12
12
|
port: number | null;
|
|
13
13
|
}
|
|
14
|
-
/** Serve a folder of static files. `dir` is relative to the
|
|
14
|
+
/** Serve a folder of static files. `dir` is relative to the build output folder. */
|
|
15
15
|
| {
|
|
16
16
|
kind: "static";
|
|
17
17
|
dir: string;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"start-plan.d.ts","sourceRoot":"","sources":["../../../src/service/launcher-contract/start-plan.ts"],"names":[],"mappings":"AAIA
|
|
1
|
+
{"version":3,"file":"start-plan.d.ts","sourceRoot":"","sources":["../../../src/service/launcher-contract/start-plan.ts"],"names":[],"mappings":"AAIA,mFAAmF;AACnF,eAAO,MAAM,aAAa,yBAAyB,CAAC;AAEpD,2DAA2D;AAC3D,eAAO,MAAM,eAAe,sBAAsB,CAAC;AAEnD,2FAA2F;AAC3F,eAAO,MAAM,YAAY,OAAO,CAAC;AAEjC,MAAM,MAAM,SAAS;AACnB,wFAAwF;AACtF;IAAE,IAAI,EAAE,SAAS,CAAC;IAAC,OAAO,EAAE,MAAM,CAAC;IAAC,IAAI,EAAE,MAAM,GAAG,IAAI,CAAA;CAAE;AAC3D,oFAAoF;GAClF;IAAE,IAAI,EAAE,QAAQ,CAAC;IAAC,GAAG,EAAE,MAAM,CAAC;IAAC,IAAI,EAAE,MAAM,GAAG,IAAI,CAAA;CAAE,CAAC"}
|
|
@@ -1,9 +1,9 @@
|
|
|
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
|
-
/** The Launcher, relative to the
|
|
4
|
+
/** The Launcher, relative to the build output folder. Compute starts this file. */
|
|
5
5
|
export const LAUNCHER_FILE = ".prisma/launcher.mjs";
|
|
6
|
-
/** The Start plan, relative to the
|
|
6
|
+
/** The Start plan, relative to the build output folder. */
|
|
7
7
|
export const START_PLAN_FILE = ".prisma/plan.json";
|
|
8
8
|
/** The port the Service gets as `PORT` when Compute sets none and the user stated none. */
|
|
9
9
|
export const DEFAULT_PORT = 8080;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"start-plan.js","sourceRoot":"","sources":["../../../src/service/launcher-contract/start-plan.ts"],"names":[],"mappings":"AAAA,iFAAiF;AACjF,
|
|
1
|
+
{"version":3,"file":"start-plan.js","sourceRoot":"","sources":["../../../src/service/launcher-contract/start-plan.ts"],"names":[],"mappings":"AAAA,iFAAiF;AACjF,2GAA2G;AAC3G,mFAAmF;AAEnF,mFAAmF;AACnF,MAAM,CAAC,MAAM,aAAa,GAAG,sBAAsB,CAAC;AAEpD,2DAA2D;AAC3D,MAAM,CAAC,MAAM,eAAe,GAAG,mBAAmB,CAAC;AAEnD,2FAA2F;AAC3F,MAAM,CAAC,MAAM,YAAY,GAAG,IAAI,CAAC"}
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
import type { OutputDirectories, PackageJson, Start } from "../settings/types.ts";
|
|
2
|
+
import { type Untraceable } from "./trace/trace.ts";
|
|
3
|
+
/** Where the build output of a traced server is written, relative to the Service folder. */
|
|
4
|
+
export declare const BUILD_OUTPUT_FOLDER: string;
|
|
5
|
+
/** What a build hands to the caller: a folder and the file Compute starts in it. */
|
|
6
|
+
export type BuildOutput = {
|
|
7
|
+
/** The folder to copy or upload, without what `excludedFromBuildOutput` names. A real path: no part of it is a symbolic link. */
|
|
8
|
+
dir: string;
|
|
9
|
+
/** The file Compute starts, relative to `dir`. */
|
|
10
|
+
entrypoint: string;
|
|
11
|
+
} & ({
|
|
12
|
+
/** A folder of static files that the build wrote. Nothing else is needed to serve it. */
|
|
13
|
+
kind: "static site";
|
|
14
|
+
} | {
|
|
15
|
+
/** The source files and the trace of the server: the files of `node_modules` that it loads. */
|
|
16
|
+
kind: "traced server";
|
|
17
|
+
trace: TraceSummary;
|
|
18
|
+
} | {
|
|
19
|
+
/** The whole Service folder, with all of `node_modules`, because the server could not be traced. */
|
|
20
|
+
kind: "whole folder";
|
|
21
|
+
reason: Untraceable;
|
|
22
|
+
});
|
|
23
|
+
/** What the build output of a traced server holds, for the caller to show. Paths are relative to the Service folder. */
|
|
24
|
+
export interface TraceSummary {
|
|
25
|
+
files: number;
|
|
26
|
+
bytes: number;
|
|
27
|
+
entrypoints: string[];
|
|
28
|
+
bins: string[];
|
|
29
|
+
optionalPeerDependencies: string[];
|
|
30
|
+
}
|
|
31
|
+
/**
|
|
32
|
+
* Writes the build output for how the Service starts, with the Launcher and the Start plan in it.
|
|
33
|
+
*
|
|
34
|
+
* - Static files: the folder the build wrote.
|
|
35
|
+
* - A start command: the source files and the trace of the server it starts, in `.prisma/output`.
|
|
36
|
+
* - A start command whose server cannot be traced: the whole Service folder.
|
|
37
|
+
*/
|
|
38
|
+
export declare function writeBuildOutput(options: {
|
|
39
|
+
serviceDir: string;
|
|
40
|
+
start: Start;
|
|
41
|
+
/** The port the user stated, or null. */
|
|
42
|
+
port: number | null;
|
|
43
|
+
packageJson: PackageJson;
|
|
44
|
+
outputDirectories: OutputDirectories;
|
|
45
|
+
signal?: AbortSignal;
|
|
46
|
+
}): Promise<BuildOutput>;
|
|
47
|
+
//# sourceMappingURL=build-output.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"build-output.d.ts","sourceRoot":"","sources":["../../../src/service/output/build-output.ts"],"names":[],"mappings":"AASA,OAAO,KAAK,EACV,iBAAiB,EACjB,WAAW,EACX,KAAK,EACN,MAAM,sBAAsB,CAAC;AAK9B,OAAO,EAGL,KAAK,WAAW,EACjB,MAAM,kBAAkB,CAAC;AAE1B,4FAA4F;AAC5F,eAAO,MAAM,mBAAmB,QAAiC,CAAC;AAElE,oFAAoF;AACpF,MAAM,MAAM,WAAW,GAAG;IACxB,iIAAiI;IACjI,GAAG,EAAE,MAAM,CAAC;IACZ,kDAAkD;IAClD,UAAU,EAAE,MAAM,CAAC;CACpB,GAAG,CACA;IACE,yFAAyF;IACzF,IAAI,EAAE,aAAa,CAAC;CACrB,GACD;IACE,+FAA+F;IAC/F,IAAI,EAAE,eAAe,CAAC;IACtB,KAAK,EAAE,YAAY,CAAC;CACrB,GACD;IACE,oGAAoG;IACpG,IAAI,EAAE,cAAc,CAAC;IACrB,MAAM,EAAE,WAAW,CAAC;CACrB,CACJ,CAAC;AAEF,wHAAwH;AACxH,MAAM,WAAW,YAAY;IAC3B,KAAK,EAAE,MAAM,CAAC;IACd,KAAK,EAAE,MAAM,CAAC;IACd,WAAW,EAAE,MAAM,EAAE,CAAC;IACtB,IAAI,EAAE,MAAM,EAAE,CAAC;IACf,wBAAwB,EAAE,MAAM,EAAE,CAAC;CACpC;AAID;;;;;;GAMG;AACH,wBAAsB,gBAAgB,CAAC,OAAO,EAAE;IAC9C,UAAU,EAAE,MAAM,CAAC;IACnB,KAAK,EAAE,KAAK,CAAC;IACb,yCAAyC;IACzC,IAAI,EAAE,MAAM,GAAG,IAAI,CAAC;IACpB,WAAW,EAAE,WAAW,CAAC;IACzB,iBAAiB,EAAE,iBAAiB,CAAC;IACrC,MAAM,CAAC,EAAE,WAAW,CAAC;CACtB,GAAG,OAAO,CAAC,WAAW,CAAC,CA+DvB"}
|
|
@@ -0,0 +1,97 @@
|
|
|
1
|
+
// The build output of a Service: the folder a build hands to the caller, and the file Compute starts in it.
|
|
2
|
+
import { copyFileSync, mkdirSync, realpathSync, writeFileSync } from "node:fs";
|
|
3
|
+
import { rm } from "node:fs/promises";
|
|
4
|
+
import path from "node:path";
|
|
5
|
+
import { LAUNCHER_FILE, START_PLAN_FILE, } from "../launcher-contract/start-plan.js";
|
|
6
|
+
import { Copy } from "./copy.js";
|
|
7
|
+
import { excludedFromBuildOutput } from "./exclude.js";
|
|
8
|
+
import { launcherFile } from "./launcher-file.js";
|
|
9
|
+
import { inOutputDirectory, sourceFiles } from "./source-files.js";
|
|
10
|
+
import { traceServer, } from "./trace/trace.js";
|
|
11
|
+
/** Where the build output of a traced server is written, relative to the Service folder. */
|
|
12
|
+
export const BUILD_OUTPUT_FOLDER = path.join(".prisma", "output");
|
|
13
|
+
const SCRIPT_FILE = /\.(c|m)?js$/;
|
|
14
|
+
/**
|
|
15
|
+
* Writes the build output for how the Service starts, with the Launcher and the Start plan in it.
|
|
16
|
+
*
|
|
17
|
+
* - Static files: the folder the build wrote.
|
|
18
|
+
* - A start command: the source files and the trace of the server it starts, in `.prisma/output`.
|
|
19
|
+
* - A start command whose server cannot be traced: the whole Service folder.
|
|
20
|
+
*/
|
|
21
|
+
export async function writeBuildOutput(options) {
|
|
22
|
+
const { start } = options;
|
|
23
|
+
// The trace holds real paths, so every path here starts from the real path of the Service folder.
|
|
24
|
+
const serviceDir = realpathSync(options.serviceDir);
|
|
25
|
+
if (start.kind === "static") {
|
|
26
|
+
const dir = path.join(serviceDir, start.dir);
|
|
27
|
+
writeLauncher(dir, { kind: "static", dir: ".", port: options.port });
|
|
28
|
+
return { dir, entrypoint: LAUNCHER_FILE, kind: "static site" };
|
|
29
|
+
}
|
|
30
|
+
const plan = {
|
|
31
|
+
kind: "command",
|
|
32
|
+
command: start.command,
|
|
33
|
+
port: options.port,
|
|
34
|
+
};
|
|
35
|
+
const source = await sourceFiles(serviceDir, options.outputDirectories, options.signal);
|
|
36
|
+
const trace = await traceServer({
|
|
37
|
+
serviceDir,
|
|
38
|
+
command: start.command,
|
|
39
|
+
packageJson: options.packageJson,
|
|
40
|
+
builtScripts: source.filter((file) => SCRIPT_FILE.test(file) &&
|
|
41
|
+
inOutputDirectory(serviceDir, options.outputDirectories, file)),
|
|
42
|
+
signal: options.signal,
|
|
43
|
+
});
|
|
44
|
+
const dir = path.join(serviceDir, BUILD_OUTPUT_FOLDER);
|
|
45
|
+
// An earlier build may have written this folder. It must not stay in a whole-folder build output.
|
|
46
|
+
await rm(dir, { recursive: true, force: true });
|
|
47
|
+
if (typeof trace === "string") {
|
|
48
|
+
writeLauncher(serviceDir, plan);
|
|
49
|
+
return {
|
|
50
|
+
dir: serviceDir,
|
|
51
|
+
entrypoint: LAUNCHER_FILE,
|
|
52
|
+
kind: "whole folder",
|
|
53
|
+
reason: trace,
|
|
54
|
+
};
|
|
55
|
+
}
|
|
56
|
+
const copied = await copyTracedServer(serviceDir, dir, source, trace);
|
|
57
|
+
writeLauncher(dir, plan);
|
|
58
|
+
const relative = (file) => path.relative(serviceDir, file);
|
|
59
|
+
return {
|
|
60
|
+
dir,
|
|
61
|
+
entrypoint: LAUNCHER_FILE,
|
|
62
|
+
kind: "traced server",
|
|
63
|
+
trace: {
|
|
64
|
+
files: copied.files,
|
|
65
|
+
bytes: copied.bytes,
|
|
66
|
+
entrypoints: trace.entrypoints.map(relative),
|
|
67
|
+
bins: trace.bins,
|
|
68
|
+
optionalPeerDependencies: trace.optionalPeerDependencies,
|
|
69
|
+
},
|
|
70
|
+
};
|
|
71
|
+
}
|
|
72
|
+
/** Copies the source files and the trace into the build output folder, each to the place it has in the Service folder. */
|
|
73
|
+
async function copyTracedServer(serviceDir, dir, source, trace) {
|
|
74
|
+
const copy = new Copy(serviceDir, dir);
|
|
75
|
+
for (const file of source) {
|
|
76
|
+
await copy.file(file);
|
|
77
|
+
}
|
|
78
|
+
for (const file of trace.files) {
|
|
79
|
+
if (!excludedFromBuildOutput(path.basename(file))) {
|
|
80
|
+
await copy.file(file);
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
for (const installed of trace.packages) {
|
|
84
|
+
await copy.file(installed.link);
|
|
85
|
+
await copy.packageFolder(installed.dir);
|
|
86
|
+
}
|
|
87
|
+
for (const bin of trace.bins) {
|
|
88
|
+
await copy.file(path.join(serviceDir, "node_modules", ".bin", bin));
|
|
89
|
+
}
|
|
90
|
+
return copy;
|
|
91
|
+
}
|
|
92
|
+
function writeLauncher(dir, plan) {
|
|
93
|
+
mkdirSync(path.join(dir, path.dirname(LAUNCHER_FILE)), { recursive: true });
|
|
94
|
+
copyFileSync(launcherFile(), path.join(dir, LAUNCHER_FILE));
|
|
95
|
+
writeFileSync(path.join(dir, START_PLAN_FILE), JSON.stringify(plan));
|
|
96
|
+
}
|
|
97
|
+
//# sourceMappingURL=build-output.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"build-output.js","sourceRoot":"","sources":["../../../src/service/output/build-output.ts"],"names":[],"mappings":"AAAA,4GAA4G;AAC5G,OAAO,EAAE,YAAY,EAAE,SAAS,EAAE,YAAY,EAAE,aAAa,EAAE,MAAM,SAAS,CAAC;AAC/E,OAAO,EAAE,EAAE,EAAE,MAAM,kBAAkB,CAAC;AACtC,OAAO,IAAI,MAAM,WAAW,CAAC;AAC7B,OAAO,EACL,aAAa,EACb,eAAe,GAEhB,MAAM,oCAAoC,CAAC;AAM5C,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AACjC,OAAO,EAAE,uBAAuB,EAAE,MAAM,cAAc,CAAC;AACvD,OAAO,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;AAClD,OAAO,EAAE,iBAAiB,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AACnE,OAAO,EAEL,WAAW,GAEZ,MAAM,kBAAkB,CAAC;AAE1B,4FAA4F;AAC5F,MAAM,CAAC,MAAM,mBAAmB,GAAG,IAAI,CAAC,IAAI,CAAC,SAAS,EAAE,QAAQ,CAAC,CAAC;AAkClE,MAAM,WAAW,GAAG,aAAa,CAAC;AAElC;;;;;;GAMG;AACH,MAAM,CAAC,KAAK,UAAU,gBAAgB,CAAC,OAQtC;IACC,MAAM,EAA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