#!/usr/bin/env node import { NodeRuntime, NodeServices } from "@effect/platform-node"; import * as Effect from "effect/Effect"; import * as Layer from "effect/Layer"; import { layerArchiver } from "@packall/core/node"; import { cli } from "./command.js"; import { layerNpmrc, layerTransport, layerTty } from "./node/index.js"; // Everything platform-shaped, in one place. `Archiver` sits here rather than // with the registry because which tar writer packs the bundle is a property of // where the tool is running, exactly like which filesystem it reads; `Tty` is // the same idea for the terminal it is attached to, and `Transport` for the // socket it opens. // // This list is the entire difference between the CLI and the browser running // the identical command. const platform = Layer.mergeAll(NodeServices.layer, layerArchiver); cli.pipe( Effect.provide( Layer.mergeAll( platform, layerNpmrc, layerTransport, layerTty.pipe(Layer.provide(platform)), ), ), // `runMain` is what wires SIGINT and SIGTERM to fiber interruption, which is // what closes the scope holding the staging directory. Without it, Ctrl-C // halfway through a thousand-package download leaves the whole tree behind. NodeRuntime.runMain, );