IF Commons GitHub

dev

The development loop (commons 0001-libraries FR-011, FR-012): the libraries a working tree changes, and the libraries that depend on them, type-checked and tested in parallel processes and no more than they need, with a calm summary. It is what a person or an agent runs between two edits; the release loop (the packing of every library, the register, the versions) is another command and is never part of this one.

bun run dev:check the libraries affected since origin/main (and the files not yet committed), their types and their tests bun run dev:check --only system,net those libraries and their dependents, whatever changed bun run dev:check --files a.ts,b/c.ts the libraries these files affect (paths from the repository's root) bun run dev:check --all every library bun run dev:check --list say what is affected and run nothing other flags: --base REF (origin/main by default), --no-types, --no-tests, --no-license, --bail (stop at the first failing test), --repo DIR

Nothing is installed per library. The repository's root installs the packages every library shares (bun install, once), the libraries are linked under commons/node_modules (a link for each folder whose package name is @intellectual-frontiers/<folder>), so that a library that imports another by its package name reads the checkout's source, never a copy from a registry: the exports of each package are the sources. A library with a package of its own outside the shared set (a database driver) is installed in its folder, once. The affected libraries are those of affected.ts (the same code the workflow of CI runs); TypeScript 7 checks each library's own tsconfig.json, several at a time, and the tests of each run in a bun test process of its own, from its folder as verify runs them, several at a time.

import { bunCounts } from "./dev.ts";
bunCounts(" 913 pass\n 3 skip\n 0 fail\nRan 917 tests across 141 files. [55.88s]\n"); // { pass: 913, skip: 3, fail: 0, files: 141 }

Spec: 0001-libraries FR-011

Source: commons/libraries/src/dev.ts

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

Scopetypeno test imports it
type Scope =
  | { readonly kind: "since"; readonly base: string }
  | { readonly kind: "files"; readonly files: readonly string[] }
  | { readonly kind: "only"; readonly names: readonly string[] }
  | { readonly kind: "all" };

What the loop is asked about: what changed since a revision, a list of files, named libraries or everything.

Libtypeno test imports it
type Lib = Library & { readonly folder: string };

A library of the repository with its folder, as affected.ts gives it.

Countstypeno test imports it
type Counts = { readonly pass: number; readonly skip: number; readonly fail: number; readonly files: number };

The counts of one bun test run.

bunCountsfunction
function bunCounts(text: string): Counts | undefined

The counts in the end of what bun test printed, or undefined where it printed none.

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

failureLinesfunction
function failureLines(text: string): readonly string[]

The lines of bun test's output that say what failed: the failing tests and the error lines above each, in order.

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

headfunction
function head(lines: readonly string[], n: number): readonly string[]

The first lines of a compiler's output, so a long one does not bury the summary.

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

ownPackagesfunction
function ownPackages(pkg: Readonly<Record<string, unknown>>, shared: ReadonlySet<string>): readonly string[]

The packages a library declares that neither are libraries of the repository nor are installed at the root: the ones it must install itself.

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

linkLibrariesfunction
function linkLibraries(repo: string): Result<number, string>

Links the libraries under commons/node_modules where they are not linked yet (link.ts, which bun run dev:check runs before this command can import any of them).

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

defaultBasefunctionno test imports it
function defaultBase(repo: string): Promise<string>

The revision a loop compares with where none is given: origin/main, else main, else HEAD (the working tree alone).

affectedOffunction
function affectedOf(repo: string, scope: Scope): Promise<Result<{ readonly libs: readonly Lib[]; readonly why: string; }, string>>

What a scope affects: the libraries and why, or why it cannot be said.

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

poolfunction
function pool<T, R>(items: readonly T[], width: number, job: (item: T) => Promise<R>): Promise<readonly R[]>

Runs job over items, at most width at a time, and gives the results in the order of the items.

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

preparefunctionno test imports it
function prepare(repo: string, libs: readonly Lib[]): Promise<Result<readonly string[], string>>

What the loop needs installed: the root's packages, the links, and the packages of a library that has its own.

typeCheckfunctionno test imports it
function typeCheck(repo: string, libs: readonly Lib[], width: number): Promise<Outcome>

TypeScript on the libraries, several at a time.

licenseStagefunctionno test imports it
function licenseStage(repo: string): Promise<Outcome>

The license of the repository and of each library, as the check of license.ts finds it: a library with no LICENSE fails here, and the sentence says the command that writes it.

addCountsconst
const addCounts: (a: Counts, b: Counts) => Counts

The sum of counts.

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

runTestsfunctionno test imports it
function runTests(repo: string, libs: readonly Lib[], width: number, bail: boolean): Promise<Outcome>

The tests of the libraries: one bun test suite/ process for each library, from its folder as its verify runs it, several at a time and the largest suites first. One process for all of them would be fewer, but a test may set what is global to its process (the tracer of a process, a working folder), and what it sets must not reach the tests of another library.

summaryLinesfunction
function summaryLines(look: Look, what: { readonly why: string; readonly libs: readonly string[]; }, stages: readonly { readonly name: string; readonly outcome: Outcome; }[], notes: readonly string[], took: string): readonly string[]

The summary the loop prints: one line for what it looked at, one for each stage, and what failed under it.

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

repoRootOffunction
function repoRootOf(from: string): string | undefined

The root of the repository that holds from: the nearest folder above it that has commons/libraries/library.ts.

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

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