IF Commons GitHub

logical/hygiene-facts

Written to: 1 requirement: 1 proved, 0 partly, 0 failing, 0 with no test recorded. 0007-repoctl-hygiene FR-003

The facts of a repository for the hygiene check, gathered through the ports (commons repoctl 0007-repoctl-hygiene FR-003; commons 0036-distribution FR-011): the lockfiles read as data (bun.lock is JSON with comments and trailing commas, package-lock.json is JSON of lockfile versions 2 and 3), the package.json files outside node_modules, the packages installed under node_modules (a folder of the scope, nested ones and Bun's .bun store) and the relative imports of the sources. The parsers are pure; only gatherHygieneFacts of this module reads, and only through Files.

import { parseNpmLock } from "./hygiene-facts.ts";
const r = parseNpmLock('{ "packages": { "node_modules/@intellectual-frontiers/core": { "version": "0.1.5" } } }', "package-lock.json");
r.kind; // "read"

Source: commons/repoctl/src/logical/hygiene-facts.ts

5 of 14 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.stripJsoncfunctionno test imports it
function stripJsonc(text: string): string

The text of a JSON with comments and trailing commas as JSON: comments and the commas before } and ] are removed, and strings are left as they are.

logical.parseBunLockfunctionno test imports it
function parseBunLock(source: string, file: string, scope: string): LockFacts

The copies of the packages of commons a bun.lock holds: each entry of packages is [ "name@version", ... ] under a key that says where it is nested.

logical.parseNpmLockfunctionno test imports it
function parseNpmLock(source: string, file: string, scope: string): LockFacts

The copies of the packages of commons a package-lock.json (versions 2 and 3: packages keyed by path) holds.

logical.parsePackagefunctionno test imports it
function parsePackage(source: string, path: string): Result<{ readonly facts: PackageFacts; readonly workspaces: readonly string[]; }, string>

The facts of one package.json's text: its name and its dependencies of every section; the workspaces it declares are the second part.

logical.relativeImportsfunctionno test imports it
function relativeImports(source: string): readonly string[]

The relative specifiers a source imports, with the specifier as written.

logical.IGNORED_FOLDERSconstno test imports it
const IGNORED_FOLDERS: readonly string[]

The folders that hold only what is made or fetched, never read for a lockfile or a package: a path with one of these segments is left out. node_modules is never walked at all.

logical.gatherHygieneFactsfunctionno test imports it
function gatherHygieneFacts(w: Pick<World, "files" | "repo">, policy: HygienePolicy): Promise<HygieneFacts>

Gathers the facts of the repository of a world: the only reads of the check. Every folder with a package.json is a tree of its own, with the lockfiles next to it and its own node_modules.

stripJsoncfunction
function stripJsonc(text: string): string

The text of a JSON with comments and trailing commas as JSON: comments and the commas before } and ] are removed, and strings are left as they are.

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

parseBunLockfunction
function parseBunLock(source: string, file: string, scope: string): LockFacts

The copies of the packages of commons a bun.lock holds: each entry of packages is [ "name@version", ... ] under a key that says where it is nested.

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

parseNpmLockfunction
function parseNpmLock(source: string, file: string, scope: string): LockFacts

The copies of the packages of commons a package-lock.json (versions 2 and 3: packages keyed by path) holds.

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

parsePackagefunctionno test imports it
function parsePackage(source: string, path: string): Result<{ readonly facts: PackageFacts; readonly workspaces: readonly string[]; }, string>

The facts of one package.json's text: its name and its dependencies of every section; the workspaces it declares are the second part.

relativeImportsfunction
function relativeImports(source: string): readonly string[]

The relative specifiers a source imports, with the specifier as written.

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

IGNORED_FOLDERSconstno test imports it
const IGNORED_FOLDERS: readonly string[]

The folders that hold only what is made or fetched, never read for a lockfile or a package: a path with one of these segments is left out. node_modules is never walked at all.

gatherHygieneFactsfunction
function gatherHygieneFacts(w: Pick<World, "files" | "repo">, policy: HygienePolicy): Promise<HygieneFacts>

Gathers the facts of the repository of a world: the only reads of the check. Every folder with a package.json is a tree of its own, with the lockfiles next to it and its own node_modules.

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

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