[codex] Structure desktop build script failures (#3452)
Co-authored-by: codex <[email protected]>
This commit is contained in:
1 parent
d389cfd4e3
commit
60dc4af916
2 files changed
+349
-75
No files matched your search
@@ -9,15 +9,17 @@ import * as Stream from "effect/Stream";
|
||||
import { ChildProcessSpawner } from "effect/unstable/process";
|
||||
|
||||
import {
|
||||
BuildScriptError,
|
||||
BuildCommandFailedError,
|
||||
createStageWorkspaceConfig,
|
||||
createStagePnpmConfig,
|
||||
createBuildConfig,
|
||||
DESKTOP_ASAR_UNPACK,
|
||||
InvalidMacPasskeyRpDomainError,
|
||||
InvalidMacPasskeyPublishableKeyError,
|
||||
InvalidMockUpdateServerPortError,
|
||||
isMacPasskeySigningConfigurationError,
|
||||
LinuxIconResizeError,
|
||||
MacPasskeySigningConfigurationResolutionError,
|
||||
MissingMacPasskeyProvisioningProfileError,
|
||||
renderMacPasskeyEntitlements,
|
||||
resolveClerkPasskeyNativeArtifacts,
|
||||
@@ -249,10 +251,16 @@ it.layer(NodeServices.layer)("build-desktop-artifact", (it) => {
|
||||
const aggregateCause = error.cause as AggregateError;
|
||||
assert.lengthOf(aggregateCause.errors, 2);
|
||||
assert.strictEqual(aggregateCause.cause, aggregateCause.errors[0]);
|
||||
assert.instanceOf(aggregateCause.errors[0], BuildScriptError);
|
||||
assert.instanceOf(aggregateCause.errors[1], BuildScriptError);
|
||||
assert.include((aggregateCause.errors[0] as BuildScriptError).message, "magick linux icon");
|
||||
assert.include((aggregateCause.errors[1] as BuildScriptError).message, "convert linux icon");
|
||||
assert.instanceOf(aggregateCause.errors[0], BuildCommandFailedError);
|
||||
assert.instanceOf(aggregateCause.errors[1], BuildCommandFailedError);
|
||||
const primaryError = aggregateCause.errors[0] as BuildCommandFailedError;
|
||||
const fallbackError = aggregateCause.errors[1] as BuildCommandFailedError;
|
||||
assert.equal(primaryError.command, "magick linux icon 512x512");
|
||||
assert.equal(primaryError.exitCode, 1);
|
||||
assert.include(primaryError.message, "magick linux icon");
|
||||
assert.equal(fallbackError.command, "convert linux icon 512x512");
|
||||
assert.equal(fallbackError.exitCode, 2);
|
||||
assert.include(fallbackError.message, "convert linux icon");
|
||||
assert.deepStrictEqual(
|
||||
commands.map(({ command }) => command),
|
||||
["magick", "convert"],
|
||||
@@ -356,7 +364,7 @@ it.layer(NodeServices.layer)("build-desktop-artifact", (it) => {
|
||||
it("preserves known passkey signing configuration errors at the build boundary", () => {
|
||||
const decodingCause = new Error("publishable-key-decode-failed");
|
||||
const knownError = new InvalidMacPasskeyPublishableKeyError({ cause: decodingCause });
|
||||
const error = BuildScriptError.fromMacPasskeySigningConfiguration(knownError);
|
||||
const error = MacPasskeySigningConfigurationResolutionError.fromCause(knownError);
|
||||
|
||||
assert.strictEqual(error, knownError);
|
||||
assert.instanceOf(error, InvalidMacPasskeyPublishableKeyError);
|
||||
@@ -367,9 +375,9 @@ it.layer(NodeServices.layer)("build-desktop-artifact", (it) => {
|
||||
it("wraps unknown passkey signing configuration defects without copying cause text", () => {
|
||||
const secret = "pk_test_do-not-retain";
|
||||
const cause = new Error(secret);
|
||||
const error = BuildScriptError.fromMacPasskeySigningConfiguration(cause);
|
||||
const error = MacPasskeySigningConfigurationResolutionError.fromCause(cause);
|
||||
|
||||
assert.instanceOf(error, BuildScriptError);
|
||||
assert.instanceOf(error, MacPasskeySigningConfigurationResolutionError);
|
||||
assert.strictEqual(error.cause, cause);
|
||||
assert.equal(error.message, "Failed to resolve macOS passkey signing configuration.");
|
||||
assert.notInclude(error.message, secret);
|
||||
@@ -453,6 +461,27 @@ it.layer(NodeServices.layer)("build-desktop-artifact", (it) => {
|
||||
}),
|
||||
);
|
||||
|
||||
it("classifies invalid configured ports with the decoder's number grammar", () => {
|
||||
const cause = new Error("invalid configured port");
|
||||
|
||||
assert.equal(
|
||||
InvalidMockUpdateServerPortError.fromConfigValue("0x10", cause).reason,
|
||||
"not-numeric",
|
||||
);
|
||||
assert.equal(
|
||||
InvalidMockUpdateServerPortError.fromConfigValue("12.5", cause).reason,
|
||||
"not-integer",
|
||||
);
|
||||
assert.equal(
|
||||
InvalidMockUpdateServerPortError.fromConfigValue("65536", cause).reason,
|
||||
"out-of-range",
|
||||
);
|
||||
assert.strictEqual(
|
||||
InvalidMockUpdateServerPortError.fromConfigValue("0x10", cause).cause,
|
||||
cause,
|
||||
);
|
||||
});
|
||||
|
||||
it.effect("resolves default platform and architecture from host references", () =>
|
||||
Effect.gen(function* () {
|
||||
const resolved = yield* resolveBuildOptions({
|
||||
|
||||
@@ -18,7 +18,6 @@ import { resolveCatalogDependencies } from "./lib/resolve-catalog.ts";
|
||||
import * as NodeRuntime from "@effect/platform-node/NodeRuntime";
|
||||
import * as NodeServices from "@effect/platform-node/NodeServices";
|
||||
import * as Config from "effect/Config";
|
||||
import * as Data from "effect/Data";
|
||||
import * as Effect from "effect/Effect";
|
||||
import * as FileSystem from "effect/FileSystem";
|
||||
import * as Layer from "effect/Layer";
|
||||
@@ -126,19 +125,238 @@ const getDefaultArch = Effect.fn("getDefaultArch")(function* (platform: typeof B
|
||||
return yield* getDefaultBuildArch(platform, config);
|
||||
});
|
||||
|
||||
export class BuildScriptError extends Data.TaggedError("BuildScriptError")<{
|
||||
readonly message: string;
|
||||
readonly cause?: unknown;
|
||||
}> {
|
||||
static fromMacPasskeySigningConfiguration(
|
||||
export class MacPasskeySigningConfigurationResolutionError extends Schema.TaggedErrorClass<MacPasskeySigningConfigurationResolutionError>()(
|
||||
"MacPasskeySigningConfigurationResolutionError",
|
||||
{
|
||||
cause: Schema.Defect(),
|
||||
},
|
||||
) {
|
||||
static fromCause(
|
||||
cause: unknown,
|
||||
): MacPasskeySigningConfigurationError | BuildScriptError {
|
||||
): MacPasskeySigningConfigurationError | MacPasskeySigningConfigurationResolutionError {
|
||||
return isMacPasskeySigningConfigurationError(cause)
|
||||
? cause
|
||||
: new BuildScriptError({
|
||||
message: "Failed to resolve macOS passkey signing configuration.",
|
||||
cause,
|
||||
});
|
||||
: new MacPasskeySigningConfigurationResolutionError({ cause });
|
||||
}
|
||||
|
||||
override get message(): string {
|
||||
return "Failed to resolve macOS passkey signing configuration.";
|
||||
}
|
||||
}
|
||||
|
||||
export class ClerkPasskeyNativePackageMissingError extends Schema.TaggedErrorClass<ClerkPasskeyNativePackageMissingError>()(
|
||||
"ClerkPasskeyNativePackageMissingError",
|
||||
{
|
||||
packageName: Schema.String,
|
||||
binaryFileName: Schema.String,
|
||||
packageEntryPath: Schema.String,
|
||||
platform: BuildPlatform,
|
||||
arch: BuildArch,
|
||||
cause: Schema.Defect(),
|
||||
},
|
||||
) {
|
||||
override get message(): string {
|
||||
return `Clerk passkey native package is missing: ${this.packageName}`;
|
||||
}
|
||||
}
|
||||
|
||||
export class UnsupportedHostBuildPlatformError extends Schema.TaggedErrorClass<UnsupportedHostBuildPlatformError>()(
|
||||
"UnsupportedHostBuildPlatformError",
|
||||
{
|
||||
hostPlatform: Schema.String,
|
||||
},
|
||||
) {
|
||||
override get message(): string {
|
||||
return `Unsupported host platform '${this.hostPlatform}'.`;
|
||||
}
|
||||
}
|
||||
|
||||
const InvalidMockUpdateServerPortReason = Schema.Literals([
|
||||
"not-numeric",
|
||||
"not-integer",
|
||||
"out-of-range",
|
||||
]);
|
||||
|
||||
export class InvalidMockUpdateServerPortError extends Schema.TaggedErrorClass<InvalidMockUpdateServerPortError>()(
|
||||
"InvalidMockUpdateServerPortError",
|
||||
{
|
||||
reason: InvalidMockUpdateServerPortReason,
|
||||
inputLength: Schema.Int.check(Schema.isGreaterThanOrEqualTo(0)),
|
||||
cause: Schema.Defect(),
|
||||
},
|
||||
) {
|
||||
override get message(): string {
|
||||
return "Invalid mock update server port.";
|
||||
}
|
||||
|
||||
static fromConfigValue(configuredPort: string, cause: unknown) {
|
||||
return new InvalidMockUpdateServerPortError({
|
||||
reason: invalidMockUpdateServerPortReason(configuredPort),
|
||||
inputLength: configuredPort.length,
|
||||
cause,
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
export class BuildCommandFailedError extends Schema.TaggedErrorClass<BuildCommandFailedError>()(
|
||||
"BuildCommandFailedError",
|
||||
{
|
||||
command: Schema.String,
|
||||
exitCode: Schema.Int,
|
||||
stdoutTail: Schema.optionalKey(Schema.String),
|
||||
stderrTail: Schema.optionalKey(Schema.String),
|
||||
},
|
||||
) {
|
||||
override get message(): string {
|
||||
const outputSections = [
|
||||
`Command: ${this.command}`,
|
||||
formatOutputSection("stdout", this.stdoutTail ?? ""),
|
||||
formatOutputSection("stderr", this.stderrTail ?? ""),
|
||||
].filter((section): section is string => section !== undefined);
|
||||
const outputSuffix = outputSections.length > 0 ? `\n\n${outputSections.join("\n\n")}` : "";
|
||||
return `Command exited with non-zero exit code (${this.exitCode})${outputSuffix}`;
|
||||
}
|
||||
}
|
||||
|
||||
const desktopIconPlatformNames = {
|
||||
mac: "macOS",
|
||||
linux: "Linux",
|
||||
win: "Windows",
|
||||
} satisfies Record<typeof BuildPlatform.Type, string>;
|
||||
|
||||
export class DesktopIconSourceMissingError extends Schema.TaggedErrorClass<DesktopIconSourceMissingError>()(
|
||||
"DesktopIconSourceMissingError",
|
||||
{
|
||||
platform: BuildPlatform,
|
||||
sourcePath: Schema.String,
|
||||
},
|
||||
) {
|
||||
override get message(): string {
|
||||
return `Desktop ${desktopIconPlatformNames[this.platform]} icon source is missing at ${this.sourcePath}`;
|
||||
}
|
||||
}
|
||||
|
||||
export class BundledClientAssetsMissingError extends Schema.TaggedErrorClass<BundledClientAssetsMissingError>()(
|
||||
"BundledClientAssetsMissingError",
|
||||
{
|
||||
indexPath: Schema.String,
|
||||
missingFiles: Schema.Array(Schema.String),
|
||||
},
|
||||
) {
|
||||
override get message(): string {
|
||||
const preview = this.missingFiles.slice(0, 6).join(", ");
|
||||
const suffix = this.missingFiles.length > 6 ? ` (+${this.missingFiles.length - 6} more)` : "";
|
||||
return `Bundled client references missing files in ${this.indexPath}: ${preview}${suffix}. Rebuild web/server artifacts.`;
|
||||
}
|
||||
}
|
||||
|
||||
export class UnsupportedDesktopBuildPlatformError extends Schema.TaggedErrorClass<UnsupportedDesktopBuildPlatformError>()(
|
||||
"UnsupportedDesktopBuildPlatformError",
|
||||
{
|
||||
platform: Schema.String,
|
||||
},
|
||||
) {
|
||||
override get message(): string {
|
||||
return `Unsupported platform '${this.platform}'.`;
|
||||
}
|
||||
}
|
||||
|
||||
const dependencyResolutionDescriptions = {
|
||||
"server-production": "production dependencies",
|
||||
"workspace-overrides": "overrides",
|
||||
"desktop-runtime": "desktop runtime dependencies",
|
||||
} as const;
|
||||
const DependencyResolutionKind = Schema.Literals([
|
||||
"server-production",
|
||||
"workspace-overrides",
|
||||
"desktop-runtime",
|
||||
]);
|
||||
|
||||
export class DesktopBuildDependencyResolutionError extends Schema.TaggedErrorClass<DesktopBuildDependencyResolutionError>()(
|
||||
"DesktopBuildDependencyResolutionError",
|
||||
{
|
||||
kind: DependencyResolutionKind,
|
||||
manifestPath: Schema.String,
|
||||
cause: Schema.Defect(),
|
||||
},
|
||||
) {
|
||||
override get message(): string {
|
||||
return `Could not resolve ${dependencyResolutionDescriptions[this.kind]} from ${this.manifestPath}.`;
|
||||
}
|
||||
}
|
||||
|
||||
export class MissingServerProductionDependenciesError extends Schema.TaggedErrorClass<MissingServerProductionDependenciesError>()(
|
||||
"MissingServerProductionDependenciesError",
|
||||
{
|
||||
manifestPath: Schema.String,
|
||||
},
|
||||
) {
|
||||
override get message(): string {
|
||||
return `Could not resolve production dependencies from ${this.manifestPath}.`;
|
||||
}
|
||||
}
|
||||
|
||||
const DesktopBuildInputArtifact = Schema.Literals([
|
||||
"desktop-dist",
|
||||
"desktop-resources",
|
||||
"server-dist",
|
||||
"bundled-server-client",
|
||||
]);
|
||||
type DesktopBuildInputArtifact = typeof DesktopBuildInputArtifact.Type;
|
||||
const desktopBuildInputArtifactNames = {
|
||||
"desktop-dist": "desktopDist",
|
||||
"desktop-resources": "desktopResources",
|
||||
"server-dist": "serverDist",
|
||||
"bundled-server-client": "bundled server client",
|
||||
} satisfies Record<DesktopBuildInputArtifact, string>;
|
||||
|
||||
export class MissingDesktopBuildInputError extends Schema.TaggedErrorClass<MissingDesktopBuildInputError>()(
|
||||
"MissingDesktopBuildInputError",
|
||||
{
|
||||
artifact: DesktopBuildInputArtifact,
|
||||
artifactPath: Schema.String,
|
||||
buildCommand: Schema.Literal("vp run build:desktop"),
|
||||
},
|
||||
) {
|
||||
override get message(): string {
|
||||
return `Missing ${desktopBuildInputArtifactNames[this.artifact]} at ${this.artifactPath}. Run '${this.buildCommand}' first.`;
|
||||
}
|
||||
}
|
||||
|
||||
export class MacProvisioningProfileNotFoundError extends Schema.TaggedErrorClass<MacProvisioningProfileNotFoundError>()(
|
||||
"MacProvisioningProfileNotFoundError",
|
||||
{
|
||||
provisioningProfilePath: Schema.String,
|
||||
},
|
||||
) {
|
||||
override get message(): string {
|
||||
return `macOS provisioning profile not found: ${this.provisioningProfilePath}`;
|
||||
}
|
||||
}
|
||||
|
||||
export class DesktopBuildDistDirectoryMissingError extends Schema.TaggedErrorClass<DesktopBuildDistDirectoryMissingError>()(
|
||||
"DesktopBuildDistDirectoryMissingError",
|
||||
{
|
||||
distPath: Schema.String,
|
||||
platform: BuildPlatform,
|
||||
arch: BuildArch,
|
||||
},
|
||||
) {
|
||||
override get message(): string {
|
||||
return `Build completed but dist directory was not found at ${this.distPath}`;
|
||||
}
|
||||
}
|
||||
|
||||
export class DesktopBuildNoArtifactsProducedError extends Schema.TaggedErrorClass<DesktopBuildNoArtifactsProducedError>()(
|
||||
"DesktopBuildNoArtifactsProducedError",
|
||||
{
|
||||
distPath: Schema.String,
|
||||
platform: BuildPlatform,
|
||||
arch: BuildArch,
|
||||
},
|
||||
) {
|
||||
override get message(): string {
|
||||
return `Build completed but no files were produced in ${this.distPath}`;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -616,8 +834,12 @@ const stageClerkPasskeyNativeBinaries = Effect.fn("stageClerkPasskeyNativeBinari
|
||||
const sourcePath = yield* Effect.try({
|
||||
try: () => packageRequire.resolve(artifact.packageName),
|
||||
catch: (cause) =>
|
||||
new BuildScriptError({
|
||||
message: `Clerk passkey native package is missing: ${artifact.packageName}`,
|
||||
new ClerkPasskeyNativePackageMissingError({
|
||||
packageName: artifact.packageName,
|
||||
binaryFileName: artifact.binaryFileName,
|
||||
packageEntryPath,
|
||||
platform,
|
||||
arch,
|
||||
cause,
|
||||
}),
|
||||
});
|
||||
@@ -691,6 +913,18 @@ const MockUpdateServerPortSchema = Schema.NumberFromString.check(
|
||||
);
|
||||
const decodeMockUpdateServerPort = Schema.decodeUnknownEffect(MockUpdateServerPortSchema);
|
||||
|
||||
function invalidMockUpdateServerPortReason(
|
||||
configuredPort: string,
|
||||
): typeof InvalidMockUpdateServerPortReason.Type {
|
||||
const parsed = Number(configuredPort);
|
||||
if (!Number.isFinite(parsed)) return "not-numeric";
|
||||
if (!Number.isInteger(parsed)) return "not-integer";
|
||||
if (parsed < 1 || parsed > 65535) return "out-of-range";
|
||||
// This mapper is only called after schema decoding failed. An otherwise
|
||||
// valid integer therefore used a representation the decoder did not accept.
|
||||
return "not-numeric";
|
||||
}
|
||||
|
||||
const resolveBooleanFlag = (flag: Option.Option<boolean>, envValue: boolean) =>
|
||||
Option.getOrElse(flag, () => envValue);
|
||||
const mergeOptions = <A>(a: Option.Option<A>, b: Option.Option<A>, defaultValue: A) =>
|
||||
@@ -722,9 +956,7 @@ export const resolveBuildOptions = Effect.fn("resolveBuildOptions")(function* (
|
||||
);
|
||||
|
||||
if (!platform) {
|
||||
return yield* new BuildScriptError({
|
||||
message: `Unsupported host platform '${hostPlatform}'.`,
|
||||
});
|
||||
return yield* new UnsupportedHostBuildPlatformError({ hostPlatform });
|
||||
}
|
||||
|
||||
const target = mergeOptions(input.target, env.target, PLATFORM_CONFIG[platform].defaultTarget);
|
||||
@@ -745,17 +977,16 @@ export const resolveBuildOptions = Effect.fn("resolveBuildOptions")(function* (
|
||||
const verbose = resolveBooleanFlag(input.verbose, env.verbose);
|
||||
|
||||
const mockUpdates = resolveBooleanFlag(input.mockUpdates, env.mockUpdates);
|
||||
const configuredMockUpdateServerPort = Option.getOrUndefined(env.mockUpdateServerPort);
|
||||
const mockUpdateServerPort =
|
||||
Option.getOrUndefined(input.mockUpdateServerPort) ??
|
||||
(yield* resolveMockUpdateServerPort(Option.getOrUndefined(env.mockUpdateServerPort)).pipe(
|
||||
Effect.mapError(
|
||||
(cause) =>
|
||||
new BuildScriptError({
|
||||
message: "Invalid mock update server port.",
|
||||
cause,
|
||||
}),
|
||||
),
|
||||
));
|
||||
(configuredMockUpdateServerPort === undefined
|
||||
? undefined
|
||||
: yield* resolveMockUpdateServerPort(configuredMockUpdateServerPort).pipe(
|
||||
Effect.mapError((cause) =>
|
||||
InvalidMockUpdateServerPortError.fromConfigValue(configuredMockUpdateServerPort, cause),
|
||||
),
|
||||
));
|
||||
|
||||
return {
|
||||
platform,
|
||||
@@ -775,7 +1006,7 @@ export const resolveBuildOptions = Effect.fn("resolveBuildOptions")(function* (
|
||||
const runCommand = Effect.fn("runCommand")(function* (
|
||||
command: ChildProcess.Command,
|
||||
options: {
|
||||
readonly label?: string;
|
||||
readonly label: string;
|
||||
readonly verbose: boolean;
|
||||
},
|
||||
) {
|
||||
@@ -791,14 +1022,11 @@ const runCommand = Effect.fn("runCommand")(function* (
|
||||
);
|
||||
|
||||
if (exitCode !== 0) {
|
||||
const outputSections = [
|
||||
options.label ? `Command: ${options.label}` : undefined,
|
||||
formatOutputSection("stdout", stdout),
|
||||
formatOutputSection("stderr", stderr),
|
||||
].filter((section): section is string => section !== undefined);
|
||||
const outputSuffix = outputSections.length > 0 ? `\n\n${outputSections.join("\n\n")}` : "";
|
||||
return yield* new BuildScriptError({
|
||||
message: `Command exited with non-zero exit code (${exitCode})${outputSuffix}`,
|
||||
return yield* new BuildCommandFailedError({
|
||||
command: options.label,
|
||||
exitCode,
|
||||
...(stdout.trim() ? { stdoutTail: stdout } : {}),
|
||||
...(stderr.trim() ? { stderrTail: stderr } : {}),
|
||||
});
|
||||
}
|
||||
});
|
||||
@@ -845,8 +1073,9 @@ function stageMacIcons(stageResourcesDir: string, sourcePng: string, verbose: bo
|
||||
const fs = yield* FileSystem.FileSystem;
|
||||
const path = yield* Path.Path;
|
||||
if (!(yield* fs.exists(sourcePng))) {
|
||||
return yield* new BuildScriptError({
|
||||
message: `Desktop macOS icon source is missing at ${sourcePng}`,
|
||||
return yield* new DesktopIconSourceMissingError({
|
||||
platform: "mac",
|
||||
sourcePath: sourcePng,
|
||||
});
|
||||
}
|
||||
|
||||
@@ -871,8 +1100,9 @@ function stageLinuxIcons(stageResourcesDir: string, sourcePng: string, verbose:
|
||||
const fs = yield* FileSystem.FileSystem;
|
||||
const path = yield* Path.Path;
|
||||
if (!(yield* fs.exists(sourcePng))) {
|
||||
return yield* new BuildScriptError({
|
||||
message: `Desktop Linux icon source is missing at ${sourcePng}`,
|
||||
return yield* new DesktopIconSourceMissingError({
|
||||
platform: "linux",
|
||||
sourcePath: sourcePng,
|
||||
});
|
||||
}
|
||||
|
||||
@@ -931,8 +1161,9 @@ function stageWindowsIcons(stageResourcesDir: string, sourceIco: string) {
|
||||
const fs = yield* FileSystem.FileSystem;
|
||||
const path = yield* Path.Path;
|
||||
if (!(yield* fs.exists(sourceIco))) {
|
||||
return yield* new BuildScriptError({
|
||||
message: `Desktop Windows icon source is missing at ${sourceIco}`,
|
||||
return yield* new DesktopIconSourceMissingError({
|
||||
platform: "win",
|
||||
sourcePath: sourceIco,
|
||||
});
|
||||
}
|
||||
|
||||
@@ -969,10 +1200,9 @@ function validateBundledClientAssets(clientDir: string) {
|
||||
}
|
||||
|
||||
if (missing.length > 0) {
|
||||
const preview = missing.slice(0, 6).join(", ");
|
||||
const suffix = missing.length > 6 ? ` (+${missing.length - 6} more)` : "";
|
||||
return yield* new BuildScriptError({
|
||||
message: `Bundled client references missing files in ${indexPath}: ${preview}${suffix}. Rebuild web/server artifacts.`,
|
||||
return yield* new BundledClientAssetsMissingError({
|
||||
indexPath,
|
||||
missingFiles: missing,
|
||||
});
|
||||
}
|
||||
});
|
||||
@@ -1174,8 +1404,8 @@ const buildDesktopArtifact = Effect.fn("buildDesktopArtifact")(function* (
|
||||
|
||||
const platformConfig = PLATFORM_CONFIG[options.platform];
|
||||
if (!platformConfig) {
|
||||
return yield* new BuildScriptError({
|
||||
message: `Unsupported platform '${options.platform}'.`,
|
||||
return yield* new UnsupportedDesktopBuildPlatformError({
|
||||
platform: options.platform,
|
||||
});
|
||||
}
|
||||
|
||||
@@ -1183,16 +1413,17 @@ const buildDesktopArtifact = Effect.fn("buildDesktopArtifact")(function* (
|
||||
|
||||
const serverDependencies = serverPackageJson.dependencies;
|
||||
if (!serverDependencies || Object.keys(serverDependencies).length === 0) {
|
||||
return yield* new BuildScriptError({
|
||||
message: "Could not resolve production dependencies from apps/server/package.json.",
|
||||
return yield* new MissingServerProductionDependenciesError({
|
||||
manifestPath: "apps/server/package.json",
|
||||
});
|
||||
}
|
||||
|
||||
const resolvedOverrides = yield* Effect.try({
|
||||
try: () => resolveCatalogDependencies(workspaceOverrides, workspaceCatalog, "apps/desktop"),
|
||||
catch: (cause) =>
|
||||
new BuildScriptError({
|
||||
message: "Could not resolve overrides from pnpm-workspace.yaml.",
|
||||
new DesktopBuildDependencyResolutionError({
|
||||
kind: "workspace-overrides",
|
||||
manifestPath: "pnpm-workspace.yaml",
|
||||
cause,
|
||||
}),
|
||||
});
|
||||
@@ -1200,16 +1431,18 @@ const buildDesktopArtifact = Effect.fn("buildDesktopArtifact")(function* (
|
||||
const resolvedServerDependencies = yield* Effect.try({
|
||||
try: () => resolveCatalogDependencies(serverDependencies, workspaceCatalog, "apps/server"),
|
||||
catch: (cause) =>
|
||||
new BuildScriptError({
|
||||
message: "Could not resolve production dependencies from apps/server/package.json.",
|
||||
new DesktopBuildDependencyResolutionError({
|
||||
kind: "server-production",
|
||||
manifestPath: "apps/server/package.json",
|
||||
cause,
|
||||
}),
|
||||
});
|
||||
const resolvedDesktopRuntimeDependencies = yield* Effect.try({
|
||||
try: () => resolveDesktopRuntimeDependencies(desktopPackageJson.dependencies, workspaceCatalog),
|
||||
catch: (cause) =>
|
||||
new BuildScriptError({
|
||||
message: "Could not resolve desktop runtime dependencies from apps/desktop/package.json.",
|
||||
new DesktopBuildDependencyResolutionError({
|
||||
kind: "desktop-runtime",
|
||||
manifestPath: "apps/desktop/package.json",
|
||||
cause,
|
||||
}),
|
||||
});
|
||||
@@ -1243,17 +1476,25 @@ const buildDesktopArtifact = Effect.fn("buildDesktopArtifact")(function* (
|
||||
);
|
||||
}
|
||||
|
||||
for (const [label, dir] of Object.entries(distDirs)) {
|
||||
if (!(yield* fs.exists(dir))) {
|
||||
return yield* new BuildScriptError({
|
||||
message: `Missing ${label} at ${dir}. Run 'vp run build:desktop' first.`,
|
||||
const requiredBuildInputs = [
|
||||
{ artifact: "desktop-dist", artifactPath: distDirs.desktopDist },
|
||||
{ artifact: "desktop-resources", artifactPath: distDirs.desktopResources },
|
||||
{ artifact: "server-dist", artifactPath: distDirs.serverDist },
|
||||
] as const;
|
||||
for (const input of requiredBuildInputs) {
|
||||
if (!(yield* fs.exists(input.artifactPath))) {
|
||||
return yield* new MissingDesktopBuildInputError({
|
||||
...input,
|
||||
buildCommand: "vp run build:desktop",
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
if (!(yield* fs.exists(bundledClientEntry))) {
|
||||
return yield* new BuildScriptError({
|
||||
message: `Missing bundled server client at ${bundledClientEntry}. Run 'vp run build:desktop' first.`,
|
||||
return yield* new MissingDesktopBuildInputError({
|
||||
artifact: "bundled-server-client",
|
||||
artifactPath: bundledClientEntry,
|
||||
buildCommand: "vp run build:desktop",
|
||||
});
|
||||
}
|
||||
|
||||
@@ -1285,7 +1526,7 @@ const buildDesktopArtifact = Effect.fn("buildDesktopArtifact")(function* (
|
||||
options.platform === "mac" && options.signed
|
||||
? yield* Effect.try({
|
||||
try: () => resolveMacPasskeySigningConfiguration(loadRepoEnv({ repoRoot })),
|
||||
catch: BuildScriptError.fromMacPasskeySigningConfiguration,
|
||||
catch: MacPasskeySigningConfigurationResolutionError.fromCause,
|
||||
})
|
||||
: undefined;
|
||||
const macPasskeySigning = configuredMacPasskeySigning
|
||||
@@ -1302,8 +1543,8 @@ const buildDesktopArtifact = Effect.fn("buildDesktopArtifact")(function* (
|
||||
: undefined;
|
||||
if (macPasskeySigning && macEntitlementsPath) {
|
||||
if (!(yield* fs.exists(macPasskeySigning.provisioningProfilePath))) {
|
||||
return yield* new BuildScriptError({
|
||||
message: `macOS provisioning profile not found: ${macPasskeySigning.provisioningProfilePath}`,
|
||||
return yield* new MacProvisioningProfileNotFoundError({
|
||||
provisioningProfilePath: macPasskeySigning.provisioningProfilePath,
|
||||
});
|
||||
}
|
||||
yield* fs.writeFileString(macEntitlementsPath, renderMacPasskeyEntitlements(macPasskeySigning));
|
||||
@@ -1442,8 +1683,10 @@ const buildDesktopArtifact = Effect.fn("buildDesktopArtifact")(function* (
|
||||
|
||||
const stageDistDir = path.join(stageAppDir, "dist");
|
||||
if (!(yield* fs.exists(stageDistDir))) {
|
||||
return yield* new BuildScriptError({
|
||||
message: `Build completed but dist directory was not found at ${stageDistDir}`,
|
||||
return yield* new DesktopBuildDistDirectoryMissingError({
|
||||
distPath: stageDistDir,
|
||||
platform: options.platform,
|
||||
arch: options.arch,
|
||||
});
|
||||
}
|
||||
|
||||
@@ -1462,8 +1705,10 @@ const buildDesktopArtifact = Effect.fn("buildDesktopArtifact")(function* (
|
||||
}
|
||||
|
||||
if (copiedArtifacts.length === 0) {
|
||||
return yield* new BuildScriptError({
|
||||
message: `Build completed but no files were produced in ${stageDistDir}`,
|
||||
return yield* new DesktopBuildNoArtifactsProducedError({
|
||||
distPath: stageDistDir,
|
||||
platform: options.platform,
|
||||
arch: options.arch,
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user