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

build-cli-archive.ts

564 lines21.8 KB

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