1#!/usr/bin/env node
2
3// Runs the native-load probes a cross-built Windows desktop artifact skipped,
4// on a host of the target's architecture.
5
6import * as NodeRuntime from "@effect/platform-node/NodeRuntime";
7import * as NodeServices from "@effect/platform-node/NodeServices";
8import * as Effect from "effect/Effect";
9import * as Layer from "effect/Layer";
10import * as Logger from "effect/Logger";
11import { Command, Flag } from "effect/cli";
12
13import {
14 resolveDesktopProductName,
15 verifyWindowsPackagedRuntime,
16} from "./build-desktop-artifact.ts";
17
18const verifyWindowsDesktopArtifactCli = Command.make("verify-windows-desktop-artifact", {
19 appDir: Flag.String("app-dir").pipe(
20 Flag.withDescription("The electron-builder `win-<arch>-unpacked` directory."),
21 ),
22 arch: Flag.Literals("arch", ["arm64", "x64"] as const),
23 buildVersion: Flag.String("build-version").pipe(
24 Flag.withDescription("The artifact's build version."),
25 ),
26 verbose: Flag.Boolean("verbose").pipe(Flag.withDefault(false)),
27}).pipe(
28 Command.withDescription("Verify a Windows desktop artifact's packaged natives load."),
29 Command.withHandler(({ appDir, arch, buildVersion, verbose }) =>
30 Effect.gen(function* () {
31 yield* verifyWindowsPackagedRuntime({
32 packagedAppDir: appDir,
33 appExecutableName: `${resolveDesktopProductName(buildVersion)}.exe`,
34 targetArch: arch,
35 verbose,
36 });
37 yield* Effect.log(`[verify-windows-desktop-artifact] ${appDir} passed.`);
38 }),
39 ),
40);
41
42// No import.meta.main guard: CI bundles this file into one module together with
43// build-desktop-artifact.ts, whose own guard is defined false in that bundle.
44Command.run(verifyWindowsDesktopArtifactCli, { version: "0.0.0" }).pipe(
45 Effect.scoped,
46 Effect.provide(Layer.mergeAll(Logger.layer([Logger.consolePretty()]), NodeServices.layer)),
47 NodeRuntime.runMain,
48);