# runtime/entrypoints/inventory.entrypoint.ts

> 23 lines of code and 7 definitions.

Tree: Bane's Lab Content
Language: typescript
Layer: runtime
Canonical: https://banes-lab.com/anatomy/content#file-content-runtime-entrypoints-inventory-entrypoint-ts
Source text: https://banes-lab.com/source/content/runtime/entrypoints/inventory.entrypoint.ts.txt

Listed in [runtime/entrypoints](https://banes-lab.com/api/source/content/runtime/entrypoints.md), after [runtime/entrypoints/coverage.entrypoint.ts](https://banes-lab.com/source/content/runtime/entrypoints/coverage.entrypoint.ts.md) and before [runtime/entrypoints/leak.entrypoint.ts](https://banes-lab.com/source/content/runtime/entrypoints/leak.entrypoint.ts.md).

## Definitions

- `sources` (lexical_declaration, line 13)
- `inventorySources` (lexical_declaration, line 14)
- `records` (lexical_declaration, line 15)
- `found` (lexical_declaration, line 16)
- `lines` (lexical_declaration, line 17)
- `inventory` (lexical_declaration, line 23)
- `target` (lexical_declaration, line 24)

## Contained in

- [runtime/entrypoints](https://banes-lab.com/anatomy/content/folder-content-runtime-entrypoints.md)

## Source

```typescript
import type { Inventory, InventorySource } from "#types/inventory.types";
import { LINES_SUFFIX, READ_SOURCE, RECORDS_SUFFIX, WROTE } from "#configuration/strings/derivation.strings";
import { inventoryTarget, readInventorySources } from "#core/loaders/inventory.loader";
import { lineCount, scanRules } from "#core/converters/inventory.converter";
import { INVENTORY_COMMAND } from "#configuration/constants/contract.constants";
import { INVENTORY_SUMMARY } from "#configuration/strings/contract.strings";
import { persistJson } from "#core/persistence/report.persistence";
import { resolveArgv } from "@govlab/argv";
import { say } from "#core/reporters/derivation.reporter";

resolveArgv({ command: INVENTORY_COMMAND, flags: [], summary: INVENTORY_SUMMARY });

const sources = await readInventorySources();
const inventorySources: InventorySource[] = [];
const records = sources.flatMap((source) => {
    const found = scanRules(source.text, source.path);
    const lines = lineCount(source.text);
    inventorySources.push({ lines, path: source.path, records: found.length });
    say(`${READ_SOURCE}${source.path}: ${String(lines)}${LINES_SUFFIX}${String(found.length)}${RECORDS_SUFFIX}`);
    return found;
});

const inventory: Inventory = { records, sources: inventorySources };
const target = inventoryTarget();
await persistJson(target, inventory);
say(`${WROTE}${target}`);
```
