IF Commons GitHub

logical/constants

Written to: 1 requirement: 1 proved, 0 partly, 0 failing, 0 with no test recorded. 0003-repoctl-sync FR-008

The constants of the sources that say a library's version (commons repoctl 0003-repoctl-sync FR-008): a constant named for its library (ERGONEX_VERSION of ergonex), or named by the manifest in versionConstants, must say the version of its package. A release that raised the manifest and the package and left such a constant behind broke a build at one release; this finds it before the push. Pure: it reads texts it is given.

import { constantFindings } from "./constants.ts";
const lib = { name: "ergonex", folder: "commons/ergonex", version: "0.4.7", level: "L1", specKit: undefined, npm: true, versionConstants: [] };
constantFindings([lib], [{ path: "commons/ergonex/src/state-record.ts", text: 'export const ERGONEX_VERSION = "0.4.6";' }]).length; // 1

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

3 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.VersionConstanttypeno test imports it
type VersionConstant = { readonly file: string; readonly name: string };

A constant of a library's sources that holds its version: the file from the library's folder and the constant's name.

logical.Sourcetypeno test imports it
type Source = { readonly path: string; readonly text: string };

A source file: its path from the repository's root and its text.

logical.Foundtypeno test imports it
type Found = { readonly path: string; readonly name: string; readonly value: string; readonly line: number };

One NAME_VERSION = "text" found in a source, and the line it is on.

logical.constantsInfunctionno test imports it
function constantsIn(source: Source): readonly Found[]

Every constant of a source that ends in _VERSION and is a text.

logical.conventionNamefunctionno test imports it
function conventionName(library: string): string

The name a library's own version constant has by convention: its name in capitals, hyphens as underscores, and _VERSION.

logical.isReadfunctionno test imports it
function isRead(library: LibraryInfo, path: string): boolean

The sources of a library that are read for constants: the TypeScript under its src/, and the files its manifest names.

logical.constantFindingsfunctionno test imports it
function constantFindings(libraries: readonly LibraryInfo[], sources: readonly Source[]): readonly Finding[]

What is wrong with the constants of the libraries' sources: one that disagrees with its library's version, one the manifest names that is not there, one that is not a version.

VersionConstanttypeno test imports it
type VersionConstant = { readonly file: string; readonly name: string };

A constant of a library's sources that holds its version: the file from the library's folder and the constant's name.

Sourcetypeno test imports it
type Source = { readonly path: string; readonly text: string };

A source file: its path from the repository's root and its text.

Foundtypeno test imports it
type Found = { readonly path: string; readonly name: string; readonly value: string; readonly line: number };

One NAME_VERSION = "text" found in a source, and the line it is on.

constantsInfunction
function constantsIn(source: Source): readonly Found[]

Every constant of a source that ends in _VERSION and is a text.

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

conventionNamefunction
function conventionName(library: string): string

The name a library's own version constant has by convention: its name in capitals, hyphens as underscores, and _VERSION.

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

isReadfunctionno test imports it
function isRead(library: LibraryInfo, path: string): boolean

The sources of a library that are read for constants: the TypeScript under its src/, and the files its manifest names.

constantFindingsfunction
function constantFindings(libraries: readonly LibraryInfo[], sources: readonly Source[]): readonly Finding[]

What is wrong with the constants of the libraries' sources: one that disagrees with its library's version, one the manifest names that is not there, one that is not a version.

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

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