IF Commons GitHub

logical/publish

Written to: 1 requirement: 1 proved, 0 partly, 0 failing, 0 with no test recorded. 0004-repoctl-status-release FR-006

repoctl release publish (commons repoctl 0004-repoctl-status-release FR-006 to FR-010): the packed libraries of the release record, sent to npm by hand. It is a destruction (a version put on npm cannot be taken back), so it is refused unless the caller holds the releaser tier and types the confirmation that a preview printed, which names how many packages and a digest of which. The credential is taken through the credentials port, written to a private npmrc in a folder outside the repository that is removed whatever happens, and never printed, logged or put in an argument: every line the verb reports is redacted of it first. Each tarball is passed by its absolute path, because npm reads a relative dist/x.tgz as the shorthand of a GitHub repository. A hand publish is staged by npm for about an hour, and the report says so.

import { confirmationPhrase } from "./publish.ts";
confirmationPhrase([{ slug: "core", package: "@intellectual-frontiers/core", version: "0.1.0", folder: "commons/core", tag: "core-v0.1.0", publish: true }]).startsWith("publish 1 "); // true

Source: commons/repoctl/src/logical/publish.ts

7 of 24 exports are imported by a test of the run. A test that imports an export may not call it or check what it returns.

logical.ReleaseEntrytypeno test imports it
type ReleaseEntry = { readonly slug: string; readonly package: string; readonly version: string; readonly folder: string; readonly tag: string; readonly publish: boolean };

One release of the record: a library, its version, its folder and its tag, and whether it goes to npm.

logical.Itemtypeno test imports it
type Item =
  | { readonly kind: "ready"; readonly entry: ReleaseEntry; readonly tarball: string }
  | { readonly kind: "present"; readonly entry: ReleaseEntry }
  | { readonly kind: "no-tarball"; readonly entry: ReleaseEntry; readonly tarball: string }
  | { readonly kind: "unknown"; readonly entry: ReleaseEntry; readonly why: string };

What is to happen to one release.

logical.PublishPlantypeno test imports it
type PublishPlan = { readonly items: readonly Item[]; readonly phrase: string };

The plan of a publication: what each release comes to, and the phrase that confirms it.

logical.Publishedtypeno test imports it
type Published =
  | { readonly kind: "published"; readonly entry: ReleaseEntry }
  | { readonly kind: "present"; readonly entry: ReleaseEntry }
  | { readonly kind: "failed"; readonly entry: ReleaseEntry; readonly detail: readonly string[] }
  | { readonly kind: "not-run"; readonly entry: ReleaseEntry; readonly why: string };

What happened to one release.

logical.tarballPathfunctionno test imports it
function tarballPath(repo: string, e: ReleaseEntry): string

The absolute path of the tarball the packer makes for a release: dist/<scope>-<package>-<version>.tgz in the library's folder.

logical.confirmationPhrasefunctionno test imports it
function confirmationPhrase(entries: readonly ReleaseEntry[]): string

The phrase that confirms a publication: the word, how many packages go, and the start of a digest of which (publish 3 1a2b3c4d), so that what was reviewed is what is sent.

logical.planPublishfunctionno test imports it
function planPublish(w: Pick<World, "files" | "registry" | "repo">, entries: readonly ReleaseEntry[], tagged: ReadonlySet<string>): Promise<PublishPlan>

The releases of the record that are not tagged yet and go to npm, as the plan: each with its tarball, or why it cannot be sent.

logical.gatefunctionno test imports it
function gate(input: { readonly token: Secret | undefined; readonly typed: string | undefined; readonly phrase: string; }): readonly Finding[]

Whether the publication may go on: the token is there and the typed phrase is the plan's. The reasons otherwise.

logical.npmrcTextfunctionno test imports it
function npmrcText(token: Secret): string

The text of the private npmrc: the one line that gives npm the credential for the registry. It is written only to a file of mode 0600 in a folder that is removed.

logical.runPublishfunctionno test imports it
function runPublish(w: Pick<World, "files" | "process" | "repo">, plan: PublishPlan, token: Secret): Promise<readonly Published[]>

Publishes what the plan says is ready, one release at a time, and gives what happened to each. Nothing it reports holds the token.

logical.findingsOfPublishfunctionno test imports it
function findingsOfPublish(done: readonly Published[]): readonly Finding[]

The findings of a publication: a release that failed or could not be tried.

logical.STAGED_NOTEconstno test imports it
const STAGED_NOTE: "npm stages a version published by hand for about an hour: `repoctl status` lists it once npm shows it, and the release workflow makes the tags"

What is said of the versions that were sent: npm stages a hand publish for about an hour, so status may not list it at once; nothing says it is live.

ReleaseEntrytype
type ReleaseEntry = { readonly slug: string; readonly package: string; readonly version: string; readonly folder: string; readonly tag: string; readonly publish: boolean };

One release of the record: a library, its version, its folder and its tag, and whether it goes to npm.

Imported by 14 tests of the run (14 passed, 0 failed): the library's results

Itemtypeno test imports it
type Item =
  | { readonly kind: "ready"; readonly entry: ReleaseEntry; readonly tarball: string }
  | { readonly kind: "present"; readonly entry: ReleaseEntry }
  | { readonly kind: "no-tarball"; readonly entry: ReleaseEntry; readonly tarball: string }
  | { readonly kind: "unknown"; readonly entry: ReleaseEntry; readonly why: string };

What is to happen to one release.

PublishPlantypeno test imports it
type PublishPlan = { readonly items: readonly Item[]; readonly phrase: string };

The plan of a publication: what each release comes to, and the phrase that confirms it.

Publishedtypeno test imports it
type Published =
  | { readonly kind: "published"; readonly entry: ReleaseEntry }
  | { readonly kind: "present"; readonly entry: ReleaseEntry }
  | { readonly kind: "failed"; readonly entry: ReleaseEntry; readonly detail: readonly string[] }
  | { readonly kind: "not-run"; readonly entry: ReleaseEntry; readonly why: string };

What happened to one release.

tarballPathfunction
function tarballPath(repo: string, e: ReleaseEntry): string

The absolute path of the tarball the packer makes for a release: dist/<scope>-<package>-<version>.tgz in the library's folder.

Imported by 14 tests of the run (14 passed, 0 failed): the library's results

confirmationPhrasefunction
function confirmationPhrase(entries: readonly ReleaseEntry[]): string

The phrase that confirms a publication: the word, how many packages go, and the start of a digest of which (publish 3 1a2b3c4d), so that what was reviewed is what is sent.

Imported by 14 tests of the run (14 passed, 0 failed): the library's results

planPublishfunction
function planPublish(w: Pick<World, "files" | "registry" | "repo">, entries: readonly ReleaseEntry[], tagged: ReadonlySet<string>): Promise<PublishPlan>

The releases of the record that are not tagged yet and go to npm, as the plan: each with its tarball, or why it cannot be sent.

Imported by 14 tests of the run (14 passed, 0 failed): the library's results

gatefunction
function gate(input: { readonly token: Secret | undefined; readonly typed: string | undefined; readonly phrase: string; }): readonly Finding[]

Whether the publication may go on: the token is there and the typed phrase is the plan's. The reasons otherwise.

Imported by 14 tests of the run (14 passed, 0 failed): the library's results

npmrcTextfunction
function npmrcText(token: Secret): string

The text of the private npmrc: the one line that gives npm the credential for the registry. It is written only to a file of mode 0600 in a folder that is removed.

Imported by 14 tests of the run (14 passed, 0 failed): the library's results

runPublishfunctionno test imports it
function runPublish(w: Pick<World, "files" | "process" | "repo">, plan: PublishPlan, token: Secret): Promise<readonly Published[]>

Publishes what the plan says is ready, one release at a time, and gives what happened to each. Nothing it reports holds the token.

findingsOfPublishfunctionno test imports it
function findingsOfPublish(done: readonly Published[]): readonly Finding[]

The findings of a publication: a release that failed or could not be tried.

STAGED_NOTEconst
const STAGED_NOTE: "npm stages a version published by hand for about an hour: `repoctl status` lists it once npm shows it, and the release workflow makes the tags"

What is said of the versions that were sent: npm stages a hand publish for about an hour, so status may not list it at once; nothing says it is live.

Imported by 14 tests of the run (14 passed, 0 failed): the library's results

Titles, headings, exports, tables, columns and requirements. Esc closes.