@prisma/compute-sdk 0.46.0 → 0.48.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 +20 -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 +21 -13
- package/dist/service/build/build-service.js.map +1 -1
- package/dist/service/build/output-directories.d.ts +20 -0
- package/dist/service/build/output-directories.d.ts.map +1 -0
- package/dist/service/build/{build-output.js → output-directories.js} +45 -9
- 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/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/{artifact/write-artifact.d.ts → output/write-build-output.d.ts} +6 -6
- package/dist/service/output/write-build-output.d.ts.map +1 -0
- package/dist/service/{artifact/write-artifact.js → output/write-build-output.js} +7 -7
- package/dist/service/output/write-build-output.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 +3 -3
- 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 +34 -19
- package/src/service/build/{build-output.ts → output-directories.ts} +65 -13
- 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/{artifact → output}/exclude.ts +2 -2
- package/src/service/{artifact → output}/launcher-file.ts +1 -1
- package/src/service/{artifact/write-artifact.ts → output/write-build-output.ts} +9 -9
- 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 +3 -3
- 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.map +0 -1
- package/dist/service/artifact/write-artifact.js.map +0 -1
- package/dist/service/build/build-output.d.ts +0 -15
- package/dist/service/build/build-output.d.ts.map +0 -1
- package/dist/service/build/build-output.js.map +0 -1
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
|
|
|
@@ -503,6 +503,8 @@ The start is the first match of:
|
|
|
503
503
|
5. An entry file in the source: `main` or `module` from `package.json`, `index.ts`, `server.ts`, `src/index.ts`, `src/server.ts`, or their `.js` forms.
|
|
504
504
|
6. `index.html` in the Service folder.
|
|
505
505
|
|
|
506
|
+
A folder counts as created by the build when it is new after the build, or when the build wrote a file in it. A file that a build restores from a cache with its old modification time counts as written. So a second build in the same folder finds the same output as the first. A build that writes nothing the second time, such as an incremental TypeScript build with no changed source, has no output to find: state `start` or `static` in the Service config for it.
|
|
507
|
+
|
|
506
508
|
Rules 3 to 6 need the build output. For them `start` is `"after build"`, and `buildService` decides the start once the build has run.
|
|
507
509
|
|
|
508
510
|
```ts
|
|
@@ -561,7 +563,7 @@ await buildService({
|
|
|
561
563
|
|
|
562
564
|
### `buildService(options)`
|
|
563
565
|
|
|
564
|
-
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.
|
|
565
567
|
|
|
566
568
|
```ts
|
|
567
569
|
const built = await buildService({
|
|
@@ -572,54 +574,54 @@ const built = await buildService({
|
|
|
572
574
|
if (built.isOk()) {
|
|
573
575
|
built.value.start; // { value: { kind: "command", command: "npm run start" }, from: "package.json" }
|
|
574
576
|
built.value.steps; // [{ name: "install", command: "npm ci", seconds: 12, ok: true }, { name: "build", ... }]
|
|
575
|
-
built.value.
|
|
577
|
+
built.value.output; // { dir: "/repo", entrypoint: ".prisma/launcher.mjs" }
|
|
576
578
|
}
|
|
577
579
|
```
|
|
578
580
|
|
|
579
|
-
A build that produces no
|
|
581
|
+
A build that produces no build output returns a `ServiceBuildError`. It is not thrown.
|
|
580
582
|
|
|
581
583
|
```ts
|
|
582
584
|
if (built.isErr()) {
|
|
583
585
|
built.error.code; // "build_failed"
|
|
584
586
|
built.error.message; // "Build failed: npm run build"
|
|
585
|
-
built.error.
|
|
587
|
+
built.error.commandOutput; // "Service build failed (exit code 2):\nsrc/index.ts(3,1): error TS2304: ..."
|
|
586
588
|
built.error.steps; // [{ name: "install", ok: true, ... }, { name: "build", ok: false, ... }]
|
|
587
589
|
}
|
|
588
590
|
```
|
|
589
591
|
|
|
590
592
|
| `code` | Meaning |
|
|
591
593
|
| --- | --- |
|
|
592
|
-
| `install_failed` | The install command exited with an error. `
|
|
593
|
-
| `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. |
|
|
594
596
|
| `no_start` | No start rule matched. |
|
|
595
597
|
|
|
596
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.
|
|
597
599
|
|
|
598
|
-
For a static site the
|
|
600
|
+
For a static site the build output is only the built folder. For every other Service it is the Service folder.
|
|
599
601
|
|
|
600
602
|
### What the caller does next
|
|
601
603
|
|
|
602
|
-
The
|
|
604
|
+
The build output is a folder (`output.dir`) 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.
|
|
603
605
|
|
|
604
|
-
The caller leaves out every file and folder that `
|
|
606
|
+
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.
|
|
605
607
|
|
|
606
608
|
```ts
|
|
607
609
|
import { cp } from "node:fs/promises";
|
|
608
610
|
import path from "node:path";
|
|
609
|
-
import {
|
|
611
|
+
import { excludedFromBuildOutput } from "@prisma/compute-sdk/service";
|
|
610
612
|
|
|
611
|
-
const { dir, entrypoint } = built.value.
|
|
613
|
+
const { dir, entrypoint } = built.value.output;
|
|
612
614
|
|
|
613
|
-
await cp(dir, "/tmp/
|
|
615
|
+
await cp(dir, "/tmp/build-output", {
|
|
614
616
|
recursive: true,
|
|
615
|
-
filter: (source) => !
|
|
617
|
+
filter: (source) => !excludedFromBuildOutput(path.basename(source)),
|
|
616
618
|
});
|
|
617
619
|
```
|
|
618
620
|
|
|
619
621
|
`PreBuilt` takes the same function as its `exclude` option.
|
|
620
622
|
|
|
621
623
|
```ts
|
|
622
|
-
new PreBuilt({ appPath: dir, entrypoint, exclude:
|
|
624
|
+
new PreBuilt({ appPath: dir, entrypoint, exclude: excludedFromBuildOutput });
|
|
623
625
|
```
|
|
624
626
|
|
|
625
627
|
### 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
|
@@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mB,GACnB,yBAAyB,GACzB,YAAY,GACZ,qBAAqB,GACrB,cAAc,CAAC;AAEnB,MAAM,MAAM,sBAAsB,GAC9B,cAAc,GACd,oBAAoB,GACpB,uBAAuB,GACvB,mBAAmB,GACnB,QAAQ,GACR,YAAY,GACZ,qBAAqB,CAAC;AAE1B,MAAM,MAAM,eAAe,GACvB,cAAc,GACd,mBAAmB,GACnB,QAAQ,GACR,qBAAqB,CAAC;AAE1B,MAAM,MAAM,YAAY,GACpB,mBAAmB,GACnB,QAAQ,GACR,oBAAoB,GACpB,uBAAuB,GACvB,YAAY,GACZ,qBAAqB,GACrB,cAAc,CAAC;AAEnB,MAAM,MAAM,eAAe,GAAG,cAAc,GAAG,mBAAmB,GAAG,QAAQ,CAAC;AAE9E,MAAM,MAAM,wBAAwB,GAChC,cAAc,GACd,mBAAmB,GACnB,QAAQ,GACR,YAAY,GACZ,qBAAqB,CAAC;;UAIlB,gBAAgB,GAAG,cAAc,GAAG,UAAU;IACpD,oBAAoB;aACX,MAAM;cACL,oBAAoB;WACvB,SAAS,EAAE;IAClB,qFAAqF;oBACrE,MAAM;;AARxB,8FAA8F;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,eA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,EAAE,OAAO,IAAI,CAAC,KAAK,qBAAqB;SAChD,CAAC,CAAC;IACL,CAAC;CACF;AAED,MAAM,OAAO,cAAe,SAAQ,WAAW,CAAC,gBAAgB,CAAC,EAE7D;IACF,YAAY,IAA2B;QACrC,KAAK,CAAC,EAAE,OAAO,EAAE,IAAI,EAAE,OAAO,IAAI,qBAAqB,EAAE,CAAC,CAAC;IAC7D,CAAC;CACF;AAED,MAAM,OAAO,qBAAsB,SAAQ,WAAW,CACpD,uBAAuB,CACxB,EAKG;IACF,YAAY,IAIX;QACC,MAAM,SAAS,GAAG,IAAI,CAAC,QAAQ,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,YAAY,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;QACtE,KAAK,CAAC;YACJ,GAAG,IAAI;YACP,OAAO,EAAE,qBAAqB,IAAI,CAAC,QAAQ,CAAC,MAAM,mBAAmB,SAAS,EAAE;SACjF,CAAC,CAAC;IACL,CAAC;CACF;AAED,MAAM,OAAO,mBAAoB,SAAQ,WAAW,CAAC,qBAAqB,CAAC,EAEvE;CAAG;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/write-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,EACL,KAAK,
|
|
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,EACL,KAAK,WAAW,EAEjB,MAAM,iCAAiC,CAAC;AAKzC,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,CA0ClD"}
|
|
@@ -1,12 +1,12 @@
|
|
|
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/write-build-output.js";
|
|
8
8
|
import { resolveServiceBuildSettings, resolveStartAfterBuild, } from "../settings/resolve.js";
|
|
9
|
-
import {
|
|
9
|
+
import { outputDirectoriesSince, snapshotFolders, } from "./output-directories.js";
|
|
10
10
|
import { runStep, } from "./run-step.js";
|
|
11
11
|
/** The build failures have stable codes: the CLI, Console and the fix task key on them. */
|
|
12
12
|
const STEP_FAILURES = {
|
|
@@ -18,7 +18,7 @@ const NO_START = {
|
|
|
18
18
|
message: "No start command. Add a start script to package.json, or set start or static in prisma.config.ts.",
|
|
19
19
|
};
|
|
20
20
|
/**
|
|
21
|
-
* Runs the Service's install and build commands, decides how the Service starts, and writes the
|
|
21
|
+
* Runs the Service's install and build commands, decides how the Service starts, and writes the build output.
|
|
22
22
|
*
|
|
23
23
|
* A failed install, a failed build and a missing start are expected outcomes:
|
|
24
24
|
* they come back as a `ServiceBuildError`, not as a thrown error.
|
|
@@ -29,23 +29,27 @@ export async function buildService(options) {
|
|
|
29
29
|
const settings = await resolveServiceBuildSettings(read, options.config, options.signal);
|
|
30
30
|
const steps = [];
|
|
31
31
|
const fail = (failure) => Result.err(new ServiceBuildError({ ...failure, settings, steps }));
|
|
32
|
-
const
|
|
33
|
-
if (
|
|
34
|
-
return fail(
|
|
32
|
+
const outputDirectories = await installAndBuild(settings, options, steps);
|
|
33
|
+
if (outputDirectories.isErr()) {
|
|
34
|
+
return fail(outputDirectories.error);
|
|
35
35
|
}
|
|
36
36
|
const start = settings.start === "after build"
|
|
37
|
-
? await resolveStartAfterBuild(read,
|
|
37
|
+
? await resolveStartAfterBuild(read, outputDirectories.value, options.signal)
|
|
38
38
|
: settings.start;
|
|
39
39
|
if (start === null) {
|
|
40
40
|
return fail(NO_START);
|
|
41
41
|
}
|
|
42
42
|
const port = settings.port?.value ?? null;
|
|
43
|
-
const
|
|
43
|
+
const output = writeBuildOutput({
|
|
44
|
+
serviceDir: dir,
|
|
45
|
+
start: start.value,
|
|
46
|
+
port,
|
|
47
|
+
});
|
|
44
48
|
return Result.ok({
|
|
45
49
|
settings: { ...settings, start },
|
|
46
50
|
start,
|
|
47
51
|
steps,
|
|
48
|
-
|
|
52
|
+
output,
|
|
49
53
|
});
|
|
50
54
|
}
|
|
51
55
|
/** Runs the install, then the build. Returns what the build created, or the step that failed. */
|
|
@@ -63,7 +67,7 @@ async function installAndBuild(settings, options, steps) {
|
|
|
63
67
|
if (!built.ok) {
|
|
64
68
|
return Result.err(stepFailed(build, built.output));
|
|
65
69
|
}
|
|
66
|
-
return Result.ok(
|
|
70
|
+
return Result.ok(outputDirectoriesSince(dir, beforeBuild));
|
|
67
71
|
}
|
|
68
72
|
/** The build runs in production mode. The caller's variables win over these. */
|
|
69
73
|
function buildStep(settings, extraEnv = {}) {
|
|
@@ -84,9 +88,13 @@ function installStep(settings, extraEnv = {}) {
|
|
|
84
88
|
env: { ...process.env, CI: "true", ...extraEnv, NODE_ENV: "development" },
|
|
85
89
|
};
|
|
86
90
|
}
|
|
87
|
-
function stepFailed(step,
|
|
91
|
+
function stepFailed(step, commandOutput) {
|
|
88
92
|
const { code, label } = STEP_FAILURES[step.name];
|
|
89
|
-
return {
|
|
93
|
+
return {
|
|
94
|
+
code,
|
|
95
|
+
message: `${label} failed: ${step.command}`,
|
|
96
|
+
commandOutput,
|
|
97
|
+
};
|
|
90
98
|
}
|
|
91
99
|
/** Reads the files of the Service folder for the Build rules. */
|
|
92
100
|
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,EAEL,gBAAgB,GACjB,MAAM,iCAAiC,CAAC;AACzC,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,OA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B,EAC9B,WAAmC,EAAE;IAErC,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"}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import type { OutputDirectories } from "../settings/types.ts";
|
|
2
|
+
/** The folders of the Service folder at one moment. Taken before the build, it tells what the build wrote. */
|
|
3
|
+
export interface FolderSnapshot {
|
|
4
|
+
/** Each top-level folder, with the time of the newest change to a file in it. */
|
|
5
|
+
topLevelDirs: Map<string, number>;
|
|
6
|
+
/** Each folder that holds an `index.html`, with the time that file last changed. */
|
|
7
|
+
staticDirs: Map<string, number>;
|
|
8
|
+
}
|
|
9
|
+
export declare function snapshotFolders(serviceDir: string): FolderSnapshot;
|
|
10
|
+
/**
|
|
11
|
+
* What the build wrote: the folders that were not in the snapshot, and the folders that the build wrote to again.
|
|
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
|
+
*/
|
|
14
|
+
export declare function outputDirectoriesSince(serviceDir: string, before: FolderSnapshot): OutputDirectories;
|
|
15
|
+
/**
|
|
16
|
+
* True when the site in `dir` holds the first scripts and styles its `index.html` links to.
|
|
17
|
+
* A page copied out of a server build does not, and cannot be served alone.
|
|
18
|
+
*/
|
|
19
|
+
export declare function isSelfContained(dir: string): boolean;
|
|
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"}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
// Finds what the build
|
|
1
|
+
// Finds what the build wrote by comparing the Service folder before and after the build.
|
|
2
2
|
// The Build rules must not guess output folders by framework.
|
|
3
|
-
import { existsSync, readdirSync, readFileSync } from "node:fs";
|
|
3
|
+
import { existsSync, readdirSync, readFileSync, statSync } from "node:fs";
|
|
4
4
|
import { join } from "node:path";
|
|
5
5
|
/** Folders that never hold build output. */
|
|
6
6
|
const SKIPPED_DIRS = new Set(["node_modules", ".git"]);
|
|
@@ -12,16 +12,27 @@ const CHECKED_LINKS = 5;
|
|
|
12
12
|
const LOCAL_SCRIPT_OR_STYLE = /(?:src|href)="(\/[^"/][^"?#]*\.(?:js|mjs|css))["?#]/g;
|
|
13
13
|
export function snapshotFolders(serviceDir) {
|
|
14
14
|
return {
|
|
15
|
-
topLevelDirs: new
|
|
16
|
-
|
|
15
|
+
topLevelDirs: new Map(topLevelDirs(serviceDir).map((dir) => [
|
|
16
|
+
dir,
|
|
17
|
+
newestFileChange(join(serviceDir, dir)),
|
|
18
|
+
])),
|
|
19
|
+
staticDirs: new Map(dirsWithIndexHtml(serviceDir, STATIC_SITE_DEPTH).map((dir) => [
|
|
20
|
+
dir,
|
|
21
|
+
indexHtmlChange(serviceDir, dir),
|
|
22
|
+
])),
|
|
17
23
|
};
|
|
18
24
|
}
|
|
19
|
-
/**
|
|
20
|
-
|
|
25
|
+
/**
|
|
26
|
+
* What the build wrote: the folders that were not in the snapshot, and the folders that the build wrote to again.
|
|
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
|
+
*/
|
|
29
|
+
export function outputDirectoriesSince(serviceDir, before) {
|
|
21
30
|
return {
|
|
22
|
-
newDirs: topLevelDirs(serviceDir).filter((dir) =>
|
|
31
|
+
newDirs: topLevelDirs(serviceDir).filter((dir) => newestFileChange(join(serviceDir, dir)) >
|
|
32
|
+
(before.topLevelDirs.get(dir) ?? Number.NEGATIVE_INFINITY)),
|
|
23
33
|
newStaticDirs: dirsWithIndexHtml(serviceDir, STATIC_SITE_DEPTH)
|
|
24
|
-
.filter((dir) =>
|
|
34
|
+
.filter((dir) => indexHtmlChange(serviceDir, dir) >
|
|
35
|
+
(before.staticDirs.get(dir) ?? Number.NEGATIVE_INFINITY))
|
|
25
36
|
.filter((dir) => isSelfContained(join(serviceDir, dir)))
|
|
26
37
|
.sort(shallowestFirst),
|
|
27
38
|
};
|
|
@@ -37,6 +48,31 @@ export function isSelfContained(dir) {
|
|
|
37
48
|
.slice(0, CHECKED_LINKS);
|
|
38
49
|
return links.every((link) => existsSync(join(dir, link)));
|
|
39
50
|
}
|
|
51
|
+
function indexHtmlChange(serviceDir, dir) {
|
|
52
|
+
return changeTime(join(serviceDir, dir, "index.html"));
|
|
53
|
+
}
|
|
54
|
+
/**
|
|
55
|
+
* When the file was last written. A tool that restores a file from a cache can give it its old modification time,
|
|
56
|
+
* so the time the file system recorded the write counts too.
|
|
57
|
+
*/
|
|
58
|
+
function changeTime(file) {
|
|
59
|
+
const stats = statSync(file);
|
|
60
|
+
return Math.max(stats.mtimeMs, stats.ctimeMs);
|
|
61
|
+
}
|
|
62
|
+
/** The time of the newest change to a file in `dir`, at any depth. A folder with no file gives 0. */
|
|
63
|
+
function newestFileChange(dir) {
|
|
64
|
+
let newest = 0;
|
|
65
|
+
for (const entry of readdirSync(dir, { withFileTypes: true })) {
|
|
66
|
+
const entryPath = join(dir, entry.name);
|
|
67
|
+
if (entry.isDirectory() && !SKIPPED_DIRS.has(entry.name)) {
|
|
68
|
+
newest = Math.max(newest, newestFileChange(entryPath));
|
|
69
|
+
}
|
|
70
|
+
else if (entry.isFile()) {
|
|
71
|
+
newest = Math.max(newest, changeTime(entryPath));
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
return newest;
|
|
75
|
+
}
|
|
40
76
|
function topLevelDirs(serviceDir) {
|
|
41
77
|
return readdirSync(serviceDir, { withFileTypes: true })
|
|
42
78
|
.filter((entry) => entry.isDirectory() && !SKIPPED_DIRS.has(entry.name))
|
|
@@ -60,4 +96,4 @@ function dirsWithIndexHtml(serviceDir, depth, dir = ".") {
|
|
|
60
96
|
function shallowestFirst(a, b) {
|
|
61
97
|
return a.split("/").length - b.split("/").length || a.localeCompare(b);
|
|
62
98
|
}
|
|
63
|
-
//# 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,CAAC,CAAC;SACxC,CAAC,CACH;QACD,UAAU,EAAE,IAAI,GAAG,CACjB,iBAAiB,CAAC,UAAU,EAAE,iBAAiB,CAAC,CAAC,GAAG,CAAC,CAAC,GAAG,EAAE,EAAE,CAAC;YAC5D,GAAG;YACH,eAAe,CAAC,UAAU,EAAE,GAAG,CAAC;SACjC,CAAC,CACH;KACF,CAAC;AACJ,CAAC;AAED;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CAAC,IAAI,CAAC,CAAC;SACvE,GAAG,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC;AAChC,CAAC;AAED,uGAAuG;AACvG,SAAS,iBAAiB,CACxB,UAAkB,EAClB,KAAa,EACb,GAAG,GAAG,GAAG;IAET,MAAM,KAAK,GAAa,EAAE,CAAC;IAE3B,KAAK,MAAM,KAAK,IAAI,WAAW,CAAC,IAAI,CAAC,UAAU,EAAE,GAAG,CAAC,EAAE;QACrD,aAAa,EAAE,IAAI;KACpB,CAAC,EAAE,CAAC;QACH,IAAI,KAAK,CAAC,MAAM,EAAE,IAAI,KAAK,CAAC,IAAI,KAAK,YAAY,EAAE,CAAC;YAClD,KAAK,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;QAClB,CAAC;QAED,IAAI,KAAK,CAAC,WAAW,EAAE,IAAI,CAAC,YAAY,CAAC,GAAG,CAAC,KAAK,CAAC,IAAI,CAAC,IAAI,KAAK,GAAG,CAAC,EAAE,CAAC;YACtE,KAAK,CAAC,IAAI,CACR,GAAG,iBAAiB,CAAC,UAAU,EAAE,KAAK,GAAG,CAAC,EAAE,IAAI,CAAC,GAAG,EAAE,KAAK,CAAC,IAAI,CAAC,CAAC,CACnE,CAAC;QACJ,CAAC;IACH,CAAC;IAED,OAAO,KAAK,CAAC;AACf,CAAC;AAED,SAAS,eAAe,CAAC,CAAS,EAAE,CAAS;IAC3C,OAAO,CAAC,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,MAAM,GAAG,CAAC,CAAC,KAAK,CAAC,GAAG,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 { excludedFromBuildOutput } from "./output/exclude.ts";
|
|
5
|
+
export type { BuildOutput } from "./output/write-build-output.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,OAAO,EAAE,uBAAuB,EAAE,MAAM,qBAAqB,CAAC;AAC9D,YAAY,EAAE,WAAW,EAAE,MAAM,gCAAgC,CAAC;AAClE,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;AAElC,OAAO,EAAE,uBAAuB,EAAE,MAAM,qBAAqB,CAAC;AAE9D,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,6 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* True for a file or folder that never goes into a build output, at any depth.
|
|
3
|
+
* A CI checkout keeps a token in `.git`, and dotenv files hold local secrets.
|
|
4
|
+
*/
|
|
5
|
+
export declare function excludedFromBuildOutput(name: string): boolean;
|
|
6
|
+
//# sourceMappingURL=exclude.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"exclude.d.ts","sourceRoot":"","sources":["../../../src/service/output/exclude.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,wBAAgB,uBAAuB,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAE7D"}
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* True for a file or folder that never goes into
|
|
2
|
+
* True for a file or folder that never goes into a build output, at any depth.
|
|
3
3
|
* A CI checkout keeps a token in `.git`, and dotenv files hold local secrets.
|
|
4
4
|
*/
|
|
5
|
-
export function
|
|
5
|
+
export function excludedFromBuildOutput(name) {
|
|
6
6
|
return name === ".git" || name === ".env" || name.startsWith(".env.");
|
|
7
7
|
}
|
|
8
8
|
//# sourceMappingURL=exclude.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"exclude.js","sourceRoot":"","sources":["../../../src/service/output/exclude.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,MAAM,UAAU,uBAAuB,CAAC,IAAY;IAClD,OAAO,IAAI,KAAK,MAAM,IAAI,IAAI,KAAK,MAAM,IAAI,IAAI,CAAC,UAAU,CAAC,OAAO,CAAC,CAAC;AACxE,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"launcher-file.d.ts","sourceRoot":"","sources":["../../../src/service/output/launcher-file.ts"],"names":[],"mappings":"AAMA,+EAA+E;AAC/E,wBAAgB,YAAY,IAAI,MAAM,CAUrC"}
|
|
@@ -2,7 +2,7 @@ import { existsSync } from "node:fs";
|
|
|
2
2
|
import { fileURLToPath } from "node:url";
|
|
3
3
|
/** The one-file Launcher, relative to this folder. `src/` and `dist/` hold this folder at the same depth, so one path fits both. */
|
|
4
4
|
const BUNDLED_LAUNCHER = "../../../dist/service/launcher.mjs";
|
|
5
|
-
/** The path of the Launcher as one file, ready to copy into
|
|
5
|
+
/** The path of the Launcher as one file, ready to copy into a build output. */
|
|
6
6
|
export function launcherFile() {
|
|
7
7
|
const file = fileURLToPath(new URL(BUNDLED_LAUNCHER, import.meta.url));
|
|
8
8
|
if (!existsSync(file)) {
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"launcher-file.js","sourceRoot":"","sources":["../../../src/service/output/launcher-file.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,SAAS,CAAC;AACrC,OAAO,EAAE,aAAa,EAAE,MAAM,UAAU,CAAC;AAEzC,oIAAoI;AACpI,MAAM,gBAAgB,GAAG,oCAAoC,CAAC;AAE9D,+EAA+E;AAC/E,MAAM,UAAU,YAAY;IAC1B,MAAM,IAAI,GAAG,aAAa,CAAC,IAAI,GAAG,CAAC,gBAAgB,EAAE,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,CAAC;IAEvE,IAAI,CAAC,UAAU,CAAC,IAAI,CAAC,EAAE,CAAC;QACtB,MAAM,IAAI,KAAK,CACb,8BAA8B,IAAI,uFAAuF,CAC1H,CAAC;IACJ,CAAC;IAED,OAAO,IAAI,CAAC;AACd,CAAC"}
|
|
@@ -1,16 +1,16 @@
|
|
|
1
1
|
import type { Start } from "../settings/types.ts";
|
|
2
2
|
/** What a build hands to the caller: a folder and the file Compute starts in it. */
|
|
3
|
-
export interface
|
|
4
|
-
/** The folder to copy or upload, without what `
|
|
3
|
+
export interface BuildOutput {
|
|
4
|
+
/** The folder to copy or upload, without what `excludedFromBuildOutput` names. */
|
|
5
5
|
dir: string;
|
|
6
6
|
/** The file Compute starts, relative to `dir`. */
|
|
7
7
|
entrypoint: string;
|
|
8
8
|
}
|
|
9
|
-
/** Picks the
|
|
10
|
-
export declare function
|
|
9
|
+
/** Picks the build output folder, and writes the Launcher and the Start plan into it. */
|
|
10
|
+
export declare function writeBuildOutput(options: {
|
|
11
11
|
serviceDir: string;
|
|
12
12
|
start: Start;
|
|
13
13
|
/** The port the user stated, or null. */
|
|
14
14
|
port: number | null;
|
|
15
|
-
}):
|
|
16
|
-
//# sourceMappingURL=write-
|
|
15
|
+
}): BuildOutput;
|
|
16
|
+
//# sourceMappingURL=write-build-output.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"write-build-output.d.ts","sourceRoot":"","sources":["../../../src/service/output/write-build-output.ts"],"names":[],"mappings":"AAOA,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,sBAAsB,CAAC;AAGlD,oFAAoF;AACpF,MAAM,WAAW,WAAW;IAC1B,kFAAkF;IAClF,GAAG,EAAE,MAAM,CAAC;IACZ,kDAAkD;IAClD,UAAU,EAAE,MAAM,CAAC;CACpB;AAED,yFAAyF;AACzF,wBAAgB,gBAAgB,CAAC,OAAO,EAAE;IACxC,UAAU,EAAE,MAAM,CAAC;IACnB,KAAK,EAAE,KAAK,CAAC;IACb,yCAAyC;IACzC,IAAI,EAAE,MAAM,GAAG,IAAI,CAAC;CACrB,GAAG,WAAW,CAWd"}
|
|
@@ -2,23 +2,23 @@ import { copyFileSync, mkdirSync, writeFileSync } from "node:fs";
|
|
|
2
2
|
import { dirname, join } from "node:path";
|
|
3
3
|
import { LAUNCHER_FILE, START_PLAN_FILE, } from "../launcher-contract/start-plan.js";
|
|
4
4
|
import { launcherFile } from "./launcher-file.js";
|
|
5
|
-
/** Picks the
|
|
6
|
-
export function
|
|
7
|
-
const dir =
|
|
5
|
+
/** Picks the build output folder, and writes the Launcher and the Start plan into it. */
|
|
6
|
+
export function writeBuildOutput(options) {
|
|
7
|
+
const dir = outputDir(options.serviceDir, options.start);
|
|
8
8
|
mkdirSync(join(dir, dirname(LAUNCHER_FILE)), { recursive: true });
|
|
9
9
|
copyFileSync(launcherFile(), join(dir, LAUNCHER_FILE));
|
|
10
10
|
writeFileSync(join(dir, START_PLAN_FILE), JSON.stringify(startPlan(options.start, options.port)));
|
|
11
11
|
return { dir, entrypoint: LAUNCHER_FILE };
|
|
12
12
|
}
|
|
13
|
-
/** A static site needs no source and no `node_modules`, so its
|
|
14
|
-
function
|
|
13
|
+
/** A static site needs no source and no `node_modules`, so its build output is the built folder alone. */
|
|
14
|
+
function outputDir(serviceDir, start) {
|
|
15
15
|
return start.kind === "static" ? join(serviceDir, start.dir) : serviceDir;
|
|
16
16
|
}
|
|
17
17
|
function startPlan(start, port) {
|
|
18
18
|
if (start.kind === "static") {
|
|
19
|
-
// The
|
|
19
|
+
// The build output of a static site is the site's own folder, so the plan serves the build output folder itself.
|
|
20
20
|
return { kind: "static", dir: ".", port };
|
|
21
21
|
}
|
|
22
22
|
return { kind: "command", command: start.command, port };
|
|
23
23
|
}
|
|
24
|
-
//# sourceMappingURL=write-
|
|
24
|
+
//# sourceMappingURL=write-build-output.js.map
|