COMMANDconstconst COMMAND: "bun commons/libraries/src/license.ts"The command that writes what the check finds wrong.
The license of the repository and of every library in it, written and checked from one place (commons 0035-licensing). One official text, the PolyForm Noncommercial License 1.0.0 (license/PolyForm-Noncommercial-1.0.0.md, held to the SHA-256 of its standard), and one Required Notice: line for the licensor make the LICENSE of the root and of each library folder; the third-party notices are made from the record of what is vendored.
bun commons/libraries/src/license.ts write every LICENSE and THIRD_PARTY_NOTICES.md again bun commons/libraries/src/license.ts --check write nothing and exit 1 where any file is not what the manifests and the official text make other flags: --repo DIR (the repository, the working folder by default)
What is written: LICENSE at the root and in each commons/<name>/ that holds a manifest (library.ts), and THIRD_PARTY_NOTICES.md. What is only checked, because a person writes it: LICENSING.md, COMMERCIAL.md, NOTICE, CONTRIBUTING.md, CITATION.cff, the License section of README.md and the license of the root package.json. A library with a folder and no LICENSE is a finding that names the command above, so a new library runs it once. The packer writes the same identifier into the package.json it publishes (licenseOf).
import { licenseFileText } from "./license.ts";
licenseFileText("TEXT\n").startsWith("Required Notice: Copyright Intellectual Frontiers LLC"); // trueSpec: 0001-libraries FR-019
COMMANDconstconst COMMAND: "bun commons/libraries/src/license.ts"The command that writes what the check finds wrong.
licenseOffunctionfunction licenseOf(library: Pick<Library, "license"> | undefined): "PolyForm-Noncommercial-1.0.0"The license of a library: its manifest's license, else the default of the repository.
REQUIRED_NOTICEconstconst REQUIRED_NOTICE: "Required Notice: Copyright Intellectual Frontiers LLC (https://github.com/intellectual-frontiers/.github)"The line every LICENSE begins with, as the license asks of its licensor (its section Notices).
licenseFileTextfunctionfunction licenseFileText(official: string): stringThe text of a LICENSE: the required notice, a blank line and the official text exactly as it is.
sentencefunctionfunction sentence(f: Finding): stringThe one sentence of a finding.
Madetypeno test imports ittype Made = { readonly path: string; readonly text: string };A file this module writes: its path from the repository and its whole text.
officialTextfunctionfunction officialText(id: "PolyForm-Noncommercial-1.0.0", folder?: string): Promise<Result<string, Finding>>The official text of a license, held to the SHA-256 of its standard.
thirdPartyNoticesfunctionfunction thirdPartyNotices(items: readonly ThirdPartyItem[]): stringTHIRD_PARTY_NOTICES.md made from the items.
Judgedtypeno test imports ittype Judged = { readonly made: readonly Made[]; readonly findings: readonly Finding[] };The result of looking at a repository: what it should hold and what is wrong.
judgefunctionfunction judge(repo: string, folder?: string | undefined): Promise<Judged>The files this module makes for a repository and what is wrong with the rest, read from the files and the manifests; nothing is written.