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

build-cli-archive.ts

565 lines21.9 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 = Effect.fn("build-cli-archive.removeNestedBinDirectories")(
234 function* (
235 fs: FileSystem.FileSystem,
236 path: Path.Path,
237 root: string,
238 ): Effect.fn.Return<void, PlatformError.PlatformError> {
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);
253​
254const stageWebClient = Effect.fn("stageWebClient")(function* (source: string, target: string) {
255 const fs = yield* FileSystem.FileSystem;
256 const path = yield* Path.Path;
257 yield* fs.copy(source, target);
258 const maps = (yield* fs.readDirectory(target, { recursive: true })).filter((entry) =>
259 entry.endsWith(".map"),
260 );
261 for (const entry of maps) {
262 yield* fs.remove(path.join(target, entry), { force: true });
263 }
264});
265​
266const MacSigningConfig = Config.all({
267 identity: Config.String("T3CODE_CLI_MAC_SIGN_IDENTITY").pipe(Config.option),
268 appleApiKey: Config.String("APPLE_API_KEY").pipe(Config.option),
269 appleApiKeyId: Config.String("APPLE_API_KEY_ID").pipe(Config.option),
270 appleApiIssuer: Config.String("APPLE_API_ISSUER").pipe(Config.option),
271});
272​
273/**
274 * Apple Silicon refuses to run unsigned Mach-O binaries at all, so the
275 * executable is always signed: ad hoc when no identity is configured, or with
276 * the Developer ID plus notarization when it is. The hardened runtime that
277 * notarization requires only loads signed libraries, so every native addon in
278 * the archive is signed with the same identity.
279 */
280const signMacArchiveContents = Effect.fn("signMacArchiveContents")(function* (input: {
281 readonly repoRoot: string;
282 readonly contentDir: string;
283 readonly executablePath: string;
284}) {
285 const fs = yield* FileSystem.FileSystem;
286 const path = yield* Path.Path;
287 const signing = yield* MacSigningConfig;
288 const identity = Option.getOrUndefined(signing.identity)?.trim() || "-";
289​
290 const entitlements = path.join(input.repoRoot, "apps/server/resources/cli-entitlements.plist");
291 const libraries = (yield* fs.readDirectory(input.contentDir, { recursive: true }))
292 .filter(
293 (entry) =>
294 entry.endsWith(".node") ||
295 entry.endsWith(".dylib") ||
296 entry.endsWith("spawn-helper") ||
297 entry.endsWith("t3-resource-monitor"),
298 )
299 .map((entry) => path.join(input.contentDir, entry));
300​
301 for (const target of [...libraries, input.executablePath]) {
302 yield* runCommand(
303 ChildProcess.make("codesign", [
304 "--force",
305 "--sign",
306 identity,
307 ...(identity === "-" ? [] : ["--options", "runtime", "--timestamp"]),
308 ...(target === input.executablePath ? ["--entitlements", entitlements] : []),
309 target,
310 ]),
311 `codesign ${path.relative(input.contentDir, target)}`,
312 );
313 }
314 if (identity === "-") {
315 yield* Effect.log("[cli-archive] Signed ad hoc (no T3CODE_CLI_MAC_SIGN_IDENTITY).");
316 return;
317 }
318​
319 const apiKey = Option.getOrUndefined(signing.appleApiKey);
320 const apiKeyId = Option.getOrUndefined(signing.appleApiKeyId);
321 const apiIssuer = Option.getOrUndefined(signing.appleApiIssuer);
322 if (!apiKey || !apiKeyId || !apiIssuer) {
323 yield* Effect.logWarning(
324 "[cli-archive] Developer ID signed but not notarized (missing APPLE_API_KEY*).",
325 );
326 return;
327 }
328 // notarytool only accepts archives, and a bare executable cannot be stapled,
329 // so notarize a zip of the binary and rely on the online ticket lookup.
330 const notarizeZip = path.join(path.dirname(input.executablePath), ".notarize-t3.zip");
331 yield* runCommand(
332 ChildProcess.make("ditto", ["-c", "-k", "--keepParent", input.executablePath, notarizeZip]),
333 "ditto (notarization zip)",
334 );
335 yield* runCommand(
336 ChildProcess.make("xcrun", [
337 "notarytool",
338 "submit",
339 notarizeZip,
340 "--key",
341 apiKey,
342 "--key-id",
343 apiKeyId,
344 "--issuer",
345 apiIssuer,
346 "--wait",
347 ]),
348 "notarytool submit",
349 ).pipe(Effect.ensuring(fs.remove(notarizeZip, { force: true }).pipe(Effect.ignore)));
350 yield* Effect.log("[cli-archive] Notarized t3.");
351});
352​
353const WindowsSigningConfig = Config.all({
354 endpoint: Config.String("AZURE_TRUSTED_SIGNING_ENDPOINT").pipe(Config.option),
355 accountName: Config.String("AZURE_TRUSTED_SIGNING_ACCOUNT_NAME").pipe(Config.option),
356 certificateProfileName: Config.String("AZURE_TRUSTED_SIGNING_CERTIFICATE_PROFILE_NAME").pipe(
357 Config.option,
358 ),
359});
360​
361/**
362 * Node's --build-sea injects the blob into a copy of node.exe by rebuilding its
363 * resource section but, unlike its Mach-O path, leaves node's original
364 * Authenticode data-directory entry in the PE header. The file grows, so the
365 * entry now points into the middle of the new section at bytes that are not a
366 * certificate table.
367 */
368const stripStaleAuthenticodeEntry = Effect.fn("stripStaleAuthenticodeEntry")(function* (
369 executablePath: string,
370) {
371 const fs = yield* FileSystem.FileSystem;
372 const bytes = yield* fs.readFile(executablePath);
373 const view = new DataView(bytes.buffer, bytes.byteOffset, bytes.byteLength);
374 const peOffset = view.getUint32(0x3c, true);
375 if (view.getUint32(peOffset, true) !== 0x00004550) {
376 return yield* new CliArchiveInputMissingError({
377 inputPath: executablePath,
378 hint: "Expected a PE executable to strip the stale signature entry from.",
379 });
380 }
381 const optionalHeader = peOffset + 24;
382 const magic = view.getUint16(optionalHeader, true);
383 // Data directories start at +112 (PE32+) or +96 (PE32); the certificate
384 // table is directory index 4, eight bytes (file offset, size).
385 const securityEntry = optionalHeader + (magic === 0x20b ? 112 : 96) + 4 * 8;
386 const offset = view.getUint32(securityEntry, true);
387 const size = view.getUint32(securityEntry + 4, true);
388 if (offset === 0 && size === 0) return;
389 if (offset + size === bytes.byteLength) {
390 // A certificate table that still ends at EOF is intact; leave it for
391 // signtool to replace rather than second-guessing it here.
392 return;
393 }
394 view.setUint32(securityEntry, 0, true);
395 view.setUint32(securityEntry + 4, 0, true);
396 yield* fs.writeFile(executablePath, bytes);
397 yield* Effect.log(
398 `[cli-archive] Cleared the stale Authenticode entry (offset ${String(offset)}, size ${String(size)}) left by --build-sea.`,
399 );
400});
401​
402const signWindowsExecutable = Effect.fn("signWindowsExecutable")(function* (
403 executablePath: string,
404) {
405 const signing = yield* WindowsSigningConfig;
406 const endpoint = Option.getOrUndefined(signing.endpoint);
407 const accountName = Option.getOrUndefined(signing.accountName);
408 const profile = Option.getOrUndefined(signing.certificateProfileName);
409 if (!endpoint || !accountName || !profile) {
410 yield* Effect.log("[cli-archive] Windows signing disabled (missing Azure Trusted Signing).");
411 return;
412 }
413 yield* stripStaleAuthenticodeEntry(executablePath);
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* HostProcess.Platform;
456 const hostKey = `${hostPlatform === "win32" ? "win" : hostPlatform}-${yield* HostProcess.Architecture}`;
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 // On Linux, pnpm hard-links identical files out of its store and node-gyp
520 // hard-links build outputs, and GNU tar records those as link entries.
521 // The npm registry rejects a tarball containing any, and the npm platform
522 // packages are re-packed from this archive's contents, so store every
523 // file as a file. macOS's bsdtar has no such flag; pnpm clones there.
524 yield* runCommand(
525 ChildProcess.make("tar", [
526 ...(input.platform === "linux" ? ["--hard-dereference"] : []),
527 "-czf",
528 archivePath,
529 "-C",
530 stageRoot,
531 stem,
532 ]),
533 "tar (gzip)",
534 );
535 }
536 const stat = yield* fs.stat(archivePath);
537 yield* Effect.log(`[cli-archive] Wrote ${archivePath} (${String(stat.size)} bytes).`);
538 return archivePath;
539});
540​
541const command = Command.make(
542 "build-cli-archive",
543 {
544 platform: Flag.Literals("platform", BuildPlatform.literals),
545 arch: Flag.Literals("arch", BuildArch.literals),
546 version: Flag.String("version").pipe(
547 Flag.withDescription("Release version for the archive name."),
548 ),
549 outputDir: Flag.String("output-dir").pipe(Flag.withDefault("release-cli")),
550 resourceMonitorDir: Flag.String("resource-monitor-dir").pipe(
551 Flag.withDescription(
552 "Directory laid out like dist/resource-monitor (defaults to apps/server/dist/resource-monitor).",
553 ),
554 Flag.optional,
555 ),
556 },
557 (input) => buildCliArchive(input).pipe(Effect.scoped),
558).pipe(Command.withDescription("Package the t3 single-executable into a per-platform archive."));
559​
560if (import.meta.main) {
561 Command.run(command, { version: "0.0.0" }).pipe(
562 Effect.provide(Layer.mergeAll(Logger.layer([Logger.consolePretty()]), NodeServices.layer)),
563 NodeRuntime.runMain,
564 );