Open History to see the last commit
1#!/usr/bin/env node
2/**
3 * Packages the server single-executable into a self-contained per-platform
4 * archive: the `t3` binary, the web client, the resource monitor, and a
5 * production install of the native packages the bundle keeps external. The
6 * archive is the unit every runtime installer downloads, so nothing in it may
7 * require Node, npm, or a compiler on the machine that unpacks it.
8 *
9 * Layout inside the archive (a single top-level directory named after the
10 * archive stem):
11 *
12 * t3 | t3.exe the single-executable
13 * client/ web app served by the server
14 * resource-monitor/ per-platform Rust helper, same paths as the npm package
15 * node_modules/ runtime externals (node-pty, msgpackr-extract, fff)
16 */
17import * as NodeRuntime from "@effect/platform-node/NodeRuntime";
18import * as NodeServices from "@effect/platform-node/NodeServices";
19import * as Config from "effect/Config";
20import * as Effect from "effect/Effect";
21import * as FileSystem from "effect/FileSystem";
22import * as Layer from "effect/Layer";
23import * as Logger from "effect/Logger";
24import * as Option from "effect/Option";
25import * as Path from "effect/Path";
26import * as Schema from "effect/Schema";
27import { Command, Flag } from "effect/unstable/cli";
28import { ChildProcess, ChildProcessSpawner } from "effect/unstable/process";
29
30import { HostProcessArchitecture, HostProcessPlatform } from "@t3tools/shared/hostProcess";
31import { fromYaml } from "@t3tools/shared/schemaYaml";
32import { resolveSpawnCommand } from "@t3tools/shared/shell";
33import rootPackageJson from "../package.json" with { type: "json" };
34import serverPackageJson from "../apps/server/package.json" with { type: "json" };
35
36import {
37 createStagePatchedDependencies,
38 createStageWorkspaceConfig,
39 resolveFffNativeDependencies,
40 STAGE_INSTALL_ARGS,
41} from "./build-desktop-artifact.ts";
42import { selectCliRuntimeExternalDependencies } from "./lib/cli-external-packages.ts";
43import { resolveCatalogDependencies } from "./lib/resolve-catalog.ts";
44
45const BuildPlatform = Schema.Literals(["mac", "linux", "win"]);
46const BuildArch = Schema.Literals(["arm64", "x64"]);
47type BuildPlatform = typeof BuildPlatform.Type;
48type BuildArch = typeof BuildArch.Type;
49
50const WorkspaceConfig = Schema.Struct({
51 catalog: Schema.optional(Schema.Record(Schema.String, Schema.String)),
52 overrides: Schema.optional(Schema.Record(Schema.String, Schema.String)),
53 patchedDependencies: Schema.optional(Schema.Record(Schema.String, Schema.String)),
54 allowBuilds: Schema.optional(Schema.Record(Schema.String, Schema.Boolean)),
55});
56const decodeWorkspaceConfig = Schema.decodeEffect(fromYaml(WorkspaceConfig));
57const encodeJsonString = Schema.encodeEffect(Schema.fromJsonString(Schema.Unknown));
58const StageWorkspaceConfig = Schema.Struct({
59 supportedArchitectures: Schema.Struct({
60 os: Schema.Array(Schema.String),
61 cpu: Schema.Array(Schema.String),
62 libc: Schema.optional(Schema.Array(Schema.String)),
63 }),
64 allowBuilds: Schema.optional(Schema.Record(Schema.String, Schema.Boolean)),
65 patchedDependencies: Schema.optional(Schema.Record(Schema.String, Schema.String)),
66 overrides: Schema.optional(Schema.Record(Schema.String, Schema.String)),
67 nodeLinker: Schema.optional(Schema.Literals(["hoisted"])),
68});
69const encodeStageWorkspaceConfig = Schema.encodeEffect(fromYaml(StageWorkspaceConfig));
70
71const RepoRoot = Effect.service(Path.Path).pipe(
72 Effect.flatMap((path) => path.fromFileUrl(new URL("..", import.meta.url))),
73);
74
75export class CliArchiveCommandFailedError extends Schema.TaggedError<CliArchiveCommandFailedError>()(
76 "CliArchiveCommandFailedError",
77 { command: Schema.String, exitCode: Schema.Int },
78) {
79 override get message(): string {
80 return `${this.command} exited with code ${this.exitCode}.`;
81 }
82}
83
84export class CliArchiveInputMissingError extends Schema.TaggedError<CliArchiveInputMissingError>()(
85 "CliArchiveInputMissingError",
86 { inputPath: Schema.String, hint: Schema.String },
87) {
88 override get message(): string {
89 return `Missing ${this.inputPath}. ${this.hint}`;
90 }
91}
92
93/** Platform/arch pair as it appears in archive names and `process.platform`/`process.arch`. */
94export function cliArchivePlatformKey(platform: BuildPlatform, arch: BuildArch): string {
95 const nodePlatform = platform === "mac" ? "darwin" : platform === "win" ? "win32" : "linux";
96 return `${nodePlatform}-${arch}`;
97}
98
99export function cliArchiveStem(version: string, platform: BuildPlatform, arch: BuildArch): string {
100 return `t3-${version}-${cliArchivePlatformKey(platform, arch)}`;
101}
102
103export function cliArchiveFileName(version: string, platform: BuildPlatform, arch: BuildArch) {
104 // gzip rather than xz: GNU tar needs an external xz binary for -J, which
105 // minimal hosts lack, while every tar (and Node's zlib) handles gzip alone.
106 return `${cliArchiveStem(version, platform, arch)}.${platform === "win" ? "zip" : "tar.gz"}`;
107}
108
109/** The bsdtar Windows ships in System32; resolves regardless of which tar is first on PATH. */
110export function windowsSystemTar(): string {
111 const systemRoot = process.env.SystemRoot ?? process.env.windir ?? "C:\\Windows";
112 return `${systemRoot}\\System32\\tar.exe`;
113}
114
115const runCommand = Effect.fn("runCommand")(function* (
116 command: ChildProcess.Command,
117 label: string,
118) {
119 const spawner = yield* ChildProcessSpawner.ChildProcessSpawner;
120 // Output is inherited so the build log shows what each tool did; a failing
121 // signing or packaging step is otherwise a bare exit code.
122 const child = yield* spawner.spawn(
123 ChildProcess.isStandardCommand(command)
124 ? ChildProcess.make(command.command, command.args, {
125 ...command.options,
126 stdout: "inherit",
127 stderr: "inherit",
128 })
129 : command,
130 );
131 const exitCode = Number(yield* child.exitCode);
132 if (exitCode !== 0) {
133 return yield* new CliArchiveCommandFailedError({ command: label, exitCode });
134 }
135});
136
137const requireInput = Effect.fn("requireInput")(function* (inputPath: string, hint: string) {
138 const fs = yield* FileSystem.FileSystem;
139 if (!(yield* fs.exists(inputPath))) {
140 return yield* new CliArchiveInputMissingError({ inputPath, hint });
141 }
142});
143
144/**
145 * Installs the runtime-external packages into `stageDir/node_modules` with a
146 * hoisted, symlink-free layout. The tree is archived and unpacked on machines
147 * without pnpm, so the store layout cannot be relied on to survive the trip.
148 */
149const stageRuntimeExternals = Effect.fn("stageRuntimeExternals")(function* (input: {
150 readonly repoRoot: string;
151 readonly stageDir: string;
152 readonly platform: BuildPlatform;
153 readonly arch: BuildArch;
154 readonly version: string;
155}) {
156 const fs = yield* FileSystem.FileSystem;
157 const path = yield* Path.Path;
158 const workspace = yield* decodeWorkspaceConfig(
159 yield* fs.readFileString(path.join(input.repoRoot, "pnpm-workspace.yaml")),
160 );
161 const catalog = workspace.catalog ?? {};
162 const serverDependencies = resolveCatalogDependencies(
163 serverPackageJson.dependencies,
164 catalog,
165 "apps/server",
166 );
167 const fffNodeVersion = serverDependencies["@ff-labs/fff-node"];
168 if (fffNodeVersion === undefined) {
169 return yield* new CliArchiveInputMissingError({
170 inputPath: "apps/server/package.json#dependencies['@ff-labs/fff-node']",
171 hint: "The archive stages fff's platform binary from this version.",
172 });
173 }
174 const dependencies = {
175 ...selectCliRuntimeExternalDependencies(serverDependencies),
176 ...resolveFffNativeDependencies(input.platform, input.arch, fffNodeVersion),
177 };
178 const patchedDependencies = createStagePatchedDependencies(
179 workspace.patchedDependencies ?? {},
180 dependencies,
181 );
182
183 yield* fs.writeFileString(
184 path.join(input.stageDir, "package.json"),
185 `${yield* encodeJsonString({
186 name: "t3-runtime",
187 version: input.version,
188 private: true,
189 packageManager: rootPackageJson.packageManager,
190 dependencies,
191 })}\n`,
192 );
193 yield* fs.writeFileString(
194 path.join(input.stageDir, "pnpm-workspace.yaml"),
195 yield* encodeStageWorkspaceConfig({
196 ...createStageWorkspaceConfig({
197 platform: input.platform,
198 arch: input.arch,
199 ...(workspace.allowBuilds ? { allowBuilds: workspace.allowBuilds } : {}),
200 patchedDependencies,
201 overrides: resolveCatalogDependencies(workspace.overrides ?? {}, catalog, "apps/server"),
202 }),
203 nodeLinker: "hoisted",
204 }),
205 );
206 if (Object.keys(patchedDependencies).length > 0) {
207 yield* fs.copy(path.join(input.repoRoot, "patches"), path.join(input.stageDir, "patches"));
208 }
209
210 const install = yield* resolveSpawnCommand("vp", [...STAGE_INSTALL_ARGS]);
211 yield* runCommand(
212 ChildProcess.make(install.command, install.args, {
213 cwd: input.stageDir,
214 shell: install.shell,
215 stdout: "inherit",
216 stderr: "inherit",
217 }),
218 "vp install --prod (cli archive runtime externals)",
219 );
220
221 // pnpm's bookkeeping and the manifest only matter to pnpm; the runtime
222 // resolves packages by directory. node-pty ships every platform's prebuilds
223 // in one package (58 MB); only the archive's own platform loads.
224 const platformKey = cliArchivePlatformKey(input.platform, input.arch);
225 const prebuildsDir = path.join(input.stageDir, "node_modules/node-pty/prebuilds");
226 const foreignPrebuilds = (yield* fs
227 .readDirectory(prebuildsDir)
228 .pipe(Effect.orElseSucceed((): ReadonlyArray<string> => []))).filter(
229 (entry) => entry !== platformKey,
230 );
231 for (const entry of [
232 "package.json",
233 "pnpm-workspace.yaml",
234 "pnpm-lock.yaml",
235 "patches",
236 "node_modules/.pnpm",
237 "node_modules/.modules.yaml",
238 "node_modules/.pnpm-workspace-state-v1.json",
239 "node_modules/.bin",
240 ...foreignPrebuilds.map((entry) => `node_modules/node-pty/prebuilds/${entry}`),
241 ]) {
242 yield* fs.remove(path.join(input.stageDir, entry), { recursive: true, force: true });
243 }
244});
245
246/** Copies the web client without its sourcemaps, which nothing serves. */
247const stageWebClient = Effect.fn("stageWebClient")(function* (source: string, target: string) {
248 const fs = yield* FileSystem.FileSystem;
249 const path = yield* Path.Path;
250 yield* fs.copy(source, target);
251 const maps = (yield* fs.readDirectory(target, { recursive: true })).filter((entry) =>
252 entry.endsWith(".map"),
253 );
254 for (const entry of maps) {
255 yield* fs.remove(path.join(target, entry), { force: true });
256 }
257});
258
259const MacSigningConfig = Config.all({
260 identity: Config.string("T3CODE_CLI_MAC_SIGN_IDENTITY").pipe(Config.option),
261 appleApiKey: Config.string("APPLE_API_KEY").pipe(Config.option),
262 appleApiKeyId: Config.string("APPLE_API_KEY_ID").pipe(Config.option),
263 appleApiIssuer: Config.string("APPLE_API_ISSUER").pipe(Config.option),
264});
265
266/**
267 * Apple Silicon refuses to run unsigned Mach-O binaries at all, so the
268 * executable is always signed: ad hoc when no identity is configured, or with
269 * the Developer ID plus notarization when it is. The hardened runtime that
270 * notarization requires only loads signed libraries, so every native addon in
271 * the archive is signed with the same identity.
272 */
273const signMacArchiveContents = Effect.fn("signMacArchiveContents")(function* (input: {
274 readonly repoRoot: string;
275 readonly contentDir: string;
276 readonly executablePath: string;
277}) {
278 const fs = yield* FileSystem.FileSystem;
279 const path = yield* Path.Path;
280 const signing = yield* MacSigningConfig;
281 const identity = Option.getOrUndefined(signing.identity)?.trim() || "-";
282
283 const entitlements = path.join(input.repoRoot, "apps/server/resources/cli-entitlements.plist");
284 const libraries = (yield* fs.readDirectory(input.contentDir, { recursive: true }))
285 .filter(
286 (entry) =>
287 entry.endsWith(".node") ||
288 entry.endsWith(".dylib") ||
289 entry.endsWith("spawn-helper") ||
290 entry.endsWith("t3-resource-monitor"),
291 )
292 .map((entry) => path.join(input.contentDir, entry));
293
294 for (const target of [...libraries, input.executablePath]) {
295 yield* runCommand(
296 ChildProcess.make("codesign", [
297 "--force",
298 "--sign",
299 identity,
300 ...(identity === "-" ? [] : ["--options", "runtime", "--timestamp"]),
301 ...(target === input.executablePath ? ["--entitlements", entitlements] : []),
302 target,
303 ]),
304 `codesign ${path.relative(input.contentDir, target)}`,
305 );
306 }
307 if (identity === "-") {
308 yield* Effect.log("[cli-archive] Signed ad hoc (no T3CODE_CLI_MAC_SIGN_IDENTITY).");
309 return;
310 }
311
312 const apiKey = Option.getOrUndefined(signing.appleApiKey);
313 const apiKeyId = Option.getOrUndefined(signing.appleApiKeyId);
314 const apiIssuer = Option.getOrUndefined(signing.appleApiIssuer);
315 if (!apiKey || !apiKeyId || !apiIssuer) {
316 yield* Effect.logWarning(
317 "[cli-archive] Developer ID signed but not notarized (missing APPLE_API_KEY*).",
318 );
319 return;
320 }
321 // notarytool only accepts archives, and a bare executable cannot be stapled,
322 // so notarize a zip of the binary and rely on the online ticket lookup.
323 const notarizeZip = path.join(path.dirname(input.executablePath), ".notarize-t3.zip");
324 yield* runCommand(
325 ChildProcess.make("ditto", ["-c", "-k", "--keepParent", input.executablePath, notarizeZip]),
326 "ditto (notarization zip)",
327 );
328 yield* runCommand(
329 ChildProcess.make("xcrun", [
330 "notarytool",
331 "submit",
332 notarizeZip,
333 "--key",
334 apiKey,
335 "--key-id",
336 apiKeyId,
337 "--issuer",
338 apiIssuer,
339 "--wait",
340 ]),
341 "notarytool submit",
342 ).pipe(Effect.ensuring(fs.remove(notarizeZip, { force: true }).pipe(Effect.ignore)));
343 yield* Effect.log("[cli-archive] Notarized t3.");
344});
345
346const WindowsSigningConfig = Config.all({
347 endpoint: Config.string("AZURE_TRUSTED_SIGNING_ENDPOINT").pipe(Config.option),
348 accountName: Config.string("AZURE_TRUSTED_SIGNING_ACCOUNT_NAME").pipe(Config.option),
349 certificateProfileName: Config.string("AZURE_TRUSTED_SIGNING_CERTIFICATE_PROFILE_NAME").pipe(
350 Config.option,
351 ),
352});
353
354/**
355 * Node's --build-sea injects the blob into a copy of node.exe by rebuilding
356 * its resource section but, unlike its Mach-O path, leaves node's original
357 * Authenticode data-directory entry in the PE header. The file grows, so the
358 * entry now points into the middle of the new section at bytes that are not a
359 * certificate table. signtool refuses to sign such an image (0x800700C1, "not
360 * a valid Win32 application") and cannot `remove /s` it either, since the SIP
361 * fails to parse the garbage. Clearing the entry is exactly what a signature
362 * strip does, without needing a parser that trusts the broken table.
363 */
364const stripStaleAuthenticodeEntry = Effect.fn("stripStaleAuthenticodeEntry")(function* (
365 executablePath: string,
366) {
367 const fs = yield* FileSystem.FileSystem;
368 const bytes = yield* fs.readFile(executablePath);
369 const view = new DataView(bytes.buffer, bytes.byteOffset, bytes.byteLength);
370 const peOffset = view.getUint32(0x3c, true);
371 if (view.getUint32(peOffset, true) !== 0x00004550) {
372 return yield* new CliArchiveInputMissingError({
373 inputPath: executablePath,
374 hint: "Expected a PE executable to strip the stale signature entry from.",
375 });
376 }
377 const optionalHeader = peOffset + 24;
378 const magic = view.getUint16(optionalHeader, true);
379 // Data directories start at +112 (PE32+) or +96 (PE32); the certificate
380 // table is directory index 4, eight bytes (file offset, size).
381 const securityEntry = optionalHeader + (magic === 0x20b ? 112 : 96) + 4 * 8;
382 const offset = view.getUint32(securityEntry, true);
383 const size = view.getUint32(securityEntry + 4, true);
384 if (offset === 0 && size === 0) return;
385 if (offset + size === bytes.byteLength) {
386 // A certificate table that still ends at EOF is intact; leave it for
387 // signtool to replace rather than second-guessing it here.
388 return;
389 }
390 view.setUint32(securityEntry, 0, true);
391 view.setUint32(securityEntry + 4, 0, true);
392 yield* fs.writeFile(executablePath, bytes);
393 yield* Effect.log(
394 `[cli-archive] Cleared the stale Authenticode entry (offset ${String(offset)}, size ${String(size)}) left by --build-sea.`,
395 );
396});
397
398/** Signs t3.exe through the same Azure Trusted Signing setup the installer uses. */
399const signWindowsExecutable = Effect.fn("signWindowsExecutable")(function* (
400 executablePath: string,
401) {
402 const signing = yield* WindowsSigningConfig;
403 const endpoint = Option.getOrUndefined(signing.endpoint);
404 const accountName = Option.getOrUndefined(signing.accountName);
405 const profile = Option.getOrUndefined(signing.certificateProfileName);
406 if (!endpoint || !accountName || !profile) {
407 yield* Effect.log("[cli-archive] Windows signing disabled (missing Azure Trusted Signing).");
408 return;
409 }
410 yield* stripStaleAuthenticodeEntry(executablePath);
411 // Mirrors electron-builder's invocation for the installer: every value
412 // single-quoted, the file path in Windows form. `$ErrorActionPreference`
413 // makes a signing failure inside the cmdlet surface as a non-zero exit.
414 const quote = (value: string) => `'${value.replaceAll("'", "''")}'`;
415 const script = [
416 "$ErrorActionPreference = 'Stop';",
417 "Invoke-TrustedSigning",
418 `-Endpoint ${quote(endpoint)}`,
419 `-CodeSigningAccountName ${quote(accountName)}`,
420 `-CertificateProfileName ${quote(profile)}`,
421 "-FileDigest 'SHA256'",
422 "-TimestampRfc3161 'http://timestamp.acs.microsoft.com'",
423 "-TimestampDigest 'SHA256'",
424 `-Files ${quote(executablePath)}`,
425 ].join(" ");
426 yield* runCommand(
427 ChildProcess.make("pwsh", ["-NoProfile", "-NonInteractive", "-Command", script]),
428 "Invoke-TrustedSigning t3.exe",
429 );
430 yield* Effect.log("[cli-archive] Signed t3.exe (Azure Trusted Signing).");
431});
432
433const buildCliArchive = Effect.fn("buildCliArchive")(function* (input: {
434 readonly platform: BuildPlatform;
435 readonly arch: BuildArch;
436 readonly version: string;
437 readonly outputDir: string;
438 readonly resourceMonitorDir: Option.Option<string>;
439}) {
440 const fs = yield* FileSystem.FileSystem;
441 const path = yield* Path.Path;
442 const repoRoot = yield* RepoRoot;
443 const serverDir = path.join(repoRoot, "apps/server");
444 const executableName = input.platform === "win" ? "t3.exe" : "t3";
445 // tsdown suffixes cross-built executables with their target (t3-darwin-x64);
446 // a host build is plain t3. Prefer the exact target when both exist.
447 const targetKey = `${input.platform === "mac" ? "darwin" : input.platform}-${input.arch}`;
448 const targetExecutable = path.join(
449 serverDir,
450 "dist-exe",
451 `t3-${targetKey}${input.platform === "win" ? ".exe" : ""}`,
452 );
453 // The unsuffixed host build is only a valid stand-in when it was built for
454 // this platform and architecture; otherwise a missing target must fail.
455 const hostPlatform = yield* HostProcessPlatform;
456 const hostKey = `${hostPlatform === "win32" ? "win" : hostPlatform}-${yield* HostProcessArchitecture}`;
457 const builtExecutable = (yield* fs.exists(targetExecutable))
458 ? targetExecutable
459 : targetKey === hostKey
460 ? path.join(serverDir, "dist-exe", executableName)
461 : targetExecutable;
462 const webClient = path.join(serverDir, "dist/client");
463 const resourceMonitorDir = Option.getOrElse(input.resourceMonitorDir, () =>
464 path.join(serverDir, "dist/resource-monitor"),
465 );
466
467 yield* requireInput(
468 builtExecutable,
469 `Run \`node apps/server/scripts/cli.ts build-exe --target ${targetKey}\` first.`,
470 );
471 yield* requireInput(path.join(webClient, "index.html"), "Run `vp run --filter t3 build` first.");
472 yield* requireInput(
473 resourceMonitorDir,
474 "Build the resource monitor or pass --resource-monitor-dir.",
475 );
476
477 const stem = cliArchiveStem(input.version, input.platform, input.arch);
478 const stageRoot = yield* fs.makeTempDirectoryScoped({ prefix: "t3-cli-archive-" });
479 const contentDir = path.join(stageRoot, stem);
480 yield* fs.makeDirectory(contentDir, { recursive: true });
481
482 yield* Effect.log(`[cli-archive] Staging ${stem}...`);
483 yield* fs.copyFile(builtExecutable, path.join(contentDir, executableName));
484 yield* stageWebClient(webClient, path.join(contentDir, "client"));
485 yield* fs.copy(resourceMonitorDir, path.join(contentDir, "resource-monitor"));
486 yield* stageRuntimeExternals({
487 repoRoot,
488 stageDir: contentDir,
489 platform: input.platform,
490 arch: input.arch,
491 version: input.version,
492 });
493
494 const executablePath = path.join(contentDir, executableName);
495 if (input.platform === "mac") {
496 yield* signMacArchiveContents({ repoRoot, contentDir, executablePath });
497 } else if (input.platform === "win") {
498 yield* signWindowsExecutable(executablePath);
499 }
500 if (input.platform !== "win") {
501 yield* fs.chmod(executablePath, 0o755);
502 }
503
504 yield* fs.makeDirectory(input.outputDir, { recursive: true });
505 const archivePath = path.join(
506 input.outputDir,
507 cliArchiveFileName(input.version, input.platform, input.arch),
508 );
509 yield* fs.remove(archivePath, { force: true });
510 if (input.platform === "win") {
511 // Windows ships bsdtar, which writes zip natively. Name it by path: under
512 // the Git Bash shell CI uses, a bare `tar` is GNU tar, which neither
513 // writes zip nor accepts a drive-letter path.
514 yield* runCommand(
515 ChildProcess.make(windowsSystemTar(), ["-a", "-c", "-f", archivePath, "-C", stageRoot, stem]),
516 "tar (zip)",
517 );
518 } else {
519 yield* runCommand(
520 ChildProcess.make("tar", ["-czf", archivePath, "-C", stageRoot, stem]),
521 "tar (gzip)",
522 );
523 }
524 const stat = yield* fs.stat(archivePath);
525 yield* Effect.log(`[cli-archive] Wrote ${archivePath} (${String(stat.size)} bytes).`);
526 return archivePath;
527});
528
529const command = Command.make(
530 "build-cli-archive",
531 {
532 platform: Flag.choice("platform", BuildPlatform.literals),
533 arch: Flag.choice("arch", BuildArch.literals),
534 version: Flag.string("version").pipe(
535 Flag.withDescription("Release version for the archive name."),
536 ),
537 outputDir: Flag.string("output-dir").pipe(Flag.withDefault("release-cli")),
538 resourceMonitorDir: Flag.string("resource-monitor-dir").pipe(
539 Flag.withDescription(
540 "Directory laid out like dist/resource-monitor (defaults to apps/server/dist/resource-monitor).",
541 ),
542 Flag.optional,
543 ),
544 },
545 (input) => buildCliArchive(input).pipe(Effect.scoped),
546).pipe(Command.withDescription("Package the t3 single-executable into a per-platform archive."));
547
548if (import.meta.main) {
549 Command.run(command, { version: "0.0.0" }).pipe(
550 Effect.provide(Layer.mergeAll(Logger.layer([Logger.consolePretty()]), NodeServices.layer)),
551 NodeRuntime.runMain,
552 );
553}