DISTRIBUTION_MODESconstconst DISTRIBUTION_MODES: readonly ["per-library", "single"]The modes of distribution: a closed set.
The distribution mode of the repository (commons 0036-distribution FR-019, FR-020): how the libraries of commons reach a registry. There are two modes and no other. In per-library mode each library that names npm is a package of its own, five metapackages install them as sets, and the release raises and publishes each library. In single mode the whole of commons is one package, @intellectual-frontiers/commons, with one version, one release record and one tag. The source tree is the same in both: the folders, their specifications, their verify, their layers and their version fields do not change with the mode; only what is packed, released and published does.
The mode is one constant, DISTRIBUTION, which every program that packs, plans or generates for distribution reads through activeMode; changing it is one line and the generated files follow (repoctl sync). The environment variable IFC_DISTRIBUTION names the other mode for one run, which is how the machinery of the mode that is not active is proved and how a release of it would be tried; a value that is not a mode is refused, never read as the default. The machinery of the inactive mode is not deleted: it is switched off, so that the owner can switch back.
import { activeMode, parseMode } from "./distribution.ts";
activeMode(undefined); // { kind: "ok", value: "single" }
parseMode("per-library").kind; // "ok"Spec: 0001-libraries FR-028
DISTRIBUTION_MODESconstconst DISTRIBUTION_MODES: readonly ["per-library", "single"]The modes of distribution: a closed set.
DistributionModetypeno test imports ittype DistributionMode = (typeof DISTRIBUTION_MODES)[number];A mode of distribution.
DISTRIBUTIONconstconst DISTRIBUTION: "per-library" | "single"The mode of this repository (0036-distribution FR-019).
MODE_VARIABLEconstno test imports itconst MODE_VARIABLE: "IFC_DISTRIBUTION"The environment variable that names the mode for one run.
parseModefunctionfunction parseMode(text: string): Result<"per-library" | "single", string>A mode from its text, or why the text is not one.
activeModefunctionfunction activeMode(fromEnvironment: string | undefined): Result<"per-library" | "single", string>The mode a run uses: the one the environment names where it names one, the mode of the repository otherwise.
SINGLEconstno test imports itconst SINGLE: { readonly package: "@intellectual-frontiers/commons"; readonly slug: "commons"; readonly folder: "commons/commons"; }The one package of single mode: its name, its release slug (the first word of its tag) and its folder.
SINGLE_EXCLUDEDconstno test imports itconst SINGLE_EXCLUDED: ReadonlyMap<string, string>The libraries that single mode leaves out of the package, each with its reason: the policy of the one package, which is none while the owner orders every library in. A library with a held reason is not left out by that (a held library is packed like any other); it is left out only by an entry here.
PeerRuletypeno test imports ittype PeerRule = { readonly range: string; readonly optional: boolean; readonly why: string; readonly pinnedBy: "dependencies" | "devDependencies" };How a package the single package does not install is asked for: the range a consumer's copy must satisfy, whether the package works without it, and why (0036-distribution FR-023).
SINGLE_PEERSconstconst SINGLE_PEERS: ReadonlyMap<string, PeerRule>The third-party packages that the single package does not install but asks the consumer for, as peerDependencies (0036-distribution FR-023, FR-033): the database drivers that the libraries take as ports (a driver is handed to a library by its caller, typed by the shape it is used by, and no source of commons imports one by name), the two packages only the documentation generator loads, and the TypeScript compiler, whose API the documentation generator reads. Each is optional: a consumer that uses a store of AnyFS or of Data installs its driver, one that builds a site installs what Docs loads, and the compiler of the consumer is the one used, so that a second is never installed. This breaks a consumer that relied on the package to install one of them (a driver, shiki, beautiful-mermaid or a second compiler): it installs the one it uses, and a missing one says which. The range of each is the versions the libraries are written against, and pinnedBy says where a library names the version it is written against (a driver in its devDependencies, what Docs loads in its dependencies).
SINGLE_BUDGETconstno test imports itconst SINGLE_BUDGET: { readonly apparentBytes: 30500000; readonly files: 5300; readonly tarballBytes: 5600000; }The size budget of the single package (0036-distribution FR-032): a growth beyond it is a finding, so that it is a decision and never an accident. Bytes of the staged package, files of it, and bytes of the tarball.
PUBLISH_TARGETSconstno test imports itconst PUBLISH_TARGETS: readonly ["github", "npm"]The registries a release can send a package to: a closed set.
PublishTargettypeno test imports ittype PublishTarget = (typeof PUBLISH_TARGETS)[number];A registry a release sends a package to.
GITHUB_REGISTRYconstno test imports itconst GITHUB_REGISTRY: "https://npm.pkg.github.com"The address of the GitHub package registry of the organization.
SINGLE_TARGETSconstconst SINGLE_TARGETS: readonly ("github" | "npm")[]The registries the one package is sent to (0036-distribution FR-028): the GitHub package registry only. npm is a switch that is off: adding it here makes the release record, the publication and the manifest of the package carry npm as well, and nothing else changes.
optionalPeersAsPeerDependenciesfunctionno test imports itfunction optionalPeersAsPeerDependencies(targets?: readonly ("github" | "npm")[]): booleanWhether an optional peer of SINGLE_PEERS can be a peerDependencies entry marked optional in peerDependenciesMeta (0036-distribution FR-023): it can where no registry the package is sent to drops peerDependenciesMeta. The GitHub package registry drops it from the metadata a package manager resolves from, so a package sent to it names an optional peer in ifcOptionalPeers instead, which no package manager reads.
isSinglefunctionno test imports itfunction isSingle(fromEnvironment: string | undefined): booleanWhether a run is in single mode: the environment's mode, or the repository's. A value that is no mode is not single; the commands that pack and release refuse it.