test-inventory 0.4.1 → 0.5.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,90 @@
1
+ import type { ModuleReader, Span } from './model.ts';
2
+ import { type ParsedFile } from './parse.ts';
3
+ import type { ConfigRecord, Diagnostic, Framework, ProjectRecord } from './types.ts';
4
+ import { Values } from './values.ts';
5
+ /** A file a config is read from: the config itself, or a module it imports settings from, at `file`. */
6
+ interface ConfigFrame {
7
+ parsed: ParsedFile;
8
+ values: Values;
9
+ relativeFilePath: string;
10
+ file: string;
11
+ readModule: ModuleReader;
12
+ }
13
+ /** Where an expression is written. */
14
+ interface Site {
15
+ frame: ConfigFrame;
16
+ node: Span;
17
+ }
18
+ /** A setting the scan can't work out without running the config. `where` is null for a config it couldn't read at all. */
19
+ export interface Unknown {
20
+ kind: 'unknown';
21
+ where: Site | null;
22
+ }
23
+ /**
24
+ * A config setting: a value, an object or a list of settings, or one the scan can't work out. An object's `rest` is a
25
+ * spread the scan can't work out, which may set any key not written after it.
26
+ */
27
+ export type Setting = {
28
+ kind: 'value';
29
+ value: string | number | boolean | null | undefined;
30
+ } | {
31
+ kind: 'regex';
32
+ source: string;
33
+ flags: string;
34
+ } | ObjectSetting | {
35
+ kind: 'list';
36
+ items: Setting[];
37
+ } | Unknown;
38
+ export interface ObjectSetting {
39
+ kind: 'object';
40
+ keys: Map<string, Setting>;
41
+ rest: Unknown | null;
42
+ }
43
+ /** The source text of a setting the scan can't work out; null for one of a config it couldn't read at all. */
44
+ export declare function unknownText(setting: Unknown): string | null;
45
+ /** The setting under a path of keys, such as `['test', 'globals']`; null when the config doesn't set it. */
46
+ export declare function settingAt(setting: Setting, keys: readonly string[]): Setting | null;
47
+ /**
48
+ * Vite's `mergeConfig(base, over)`: objects merge key by key, lists are joined with a single setting taken as a list
49
+ * of one, and `null` or `undefined` keeps the other side.
50
+ */
51
+ export declare function mergeDeep(base: Setting, over: Setting): Setting;
52
+ /** The config a scanned file uses, read once however many files use it. */
53
+ export interface ConfigFile {
54
+ /** The config's absolute path. */
55
+ file: string;
56
+ record: Omit<ConfigRecord, 'projects'>;
57
+ settings: Setting;
58
+ }
59
+ /** Finds and reads the configs of one scan, and collects what it can't work out in them as diagnostics. */
60
+ export declare class Configs {
61
+ readonly diagnostics: Diagnostic[];
62
+ private readonly root;
63
+ private readonly framework;
64
+ private readonly readerFor;
65
+ private readonly inFolders;
66
+ private readonly files;
67
+ private readonly used;
68
+ private readonly reported;
69
+ private readonly version;
70
+ constructor(root: string, framework: Framework, readerFor: (fromFile: string) => ModuleReader, version: [number, number] | null);
71
+ /**
72
+ * The configs in a file's folder and the folders above it, up to the root, outermost first: in each folder, the one
73
+ * the runner started there would use.
74
+ */
75
+ around(file: string): ConfigFile[];
76
+ /** The config at a path, read once however many files or projects refer to it. */
77
+ at(file: string): ConfigFile;
78
+ /** A path from the root, with `/` separators; `.` for the root itself. */
79
+ relative(file: string): string;
80
+ /** Lists a config in the output, as one that scanned files use. */
81
+ use(config: ConfigFile): void;
82
+ /** The configs that scanned files use, sorted by path, with the projects `projectsOf` gives each. */
83
+ records(projectsOf: (config: ConfigFile) => ProjectRecord[] | null): ConfigRecord[];
84
+ /** Reports a setting the scan reads but can't work out, once; `key` names it, and `effect` says what the scan does. */
85
+ reportUnknown(setting: Unknown, key: string, effect: string): void;
86
+ /** The config the runner started in a folder would use; null when the folder has none. */
87
+ inFolder(folder: string): ConfigFile | null;
88
+ private read;
89
+ }
90
+ export {};