@fungi.computer/oyster 0.52.2 → 0.53.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/agent-computer-source.js +3 -2
- package/dist/build/candidate-cli.mjs +29 -12
- package/dist/build/effect.d.ts +2 -0
- package/dist/build/effect.js +2 -1
- package/dist/build/local-build.d.ts +17 -1
- package/dist/build/local-build.js +112 -10
- package/dist/build/shared-workspace.d.ts +7 -0
- package/dist/build/shared-workspace.js +18 -0
- package/dist/build.d.ts +1 -1
- package/dist/build.js +1 -1
- package/dist/embed-scripts.js +1 -1
- package/dist/page-script.js +3 -3
- package/dist/platform-skills.generated.d.ts +2 -2
- package/dist/platform-skills.generated.js +2 -2
- package/dist/standalone/agent-computers.js +3 -2
- package/dist/standalone/agents.d.ts +2 -2
- package/dist/standalone/agents.js +7 -0
- package/dist/standalone/computer-capabilities.d.ts +5 -0
- package/dist/standalone/computer-capabilities.js +11 -0
- package/dist/standalone/computer.d.ts +2 -2
- package/dist/standalone/computer.js +26 -2
- package/dist/standalone/workflow-host.d.ts +16 -16
- package/dist/standalone/workflows.d.ts +16 -16
- package/dist/workers.d.ts +3 -3
- package/docs/api/build-contract.md +6 -0
- package/docs/api/build.md +62 -0
- package/package.json +22 -22
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { Knapsack, } from "@fungi.computer/knapsack";
|
|
2
|
-
import {
|
|
2
|
+
import {} from "@fungi.computer/computer-contract";
|
|
3
|
+
import { advertisedComputerCapabilities } from "./standalone/computer-capabilities.js";
|
|
3
4
|
/** Capture each named Computer and its Files port under the same authority. */
|
|
4
5
|
export function readAgentComputerConnections(options) {
|
|
5
6
|
return capturedConnections(options, options.read());
|
|
@@ -78,7 +79,7 @@ export function createAgentComputerSurface() {
|
|
|
78
79
|
},
|
|
79
80
|
},
|
|
80
81
|
computer: {
|
|
81
|
-
getCapabilities: () => Promise.resolve(
|
|
82
|
+
getCapabilities: () => Promise.resolve(advertisedComputerCapabilities()),
|
|
82
83
|
call: refusedBeforeRun,
|
|
83
84
|
},
|
|
84
85
|
},
|
|
@@ -36084,7 +36084,7 @@ function snapshotBuildEnvironment(sourceSnapshotPath) {
|
|
|
36084
36084
|
};
|
|
36085
36085
|
return env;
|
|
36086
36086
|
}
|
|
36087
|
-
function rebuildViteSnapshot(sourceSnapshotPath, recipe, options) {
|
|
36087
|
+
function rebuildViteSnapshot(sourceSnapshotPath, recipe, options, shared) {
|
|
36088
36088
|
if (recipe.kind === "source-html")
|
|
36089
36089
|
return rebuildNpmSnapshot(sourceSnapshotPath, recipe, options);
|
|
36090
36090
|
return gen2(function* () {
|
|
@@ -36110,15 +36110,23 @@ function rebuildViteSnapshot(sourceSnapshotPath, recipe, options) {
|
|
|
36110
36110
|
)
|
|
36111
36111
|
);
|
|
36112
36112
|
const installStarted = performance.now();
|
|
36113
|
-
|
|
36114
|
-
|
|
36115
|
-
|
|
36116
|
-
|
|
36117
|
-
|
|
36118
|
-
|
|
36119
|
-
|
|
36113
|
+
if (shared === null)
|
|
36114
|
+
yield* run2([
|
|
36115
|
+
...productionWorkspaceSelectors(html),
|
|
36116
|
+
...frozenSnapshotInstallArguments(
|
|
36117
|
+
options.packageStoreDirectory,
|
|
36118
|
+
options.packageCacheDirectory
|
|
36119
|
+
)
|
|
36120
|
+
]);
|
|
36121
|
+
else if (shared.snapshotPath !== sourceSnapshotPath || !productionWorkspaceSelectors(html).every(
|
|
36122
|
+
(selector) => shared.selectors.has(selector)
|
|
36123
|
+
))
|
|
36124
|
+
return yield* fail5(
|
|
36125
|
+
new Error("The shared install did not hydrate this App's workspace")
|
|
36126
|
+
);
|
|
36120
36127
|
const buildStarted = performance.now();
|
|
36121
|
-
|
|
36128
|
+
if (shared === null)
|
|
36129
|
+
options.onPhase?.("install", buildStarted - installStarted);
|
|
36122
36130
|
const appDirectory = join5(sourceSnapshotPath, html.directory);
|
|
36123
36131
|
const dependencies = join5(appDirectory, ".publisher-dependencies.mjs");
|
|
36124
36132
|
const program = join5(appDirectory, ".publisher-build.mjs");
|
|
@@ -36132,8 +36140,11 @@ function rebuildViteSnapshot(sourceSnapshotPath, recipe, options) {
|
|
|
36132
36140
|
catch: (error2) => error2
|
|
36133
36141
|
})
|
|
36134
36142
|
);
|
|
36143
|
+
const steps = html.steps.filter(
|
|
36144
|
+
(step) => step.kind !== "typescript" || !shared?.compiled.has(step.config)
|
|
36145
|
+
);
|
|
36135
36146
|
const groups = [];
|
|
36136
|
-
for (const step of
|
|
36147
|
+
for (const step of steps) {
|
|
36137
36148
|
const last = groups.at(-1);
|
|
36138
36149
|
if (step.kind === "typescript" && last?.every((member) => member.kind === "typescript"))
|
|
36139
36150
|
last.push(step);
|
|
@@ -36166,6 +36177,9 @@ function rebuildViteSnapshot(sourceSnapshotPath, recipe, options) {
|
|
|
36166
36177
|
],
|
|
36167
36178
|
appDirectory
|
|
36168
36179
|
);
|
|
36180
|
+
for (const compiled of group)
|
|
36181
|
+
if (compiled.kind === "typescript")
|
|
36182
|
+
shared?.compiled.add(compiled.config);
|
|
36169
36183
|
}
|
|
36170
36184
|
yield* run2(
|
|
36171
36185
|
[
|
|
@@ -36460,6 +36474,9 @@ function localSnapshotBuildOptions(source, recipe, emission) {
|
|
|
36460
36474
|
return options;
|
|
36461
36475
|
}
|
|
36462
36476
|
function createLocalBuildExecutor(options = {}) {
|
|
36477
|
+
return createWorkspaceBuildExecutor(options, null);
|
|
36478
|
+
}
|
|
36479
|
+
function createWorkspaceBuildExecutor(options, shared) {
|
|
36463
36480
|
const emissions = /* @__PURE__ */ new WeakMap();
|
|
36464
36481
|
const compiler2 = {
|
|
36465
36482
|
build: (source, recipe) => {
|
|
@@ -36526,7 +36543,7 @@ function createLocalBuildExecutor(options = {}) {
|
|
|
36526
36543
|
const ui = yield* recipe.kind === "bundled-html" ? tryPromise2({
|
|
36527
36544
|
try: () => readBundledHtml(source.snapshotPath, recipe),
|
|
36528
36545
|
catch: () => new Error("Captured HTML bundle failed validation")
|
|
36529
|
-
}) : rebuildViteSnapshot(source.snapshotPath, recipe, options);
|
|
36546
|
+
}) : rebuildViteSnapshot(source.snapshotPath, recipe, options, shared);
|
|
36530
36547
|
const code = yield* compiler2.build(source, {
|
|
36531
36548
|
bundle: true,
|
|
36532
36549
|
entry,
|
|
@@ -36552,7 +36569,7 @@ function createLocalBuildExecutor(options = {}) {
|
|
|
36552
36569
|
};
|
|
36553
36570
|
});
|
|
36554
36571
|
}
|
|
36555
|
-
return recipe.format !== "esm" ? rebuildViteSnapshot(source.snapshotPath, recipe, options) : acquireUseRelease2(
|
|
36572
|
+
return recipe.format !== "esm" ? rebuildViteSnapshot(source.snapshotPath, recipe, options, shared) : acquireUseRelease2(
|
|
36556
36573
|
tryPromise2({
|
|
36557
36574
|
try: () => {
|
|
36558
36575
|
const emission = emissions.get(source);
|
package/dist/build/effect.d.ts
CHANGED
|
@@ -218,6 +218,8 @@ export type CapturedConfig = Readonly<{
|
|
|
218
218
|
* another policy describes a build this code does not perform.
|
|
219
219
|
*/
|
|
220
220
|
export declare function pinsCurrentToolchain(recipe: PinnedRecipe): boolean;
|
|
221
|
+
/** Decode and pin one App Publisher configuration, with its recipe digest. */
|
|
222
|
+
export declare function captureConfig(input: AppPublisherCoreConfigInput): CapturedConfig;
|
|
221
223
|
/** Hash every captured build and output-policy input in the Publisher recipe. */
|
|
222
224
|
export declare function digestPinnedRecipe(recipe: PinnedRecipe): Sha256Digest;
|
|
223
225
|
/** Decode and normalize Publisher-owned recipe policy for durable seed proof. */
|
package/dist/build/effect.js
CHANGED
|
@@ -128,7 +128,8 @@ export function pinsCurrentToolchain(recipe) {
|
|
|
128
128
|
const entries = (toolchain) => JSON.stringify(Object.entries(toolchain).sort(([a], [b]) => a.localeCompare(b)));
|
|
129
129
|
return entries(currentToolchain(recipe)) === entries(recipe.toolchain);
|
|
130
130
|
}
|
|
131
|
-
|
|
131
|
+
/** Decode and pin one App Publisher configuration, with its recipe digest. */
|
|
132
|
+
export function captureConfig(input) {
|
|
132
133
|
let decoded;
|
|
133
134
|
try {
|
|
134
135
|
decoded = Schema.decodeUnknownSync(AppPublisherCoreConfigSchema)(input);
|
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
import { Buffer } from "node:buffer";
|
|
2
2
|
import { type DefinitionEmission } from "./definition-emission.js";
|
|
3
3
|
import { type AssetBuildPolicy } from "@fungi.computer/puffball/assets";
|
|
4
|
+
import type { ReleaseId } from "@fungi.computer/puffball";
|
|
4
5
|
import { parseSha256Digest, type AppId, type SourceRevision } from "@fungi.computer/puffball";
|
|
5
6
|
import * as Effect from "effect/Effect";
|
|
6
7
|
import * as esbuild from "esbuild";
|
|
7
|
-
import { type AppPublisher, type ArtifactWriter, type BuildExecutor, type CapturedSource, type PinnedRecipe, type ReleaseCreator, type SourceCapture } from "./effect.js";
|
|
8
|
+
import { AppPublisherError, type AppPublisher, type AppPublisherCoreConfigInput, type ArtifactWriter, type BuildExecutor, type CapturedSource, type PinnedRecipe, type PreparedCandidate, type ReleaseCreator, type SourceCapture } from "./effect.js";
|
|
8
9
|
export declare class GitCommandError extends Error {
|
|
9
10
|
readonly exitCode: number | null;
|
|
10
11
|
constructor(message: string, exitCode: number | null);
|
|
@@ -72,6 +73,21 @@ export type LocalBuildExecutorOptions = Readonly<{
|
|
|
72
73
|
export declare function localSnapshotBuildOptions(source: CapturedSource, recipe: PinnedRecipe, emission: DefinitionEmission): esbuild.BuildOptions;
|
|
73
74
|
/** Local proving adapter; it builds only the captured extracted snapshot. */
|
|
74
75
|
export declare function createLocalBuildExecutor(options?: LocalBuildExecutorOptions): BuildExecutor;
|
|
76
|
+
/**
|
|
77
|
+
* Prepare several first-party Apps from one capture of one commit: one source
|
|
78
|
+
* snapshot, one frozen install and each workspace TypeScript config compiled
|
|
79
|
+
* once, then each App's stylesheets, page, declaration and backend in order.
|
|
80
|
+
* Every App keeps its own recipe digest and the capture's provenance; the
|
|
81
|
+
* first failure stops the pass.
|
|
82
|
+
*/
|
|
83
|
+
export declare function createLocalCandidatesPreparer(options: Readonly<{
|
|
84
|
+
configs: readonly AppPublisherCoreConfigInput[];
|
|
85
|
+
sourceCapture: SourceCapture;
|
|
86
|
+
executor: Omit<LocalBuildExecutorOptions, "packageScripts">;
|
|
87
|
+
}>): Readonly<{
|
|
88
|
+
/** Prepare each configured App, in order, under its Release ID. */
|
|
89
|
+
prepareCandidates: (releaseIds: readonly ReleaseId[]) => Effect.Effect<readonly PreparedCandidate[], AppPublisherError>;
|
|
90
|
+
}>;
|
|
75
91
|
/** Local proving adapter; the configured root is private and write-once. */
|
|
76
92
|
export declare function createLocalArtifactWriter(artifactRoot: string, assetPolicy?: AssetBuildPolicy): ArtifactWriter;
|
|
77
93
|
/** Local Git, recipe and artifact directory configuration with a Release catalog. */
|
|
@@ -5,6 +5,7 @@ import { Buffer } from "node:buffer";
|
|
|
5
5
|
import { appBackendPackageMainFields, createDefinitionEmission, } from "./definition-emission.js";
|
|
6
6
|
import { frozenSnapshotInstallArguments, packageScriptArguments, } from "./snapshot-package-store.js";
|
|
7
7
|
import { isInsideSnapshot } from "./snapshot-programs/snapshot-path.js";
|
|
8
|
+
import { sharedTypeScriptCompiler } from "./shared-workspace.js";
|
|
8
9
|
import { writeImmutableArtifact, } from "./artifact-writer.js";
|
|
9
10
|
import { contentObjectOwner } from "./content-objects.js";
|
|
10
11
|
import { assetPathSchema, } from "@fungi.computer/puffball/assets";
|
|
@@ -24,7 +25,7 @@ import * as Schema from "effect/Schema";
|
|
|
24
25
|
import * as esbuild from "esbuild";
|
|
25
26
|
import { readWantedLockfile, writeWantedLockfile } from "@pnpm/lockfile.fs";
|
|
26
27
|
import { pruneSharedLockfile } from "@pnpm/lockfile.pruner";
|
|
27
|
-
import { AppPublisherError, appBackendExportConditions, createAppPublisher, pinnedRecipeSchema, pinsCurrentToolchain, } from "./effect.js";
|
|
28
|
+
import { AppPublisherError, appBackendExportConditions, captureConfig, createAppPublisher, createCapturedCandidatePreparer, pinnedRecipeSchema, pinsCurrentToolchain, } from "./effect.js";
|
|
28
29
|
import { artifactsGitEnvironment, repositoryEnvironment, } from "./git-environment.js";
|
|
29
30
|
const localConfigSchema = Schema.Struct({
|
|
30
31
|
appId: appIdSchema,
|
|
@@ -640,7 +641,7 @@ function snapshotBuildEnvironment(sourceSnapshotPath) {
|
|
|
640
641
|
};
|
|
641
642
|
return env;
|
|
642
643
|
}
|
|
643
|
-
function rebuildViteSnapshot(sourceSnapshotPath, recipe, options) {
|
|
644
|
+
function rebuildViteSnapshot(sourceSnapshotPath, recipe, options, shared) {
|
|
644
645
|
if (recipe.kind === "source-html")
|
|
645
646
|
return rebuildNpmSnapshot(sourceSnapshotPath, recipe, options);
|
|
646
647
|
return Effect.gen(function* () {
|
|
@@ -658,12 +659,17 @@ function rebuildViteSnapshot(sourceSnapshotPath, recipe, options) {
|
|
|
658
659
|
html.steps.some((step) => step.kind === "script"))
|
|
659
660
|
return yield* Effect.fail(new Error("This source builds a dependency with its package script, which only a Computer build runs"));
|
|
660
661
|
const installStarted = performance.now();
|
|
661
|
-
|
|
662
|
-
|
|
663
|
-
|
|
664
|
-
|
|
662
|
+
if (shared === null)
|
|
663
|
+
yield* run([
|
|
664
|
+
...productionWorkspaceSelectors(html),
|
|
665
|
+
...frozenSnapshotInstallArguments(options.packageStoreDirectory, options.packageCacheDirectory),
|
|
666
|
+
]);
|
|
667
|
+
else if (shared.snapshotPath !== sourceSnapshotPath ||
|
|
668
|
+
!productionWorkspaceSelectors(html).every((selector) => shared.selectors.has(selector)))
|
|
669
|
+
return yield* Effect.fail(new Error("The shared install did not hydrate this App's workspace"));
|
|
665
670
|
const buildStarted = performance.now();
|
|
666
|
-
|
|
671
|
+
if (shared === null)
|
|
672
|
+
options.onPhase?.("install", buildStarted - installStarted);
|
|
667
673
|
const appDirectory = join(sourceSnapshotPath, html.directory);
|
|
668
674
|
const dependencies = join(appDirectory, ".publisher-dependencies.mjs");
|
|
669
675
|
const program = join(appDirectory, ".publisher-build.mjs");
|
|
@@ -677,8 +683,11 @@ function rebuildViteSnapshot(sourceSnapshotPath, recipe, options) {
|
|
|
677
683
|
}));
|
|
678
684
|
// Keep the derived order and every diagnostic/emit check. Consecutive
|
|
679
685
|
// projects share one warmed compiler; stylesheet steps stay separate.
|
|
686
|
+
// A shared pass compiles each TypeScript config once: an earlier App
|
|
687
|
+
// emitted it from this same tree with the same pinned compiler.
|
|
688
|
+
const steps = html.steps.filter((step) => step.kind !== "typescript" || !shared?.compiled.has(step.config));
|
|
680
689
|
const groups = [];
|
|
681
|
-
for (const step of
|
|
690
|
+
for (const step of steps) {
|
|
682
691
|
const last = groups.at(-1);
|
|
683
692
|
if (step.kind === "typescript" &&
|
|
684
693
|
last?.every((member) => member.kind === "typescript"))
|
|
@@ -712,6 +721,9 @@ function rebuildViteSnapshot(sourceSnapshotPath, recipe, options) {
|
|
|
712
721
|
JSON.stringify(group),
|
|
713
722
|
tailwindToolchainDirectory(html),
|
|
714
723
|
], appDirectory);
|
|
724
|
+
for (const compiled of group)
|
|
725
|
+
if (compiled.kind === "typescript")
|
|
726
|
+
shared?.compiled.add(compiled.config);
|
|
715
727
|
}
|
|
716
728
|
yield* run([
|
|
717
729
|
"--config.verify-deps-before-run=false",
|
|
@@ -961,6 +973,9 @@ export function localSnapshotBuildOptions(source, recipe, emission) {
|
|
|
961
973
|
}
|
|
962
974
|
/** Local proving adapter; it builds only the captured extracted snapshot. */
|
|
963
975
|
export function createLocalBuildExecutor(options = {}) {
|
|
976
|
+
return createWorkspaceBuildExecutor(options, null);
|
|
977
|
+
}
|
|
978
|
+
function createWorkspaceBuildExecutor(options, shared) {
|
|
964
979
|
const emissions = new WeakMap();
|
|
965
980
|
const compiler = {
|
|
966
981
|
build: (source, recipe) => {
|
|
@@ -1002,7 +1017,7 @@ export function createLocalBuildExecutor(options = {}) {
|
|
|
1002
1017
|
try: () => readBundledHtml(source.snapshotPath, recipe),
|
|
1003
1018
|
catch: () => new Error("Captured HTML bundle failed validation"),
|
|
1004
1019
|
})
|
|
1005
|
-
: rebuildViteSnapshot(source.snapshotPath, recipe, options);
|
|
1020
|
+
: rebuildViteSnapshot(source.snapshotPath, recipe, options, shared);
|
|
1006
1021
|
const code = yield* compiler.build(source, {
|
|
1007
1022
|
bundle: true,
|
|
1008
1023
|
entry,
|
|
@@ -1031,7 +1046,7 @@ export function createLocalBuildExecutor(options = {}) {
|
|
|
1031
1046
|
});
|
|
1032
1047
|
}
|
|
1033
1048
|
return recipe.format !== "esm"
|
|
1034
|
-
? rebuildViteSnapshot(source.snapshotPath, recipe, options)
|
|
1049
|
+
? rebuildViteSnapshot(source.snapshotPath, recipe, options, shared)
|
|
1035
1050
|
: Effect.acquireUseRelease(Effect.tryPromise({
|
|
1036
1051
|
try: () => {
|
|
1037
1052
|
const emission = emissions.get(source);
|
|
@@ -1096,6 +1111,93 @@ export function createLocalBuildExecutor(options = {}) {
|
|
|
1096
1111
|
},
|
|
1097
1112
|
};
|
|
1098
1113
|
}
|
|
1114
|
+
/**
|
|
1115
|
+
* The root scratch files one App's build writes once (`wx`) and reads back:
|
|
1116
|
+
* its Vite output, single-file page and emitted definition. A shared pass
|
|
1117
|
+
* removes them after each App so the next App writes the same paths.
|
|
1118
|
+
*/
|
|
1119
|
+
const appScratchFiles = [
|
|
1120
|
+
".publisher-output",
|
|
1121
|
+
".publisher.html",
|
|
1122
|
+
".fungi-built-definition.mjs",
|
|
1123
|
+
];
|
|
1124
|
+
/**
|
|
1125
|
+
* The shared dependency phase for every App a pass builds from one capture:
|
|
1126
|
+
* each App's workspace build is derived and checked as its own build checks
|
|
1127
|
+
* it, then one frozen install hydrates all of them. The dependency compiler
|
|
1128
|
+
* loads TypeScript from each App's own `node_modules`, so every App must
|
|
1129
|
+
* resolve the same compiler before one App's emit may stand for another's.
|
|
1130
|
+
*/
|
|
1131
|
+
function prepareSharedWorkspace(snapshotPath, recipes, options) {
|
|
1132
|
+
return Effect.gen(function* () {
|
|
1133
|
+
const env = snapshotBuildEnvironment(snapshotPath);
|
|
1134
|
+
const run = (args) => runHtmlCommand(args, snapshotPath, env, "pnpm", options.onOutput);
|
|
1135
|
+
if ((yield* run(["--version"])).trim() !== "11.24.0")
|
|
1136
|
+
return yield* Effect.fail(new Error("Publisher requires pnpm 11.24.0"));
|
|
1137
|
+
const builds = [];
|
|
1138
|
+
for (const recipe of recipes) {
|
|
1139
|
+
if (recipe.kind === "source-html" ||
|
|
1140
|
+
recipe.kind === "bundled-html" ||
|
|
1141
|
+
recipe.format === "esm" ||
|
|
1142
|
+
!pinsCurrentToolchain(recipe))
|
|
1143
|
+
return yield* Effect.fail(new Error("A shared pass builds only workspace Vite Apps"));
|
|
1144
|
+
const html = yield* capturedWorkspaceBuild(snapshotPath, recipe.entry, run, recipe.backend?.entry ?? null);
|
|
1145
|
+
yield* Effect.tryPromise({
|
|
1146
|
+
try: () => checkPinnedWorkspaceToolchain(snapshotPath, html, recipe),
|
|
1147
|
+
catch: (error) => error,
|
|
1148
|
+
});
|
|
1149
|
+
if (html.steps.some((step) => step.kind === "script"))
|
|
1150
|
+
return yield* Effect.fail(new Error("This source builds a dependency with its package script, which only a Computer build runs"));
|
|
1151
|
+
builds.push(html);
|
|
1152
|
+
}
|
|
1153
|
+
const selectors = builds.flatMap(productionWorkspaceSelectors);
|
|
1154
|
+
const started = performance.now();
|
|
1155
|
+
yield* run([
|
|
1156
|
+
...selectors,
|
|
1157
|
+
...frozenSnapshotInstallArguments(options.packageStoreDirectory, options.packageCacheDirectory),
|
|
1158
|
+
]);
|
|
1159
|
+
options.onPhase?.("install", performance.now() - started);
|
|
1160
|
+
yield* Effect.try(() => sharedTypeScriptCompiler(snapshotPath, builds.map((html) => html.directory)));
|
|
1161
|
+
return { snapshotPath, selectors: new Set(selectors), compiled: new Set() };
|
|
1162
|
+
});
|
|
1163
|
+
}
|
|
1164
|
+
/**
|
|
1165
|
+
* Prepare several first-party Apps from one capture of one commit: one source
|
|
1166
|
+
* snapshot, one frozen install and each workspace TypeScript config compiled
|
|
1167
|
+
* once, then each App's stylesheets, page, declaration and backend in order.
|
|
1168
|
+
* Every App keeps its own recipe digest and the capture's provenance; the
|
|
1169
|
+
* first failure stops the pass.
|
|
1170
|
+
*/
|
|
1171
|
+
export function createLocalCandidatesPreparer(options) {
|
|
1172
|
+
const configs = options.configs.map(captureConfig);
|
|
1173
|
+
const prepareCandidates = (releaseIds) => Effect.scoped(Effect.gen(function* () {
|
|
1174
|
+
if (releaseIds.length !== configs.length)
|
|
1175
|
+
return yield* Effect.fail(new AppPublisherError("configuration"));
|
|
1176
|
+
const source = yield* options.sourceCapture
|
|
1177
|
+
.capture()
|
|
1178
|
+
.pipe(Effect.mapError(() => new AppPublisherError("source")));
|
|
1179
|
+
const shared = yield* prepareSharedWorkspace(source.snapshotPath, configs.map(({ recipe }) => recipe), options.executor).pipe(Effect.mapError((cause) => new AppPublisherError("build", { cause })));
|
|
1180
|
+
const prepared = [];
|
|
1181
|
+
for (const [index, config] of configs.entries()) {
|
|
1182
|
+
const releaseId = releaseIds[index];
|
|
1183
|
+
if (releaseId === undefined)
|
|
1184
|
+
return yield* Effect.fail(new AppPublisherError("configuration"));
|
|
1185
|
+
prepared.push(yield* createCapturedCandidatePreparer(config, {
|
|
1186
|
+
sourceCapture: { capture: () => Effect.succeed(source) },
|
|
1187
|
+
buildExecutor: createWorkspaceBuildExecutor(options.executor, shared),
|
|
1188
|
+
}).prepareCandidate(releaseId));
|
|
1189
|
+
yield* Effect.tryPromise({
|
|
1190
|
+
try: () => Promise.all(appScratchFiles.map((file) => rm(join(source.snapshotPath, file), {
|
|
1191
|
+
recursive: true,
|
|
1192
|
+
force: true,
|
|
1193
|
+
}))),
|
|
1194
|
+
catch: (cause) => new AppPublisherError("build", { cause }),
|
|
1195
|
+
});
|
|
1196
|
+
}
|
|
1197
|
+
return prepared;
|
|
1198
|
+
}));
|
|
1199
|
+
return Object.freeze({ prepareCandidates });
|
|
1200
|
+
}
|
|
1099
1201
|
/** The configured artifact directory as write-once immutable objects. */
|
|
1100
1202
|
function directoryArtifactObjects(artifactRoot, signal) {
|
|
1101
1203
|
const pathOf = (artifactRef) => join(artifactRoot, artifactRef.slice("artifact:".length));
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The one TypeScript compiler every App of a shared pass resolves. The
|
|
3
|
+
* dependency compiler loads TypeScript from each App's own `node_modules`, so
|
|
4
|
+
* one App's emit stands for another's only when both resolve the same
|
|
5
|
+
* compiler inside the captured snapshot; anything else fails closed.
|
|
6
|
+
*/
|
|
7
|
+
export declare function sharedTypeScriptCompiler(snapshotPath: string, appDirectories: readonly string[]): string;
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { realpathSync } from "node:fs";
|
|
2
|
+
import { join } from "node:path";
|
|
3
|
+
import { isInsideSnapshot } from "./snapshot-programs/snapshot-path.js";
|
|
4
|
+
/**
|
|
5
|
+
* The one TypeScript compiler every App of a shared pass resolves. The
|
|
6
|
+
* dependency compiler loads TypeScript from each App's own `node_modules`, so
|
|
7
|
+
* one App's emit stands for another's only when both resolve the same
|
|
8
|
+
* compiler inside the captured snapshot; anything else fails closed.
|
|
9
|
+
*/
|
|
10
|
+
export function sharedTypeScriptCompiler(snapshotPath, appDirectories) {
|
|
11
|
+
const compilers = new Set(appDirectories.map((directory) => realpathSync(join(snapshotPath, directory, "node_modules/typescript"))));
|
|
12
|
+
const [compiler] = compilers;
|
|
13
|
+
if (compilers.size !== 1 ||
|
|
14
|
+
compiler === undefined ||
|
|
15
|
+
!isInsideSnapshot(snapshotPath, compiler))
|
|
16
|
+
throw new Error("A shared pass requires every App to resolve the same TypeScript compiler");
|
|
17
|
+
return compiler;
|
|
18
|
+
}
|
package/dist/build.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
export * from "./build/effect.js";
|
|
2
|
-
export { createLocalSourceCapture, createLocalDirectorySourceCapture, createArtifactsSourceCapture, createLocalCommitSourceCapture, createFirstPartyAppSourceDistribution, localSnapshotBuildOptions, createLocalBuildExecutor, createLocalArtifactWriter, createLocalAppPublisher, type FirstPartyAppSourceDistribution, type LocalBuildExecutorOptions, type LocalAppPublisherOptions, } from "./build/local-build.js";
|
|
2
|
+
export { createLocalSourceCapture, createLocalDirectorySourceCapture, createArtifactsSourceCapture, createLocalCommitSourceCapture, createFirstPartyAppSourceDistribution, localSnapshotBuildOptions, createLocalBuildExecutor, createLocalCandidatesPreparer, createLocalArtifactWriter, createLocalAppPublisher, type FirstPartyAppSourceDistribution, type LocalBuildExecutorOptions, type LocalAppPublisherOptions, } from "./build/local-build.js";
|
|
3
3
|
export { createDefinitionEmission, type AppBackendOutput, type DefinitionEmission, } from "./build/definition-emission.js";
|
|
4
4
|
export { readBundledHtml } from "./build/bundled-html.js";
|
|
5
5
|
export { bundledHtmlRecipe, boundedBundlePolicy } from "./build/html-recipe.js";
|
package/dist/build.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/** Node-only App source capture, compilation and artifact writing. */
|
|
2
2
|
import { dependencyBuildProgram as bundledDependencyBuildProgram } from "#snapshot-program-scripts";
|
|
3
3
|
export * from "./build/effect.js";
|
|
4
|
-
export { createLocalSourceCapture, createLocalDirectorySourceCapture, createArtifactsSourceCapture, createLocalCommitSourceCapture, createFirstPartyAppSourceDistribution, localSnapshotBuildOptions, createLocalBuildExecutor, createLocalArtifactWriter, createLocalAppPublisher, } from "./build/local-build.js";
|
|
4
|
+
export { createLocalSourceCapture, createLocalDirectorySourceCapture, createArtifactsSourceCapture, createLocalCommitSourceCapture, createFirstPartyAppSourceDistribution, localSnapshotBuildOptions, createLocalBuildExecutor, createLocalCandidatesPreparer, createLocalArtifactWriter, createLocalAppPublisher, } from "./build/local-build.js";
|
|
5
5
|
export { createDefinitionEmission, } from "./build/definition-emission.js";
|
|
6
6
|
export { readBundledHtml } from "./build/bundled-html.js";
|
|
7
7
|
export { bundledHtmlRecipe, boundedBundlePolicy } from "./build/html-recipe.js";
|