@wtf/release
v2.3.0
Published
A release of a repo by any driver, over ecosystems that implement one contract, of no release tool and no train, on the platform its caller gives it (@wtf/platform) and the folder of the repo, a handle of the File System standard: the types of what a rele
Maintainers
Readme
@wtf/release
A release of a repo, run by any driver, over ecosystems that implement one contract. A driver is whatever runs the release: a plugin of a release tool, a CLI of your own, a test. An ecosystem is what knows one kind of package, as npm's or Cargo's: its manifests, its registry and its rules of versions. This package is the contract between them, the driver of its steps, and what every package of a release runs by, with no release tool and no train.
A caller gives it the platform it runs on, a Pick of
@wtf/platform, and the folder of the
repo, a handle of the File System standard, of
@wtf/platform-fs-node on disk,
of @wtf/platform-fs-memory in
memory, or a browser's. It names no Node, so it runs wherever its caller has a platform: a plugin of a release
tool, a CLI, a test in memory.
It holds git of a repo, its files and its programs, paths and globs, validators of options, what
an ecosystem is and the order to publish its packages in, the folders a build generates, forges and
the links of a release, and ReleaseError, the base of the errors of every package over it. The
libraries of the trains and of each ecosystem build on it.
A release by any driver
The contract is ./contract. A driver gives each ecosystem the
same plain values, a Release: the version, the folder of the repo, the platform, whether it is a
dry run, and where to log and to warn. It works out what the release is of, a Plan for each ecosystem: the
packages that publish, in order, and the version of each package of the repo. Then it runs the steps
it is asked, each over every ecosystem in the order it gives, by runStep of ./driver:
| Step | What an ecosystem does | Required |
| --------- | ----------------------------------------------------------------------- | -------- |
| verify | checks its options, the version and the credentials, and writes nothing | no |
| prepare | writes the versions into its manifests, and gives the files it wrote | no |
| smoke | tries what it will publish, before it is published | no |
| publish | publishes the packages, each the registry has already skipped | yes |
| move | points the moving names, as npm's dist-tags, and gives what it moved | no |
An ecosystem of no package in its plan, or of no such step, is skipped, and the log says so. verify
runs every ecosystem and throws what each found together; any other step stops at the first that
fails, and a run again finishes it. The driver knows no train and no release tool: which steps a run
has, and in which run, is its caller's. It runs verify once the version is known, so an ecosystem
checks the version itself, never a placeholder.
An ecosystem's type is ReleasingEcosystem of its options, its packages and the optional steps it
has, as ReleasingEcosystem<CargoOptions, CargoPackage, 'verify' | 'prepare'>: a caller calls each
of those steps as it is, and the driver skips one it has not. The order to publish the packages of
one ecosystem in, publishOrder of ./order, puts each after what it depends on, and two that
depend on neither in the order of their names.
publish says what it published, a Released of each package. The forge of the run, a Forge of
./forge (GitLab's, GitHub's), knows where a package on its own registries lives, and keeps a file
of one of no page; linksOf gives the link of each package of a release, of its own page, the
forge's page of it, or its file kept.
Whether a version is on its registry
./verify is the check that a registry holds a version, of no change to it, one contract for every
ecosystem: each gives a VerifyVersion, which takes the name and the version, the platform and its
own options, and gives a Verified, the registry it asked and found, missing, or error of a
reason. It never throws, and a registry that refuses to be read is an error, never missing. It
is no step of a release: verify of the contract checks a release before it writes anything, and
this asks a registry after a publish, or at any time. waitForVersion asks again, each wait longer
than the one before, as of a registry that shows a new version late.
import { verifiedText, type VerifyPlatform, type VerifyVersion } from '@wtf/release/verify'
// A registry of no version at all.
const verify: VerifyVersion = async ({ name, version }) => ({
status: 'missing',
name,
version,
registry: 'nowhere',
reason: 'it holds nothing'
})
export const said = async (platform: VerifyPlatform): Promise<string> =>
verifiedText(await verify({ name: 'acme', version: '1.0.0' }, { platform }))As a library
Each function takes only what it uses:
- reading the files of the repo takes its folder,
root, alone; - running git and the other programs of the repo takes a
RepoPlatform:spawn,env, anddirs.cwd, the path of the folderrootis the handle of; - a release that fetches and stages files outside the repo takes a
ReleasePlatform, which aProcessPlatformof@wtf/platformis.
import type { RepoContext } from '@wtf/release'
import { ReleaseError, throwAll } from '@wtf/release/errors'
import { readFile } from '@wtf/release/files'
import { trackedFiles } from '@wtf/release/git'
import { pathMatcher } from '@wtf/release/paths'
import { errorsOf, objectOf, stringOf } from '@wtf/release/validator'
/** The errors of a package of its own: a class that extends `ReleaseError`. */
export class DeployError extends ReleaseError {}
const options = objectOf<{ target: string }>({ target: { of: stringOf({ minLength: 1 }) } })
/** The text of each file of the repo of `target`, of its options checked first. */
export async function deployed(value: unknown, { root, platform }: RepoContext) {
throwAll(errorsOf(options, value, DeployError))
const ofTarget = pathMatcher([(value as { target: string }).target])
const files = (await trackedFiles({ platform })).filter(ofTarget)
return Promise.all(files.map((file) => readFile(root, file)))
}| Export | What it is |
| ------------------------ | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| @wtf/release | The types of what a release runs by: RepoPlatform, ReleasePlatform and RepoContext |
| @wtf/release/files | The files of a folder, by their paths from it: read, written, listed, made, removed and copied |
| @wtf/release/process | run, a program run to its end in the folder of the repo, and envOf, the environment of a program |
| @wtf/release/posix | Paths as POSIX writes them |
| @wtf/release/paths | pathMatcher, whether a file is of a set of paths and globs; normalizePath, a path as they are compared |
| @wtf/release/git | git, the revision, the tags, the tracked files, the files of each commit, the commits since a ref, and the URL of a remote, its host and its path |
| @wtf/release/ecosystem | Ecosystem, Package, Dependency: what an ecosystem gives a release; readPackages, the packages of each; loadEcosystems, the ecosystems a config names, loaded |
| @wtf/release/order | publishOrder: the packages of an ecosystem in the order to publish them in, a base pinned first and a docs package last, and the faults of the order |
| @wtf/release/generated | A folder a build generates, listed by the build in its .generated, and staged for a release commit by its list |
| @wtf/release/contract | Release, Plan, ReleasingEcosystem: what a driver gives an ecosystem, what a release is of, and the steps an ecosystem implements |
| @wtf/release/driver | runStep: a step of every ecosystem of a release, in the order given, over its plan |
| @wtf/release/forge | Forge, where a repo lives, its registries, and the pages of a release and a commit; Released, a package a release published; linksOf, the link of each from the release of the tag; TrustedPublisher, a pipeline a registry trusts to publish, of GitLab or GitHub |
| @wtf/release/verify | VerifyVersion, Verified: whether a registry holds a version, one check of every ecosystem; waitForVersion, asked again until it does; verifyEach, queryOf, durationOf |
| @wtf/release/validator | Validators of options, each a Standard Schema and a Standard JSON Schema, and the errors of their issues, of a class of your own |
| @wtf/release/errors | ReleaseError, of a stable code and details of how to fix it, ErrorClass, throwAll, and RELEASE_ERRORS |
Its errors are plain errors. A release tool that prints errors its own way marks them as they leave
its steps: @wtf/semantic-release does so for semantic-release.
License
MIT
