Skip to content
Source
Sign inSign up
pingdotgg/t3code
Open History to see the last commit

build-desktop-artifact.ts

655 lines21.3 KB

1#!/usr/bin/env node
2​
3import { spawnSync } from "node:child_process";
4​
5import rootPackageJson from "../package.json" with { type: "json" };
6import desktopPackageJson from "../apps/desktop/package.json" with { type: "json" };
7import serverPackageJson from "../apps/server/package.json" with { type: "json" };
8​
9import * as NodeRuntime from "@effect/platform-node/NodeRuntime";
10import * as NodeServices from "@effect/platform-node/NodeServices";
11import { Config, Data, Effect, FileSystem, Logger, Option, Path, Schema } from "effect";
12import { Command, Flag } from "effect/unstable/cli";
13import { ChildProcess } from "effect/unstable/process";
14​
15const BuildPlatform = Schema.Literals(["mac", "linux", "win"]);
16const BuildArch = Schema.Literals(["arm64", "x64", "universal"]);
17​
18const RepoRoot = Effect.service(Path.Path).pipe(
19 Effect.flatMap((path) => path.fromFileUrl(new URL("..", import.meta.url))),
20);
21const IconSource = Effect.zipWith(RepoRoot, Effect.service(Path.Path), (repoRoot, path) =>
22 path.join(repoRoot, "assets/macos-icon-1024.png"),
23);
24​
25interface PlatformConfig {
26 readonly cliFlag: "--mac" | "--linux" | "--win";
27 readonly defaultTarget: string;
28 readonly archChoices: ReadonlyArray<typeof BuildArch.Type>;
30​
31const PLATFORM_CONFIG: Record<typeof BuildPlatform.Type, PlatformConfig> = {
32 mac: {
33 cliFlag: "--mac",
34 defaultTarget: "dmg",
35 archChoices: ["arm64", "x64", "universal"],
36 },
37 linux: {
38 cliFlag: "--linux",
39 defaultTarget: "AppImage",
40 archChoices: ["x64", "arm64"],
41 },
42 win: {
43 cliFlag: "--win",
44 defaultTarget: "nsis",
45 archChoices: ["x64", "arm64"],
46 },
47};
48​
49interface BuildCliInput {
50 readonly platform: Option.Option<typeof BuildPlatform.Type>;
51 readonly target: Option.Option<string>;
52 readonly arch: Option.Option<typeof BuildArch.Type>;
53 readonly buildVersion: Option.Option<string>;
54 readonly outputDir: Option.Option<string>;
55 readonly skipBuild: Option.Option<boolean>;
56 readonly keepStage: Option.Option<boolean>;
57 readonly signed: Option.Option<boolean>;
58 readonly verbose: Option.Option<boolean>;
60​
61function detectHostBuildPlatform(hostPlatform: string): typeof BuildPlatform.Type | undefined {
62 if (hostPlatform === "darwin") return "mac";
63 if (hostPlatform === "linux") return "linux";
64 if (hostPlatform === "win32") return "win";
65 return undefined;
67​
68function getDefaultArch(platform: typeof BuildPlatform.Type): typeof BuildArch.Type {
69 const config = PLATFORM_CONFIG[platform];
70 if (!config) {
71 return "x64";
72 }
73​
74 if (process.arch === "arm64" && config.archChoices.includes("arm64")) {
75 return "arm64";
76 }
77 if (process.arch === "x64" && config.archChoices.includes("x64")) {
78 return "x64";
79 }
80​
81 return config.archChoices[0] ?? "x64";
83​
84class BuildScriptError extends Data.TaggedError("BuildScriptError")<{
85 readonly message: string;
86 readonly cause?: unknown;
87}> {}
88​
89function resolveGitCommitHash(repoRoot: string): string {
90 const result = spawnSync("git", ["rev-parse", "--short=12", "HEAD"], {
91 cwd: repoRoot,
92 encoding: "utf8",
93 });
94 if (result.status !== 0) {
95 return "unknown";
96 }
97 const hash = result.stdout.trim();
98 if (!/^[0-9a-f]{7,40}$/i.test(hash)) {
99 return "unknown";
100 }
101 return hash.toLowerCase();
103​
104interface ResolvedBuildOptions {
105 readonly platform: typeof BuildPlatform.Type;
106 readonly target: string;
107 readonly arch: typeof BuildArch.Type;
108 readonly version: string | undefined;
109 readonly outputDir: string;
110 readonly skipBuild: boolean;
111 readonly keepStage: boolean;
112 readonly signed: boolean;
113 readonly verbose: boolean;
115​
116interface StagePackageJson {
117 readonly name: string;
118 readonly version: string;
119 readonly buildVersion: string;
120 readonly t3codeCommitHash: string;
121 readonly private: true;
122 readonly description: string;
123 readonly author: string;
124 readonly main: string;
125 readonly build: Record<string, unknown>;
126 readonly dependencies: Record<string, unknown>;
127 readonly devDependencies: {
128 readonly electron: string;
129 };
131​
132const AzureTrustedSigningOptionsConfig = Config.all({
133 publisherName: Config.string("AZURE_TRUSTED_SIGNING_PUBLISHER_NAME"),
134 endpoint: Config.string("AZURE_TRUSTED_SIGNING_ENDPOINT"),
135 certificateProfileName: Config.string("AZURE_TRUSTED_SIGNING_CERTIFICATE_PROFILE_NAME"),
136 codeSigningAccountName: Config.string("AZURE_TRUSTED_SIGNING_ACCOUNT_NAME"),
137 fileDigest: Config.string("AZURE_TRUSTED_SIGNING_FILE_DIGEST").pipe(
138 Config.withDefault(() => "SHA256"),
139 ),
140 timestampDigest: Config.string("AZURE_TRUSTED_SIGNING_TIMESTAMP_DIGEST").pipe(
141 Config.withDefault(() => "SHA256"),
142 ),
143 timestampRfc3161: Config.string("AZURE_TRUSTED_SIGNING_TIMESTAMP_RFC3161").pipe(
144 Config.withDefault(() => "http://timestamp.acs.microsoft.com"),
145 ),
146});
147​
148const BuildEnvConfig = Config.all({
149 platform: Config.schema(BuildPlatform, "T3CODE_DESKTOP_PLATFORM").pipe(Config.option),
150 target: Config.string("T3CODE_DESKTOP_TARGET").pipe(Config.option),
151 arch: Config.schema(BuildArch, "T3CODE_DESKTOP_ARCH").pipe(Config.option),
152 version: Config.string("T3CODE_DESKTOP_VERSION").pipe(Config.option),
153 outputDir: Config.string("T3CODE_DESKTOP_OUTPUT_DIR").pipe(Config.option),
154 skipBuild: Config.boolean("T3CODE_DESKTOP_SKIP_BUILD").pipe(Config.withDefault(() => false)),
155 keepStage: Config.boolean("T3CODE_DESKTOP_KEEP_STAGE").pipe(Config.withDefault(() => false)),
156 signed: Config.boolean("T3CODE_DESKTOP_SIGNED").pipe(Config.withDefault(() => false)),
157 verbose: Config.boolean("T3CODE_DESKTOP_VERBOSE").pipe(Config.withDefault(() => false)),
158});
159​
160const resolveBooleanFlag = (flag: Option.Option<boolean>, envValue: boolean) =>
161 Option.getOrElse(Option.filter(flag, Boolean), () => envValue);
162const mergeOptions = <A>(a: Option.Option<A>, b: Option.Option<A>, defaultValue: A) =>
163 Option.getOrElse(a, () => Option.getOrElse(b, () => defaultValue));
164​
165const resolveBuildOptions = Effect.fn(function* (input: BuildCliInput) {
166 const path = yield* Path.Path;
167 const repoRoot = yield* RepoRoot;
168 const env = yield* BuildEnvConfig.asEffect();
169​
170 const platform = mergeOptions(
171 input.platform,
172 env.platform,
173 detectHostBuildPlatform(process.platform),
174 );
175​
176 if (!platform) {
177 return yield* new BuildScriptError({
178 message: `Unsupported host platform '${process.platform}'.`,
179 });
180 }
181​
182 const target = mergeOptions(input.target, env.target, PLATFORM_CONFIG[platform].defaultTarget);
183 const arch = mergeOptions(input.arch, env.arch, getDefaultArch(platform));
184 const version = mergeOptions(input.buildVersion, env.version, undefined);
185 const outputDir = path.resolve(repoRoot, mergeOptions(input.outputDir, env.outputDir, "release"));
186​
187 const skipBuild = resolveBooleanFlag(input.skipBuild, env.skipBuild);
188 const keepStage = resolveBooleanFlag(input.keepStage, env.keepStage);
189 const signed = resolveBooleanFlag(input.signed, env.signed);
190 const verbose = resolveBooleanFlag(input.verbose, env.verbose);
191​
192 return {
193 platform,
194 target,
195 arch,
196 version,
197 outputDir,
198 skipBuild,
199 keepStage,
200 signed,
201 verbose,
202 } satisfies ResolvedBuildOptions;
203});
204​
205const commandOutputOptions = (verbose: boolean) =>
206 ({
207 stdout: verbose ? "inherit" : "ignore",
208 stderr: "inherit",
209 }) as const;
210​
211const runCommand = Effect.fn(function* (command: ChildProcess.Command) {
212 const exitCode = yield* ChildProcess.exitCode(command);
213​
214 if (exitCode !== 0) {
215 return yield* new BuildScriptError({
216 message: "Command exited with non-zero exit code",
217 });
218 }
219});
220​
221function generateMacIconSet(
222 sourcePng: string,
223 targetIcns: string,
224 tmpRoot: string,
225 path: Path.Path,
226 verbose: boolean,
227) {
228 return Effect.gen(function* () {
229 const fs = yield* FileSystem.FileSystem;
230 const iconsetDir = path.join(tmpRoot, "icon.iconset");
231 yield* fs.makeDirectory(iconsetDir, { recursive: true });
232​
233 const iconSizes = [16, 32, 128, 256, 512] as const;
234 for (const size of iconSizes) {
235 yield* runCommand(
236 ChildProcess.make({
237 ...commandOutputOptions(verbose),
238 })`sips -z ${size} ${size} ${sourcePng} --out ${path.join(iconsetDir, `icon_${size}x${size}.png`)}`,
239 );
240​
241 const retinaSize = size * 2;
242 yield* runCommand(
243 ChildProcess.make({
244 ...commandOutputOptions(verbose),
245 })`sips -z ${retinaSize} ${retinaSize} ${sourcePng} --out ${path.join(iconsetDir, `icon_${size}x${size}@2x.png`)}`,
246 );
247 }
248​
249 yield* runCommand(
250 ChildProcess.make({
251 ...commandOutputOptions(verbose),
252 })`iconutil -c icns ${iconsetDir} -o ${targetIcns}`,
253 );
254 });
256​
257function stageMacIcons(stageResourcesDir: string, verbose: boolean) {
258 return Effect.gen(function* () {
259 const fs = yield* FileSystem.FileSystem;
260 const path = yield* Path.Path;
261 const iconSource = yield* IconSource;
262 if (!(yield* fs.exists(iconSource))) {
263 return yield* new BuildScriptError({
264 message: `Production icon source is missing at ${iconSource}`,
265 });
266 }
267​
268 const tmpRoot = yield* fs.makeTempDirectoryScoped({
269 prefix: "t3code-icon-build-",
270 });
271​
272 const iconPngPath = path.join(stageResourcesDir, "icon.png");
273 const iconIcnsPath = path.join(stageResourcesDir, "icon.icns");
274​
275 yield* runCommand(
276 ChildProcess.make({
277 ...commandOutputOptions(verbose),
278 })`sips -z 512 512 ${iconSource} --out ${iconPngPath}`,
279 );
280​
281 yield* generateMacIconSet(iconSource, iconIcnsPath, tmpRoot, path, verbose);
282 });
284​
285function validateBundledClientAssets(clientDir: string) {
286 return Effect.gen(function* () {
287 const fs = yield* FileSystem.FileSystem;
288 const path = yield* Path.Path;
289 const indexPath = path.join(clientDir, "index.html");
290 const indexHtml = yield* fs.readFileString(indexPath);
291 const refs = [...indexHtml.matchAll(/\b(?:src|href)=["']([^"']+)["']/g)].map(
292 (match) => match[1],
293 );
294 const missing: string[] = [];
295​
296 for (const ref of refs) {
297 const normalizedRef = ref.split("#")[0]?.split("?")[0] ?? "";
298 if (!normalizedRef) continue;
299 if (normalizedRef.startsWith("http://") || normalizedRef.startsWith("https://")) continue;
300 if (normalizedRef.startsWith("data:") || normalizedRef.startsWith("mailto:")) continue;
301​
302 const ext = path.extname(normalizedRef);
303 if (!ext) continue;
304​
305 const relativePath = normalizedRef.replace(/^\/+/, "");
306 const assetPath = path.join(clientDir, relativePath);
307 if (!(yield* fs.exists(assetPath))) {
308 missing.push(normalizedRef);
309 }
310 }
311​
312 if (missing.length > 0) {
313 const preview = missing.slice(0, 6).join(", ");
314 const suffix = missing.length > 6 ? ` (+${missing.length - 6} more)` : "";
315 return yield* new BuildScriptError({
316 message: `Bundled client references missing files in ${indexPath}: ${preview}${suffix}. Rebuild web/server artifacts.`,
317 });
318 }
319 });
321​
322function resolveCatalogDependencies(
323 dependencies: Record<string, unknown>,
324 catalog: Record<string, unknown>,
325 dependencySourceLabel: string,
326): Record<string, unknown> {
327 return Object.fromEntries(
328 Object.entries(dependencies).map(([dependencyName, spec]) => {
329 if (typeof spec !== "string" || !spec.startsWith("catalog:")) {
330 return [dependencyName, spec];
331 }
332​
333 const catalogKey = spec.slice("catalog:".length).trim();
334 const lookupKey = catalogKey.length > 0 ? catalogKey : dependencyName;
335 const resolvedSpec = catalog[lookupKey];
336 if (typeof resolvedSpec !== "string" || resolvedSpec.length === 0) {
337 throw new BuildScriptError({
338 message: `Unable to resolve '${spec}' for ${dependencySourceLabel} dependency '${dependencyName}'. Expected key '${lookupKey}' in root workspace catalog.`,
339 });
340 }
341​
342 return [dependencyName, resolvedSpec];
343 }),
344 );
346​
347const createBuildConfig = Effect.fn(function* (
348 platform: typeof BuildPlatform.Type,
349 target: string,
350 productName: string,
351 signed: boolean,
352) {
353 const buildConfig: Record<string, unknown> = {
354 appId: "com.t3tools.t3code",
355 productName,
356 artifactName: "T3-Code-${version}-${arch}.${ext}",
357 directories: {
358 buildResources: "apps/desktop/resources",
359 },
360 };
361​
362 if (platform === "mac") {
363 buildConfig.mac = {
364 target: [target],
365 icon: "icon.icns",
366 category: "public.app-category.developer-tools",
367 };
368 }
369​
370 if (platform === "linux") {
371 buildConfig.linux = {
372 target: [target],
373 icon: "icon.png",
374 category: "Development",
375 };
376 }
377​
378 if (platform === "win") {
379 const winConfig: Record<string, unknown> = {
380 target: [target],
381 icon: "icon.ico",
382 };
383 if (signed) {
384 winConfig.azureSignOptions = yield* AzureTrustedSigningOptionsConfig;
385 }
386 buildConfig.win = winConfig;
387 }
388​
389 return buildConfig;
390});
391​
392const assertPlatformBuildResources = Effect.fn(function* (
393 platform: typeof BuildPlatform.Type,
394 stageResourcesDir: string,
395 verbose: boolean,
396) {
397 const fs = yield* FileSystem.FileSystem;
398 const path = yield* Path.Path;
399​
400 if (platform === "mac") {
401 yield* stageMacIcons(stageResourcesDir, verbose);
402 return;
403 }
404​
405 if (platform === "linux") {
406 const iconPath = path.join(stageResourcesDir, "icon.png");
407 if (!(yield* fs.exists(iconPath))) {
408 return yield* new BuildScriptError({
409 message: `Missing Linux icon at ${iconPath}`,
410 });
411 }
412 return;
413 }
414​
415 if (platform === "win") {
416 const iconPath = path.join(stageResourcesDir, "icon.ico");
417 if (!(yield* fs.exists(iconPath))) {
418 return yield* new BuildScriptError({
419 message: `Missing Windows icon at ${iconPath}`,
420 });
421 }
422 }
423});
424​
425const buildDesktopArtifact = Effect.fn(function* (options: ResolvedBuildOptions) {
426 const repoRoot = yield* RepoRoot;
427 const path = yield* Path.Path;
428 const fs = yield* FileSystem.FileSystem;
429​
430 const platformConfig = PLATFORM_CONFIG[options.platform];
431 if (!platformConfig) {
432 return yield* new BuildScriptError({
433 message: `Unsupported platform '${options.platform}'.`,
434 });
435 }
436​
437 const electronVersion = desktopPackageJson.dependencies.electron;
438​
439 const dependencies = serverPackageJson.dependencies;
440 if (!dependencies || Object.keys(dependencies).length === 0) {
441 return yield* new BuildScriptError({
442 message: "Could not resolve production dependencies from apps/server/package.json.",
443 });
444 }
445​
446 const resolvedDependencies = yield* Effect.try({
447 try: () =>
448 resolveCatalogDependencies(dependencies, rootPackageJson.workspaces.catalog, "apps/server"),
449 catch: (cause) =>
450 new BuildScriptError({
451 message: "Could not resolve production dependencies from apps/server/package.json.",
452 cause,
453 }),
454 });
455​
456 const appVersion = options.version ?? serverPackageJson.version;
457 const commitHash = resolveGitCommitHash(repoRoot);
458 const mkdir = options.keepStage ? fs.makeTempDirectory : fs.makeTempDirectoryScoped;
459 const stageRoot = yield* mkdir({
460 prefix: `t3code-desktop-${options.platform}-stage-`,
461 });
462​
463 const stageAppDir = path.join(stageRoot, "app");
464 const stageResourcesDir = path.join(stageAppDir, "apps/desktop/resources");
465 const distDirs = {
466 desktopDist: path.join(repoRoot, "apps/desktop/dist-electron"),
467 desktopResources: path.join(repoRoot, "apps/desktop/resources"),
468 serverDist: path.join(repoRoot, "apps/server/dist"),
469 };
470 const bundledClientEntry = path.join(distDirs.serverDist, "client/index.html");
471​
472 if (!options.skipBuild) {
473 yield* Effect.log("[desktop-artifact] Building desktop/server/web artifacts...");
474 yield* runCommand(
475 ChildProcess.make({
476 cwd: repoRoot,
477 ...commandOutputOptions(options.verbose),
478 })`bun run build:desktop`,
479 );
480 }
481​
482 for (const [label, dir] of Object.entries(distDirs)) {
483 if (!(yield* fs.exists(dir))) {
484 return yield* new BuildScriptError({
485 message: `Missing ${label} at ${dir}. Run 'bun run build:desktop' first.`,
486 });
487 }
488 }
489​
490 if (!(yield* fs.exists(bundledClientEntry))) {
491 return yield* new BuildScriptError({
492 message: `Missing bundled server client at ${bundledClientEntry}. Run 'bun run build:desktop' first.`,
493 });
494 }
495​
496 yield* validateBundledClientAssets(path.dirname(bundledClientEntry));
497​
498 yield* fs.makeDirectory(path.join(stageAppDir, "apps/desktop"), { recursive: true });
499 yield* fs.makeDirectory(path.join(stageAppDir, "apps/server"), { recursive: true });
500​
501 yield* Effect.log("[desktop-artifact] Staging release app...");
502 yield* fs.copy(distDirs.desktopDist, path.join(stageAppDir, "apps/desktop/dist-electron"));
503 yield* fs.copy(distDirs.desktopResources, stageResourcesDir);
504 yield* fs.copy(distDirs.serverDist, path.join(stageAppDir, "apps/server/dist"));
505​
506 yield* assertPlatformBuildResources(options.platform, stageResourcesDir, options.verbose);
507​
508 const stagePackageJson: StagePackageJson = {
509 name: "t3-code-desktop",
510 version: appVersion,
511 buildVersion: appVersion,
512 t3codeCommitHash: commitHash,
513 private: true,
514 description: "T3 Code desktop build",
515 author: "T3 Tools",
516 main: "apps/desktop/dist-electron/main.js",
517 build: yield* createBuildConfig(
518 options.platform,
519 options.target,
520 desktopPackageJson.productName ?? "T3 Code",
521 options.signed,
522 ),
523 dependencies: resolvedDependencies,
524 devDependencies: {
525 electron: electronVersion,
526 },
527 };
528​
529 yield* fs.writeFileString(
530 path.join(stageAppDir, "package.json"),
531 `${JSON.stringify(stagePackageJson, null, 2)}\n`,
532 );
533​
534 yield* Effect.log("[desktop-artifact] Installing staged production dependencies...");
535 yield* runCommand(
536 ChildProcess.make({
537 cwd: stageAppDir,
538 ...commandOutputOptions(options.verbose),
539 })`bun install --production`,
540 );
541​
542 const buildEnv: NodeJS.ProcessEnv = {
543 ...process.env,
544 };
545 for (const [key, value] of Object.entries(buildEnv)) {
546 if (value === "") {
547 delete buildEnv[key];
548 }
549 }
550 if (!options.signed) {
551 buildEnv.CSC_IDENTITY_AUTO_DISCOVERY = "false";
552 delete buildEnv.CSC_LINK;
553 delete buildEnv.CSC_KEY_PASSWORD;
554 delete buildEnv.APPLE_API_KEY;
555 delete buildEnv.APPLE_API_KEY_ID;
556 delete buildEnv.APPLE_API_ISSUER;
557 }
558​
559 yield* Effect.log(
560 `[desktop-artifact] Building ${options.platform}/${options.target} (arch=${options.arch}, version=${appVersion})...`,
561 );
562 yield* runCommand(
563 ChildProcess.make({
564 cwd: stageAppDir,
565 env: buildEnv,
566 ...commandOutputOptions(options.verbose),
567 })`bunx electron-builder ${platformConfig.cliFlag} ${options.target} --${options.arch} --publish never`,
568 );
569​
570 const stageDistDir = path.join(stageAppDir, "dist");
571 if (!(yield* fs.exists(stageDistDir))) {
572 return yield* new BuildScriptError({
573 message: `Build completed but dist directory was not found at ${stageDistDir}`,
574 });
575 }
576​
577 const stageEntries = yield* fs.readDirectory(stageDistDir);
578 yield* fs.makeDirectory(options.outputDir, { recursive: true });
579​
580 const copiedArtifacts: string[] = [];
581 for (const entry of stageEntries) {
582 const from = path.join(stageDistDir, entry);
583 const stat = yield* fs.stat(from).pipe(Effect.catch(() => Effect.succeed(null)));
584 if (!stat || stat.type !== "File") continue;
585​
586 const to = path.join(options.outputDir, entry);
587 yield* fs.copyFile(from, to);
588 copiedArtifacts.push(to);
589 }
590​
591 if (copiedArtifacts.length === 0) {
592 return yield* new BuildScriptError({
593 message: `Build completed but no files were produced in ${stageDistDir}`,
594 });
595 }
596​
597 yield* Effect.log("[desktop-artifact] Done. Artifacts:").pipe(
598 Effect.annotateLogs({ artifacts: copiedArtifacts }),
599 );
600});
601​
602const buildDesktopArtifactCli = Command.make("build-desktop-artifact", {
603 platform: Flag.choice("platform", BuildPlatform.literals).pipe(
604 Flag.withDescription("Build platform (env: T3CODE_DESKTOP_PLATFORM)."),
605 Flag.optional,
606 ),
607 target: Flag.string("target").pipe(
608 Flag.withDescription(
609 "Artifact target, for example dmg/AppImage/nsis (env: T3CODE_DESKTOP_TARGET).",
610 ),
611 Flag.optional,
612 ),
613 arch: Flag.choice("arch", BuildArch.literals).pipe(
614 Flag.withDescription("Build arch, for example arm64/x64/universal (env: T3CODE_DESKTOP_ARCH)."),
615 Flag.optional,
616 ),
617 buildVersion: Flag.string("build-version").pipe(
618 Flag.withDescription("Artifact version metadata (env: T3CODE_DESKTOP_VERSION)."),
619 Flag.optional,
620 ),
621 outputDir: Flag.string("output-dir").pipe(
622 Flag.withDescription("Output directory for artifacts (env: T3CODE_DESKTOP_OUTPUT_DIR)."),
623 Flag.optional,
624 ),
625 skipBuild: Flag.boolean("skip-build").pipe(
626 Flag.withDescription(
627 "Skip `bun run build:desktop` and use existing dist artifacts (env: T3CODE_DESKTOP_SKIP_BUILD).",
628 ),
629 Flag.optional,
630 ),
631 keepStage: Flag.boolean("keep-stage").pipe(
632 Flag.withDescription("Keep temporary staging files (env: T3CODE_DESKTOP_KEEP_STAGE)."),
633 Flag.optional,
634 ),
635 signed: Flag.boolean("signed").pipe(
636 Flag.withDescription(
637 "Enable signing/notarization discovery; Windows uses Azure Trusted Signing (env: T3CODE_DESKTOP_SIGNED).",
638 ),
639 Flag.optional,
640 ),
641 verbose: Flag.boolean("verbose").pipe(
642 Flag.withDescription("Stream subprocess stdout (env: T3CODE_DESKTOP_VERBOSE)."),
643 Flag.optional,
644 ),
645}).pipe(
646 Command.withDescription("Build a desktop artifact for T3 Code."),
647 Command.withHandler((input) => Effect.flatMap(resolveBuildOptions(input), buildDesktopArtifact)),
648);
649​
650Command.run(buildDesktopArtifactCli, { version: "0.0.0" }).pipe(
651 Effect.scoped,
652 Effect.provide(Logger.layer([Logger.consolePretty()])),
653 Effect.provide(NodeServices.layer),
654 NodeRuntime.runMain,
655);