IF Commons GitHub

logical/usage

Written to: 4 requirements: 4 proved, 0 partly, 0 failing, 0 with no test recorded. 0014-repoctl-usage FR-001, 0014-repoctl-usage FR-002, 0014-repoctl-usage FR-003, 0014-repoctl-usage FR-004

What a consumer uses of the package @intellectual-frontiers/commons (commons repoctl 0014-repoctl-usage; commons 0036-distribution FR-034): the libraries a repository imports and with which subpaths, read from its own files; the graph of the package, read from the sources of the installed copy (which library imports which, the files and bytes of each); and the answer, a pure function of the two: the libraries imported directly, those reached only through the imports of those, and those never touched, with their sizes.

The answer is the same for the same inputs and is in the order of the names of the libraries. A library the repository imports that the package does not hold is a finding and is not counted; a library reached by two paths names the one through which it is reached first, in the order of the names.

import { consumerImports, usageOf } from "./usage.ts";
consumerImports('import { ok } from "@intellectual-frontiers/commons/core";', "a.ts", "@intellectual-frontiers/commons");
// [{ library: "core", subpath: undefined, file: "a.ts" }]

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

5 of 20 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.ConsumerImporttypeno test imports it
type ConsumerImport = { readonly library: string; readonly subpath: string | undefined; readonly file: string };

One import of a library of the package by a file of the consumer.

logical.PackageLibrarytypeno test imports it
type PackageLibrary = { readonly name: string; readonly imports: readonly string[]; readonly files: number; readonly bytes: number };

A library of the package: the libraries its sources import, its files and its bytes.

logical.consumerImportsfunctionno test imports it
function consumerImports(text: string, file: string, packageName: string): readonly ConsumerImport[]

The libraries a file imports from the package: each specifier <package>/<library>[/<subpath>]; the bare package names no library and is left out.

logical.libraryImportsfunctionno test imports it
function libraryImports(text: string, self: string, packageName: string, known: ReadonlySet<string>): readonly string[]

The libraries of the package that a source imports: the specifiers <package>/<library>... (and @intellectual-frontiers/<library>... as the sources of a library write them), other than the library itself.

logical.Directtypeno test imports it
type Direct = { readonly library: string; readonly subpaths: readonly string[]; readonly files: number; readonly bytes: number };

What the repository imports of one library.

logical.Reachedtypeno test imports it
type Reached = { readonly library: string; readonly via: string; readonly bytes: number };

A library the repository reaches only through others.

logical.Untouchedtypeno test imports it
type Untouched = { readonly library: string; readonly bytes: number };

A library the repository never touches.

logical.UsageReporttypeno test imports it
type UsageReport = { readonly package: string; readonly libraries: number; readonly bytes: number; readonly dire… (607 characters)
type UsageReport = {
  readonly package: string;
  readonly libraries: number;
  readonly bytes: number;
  readonly direct: readonly Direct[];
  readonly reached: readonly Reached[];
  readonly untouched: readonly Untouched[];
  readonly totals: {
    readonly direct: { readonly libraries: number; readonly bytes: number };
    readonly reached: { readonly libraries: number; readonly bytes: number };
    readonly untouched: { readonly libraries: number; readonly bytes: number };
  };
  /** The libraries the repository imports that the package does not hold. */
  readonly unknown: readonly string[];
};

The answer.

logical.usageOffunctionno test imports it
function usageOf(packageName: string, imports: readonly ConsumerImport[], graph: readonly PackageLibrary[]): UsageReport

The answer for the imports of a repository and the graph of a package.

logical.usageTextfunctionno test imports it
function usageText(r: UsageReport): string

The answer as text: the three groups with their sizes, and the libraries of each.

ConsumerImporttypeno test imports it
type ConsumerImport = { readonly library: string; readonly subpath: string | undefined; readonly file: string };

One import of a library of the package by a file of the consumer.

PackageLibrarytype
type PackageLibrary = { readonly name: string; readonly imports: readonly string[]; readonly files: number; readonly bytes: number };

A library of the package: the libraries its sources import, its files and its bytes.

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

consumerImportsfunction
function consumerImports(text: string, file: string, packageName: string): readonly ConsumerImport[]

The libraries a file imports from the package: each specifier <package>/<library>[/<subpath>]; the bare package names no library and is left out.

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

libraryImportsfunction
function libraryImports(text: string, self: string, packageName: string, known: ReadonlySet<string>): readonly string[]

The libraries of the package that a source imports: the specifiers <package>/<library>... (and @intellectual-frontiers/<library>... as the sources of a library write them), other than the library itself.

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

Directtypeno test imports it
type Direct = { readonly library: string; readonly subpaths: readonly string[]; readonly files: number; readonly bytes: number };

What the repository imports of one library.

Reachedtypeno test imports it
type Reached = { readonly library: string; readonly via: string; readonly bytes: number };

A library the repository reaches only through others.

Untouchedtypeno test imports it
type Untouched = { readonly library: string; readonly bytes: number };

A library the repository never touches.

UsageReporttypeno test imports it
type UsageReport = { readonly package: string; readonly libraries: number; readonly bytes: number; readonly dire… (607 characters)
type UsageReport = {
  readonly package: string;
  readonly libraries: number;
  readonly bytes: number;
  readonly direct: readonly Direct[];
  readonly reached: readonly Reached[];
  readonly untouched: readonly Untouched[];
  readonly totals: {
    readonly direct: { readonly libraries: number; readonly bytes: number };
    readonly reached: { readonly libraries: number; readonly bytes: number };
    readonly untouched: { readonly libraries: number; readonly bytes: number };
  };
  /** The libraries the repository imports that the package does not hold. */
  readonly unknown: readonly string[];
};

The answer.

usageOffunction
function usageOf(packageName: string, imports: readonly ConsumerImport[], graph: readonly PackageLibrary[]): UsageReport

The answer for the imports of a repository and the graph of a package.

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

usageTextfunction
function usageText(r: UsageReport): string

The answer as text: the three groups with their sizes, and the libraries of each.

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

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